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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 | 49 |
50 // It2MeHost::Observer implementation. | 50 // It2MeHost::Observer implementation. |
51 void OnClientAuthenticated(const std::string& client_username) | 51 void OnClientAuthenticated(const std::string& client_username) |
52 override; | 52 override; |
53 void OnStoreAccessCode(const std::string& access_code, | 53 void OnStoreAccessCode(const std::string& access_code, |
54 base::TimeDelta access_code_lifetime) override; | 54 base::TimeDelta access_code_lifetime) override; |
55 void OnNatPolicyChanged(bool nat_traversal_enabled) override; | 55 void OnNatPolicyChanged(bool nat_traversal_enabled) override; |
56 void OnStateChanged(It2MeHostState state, | 56 void OnStateChanged(It2MeHostState state, |
57 const std::string& error_message) override; | 57 const std::string& error_message) override; |
58 | 58 |
| 59 // Set a callback to be called when a policy error notification has been |
| 60 // processed. |
| 61 void SetPolicyErrorClosureForTesting(const base::Closure& closure); |
| 62 |
59 static std::string HostStateToString(It2MeHostState host_state); | 63 static std::string HostStateToString(It2MeHostState host_state); |
60 | 64 |
61 private: | 65 private: |
62 // These "Process.." methods handle specific request types. The |response| | 66 // These "Process.." methods handle specific request types. The |response| |
63 // dictionary is pre-filled by ProcessMessage() with the parts of the | 67 // dictionary is pre-filled by ProcessMessage() with the parts of the |
64 // response already known ("id" and "type" fields). | 68 // response already known ("id" and "type" fields). |
65 void ProcessHello(std::unique_ptr<base::DictionaryValue> message, | 69 void ProcessHello(std::unique_ptr<base::DictionaryValue> message, |
66 std::unique_ptr<base::DictionaryValue> response) const; | 70 std::unique_ptr<base::DictionaryValue> response) const; |
67 void ProcessConnect(std::unique_ptr<base::DictionaryValue> message, | 71 void ProcessConnect(std::unique_ptr<base::DictionaryValue> message, |
68 std::unique_ptr<base::DictionaryValue> response); | 72 std::unique_ptr<base::DictionaryValue> response); |
69 void ProcessDisconnect(std::unique_ptr<base::DictionaryValue> message, | 73 void ProcessDisconnect(std::unique_ptr<base::DictionaryValue> message, |
70 std::unique_ptr<base::DictionaryValue> response); | 74 std::unique_ptr<base::DictionaryValue> response); |
71 void ProcessIncomingIq(std::unique_ptr<base::DictionaryValue> message, | 75 void ProcessIncomingIq(std::unique_ptr<base::DictionaryValue> message, |
72 std::unique_ptr<base::DictionaryValue> response); | 76 std::unique_ptr<base::DictionaryValue> response); |
73 void SendErrorAndExit(std::unique_ptr<base::DictionaryValue> response, | 77 void SendErrorAndExit(std::unique_ptr<base::DictionaryValue> response, |
74 const std::string& description) const; | 78 const std::string& description) const; |
| 79 void SendPolicyErrorAndExit() const; |
75 void SendMessageToClient(std::unique_ptr<base::Value> message) const; | 80 void SendMessageToClient(std::unique_ptr<base::Value> message) const; |
76 | 81 |
77 // Callback for DelegatingSignalStrategy. | 82 // Callback for DelegatingSignalStrategy. |
78 void SendOutgoingIq(const std::string& iq); | 83 void SendOutgoingIq(const std::string& iq); |
79 | 84 |
80 // Called when initial policies are read and when they change. | 85 // Called when initial policies are read and when they change. |
81 void OnPolicyUpdate(std::unique_ptr<base::DictionaryValue> policies); | 86 void OnPolicyUpdate(std::unique_ptr<base::DictionaryValue> policies); |
82 | 87 |
| 88 // Called when malformed policies are detected. |
| 89 void OnPolicyError(); |
| 90 |
83 // Returns whether the request was successfully sent to the elevated host. | 91 // Returns whether the request was successfully sent to the elevated host. |
84 bool DelegateToElevatedHost(std::unique_ptr<base::DictionaryValue> message); | 92 bool DelegateToElevatedHost(std::unique_ptr<base::DictionaryValue> message); |
85 | 93 |
86 // Used to determine whether to create and pass messages to an elevated host. | 94 // Used to determine whether to create and pass messages to an elevated host. |
87 bool needs_elevation_ = false; | 95 bool needs_elevation_ = false; |
88 | 96 |
89 #if defined(OS_WIN) | 97 #if defined(OS_WIN) |
90 // Controls the lifetime of the elevated native messaging host process. | 98 // Controls the lifetime of the elevated native messaging host process. |
91 // Note: 'elevated' in this instance means having the UiAccess privilege, not | 99 // Note: 'elevated' in this instance means having the UiAccess privilege, not |
92 // being run as a higher privilege user. | 100 // being run as a higher privilege user. |
(...skipping 25 matching lines...) Expand all Loading... |
118 | 126 |
119 // Used to retrieve Chrome policies set for the local machine. | 127 // Used to retrieve Chrome policies set for the local machine. |
120 std::unique_ptr<PolicyWatcher> policy_watcher_; | 128 std::unique_ptr<PolicyWatcher> policy_watcher_; |
121 | 129 |
122 // On startup, it is possible to have Connect() called before the policy read | 130 // On startup, it is possible to have Connect() called before the policy read |
123 // is completed. Rather than just failing, we thunk the connection call so | 131 // is completed. Rather than just failing, we thunk the connection call so |
124 // it can be executed after at least one successful policy read. This | 132 // it can be executed after at least one successful policy read. This |
125 // variable contains the thunk if it is necessary. | 133 // variable contains the thunk if it is necessary. |
126 base::Closure pending_connect_; | 134 base::Closure pending_connect_; |
127 | 135 |
| 136 base::Closure policy_error_closure_for_testing_; |
| 137 |
128 base::WeakPtr<It2MeNativeMessagingHost> weak_ptr_; | 138 base::WeakPtr<It2MeNativeMessagingHost> weak_ptr_; |
129 base::WeakPtrFactory<It2MeNativeMessagingHost> weak_factory_; | 139 base::WeakPtrFactory<It2MeNativeMessagingHost> weak_factory_; |
130 | 140 |
131 DISALLOW_COPY_AND_ASSIGN(It2MeNativeMessagingHost); | 141 DISALLOW_COPY_AND_ASSIGN(It2MeNativeMessagingHost); |
132 }; | 142 }; |
133 | 143 |
134 } // namespace remoting | 144 } // namespace remoting |
135 | 145 |
136 #endif // REMOTING_HOST_IT2ME_IT2ME_NATIVE_MESSAGING_HOST_H_ | 146 #endif // REMOTING_HOST_IT2ME_IT2ME_NATIVE_MESSAGING_HOST_H_ |
OLD | NEW |