OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/service/cloud_print/cloud_print_url_fetcher.h" | 5 #include "chrome/service/cloud_print/cloud_print_url_fetcher.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
11 #include "base/values.h" | 11 #include "base/values.h" |
12 #include "chrome/common/cloud_print/cloud_print_constants.h" | 12 #include "chrome/common/cloud_print/cloud_print_constants.h" |
13 #include "chrome/common/cloud_print/cloud_print_helpers.h" | 13 #include "chrome/common/cloud_print/cloud_print_helpers.h" |
14 #include "chrome/service/cloud_print/cloud_print_service_helpers.h" | 14 #include "chrome/service/cloud_print/cloud_print_service_helpers.h" |
15 #include "chrome/service/cloud_print/cloud_print_token_store.h" | 15 #include "chrome/service/cloud_print/cloud_print_token_store.h" |
16 #include "chrome/service/net/service_url_request_context_getter.h" | 16 #include "chrome/service/net/service_url_request_context_getter.h" |
17 #include "chrome/service/service_process.h" | 17 #include "chrome/service/service_process.h" |
18 #include "components/data_use_measurement/core/data_use_user_data.h" | 18 #include "components/data_use_measurement/core/data_use_user_data.h" |
19 #include "net/base/load_flags.h" | 19 #include "net/base/load_flags.h" |
20 #include "net/http/http_status_code.h" | 20 #include "net/http/http_status_code.h" |
21 #include "net/traffic_annotation/network_traffic_annotation.h" | |
21 #include "net/url_request/url_fetcher.h" | 22 #include "net/url_request/url_fetcher.h" |
22 #include "net/url_request/url_request_status.h" | 23 #include "net/url_request/url_request_status.h" |
23 #include "url/gurl.h" | 24 #include "url/gurl.h" |
24 | 25 |
25 namespace cloud_print { | 26 namespace cloud_print { |
26 | 27 |
27 namespace { | 28 namespace { |
28 | 29 |
29 void ReportRequestTime(CloudPrintURLFetcher::RequestType type, | 30 void ReportRequestTime(CloudPrintURLFetcher::RequestType type, |
30 base::TimeDelta time) { | 31 base::TimeDelta time) { |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
252 int max_retries, | 253 int max_retries, |
253 const std::string& post_data_mime_type, | 254 const std::string& post_data_mime_type, |
254 const std::string& post_data, | 255 const std::string& post_data, |
255 const std::string& additional_headers) { | 256 const std::string& additional_headers) { |
256 DCHECK(delegate); | 257 DCHECK(delegate); |
257 type_ = type; | 258 type_ = type; |
258 UMA_HISTOGRAM_ENUMERATION("CloudPrint.UrlFetcherRequestType", type, | 259 UMA_HISTOGRAM_ENUMERATION("CloudPrint.UrlFetcherRequestType", type, |
259 REQUEST_MAX); | 260 REQUEST_MAX); |
260 // Persist the additional headers in case we need to retry the request. | 261 // Persist the additional headers in case we need to retry the request. |
261 additional_headers_ = additional_headers; | 262 additional_headers_ = additional_headers; |
262 request_ = net::URLFetcher::Create(0, url, request_type, this); | 263 net::NetworkTrafficAnnotationTag traffic_annotation = |
264 net::DefineNetworkTrafficAnnotation("cloud_print_url_fetcher", R"( | |
265 semantics { | |
266 sender: "Cloud Print" | |
267 description: | |
268 "Google Cloud Print allows users to print to a corp printer " | |
Lei Zhang
2017/04/18 19:16:41
Drop the word corp? Lots of people use Cloud Print
Ramin Halavati
2017/04/19 05:59:07
Done.
| |
269 "without needing to add the printer to their computer" | |
270 trigger: | |
271 "Printing and running background Cloud Print services." | |
272 data: "..." | |
273 destination: WEBSITE/GOOGLE_OWNED_SERVICE/OTHER | |
274 } | |
275 policy { | |
276 cookies_allowed: true | |
Vitaly Buka (NO REVIEWS)
2017/04/18 17:32:44
ths is incorrect
it sets net::LOAD_DO_NOT_SEND_COO
Ramin Halavati
2017/04/19 05:59:06
Done.
| |
277 cookies_store: "user" | |
278 setting: | |
279 "This feature cannot be disabled by settings." | |
280 chrome_policy { | |
281 CloudPrintProxyEnabled { | |
282 policy_options {mode: MANDATORY} | |
283 CloudPrintProxyEnabled: false | |
284 } | |
285 } | |
286 chrome_policy { | |
287 CloudPrintSubmitEnabled { | |
288 policy_options {mode: MANDATORY} | |
289 CloudPrintSubmitEnabled: false | |
290 } | |
291 } | |
292 })"); | |
293 request_ = | |
294 net::URLFetcher::Create(0, url, request_type, this, traffic_annotation); | |
263 data_use_measurement::DataUseUserData::AttachToFetcher( | 295 data_use_measurement::DataUseUserData::AttachToFetcher( |
264 request_.get(), data_use_measurement::DataUseUserData::CLOUD_PRINT); | 296 request_.get(), data_use_measurement::DataUseUserData::CLOUD_PRINT); |
265 request_->SetRequestContext(GetRequestContextGetter()); | 297 request_->SetRequestContext(GetRequestContextGetter()); |
266 // Since we implement our own retry logic, disable the retry in URLFetcher. | 298 // Since we implement our own retry logic, disable the retry in URLFetcher. |
267 request_->SetAutomaticallyRetryOn5xx(false); | 299 request_->SetAutomaticallyRetryOn5xx(false); |
268 request_->SetMaxRetriesOn5xx(max_retries); | 300 request_->SetMaxRetriesOn5xx(max_retries); |
269 delegate_ = delegate; | 301 delegate_ = delegate; |
270 SetupRequestHeaders(); | 302 SetupRequestHeaders(); |
271 request_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | | 303 request_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | |
272 net::LOAD_DO_NOT_SAVE_COOKIES); | 304 net::LOAD_DO_NOT_SAVE_COOKIES); |
(...skipping 23 matching lines...) Expand all Loading... | |
296 ServiceURLRequestContextGetter* getter = | 328 ServiceURLRequestContextGetter* getter = |
297 g_service_process->GetServiceURLRequestContextGetter(); | 329 g_service_process->GetServiceURLRequestContextGetter(); |
298 // Now set up the user agent for cloudprint. | 330 // Now set up the user agent for cloudprint. |
299 std::string user_agent = getter->user_agent(); | 331 std::string user_agent = getter->user_agent(); |
300 base::StringAppendF(&user_agent, " %s", kCloudPrintUserAgent); | 332 base::StringAppendF(&user_agent, " %s", kCloudPrintUserAgent); |
301 getter->set_user_agent(user_agent); | 333 getter->set_user_agent(user_agent); |
302 return getter; | 334 return getter; |
303 } | 335 } |
304 | 336 |
305 } // namespace cloud_print | 337 } // namespace cloud_print |
OLD | NEW |