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_api.h" | 5 #include "chrome/browser/extensions/api/web_request/web_request_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/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 2196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2207 ipc_sender.get() ? ipc_sender->render_process_id() : -1; | 2207 ipc_sender.get() ? ipc_sender->render_process_id() : -1; |
2208 | 2208 |
2209 const Extension* extension = | 2209 const Extension* extension = |
2210 extension_info_map()->extensions().GetByID(extension_id()); | 2210 extension_info_map()->extensions().GetByID(extension_id()); |
2211 std::string extension_name = extension ? extension->name() : extension_id(); | 2211 std::string extension_name = extension ? extension->name() : extension_id(); |
2212 | 2212 |
2213 bool is_web_view_guest = webview_instance_id != 0; | 2213 bool is_web_view_guest = webview_instance_id != 0; |
2214 // We check automatically whether the extension has the 'webRequest' | 2214 // We check automatically whether the extension has the 'webRequest' |
2215 // permission. For blocking calls we require the additional permission | 2215 // permission. For blocking calls we require the additional permission |
2216 // 'webRequestBlocking'. | 2216 // 'webRequestBlocking'. |
2217 if ((!is_web_view_guest && extra_info_spec & | 2217 if ((!is_web_view_guest && |
2218 (ExtensionWebRequestEventRouter::ExtraInfoSpec::BLOCKING | | 2218 extra_info_spec & |
2219 ExtensionWebRequestEventRouter::ExtraInfoSpec::ASYNC_BLOCKING)) && | 2219 (ExtensionWebRequestEventRouter::ExtraInfoSpec::BLOCKING | |
2220 !extension->HasAPIPermission( | 2220 ExtensionWebRequestEventRouter::ExtraInfoSpec::ASYNC_BLOCKING)) && |
2221 extensions::APIPermission::kWebRequestBlocking)) { | 2221 !extension->permissions_data()->HasAPIPermission( |
| 2222 extensions::APIPermission::kWebRequestBlocking)) { |
2222 error_ = keys::kBlockingPermissionRequired; | 2223 error_ = keys::kBlockingPermissionRequired; |
2223 return false; | 2224 return false; |
2224 } | 2225 } |
2225 | 2226 |
2226 // We allow to subscribe to patterns that are broader than the host | 2227 // We allow to subscribe to patterns that are broader than the host |
2227 // permissions. E.g., we could subscribe to http://www.example.com/* | 2228 // permissions. E.g., we could subscribe to http://www.example.com/* |
2228 // while having host permissions for http://www.example.com/foo/* and | 2229 // while having host permissions for http://www.example.com/foo/* and |
2229 // http://www.example.com/bar/*. | 2230 // http://www.example.com/bar/*. |
2230 // For this reason we do only a coarse check here to warn the extension | 2231 // For this reason we do only a coarse check here to warn the extension |
2231 // developer if he does something obviously wrong. | 2232 // developer if he does something obviously wrong. |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2472 } else if ((*it)->name().find("AdBlock") != std::string::npos) { | 2473 } else if ((*it)->name().find("AdBlock") != std::string::npos) { |
2473 adblock = true; | 2474 adblock = true; |
2474 } else { | 2475 } else { |
2475 other = true; | 2476 other = true; |
2476 } | 2477 } |
2477 } | 2478 } |
2478 } | 2479 } |
2479 | 2480 |
2480 host->Send(new ExtensionMsg_UsingWebRequestAPI(adblock, adblock_plus, other)); | 2481 host->Send(new ExtensionMsg_UsingWebRequestAPI(adblock, adblock_plus, other)); |
2481 } | 2482 } |
OLD | NEW |