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_FRAME_HOST_FRAME_TREE_H_ | 5 #ifndef CONTENT_BROWSER_FRAME_HOST_FRAME_TREE_H_ |
6 #define CONTENT_BROWSER_FRAME_HOST_FRAME_TREE_H_ | 6 #define CONTENT_BROWSER_FRAME_HOST_FRAME_TREE_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 23 matching lines...) Expand all Loading... |
34 // it to serve as an anchor for state that needs to persist across top-level | 34 // it to serve as an anchor for state that needs to persist across top-level |
35 // page navigations. | 35 // page navigations. |
36 // | 36 // |
37 // TODO(ajwong): Move NavigationController ownership to the main frame | 37 // TODO(ajwong): Move NavigationController ownership to the main frame |
38 // FrameTreeNode. Possibly expose access to it from here. | 38 // FrameTreeNode. Possibly expose access to it from here. |
39 // | 39 // |
40 // This object is only used on the UI thread. | 40 // This object is only used on the UI thread. |
41 class CONTENT_EXPORT FrameTree { | 41 class CONTENT_EXPORT FrameTree { |
42 public: | 42 public: |
43 class NodeRange; | 43 class NodeRange; |
44 class ConstNodeRange; | |
45 | 44 |
46 class CONTENT_EXPORT NodeIterator { | 45 class CONTENT_EXPORT NodeIterator { |
47 public: | 46 public: |
48 ~NodeIterator(); | 47 ~NodeIterator(); |
49 | 48 |
50 NodeIterator& operator++(); | 49 NodeIterator& operator++(); |
51 | 50 |
52 bool operator==(const NodeIterator& rhs) const; | 51 bool operator==(const NodeIterator& rhs) const; |
53 bool operator!=(const NodeIterator& rhs) const { return !(*this == rhs); } | 52 bool operator!=(const NodeIterator& rhs) const { return !(*this == rhs); } |
54 | 53 |
(...skipping 16 matching lines...) Expand all Loading... |
71 | 70 |
72 private: | 71 private: |
73 friend class FrameTree; | 72 friend class FrameTree; |
74 | 73 |
75 NodeRange(FrameTree* tree, FrameTreeNode* node_to_skip); | 74 NodeRange(FrameTree* tree, FrameTreeNode* node_to_skip); |
76 | 75 |
77 FrameTree* const tree_; | 76 FrameTree* const tree_; |
78 FrameTreeNode* const node_to_skip_; | 77 FrameTreeNode* const node_to_skip_; |
79 }; | 78 }; |
80 | 79 |
81 class CONTENT_EXPORT ConstNodeIterator { | |
82 public: | |
83 ~ConstNodeIterator(); | |
84 | |
85 ConstNodeIterator& operator++(); | |
86 | |
87 bool operator==(const ConstNodeIterator& rhs) const; | |
88 bool operator!=(const ConstNodeIterator& rhs) const { | |
89 return !(*this == rhs); | |
90 } | |
91 | |
92 const FrameTreeNode* operator*() { return current_node_; } | |
93 | |
94 private: | |
95 friend class ConstNodeRange; | |
96 | |
97 ConstNodeIterator(const FrameTreeNode* starting_node); | |
98 | |
99 const FrameTreeNode* current_node_; | |
100 std::queue<const FrameTreeNode*> queue_; | |
101 }; | |
102 | |
103 class CONTENT_EXPORT ConstNodeRange { | |
104 public: | |
105 ConstNodeIterator begin(); | |
106 ConstNodeIterator end(); | |
107 | |
108 private: | |
109 friend class FrameTree; | |
110 | |
111 ConstNodeRange(const FrameTree* tree); | |
112 | |
113 const FrameTree* const tree_; | |
114 }; | |
115 | |
116 // Each FrameTreeNode will default to using the given |navigator| for | 80 // Each FrameTreeNode will default to using the given |navigator| for |
117 // navigation tasks in the frame. | 81 // navigation tasks in the frame. |
118 // A set of delegates are remembered here so that we can create | 82 // A set of delegates are remembered here so that we can create |
119 // RenderFrameHostManagers. | 83 // RenderFrameHostManagers. |
120 // TODO(creis): This set of delegates will change as we move things to | 84 // TODO(creis): This set of delegates will change as we move things to |
121 // Navigator. | 85 // Navigator. |
122 FrameTree(Navigator* navigator, | 86 FrameTree(Navigator* navigator, |
123 RenderFrameHostDelegate* render_frame_delegate, | 87 RenderFrameHostDelegate* render_frame_delegate, |
124 RenderViewHostDelegate* render_view_delegate, | 88 RenderViewHostDelegate* render_view_delegate, |
125 RenderWidgetHostDelegate* render_widget_delegate, | 89 RenderWidgetHostDelegate* render_widget_delegate, |
(...skipping 12 matching lines...) Expand all Loading... |
138 // Returns the first frame in this tree with the given |name|, or the main | 102 // Returns the first frame in this tree with the given |name|, or the main |
139 // frame if |name| is empty. | 103 // frame if |name| is empty. |
140 // Note that this does NOT support pseudo-names like _self, _top, and _blank, | 104 // Note that this does NOT support pseudo-names like _self, _top, and _blank, |
141 // nor searching other FrameTrees (unlike blink::WebView::findFrameByName). | 105 // nor searching other FrameTrees (unlike blink::WebView::findFrameByName). |
142 FrameTreeNode* FindByName(const std::string& name); | 106 FrameTreeNode* FindByName(const std::string& name); |
143 | 107 |
144 // Returns a range to iterate over all FrameTreeNodes in the frame tree in | 108 // Returns a range to iterate over all FrameTreeNodes in the frame tree in |
145 // breadth-first traversal order. | 109 // breadth-first traversal order. |
146 NodeRange Nodes(); | 110 NodeRange Nodes(); |
147 | 111 |
148 // Returns a range to iterate over all FrameTreeNodes in the frame tree in | |
149 // breadth-first traversal order. All FrameTreeNodes returned will be const. | |
150 ConstNodeRange ConstNodes() const; | |
151 | |
152 // Adds a new child frame to the frame tree. |process_id| is required to | 112 // Adds a new child frame to the frame tree. |process_id| is required to |
153 // disambiguate |new_routing_id|, and it must match the process of the | 113 // disambiguate |new_routing_id|, and it must match the process of the |
154 // |parent| node. Otherwise no child is added and this method returns false. | 114 // |parent| node. Otherwise no child is added and this method returns false. |
155 bool AddFrame(FrameTreeNode* parent, | 115 bool AddFrame(FrameTreeNode* parent, |
156 int process_id, | 116 int process_id, |
157 int new_routing_id, | 117 int new_routing_id, |
158 blink::WebTreeScopeType scope, | 118 blink::WebTreeScopeType scope, |
159 const std::string& frame_name, | 119 const std::string& frame_name, |
160 blink::WebSandboxFlags sandbox_flags, | 120 blink::WebSandboxFlags sandbox_flags, |
161 const blink::WebFrameOwnerProperties& frame_owner_properties); | 121 const blink::WebFrameOwnerProperties& frame_owner_properties); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 // Updates the overall load progress and notifies the WebContents. | 180 // Updates the overall load progress and notifies the WebContents. |
221 void UpdateLoadProgress(); | 181 void UpdateLoadProgress(); |
222 | 182 |
223 // Returns this FrameTree's total load progress. | 183 // Returns this FrameTree's total load progress. |
224 double load_progress() { return load_progress_; } | 184 double load_progress() { return load_progress_; } |
225 | 185 |
226 // Resets the load progress on all nodes in this FrameTree. | 186 // Resets the load progress on all nodes in this FrameTree. |
227 void ResetLoadProgress(); | 187 void ResetLoadProgress(); |
228 | 188 |
229 // Returns true if at least one of the nodes in this FrameTree is loading. | 189 // Returns true if at least one of the nodes in this FrameTree is loading. |
230 bool IsLoading() const; | 190 bool IsLoading(); |
231 | 191 |
232 // Set page-level focus in all SiteInstances involved in rendering | 192 // Set page-level focus in all SiteInstances involved in rendering |
233 // this FrameTree, not including the current main frame's | 193 // this FrameTree, not including the current main frame's |
234 // SiteInstance. The focus update will be sent via the main frame's proxies | 194 // SiteInstance. The focus update will be sent via the main frame's proxies |
235 // in those SiteInstances. | 195 // in those SiteInstances. |
236 void ReplicatePageFocus(bool is_focused); | 196 void ReplicatePageFocus(bool is_focused); |
237 | 197 |
238 // Updates page-level focus for this FrameTree in the subframe renderer | 198 // Updates page-level focus for this FrameTree in the subframe renderer |
239 // identified by |instance|. | 199 // identified by |instance|. |
240 void SetPageFocus(SiteInstance* instance, bool is_focused); | 200 void SetPageFocus(SiteInstance* instance, bool is_focused); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 | 246 |
287 // Overall load progress. | 247 // Overall load progress. |
288 double load_progress_; | 248 double load_progress_; |
289 | 249 |
290 DISALLOW_COPY_AND_ASSIGN(FrameTree); | 250 DISALLOW_COPY_AND_ASSIGN(FrameTree); |
291 }; | 251 }; |
292 | 252 |
293 } // namespace content | 253 } // namespace content |
294 | 254 |
295 #endif // CONTENT_BROWSER_FRAME_HOST_FRAME_TREE_H_ | 255 #endif // CONTENT_BROWSER_FRAME_HOST_FRAME_TREE_H_ |
OLD | NEW |