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 <string> | 8 #include <string> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "content/browser/frame_host/frame_tree_node.h" | 12 #include "content/browser/frame_host/frame_tree_node.h" |
13 #include "content/common/content_export.h" | 13 #include "content/common/content_export.h" |
14 | 14 |
15 namespace content { | 15 namespace content { |
16 | 16 |
17 class FrameTreeNode; | 17 class FrameTreeNode; |
18 class NavigationControllerImpl; | |
19 class NavigatorDelegate; | |
18 class RenderProcessHost; | 20 class RenderProcessHost; |
19 class RenderViewHostImpl; | 21 class RenderViewHostImpl; |
20 | 22 |
21 // Represents the frame tree for a page. With the exception of the main frame, | 23 // Represents the frame tree for a page. With the exception of the main frame, |
22 // all FrameTreeNodes will be created/deleted in response to frame attach and | 24 // all FrameTreeNodes will be created/deleted in response to frame attach and |
23 // detach events in the DOM. | 25 // detach events in the DOM. |
24 // | 26 // |
25 // The main frame's FrameTreeNode is special in that it is reused. This allows | 27 // The main frame's FrameTreeNode is special in that it is reused. This allows |
26 // it to serve as an anchor for state that needs to persist across top-level | 28 // it to serve as an anchor for state that needs to persist across top-level |
27 // page navigations. | 29 // page navigations. |
28 // | 30 // |
29 // TODO(ajwong): Move NavigationController ownership to the main frame | 31 // TODO(ajwong): Move NavigationController ownership to the main frame |
30 // FrameTreeNode. Possibly expose access to it from here. | 32 // FrameTreeNode. Possibly expose access to it from here. |
31 // | 33 // |
32 // TODO(ajwong): Currently this class only contains FrameTreeNodes for | 34 // TODO(ajwong): Currently this class only contains FrameTreeNodes for |
33 // subframes if the --site-per-process flag is enabled. | 35 // subframes if the --site-per-process flag is enabled. |
34 // | 36 // |
35 // This object is only used on the UI thread. | 37 // This object is only used on the UI thread. |
36 class CONTENT_EXPORT FrameTree { | 38 class CONTENT_EXPORT FrameTree { |
37 public: | 39 public: |
38 FrameTree(); | 40 FrameTree(); |
39 ~FrameTree(); | 41 ~FrameTree(); |
40 | 42 |
43 // Initializes the frame tree with a NavigationController which keeps | |
Charlie Reis
2013/11/07 01:22:43
If I understand correctly, InterstitialPages are g
| |
44 // session history for it and NavigationObserver which dispatches | |
Charlie Reis
2013/11/07 01:22:43
nit: NavigatorDelegate.
| |
45 // notifications for navigation events. | |
46 void Init( | |
47 NavigationControllerImpl* navigation_controller, | |
Charlie Reis
2013/11/07 01:22:43
nit: Should go on previous line.
| |
48 NavigatorDelegate* navigator_delegate); | |
49 | |
41 // Returns the FrameTreeNode with the given |frame_id|. | 50 // Returns the FrameTreeNode with the given |frame_id|. |
42 FrameTreeNode* FindByID(int64 frame_id); | 51 FrameTreeNode* FindByID(int64 frame_id); |
43 | 52 |
44 // Executes |on_node| on each node in the frame tree. If |on_node| returns | 53 // Executes |on_node| on each node in the frame tree. If |on_node| returns |
45 // false, terminates the iteration immediately. Returning false is useful | 54 // false, terminates the iteration immediately. Returning false is useful |
46 // if |on_node| is just doing a search over the tree. | 55 // if |on_node| is just doing a search over the tree. |
47 void ForEach(const base::Callback<bool(FrameTreeNode*)>& on_node) const; | 56 void ForEach(const base::Callback<bool(FrameTreeNode*)>& on_node) const; |
48 | 57 |
49 // After the FrameTree is created, or after SwapMainFrame() has been called, | 58 // After the FrameTree is created, or after SwapMainFrame() has been called, |
50 // the root node does not yet have a frame id. This is allocated by the | 59 // the root node does not yet have a frame id. This is allocated by the |
(...skipping 27 matching lines...) Expand all Loading... | |
78 | 87 |
79 // Convenience accessor for the main frame's RenderFrameHostImpl. | 88 // Convenience accessor for the main frame's RenderFrameHostImpl. |
80 RenderFrameHostImpl* GetMainFrame() const; | 89 RenderFrameHostImpl* GetMainFrame() const; |
81 | 90 |
82 // Allows a client to listen for frame removal. | 91 // Allows a client to listen for frame removal. |
83 void SetFrameRemoveListener( | 92 void SetFrameRemoveListener( |
84 const base::Callback<void(RenderViewHostImpl*, int64)>& on_frame_removed); | 93 const base::Callback<void(RenderViewHostImpl*, int64)>& on_frame_removed); |
85 | 94 |
86 FrameTreeNode* GetRootForTesting() { return root_.get(); } | 95 FrameTreeNode* GetRootForTesting() { return root_.get(); } |
87 | 96 |
97 Navigator* navigator() { | |
Charlie Reis
2013/11/07 01:22:43
Do we need this here? I'm thinking we'll want to
| |
98 return root_->navigator(); | |
99 } | |
100 | |
88 private: | 101 private: |
89 scoped_ptr<FrameTreeNode> CreateNode(int64 frame_id, | 102 scoped_ptr<FrameTreeNode> CreateNode(Navigator* parent_navigator, |
103 int64 frame_id, | |
90 const std::string& frame_name, | 104 const std::string& frame_name, |
91 int render_frame_host_id, | 105 int render_frame_host_id, |
92 RenderProcessHost* render_process_host); | 106 RenderProcessHost* render_process_host); |
93 | 107 |
108 // The root node for the frame tree. | |
94 scoped_ptr<FrameTreeNode> root_; | 109 scoped_ptr<FrameTreeNode> root_; |
95 | 110 |
111 // Callback which is invoked when a FrameTreeNode is removed from the | |
112 // tree. | |
96 base::Callback<void(RenderViewHostImpl*, int64)> on_frame_removed_; | 113 base::Callback<void(RenderViewHostImpl*, int64)> on_frame_removed_; |
97 | 114 |
98 DISALLOW_COPY_AND_ASSIGN(FrameTree); | 115 DISALLOW_COPY_AND_ASSIGN(FrameTree); |
99 }; | 116 }; |
100 | 117 |
101 } // namespace content | 118 } // namespace content |
102 | 119 |
103 #endif // CONTENT_BROWSER_FRAME_HOST_FRAME_TREE_H_ | 120 #endif // CONTENT_BROWSER_FRAME_HOST_FRAME_TREE_H_ |
OLD | NEW |