| 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 #ifndef EXTENSIONS_RENDERER_EXTENSION_FRAME_HELPER_H_ | 5 #ifndef EXTENSIONS_RENDERER_EXTENSION_FRAME_HELPER_H_ |
| 6 #define EXTENSIONS_RENDERER_EXTENSION_FRAME_HELPER_H_ | 6 #define EXTENSIONS_RENDERER_EXTENSION_FRAME_HELPER_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/callback_forward.h" | 10 #include "base/callback_forward.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 } | 66 } |
| 67 | 67 |
| 68 // Called when the document element has been inserted in this frame. This | 68 // Called when the document element has been inserted in this frame. This |
| 69 // method may invoke untrusted JavaScript code that invalidate the frame and | 69 // method may invoke untrusted JavaScript code that invalidate the frame and |
| 70 // this ExtensionFrameHelper. | 70 // this ExtensionFrameHelper. |
| 71 void RunScriptsAtDocumentStart(); | 71 void RunScriptsAtDocumentStart(); |
| 72 | 72 |
| 73 // Called after the DOMContentLoaded event has fired. | 73 // Called after the DOMContentLoaded event has fired. |
| 74 void RunScriptsAtDocumentEnd(); | 74 void RunScriptsAtDocumentEnd(); |
| 75 | 75 |
| 76 // Called before the window.onload event is fired. |
| 77 void RunScriptsAtDocumentIdle(); |
| 78 |
| 76 // Schedule a callback, to be run at the next RunScriptsAtDocumentStart | 79 // Schedule a callback, to be run at the next RunScriptsAtDocumentStart |
| 77 // notification. Only call this when you are certain that there will be such a | 80 // notification. Only call this when you are certain that there will be such a |
| 78 // notification, e.g. from RenderFrameObserver::DidCreateDocumentElement. | 81 // notification, e.g. from RenderFrameObserver::DidCreateDocumentElement. |
| 79 // Otherwise the callback is never invoked, or invoked for a document that you | 82 // Otherwise the callback is never invoked, or invoked for a document that you |
| 80 // were not expecting. | 83 // were not expecting. |
| 81 void ScheduleAtDocumentStart(const base::Closure& callback); | 84 void ScheduleAtDocumentStart(const base::Closure& callback); |
| 82 | 85 |
| 83 // Schedule a callback, to be run at the next RunScriptsAtDocumentEnd call. | 86 // Schedule a callback, to be run at the next RunScriptsAtDocumentEnd call. |
| 84 void ScheduleAtDocumentEnd(const base::Closure& callback); | 87 void ScheduleAtDocumentEnd(const base::Closure& callback); |
| 85 | 88 |
| 89 // Schedule a callback, to be run at the next RunScriptsAtDocumentIdle call. |
| 90 void ScheduleAtDocumentIdle(const base::Closure& callback); |
| 91 |
| 86 private: | 92 private: |
| 87 // RenderFrameObserver implementation. | 93 // RenderFrameObserver implementation. |
| 88 void DidCreateDocumentElement() override; | 94 void DidCreateDocumentElement() override; |
| 89 void DidCreateNewDocument() override; | 95 void DidCreateNewDocument() override; |
| 90 void DidMatchCSS( | 96 void DidMatchCSS( |
| 91 const blink::WebVector<blink::WebString>& newly_matching_selectors, | 97 const blink::WebVector<blink::WebString>& newly_matching_selectors, |
| 92 const blink::WebVector<blink::WebString>& stopped_matching_selectors) | 98 const blink::WebVector<blink::WebString>& stopped_matching_selectors) |
| 93 override; | 99 override; |
| 94 void DidStartProvisionalLoad(blink::WebDataSource* data_source) override; | 100 void DidStartProvisionalLoad(blink::WebDataSource* data_source) override; |
| 95 void DidCreateScriptContext(v8::Local<v8::Context>, | 101 void DidCreateScriptContext(v8::Local<v8::Context>, |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 | 141 |
| 136 // Whether or not the current document element has been created. | 142 // Whether or not the current document element has been created. |
| 137 bool did_create_current_document_element_; | 143 bool did_create_current_document_element_; |
| 138 | 144 |
| 139 // Callbacks to be run at the next RunScriptsAtDocumentStart notification. | 145 // Callbacks to be run at the next RunScriptsAtDocumentStart notification. |
| 140 std::vector<base::Closure> document_element_created_callbacks_; | 146 std::vector<base::Closure> document_element_created_callbacks_; |
| 141 | 147 |
| 142 // Callbacks to be run at the next RunScriptsAtDocumentEnd notification. | 148 // Callbacks to be run at the next RunScriptsAtDocumentEnd notification. |
| 143 std::vector<base::Closure> document_load_finished_callbacks_; | 149 std::vector<base::Closure> document_load_finished_callbacks_; |
| 144 | 150 |
| 151 // Callbacks to be run at the next RunScriptsAtDocumentIdle notification. |
| 152 std::vector<base::Closure> document_idle_callbacks_; |
| 153 |
| 145 bool delayed_main_world_script_initialization_ = false; | 154 bool delayed_main_world_script_initialization_ = false; |
| 146 | 155 |
| 147 base::WeakPtrFactory<ExtensionFrameHelper> weak_ptr_factory_; | 156 base::WeakPtrFactory<ExtensionFrameHelper> weak_ptr_factory_; |
| 148 | 157 |
| 149 DISALLOW_COPY_AND_ASSIGN(ExtensionFrameHelper); | 158 DISALLOW_COPY_AND_ASSIGN(ExtensionFrameHelper); |
| 150 }; | 159 }; |
| 151 | 160 |
| 152 } // namespace extensions | 161 } // namespace extensions |
| 153 | 162 |
| 154 #endif // EXTENSIONS_RENDERER_EXTENSION_FRAME_HELPER_H_ | 163 #endif // EXTENSIONS_RENDERER_EXTENSION_FRAME_HELPER_H_ |
| OLD | NEW |