OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/extensions/api/messaging/native_process_launcher.h" | 5 #include "chrome/browser/extensions/api/messaging/native_process_launcher.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/posix/eintr_wrapper.h" | 10 #include "base/posix/eintr_wrapper.h" |
11 #include "base/process_util.h" | 11 #include "base/process_util.h" |
12 #include "chrome/browser/extensions/api/messaging/native_messaging_host_manifest .h" | |
12 | 13 |
13 namespace extensions { | 14 namespace extensions { |
14 | 15 |
16 namespace { | |
17 | |
18 const char kNativeMessagingDirectory[] = | |
19 #if defined(OS_MAXOSX) | |
Nico
2013/03/20 04:04:27
OS_MAXOSX should be OS_MACOSX (note C instead of X
Sergey Ulanov
2013/03/20 04:25:15
Thanks for catching and fixing it!
Nico
2013/03/20 04:42:51
Sounds good. The master prefs file is right in /Li
| |
20 "/Library/Chrome/NativeMessagingHosts"; | |
21 #else | |
22 "/etc/opt/chrome/native-messaging-hosts"; | |
23 #endif | |
24 | |
25 } // namespace | |
26 | |
27 // static | |
28 scoped_ptr<NativeMessagingHostManifest> | |
29 NativeProcessLauncher::FindAndLoadManifest( | |
30 const std::string& native_host_name, | |
31 std::string* error_message) { | |
32 base::FilePath manifest_path = | |
33 base::FilePath(kNativeMessagingDirectory).Append( | |
34 native_host_name + ".json"); | |
35 return NativeMessagingHostManifest::Load(manifest_path, error_message); | |
36 } | |
37 | |
15 // static | 38 // static |
16 bool NativeProcessLauncher::LaunchNativeProcess( | 39 bool NativeProcessLauncher::LaunchNativeProcess( |
17 const base::FilePath& path, | 40 const base::FilePath& path, |
18 base::PlatformFile* read_file, | 41 base::PlatformFile* read_file, |
19 base::PlatformFile* write_file) { | 42 base::PlatformFile* write_file) { |
20 base::FileHandleMappingVector fd_map; | 43 base::FileHandleMappingVector fd_map; |
21 | 44 |
22 int read_pipe_fds[2] = {0}; | 45 int read_pipe_fds[2] = {0}; |
23 if (HANDLE_EINTR(pipe(read_pipe_fds)) != 0) { | 46 if (HANDLE_EINTR(pipe(read_pipe_fds)) != 0) { |
24 LOG(ERROR) << "Bad read pipe"; | 47 LOG(ERROR) << "Bad read pipe"; |
(...skipping 25 matching lines...) Expand all Loading... | |
50 write_pipe_read_fd.reset(); | 73 write_pipe_read_fd.reset(); |
51 read_pipe_write_fd.reset(); | 74 read_pipe_write_fd.reset(); |
52 | 75 |
53 *read_file = *read_pipe_read_fd.release(); | 76 *read_file = *read_pipe_read_fd.release(); |
54 *write_file = *write_pipe_write_fd.release(); | 77 *write_file = *write_pipe_write_fd.release(); |
55 | 78 |
56 return true; | 79 return true; |
57 } | 80 } |
58 | 81 |
59 } // namespace extensions | 82 } // namespace extensions |
OLD | NEW |