| 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 #ifndef CHROME_BROWSER_EXTENSIONS_API_MESSAGING_NATIVE_PROCESS_LAUNCHER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_MESSAGING_NATIVE_PROCESS_LAUNCHER_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_MESSAGING_NATIVE_PROCESS_LAUNCHER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_MESSAGING_NATIVE_PROCESS_LAUNCHER_H_ |
| 7 | 7 |
| 8 #include "base/callback_forward.h" | 8 #include "base/callback_forward.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/platform_file.h" | 10 #include "base/platform_file.h" |
| 11 #include "base/process/process.h" | 11 #include "base/process/process.h" |
| 12 #include "ui/gfx/native_widget_types.h" |
| 12 | 13 |
| 13 class CommandLine; | 14 class CommandLine; |
| 14 class GURL; | 15 class GURL; |
| 15 | 16 |
| 16 namespace base { | 17 namespace base { |
| 17 class FilePath; | 18 class FilePath; |
| 18 } | 19 } |
| 19 | 20 |
| 20 namespace extensions { | 21 namespace extensions { |
| 21 | 22 |
| 22 class NativeProcessLauncher { | 23 class NativeProcessLauncher { |
| 23 public: | 24 public: |
| 24 enum LaunchResult { | 25 enum LaunchResult { |
| 25 RESULT_SUCCESS, | 26 RESULT_SUCCESS, |
| 26 RESULT_INVALID_NAME, | 27 RESULT_INVALID_NAME, |
| 27 RESULT_NOT_FOUND, | 28 RESULT_NOT_FOUND, |
| 28 RESULT_FORBIDDEN, | 29 RESULT_FORBIDDEN, |
| 29 RESULT_FAILED_TO_START, | 30 RESULT_FAILED_TO_START, |
| 30 }; | 31 }; |
| 31 | 32 |
| 32 // Callback that's called after the process has been launched. |result| is | 33 // Callback that's called after the process has been launched. |result| is |
| 33 // set to false in case of a failure. Handler must take ownership of the IO | 34 // set to false in case of a failure. Handler must take ownership of the IO |
| 34 // handles. | 35 // handles. |
| 35 typedef base::Callback<void (LaunchResult result, | 36 typedef base::Callback<void (LaunchResult result, |
| 36 base::PlatformFile read_file, | 37 base::PlatformFile read_file, |
| 37 base::PlatformFile write_file)> LaunchedCallback; | 38 base::PlatformFile write_file)> LaunchedCallback; |
| 38 | 39 |
| 39 static scoped_ptr<NativeProcessLauncher> CreateDefault(); | 40 static scoped_ptr<NativeProcessLauncher> CreateDefault( |
| 41 gfx::NativeView native_view); |
| 40 | 42 |
| 41 NativeProcessLauncher() {} | 43 NativeProcessLauncher() {} |
| 42 virtual ~NativeProcessLauncher() {} | 44 virtual ~NativeProcessLauncher() {} |
| 43 | 45 |
| 44 // Finds native messaging host with the specified name and launches it | 46 // Finds native messaging host with the specified name and launches it |
| 45 // asynchronously. Also checks that the specified |origin| is permitted to | 47 // asynchronously. Also checks that the specified |origin| is permitted to |
| 46 // access the host. |callback| is called after the process has been started. | 48 // access the host. |callback| is called after the process has been started. |
| 47 // If the launcher is destroyed before the callback is called then the call is | 49 // If the launcher is destroyed before the callback is called then the call is |
| 48 // canceled and the process is stopped if it has been started already (by | 50 // canceled and the process is stopped if it has been started already (by |
| 49 // closing IO pipes). | 51 // closing IO pipes). |
| (...skipping 15 matching lines...) Expand all Loading... |
| 65 base::PlatformFile* read_file, | 67 base::PlatformFile* read_file, |
| 66 base::PlatformFile* write_file); | 68 base::PlatformFile* write_file); |
| 67 | 69 |
| 68 private: | 70 private: |
| 69 DISALLOW_COPY_AND_ASSIGN(NativeProcessLauncher); | 71 DISALLOW_COPY_AND_ASSIGN(NativeProcessLauncher); |
| 70 }; | 72 }; |
| 71 | 73 |
| 72 } // namespace extensions | 74 } // namespace extensions |
| 73 | 75 |
| 74 #endif // CHROME_BROWSER_EXTENSIONS_API_MESSAGING_NATIVE_PROCESS_LAUNCHER_H_ | 76 #endif // CHROME_BROWSER_EXTENSIONS_API_MESSAGING_NATIVE_PROCESS_LAUNCHER_H_ |
| OLD | NEW |