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 remoting { | 20 namespace remoting { |
21 | 21 |
22 // Implementation of the native messaging host process. | 22 // Implementation of the native messaging host process. |
23 class It2MeNativeMessagingHost : public It2MeHost::Observer, | 23 class It2MeNativeMessagingHost : public It2MeHost::Observer, |
24 public extensions::NativeMessageHost { | 24 public extensions::NativeMessageHost { |
25 public: | 25 public: |
26 It2MeNativeMessagingHost(scoped_refptr<AutoThreadTaskRunner> task_runner, | 26 It2MeNativeMessagingHost(scoped_refptr<AutoThreadTaskRunner> task_runner, |
27 scoped_ptr<It2MeHostFactory> factory); | 27 scoped_ptr<It2MeHostFactory> factory); |
28 virtual ~It2MeNativeMessagingHost(); | 28 ~It2MeNativeMessagingHost() override; |
29 | 29 |
30 // extensions::NativeMessageHost implementation. | 30 // extensions::NativeMessageHost implementation. |
31 virtual void OnMessage(const std::string& message) override; | 31 void OnMessage(const std::string& message) override; |
32 virtual void Start(Client* client) override; | 32 void Start(Client* client) override; |
33 virtual scoped_refptr<base::SingleThreadTaskRunner> task_runner() | 33 scoped_refptr<base::SingleThreadTaskRunner> task_runner() const override; |
34 const override; | |
35 | 34 |
36 // It2MeHost::Observer implementation. | 35 // It2MeHost::Observer implementation. |
37 virtual void OnClientAuthenticated(const std::string& client_username) | 36 void OnClientAuthenticated(const std::string& client_username) override; |
38 override; | 37 void OnStoreAccessCode(const std::string& access_code, |
39 virtual void OnStoreAccessCode(const std::string& access_code, | 38 base::TimeDelta access_code_lifetime) override; |
40 base::TimeDelta access_code_lifetime) override; | 39 void OnNatPolicyChanged(bool nat_traversal_enabled) override; |
41 virtual void OnNatPolicyChanged(bool nat_traversal_enabled) override; | 40 void OnStateChanged(It2MeHostState state) override; |
42 virtual void OnStateChanged(It2MeHostState state) override; | |
43 | 41 |
44 static std::string HostStateToString(It2MeHostState host_state); | 42 static std::string HostStateToString(It2MeHostState host_state); |
45 | 43 |
46 private: | 44 private: |
47 // These "Process.." methods handle specific request types. The |response| | 45 // These "Process.." methods handle specific request types. The |response| |
48 // dictionary is pre-filled by ProcessMessage() with the parts of the | 46 // dictionary is pre-filled by ProcessMessage() with the parts of the |
49 // response already known ("id" and "type" fields). | 47 // response already known ("id" and "type" fields). |
50 void ProcessHello(const base::DictionaryValue& message, | 48 void ProcessHello(const base::DictionaryValue& message, |
51 scoped_ptr<base::DictionaryValue> response) const; | 49 scoped_ptr<base::DictionaryValue> response) const; |
52 void ProcessConnect(const base::DictionaryValue& message, | 50 void ProcessConnect(const base::DictionaryValue& message, |
(...skipping 24 matching lines...) Expand all Loading... |
77 base::WeakPtr<It2MeNativeMessagingHost> weak_ptr_; | 75 base::WeakPtr<It2MeNativeMessagingHost> weak_ptr_; |
78 base::WeakPtrFactory<It2MeNativeMessagingHost> weak_factory_; | 76 base::WeakPtrFactory<It2MeNativeMessagingHost> weak_factory_; |
79 | 77 |
80 DISALLOW_COPY_AND_ASSIGN(It2MeNativeMessagingHost); | 78 DISALLOW_COPY_AND_ASSIGN(It2MeNativeMessagingHost); |
81 }; | 79 }; |
82 | 80 |
83 } // namespace remoting | 81 } // namespace remoting |
84 | 82 |
85 #endif // REMOTING_HOST_IT2ME_IT2ME_NATIVE_MESSAGING_HOST_H_ | 83 #endif // REMOTING_HOST_IT2ME_IT2ME_NATIVE_MESSAGING_HOST_H_ |
86 | 84 |
OLD | NEW |