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

Side by Side Diff: chrome/browser/extensions/extension_webrequest_api.cc

Issue 9120011: Use GURL::Replacements to trim query and ref from URL (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/extensions/extension_webrequest_api.h" 5 #include "chrome/browser/extensions/extension_webrequest_api.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/json/json_writer.h" 10 #include "base/json/json_writer.h"
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 139
140 // Returns true if the URL is sensitive and requests to this URL must not be 140 // Returns true if the URL is sensitive and requests to this URL must not be
141 // modified/canceled by extensions, e.g. because it is targeted to the webstore 141 // modified/canceled by extensions, e.g. because it is targeted to the webstore
142 // to check for updates, extension blacklisting, etc. 142 // to check for updates, extension blacklisting, etc.
143 bool IsSensitiveURL(const GURL& url) { 143 bool IsSensitiveURL(const GURL& url) {
144 bool is_webstore_gallery_url = 144 bool is_webstore_gallery_url =
145 StartsWithASCII(url.spec(), extension_urls::kGalleryBrowsePrefix, true); 145 StartsWithASCII(url.spec(), extension_urls::kGalleryBrowsePrefix, true);
146 bool is_google_com_chrome_url = 146 bool is_google_com_chrome_url =
147 EndsWith(url.host(), "google.com", true) && 147 EndsWith(url.host(), "google.com", true) &&
148 StartsWithASCII(url.path(), "/chrome", true); 148 StartsWithASCII(url.path(), "/chrome", true);
149 std::string url_without_query = 149 GURL::Replacements replacements;
150 url.spec().substr(0, url.spec().find_first_of('?')); 150 replacements.ClearQuery();
151 replacements.ClearRef();
152 GURL url_without_query = url.ReplaceComponents(replacements);
151 return is_webstore_gallery_url || is_google_com_chrome_url || 153 return is_webstore_gallery_url || is_google_com_chrome_url ||
152 extension_urls::IsWebstoreUpdateUrl(GURL(url_without_query)) || 154 extension_urls::IsWebstoreUpdateUrl(url_without_query) ||
153 extension_urls::IsBlacklistUpdateUrl(url); 155 extension_urls::IsBlacklistUpdateUrl(url);
154 } 156 }
155 157
156 // Returns true if the scheme is one we want to allow extensions to have access 158 // Returns true if the scheme is one we want to allow extensions to have access
157 // to. Extensions still need specific permissions for a given URL, which is 159 // to. Extensions still need specific permissions for a given URL, which is
158 // covered by CanExtensionAccessURL. 160 // covered by CanExtensionAccessURL.
159 bool HasWebRequestScheme(const GURL& url) { 161 bool HasWebRequestScheme(const GURL& url) {
160 return (url.SchemeIs(chrome::kAboutScheme) || 162 return (url.SchemeIs(chrome::kAboutScheme) ||
161 url.SchemeIs(chrome::kFileScheme) || 163 url.SchemeIs(chrome::kFileScheme) ||
162 url.SchemeIs(chrome::kFtpScheme) || 164 url.SchemeIs(chrome::kFtpScheme) ||
(...skipping 1562 matching lines...) Expand 10 before | Expand all | Expand 10 after
1725 } else if ((*it)->name().find("AdBlock") != std::string::npos) { 1727 } else if ((*it)->name().find("AdBlock") != std::string::npos) {
1726 adblock = true; 1728 adblock = true;
1727 } else { 1729 } else {
1728 other = true; 1730 other = true;
1729 } 1731 }
1730 } 1732 }
1731 } 1733 }
1732 1734
1733 host->Send(new ExtensionMsg_UsingWebRequestAPI(adblock, adblock_plus, other)); 1735 host->Send(new ExtensionMsg_UsingWebRequestAPI(adblock, adblock_plus, other));
1734 } 1736 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698