| 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 CONTENT_BROWSER_WEB_CONTENTS_FRAME_TREE_NODE_H_ | 5 #ifndef CONTENT_BROWSER_WEB_CONTENTS_FRAME_TREE_NODE_H_ |
| 6 #define CONTENT_BROWSER_WEB_CONTENTS_FRAME_TREE_NODE_H_ | 6 #define CONTENT_BROWSER_WEB_CONTENTS_FRAME_TREE_NODE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/memory/scoped_vector.h" | 12 #include "base/memory/scoped_vector.h" |
| 13 #include "content/common/content_export.h" | 13 #include "content/common/content_export.h" |
| 14 #include "url/gurl.h" | 14 #include "url/gurl.h" |
| 15 | 15 |
| 16 namespace content { | 16 namespace content { |
| 17 | 17 |
| 18 class Navigator; |
| 18 class RenderFrameHostImpl; | 19 class RenderFrameHostImpl; |
| 19 | 20 |
| 20 // When a page contains iframes, its renderer process maintains a tree structure | 21 // When a page contains iframes, its renderer process maintains a tree structure |
| 21 // of those frames. We are mirroring this tree in the browser process. This | 22 // of those frames. We are mirroring this tree in the browser process. This |
| 22 // class represents a node in this tree and is a wrapper for all objects that | 23 // class represents a node in this tree and is a wrapper for all objects that |
| 23 // are frame-specific (as opposed to page-specific). | 24 // are frame-specific (as opposed to page-specific). |
| 24 class CONTENT_EXPORT FrameTreeNode { | 25 class CONTENT_EXPORT FrameTreeNode { |
| 25 public: | 26 public: |
| 26 static const int64 kInvalidFrameId; | 27 static const int64 kInvalidFrameId; |
| 27 | 28 |
| 28 FrameTreeNode(int64 frame_id, const std::string& name, | 29 FrameTreeNode(Navigator* navigator, |
| 30 int64 frame_id, |
| 31 const std::string& name, |
| 29 scoped_ptr<RenderFrameHostImpl> render_frame_host); | 32 scoped_ptr<RenderFrameHostImpl> render_frame_host); |
| 30 ~FrameTreeNode(); | 33 ~FrameTreeNode(); |
| 31 | 34 |
| 32 void AddChild(scoped_ptr<FrameTreeNode> child); | 35 void AddChild(scoped_ptr<FrameTreeNode> child); |
| 33 void RemoveChild(int64 child_id); | 36 void RemoveChild(int64 child_id); |
| 34 | 37 |
| 35 // Transitional API allowing the RenderFrameHost of a FrameTreeNode | 38 // Transitional API allowing the RenderFrameHost of a FrameTreeNode |
| 36 // representing the main frame to be provided by someone else. After | 39 // representing the main frame to be provided by someone else. After |
| 37 // this is called, the FrameTreeNode no longer owns its RenderFrameHost. | 40 // this is called, the FrameTreeNode no longer owns its RenderFrameHost. |
| 38 // | 41 // |
| (...skipping 29 matching lines...) Expand all Loading... |
| 68 } | 71 } |
| 69 | 72 |
| 70 void set_current_url(const GURL& url) { | 73 void set_current_url(const GURL& url) { |
| 71 current_url_ = url; | 74 current_url_ = url; |
| 72 } | 75 } |
| 73 | 76 |
| 74 RenderFrameHostImpl* render_frame_host() const { | 77 RenderFrameHostImpl* render_frame_host() const { |
| 75 return render_frame_host_; | 78 return render_frame_host_; |
| 76 } | 79 } |
| 77 | 80 |
| 81 Navigator* navigator() { |
| 82 return navigator_; |
| 83 } |
| 84 |
| 85 |
| 78 private: | 86 private: |
| 79 // The unique identifier for the frame in the page. | 87 // The unique identifier for the frame in the page. |
| 80 int64 frame_id_; | 88 int64 frame_id_; |
| 81 | 89 |
| 82 // The assigned name of the frame. This name can be empty, unlike the unique | 90 // The assigned name of the frame. This name can be empty, unlike the unique |
| 83 // name generated internally in the DOM tree. | 91 // name generated internally in the DOM tree. |
| 84 std::string frame_name_; | 92 std::string frame_name_; |
| 85 | 93 |
| 86 // The immediate children of this specific frame. | 94 // The immediate children of this specific frame. |
| 87 ScopedVector<FrameTreeNode> children_; | 95 ScopedVector<FrameTreeNode> children_; |
| 88 | 96 |
| 97 // Used to perform navigation in the RenderFrameHosts associated with this |
| 98 // FrameTreeNode. Owned by FrameTree. |
| 99 Navigator* navigator_; |
| 100 |
| 89 // When ResetForMainFrame() is called, this is set to false and the | 101 // When ResetForMainFrame() is called, this is set to false and the |
| 90 // |render_frame_host_| below is not deleted on destruction. | 102 // |render_frame_host_| below is not deleted on destruction. |
| 91 // | 103 // |
| 92 // For the mainframe, the FrameTree does not own the |render_frame_host_|. | 104 // For the mainframe, the FrameTree does not own the |render_frame_host_|. |
| 93 // This is a transitional wart because RenderViewHostManager does not yet | 105 // This is a transitional wart because RenderViewHostManager does not yet |
| 94 // have the bookkeeping logic to handle creating a pending RenderFrameHost | 106 // have the bookkeeping logic to handle creating a pending RenderFrameHost |
| 95 // along with a pending RenderViewHost. Thus, for the main frame, the | 107 // along with a pending RenderViewHost. Thus, for the main frame, the |
| 96 // RenderViewHost currently retains ownership and the FrameTreeNode should | 108 // RenderViewHost currently retains ownership and the FrameTreeNode should |
| 97 // not delete it on destruction. | 109 // not delete it on destruction. |
| 98 bool owns_render_frame_host_; | 110 bool owns_render_frame_host_; |
| 99 | 111 |
| 100 // The active RenderFrameHost for this frame. The FrameTreeNode does not | 112 // The active RenderFrameHost for this frame. The FrameTreeNode does not |
| 101 // always own this pointer. See comments above |owns_render_frame_host_|. | 113 // always own this pointer. See comments above |owns_render_frame_host_|. |
| 102 // TODO(ajwong): Replace with RenderFrameHostManager. | 114 // TODO(ajwong): Replace with RenderFrameHostManager. |
| 103 RenderFrameHostImpl* render_frame_host_; | 115 RenderFrameHostImpl* render_frame_host_; |
| 104 | 116 |
| 105 // Track the current frame's last committed URL, so we can estimate the | 117 // Track the current frame's last committed URL, so we can estimate the |
| 106 // process impact of out-of-process iframes. | 118 // process impact of out-of-process iframes. |
| 107 // TODO(creis): Remove this when we can store subframe URLs in the | 119 // TODO(creis): Remove this when we can store subframe URLs in the |
| 108 // NavigationController. | 120 // NavigationController. |
| 109 GURL current_url_; | 121 GURL current_url_; |
| 110 | 122 |
| 111 DISALLOW_COPY_AND_ASSIGN(FrameTreeNode); | 123 DISALLOW_COPY_AND_ASSIGN(FrameTreeNode); |
| 112 }; | 124 }; |
| 113 | 125 |
| 114 } // namespace content | 126 } // namespace content |
| 115 | 127 |
| 116 #endif // CONTENT_BROWSER_WEB_CONTENTS_FRAME_TREE_NODE_H_ | 128 #endif // CONTENT_BROWSER_WEB_CONTENTS_FRAME_TREE_NODE_H_ |
| OLD | NEW |