Chromium Code Reviews| Index: extensions/renderer/extension_helper.cc |
| diff --git a/extensions/renderer/extension_helper.cc b/extensions/renderer/extension_helper.cc |
| index fef086948a3e113184db846b7f40a7f2e82e0f33..f6b9b25c73ecb2036f1492397bb2c2e589df0133 100644 |
| --- a/extensions/renderer/extension_helper.cc |
| +++ b/extensions/renderer/extension_helper.cc |
| @@ -9,6 +9,8 @@ |
| #include "extensions/common/api/messaging/message.h" |
| #include "extensions/common/constants.h" |
| #include "extensions/common/extension_messages.h" |
| +#include "extensions/common/permissions/permissions_data.h" |
| +#include "extensions/common/url_pattern_set.h" |
| #include "extensions/renderer/api/automation/automation_api_helper.h" |
| #include "extensions/renderer/console.h" |
| #include "extensions/renderer/dispatcher.h" |
| @@ -150,6 +152,10 @@ bool ExtensionHelper::OnMessageReceived(const IPC::Message& message) { |
| OnAddMessageToConsole) |
| IPC_MESSAGE_HANDLER(ExtensionMsg_AppWindowClosed, |
| OnAppWindowClosed) |
| + IPC_MESSAGE_HANDLER(ExtensionMsg_UpdateTabSpecificPermissions, |
| + OnUpdateTabSpecificPermissions) |
| + IPC_MESSAGE_HANDLER(ExtensionMsg_ClearTabSpecificPermissions, |
| + OnClearTabSpecificPermissions) |
| IPC_MESSAGE_UNHANDLED(handled = false) |
| IPC_END_MESSAGE_MAP() |
| return handled; |
| @@ -265,4 +271,37 @@ void ExtensionHelper::OnAppWindowClosed() { |
| "onAppWindowClosed"); |
| } |
| +void ExtensionHelper::OnUpdateTabSpecificPermissions( |
| + const GURL& url, |
| + const std::string& extension_id, |
| + const extensions::URLPatternSet& origin_set) { |
| + // Check against the URL to avoid races. |
| + GURL active_url(render_view()->GetWebView()->mainFrame()->document().url()); |
| + if (active_url != url) |
| + return; |
| + |
| + const Extension* extension = dispatcher_->extensions()->GetByID(extension_id); |
| + if (!extension) |
| + return; |
| + |
| + extension->permissions_data()->UpdateTabSpecificPermissions( |
| + tab_id_, |
| + new extensions::PermissionSet(extensions::APIPermissionSet(), |
| + extensions::ManifestPermissionSet(), |
| + origin_set, |
| + extensions::URLPatternSet())); |
| +} |
| + |
| +void ExtensionHelper::OnClearTabSpecificPermissions( |
| + const std::vector<std::string>& extension_ids) { |
| + for (std::vector<std::string>::const_iterator it = extension_ids.begin(); |
|
not at google - send to devlin
2014/11/18 15:44:41
Convert this to foreach syntax while you're here?
|
| + it != extension_ids.end(); |
| + ++it) { |
| + const extensions::Extension* extension = |
| + dispatcher_->extensions()->GetByID(*it); |
| + if (extension) |
| + extension->permissions_data()->ClearTabSpecificPermissions(tab_id_); |
| + } |
| +} |
| + |
| } // namespace extensions |