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

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

Issue 307933008: Revert 273866 "Block content scripts from executing until user g..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 6 months 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 | Annotate | Revision Log
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 "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "content/public/renderer/render_view.h" 8 #include "content/public/renderer/render_view.h"
9 #include "content/public/renderer/render_view_visitor.h" 9 #include "content/public/renderer/render_view_visitor.h"
10 #include "extensions/common/api/messaging/message.h" 10 #include "extensions/common/api/messaging/message.h"
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 OnExtensionDispatchOnDisconnect) 151 OnExtensionDispatchOnDisconnect)
152 IPC_MESSAGE_HANDLER(ExtensionMsg_ExecuteCode, OnExecuteCode) 152 IPC_MESSAGE_HANDLER(ExtensionMsg_ExecuteCode, OnExecuteCode)
153 IPC_MESSAGE_HANDLER(ExtensionMsg_SetTabId, OnSetTabId) 153 IPC_MESSAGE_HANDLER(ExtensionMsg_SetTabId, OnSetTabId)
154 IPC_MESSAGE_HANDLER(ExtensionMsg_UpdateBrowserWindowId, 154 IPC_MESSAGE_HANDLER(ExtensionMsg_UpdateBrowserWindowId,
155 OnUpdateBrowserWindowId) 155 OnUpdateBrowserWindowId)
156 IPC_MESSAGE_HANDLER(ExtensionMsg_NotifyRenderViewType, 156 IPC_MESSAGE_HANDLER(ExtensionMsg_NotifyRenderViewType,
157 OnNotifyRendererViewType) 157 OnNotifyRendererViewType)
158 IPC_MESSAGE_HANDLER(ExtensionMsg_AddMessageToConsole, 158 IPC_MESSAGE_HANDLER(ExtensionMsg_AddMessageToConsole,
159 OnAddMessageToConsole) 159 OnAddMessageToConsole)
160 IPC_MESSAGE_HANDLER(ExtensionMsg_AppWindowClosed, 160 IPC_MESSAGE_HANDLER(ExtensionMsg_AppWindowClosed,
161 OnAppWindowClosed) 161 OnAppWindowClosed);
162 IPC_MESSAGE_HANDLER(ExtensionMsg_GrantContentScriptPermission,
163 OnGrantContentScriptPermission)
164 IPC_MESSAGE_UNHANDLED(handled = false) 162 IPC_MESSAGE_UNHANDLED(handled = false)
165 IPC_END_MESSAGE_MAP() 163 IPC_END_MESSAGE_MAP()
166 return handled; 164 return handled;
167 } 165 }
168 166
169 void ExtensionHelper::DidFinishDocumentLoad(WebLocalFrame* frame) { 167 void ExtensionHelper::DidFinishDocumentLoad(WebLocalFrame* frame) {
170 dispatcher_->user_script_slave()->InjectScripts( 168 dispatcher_->user_script_slave()->InjectScripts(
171 frame, UserScript::DOCUMENT_END); 169 frame, UserScript::DOCUMENT_END);
172 170
173 SchedulerMap::iterator i = g_schedulers.Get().find(frame); 171 SchedulerMap::iterator i = g_schedulers.Get().find(frame);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 210
213 void ExtensionHelper::FrameDetached(WebFrame* frame) { 211 void ExtensionHelper::FrameDetached(WebFrame* frame) {
214 // This could be called before DidCreateDataSource, in which case the frame 212 // This could be called before DidCreateDataSource, in which case the frame
215 // won't be in the map. 213 // won't be in the map.
216 SchedulerMap::iterator i = g_schedulers.Get().find(frame); 214 SchedulerMap::iterator i = g_schedulers.Get().find(frame);
217 if (i == g_schedulers.Get().end()) 215 if (i == g_schedulers.Get().end())
218 return; 216 return;
219 217
220 delete i->second; 218 delete i->second;
221 g_schedulers.Get().erase(i); 219 g_schedulers.Get().erase(i);
222
223 dispatcher_->user_script_slave()->FrameDetached(frame);
224 } 220 }
225 221
226 void ExtensionHelper::DidMatchCSS( 222 void ExtensionHelper::DidMatchCSS(
227 blink::WebLocalFrame* frame, 223 blink::WebLocalFrame* frame,
228 const blink::WebVector<blink::WebString>& newly_matching_selectors, 224 const blink::WebVector<blink::WebString>& newly_matching_selectors,
229 const blink::WebVector<blink::WebString>& stopped_matching_selectors) { 225 const blink::WebVector<blink::WebString>& stopped_matching_selectors) {
230 dispatcher_->DidMatchCSS( 226 dispatcher_->DidMatchCSS(
231 frame, newly_matching_selectors, stopped_matching_selectors); 227 frame, newly_matching_selectors, stopped_matching_selectors);
232 } 228 }
233 229
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 v8::Handle<v8::Context> v8_context = 339 v8::Handle<v8::Context> v8_context =
344 render_view()->GetWebView()->mainFrame()->mainWorldScriptContext(); 340 render_view()->GetWebView()->mainFrame()->mainWorldScriptContext();
345 ScriptContext* script_context = 341 ScriptContext* script_context =
346 dispatcher_->script_context_set().GetByV8Context(v8_context); 342 dispatcher_->script_context_set().GetByV8Context(v8_context);
347 if (!script_context) 343 if (!script_context)
348 return; 344 return;
349 script_context->module_system()->CallModuleMethod("app.window", 345 script_context->module_system()->CallModuleMethod("app.window",
350 "onAppWindowClosed"); 346 "onAppWindowClosed");
351 } 347 }
352 348
353 void ExtensionHelper::OnGrantContentScriptPermission(int request_id) {
354 dispatcher_->user_script_slave()->OnContentScriptGrantedPermission(
355 render_view(), request_id);
356 }
357
358 } // namespace extensions 349 } // namespace extensions
OLDNEW
« no previous file with comments | « trunk/src/extensions/renderer/extension_helper.h ('k') | trunk/src/extensions/renderer/script_injection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698