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

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

Issue 1668523002: [Password Manager] Switch password manager code to use the Feature framework. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addresses the review inputs. Created 4 years, 10 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"
12 #include "base/metrics/field_trial.h" 11 #include "base/metrics/field_trial.h"
13 #include "base/strings/string_piece.h" 12 #include "base/strings/string_piece.h"
14 #include "base/strings/string_util.h" 13 #include "base/strings/string_util.h"
15 #include "components/autofill/core/common/password_form.h" 14 #include "components/autofill/core/common/password_form.h"
16 #include "components/password_manager/core/common/password_manager_switches.h" 15 #include "components/password_manager/core/browser/password_manager_util.h"
16 #include "components/password_manager/core/common/password_manager_features.h"
17 #include "components/url_formatter/elide_url.h" 17 #include "components/url_formatter/elide_url.h"
18 #include "components/variations/variations_associated_data.h" 18 #include "components/variations/variations_associated_data.h"
19 #include "net/base/escape.h" 19 #include "net/base/escape.h"
20 #include "url/third_party/mozilla/url_parse.h" 20 #include "url/third_party/mozilla/url_parse.h"
21 #include "url/url_canon_stdstring.h" 21 #include "url/url_canon_stdstring.h"
22 22
23 namespace password_manager { 23 namespace password_manager {
24 24
25 namespace { 25 namespace {
26 26
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 if (a.size() != b.size()) 284 if (a.size() != b.size())
285 return false; 285 return false;
286 286
287 std::vector<FacetURI> a_sorted(a.begin(), a.end()); 287 std::vector<FacetURI> a_sorted(a.begin(), a.end());
288 std::vector<FacetURI> b_sorted(b.begin(), b.end()); 288 std::vector<FacetURI> b_sorted(b.begin(), b.end());
289 std::sort(a_sorted.begin(), a_sorted.end()); 289 std::sort(a_sorted.begin(), a_sorted.end());
290 std::sort(b_sorted.begin(), b_sorted.end()); 290 std::sort(b_sorted.begin(), b_sorted.end());
291 return std::equal(a_sorted.begin(), a_sorted.end(), b_sorted.begin()); 291 return std::equal(a_sorted.begin(), a_sorted.end(), b_sorted.begin());
292 } 292 }
293 293
294 bool IsAffiliationBasedMatchingEnabled(const base::CommandLine& command_line) { 294 bool IsAffiliationBasedMatchingEnabled() {
295 // Note: It is important to always query the field trial state, to ensure that 295 // Note: It is important to always query the field trial state, to ensure that
296 // UMA reports the correct group. 296 // UMA reports the correct group.
297 const std::string group_name = 297 const std::string group_name =
298 base::FieldTrialList::FindFullName(kFieldTrialName); 298 base::FieldTrialList::FindFullName(kFieldTrialName);
299 299
300 if (command_line.HasSwitch(switches::kDisableAffiliationBasedMatching)) 300 if (base::FeatureList::IsEnabled(features::kAffiliationBasedMatching))
301 return true;
302
303 if (password_manager_util::IsFeatureDisabledFromCommandLine(
304 features::kAffiliationBasedMatching)) {
301 return false; 305 return false;
302 if (command_line.HasSwitch(switches::kEnableAffiliationBasedMatching)) 306 }
303 return true; 307
304 return !base::StartsWith(group_name, "Disabled", 308 return !base::StartsWith(group_name, "Disabled",
305 base::CompareCase::INSENSITIVE_ASCII); 309 base::CompareCase::INSENSITIVE_ASCII);
306 } 310 }
307 311
308 bool IsPropagatingPasswordChangesToWebCredentialsEnabled( 312 bool IsPropagatingPasswordChangesToWebCredentialsEnabled() {
309 const base::CommandLine& command_line) {
310 // Note: It is important to always query the variation param first, which, in 313 // 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 314 // turn, queries the field trial state, which ensures that UMA reports the
312 // correct group if it is forced by a command line flag. 315 // correct group if it is forced by a command line flag.
313 const std::string update_enabled = variations::GetVariationParamValue( 316 const std::string update_enabled = variations::GetVariationParamValue(
314 kFieldTrialName, "propagate_password_changes_to_web"); 317 kFieldTrialName, "propagate_password_changes_to_web");
315 318
316 if (command_line.HasSwitch(switches::kDisableAffiliationBasedMatching)) 319 if (base::FeatureList::IsEnabled(features::kAffiliationBasedMatching))
320 return true;
321
322 if (password_manager_util::IsFeatureDisabledFromCommandLine(
323 features::kAffiliationBasedMatching)) {
317 return false; 324 return false;
318 if (command_line.HasSwitch(switches::kEnableAffiliationBasedMatching)) 325 }
319 return true; 326
320 return !base::LowerCaseEqualsASCII(update_enabled, "disabled"); 327 return !base::LowerCaseEqualsASCII(update_enabled, "disabled");
321 } 328 }
322 329
323 bool IsValidAndroidFacetURI(const std::string& url) { 330 bool IsValidAndroidFacetURI(const std::string& url) {
324 FacetURI facet = FacetURI::FromPotentiallyInvalidSpec(url); 331 FacetURI facet = FacetURI::FromPotentiallyInvalidSpec(url);
325 return facet.IsValidAndroidFacetURI(); 332 return facet.IsValidAndroidFacetURI();
326 } 333 }
327 334
328 std::string GetHumanReadableOrigin(const autofill::PasswordForm& password_form, 335 std::string GetHumanReadableOrigin(const autofill::PasswordForm& password_form,
329 const std::string& languages) { 336 const std::string& languages) {
330 FacetURI facet_uri = 337 FacetURI facet_uri =
331 FacetURI::FromPotentiallyInvalidSpec(password_form.signon_realm); 338 FacetURI::FromPotentiallyInvalidSpec(password_form.signon_realm);
332 if (facet_uri.IsValidAndroidFacetURI()) 339 if (facet_uri.IsValidAndroidFacetURI())
333 return GetHumanReadableOriginForAndroidUri(facet_uri); 340 return GetHumanReadableOriginForAndroidUri(facet_uri);
334 341
335 return base::UTF16ToUTF8(url_formatter::FormatUrlForSecurityDisplay( 342 return base::UTF16ToUTF8(url_formatter::FormatUrlForSecurityDisplay(
336 password_form.origin, languages)); 343 password_form.origin, languages));
337 } 344 }
338 345
339 std::string GetHumanReadableOriginForAndroidUri(const FacetURI facet_uri) { 346 std::string GetHumanReadableOriginForAndroidUri(const FacetURI facet_uri) {
340 DCHECK(facet_uri.IsValidAndroidFacetURI()); 347 DCHECK(facet_uri.IsValidAndroidFacetURI());
341 return facet_uri.scheme() + "://" + facet_uri.android_package_name(); 348 return facet_uri.scheme() + "://" + facet_uri.android_package_name();
342 } 349 }
343 350
344 } // namespace password_manager 351 } // namespace password_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698