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

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

Issue 404613006: Declarative content scripts: Renderer-side: per-extension shared memory regions (lazily loaded) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixes for last round of comments Created 6 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/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/weak_ptr.h" 8 #include "base/memory/weak_ptr.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "content/public/renderer/render_view.h" 10 #include "content/public/renderer/render_view.h"
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 int64 request_id) { 129 int64 request_id) {
130 manager_->HandlePermitScriptInjection(request_id); 130 manager_->HandlePermitScriptInjection(request_id);
131 } 131 }
132 132
133 void ScriptInjectionManager::RVOHelper::RunIdle(blink::WebFrame* frame) { 133 void ScriptInjectionManager::RVOHelper::RunIdle(blink::WebFrame* frame) {
134 manager_->InjectScripts(frame, UserScript::DOCUMENT_IDLE); 134 manager_->InjectScripts(frame, UserScript::DOCUMENT_IDLE);
135 } 135 }
136 136
137 ScriptInjectionManager::ScriptInjectionManager( 137 ScriptInjectionManager::ScriptInjectionManager(
138 const ExtensionSet* extensions, 138 const ExtensionSet* extensions,
139 UserScriptSet* user_script_set) 139 UserScriptSetManager* user_script_set_manager)
140 : extensions_(extensions), 140 : extensions_(extensions),
141 user_script_set_(user_script_set), 141 user_script_set_manager_(user_script_set_manager),
142 user_script_set_observer_(this) { 142 user_script_set_manager_observer_(this) {
143 user_script_set_observer_.Add(user_script_set_); 143 user_script_set_manager_observer_.Add(user_script_set_manager_);
144 } 144 }
145 145
146 ScriptInjectionManager::~ScriptInjectionManager() { 146 ScriptInjectionManager::~ScriptInjectionManager() {
147 } 147 }
148 148
149 void ScriptInjectionManager::OnRenderViewCreated( 149 void ScriptInjectionManager::OnRenderViewCreated(
150 content::RenderView* render_view) { 150 content::RenderView* render_view) {
151 rvo_helpers_.push_back(new RVOHelper(render_view, this)); 151 rvo_helpers_.push_back(new RVOHelper(render_view, this));
152 } 152 }
153 153
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 ++iter; 230 ++iter;
231 } 231 }
232 } 232 }
233 233
234 // Try to inject any user scripts that should run for this location. If they 234 // Try to inject any user scripts that should run for this location. If they
235 // don't complete their injection (for example, waiting for a permission 235 // don't complete their injection (for example, waiting for a permission
236 // response) then they will be added to |pending_injections_|. 236 // response) then they will be added to |pending_injections_|.
237 ScopedVector<ScriptInjection> user_script_injections; 237 ScopedVector<ScriptInjection> user_script_injections;
238 int tab_id = ExtensionHelper::Get(content::RenderView::FromWebView( 238 int tab_id = ExtensionHelper::Get(content::RenderView::FromWebView(
239 frame->top()->view()))->tab_id(); 239 frame->top()->view()))->tab_id();
240 user_script_set_->GetInjections( 240 user_script_set_manager_->GetAllInjections(
241 &user_script_injections, frame, tab_id, run_location); 241 &user_script_injections, frame, tab_id, run_location);
242 for (ScopedVector<ScriptInjection>::iterator iter = 242 for (ScopedVector<ScriptInjection>::iterator iter =
243 user_script_injections.begin(); 243 user_script_injections.begin();
244 iter != user_script_injections.end();) { 244 iter != user_script_injections.end();) {
245 scoped_ptr<ScriptInjection> injection(*iter); 245 scoped_ptr<ScriptInjection> injection(*iter);
246 iter = user_script_injections.weak_erase(iter); 246 iter = user_script_injections.weak_erase(iter);
247 if (!injection->TryToInject(run_location, 247 if (!injection->TryToInject(run_location,
248 extensions_->GetByID(injection->extension_id()), 248 extensions_->GetByID(injection->extension_id()),
249 &scripts_run_info)) { 249 &scripts_run_info)) {
250 pending_injections_.push_back(injection.release()); 250 pending_injections_.push_back(injection.release());
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 306
307 ScriptsRunInfo scripts_run_info; 307 ScriptsRunInfo scripts_run_info;
308 if (injection->OnPermissionGranted(extensions_->GetByID( 308 if (injection->OnPermissionGranted(extensions_->GetByID(
309 injection->extension_id()), 309 injection->extension_id()),
310 &scripts_run_info)) { 310 &scripts_run_info)) {
311 scripts_run_info.LogRun(injection->web_frame(), UserScript::RUN_DEFERRED); 311 scripts_run_info.LogRun(injection->web_frame(), UserScript::RUN_DEFERRED);
312 } 312 }
313 } 313 }
314 314
315 } // namespace extensions 315 } // 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