| 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/api/web_request/web_request_permissions.h" | 5 #include "chrome/browser/extensions/api/web_request/web_request_permissions.h" |
| 6 | 6 |
| 7 #include "base/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
| 8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "chrome/browser/extensions/extension_renderer_state.h" | 9 #include "chrome/browser/extensions/extension_renderer_state.h" |
| 10 #include "chrome/common/extensions/extension_constants.h" | 10 #include "chrome/common/extensions/extension_constants.h" |
| 11 #include "chrome/common/url_constants.h" | 11 #include "chrome/common/url_constants.h" |
| 12 #include "content/public/browser/resource_request_info.h" | 12 #include "content/public/browser/resource_request_info.h" |
| 13 #include "extensions/browser/info_map.h" | 13 #include "extensions/browser/info_map.h" |
| 14 #include "extensions/common/constants.h" | 14 #include "extensions/common/constants.h" |
| 15 #include "extensions/common/extension.h" | 15 #include "extensions/common/extension.h" |
| 16 #include "extensions/common/permissions/permissions_data.h" | 16 #include "extensions/common/permissions/permissions_data.h" |
| 17 #include "net/base/url_constants.h" |
| 17 #include "net/url_request/url_request.h" | 18 #include "net/url_request/url_request.h" |
| 18 #include "url/gurl.h" | 19 #include "url/gurl.h" |
| 19 | 20 |
| 20 using content::ResourceRequestInfo; | 21 using content::ResourceRequestInfo; |
| 21 | 22 |
| 22 namespace { | 23 namespace { |
| 23 | 24 |
| 24 // Returns true if the URL is sensitive and requests to this URL must not be | 25 // Returns true if the URL is sensitive and requests to this URL must not be |
| 25 // modified/canceled by extensions, e.g. because it is targeted to the webstore | 26 // modified/canceled by extensions, e.g. because it is targeted to the webstore |
| 26 // to check for updates, extension blacklisting, etc. | 27 // to check for updates, extension blacklisting, etc. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 extension_urls::IsBlacklistUpdateUrl(url); | 65 extension_urls::IsBlacklistUpdateUrl(url); |
| 65 } | 66 } |
| 66 | 67 |
| 67 // Returns true if the scheme is one we want to allow extensions to have access | 68 // Returns true if the scheme is one we want to allow extensions to have access |
| 68 // to. Extensions still need specific permissions for a given URL, which is | 69 // to. Extensions still need specific permissions for a given URL, which is |
| 69 // covered by CanExtensionAccessURL. | 70 // covered by CanExtensionAccessURL. |
| 70 bool HasWebRequestScheme(const GURL& url) { | 71 bool HasWebRequestScheme(const GURL& url) { |
| 71 return (url.SchemeIs(content::kAboutScheme) || | 72 return (url.SchemeIs(content::kAboutScheme) || |
| 72 url.SchemeIs(content::kFileScheme) || | 73 url.SchemeIs(content::kFileScheme) || |
| 73 url.SchemeIs(content::kFileSystemScheme) || | 74 url.SchemeIs(content::kFileSystemScheme) || |
| 74 url.SchemeIs(content::kFtpScheme) || | 75 url.SchemeIs(content::kFtpScheme) || url.SchemeIs(net::kHttpScheme) || |
| 75 url.SchemeIs(content::kHttpScheme) || | 76 url.SchemeIs(net::kHttpsScheme) || |
| 76 url.SchemeIs(content::kHttpsScheme) || | |
| 77 url.SchemeIs(extensions::kExtensionScheme)); | 77 url.SchemeIs(extensions::kExtensionScheme)); |
| 78 } | 78 } |
| 79 | 79 |
| 80 } // namespace | 80 } // namespace |
| 81 | 81 |
| 82 // static | 82 // static |
| 83 bool WebRequestPermissions::HideRequest( | 83 bool WebRequestPermissions::HideRequest( |
| 84 const extensions::InfoMap* extension_info_map, | 84 const extensions::InfoMap* extension_info_map, |
| 85 const net::URLRequest* request) { | 85 const net::URLRequest* request) { |
| 86 // Hide requests from the Chrome WebStore App or signin process. | 86 // Hide requests from the Chrome WebStore App or signin process. |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 } | 139 } |
| 140 break; | 140 break; |
| 141 case REQUIRE_ALL_URLS: | 141 case REQUIRE_ALL_URLS: |
| 142 if (!extensions::PermissionsData::HasEffectiveAccessToAllHosts(extension)) | 142 if (!extensions::PermissionsData::HasEffectiveAccessToAllHosts(extension)) |
| 143 return false; | 143 return false; |
| 144 break; | 144 break; |
| 145 } | 145 } |
| 146 | 146 |
| 147 return true; | 147 return true; |
| 148 } | 148 } |
| OLD | NEW |