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

Side by Side Diff: chrome/browser/password_manager/login_database.cc

Issue 102843002: Move RemoveChars, ReplaceChars, TrimString, and TruncateUTF8ToByteSize to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 | Annotate | Revision Log
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 "chrome/browser/password_manager/login_database.h" 5 #include "chrome/browser/password_manager/login_database.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 // in the |logins| table. The result (scheme, domain and port) is verified 493 // in the |logins| table. The result (scheme, domain and port) is verified
494 // further down using GURL. See the functions SchemeMatches, 494 // further down using GURL. See the functions SchemeMatches,
495 // RegistryControlledDomainMatches and PortMatches. 495 // RegistryControlledDomainMatches and PortMatches.
496 const std::string extended_sql_query = 496 const std::string extended_sql_query =
497 sql_query + "OR signon_realm REGEXP ? "; 497 sql_query + "OR signon_realm REGEXP ? ";
498 // TODO(nyquist) Re-enable usage of GetCachedStatement when 498 // TODO(nyquist) Re-enable usage of GetCachedStatement when
499 // http://crbug.com/248608 is fixed. 499 // http://crbug.com/248608 is fixed.
500 s.Assign(db_.GetUniqueStatement(extended_sql_query.c_str())); 500 s.Assign(db_.GetUniqueStatement(extended_sql_query.c_str()));
501 // We need to escape . in the domain. Since the domain has already been 501 // We need to escape . in the domain. Since the domain has already been
502 // sanitized using GURL, we do not need to escape any other characters. 502 // sanitized using GURL, we do not need to escape any other characters.
503 ReplaceChars(registered_domain, ".", "\\.", &registered_domain); 503 base::ReplaceChars(registered_domain, ".", "\\.", &registered_domain);
504 std::string scheme = signon_realm.scheme(); 504 std::string scheme = signon_realm.scheme();
505 // We need to escape . in the scheme. Since the scheme has already been 505 // We need to escape . in the scheme. Since the scheme has already been
506 // sanitized using GURL, we do not need to escape any other characters. 506 // sanitized using GURL, we do not need to escape any other characters.
507 // The scheme soap.beep is an example with '.'. 507 // The scheme soap.beep is an example with '.'.
508 ReplaceChars(scheme, ".", "\\.", &scheme); 508 base::ReplaceChars(scheme, ".", "\\.", &scheme);
509 const std::string port = signon_realm.port(); 509 const std::string port = signon_realm.port();
510 // For a signon realm such as http://foo.bar/, this regexp will match 510 // For a signon realm such as http://foo.bar/, this regexp will match
511 // domains on the form http://foo.bar/, http://www.foo.bar/, 511 // domains on the form http://foo.bar/, http://www.foo.bar/,
512 // http://www.mobile.foo.bar/. It will not match http://notfoo.bar/. 512 // http://www.mobile.foo.bar/. It will not match http://notfoo.bar/.
513 // The scheme and port has to be the same as the observed form. 513 // The scheme and port has to be the same as the observed form.
514 std::string regexp = "^(" + scheme + ":\\/\\/)([\\w-]+\\.)*" + 514 std::string regexp = "^(" + scheme + ":\\/\\/)([\\w-]+\\.)*" +
515 registered_domain + "(:" + port + ")?\\/$"; 515 registered_domain + "(:" + port + ")?\\/$";
516 s.BindString(0, form.signon_realm); 516 s.BindString(0, form.signon_realm);
517 s.BindString(1, regexp); 517 s.BindString(1, regexp);
518 } else { 518 } else {
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 std::vector<string16> LoginDatabase::DeserializeVector(const Pickle& p) const { 644 std::vector<string16> LoginDatabase::DeserializeVector(const Pickle& p) const {
645 std::vector<string16> ret; 645 std::vector<string16> ret;
646 string16 str; 646 string16 str;
647 647
648 PickleIterator iterator(p); 648 PickleIterator iterator(p);
649 while (iterator.ReadString16(&str)) { 649 while (iterator.ReadString16(&str)) {
650 ret.push_back(str); 650 ret.push_back(str);
651 } 651 }
652 return ret; 652 return ret;
653 } 653 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698