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

Unified 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: Up to #50: ExtensionFrameHelper callbacks, comments Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: extensions/renderer/extension_frame_helper.h
diff --git a/extensions/renderer/extension_frame_helper.h b/extensions/renderer/extension_frame_helper.h
index a710d4f970517610fe40be239176e685b9cf89ab..5fdd6d497c3e080521c9fae9dc1c9d303b4a41d1 100644
--- a/extensions/renderer/extension_frame_helper.h
+++ b/extensions/renderer/extension_frame_helper.h
@@ -8,6 +8,7 @@
#include <vector>
#include "base/macros.h"
+#include "base/memory/weak_ptr.h"
#include "content/public/common/console_message_level.h"
#include "content/public/renderer/render_frame_observer.h"
#include "content/public/renderer/render_frame_observer_tracker.h"
@@ -61,6 +62,25 @@ class ExtensionFrameHelper
return did_create_current_document_element_;
}
+ // Called when the document element has been inserted in this frame. This
+ // method may invoke untrusted JavaScript code that invalidate the frame and
+ // this ExtensionFrameHelper.
+ void AfterDidCreateDocumentElement();
+
+ // Called after the DOMContentLoaded event has fired.
+ void AfterDidFinishDocumentLoad();
+
+ // Schedule a callback, to be run at the next AfterDidCreateDocumentElement
+ // notification. Only call this when you are certain that there will be such a
+ // notification, e.g. from RenderFrameObserver::DidCreateDocumentElement.
+ // Otherwise the callback is never invoked, or invoked for a document that you
+ // were not expecting.
+ void ScheduleAfterDidCreateDocumentElement(const base::Closure& callback);
+
+ // Schedule a callback, to be run at the next AfterDidFinishDocumentLoad
+ // notification.
+ void ScheduleAfterDidFinishDocumentLoad(const base::Closure& callback);
+
private:
// RenderFrameObserver implementation.
void DidCreateDocumentElement() override;
@@ -113,6 +133,14 @@ class ExtensionFrameHelper
// Whether or not the current document element has been created.
bool did_create_current_document_element_;
+ // Callbacks to be run at the next AfterDidCreateDocumentElement notification.
+ std::vector<base::Closure> document_element_created_callbacks_;
+
+ // Callbacks to be run at the next AfterDidFinishDocumentLoad notification.
+ std::vector<base::Closure> document_load_finished_callbacks_;
+
+ base::WeakPtrFactory<ExtensionFrameHelper> weak_ptr_factory_;
+
DISALLOW_COPY_AND_ASSIGN(ExtensionFrameHelper);
};

Powered by Google App Engine
This is Rietveld 408576698