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

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

Issue 1642283002: Deal with frame removal by content scripts (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Last nits Created 4 years, 9 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
« no previous file with comments | « extensions/renderer/dispatcher.cc ('k') | extensions/renderer/extension_frame_helper.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #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
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 RunScriptsAtDocumentStart();
69
70 // Called after the DOMContentLoaded event has fired.
71 void RunScriptsAtDocumentEnd();
72
73 // Schedule a callback, to be run at the next RunScriptsAtDocumentStart
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 ScheduleAtDocumentStart(const base::Closure& callback);
79
80 // Schedule a callback, to be run at the next RunScriptsAtDocumentEnd call.
81 void ScheduleAtDocumentEnd(const base::Closure& callback);
82
64 private: 83 private:
65 // RenderFrameObserver implementation. 84 // RenderFrameObserver implementation.
66 void DidCreateDocumentElement() override; 85 void DidCreateDocumentElement() override;
67 void DidCreateNewDocument() override; 86 void DidCreateNewDocument() override;
68 void DidMatchCSS( 87 void DidMatchCSS(
69 const blink::WebVector<blink::WebString>& newly_matching_selectors, 88 const blink::WebVector<blink::WebString>& newly_matching_selectors,
70 const blink::WebVector<blink::WebString>& stopped_matching_selectors) 89 const blink::WebVector<blink::WebString>& stopped_matching_selectors)
71 override; 90 override;
72 void DidCreateScriptContext(v8::Local<v8::Context>, 91 void DidCreateScriptContext(v8::Local<v8::Context>,
73 int extension_group, 92 int extension_group,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 int tab_id_; 125 int tab_id_;
107 126
108 // The id of the browser window the render frame is attached to. 127 // The id of the browser window the render frame is attached to.
109 int browser_window_id_; 128 int browser_window_id_;
110 129
111 Dispatcher* extension_dispatcher_; 130 Dispatcher* extension_dispatcher_;
112 131
113 // Whether or not the current document element has been created. 132 // Whether or not the current document element has been created.
114 bool did_create_current_document_element_; 133 bool did_create_current_document_element_;
115 134
135 // Callbacks to be run at the next RunScriptsAtDocumentStart notification.
136 std::vector<base::Closure> document_element_created_callbacks_;
137
138 // Callbacks to be run at the next RunScriptsAtDocumentEnd notification.
139 std::vector<base::Closure> document_load_finished_callbacks_;
140
141 base::WeakPtrFactory<ExtensionFrameHelper> weak_ptr_factory_;
142
116 DISALLOW_COPY_AND_ASSIGN(ExtensionFrameHelper); 143 DISALLOW_COPY_AND_ASSIGN(ExtensionFrameHelper);
117 }; 144 };
118 145
119 } // namespace extensions 146 } // namespace extensions
120 147
121 #endif // EXTENSIONS_RENDERER_EXTENSION_FRAME_HELPER_H_ 148 #endif // EXTENSIONS_RENDERER_EXTENSION_FRAME_HELPER_H_
OLDNEW
« no previous file with comments | « extensions/renderer/dispatcher.cc ('k') | extensions/renderer/extension_frame_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698