| Index: chrome/browser/extensions/api/messaging/native_message_process_host.h
|
| diff --git a/chrome/browser/extensions/api/messaging/native_message_process_host.h b/chrome/browser/extensions/api/messaging/native_message_process_host.h
|
| index 47fe8723fd34a8809bb6da1d98bb30eaf5405160..983009f7d858988434777dd46e8595e970258314 100644
|
| --- a/chrome/browser/extensions/api/messaging/native_message_process_host.h
|
| +++ b/chrome/browser/extensions/api/messaging/native_message_process_host.h
|
| @@ -14,10 +14,9 @@
|
| #include "base/message_loop/message_loop.h"
|
| #include "base/process/process.h"
|
| #include "chrome/browser/extensions/api/messaging/native_process_launcher.h"
|
| +#include "extensions/browser/api/messaging/native_message_host.h"
|
| #include "ui/gfx/native_widget_types.h"
|
|
|
| -class PrefService;
|
| -
|
| namespace net {
|
|
|
| class DrainableIOBuffer;
|
| @@ -35,54 +34,25 @@ namespace extensions {
|
| // This class must only be created, called, and deleted on the IO thread.
|
| // Public methods typically accept callbacks which will be invoked on the UI
|
| // thread.
|
| -class NativeMessageProcessHost
|
| +class NativeMessageProcessHost :
|
| #if defined(OS_POSIX)
|
| - : public base::MessageLoopForIO::Watcher
|
| + public base::MessageLoopForIO::Watcher,
|
| #endif // !defined(OS_POSIX)
|
| -{
|
| + public NativeMessageHost {
|
| public:
|
| - // Interface for the object that receives messages from the native process.
|
| - class Client {
|
| - public:
|
| - virtual ~Client() {}
|
| - // Called on the UI thread.
|
| - virtual void PostMessageFromNativeProcess(int port_id,
|
| - const std::string& message) = 0;
|
| - virtual void CloseChannel(int port_id,
|
| - const std::string& error_message) = 0;
|
| - };
|
| -
|
| - // Result returned from IsHostAllowed().
|
| - enum PolicyPermission {
|
| - DISALLOW, // The host is not allowed.
|
| - ALLOW_SYSTEM_ONLY, // Allowed only when installed on system level.
|
| - ALLOW_ALL, // Allowed when installed on system or user level.
|
| - };
|
| + typedef NativeMessageHost::Client Client;
|
|
|
| virtual ~NativeMessageProcessHost();
|
|
|
| - // Returns policy permissions for the host with the specified name.
|
| - static PolicyPermission IsHostAllowed(const PrefService* pref_service,
|
| - const std::string& native_host_name);
|
| -
|
| - static scoped_ptr<NativeMessageProcessHost> Create(
|
| - gfx::NativeView native_view,
|
| - base::WeakPtr<Client> weak_client_ui,
|
| - const std::string& source_extension_id,
|
| - const std::string& native_host_name,
|
| - int destination_port,
|
| - bool allow_user_level);
|
| -
|
| // Create using specified |launcher|. Used in tests.
|
| - static scoped_ptr<NativeMessageProcessHost> CreateWithLauncher(
|
| - base::WeakPtr<Client> weak_client_ui,
|
| + static scoped_ptr<NativeMessageHost> CreateWithLauncher(
|
| const std::string& source_extension_id,
|
| const std::string& native_host_name,
|
| - int destination_port,
|
| scoped_ptr<NativeProcessLauncher> launcher);
|
|
|
| - // Send a message with the specified payload.
|
| - void Send(const std::string& json);
|
| + // extensions::NativeMessageHost implementation.
|
| + virtual void Send(const std::string& json) OVERRIDE;
|
| + virtual void set_client(base::WeakPtr<Client> client) OVERRIDE;
|
|
|
| #if defined(OS_POSIX)
|
| // MessageLoopForIO::Watcher interface
|
| @@ -95,10 +65,8 @@ class NativeMessageProcessHost
|
| void ReadNowForTesting();
|
|
|
| private:
|
| - NativeMessageProcessHost(base::WeakPtr<Client> weak_client_ui,
|
| - const std::string& source_extension_id,
|
| + NativeMessageProcessHost(const std::string& source_extension_id,
|
| const std::string& native_host_name,
|
| - int destination_port,
|
| scoped_ptr<NativeProcessLauncher> launcher);
|
|
|
| // Starts the host process.
|
| @@ -127,7 +95,7 @@ class NativeMessageProcessHost
|
|
|
| // The Client messages will be posted to. Should only be accessed from the
|
| // UI thread.
|
| - base::WeakPtr<Client> weak_client_ui_;
|
| + base::WeakPtr<Client> weak_client_;
|
|
|
| // ID of the calling extension.
|
| std::string source_extension_id_;
|
| @@ -135,10 +103,6 @@ class NativeMessageProcessHost
|
| // Name of the native messaging host.
|
| std::string native_host_name_;
|
|
|
| - // The id of the port on the other side of this connection. This is passed to
|
| - // |weak_client_ui_| when posting messages.
|
| - int destination_port_;
|
| -
|
| // Launcher used to launch the native process.
|
| scoped_ptr<NativeProcessLauncher> launcher_;
|
|
|
|
|