| OLD | NEW |
| 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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 &document_element_created_callbacks_); | 164 &document_element_created_callbacks_); |
| 165 // |this| might be dead by now. | 165 // |this| might be dead by now. |
| 166 } | 166 } |
| 167 | 167 |
| 168 void ExtensionFrameHelper::RunScriptsAtDocumentEnd() { | 168 void ExtensionFrameHelper::RunScriptsAtDocumentEnd() { |
| 169 RunCallbacksWhileFrameIsValid(weak_ptr_factory_.GetWeakPtr(), | 169 RunCallbacksWhileFrameIsValid(weak_ptr_factory_.GetWeakPtr(), |
| 170 &document_load_finished_callbacks_); | 170 &document_load_finished_callbacks_); |
| 171 // |this| might be dead by now. | 171 // |this| might be dead by now. |
| 172 } | 172 } |
| 173 | 173 |
| 174 void ExtensionFrameHelper::RunScriptsAtDocumentIdle() { |
| 175 RunCallbacksWhileFrameIsValid(weak_ptr_factory_.GetWeakPtr(), |
| 176 &document_idle_callbacks_); |
| 177 // |this| might be dead by now. |
| 178 } |
| 179 |
| 174 void ExtensionFrameHelper::ScheduleAtDocumentStart( | 180 void ExtensionFrameHelper::ScheduleAtDocumentStart( |
| 175 const base::Closure& callback) { | 181 const base::Closure& callback) { |
| 176 document_element_created_callbacks_.push_back(callback); | 182 document_element_created_callbacks_.push_back(callback); |
| 177 } | 183 } |
| 178 | 184 |
| 179 void ExtensionFrameHelper::ScheduleAtDocumentEnd( | 185 void ExtensionFrameHelper::ScheduleAtDocumentEnd( |
| 180 const base::Closure& callback) { | 186 const base::Closure& callback) { |
| 181 document_load_finished_callbacks_.push_back(callback); | 187 document_load_finished_callbacks_.push_back(callback); |
| 182 } | 188 } |
| 183 | 189 |
| 190 void ExtensionFrameHelper::ScheduleAtDocumentIdle( |
| 191 const base::Closure& callback) { |
| 192 document_idle_callbacks_.push_back(callback); |
| 193 } |
| 194 |
| 184 void ExtensionFrameHelper::DidMatchCSS( | 195 void ExtensionFrameHelper::DidMatchCSS( |
| 185 const blink::WebVector<blink::WebString>& newly_matching_selectors, | 196 const blink::WebVector<blink::WebString>& newly_matching_selectors, |
| 186 const blink::WebVector<blink::WebString>& stopped_matching_selectors) { | 197 const blink::WebVector<blink::WebString>& stopped_matching_selectors) { |
| 187 extension_dispatcher_->content_watcher()->DidMatchCSS( | 198 extension_dispatcher_->content_watcher()->DidMatchCSS( |
| 188 render_frame()->GetWebFrame(), newly_matching_selectors, | 199 render_frame()->GetWebFrame(), newly_matching_selectors, |
| 189 stopped_matching_selectors); | 200 stopped_matching_selectors); |
| 190 } | 201 } |
| 191 | 202 |
| 192 void ExtensionFrameHelper::DidStartProvisionalLoad( | 203 void ExtensionFrameHelper::DidStartProvisionalLoad( |
| 193 blink::WebDataSource* data_source) { | 204 blink::WebDataSource* data_source) { |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 const base::ListValue& args) { | 329 const base::ListValue& args) { |
| 319 extension_dispatcher_->InvokeModuleSystemMethod( | 330 extension_dispatcher_->InvokeModuleSystemMethod( |
| 320 render_frame(), extension_id, module_name, function_name, args); | 331 render_frame(), extension_id, module_name, function_name, args); |
| 321 } | 332 } |
| 322 | 333 |
| 323 void ExtensionFrameHelper::OnDestruct() { | 334 void ExtensionFrameHelper::OnDestruct() { |
| 324 delete this; | 335 delete this; |
| 325 } | 336 } |
| 326 | 337 |
| 327 } // namespace extensions | 338 } // namespace extensions |
| OLD | NEW |