| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/renderer/extension_helper.h" | 5 #include "extensions/renderer/extension_helper.h" |
| 6 | 6 |
| 7 #include "content/public/renderer/render_view.h" | 7 #include "content/public/renderer/render_view.h" |
| 8 #include "content/public/renderer/render_view_visitor.h" | 8 #include "content/public/renderer/render_view_visitor.h" |
| 9 #include "extensions/common/constants.h" | 9 #include "extensions/common/constants.h" |
| 10 #include "extensions/common/extension_messages.h" | 10 #include "extensions/common/extension_messages.h" |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 IPC_MESSAGE_HANDLER(ExtensionMsg_SetFrameName, OnSetFrameName) | 138 IPC_MESSAGE_HANDLER(ExtensionMsg_SetFrameName, OnSetFrameName) |
| 139 IPC_MESSAGE_HANDLER(ExtensionMsg_SetTabId, OnSetTabId) | 139 IPC_MESSAGE_HANDLER(ExtensionMsg_SetTabId, OnSetTabId) |
| 140 IPC_MESSAGE_HANDLER(ExtensionMsg_UpdateBrowserWindowId, | 140 IPC_MESSAGE_HANDLER(ExtensionMsg_UpdateBrowserWindowId, |
| 141 OnUpdateBrowserWindowId) | 141 OnUpdateBrowserWindowId) |
| 142 IPC_MESSAGE_HANDLER(ExtensionMsg_NotifyRenderViewType, | 142 IPC_MESSAGE_HANDLER(ExtensionMsg_NotifyRenderViewType, |
| 143 OnNotifyRendererViewType) | 143 OnNotifyRendererViewType) |
| 144 IPC_MESSAGE_HANDLER(ExtensionMsg_AddMessageToConsole, | 144 IPC_MESSAGE_HANDLER(ExtensionMsg_AddMessageToConsole, |
| 145 OnAddMessageToConsole) | 145 OnAddMessageToConsole) |
| 146 IPC_MESSAGE_HANDLER(ExtensionMsg_AppWindowClosed, | 146 IPC_MESSAGE_HANDLER(ExtensionMsg_AppWindowClosed, |
| 147 OnAppWindowClosed) | 147 OnAppWindowClosed) |
| 148 IPC_MESSAGE_HANDLER(ExtensionMsg_UpdateTabSpecificPermissions, | |
| 149 OnUpdateTabSpecificPermissions) | |
| 150 IPC_MESSAGE_HANDLER(ExtensionMsg_ClearTabSpecificPermissions, | |
| 151 OnClearTabSpecificPermissions) | |
| 152 IPC_MESSAGE_UNHANDLED(handled = false) | 148 IPC_MESSAGE_UNHANDLED(handled = false) |
| 153 IPC_END_MESSAGE_MAP() | 149 IPC_END_MESSAGE_MAP() |
| 154 return handled; | 150 return handled; |
| 155 } | 151 } |
| 156 | 152 |
| 157 void ExtensionHelper::DidCreateDocumentElement(WebLocalFrame* frame) { | 153 void ExtensionHelper::DidCreateDocumentElement(WebLocalFrame* frame) { |
| 158 dispatcher_->DidCreateDocumentElement(frame); | 154 dispatcher_->DidCreateDocumentElement(frame); |
| 159 } | 155 } |
| 160 | 156 |
| 161 void ExtensionHelper::DraggableRegionsChanged(blink::WebFrame* frame) { | 157 void ExtensionHelper::DraggableRegionsChanged(blink::WebFrame* frame) { |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 v8::Handle<v8::Context> v8_context = | 225 v8::Handle<v8::Context> v8_context = |
| 230 render_view()->GetWebView()->mainFrame()->mainWorldScriptContext(); | 226 render_view()->GetWebView()->mainFrame()->mainWorldScriptContext(); |
| 231 ScriptContext* script_context = | 227 ScriptContext* script_context = |
| 232 dispatcher_->script_context_set().GetByV8Context(v8_context); | 228 dispatcher_->script_context_set().GetByV8Context(v8_context); |
| 233 if (!script_context) | 229 if (!script_context) |
| 234 return; | 230 return; |
| 235 script_context->module_system()->CallModuleMethod("app.window", | 231 script_context->module_system()->CallModuleMethod("app.window", |
| 236 "onAppWindowClosed"); | 232 "onAppWindowClosed"); |
| 237 } | 233 } |
| 238 | 234 |
| 239 void ExtensionHelper::OnUpdateTabSpecificPermissions( | |
| 240 const GURL& url, | |
| 241 const std::string& extension_id, | |
| 242 const extensions::URLPatternSet& origin_set) { | |
| 243 // Check against the URL to avoid races. | |
| 244 GURL active_url(render_view()->GetWebView()->mainFrame()->document().url()); | |
| 245 if (active_url != url) | |
| 246 return; | |
| 247 | |
| 248 const Extension* extension = dispatcher_->extensions()->GetByID(extension_id); | |
| 249 if (!extension) | |
| 250 return; | |
| 251 | |
| 252 extension->permissions_data()->UpdateTabSpecificPermissions( | |
| 253 tab_id_, | |
| 254 new extensions::PermissionSet(extensions::APIPermissionSet(), | |
| 255 extensions::ManifestPermissionSet(), | |
| 256 origin_set, | |
| 257 extensions::URLPatternSet())); | |
| 258 } | |
| 259 | |
| 260 void ExtensionHelper::OnClearTabSpecificPermissions( | |
| 261 const std::vector<std::string>& extension_ids) { | |
| 262 for (const auto& id : extension_ids) { | |
| 263 const extensions::Extension* extension = | |
| 264 dispatcher_->extensions()->GetByID(id); | |
| 265 if (extension) | |
| 266 extension->permissions_data()->ClearTabSpecificPermissions(tab_id_); | |
| 267 } | |
| 268 } | |
| 269 | |
| 270 } // namespace extensions | 235 } // namespace extensions |
| OLD | NEW |