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

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

Issue 1293673002: Create thread-safe RendererExtensionRegistry from ExtensionSet (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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
« no previous file with comments | « extensions/renderer/script_injection_manager.h ('k') | extensions/renderer/user_script_set.h » ('j') | 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/script_injection_manager.h" 5 #include "extensions/renderer/script_injection_manager.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "base/values.h" 10 #include "base/values.h"
11 #include "content/public/renderer/render_frame.h" 11 #include "content/public/renderer/render_frame.h"
12 #include "content/public/renderer/render_frame_observer.h" 12 #include "content/public/renderer/render_frame_observer.h"
13 #include "content/public/renderer/render_thread.h" 13 #include "content/public/renderer/render_thread.h"
14 #include "extensions/common/extension.h" 14 #include "extensions/common/extension.h"
15 #include "extensions/common/extension_messages.h" 15 #include "extensions/common/extension_messages.h"
16 #include "extensions/common/extension_set.h" 16 #include "extensions/common/extension_set.h"
17 #include "extensions/renderer/extension_frame_helper.h" 17 #include "extensions/renderer/extension_frame_helper.h"
18 #include "extensions/renderer/extension_injection_host.h" 18 #include "extensions/renderer/extension_injection_host.h"
19 #include "extensions/renderer/programmatic_script_injector.h" 19 #include "extensions/renderer/programmatic_script_injector.h"
20 #include "extensions/renderer/renderer_extension_registry.h"
20 #include "extensions/renderer/script_injection.h" 21 #include "extensions/renderer/script_injection.h"
21 #include "extensions/renderer/scripts_run_info.h" 22 #include "extensions/renderer/scripts_run_info.h"
22 #include "extensions/renderer/web_ui_injection_host.h" 23 #include "extensions/renderer/web_ui_injection_host.h"
23 #include "ipc/ipc_message_macros.h" 24 #include "ipc/ipc_message_macros.h"
24 #include "third_party/WebKit/public/web/WebDocument.h" 25 #include "third_party/WebKit/public/web/WebDocument.h"
25 #include "third_party/WebKit/public/web/WebFrame.h" 26 #include "third_party/WebKit/public/web/WebFrame.h"
26 #include "third_party/WebKit/public/web/WebLocalFrame.h" 27 #include "third_party/WebKit/public/web/WebLocalFrame.h"
27 #include "third_party/WebKit/public/web/WebView.h" 28 #include "third_party/WebKit/public/web/WebView.h"
28 #include "url/gurl.h" 29 #include "url/gurl.h"
29 30
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 void ScriptInjectionManager::RFOHelper::InvalidateAndResetFrame() { 209 void ScriptInjectionManager::RFOHelper::InvalidateAndResetFrame() {
209 // Invalidate any pending idle injections, and reset the frame inject on idle. 210 // Invalidate any pending idle injections, and reset the frame inject on idle.
210 weak_factory_.InvalidateWeakPtrs(); 211 weak_factory_.InvalidateWeakPtrs();
211 // We reset to inject on idle, because the frame can be reused (in the case of 212 // We reset to inject on idle, because the frame can be reused (in the case of
212 // navigation). 213 // navigation).
213 should_run_idle_ = true; 214 should_run_idle_ = true;
214 manager_->InvalidateForFrame(render_frame()); 215 manager_->InvalidateForFrame(render_frame());
215 } 216 }
216 217
217 ScriptInjectionManager::ScriptInjectionManager( 218 ScriptInjectionManager::ScriptInjectionManager(
218 const ExtensionSet* extensions,
219 UserScriptSetManager* user_script_set_manager) 219 UserScriptSetManager* user_script_set_manager)
220 : extensions_(extensions), 220 : user_script_set_manager_(user_script_set_manager),
221 user_script_set_manager_(user_script_set_manager),
222 user_script_set_manager_observer_(this) { 221 user_script_set_manager_observer_(this) {
223 user_script_set_manager_observer_.Add(user_script_set_manager_); 222 user_script_set_manager_observer_.Add(user_script_set_manager_);
224 } 223 }
225 224
226 ScriptInjectionManager::~ScriptInjectionManager() { 225 ScriptInjectionManager::~ScriptInjectionManager() {
227 } 226 }
228 227
229 void ScriptInjectionManager::OnRenderFrameCreated( 228 void ScriptInjectionManager::OnRenderFrameCreated(
230 content::RenderFrame* render_frame) { 229 content::RenderFrame* render_frame) {
231 rfo_helpers_.push_back(new RFOHelper(render_frame, this)); 230 rfo_helpers_.push_back(new RFOHelper(render_frame, this));
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 case ScriptInjection::INJECTION_FINISHED: 393 case ScriptInjection::INJECTION_FINISHED:
395 break; 394 break;
396 } 395 }
397 } 396 }
398 397
399 void ScriptInjectionManager::HandleExecuteCode( 398 void ScriptInjectionManager::HandleExecuteCode(
400 const ExtensionMsg_ExecuteCode_Params& params, 399 const ExtensionMsg_ExecuteCode_Params& params,
401 content::RenderFrame* render_frame) { 400 content::RenderFrame* render_frame) {
402 scoped_ptr<const InjectionHost> injection_host; 401 scoped_ptr<const InjectionHost> injection_host;
403 if (params.host_id.type() == HostID::EXTENSIONS) { 402 if (params.host_id.type() == HostID::EXTENSIONS) {
404 injection_host = ExtensionInjectionHost::Create(params.host_id.id(), 403 injection_host = ExtensionInjectionHost::Create(params.host_id.id());
405 extensions_);
406 if (!injection_host) 404 if (!injection_host)
407 return; 405 return;
408 } else if (params.host_id.type() == HostID::WEBUI) { 406 } else if (params.host_id.type() == HostID::WEBUI) {
409 injection_host.reset( 407 injection_host.reset(
410 new WebUIInjectionHost(params.host_id)); 408 new WebUIInjectionHost(params.host_id));
411 } 409 }
412 410
413 scoped_ptr<ScriptInjection> injection(new ScriptInjection( 411 scoped_ptr<ScriptInjection> injection(new ScriptInjection(
414 scoped_ptr<ScriptInjector>( 412 scoped_ptr<ScriptInjector>(
415 new ProgrammaticScriptInjector(params, render_frame)), 413 new ProgrammaticScriptInjector(params, render_frame)),
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 ScriptsRunInfo scripts_run_info(injection->render_frame(), 471 ScriptsRunInfo scripts_run_info(injection->render_frame(),
474 UserScript::RUN_DEFERRED); 472 UserScript::RUN_DEFERRED);
475 ScriptInjection::InjectionResult res = injection->OnPermissionGranted( 473 ScriptInjection::InjectionResult res = injection->OnPermissionGranted(
476 &scripts_run_info); 474 &scripts_run_info);
477 if (res == ScriptInjection::INJECTION_BLOCKED) 475 if (res == ScriptInjection::INJECTION_BLOCKED)
478 running_injections_.push_back(injection.Pass()); 476 running_injections_.push_back(injection.Pass());
479 scripts_run_info.LogRun(); 477 scripts_run_info.LogRun();
480 } 478 }
481 479
482 } // namespace extensions 480 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/renderer/script_injection_manager.h ('k') | extensions/renderer/user_script_set.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698