| 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/http_ice_config_request.h" | 5 #include "remoting/protocol/http_ice_config_request.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
| 9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| 11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
| 12 #include "base/values.h" | 12 #include "base/values.h" |
| 13 #include "net/base/url_util.h" | 13 #include "net/base/url_util.h" |
| 14 #include "net/traffic_annotation/network_traffic_annotation.h" |
| 14 #include "remoting/protocol/ice_config.h" | 15 #include "remoting/protocol/ice_config.h" |
| 15 | 16 |
| 16 namespace remoting { | 17 namespace remoting { |
| 17 namespace protocol { | 18 namespace protocol { |
| 18 | 19 |
| 19 namespace { | 20 namespace { |
| 20 | 21 |
| 21 // Ensure ICE config is correct at least one hour after session starts. | 22 // Ensure ICE config is correct at least one hour after session starts. |
| 22 const int kMinimumConfigLifetimeSeconds = 3600; | 23 const int kMinimumConfigLifetimeSeconds = 3600; |
| 23 | 24 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 | 91 |
| 91 return true; | 92 return true; |
| 92 } | 93 } |
| 93 | 94 |
| 94 } // namespace | 95 } // namespace |
| 95 | 96 |
| 96 HttpIceConfigRequest::HttpIceConfigRequest( | 97 HttpIceConfigRequest::HttpIceConfigRequest( |
| 97 UrlRequestFactory* url_request_factory, | 98 UrlRequestFactory* url_request_factory, |
| 98 const std::string& url) | 99 const std::string& url) |
| 99 : url_(url) { | 100 : url_(url) { |
| 100 url_request_ = | 101 net::NetworkTrafficAnnotationTag traffic_annotation = |
| 101 url_request_factory->CreateUrlRequest(UrlRequest::Type::POST, url_); | 102 net::DefineNetworkTrafficAnnotation("CRD_ice_config_request", R"( |
| 103 semantics { |
| 104 sender: "Chrome Remote Desktop" |
| 105 description: |
| 106 "Request is used by Chrome Remote Desktop to fetch ICE " |
| 107 "configuration which contains list of STUN & TURN servers and TURN " |
| 108 "credentials." |
| 109 trigger: "Chrome Remote Desktop usage." |
| 110 data: "None." |
| 111 destination: GOOGLE_OWNED_SERVICE |
| 112 } |
| 113 policy { |
| 114 cookies_allowed: false/true |
| 115 cookies_store: "..." |
| 116 setting: |
| 117 "This feature cannot be disabled by settings. You can block Chrome " |
| 118 "Remote Desktop as specified here: " |
| 119 "https://support.google.com/chrome/a/answer/2799701?hl=en" |
| 120 chrome_policy { |
| 121 RemoteAccessHostFirewallTraversal { |
| 122 policy_options {mode: MANDATORY} |
| 123 RemoteAccessHostFirewallTraversal: false |
| 124 } |
| 125 } |
| 126 policy_exception_justification: |
| 127 "Above specified policy is only applicable on the host side and " |
| 128 "doesn't have effect in Android and iOS client apps. The product " |
| 129 "is shipped separately from Chromium, except on Chrome OS." |
| 130 })"); |
| 131 url_request_ = url_request_factory->CreateUrlRequest( |
| 132 UrlRequest::Type::POST, url_, traffic_annotation); |
| 102 url_request_->SetPostData("application/json", ""); | 133 url_request_->SetPostData("application/json", ""); |
| 103 } | 134 } |
| 104 | 135 |
| 105 HttpIceConfigRequest::~HttpIceConfigRequest() {} | 136 HttpIceConfigRequest::~HttpIceConfigRequest() {} |
| 106 | 137 |
| 107 void HttpIceConfigRequest::Send(const OnIceConfigCallback& callback) { | 138 void HttpIceConfigRequest::Send(const OnIceConfigCallback& callback) { |
| 108 DCHECK(on_ice_config_callback_.is_null()); | 139 DCHECK(on_ice_config_callback_.is_null()); |
| 109 DCHECK(!callback.is_null()); | 140 DCHECK(!callback.is_null()); |
| 110 | 141 |
| 111 on_ice_config_callback_ = callback; | 142 on_ice_config_callback_ = callback; |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 if (errors_found || ice_config.stun_servers.empty() || | 233 if (errors_found || ice_config.stun_servers.empty() || |
| 203 ice_config.turn_servers.empty()) { | 234 ice_config.turn_servers.empty()) { |
| 204 ice_config.expiration_time = base::Time::Now(); | 235 ice_config.expiration_time = base::Time::Now(); |
| 205 } | 236 } |
| 206 | 237 |
| 207 base::ResetAndReturn(&on_ice_config_callback_).Run(ice_config); | 238 base::ResetAndReturn(&on_ice_config_callback_).Run(ice_config); |
| 208 } | 239 } |
| 209 | 240 |
| 210 } // namespace protocol | 241 } // namespace protocol |
| 211 } // namespace remoting | 242 } // namespace remoting |
| OLD | NEW |