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." |
| 161 trigger: "Chrome Remote Desktop usage." |
| 162 data: "Relay token (received over XMPP)." |
| 163 destination: GOOGLE_OWNED_SERVICE |
| 164 } |
| 165 policy { |
| 166 cookies_allowed: false/true |
| 167 cookies_store: "..." |
| 168 setting: |
| 169 "This feature cannot be disabled by settings. You can block Chrome " |
| 170 "Remote Desktop as specified here: " |
| 171 "https://support.google.com/chrome/a/answer/2799701?hl=en" |
| 172 chrome_policy { |
| 173 RemoteAccessHostFirewallTraversal { |
| 174 policy_options {mode: MANDATORY} |
| 175 RemoteAccessHostFirewallTraversal: false |
| 176 } |
| 177 } |
| 178 policy_exception_justification: |
| 179 "Above specified policy is only applicable on the host side and " |
| 180 "doesn't have effect in Android and iOS client apps. The product " |
| 181 "is shipped separately from Chromium, except on Chrome OS." |
| 182 })"); |
153 std::unique_ptr<UrlRequest> url_request = | 183 std::unique_ptr<UrlRequest> url_request = |
154 transport_context_->url_request_factory()->CreateUrlRequest( | 184 transport_context_->url_request_factory()->CreateUrlRequest( |
155 UrlRequest::Type::GET, url); | 185 UrlRequest::Type::GET, url, traffic_annotation); |
156 url_request->AddHeader("X-Talk-Google-Relay-Auth: " + | 186 url_request->AddHeader("X-Talk-Google-Relay-Auth: " + |
157 ice_config_.relay_token); | 187 ice_config_.relay_token); |
158 url_request->AddHeader("X-Google-Relay-Auth: " + ice_config_.relay_token); | 188 url_request->AddHeader("X-Google-Relay-Auth: " + ice_config_.relay_token); |
159 url_request->AddHeader("X-Stream-Type: chromoting"); | 189 url_request->AddHeader("X-Stream-Type: chromoting"); |
160 url_request->Start(base::Bind(&PortAllocatorSession::OnSessionRequestResult, | 190 url_request->Start(base::Bind(&PortAllocatorSession::OnSessionRequestResult, |
161 base::Unretained(this))); | 191 base::Unretained(this))); |
162 url_requests_.insert(std::move(url_request)); | 192 url_requests_.insert(std::move(url_request)); |
163 } | 193 } |
164 | 194 |
165 void PortAllocatorSession::OnSessionRequestResult( | 195 void PortAllocatorSession::OnSessionRequestResult( |
(...skipping 27 matching lines...) Expand all Loading... |
193 relay_config.ports.push_back( | 223 relay_config.ports.push_back( |
194 cricket::ProtocolAddress(address, cricket::PROTO_UDP)); | 224 cricket::ProtocolAddress(address, cricket::PROTO_UDP)); |
195 config->AddRelay(relay_config); | 225 config->AddRelay(relay_config); |
196 } | 226 } |
197 | 227 |
198 ConfigReady(config.release()); | 228 ConfigReady(config.release()); |
199 } | 229 } |
200 | 230 |
201 } // namespace protocol | 231 } // namespace protocol |
202 } // namespace remoting | 232 } // namespace remoting |
OLD | NEW |