| 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. This method may invoke |
| 66 // untrusted JavaScript code and invalidate the frame. |
| 67 void AfterDidCreateDocumentElement( |
| 68 const base::WeakPtr<content::RenderFrame>& render_frame_weak); |
| 69 |
| 70 // Schedule a callback, to be run at the next AfterDidCreateDocumentElement |
| 71 // notification. Only call this when you are certain that there will be such a |
| 72 // notification, e.g. from RenderFrameObserver::DidCreateDocumentElement. |
| 73 // Otherwise the callback is never invoked, or invoked for a document that you |
| 74 // were not expecting. |
| 75 void ScheduleAfterDidCreateDocumentElement(const base::Closure& callback); |
| 76 |
| 64 private: | 77 private: |
| 65 // RenderFrameObserver implementation. | 78 // RenderFrameObserver implementation. |
| 66 void DidCreateDocumentElement() override; | 79 void DidCreateDocumentElement() override; |
| 67 void DidCreateNewDocument() override; | 80 void DidCreateNewDocument() override; |
| 68 void DidMatchCSS( | 81 void DidMatchCSS( |
| 69 const blink::WebVector<blink::WebString>& newly_matching_selectors, | 82 const blink::WebVector<blink::WebString>& newly_matching_selectors, |
| 70 const blink::WebVector<blink::WebString>& stopped_matching_selectors) | 83 const blink::WebVector<blink::WebString>& stopped_matching_selectors) |
| 71 override; | 84 override; |
| 72 void DidCreateScriptContext(v8::Local<v8::Context>, | 85 void DidCreateScriptContext(v8::Local<v8::Context>, |
| 73 int extension_group, | 86 int extension_group, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 int tab_id_; | 119 int tab_id_; |
| 107 | 120 |
| 108 // The id of the browser window the render frame is attached to. | 121 // The id of the browser window the render frame is attached to. |
| 109 int browser_window_id_; | 122 int browser_window_id_; |
| 110 | 123 |
| 111 Dispatcher* extension_dispatcher_; | 124 Dispatcher* extension_dispatcher_; |
| 112 | 125 |
| 113 // Whether or not the current document element has been created. | 126 // Whether or not the current document element has been created. |
| 114 bool did_create_current_document_element_; | 127 bool did_create_current_document_element_; |
| 115 | 128 |
| 129 // Callbacks to be run at the next AfterDidCreateDocumentElement notification. |
| 130 std::vector<base::Closure> document_element_created_callbacks_; |
| 131 |
| 116 DISALLOW_COPY_AND_ASSIGN(ExtensionFrameHelper); | 132 DISALLOW_COPY_AND_ASSIGN(ExtensionFrameHelper); |
| 117 }; | 133 }; |
| 118 | 134 |
| 119 } // namespace extensions | 135 } // namespace extensions |
| 120 | 136 |
| 121 #endif // EXTENSIONS_RENDERER_EXTENSION_FRAME_HELPER_H_ | 137 #endif // EXTENSIONS_RENDERER_EXTENSION_FRAME_HELPER_H_ |
| OLD | NEW |