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

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

Issue 1172753003: Move LowerCaseEqualsASCII to base namespace (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@string_util
Patch Set: Created 5 years, 6 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/autofill/core/common/password_form.h" 15 #include "components/autofill/core/common/password_form.h"
16 #include "components/password_manager/core/common/password_manager_switches.h" 16 #include "components/password_manager/core/common/password_manager_switches.h"
17 #include "components/variations/variations_associated_data.h" 17 #include "components/variations/variations_associated_data.h"
18 #include "net/base/escape.h" 18 #include "net/base/escape.h"
19 #include "url/third_party/mozilla/url_parse.h" 19 #include "url/third_party/mozilla/url_parse.h"
20 #include "url/url_canon_stdstring.h" 20 #include "url/url_canon_stdstring.h"
21 #include "url/url_util.h"
22 21
23 namespace password_manager { 22 namespace password_manager {
24 23
25 namespace { 24 namespace {
26 25
27 // The scheme used for identifying Android applications. 26 // The scheme used for identifying Android applications.
28 const char kAndroidAppScheme[] = "android"; 27 const char kAndroidAppScheme[] = "android";
29 28
30 // The name of the field trial controlling affiliation-based matching. 29 // The name of the field trial controlling affiliation-based matching.
31 const char kFieldTrialName[] = "AffiliationBasedMatching"; 30 const char kFieldTrialName[] = "AffiliationBasedMatching";
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 bool ParseAndCanonicalizeFacetURI(const std::string& input_uri, 175 bool ParseAndCanonicalizeFacetURI(const std::string& input_uri,
177 std::string* canonical_uri) { 176 std::string* canonical_uri) {
178 DCHECK(canonical_uri); 177 DCHECK(canonical_uri);
179 canonical_uri->clear(); 178 canonical_uri->clear();
180 canonical_uri->reserve(input_uri.size() + 32); 179 canonical_uri->reserve(input_uri.size() + 32);
181 180
182 url::Parsed input_parsed; 181 url::Parsed input_parsed;
183 url::ParseStandardURL(input_uri.c_str(), input_uri.size(), &input_parsed); 182 url::ParseStandardURL(input_uri.c_str(), input_uri.size(), &input_parsed);
184 183
185 base::StringPiece scheme = ComponentString(input_uri, input_parsed.scheme); 184 base::StringPiece scheme = ComponentString(input_uri, input_parsed.scheme);
186 if (url::LowerCaseEqualsASCII(scheme.begin(), scheme.end(), 185 if (base::LowerCaseEqualsASCII(scheme.begin(), scheme.end(),
187 url::kHttpsScheme)) { 186 url::kHttpsScheme)) {
188 return CanonicalizeWebFacetURI(input_uri, input_parsed, canonical_uri); 187 return CanonicalizeWebFacetURI(input_uri, input_parsed, canonical_uri);
189 } else if (url::LowerCaseEqualsASCII(scheme.begin(), scheme.end(), 188 } else if (base::LowerCaseEqualsASCII(scheme.begin(), scheme.end(),
190 kAndroidAppScheme)) { 189 kAndroidAppScheme)) {
191 return CanonicalizeAndroidFacetURI(input_uri, input_parsed, canonical_uri); 190 return CanonicalizeAndroidFacetURI(input_uri, input_parsed, canonical_uri);
192 } 191 }
193 return false; 192 return false;
194 } 193 }
195 194
196 } // namespace 195 } // namespace
197 196
198 197
199 // FacetURI ------------------------------------------------------------------- 198 // FacetURI -------------------------------------------------------------------
200 199
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 // Note: It is important to always query the variation param first, which, in 310 // Note: It is important to always query the variation param first, which, in
312 // turn, queries the field trial state, which ensures that UMA reports the 311 // turn, queries the field trial state, which ensures that UMA reports the
313 // correct group if it is forced by a command line flag. 312 // correct group if it is forced by a command line flag.
314 const std::string update_enabled = variations::GetVariationParamValue( 313 const std::string update_enabled = variations::GetVariationParamValue(
315 kFieldTrialName, "propagate_password_changes_to_web"); 314 kFieldTrialName, "propagate_password_changes_to_web");
316 315
317 if (command_line.HasSwitch(switches::kDisableAffiliationBasedMatching)) 316 if (command_line.HasSwitch(switches::kDisableAffiliationBasedMatching))
318 return false; 317 return false;
319 if (command_line.HasSwitch(switches::kEnableAffiliationBasedMatching)) 318 if (command_line.HasSwitch(switches::kEnableAffiliationBasedMatching))
320 return true; 319 return true;
321 return LowerCaseEqualsASCII(update_enabled, "enabled"); 320 return base::LowerCaseEqualsASCII(update_enabled, "enabled");
322 } 321 }
323 322
324 bool IsAffiliationRequestsForDummyFacetsEnabled( 323 bool IsAffiliationRequestsForDummyFacetsEnabled(
325 const base::CommandLine& command_line) { 324 const base::CommandLine& command_line) {
326 const std::string synthesizing_enabled = variations::GetVariationParamValue( 325 const std::string synthesizing_enabled = variations::GetVariationParamValue(
327 kFieldTrialName, "affiliation_requests_for_dummy_facets"); 326 kFieldTrialName, "affiliation_requests_for_dummy_facets");
328 if (command_line.HasSwitch(switches::kDisableAffiliationBasedMatching)) 327 if (command_line.HasSwitch(switches::kDisableAffiliationBasedMatching))
329 return false; 328 return false;
330 if (command_line.HasSwitch(switches::kEnableAffiliationBasedMatching)) 329 if (command_line.HasSwitch(switches::kEnableAffiliationBasedMatching))
331 return true; 330 return true;
332 return LowerCaseEqualsASCII(synthesizing_enabled, "enabled"); 331 return base::LowerCaseEqualsASCII(synthesizing_enabled, "enabled");
333 } 332 }
334 333
335 bool IsValidAndroidFacetURI(const std::string& url) { 334 bool IsValidAndroidFacetURI(const std::string& url) {
336 FacetURI facet = FacetURI::FromPotentiallyInvalidSpec(url); 335 FacetURI facet = FacetURI::FromPotentiallyInvalidSpec(url);
337 return facet.IsValidAndroidFacetURI(); 336 return facet.IsValidAndroidFacetURI();
338 } 337 }
339 338
340 std::string GetHumanReadableOrigin(const autofill::PasswordForm& password_form, 339 std::string GetHumanReadableOrigin(const autofill::PasswordForm& password_form,
341 const std::string& languages) { 340 const std::string& languages) {
342 password_manager::FacetURI facet_uri = 341 password_manager::FacetURI facet_uri =
343 password_manager::FacetURI::FromPotentiallyInvalidSpec( 342 password_manager::FacetURI::FromPotentiallyInvalidSpec(
344 password_form.signon_realm); 343 password_form.signon_realm);
345 if (facet_uri.IsValidAndroidFacetURI()) 344 if (facet_uri.IsValidAndroidFacetURI())
346 return facet_uri.scheme() + "://" + facet_uri.android_package_name(); 345 return facet_uri.scheme() + "://" + facet_uri.android_package_name();
347 return base::UTF16ToUTF8(net::FormatUrl(password_form.origin, languages)); 346 return base::UTF16ToUTF8(net::FormatUrl(password_form.origin, languages));
348 } 347 }
349 } // namespace password_manager 348 } // namespace password_manager
OLDNEW
« no previous file with comments | « components/omnibox/search_provider.cc ('k') | components/plugins/renderer/mobile_youtube_plugin.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698