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

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: Cleanup in WebContentsImpl Created 5 years, 7 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: 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..fc893578b36e925e3d736822d4ba5b7bcce135d2 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,10 @@ class CONTENT_EXPORT FrameTreeNode {
FrameTreeNode* parent() const { return parent_; }
+ FrameTreeNode* opener() const { return opener_; }
+
+ void SetOpener(FrameTreeNode* opener);
Charlie Reis 2015/06/03 20:01:37 Worth mentioning a bit of what else this does.
alexmos 2015/06/05 22:34:31 Done.
+
FrameTreeNode* child_at(size_t index) const {
return children_[index];
}
@@ -172,6 +187,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 +215,17 @@ 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 the frame disowns its opener by setting its
Charlie Reis 2015/06/03 20:01:37 nit: this frame
alexmos 2015/06/05 22:34:31 Done.
+ // 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.
Charlie Reis 2015/06/03 20:01:37 Should we also delete it from here if this node's
alexmos 2015/06/05 22:34:31 Do you mean delete opener_observer_ in SetOpener,
+ scoped_ptr<OpenerDestroyedObserver> opener_observer_;
+
// The immediate children of this specific frame.
ScopedVector<FrameTreeNode> children_;
@@ -229,6 +257,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.
+ ObserverList<Observer> observers_;
+
DISALLOW_COPY_AND_ASSIGN(FrameTreeNode);
};

Powered by Google App Engine
This is Rietveld 408576698