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 2212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2223 return false; | 2223 return false; |
2224 } | 2224 } |
2225 | 2225 |
2226 // We allow to subscribe to patterns that are broader than the host | 2226 // We allow to subscribe to patterns that are broader than the host |
2227 // permissions. E.g., we could subscribe to http://www.example.com/* | 2227 // permissions. E.g., we could subscribe to http://www.example.com/* |
2228 // while having host permissions for http://www.example.com/foo/* and | 2228 // while having host permissions for http://www.example.com/foo/* and |
2229 // http://www.example.com/bar/*. | 2229 // http://www.example.com/bar/*. |
2230 // For this reason we do only a coarse check here to warn the extension | 2230 // For this reason we do only a coarse check here to warn the extension |
2231 // developer if he does something obviously wrong. | 2231 // developer if he does something obviously wrong. |
2232 if (!is_web_view_guest && | 2232 if (!is_web_view_guest && |
2233 extensions::PermissionsData::ForExtension(extension) | 2233 extension->permissions_data()->GetEffectiveHostPermissions().is_empty()) { |
2234 ->GetEffectiveHostPermissions() | |
2235 .is_empty()) { | |
2236 error_ = keys::kHostPermissionsRequired; | 2234 error_ = keys::kHostPermissionsRequired; |
2237 return false; | 2235 return false; |
2238 } | 2236 } |
2239 | 2237 |
2240 bool success = | 2238 bool success = |
2241 ExtensionWebRequestEventRouter::GetInstance()->AddEventListener( | 2239 ExtensionWebRequestEventRouter::GetInstance()->AddEventListener( |
2242 profile_id(), extension_id(), extension_name, | 2240 profile_id(), extension_id(), extension_name, |
2243 event_name, sub_event_name, filter, extra_info_spec, | 2241 event_name, sub_event_name, filter, extra_info_spec, |
2244 embedder_process_id, webview_instance_id, ipc_sender_weak()); | 2242 embedder_process_id, webview_instance_id, ipc_sender_weak()); |
2245 EXTENSION_FUNCTION_VALIDATE(success); | 2243 EXTENSION_FUNCTION_VALIDATE(success); |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2474 } else if ((*it)->name().find("AdBlock") != std::string::npos) { | 2472 } else if ((*it)->name().find("AdBlock") != std::string::npos) { |
2475 adblock = true; | 2473 adblock = true; |
2476 } else { | 2474 } else { |
2477 other = true; | 2475 other = true; |
2478 } | 2476 } |
2479 } | 2477 } |
2480 } | 2478 } |
2481 | 2479 |
2482 host->Send(new ExtensionMsg_UsingWebRequestAPI(adblock, adblock_plus, other)); | 2480 host->Send(new ExtensionMsg_UsingWebRequestAPI(adblock, adblock_plus, other)); |
2483 } | 2481 } |
OLD | NEW |