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/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/weak_ptr.h" |
11 #include "content/public/common/console_message_level.h" | 12 #include "content/public/common/console_message_level.h" |
12 #include "content/public/renderer/render_frame_observer.h" | 13 #include "content/public/renderer/render_frame_observer.h" |
13 #include "content/public/renderer/render_frame_observer_tracker.h" | 14 #include "content/public/renderer/render_frame_observer_tracker.h" |
14 #include "extensions/common/view_type.h" | 15 #include "extensions/common/view_type.h" |
15 | 16 |
16 struct ExtensionMsg_ExternalConnectionInfo; | 17 struct ExtensionMsg_ExternalConnectionInfo; |
17 struct ExtensionMsg_TabConnectionInfo; | 18 struct ExtensionMsg_TabConnectionInfo; |
18 | 19 |
19 namespace base { | 20 namespace base { |
20 class ListValue; | 21 class ListValue; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 // deleted. | 55 // deleted. |
55 static bool IsContextForEventPage(const ScriptContext* context); | 56 static bool IsContextForEventPage(const ScriptContext* context); |
56 | 57 |
57 ViewType view_type() const { return view_type_; } | 58 ViewType view_type() const { return view_type_; } |
58 int tab_id() const { return tab_id_; } | 59 int tab_id() const { return tab_id_; } |
59 int browser_window_id() const { return browser_window_id_; } | 60 int browser_window_id() const { return browser_window_id_; } |
60 bool did_create_current_document_element() const { | 61 bool did_create_current_document_element() const { |
61 return did_create_current_document_element_; | 62 return did_create_current_document_element_; |
62 } | 63 } |
63 | 64 |
| 65 // Called when the document element has been inserted in this frame. This |
| 66 // method may invoke untrusted JavaScript code that invalidate the frame and |
| 67 // this ExtensionFrameHelper. |
| 68 void AfterDidCreateDocumentElement(); |
| 69 |
| 70 // Called after the DOMContentLoaded event has fired. |
| 71 void AfterDidFinishDocumentLoad(); |
| 72 |
| 73 // Schedule a callback, to be run at the next AfterDidCreateDocumentElement |
| 74 // notification. Only call this when you are certain that there will be such a |
| 75 // notification, e.g. from RenderFrameObserver::DidCreateDocumentElement. |
| 76 // Otherwise the callback is never invoked, or invoked for a document that you |
| 77 // were not expecting. |
| 78 void ScheduleAfterDidCreateDocumentElement(const base::Closure& callback); |
| 79 |
| 80 // Schedule a callback, to be run at the next AfterDidFinishDocumentLoad |
| 81 // notification. |
| 82 void ScheduleAfterDidFinishDocumentLoad(const base::Closure& callback); |
| 83 |
64 private: | 84 private: |
65 // RenderFrameObserver implementation. | 85 // RenderFrameObserver implementation. |
66 void DidCreateDocumentElement() override; | 86 void DidCreateDocumentElement() override; |
67 void DidCreateNewDocument() override; | 87 void DidCreateNewDocument() override; |
68 void DidMatchCSS( | 88 void DidMatchCSS( |
69 const blink::WebVector<blink::WebString>& newly_matching_selectors, | 89 const blink::WebVector<blink::WebString>& newly_matching_selectors, |
70 const blink::WebVector<blink::WebString>& stopped_matching_selectors) | 90 const blink::WebVector<blink::WebString>& stopped_matching_selectors) |
71 override; | 91 override; |
72 void DidCreateScriptContext(v8::Local<v8::Context>, | 92 void DidCreateScriptContext(v8::Local<v8::Context>, |
73 int extension_group, | 93 int extension_group, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 int tab_id_; | 126 int tab_id_; |
107 | 127 |
108 // The id of the browser window the render frame is attached to. | 128 // The id of the browser window the render frame is attached to. |
109 int browser_window_id_; | 129 int browser_window_id_; |
110 | 130 |
111 Dispatcher* extension_dispatcher_; | 131 Dispatcher* extension_dispatcher_; |
112 | 132 |
113 // Whether or not the current document element has been created. | 133 // Whether or not the current document element has been created. |
114 bool did_create_current_document_element_; | 134 bool did_create_current_document_element_; |
115 | 135 |
| 136 // Callbacks to be run at the next AfterDidCreateDocumentElement notification. |
| 137 std::vector<base::Closure> document_element_created_callbacks_; |
| 138 |
| 139 // Callbacks to be run at the next AfterDidFinishDocumentLoad notification. |
| 140 std::vector<base::Closure> document_load_finished_callbacks_; |
| 141 |
| 142 base::WeakPtrFactory<ExtensionFrameHelper> weak_ptr_factory_; |
| 143 |
116 DISALLOW_COPY_AND_ASSIGN(ExtensionFrameHelper); | 144 DISALLOW_COPY_AND_ASSIGN(ExtensionFrameHelper); |
117 }; | 145 }; |
118 | 146 |
119 } // namespace extensions | 147 } // namespace extensions |
120 | 148 |
121 #endif // EXTENSIONS_RENDERER_EXTENSION_FRAME_HELPER_H_ | 149 #endif // EXTENSIONS_RENDERER_EXTENSION_FRAME_HELPER_H_ |
OLD | NEW |