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

Side by Side Diff: components/password_manager/core/browser/affiliation_utils.cc

Issue 1066543004: Update affiliated web credentials when Android credentials are updated. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix the correct MessageLoopProxy occurrence this time. Created 5 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 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_utils.h" 5 #include "components/password_manager/core/browser/affiliation_utils.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <ostream> 8 #include <ostream>
9 9
10 #include "base/base64.h" 10 #include "base/base64.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/metrics/field_trial.h" 12 #include "base/metrics/field_trial.h"
13 #include "base/strings/string_piece.h" 13 #include "base/strings/string_piece.h"
14 #include "base/strings/string_util.h" 14 #include "base/strings/string_util.h"
15 #include "components/password_manager/core/common/password_manager_switches.h" 15 #include "components/password_manager/core/common/password_manager_switches.h"
16 #include "components/variations/variations_associated_data.h"
16 #include "net/base/escape.h" 17 #include "net/base/escape.h"
17 #include "url/third_party/mozilla/url_parse.h" 18 #include "url/third_party/mozilla/url_parse.h"
18 #include "url/url_canon_stdstring.h" 19 #include "url/url_canon_stdstring.h"
19 #include "url/url_util.h" 20 #include "url/url_util.h"
20 21
21 namespace password_manager { 22 namespace password_manager {
22 23
23 namespace { 24 namespace {
24 25
25 // The scheme used for identifying Android applications. 26 // The scheme used for identifying Android applications.
26 const char kAndroidAppScheme[] = "android"; 27 const char kAndroidAppScheme[] = "android";
27 28
29 // The name of the field trial controlling affiliation-based matching.
30 const char kFieldTrialName[] = "AffiliationBasedMatching";
31
28 // Returns a StringPiece corresponding to |component| in |uri|, or the empty 32 // Returns a StringPiece corresponding to |component| in |uri|, or the empty
29 // string in case there is no such component. 33 // string in case there is no such component.
30 base::StringPiece ComponentString(const std::string& uri, 34 base::StringPiece ComponentString(const std::string& uri,
31 const url::Component& component) { 35 const url::Component& component) {
32 if (!component.is_valid()) 36 if (!component.is_valid())
33 return base::StringPiece(); 37 return base::StringPiece();
34 return base::StringPiece(uri.c_str() + component.begin, component.len); 38 return base::StringPiece(uri.c_str() + component.begin, component.len);
35 } 39 }
36 40
37 // Returns true if the passed ASCII |input| string contains nothing else than 41 // Returns true if the passed ASCII |input| string contains nothing else than
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 std::vector<FacetURI> b_sorted(b.begin(), b.end()); 289 std::vector<FacetURI> b_sorted(b.begin(), b.end());
286 std::sort(a_sorted.begin(), a_sorted.end()); 290 std::sort(a_sorted.begin(), a_sorted.end());
287 std::sort(b_sorted.begin(), b_sorted.end()); 291 std::sort(b_sorted.begin(), b_sorted.end());
288 return std::equal(a_sorted.begin(), a_sorted.end(), b_sorted.begin()); 292 return std::equal(a_sorted.begin(), a_sorted.end(), b_sorted.begin());
289 } 293 }
290 294
291 bool IsAffiliationBasedMatchingEnabled(const base::CommandLine& command_line) { 295 bool IsAffiliationBasedMatchingEnabled(const base::CommandLine& command_line) {
292 // Note: It is important to always query the field trial state, to ensure that 296 // Note: It is important to always query the field trial state, to ensure that
293 // UMA reports the correct group. 297 // UMA reports the correct group.
294 const std::string group_name = 298 const std::string group_name =
295 base::FieldTrialList::FindFullName("AffiliationBasedMatching"); 299 base::FieldTrialList::FindFullName(kFieldTrialName);
296 300
297 if (command_line.HasSwitch(switches::kDisableAffiliationBasedMatching)) 301 if (command_line.HasSwitch(switches::kDisableAffiliationBasedMatching))
298 return false; 302 return false;
299 if (command_line.HasSwitch(switches::kEnableAffiliationBasedMatching)) 303 if (command_line.HasSwitch(switches::kEnableAffiliationBasedMatching))
300 return true; 304 return true;
301 return StartsWithASCII(group_name, "Enabled", /*case_sensitive=*/false); 305 return StartsWithASCII(group_name, "Enabled", /*case_sensitive=*/false);
302 } 306 }
303 307
308 bool IsPropagatingPasswordChangesToWebCredentialsEnabled(
309 const base::CommandLine& command_line) {
310 // Note: It is important to always query the variation param first, which, in
311 // turn, queries the field trial state, which ensures that UMA reports the
312 // correct group if it is forced by a command line flag.
313 const std::string update_enabled = variations::GetVariationParamValue(
314 kFieldTrialName, "propagate_password_changes_to_web");
315
316 if (command_line.HasSwitch(switches::kDisableAffiliationBasedMatching))
317 return false;
318 if (command_line.HasSwitch(switches::kEnableAffiliationBasedMatching))
319 return true;
320 return LowerCaseEqualsASCII(update_enabled, "enabled");
321 }
322
304 bool IsValidAndroidFacetURI(const std::string& url) { 323 bool IsValidAndroidFacetURI(const std::string& url) {
305 FacetURI facet = FacetURI::FromPotentiallyInvalidSpec(url); 324 FacetURI facet = FacetURI::FromPotentiallyInvalidSpec(url);
306 return facet.IsValidAndroidFacetURI(); 325 return facet.IsValidAndroidFacetURI();
307 } 326 }
308 327
309 } // namespace password_manager 328 } // namespace password_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698