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_NODE_H_ | 5 #ifndef CONTENT_BROWSER_FRAME_HOST_FRAME_TREE_NODE_H_ |
6 #define CONTENT_BROWSER_FRAME_HOST_FRAME_TREE_NODE_H_ | 6 #define CONTENT_BROWSER_FRAME_HOST_FRAME_TREE_NODE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 class NavigationRequest; | 24 class NavigationRequest; |
25 class Navigator; | 25 class Navigator; |
26 class RenderFrameHostImpl; | 26 class RenderFrameHostImpl; |
27 | 27 |
28 // When a page contains iframes, its renderer process maintains a tree structure | 28 // When a page contains iframes, its renderer process maintains a tree structure |
29 // of those frames. We are mirroring this tree in the browser process. This | 29 // of those frames. We are mirroring this tree in the browser process. This |
30 // class represents a node in this tree and is a wrapper for all objects that | 30 // class represents a node in this tree and is a wrapper for all objects that |
31 // are frame-specific (as opposed to page-specific). | 31 // are frame-specific (as opposed to page-specific). |
32 class CONTENT_EXPORT FrameTreeNode { | 32 class CONTENT_EXPORT FrameTreeNode { |
33 public: | 33 public: |
34 // These values indicate the loading progress status. The minimum progress | |
35 // value matches what Blink's ProgressTracker has traditionally used for a | |
36 // minimum progress value. | |
37 // TODO(fdegans): Move these values to the implementation when the relevant | |
38 // IPCs are moved from WebContentsImpl to RenderFrameHost. | |
39 static const double kLoadingProgressNotStarted; | |
40 static const double kLoadingProgressMinimum; | |
41 static const double kLoadingProgressDone; | |
42 | |
43 // Returns the FrameTreeNode with the given global |frame_tree_node_id|, | 34 // Returns the FrameTreeNode with the given global |frame_tree_node_id|, |
44 // regardless of which FrameTree it is in. | 35 // regardless of which FrameTree it is in. |
45 static FrameTreeNode* GloballyFindByID(int64 frame_tree_node_id); | 36 static FrameTreeNode* GloballyFindByID(int64 frame_tree_node_id); |
46 | 37 |
47 FrameTreeNode(FrameTree* frame_tree, | 38 FrameTreeNode(FrameTree* frame_tree, |
48 Navigator* navigator, | 39 Navigator* navigator, |
49 RenderFrameHostDelegate* render_frame_delegate, | 40 RenderFrameHostDelegate* render_frame_delegate, |
50 RenderViewHostDelegate* render_view_delegate, | 41 RenderViewHostDelegate* render_view_delegate, |
51 RenderWidgetHostDelegate* render_widget_delegate, | 42 RenderWidgetHostDelegate* render_widget_delegate, |
52 RenderFrameHostManager::Delegate* manager_delegate, | 43 RenderFrameHostManager::Delegate* manager_delegate, |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 | 119 |
129 RenderFrameHostImpl* current_frame_host() const { | 120 RenderFrameHostImpl* current_frame_host() const { |
130 return render_manager_.current_frame_host(); | 121 return render_manager_.current_frame_host(); |
131 } | 122 } |
132 | 123 |
133 bool IsDescendantOf(FrameTreeNode* other) const; | 124 bool IsDescendantOf(FrameTreeNode* other) const; |
134 | 125 |
135 // Returns true if this node is in a loading state. | 126 // Returns true if this node is in a loading state. |
136 bool IsLoading() const; | 127 bool IsLoading() const; |
137 | 128 |
138 // Sets this node's loading progress (from 0 to 1). | |
139 void set_loading_progress(double loading_progress) { | |
140 loading_progress_ = loading_progress; | |
141 } | |
142 | |
143 // Returns this node's loading progress. | 129 // Returns this node's loading progress. |
144 double loading_progress() const { return loading_progress_; } | 130 double loading_progress() const { return loading_progress_; } |
145 | 131 |
146 NavigationRequest* navigation_request() { return navigation_request_.get(); } | 132 NavigationRequest* navigation_request() { return navigation_request_.get(); } |
147 | 133 |
148 // PlzNavigate | 134 // PlzNavigate |
149 // Takes ownership of |navigation_request| and makes it the current | 135 // Takes ownership of |navigation_request| and makes it the current |
150 // NavigationRequest of this frame. This corresponds to the start of a new | 136 // NavigationRequest of this frame. This corresponds to the start of a new |
151 // navigation. If there was an ongoing navigation request before calling this | 137 // navigation. If there was an ongoing navigation request before calling this |
152 // function, it is canceled. |navigation_request| should not be null. | 138 // function, it is canceled. |navigation_request| should not be null. |
153 void SetNavigationRequest(scoped_ptr<NavigationRequest> navigation_request); | 139 void SetNavigationRequest(scoped_ptr<NavigationRequest> navigation_request); |
154 | 140 |
155 // PlzNavigate | 141 // PlzNavigate |
156 // Resets the current navigation request. |is_commit| is true if the reset is | 142 // Resets the current navigation request. |is_commit| is true if the reset is |
157 // due to the commit of the navigation. | 143 // due to the commit of the navigation. |
158 void ResetNavigationRequest(bool is_commit); | 144 void ResetNavigationRequest(bool is_commit); |
159 | 145 |
| 146 // Returns true if this node is in a state where the loading progress is being |
| 147 // tracked. |
| 148 bool has_started_loading() const; |
| 149 |
| 150 // Resets this node's loading progress. |
| 151 void reset_loading_progress(); |
| 152 |
| 153 // A RenderFrameHost in this node started loading. |
| 154 // |to_different_document| will be true unless the load is a fragment |
| 155 // navigation, or triggered by history.pushState/replaceState. |
| 156 void DidStartLoading(bool to_different_document); |
| 157 |
| 158 // A RenderFrameHost in this node stopped loading. |
| 159 void DidStopLoading(); |
| 160 |
| 161 // The load progress for a RenderFrameHost in this node was updated to |
| 162 // |load_progress|. This will notify the FrameTree which will in turn notify |
| 163 // the WebContents. |
| 164 void DidChangeLoadProgress(double load_progress); |
| 165 |
160 private: | 166 private: |
161 void set_parent(FrameTreeNode* parent) { parent_ = parent; } | 167 void set_parent(FrameTreeNode* parent) { parent_ = parent; } |
162 | 168 |
163 // The next available browser-global FrameTreeNode ID. | 169 // The next available browser-global FrameTreeNode ID. |
164 static int64 next_frame_tree_node_id_; | 170 static int64 next_frame_tree_node_id_; |
165 | 171 |
166 // The FrameTree that owns us. | 172 // The FrameTree that owns us. |
167 FrameTree* frame_tree_; // not owned. | 173 FrameTree* frame_tree_; // not owned. |
168 | 174 |
169 // The Navigator object responsible for managing navigations at this node | 175 // The Navigator object responsible for managing navigations at this node |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 // Owns an ongoing NavigationRequest until it is ready to commit. It will then | 220 // Owns an ongoing NavigationRequest until it is ready to commit. It will then |
215 // be reset and a RenderFrameHost will be responsible for the navigation. | 221 // be reset and a RenderFrameHost will be responsible for the navigation. |
216 scoped_ptr<NavigationRequest> navigation_request_; | 222 scoped_ptr<NavigationRequest> navigation_request_; |
217 | 223 |
218 DISALLOW_COPY_AND_ASSIGN(FrameTreeNode); | 224 DISALLOW_COPY_AND_ASSIGN(FrameTreeNode); |
219 }; | 225 }; |
220 | 226 |
221 } // namespace content | 227 } // namespace content |
222 | 228 |
223 #endif // CONTENT_BROWSER_FRAME_HOST_FRAME_TREE_NODE_H_ | 229 #endif // CONTENT_BROWSER_FRAME_HOST_FRAME_TREE_NODE_H_ |
OLD | NEW |