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

Unified Diff: content/browser/frame_host/frame_tree_node.h

Issue 1086283002: Track frame openers in FrameTreeNodes instead of WebContents (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Second round of feedback Created 5 years, 6 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
« no previous file with comments | « content/browser/frame_host/frame_tree_browsertest.cc ('k') | content/browser/frame_host/frame_tree_node.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/frame_host/frame_tree_node.h
diff --git a/content/browser/frame_host/frame_tree_node.h b/content/browser/frame_host/frame_tree_node.h
index 21fbf2785803dd05954053b255da7c95e817f143..19f87a3563b50260d1a191686ef5d9f2a1159224 100644
--- a/content/browser/frame_host/frame_tree_node.h
+++ b/content/browser/frame_host/frame_tree_node.h
@@ -31,6 +31,14 @@ class RenderFrameHostImpl;
// are frame-specific (as opposed to page-specific).
class CONTENT_EXPORT FrameTreeNode {
public:
+ class Observer {
+ public:
+ // Invoked when a FrameTreeNode is being destroyed.
+ virtual void OnFrameTreeNodeDestroyed(FrameTreeNode* node) {}
+
+ virtual ~Observer() {}
+ };
+
// Returns the FrameTreeNode with the given global |frame_tree_node_id|,
// regardless of which FrameTree it is in.
static FrameTreeNode* GloballyFindByID(int frame_tree_node_id);
@@ -47,6 +55,9 @@ class CONTENT_EXPORT FrameTreeNode {
~FrameTreeNode();
+ void AddObserver(Observer* observer);
+ void RemoveObserver(Observer* observer);
+
bool IsMainFrame() const;
void AddChild(scoped_ptr<FrameTreeNode> child,
@@ -83,6 +94,13 @@ class CONTENT_EXPORT FrameTreeNode {
FrameTreeNode* parent() const { return parent_; }
+ FrameTreeNode* opener() const { return opener_; }
+
+ // Assigns a new opener for this node and, if |opener| is non-null, registers
+ // an observer that will clear this node's opener if |opener| is ever
+ // destroyed.
+ void SetOpener(FrameTreeNode* opener);
+
FrameTreeNode* child_at(size_t index) const {
return children_[index];
}
@@ -172,6 +190,8 @@ class CONTENT_EXPORT FrameTreeNode {
void DidChangeLoadProgress(double load_progress);
private:
+ class OpenerDestroyedObserver;
+
void set_parent(FrameTreeNode* parent) { parent_ = parent; }
// The next available browser-global FrameTreeNode ID.
@@ -198,6 +218,18 @@ class CONTENT_EXPORT FrameTreeNode {
// not yet been attached to the frame tree.
FrameTreeNode* parent_;
+ // The frame that opened this frame, if any. Will be set to null if the
+ // opener is closed, or if this frame disowns its opener by setting its
+ // window.opener to null.
+ FrameTreeNode* opener_;
+
+ // An observer that clears this node's |opener_| if the opener is destroyed.
+ // This observer is added to the |opener_|'s observer list when the |opener_|
+ // is set to a non-null node, and it is removed from that list when |opener_|
+ // changes or when this node is destroyed. It is also cleared if |opener_|
+ // is disowned.
+ scoped_ptr<OpenerDestroyedObserver> opener_observer_;
+
// The immediate children of this specific frame.
ScopedVector<FrameTreeNode> children_;
@@ -229,6 +261,9 @@ class CONTENT_EXPORT FrameTreeNode {
// be reset and a RenderFrameHost will be responsible for the navigation.
scoped_ptr<NavigationRequest> navigation_request_;
+ // List of objects observing this FrameTreeNode.
+ base::ObserverList<Observer> observers_;
+
DISALLOW_COPY_AND_ASSIGN(FrameTreeNode);
};
« no previous file with comments | « content/browser/frame_host/frame_tree_browsertest.cc ('k') | content/browser/frame_host/frame_tree_node.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698