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 "google_apis/gaia/oauth2_api_call_flow.h" | 5 #include "google_apis/gaia/oauth2_api_call_flow.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
72 CHECK(source); | 72 CHECK(source); |
73 CHECK_EQ(API_CALL_STARTED, state_); | 73 CHECK_EQ(API_CALL_STARTED, state_); |
74 EndApiCall(source); | 74 EndApiCall(source); |
75 } | 75 } |
76 | 76 |
77 std::unique_ptr<URLFetcher> OAuth2ApiCallFlow::CreateURLFetcher( | 77 std::unique_ptr<URLFetcher> OAuth2ApiCallFlow::CreateURLFetcher( |
78 net::URLRequestContextGetter* context, | 78 net::URLRequestContextGetter* context, |
79 const std::string& access_token) { | 79 const std::string& access_token) { |
80 std::string body = CreateApiCallBody(); | 80 std::string body = CreateApiCallBody(); |
81 net::URLFetcher::RequestType request_type = GetRequestTypeForBody(body); | 81 net::URLFetcher::RequestType request_type = GetRequestTypeForBody(body); |
82 std::unique_ptr<URLFetcher> result = | 82 net::NetworkTrafficAnnotationTag traffic_annotation = |
83 net::URLFetcher::Create(0, CreateApiCallUrl(), request_type, this); | 83 CompleteNetworkTrafficAnnotation("oauth2_api_call_flow", |
84 GetNetworkTrafficAnnotationTag(), R"( | |
85 policy { | |
86 cookies_allowed: false | |
87 setting: "..." | |
88 chrome_policy { | |
89 [POLICY_NAME] { | |
90 policy_options {mode: MANDATORY/RECOMMENDED/UNSET} | |
91 [POLICY_NAME]: ... //(value to disable it) | |
92 } | |
93 } | |
94 policy_exception_justification: "..." | |
95 })"); | |
96 std::unique_ptr<URLFetcher> result = net::URLFetcher::Create( | |
97 0, CreateApiCallUrl(), request_type, this, traffic_annotation); | |
Roger Tawa OOO till Jul 10th
2017/05/26 13:46:10
The annotation comes from GetNetworkTrafficAnnotat
Ramin Halavati
2017/05/29 05:30:52
At least cookies are set here. Is it OK if I remov
| |
84 | 98 |
85 gaia::MarkURLFetcherAsGaia(result.get()); | 99 gaia::MarkURLFetcherAsGaia(result.get()); |
86 result->SetRequestContext(context); | 100 result->SetRequestContext(context); |
87 result->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | | 101 result->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | |
88 net::LOAD_DO_NOT_SAVE_COOKIES); | 102 net::LOAD_DO_NOT_SAVE_COOKIES); |
89 result->AddExtraRequestHeader(MakeAuthorizationHeader(access_token)); | 103 result->AddExtraRequestHeader(MakeAuthorizationHeader(access_token)); |
90 // Fetchers are sometimes cancelled because a network change was detected, | 104 // Fetchers are sometimes cancelled because a network change was detected, |
91 // especially at startup and after sign-in on ChromeOS. Retrying once should | 105 // especially at startup and after sign-in on ChromeOS. Retrying once should |
92 // be enough in those cases; let the fetcher retry up to 3 times just in case. | 106 // be enough in those cases; let the fetcher retry up to 3 times just in case. |
93 // http://crbug.com/163710 | 107 // http://crbug.com/163710 |
94 result->SetAutomaticallyRetryOnNetworkChanges(3); | 108 result->SetAutomaticallyRetryOnNetworkChanges(3); |
95 | 109 |
96 // Even if the the body is empty, we still set the Content-Type because an | 110 // Even if the the body is empty, we still set the Content-Type because an |
97 // empty string may be a meaningful value. For example, a Protocol Buffer | 111 // empty string may be a meaningful value. For example, a Protocol Buffer |
98 // message with only default values will be serialized as an empty string. | 112 // message with only default values will be serialized as an empty string. |
99 if (request_type != net::URLFetcher::GET) | 113 if (request_type != net::URLFetcher::GET) |
100 result->SetUploadData(CreateApiCallBodyContentType(), body); | 114 result->SetUploadData(CreateApiCallBodyContentType(), body); |
101 | 115 |
102 return result; | 116 return result; |
103 } | 117 } |
OLD | NEW |