Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(381)

Side by Side Diff: extensions/renderer/extension_helper.cc

Issue 708713003: Don't crash when granting permissions to active tab. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Change for with iterators to a foreach. Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « extensions/renderer/extension_helper.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/api/messaging/message.h" 9 #include "extensions/common/api/messaging/message.h"
10 #include "extensions/common/constants.h" 10 #include "extensions/common/constants.h"
11 #include "extensions/common/extension_messages.h" 11 #include "extensions/common/extension_messages.h"
12 #include "extensions/common/permissions/permissions_data.h"
13 #include "extensions/common/url_pattern_set.h"
12 #include "extensions/renderer/api/automation/automation_api_helper.h" 14 #include "extensions/renderer/api/automation/automation_api_helper.h"
13 #include "extensions/renderer/console.h" 15 #include "extensions/renderer/console.h"
14 #include "extensions/renderer/dispatcher.h" 16 #include "extensions/renderer/dispatcher.h"
15 #include "extensions/renderer/messaging_bindings.h" 17 #include "extensions/renderer/messaging_bindings.h"
16 #include "third_party/WebKit/public/platform/WebURLRequest.h" 18 #include "third_party/WebKit/public/platform/WebURLRequest.h"
17 #include "third_party/WebKit/public/web/WebConsoleMessage.h" 19 #include "third_party/WebKit/public/web/WebConsoleMessage.h"
18 #include "third_party/WebKit/public/web/WebDocument.h" 20 #include "third_party/WebKit/public/web/WebDocument.h"
19 #include "third_party/WebKit/public/web/WebLocalFrame.h" 21 #include "third_party/WebKit/public/web/WebLocalFrame.h"
20 #include "third_party/WebKit/public/web/WebView.h" 22 #include "third_party/WebKit/public/web/WebView.h"
21 23
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 IPC_MESSAGE_HANDLER(ExtensionMsg_SetFrameName, OnSetFrameName) 145 IPC_MESSAGE_HANDLER(ExtensionMsg_SetFrameName, OnSetFrameName)
144 IPC_MESSAGE_HANDLER(ExtensionMsg_SetTabId, OnSetTabId) 146 IPC_MESSAGE_HANDLER(ExtensionMsg_SetTabId, OnSetTabId)
145 IPC_MESSAGE_HANDLER(ExtensionMsg_UpdateBrowserWindowId, 147 IPC_MESSAGE_HANDLER(ExtensionMsg_UpdateBrowserWindowId,
146 OnUpdateBrowserWindowId) 148 OnUpdateBrowserWindowId)
147 IPC_MESSAGE_HANDLER(ExtensionMsg_NotifyRenderViewType, 149 IPC_MESSAGE_HANDLER(ExtensionMsg_NotifyRenderViewType,
148 OnNotifyRendererViewType) 150 OnNotifyRendererViewType)
149 IPC_MESSAGE_HANDLER(ExtensionMsg_AddMessageToConsole, 151 IPC_MESSAGE_HANDLER(ExtensionMsg_AddMessageToConsole,
150 OnAddMessageToConsole) 152 OnAddMessageToConsole)
151 IPC_MESSAGE_HANDLER(ExtensionMsg_AppWindowClosed, 153 IPC_MESSAGE_HANDLER(ExtensionMsg_AppWindowClosed,
152 OnAppWindowClosed) 154 OnAppWindowClosed)
155 IPC_MESSAGE_HANDLER(ExtensionMsg_UpdateTabSpecificPermissions,
156 OnUpdateTabSpecificPermissions)
157 IPC_MESSAGE_HANDLER(ExtensionMsg_ClearTabSpecificPermissions,
158 OnClearTabSpecificPermissions)
153 IPC_MESSAGE_UNHANDLED(handled = false) 159 IPC_MESSAGE_UNHANDLED(handled = false)
154 IPC_END_MESSAGE_MAP() 160 IPC_END_MESSAGE_MAP()
155 return handled; 161 return handled;
156 } 162 }
157 163
158 void ExtensionHelper::DidCreateDocumentElement(WebLocalFrame* frame) { 164 void ExtensionHelper::DidCreateDocumentElement(WebLocalFrame* frame) {
159 dispatcher_->DidCreateDocumentElement(frame); 165 dispatcher_->DidCreateDocumentElement(frame);
160 } 166 }
161 167
162 void ExtensionHelper::DraggableRegionsChanged(blink::WebFrame* frame) { 168 void ExtensionHelper::DraggableRegionsChanged(blink::WebFrame* frame) {
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 v8::Handle<v8::Context> v8_context = 264 v8::Handle<v8::Context> v8_context =
259 render_view()->GetWebView()->mainFrame()->mainWorldScriptContext(); 265 render_view()->GetWebView()->mainFrame()->mainWorldScriptContext();
260 ScriptContext* script_context = 266 ScriptContext* script_context =
261 dispatcher_->script_context_set().GetByV8Context(v8_context); 267 dispatcher_->script_context_set().GetByV8Context(v8_context);
262 if (!script_context) 268 if (!script_context)
263 return; 269 return;
264 script_context->module_system()->CallModuleMethod("app.window", 270 script_context->module_system()->CallModuleMethod("app.window",
265 "onAppWindowClosed"); 271 "onAppWindowClosed");
266 } 272 }
267 273
274 void ExtensionHelper::OnUpdateTabSpecificPermissions(
275 const GURL& url,
276 const std::string& extension_id,
277 const extensions::URLPatternSet& origin_set) {
278 // Check against the URL to avoid races.
279 GURL active_url(render_view()->GetWebView()->mainFrame()->document().url());
280 if (active_url != url)
281 return;
282
283 const Extension* extension = dispatcher_->extensions()->GetByID(extension_id);
284 if (!extension)
285 return;
286
287 extension->permissions_data()->UpdateTabSpecificPermissions(
288 tab_id_,
289 new extensions::PermissionSet(extensions::APIPermissionSet(),
290 extensions::ManifestPermissionSet(),
291 origin_set,
292 extensions::URLPatternSet()));
293 }
294
295 void ExtensionHelper::OnClearTabSpecificPermissions(
296 const std::vector<std::string>& extension_ids) {
297 for (const auto& id : extension_ids) {
298 const extensions::Extension* extension =
299 dispatcher_->extensions()->GetByID(id);
300 if (extension)
301 extension->permissions_data()->ClearTabSpecificPermissions(tab_id_);
302 }
303 }
304
268 } // namespace extensions 305 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/renderer/extension_helper.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698