Chromium Code Reviews| OLD | NEW | 
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/password_manager/core/browser/affiliation_fetcher.h" | 5 #include "components/password_manager/core/browser/affiliation_fetcher.h" | 
| 6 | 6 | 
| 7 #include <stddef.h> | 7 #include <stddef.h> | 
| 8 #include <utility> | 8 #include <utility> | 
| 9 | 9 | 
| 10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" | 
| 11 #include "base/metrics/sparse_histogram.h" | 11 #include "base/metrics/sparse_histogram.h" | 
| 12 #include "components/password_manager/core/browser/affiliation_api.pb.h" | 12 #include "components/password_manager/core/browser/affiliation_api.pb.h" | 
| 13 #include "components/password_manager/core/browser/affiliation_utils.h" | 13 #include "components/password_manager/core/browser/affiliation_utils.h" | 
| 14 #include "components/password_manager/core/browser/test_affiliation_fetcher_fact ory.h" | 14 #include "components/password_manager/core/browser/test_affiliation_fetcher_fact ory.h" | 
| 15 #include "google_apis/google_api_keys.h" | 15 #include "google_apis/google_api_keys.h" | 
| 16 #include "net/base/load_flags.h" | 16 #include "net/base/load_flags.h" | 
| 17 #include "net/base/url_util.h" | 17 #include "net/base/url_util.h" | 
| 18 #include "net/http/http_status_code.h" | 18 #include "net/http/http_status_code.h" | 
| 19 #include "net/traffic_annotation/network_traffic_annotation.h" | |
| 19 #include "net/url_request/url_fetcher.h" | 20 #include "net/url_request/url_fetcher.h" | 
| 20 #include "net/url_request/url_request_context_getter.h" | 21 #include "net/url_request/url_request_context_getter.h" | 
| 21 #include "url/gurl.h" | 22 #include "url/gurl.h" | 
| 22 | 23 | 
| 23 namespace password_manager { | 24 namespace password_manager { | 
| 24 | 25 | 
| 25 namespace { | 26 namespace { | 
| 26 | 27 | 
| 27 // Enumeration listing the possible outcomes of fetching affiliation information | 28 // Enumeration listing the possible outcomes of fetching affiliation information | 
| 28 // from the Affiliation API. This is used in UMA histograms, so do not change | 29 // from the Affiliation API. This is used in UMA histograms, so do not change | 
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 84 | 85 | 
| 85 // static | 86 // static | 
| 86 void AffiliationFetcher::SetFactoryForTesting( | 87 void AffiliationFetcher::SetFactoryForTesting( | 
| 87 TestAffiliationFetcherFactory* factory) { | 88 TestAffiliationFetcherFactory* factory) { | 
| 88 g_testing_factory = factory; | 89 g_testing_factory = factory; | 
| 89 } | 90 } | 
| 90 | 91 | 
| 91 void AffiliationFetcher::StartRequest() { | 92 void AffiliationFetcher::StartRequest() { | 
| 92 DCHECK(!fetcher_); | 93 DCHECK(!fetcher_); | 
| 93 | 94 | 
| 94 fetcher_ = | 95 net::NetworkTrafficAnnotationTag traffic_annotation = | 
| 95 net::URLFetcher::Create(BuildQueryURL(), net::URLFetcher::POST, this); | 96 net::DefineNetworkTrafficAnnotation("android_affiliation", R"( | 
| 
 
engedy
2017/02/21 12:39:18
nit: How about affiliation_lookup?
 
Ramin Halavati
2017/02/21 13:12:02
Done.
 
 | |
| 97 semantics { | |
| 98 sender: "Affiliation Fetcher" | |
| 99 description: | |
| 100 "Password storage of users syncing their passwords to Google " | |
| 
 
engedy
2017/02/21 12:39:18
Suggestion for first sentence:
Users syncing thei
 
Ramin Halavati
2017/02/21 13:12:02
Done.
 
 | |
| 101 "without a custom passphrase may contain credentials for Android " | |
| 102 "apps. This service downloads the associations between Android " | |
| 103 "apps and the corresponding websites. Thus, the android " | |
| 
 
engedy
2017/02/21 12:39:18
nit: Android
 
Ramin Halavati
2017/02/21 13:12:02
Done.
 
 | |
| 104 "credentials can be used while browsing the web. " | |
| 105 trigger: "On startup." | |
| 
 
engedy
2017/02/21 12:39:18
Yes, it's most often on start-up, but there are al
 
Ramin Halavati
2017/02/21 13:12:02
Done.
 
 | |
| 106 data: | |
| 107 "List of Android apps the user has credentials for. The passwords " | |
| 108 "and usernames aren't sent." | |
| 109 destination: GOOGLE_OWNED_SERVICE | |
| 110 } | |
| 111 policy { | |
| 112 cookies_allowed: false | |
| 113 setting: | |
| 114 "Users can enable or disable this feature either by stoping " | |
| 115 "syncing passwords to Google (via unchecking 'Passwords' in " | |
| 116 "Chrome's settings under 'Sign In', 'advanced sync settings') or " | |
| 
 
engedy
2017/02/21 12:39:18
nit: Advanced
 
Ramin Halavati
2017/02/21 13:12:02
Done.
 
 | |
| 117 "by introducing a custom passphrase to disable this service. The " | |
| 118 "feature is enabled by default." | |
| 119 policy { | |
| 120 SyncDisabled { | |
| 121 policy_options {mode: MANDATORY} | |
| 122 value: True | |
| 123 } | |
| 124 } | |
| 125 })"); | |
| 126 fetcher_ = net::URLFetcher::Create(BuildQueryURL(), net::URLFetcher::POST, | |
| 127 this, traffic_annotation); | |
| 96 fetcher_->SetRequestContext(request_context_getter_.get()); | 128 fetcher_->SetRequestContext(request_context_getter_.get()); | 
| 97 fetcher_->SetUploadData("application/x-protobuf", PreparePayload()); | 129 fetcher_->SetUploadData("application/x-protobuf", PreparePayload()); | 
| 98 fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES | | 130 fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES | | 
| 99 net::LOAD_DO_NOT_SEND_COOKIES | | 131 net::LOAD_DO_NOT_SEND_COOKIES | | 
| 100 net::LOAD_DO_NOT_SEND_AUTH_DATA | | 132 net::LOAD_DO_NOT_SEND_AUTH_DATA | | 
| 101 net::LOAD_BYPASS_CACHE | net::LOAD_DISABLE_CACHE); | 133 net::LOAD_BYPASS_CACHE | net::LOAD_DISABLE_CACHE); | 
| 102 fetcher_->SetAutomaticallyRetryOn5xx(false); | 134 fetcher_->SetAutomaticallyRetryOn5xx(false); | 
| 103 fetcher_->SetAutomaticallyRetryOnNetworkChanges(0); | 135 fetcher_->SetAutomaticallyRetryOnNetworkChanges(0); | 
| 104 fetcher_->Start(); | 136 fetcher_->Start(); | 
| 105 } | 137 } | 
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 210 ReportStatistics(AFFILIATION_FETCH_RESULT_MALFORMED, nullptr); | 242 ReportStatistics(AFFILIATION_FETCH_RESULT_MALFORMED, nullptr); | 
| 211 delegate_->OnMalformedResponse(); | 243 delegate_->OnMalformedResponse(); | 
| 212 } | 244 } | 
| 213 } else { | 245 } else { | 
| 214 ReportStatistics(AFFILIATION_FETCH_RESULT_FAILURE, fetcher_.get()); | 246 ReportStatistics(AFFILIATION_FETCH_RESULT_FAILURE, fetcher_.get()); | 
| 215 delegate_->OnFetchFailed(); | 247 delegate_->OnFetchFailed(); | 
| 216 } | 248 } | 
| 217 } | 249 } | 
| 218 | 250 | 
| 219 } // namespace password_manager | 251 } // namespace password_manager | 
| OLD | NEW |