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 <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 10 matching lines...) Expand all Loading... |
21 | 21 |
22 namespace base { | 22 namespace base { |
23 class DictionaryValue; | 23 class DictionaryValue; |
24 class Value; | 24 class Value; |
25 class SingleThreadTaskRunner; | 25 class SingleThreadTaskRunner; |
26 } // namespace base | 26 } // namespace base |
27 | 27 |
28 namespace remoting { | 28 namespace remoting { |
29 | 29 |
30 class ChromotingHostContext; | 30 class ChromotingHostContext; |
| 31 class DelegatingSignalStrategy; |
31 class ElevatedNativeMessagingHost; | 32 class ElevatedNativeMessagingHost; |
32 class PolicyWatcher; | 33 class PolicyWatcher; |
33 | 34 |
34 // Implementation of the native messaging host process. | 35 // Implementation of the native messaging host process. |
35 class It2MeNativeMessagingHost : public It2MeHost::Observer, | 36 class It2MeNativeMessagingHost : public It2MeHost::Observer, |
36 public extensions::NativeMessageHost { | 37 public extensions::NativeMessageHost { |
37 public: | 38 public: |
38 It2MeNativeMessagingHost(bool needs_elevation, | 39 It2MeNativeMessagingHost(bool needs_elevation, |
39 policy::PolicyService* policy_service, | 40 policy::PolicyService* policy_service, |
40 std::unique_ptr<ChromotingHostContext> host_context, | 41 std::unique_ptr<ChromotingHostContext> host_context, |
(...skipping 19 matching lines...) Expand all Loading... |
60 private: | 61 private: |
61 // These "Process.." methods handle specific request types. The |response| | 62 // These "Process.." methods handle specific request types. The |response| |
62 // dictionary is pre-filled by ProcessMessage() with the parts of the | 63 // dictionary is pre-filled by ProcessMessage() with the parts of the |
63 // response already known ("id" and "type" fields). | 64 // response already known ("id" and "type" fields). |
64 void ProcessHello(std::unique_ptr<base::DictionaryValue> message, | 65 void ProcessHello(std::unique_ptr<base::DictionaryValue> message, |
65 std::unique_ptr<base::DictionaryValue> response) const; | 66 std::unique_ptr<base::DictionaryValue> response) const; |
66 void ProcessConnect(std::unique_ptr<base::DictionaryValue> message, | 67 void ProcessConnect(std::unique_ptr<base::DictionaryValue> message, |
67 std::unique_ptr<base::DictionaryValue> response); | 68 std::unique_ptr<base::DictionaryValue> response); |
68 void ProcessDisconnect(std::unique_ptr<base::DictionaryValue> message, | 69 void ProcessDisconnect(std::unique_ptr<base::DictionaryValue> message, |
69 std::unique_ptr<base::DictionaryValue> response); | 70 std::unique_ptr<base::DictionaryValue> response); |
| 71 void ProcessIncomingIq(std::unique_ptr<base::DictionaryValue> message, |
| 72 std::unique_ptr<base::DictionaryValue> response); |
70 void SendErrorAndExit(std::unique_ptr<base::DictionaryValue> response, | 73 void SendErrorAndExit(std::unique_ptr<base::DictionaryValue> response, |
71 const std::string& description) const; | 74 const std::string& description) const; |
72 void SendMessageToClient(std::unique_ptr<base::Value> message) const; | 75 void SendMessageToClient(std::unique_ptr<base::Value> message) const; |
73 | 76 |
| 77 // Callback for DelegatingSignalStrategy. |
| 78 void SendOutgoingIq(const std::string& iq); |
| 79 |
74 // Called when initial policies are read. | 80 // Called when initial policies are read. |
75 void OnPolicyUpdate(std::unique_ptr<base::DictionaryValue> policies); | 81 void OnPolicyUpdate(std::unique_ptr<base::DictionaryValue> policies); |
76 | 82 |
77 // Returns whether the request was successfully sent to the elevated host. | 83 // Returns whether the request was successfully sent to the elevated host. |
78 bool DelegateToElevatedHost(std::unique_ptr<base::DictionaryValue> message); | 84 bool DelegateToElevatedHost(std::unique_ptr<base::DictionaryValue> message); |
79 | 85 |
80 // Used to determine whether to create and pass messages to an elevated host. | 86 // Used to determine whether to create and pass messages to an elevated host. |
81 bool needs_elevation_ = false; | 87 bool needs_elevation_ = false; |
82 | 88 |
83 #if defined(OS_WIN) | 89 #if defined(OS_WIN) |
84 // Controls the lifetime of the elevated native messaging host process. | 90 // Controls the lifetime of the elevated native messaging host process. |
85 // Note: 'elevated' in this instance means having the UiAccess privilege, not | 91 // Note: 'elevated' in this instance means having the UiAccess privilege, not |
86 // being run as a higher privilege user. | 92 // being run as a higher privilege user. |
87 std::unique_ptr<ElevatedNativeMessagingHost> elevated_host_; | 93 std::unique_ptr<ElevatedNativeMessagingHost> elevated_host_; |
88 #endif // defined(OS_WIN) | 94 #endif // defined(OS_WIN) |
89 | 95 |
90 Client* client_ = nullptr; | 96 Client* client_ = nullptr; |
| 97 DelegatingSignalStrategy* delegating_signal_strategy_ = nullptr; |
91 std::unique_ptr<ChromotingHostContext> host_context_; | 98 std::unique_ptr<ChromotingHostContext> host_context_; |
92 std::unique_ptr<It2MeHostFactory> factory_; | 99 std::unique_ptr<It2MeHostFactory> factory_; |
93 scoped_refptr<It2MeHost> it2me_host_; | 100 scoped_refptr<It2MeHost> it2me_host_; |
94 | 101 |
95 #if !defined(OS_CHROMEOS) | 102 #if !defined(OS_CHROMEOS) |
96 // Don't install a log message handler on ChromeOS because we run in the | 103 // Don't install a log message handler on ChromeOS because we run in the |
97 // browser process and don't want to intercept all its log messages. | 104 // browser process and don't want to intercept all its log messages. |
98 std::unique_ptr<LogMessageHandler> log_message_handler_; | 105 std::unique_ptr<LogMessageHandler> log_message_handler_; |
99 #endif | 106 #endif |
100 | 107 |
101 // Cached, read-only copies of |it2me_host_| session state. | 108 // Cached, read-only copies of |it2me_host_| session state. |
102 It2MeHostState state_; | 109 It2MeHostState state_; |
103 std::string access_code_; | 110 std::string access_code_; |
104 base::TimeDelta access_code_lifetime_; | 111 base::TimeDelta access_code_lifetime_; |
105 std::string client_username_; | 112 std::string client_username_; |
106 | 113 |
107 // IT2Me Talk server configuration used by |it2me_host_| to connect. | |
108 XmppSignalStrategy::XmppServerConfig xmpp_server_config_; | |
109 | |
110 // Chromoting Bot JID used by |it2me_host_| to register the host. | |
111 std::string directory_bot_jid_; | |
112 | |
113 // Indicates whether or not a policy has ever been read. This is to ensure | 114 // Indicates whether or not a policy has ever been read. This is to ensure |
114 // that on startup, we do not accidentally start a connection before we have | 115 // that on startup, we do not accidentally start a connection before we have |
115 // queried our policy restrictions. | 116 // queried our policy restrictions. |
116 bool policy_received_ = false; | 117 bool policy_received_ = false; |
117 | 118 |
118 policy::PolicyService* policy_service_ = nullptr; | 119 policy::PolicyService* policy_service_ = nullptr; |
119 | 120 |
120 // Used to retrieve Chrome policies set for the local machine. | 121 // Used to retrieve Chrome policies set for the local machine. |
121 std::unique_ptr<PolicyWatcher> policy_watcher_; | 122 std::unique_ptr<PolicyWatcher> policy_watcher_; |
122 | 123 |
123 // On startup, it is possible to have Connect() called before the policy read | 124 // On startup, it is possible to have Connect() called before the policy read |
124 // is completed. Rather than just failing, we thunk the connection call so | 125 // is completed. Rather than just failing, we thunk the connection call so |
125 // it can be executed after at least one successful policy read. This | 126 // it can be executed after at least one successful policy read. This |
126 // variable contains the thunk if it is necessary. | 127 // variable contains the thunk if it is necessary. |
127 base::Closure pending_connect_; | 128 base::Closure pending_connect_; |
128 | 129 |
129 base::WeakPtr<It2MeNativeMessagingHost> weak_ptr_; | 130 base::WeakPtr<It2MeNativeMessagingHost> weak_ptr_; |
130 base::WeakPtrFactory<It2MeNativeMessagingHost> weak_factory_; | 131 base::WeakPtrFactory<It2MeNativeMessagingHost> weak_factory_; |
131 | 132 |
132 DISALLOW_COPY_AND_ASSIGN(It2MeNativeMessagingHost); | 133 DISALLOW_COPY_AND_ASSIGN(It2MeNativeMessagingHost); |
133 }; | 134 }; |
134 | 135 |
135 } // namespace remoting | 136 } // namespace remoting |
136 | 137 |
137 #endif // REMOTING_HOST_IT2ME_IT2ME_NATIVE_MESSAGING_HOST_H_ | 138 #endif // REMOTING_HOST_IT2ME_IT2ME_NATIVE_MESSAGING_HOST_H_ |
OLD | NEW |