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

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

Issue 2633253002: Split content script injections into multiple tasks (Closed)
Patch Set: Inject document_idle scripts before window.onload Created 3 years, 10 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_frame_helper.h" 5 #include "extensions/renderer/extension_frame_helper.h"
6 6
7 #include "base/metrics/histogram_macros.h" 7 #include "base/metrics/histogram_macros.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "base/timer/elapsed_timer.h" 9 #include "base/timer/elapsed_timer.h"
10 #include "content/public/renderer/render_frame.h" 10 #include "content/public/renderer/render_frame.h"
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 &document_element_created_callbacks_); 162 &document_element_created_callbacks_);
163 // |this| might be dead by now. 163 // |this| might be dead by now.
164 } 164 }
165 165
166 void ExtensionFrameHelper::RunScriptsAtDocumentEnd() { 166 void ExtensionFrameHelper::RunScriptsAtDocumentEnd() {
167 RunCallbacksWhileFrameIsValid(weak_ptr_factory_.GetWeakPtr(), 167 RunCallbacksWhileFrameIsValid(weak_ptr_factory_.GetWeakPtr(),
168 &document_load_finished_callbacks_); 168 &document_load_finished_callbacks_);
169 // |this| might be dead by now. 169 // |this| might be dead by now.
170 } 170 }
171 171
172 void ExtensionFrameHelper::RunScriptsAtDocumentIdle() {
173 RunCallbacksWhileFrameIsValid(weak_ptr_factory_.GetWeakPtr(),
174 &document_idle_callbacks_);
175 }
176
172 void ExtensionFrameHelper::ScheduleAtDocumentStart( 177 void ExtensionFrameHelper::ScheduleAtDocumentStart(
173 const base::Closure& callback) { 178 const base::Closure& callback) {
174 document_element_created_callbacks_.push_back(callback); 179 document_element_created_callbacks_.push_back(callback);
175 } 180 }
176 181
177 void ExtensionFrameHelper::ScheduleAtDocumentEnd( 182 void ExtensionFrameHelper::ScheduleAtDocumentEnd(
178 const base::Closure& callback) { 183 const base::Closure& callback) {
179 document_load_finished_callbacks_.push_back(callback); 184 document_load_finished_callbacks_.push_back(callback);
180 } 185 }
181 186
187 void ExtensionFrameHelper::ScheduleAtDocumentIdle(
188 const base::Closure& callback) {
189 document_idle_callbacks_.push_back(callback);
190 }
191
182 void ExtensionFrameHelper::DidMatchCSS( 192 void ExtensionFrameHelper::DidMatchCSS(
183 const blink::WebVector<blink::WebString>& newly_matching_selectors, 193 const blink::WebVector<blink::WebString>& newly_matching_selectors,
184 const blink::WebVector<blink::WebString>& stopped_matching_selectors) { 194 const blink::WebVector<blink::WebString>& stopped_matching_selectors) {
185 extension_dispatcher_->content_watcher()->DidMatchCSS( 195 extension_dispatcher_->content_watcher()->DidMatchCSS(
186 render_frame()->GetWebFrame(), newly_matching_selectors, 196 render_frame()->GetWebFrame(), newly_matching_selectors,
187 stopped_matching_selectors); 197 stopped_matching_selectors);
188 } 198 }
189 199
190 void ExtensionFrameHelper::DidStartProvisionalLoad( 200 void ExtensionFrameHelper::DidStartProvisionalLoad(
191 blink::WebDataSource* data_source) { 201 blink::WebDataSource* data_source) {
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 const base::ListValue& args) { 327 const base::ListValue& args) {
318 extension_dispatcher_->InvokeModuleSystemMethod( 328 extension_dispatcher_->InvokeModuleSystemMethod(
319 render_frame(), extension_id, module_name, function_name, args); 329 render_frame(), extension_id, module_name, function_name, args);
320 } 330 }
321 331
322 void ExtensionFrameHelper::OnDestruct() { 332 void ExtensionFrameHelper::OnDestruct() {
323 delete this; 333 delete this;
324 } 334 }
325 335
326 } // namespace extensions 336 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698