OLD | NEW |
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 Loading... |
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 Loading... |
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 } |
OLD | NEW |