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

Side by Side Diff: chrome/browser/extensions/api/cookies/cookies_helpers.cc

Issue 2137503002: Revert of Replace string::find(prefix) == 0 pattern with base::StartsWith(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 (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 // Implements common functionality for the Chrome Extensions Cookies API. 5 // Implements common functionality for the Chrome Extensions Cookies API.
6 6
7 #include "chrome/browser/extensions/api/cookies/cookies_helpers.h" 7 #include "chrome/browser/extensions/api/cookies/cookies_helpers.h"
8 8
9 #include <stddef.h> 9 #include <stddef.h>
10 10
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 } else { 127 } else {
128 cookie_store->GetAllCookiesAsync(callback); 128 cookie_store->GetAllCookiesAsync(callback);
129 } 129 }
130 } 130 }
131 131
132 GURL GetURLFromCanonicalCookie(const net::CanonicalCookie& cookie) { 132 GURL GetURLFromCanonicalCookie(const net::CanonicalCookie& cookie) {
133 const std::string& domain_key = cookie.Domain(); 133 const std::string& domain_key = cookie.Domain();
134 const std::string scheme = 134 const std::string scheme =
135 cookie.IsSecure() ? url::kHttpsScheme : url::kHttpScheme; 135 cookie.IsSecure() ? url::kHttpsScheme : url::kHttpScheme;
136 const std::string host = 136 const std::string host =
137 base::StartsWith(domain_key, ".", base::CompareCase::SENSITIVE) 137 domain_key.find('.') != 0 ? domain_key : domain_key.substr(1);
138 ? domain_key.substr(1)
139 : domain_key;
140 return GURL(scheme + url::kStandardSchemeSeparator + host + "/"); 138 return GURL(scheme + url::kStandardSchemeSeparator + host + "/");
141 } 139 }
142 140
143 void AppendMatchingCookiesToVector(const net::CookieList& all_cookies, 141 void AppendMatchingCookiesToVector(const net::CookieList& all_cookies,
144 const GURL& url, 142 const GURL& url,
145 const GetAll::Params::Details* details, 143 const GetAll::Params::Details* details,
146 const Extension* extension, 144 const Extension* extension,
147 std::vector<Cookie>* match_vector) { 145 std::vector<Cookie>* match_vector) {
148 for (const net::CanonicalCookie& cookie : all_cookies) { 146 for (const net::CanonicalCookie& cookie : all_cookies) {
149 // Ignore any cookie whose domain doesn't match the extension's 147 // Ignore any cookie whose domain doesn't match the extension's
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 if (sub_domain == *details_->domain) 210 if (sub_domain == *details_->domain)
213 return true; 211 return true;
214 const size_t next_dot = sub_domain.find('.', 1); // Skip over leading dot. 212 const size_t next_dot = sub_domain.find('.', 1); // Skip over leading dot.
215 sub_domain.erase(0, next_dot); 213 sub_domain.erase(0, next_dot);
216 } 214 }
217 return false; 215 return false;
218 } 216 }
219 217
220 } // namespace cookies_helpers 218 } // namespace cookies_helpers
221 } // namespace extensions 219 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/download/download_browsertest.cc ('k') | chrome/browser/profiles/profile_avatar_icon_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698