OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #include "remoting/protocol/port_allocator.h" | 5 #include "remoting/protocol/port_allocator.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
13 #include "base/strings/string_split.h" | 13 #include "base/strings/string_split.h" |
14 #include "net/base/escape.h" | 14 #include "net/base/escape.h" |
15 #include "net/http/http_status_code.h" | 15 #include "net/http/http_status_code.h" |
16 #include "net/traffic_annotation/network_traffic_annotation.h" | |
16 #include "remoting/protocol/network_settings.h" | 17 #include "remoting/protocol/network_settings.h" |
17 #include "remoting/protocol/transport_context.h" | 18 #include "remoting/protocol/transport_context.h" |
18 | 19 |
19 namespace { | 20 namespace { |
20 | 21 |
21 typedef std::map<std::string, std::string> StringMap; | 22 typedef std::map<std::string, std::string> StringMap; |
22 | 23 |
23 // Parses the lines in the result of the HTTP request that are of the form | 24 // Parses the lines in the result of the HTTP request that are of the form |
24 // 'a=b' and returns them in a map. | 25 // 'a=b' and returns them in a map. |
25 StringMap ParseMap(const std::string& string) { | 26 StringMap ParseMap(const std::string& string) { |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
143 std::string host = | 144 std::string host = |
144 ice_config_.relay_servers[attempts_ % ice_config_.relay_servers.size()]; | 145 ice_config_.relay_servers[attempts_ % ice_config_.relay_servers.size()]; |
145 attempts_++; | 146 attempts_++; |
146 | 147 |
147 DCHECK(!username().empty()); | 148 DCHECK(!username().empty()); |
148 DCHECK(!password().empty()); | 149 DCHECK(!password().empty()); |
149 std::string url = "https://" + host + "/create_session?username=" + | 150 std::string url = "https://" + host + "/create_session?username=" + |
150 net::EscapeUrlEncodedData(username(), false) + | 151 net::EscapeUrlEncodedData(username(), false) + |
151 "&password=" + | 152 "&password=" + |
152 net::EscapeUrlEncodedData(password(), false) + "&sn=1"; | 153 net::EscapeUrlEncodedData(password(), false) + "&sn=1"; |
154 net::NetworkTrafficAnnotationTag traffic_annotation = | |
155 net::DefineNetworkTrafficAnnotation("CRD_relay_session_request", R"( | |
156 semantics { | |
157 sender: "Chrome Remote Desktop" | |
158 description: | |
159 "Request is used by Chrome Remote Desktop to allocate relay " | |
160 "session." | |
Ramin Halavati
2017/04/13 06:59:04
Since this is read by non-very-technical admins, c
Sergey Ulanov
2017/04/18 18:40:51
Maybe reword as:
"Request is sent by Chrome Remote
Ramin Halavati
2017/04/19 05:45:15
Thank you, that's more than enough!
| |
161 trigger: "Chrome Remote Desktop usage." | |
Ramin Halavati
2017/04/13 06:59:04
Can we be more specific on WHEN?
Sergey Ulanov
2017/04/18 18:40:51
Start of each Chrome Remote Desktop and during con
Ramin Halavati
2017/04/19 05:45:15
Done.
| |
162 data: | |
163 "A temporary authentication token issued by Google services (over " | |
164 "XMPP connection)." | |
165 destination: GOOGLE_OWNED_SERVICE | |
166 } | |
167 policy { | |
168 cookies_allowed: false | |
169 setting: | |
170 "This feature cannot be disabled by settings. You can block Chrome " | |
171 "Remote Desktop as specified here: " | |
172 "https://support.google.com/chrome/?p=remote_desktop" | |
173 chrome_policy { | |
174 RemoteAccessHostFirewallTraversal { | |
175 policy_options {mode: MANDATORY} | |
176 RemoteAccessHostFirewallTraversal: false | |
177 } | |
178 } | |
179 policy_exception_justification: | |
180 "Above specified policy is only applicable on the host side and " | |
181 "doesn't have effect in Android and iOS client apps. The product " | |
182 "is shipped separately from Chromium, except on Chrome OS." | |
183 })"); | |
153 std::unique_ptr<UrlRequest> url_request = | 184 std::unique_ptr<UrlRequest> url_request = |
154 transport_context_->url_request_factory()->CreateUrlRequest( | 185 transport_context_->url_request_factory()->CreateUrlRequest( |
155 UrlRequest::Type::GET, url); | 186 UrlRequest::Type::GET, url, traffic_annotation); |
156 url_request->AddHeader("X-Talk-Google-Relay-Auth: " + | 187 url_request->AddHeader("X-Talk-Google-Relay-Auth: " + |
157 ice_config_.relay_token); | 188 ice_config_.relay_token); |
158 url_request->AddHeader("X-Google-Relay-Auth: " + ice_config_.relay_token); | 189 url_request->AddHeader("X-Google-Relay-Auth: " + ice_config_.relay_token); |
159 url_request->AddHeader("X-Stream-Type: chromoting"); | 190 url_request->AddHeader("X-Stream-Type: chromoting"); |
160 url_request->Start(base::Bind(&PortAllocatorSession::OnSessionRequestResult, | 191 url_request->Start(base::Bind(&PortAllocatorSession::OnSessionRequestResult, |
161 base::Unretained(this))); | 192 base::Unretained(this))); |
162 url_requests_.insert(std::move(url_request)); | 193 url_requests_.insert(std::move(url_request)); |
163 } | 194 } |
164 | 195 |
165 void PortAllocatorSession::OnSessionRequestResult( | 196 void PortAllocatorSession::OnSessionRequestResult( |
(...skipping 27 matching lines...) Expand all Loading... | |
193 relay_config.ports.push_back( | 224 relay_config.ports.push_back( |
194 cricket::ProtocolAddress(address, cricket::PROTO_UDP)); | 225 cricket::ProtocolAddress(address, cricket::PROTO_UDP)); |
195 config->AddRelay(relay_config); | 226 config->AddRelay(relay_config); |
196 } | 227 } |
197 | 228 |
198 ConfigReady(config.release()); | 229 ConfigReady(config.release()); |
199 } | 230 } |
200 | 231 |
201 } // namespace protocol | 232 } // namespace protocol |
202 } // namespace remoting | 233 } // namespace remoting |
OLD | NEW |