Skip to content
This repository has been archived by the owner on Jan 4, 2019. It is now read-only.

read from Chrome native messaging host file #259

Merged
merged 1 commit into from
Jul 19, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions atom/app/atom_main_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,38 @@ base::FilePath InitializeUserDataDir() {
}
PathService::Override(chrome::DIR_USER_DATA, user_data_dir);

// Setup NativeMessagingHosts to point to the default Chrome locations
// because that's where native apps will create them
#if defined(OS_POSIX)
base::FilePath default_user_data_dir;
brave::GetDefaultUserDataDirectory(&default_user_data_dir);
std::vector<base::FilePath::StringType> components;
default_user_data_dir.GetComponents(&components);
// remove "brave"
components.pop_back();
base::FilePath chrome_user_data_dir(FILE_PATH_LITERAL("/"));
for (std::vector<base::FilePath::StringType>::iterator i =
components.begin() + 1; i != components.end(); ++i) {
chrome_user_data_dir = chrome_user_data_dir.Append(*i);
}
chrome_user_data_dir = chrome_user_data_dir.Append("Google/Chrome");
PathService::OverrideAndCreateIfNeeded(
chrome::DIR_USER_NATIVE_MESSAGING,
chrome_user_data_dir.Append(FILE_PATH_LITERAL("NativeMessagingHosts")),
false, true);

base::FilePath native_messaging_dir;
#if defined(OS_MACOSX)
native_messaging_dir = base::FilePath(FILE_PATH_LITERAL(
"/Library/Google/Chrome/NativeMessagingHosts"));
#else
native_messaging_dir = base::FilePath(FILE_PATH_LITERAL(
"/etc/opt/chrome/native-messaging-hosts"));
#endif // !defined(OS_MACOSX)
PathService::OverrideAndCreateIfNeeded(chrome::DIR_NATIVE_MESSAGING,
native_messaging_dir, false, true);
#endif // defined(OS_POSIX)

return user_data_dir;
}

Expand Down