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 19 matching lines...) Expand all Loading... |
30 | 30 |
31 class ChromotingHostContext; | 31 class ChromotingHostContext; |
32 class ElevatedNativeMessagingHost; | 32 class ElevatedNativeMessagingHost; |
33 class PolicyWatcher; | 33 class PolicyWatcher; |
34 | 34 |
35 // Implementation of the native messaging host process. | 35 // Implementation of the native messaging host process. |
36 class It2MeNativeMessagingHost : public It2MeHost::Observer, | 36 class It2MeNativeMessagingHost : public It2MeHost::Observer, |
37 public extensions::NativeMessageHost { | 37 public extensions::NativeMessageHost { |
38 public: | 38 public: |
39 It2MeNativeMessagingHost(bool needs_elevation, | 39 It2MeNativeMessagingHost(bool needs_elevation, |
40 policy::PolicyService* policy_service, | 40 std::unique_ptr<PolicyWatcher> policy_watcher, |
41 std::unique_ptr<ChromotingHostContext> host_context, | 41 std::unique_ptr<ChromotingHostContext> host_context, |
42 std::unique_ptr<It2MeHostFactory> host_factory); | 42 std::unique_ptr<It2MeHostFactory> host_factory); |
43 ~It2MeNativeMessagingHost() override; | 43 ~It2MeNativeMessagingHost() override; |
44 | 44 |
45 // extensions::NativeMessageHost implementation. | 45 // extensions::NativeMessageHost implementation. |
46 void OnMessage(const std::string& message) override; | 46 void OnMessage(const std::string& message) override; |
47 void Start(Client* client) override; | 47 void Start(Client* client) override; |
48 scoped_refptr<base::SingleThreadTaskRunner> task_runner() const override; | 48 scoped_refptr<base::SingleThreadTaskRunner> task_runner() const override; |
49 | 49 |
50 // It2MeHost::Observer implementation. | 50 // It2MeHost::Observer implementation. |
(...skipping 19 matching lines...) Expand all Loading... |
70 std::unique_ptr<base::DictionaryValue> response); | 70 std::unique_ptr<base::DictionaryValue> response); |
71 void ProcessIncomingIq(std::unique_ptr<base::DictionaryValue> message, | 71 void ProcessIncomingIq(std::unique_ptr<base::DictionaryValue> message, |
72 std::unique_ptr<base::DictionaryValue> response); | 72 std::unique_ptr<base::DictionaryValue> response); |
73 void SendErrorAndExit(std::unique_ptr<base::DictionaryValue> response, | 73 void SendErrorAndExit(std::unique_ptr<base::DictionaryValue> response, |
74 const std::string& description) const; | 74 const std::string& description) const; |
75 void SendMessageToClient(std::unique_ptr<base::Value> message) const; | 75 void SendMessageToClient(std::unique_ptr<base::Value> message) const; |
76 | 76 |
77 // Callback for DelegatingSignalStrategy. | 77 // Callback for DelegatingSignalStrategy. |
78 void SendOutgoingIq(const std::string& iq); | 78 void SendOutgoingIq(const std::string& iq); |
79 | 79 |
80 // Called when initial policies are read. | 80 // Called when initial policies are read and when they change. |
81 void OnPolicyUpdate(std::unique_ptr<base::DictionaryValue> policies); | 81 void OnPolicyUpdate(std::unique_ptr<base::DictionaryValue> policies); |
82 | 82 |
83 // Returns whether the request was successfully sent to the elevated host. | 83 // Returns whether the request was successfully sent to the elevated host. |
84 bool DelegateToElevatedHost(std::unique_ptr<base::DictionaryValue> message); | 84 bool DelegateToElevatedHost(std::unique_ptr<base::DictionaryValue> message); |
85 | 85 |
86 // 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. |
87 bool needs_elevation_ = false; | 87 bool needs_elevation_ = false; |
88 | 88 |
89 #if defined(OS_WIN) | 89 #if defined(OS_WIN) |
90 // Controls the lifetime of the elevated native messaging host process. | 90 // Controls the lifetime of the elevated native messaging host process. |
(...skipping 18 matching lines...) Expand all Loading... |
109 It2MeHostState state_; | 109 It2MeHostState state_; |
110 std::string access_code_; | 110 std::string access_code_; |
111 base::TimeDelta access_code_lifetime_; | 111 base::TimeDelta access_code_lifetime_; |
112 std::string client_username_; | 112 std::string client_username_; |
113 | 113 |
114 // 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 |
115 // 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 |
116 // queried our policy restrictions. | 116 // queried our policy restrictions. |
117 bool policy_received_ = false; | 117 bool policy_received_ = false; |
118 | 118 |
119 policy::PolicyService* policy_service_ = nullptr; | |
120 | |
121 // Used to retrieve Chrome policies set for the local machine. | 119 // Used to retrieve Chrome policies set for the local machine. |
122 std::unique_ptr<PolicyWatcher> policy_watcher_; | 120 std::unique_ptr<PolicyWatcher> policy_watcher_; |
123 | 121 |
124 // On startup, it is possible to have Connect() called before the policy read | 122 // On startup, it is possible to have Connect() called before the policy read |
125 // is completed. Rather than just failing, we thunk the connection call so | 123 // is completed. Rather than just failing, we thunk the connection call so |
126 // it can be executed after at least one successful policy read. This | 124 // it can be executed after at least one successful policy read. This |
127 // variable contains the thunk if it is necessary. | 125 // variable contains the thunk if it is necessary. |
128 base::Closure pending_connect_; | 126 base::Closure pending_connect_; |
129 | 127 |
130 base::WeakPtr<It2MeNativeMessagingHost> weak_ptr_; | 128 base::WeakPtr<It2MeNativeMessagingHost> weak_ptr_; |
131 base::WeakPtrFactory<It2MeNativeMessagingHost> weak_factory_; | 129 base::WeakPtrFactory<It2MeNativeMessagingHost> weak_factory_; |
132 | 130 |
133 DISALLOW_COPY_AND_ASSIGN(It2MeNativeMessagingHost); | 131 DISALLOW_COPY_AND_ASSIGN(It2MeNativeMessagingHost); |
134 }; | 132 }; |
135 | 133 |
136 } // namespace remoting | 134 } // namespace remoting |
137 | 135 |
138 #endif // REMOTING_HOST_IT2ME_IT2ME_NATIVE_MESSAGING_HOST_H_ | 136 #endif // REMOTING_HOST_IT2ME_IT2ME_NATIVE_MESSAGING_HOST_H_ |
OLD | NEW |