| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 REMOTING_HOST_IT2ME_IT2ME_NATIVE_MESSAGING_HOST_H_ | 5 #ifndef REMOTING_HOST_IT2ME_IT2ME_NATIVE_MESSAGING_HOST_H_ |
| 6 #define REMOTING_HOST_IT2ME_IT2ME_NATIVE_MESSAGING_HOST_H_ | 6 #define REMOTING_HOST_IT2ME_IT2ME_NATIVE_MESSAGING_HOST_H_ |
| 7 | 7 |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| 11 #include "extensions/browser/api/messaging/native_message_host.h" | 11 #include "extensions/browser/api/messaging/native_message_host.h" |
| 12 #include "remoting/base/auto_thread_task_runner.h" | 12 #include "remoting/base/auto_thread_task_runner.h" |
| 13 #include "remoting/host/it2me/it2me_host.h" | 13 #include "remoting/host/it2me/it2me_host.h" |
| 14 | 14 |
| 15 namespace base { | 15 namespace base { |
| 16 class DictionaryValue; | 16 class DictionaryValue; |
| 17 class Value; | 17 class Value; |
| 18 } // namespace base | 18 } // namespace base |
| 19 | 19 |
| 20 namespace policy { |
| 21 class PolicyService; |
| 22 } // namespace policy |
| 23 |
| 20 namespace remoting { | 24 namespace remoting { |
| 21 | 25 |
| 22 // Implementation of the native messaging host process. | 26 // Implementation of the native messaging host process. |
| 23 class It2MeNativeMessagingHost : public It2MeHost::Observer, | 27 class It2MeNativeMessagingHost : public It2MeHost::Observer, |
| 24 public extensions::NativeMessageHost { | 28 public extensions::NativeMessageHost { |
| 25 public: | 29 public: |
| 26 It2MeNativeMessagingHost(scoped_refptr<AutoThreadTaskRunner> task_runner, | 30 static scoped_ptr<NativeMessageHost> CreateForChromeOS( |
| 27 scoped_ptr<It2MeHostFactory> factory); | 31 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter, |
| 32 policy::PolicyService* policy_service); |
| 33 |
| 34 It2MeNativeMessagingHost( |
| 35 scoped_ptr<ChromotingHostContext> context, |
| 36 scoped_ptr<It2MeHostFactory> factory); |
| 28 virtual ~It2MeNativeMessagingHost(); | 37 virtual ~It2MeNativeMessagingHost(); |
| 29 | 38 |
| 30 // extensions::NativeMessageHost implementation. | 39 // extensions::NativeMessageHost implementation. |
| 31 virtual void OnMessage(const std::string& message) override; | 40 virtual void OnMessage(const std::string& message) override; |
| 32 virtual void Start(Client* client) override; | 41 virtual void Start(Client* client) override; |
| 33 virtual scoped_refptr<base::SingleThreadTaskRunner> task_runner() | 42 virtual scoped_refptr<base::SingleThreadTaskRunner> task_runner() |
| 34 const override; | 43 const override; |
| 35 | 44 |
| 36 // It2MeHost::Observer implementation. | 45 // It2MeHost::Observer implementation. |
| 37 virtual void OnClientAuthenticated(const std::string& client_username) | 46 virtual void OnClientAuthenticated(const std::string& client_username) |
| (...skipping 15 matching lines...) Expand all Loading... |
| 53 scoped_ptr<base::DictionaryValue> response); | 62 scoped_ptr<base::DictionaryValue> response); |
| 54 void ProcessDisconnect(const base::DictionaryValue& message, | 63 void ProcessDisconnect(const base::DictionaryValue& message, |
| 55 scoped_ptr<base::DictionaryValue> response); | 64 scoped_ptr<base::DictionaryValue> response); |
| 56 void SendErrorAndExit(scoped_ptr<base::DictionaryValue> response, | 65 void SendErrorAndExit(scoped_ptr<base::DictionaryValue> response, |
| 57 const std::string& description) const; | 66 const std::string& description) const; |
| 58 void SendMessageToClient(scoped_ptr<base::DictionaryValue> message) const; | 67 void SendMessageToClient(scoped_ptr<base::DictionaryValue> message) const; |
| 59 | 68 |
| 60 Client* client_; | 69 Client* client_; |
| 61 scoped_ptr<It2MeHostFactory> factory_; | 70 scoped_ptr<It2MeHostFactory> factory_; |
| 62 scoped_ptr<ChromotingHostContext> host_context_; | 71 scoped_ptr<ChromotingHostContext> host_context_; |
| 72 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| 63 scoped_refptr<It2MeHost> it2me_host_; | 73 scoped_refptr<It2MeHost> it2me_host_; |
| 64 | 74 |
| 65 // Cached, read-only copies of |it2me_host_| session state. | 75 // Cached, read-only copies of |it2me_host_| session state. |
| 66 It2MeHostState state_; | 76 It2MeHostState state_; |
| 67 std::string access_code_; | 77 std::string access_code_; |
| 68 base::TimeDelta access_code_lifetime_; | 78 base::TimeDelta access_code_lifetime_; |
| 69 std::string client_username_; | 79 std::string client_username_; |
| 70 | 80 |
| 71 // IT2Me Talk server configuration used by |it2me_host_| to connect. | 81 // IT2Me Talk server configuration used by |it2me_host_| to connect. |
| 72 XmppSignalStrategy::XmppServerConfig xmpp_server_config_; | 82 XmppSignalStrategy::XmppServerConfig xmpp_server_config_; |
| 73 | 83 |
| 74 // Chromoting Bot JID used by |it2me_host_| to register the host. | 84 // Chromoting Bot JID used by |it2me_host_| to register the host. |
| 75 std::string directory_bot_jid_; | 85 std::string directory_bot_jid_; |
| 76 | 86 |
| 77 base::WeakPtr<It2MeNativeMessagingHost> weak_ptr_; | 87 base::WeakPtr<It2MeNativeMessagingHost> weak_ptr_; |
| 78 base::WeakPtrFactory<It2MeNativeMessagingHost> weak_factory_; | 88 base::WeakPtrFactory<It2MeNativeMessagingHost> weak_factory_; |
| 79 | 89 |
| 80 DISALLOW_COPY_AND_ASSIGN(It2MeNativeMessagingHost); | 90 DISALLOW_COPY_AND_ASSIGN(It2MeNativeMessagingHost); |
| 81 }; | 91 }; |
| 82 | 92 |
| 83 } // namespace remoting | 93 } // namespace remoting |
| 84 | 94 |
| 85 #endif // REMOTING_HOST_IT2ME_IT2ME_NATIVE_MESSAGING_HOST_H_ | 95 #endif // REMOTING_HOST_IT2ME_IT2ME_NATIVE_MESSAGING_HOST_H_ |
| 86 | 96 |
| OLD | NEW |