Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(49)

Side by Side Diff: components/policy/core/common/cloud/user_info_fetcher.cc

Issue 2800653002: Network traffic annotation added to common/cloud. (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "components/policy/core/common/cloud/user_info_fetcher.h" 5 #include "components/policy/core/common/cloud/user_info_fetcher.h"
6 6
7 #include "base/json/json_reader.h" 7 #include "base/json/json_reader.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "base/values.h" 10 #include "base/values.h"
11 #include "components/data_use_measurement/core/data_use_user_data.h" 11 #include "components/data_use_measurement/core/data_use_user_data.h"
12 #include "google_apis/gaia/gaia_urls.h" 12 #include "google_apis/gaia/gaia_urls.h"
13 #include "google_apis/gaia/google_service_auth_error.h" 13 #include "google_apis/gaia/google_service_auth_error.h"
14 #include "net/base/load_flags.h" 14 #include "net/base/load_flags.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 "net/url_request/url_fetcher.h" 17 #include "net/url_request/url_fetcher.h"
17 #include "net/url_request/url_request_status.h" 18 #include "net/url_request/url_request_status.h"
18 #include "url/gurl.h" 19 #include "url/gurl.h"
19 20
20 namespace { 21 namespace {
21 22
22 static const char kAuthorizationHeaderFormat[] = 23 static const char kAuthorizationHeaderFormat[] =
23 "Authorization: Bearer %s"; 24 "Authorization: Bearer %s";
24 25
25 static std::string MakeAuthorizationHeader(const std::string& auth_token) { 26 static std::string MakeAuthorizationHeader(const std::string& auth_token) {
26 return base::StringPrintf(kAuthorizationHeaderFormat, auth_token.c_str()); 27 return base::StringPrintf(kAuthorizationHeaderFormat, auth_token.c_str());
27 } 28 }
28 29
29 } // namespace 30 } // namespace
30 31
31 namespace policy { 32 namespace policy {
32 33
33 UserInfoFetcher::UserInfoFetcher(Delegate* delegate, 34 UserInfoFetcher::UserInfoFetcher(Delegate* delegate,
34 net::URLRequestContextGetter* context) 35 net::URLRequestContextGetter* context)
35 : delegate_(delegate), 36 : delegate_(delegate),
36 context_(context) { 37 context_(context) {
37 DCHECK(delegate); 38 DCHECK(delegate);
38 } 39 }
39 40
40 UserInfoFetcher::~UserInfoFetcher() { 41 UserInfoFetcher::~UserInfoFetcher() {
41 } 42 }
42 43
43 void UserInfoFetcher::Start(const std::string& access_token) { 44 void UserInfoFetcher::Start(const std::string& access_token) {
45 net::NetworkTrafficAnnotationTag traffic_annotation =
46 net::DefineNetworkTrafficAnnotation("...", R"(
47 semantics {
48 sender: "..."
pastarmovj 2017/04/07 09:58:46 Cloud Policy
Ramin Halavati 2017/04/19 05:21:58 Done.
49 description: "..."
Andrew T Wilson (Slow) 2017/04/18 12:01:32 Calls to the Google Account service to check if th
Ramin Halavati 2017/04/19 05:21:58 Done.
50 trigger: "..."
Andrew T Wilson (Slow) 2017/04/18 12:01:32 User signing in to Chrome.
Ramin Halavati 2017/04/19 05:21:58 Done.
51 data: "..."
Andrew T Wilson (Slow) 2017/04/18 12:01:32 Information about the user (specifically whether t
Ramin Halavati 2017/04/19 05:21:58 Done.
52 destination: WEBSITE/GOOGLE_OWNED_SERVICE/OTHER
pastarmovj 2017/04/07 09:58:46 GOOGLE_OWNED_SERVICE
Ramin Halavati 2017/04/19 05:21:58 Done.
53 }
54 policy {
55 cookies_allowed: false/true
pastarmovj 2017/04/07 09:58:46 true?
Andrew T Wilson (Slow) 2017/04/18 12:01:32 true
Ramin Halavati 2017/04/19 05:21:58 SAVE and SEND seem to be disabled in load flags. A
Andrew T Wilson (Slow) 2017/04/25 13:48:01 Not intentionally. So feel free to mark this as fa
Ramin Halavati 2017/04/26 05:28:06 Done.
56 cookies_store: "..."
Andrew T Wilson (Slow) 2017/04/18 12:01:32 system
Ramin Halavati 2017/04/19 05:21:58 Done.
57 setting: "..."
Andrew T Wilson (Slow) 2017/04/18 12:01:32 none
Ramin Halavati 2017/04/19 05:21:58 Done.
58 chrome_policy {
59 [POLICY_NAME] {
Andrew T Wilson (Slow) 2017/04/18 12:01:32 SigninAllowed
Ramin Halavati 2017/04/19 05:21:58 Done.
60 policy_options {mode: MANDATORY/RECOMMENDED/UNSET}
Andrew T Wilson (Slow) 2017/04/18 12:01:32 MANDATORY
Ramin Halavati 2017/04/19 05:21:58 Done.
61 [POLICY_NAME]: ... //(value to disable it)
Andrew T Wilson (Slow) 2017/04/18 12:01:32 SigninAllowed: false
Ramin Halavati 2017/04/19 05:21:58 Done.
62 }
63 }
64 policy_exception_justification: "..."
pastarmovj 2017/04/07 09:58:46 The request is part of the policy fetcher itself.
Ramin Halavati 2017/04/19 05:21:58 Done.
65 })");
44 // Create a URLFetcher and start it. 66 // Create a URLFetcher and start it.
45 url_fetcher_ = 67 url_fetcher_ =
46 net::URLFetcher::Create(0, GaiaUrls::GetInstance()->oauth_user_info_url(), 68 net::URLFetcher::Create(0, GaiaUrls::GetInstance()->oauth_user_info_url(),
47 net::URLFetcher::GET, this); 69 net::URLFetcher::GET, this, traffic_annotation);
48 data_use_measurement::DataUseUserData::AttachToFetcher( 70 data_use_measurement::DataUseUserData::AttachToFetcher(
49 url_fetcher_.get(), data_use_measurement::DataUseUserData::POLICY); 71 url_fetcher_.get(), data_use_measurement::DataUseUserData::POLICY);
50 url_fetcher_->SetRequestContext(context_); 72 url_fetcher_->SetRequestContext(context_);
51 url_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | 73 url_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES |
52 net::LOAD_DO_NOT_SAVE_COOKIES); 74 net::LOAD_DO_NOT_SAVE_COOKIES);
53 url_fetcher_->AddExtraRequestHeader(MakeAuthorizationHeader(access_token)); 75 url_fetcher_->AddExtraRequestHeader(MakeAuthorizationHeader(access_token));
54 url_fetcher_->Start(); // Results in a call to OnURLFetchComplete(). 76 url_fetcher_->Start(); // Results in a call to OnURLFetchComplete().
55 } 77 }
56 78
57 void UserInfoFetcher::OnURLFetchComplete(const net::URLFetcher* source) { 79 void UserInfoFetcher::OnURLFetchComplete(const net::URLFetcher* source) {
(...skipping 26 matching lines...) Expand all
84 if (parsed_value.get() && parsed_value->GetAsDictionary(&dict)) { 106 if (parsed_value.get() && parsed_value->GetAsDictionary(&dict)) {
85 delegate_->OnGetUserInfoSuccess(dict); 107 delegate_->OnGetUserInfoSuccess(dict);
86 } else { 108 } else {
87 NOTREACHED() << "Could not parse userinfo response from server"; 109 NOTREACHED() << "Could not parse userinfo response from server";
88 delegate_->OnGetUserInfoFailure(GoogleServiceAuthError( 110 delegate_->OnGetUserInfoFailure(GoogleServiceAuthError(
89 GoogleServiceAuthError::CONNECTION_FAILED)); 111 GoogleServiceAuthError::CONNECTION_FAILED));
90 } 112 }
91 } 113 }
92 114
93 }; // namespace policy 115 }; // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698