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_RENDERER_HOST_FRAME_TREE_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_FRAME_TREE_H_ |
6 #define CONTENT_BROWSER_RENDERER_HOST_FRAME_TREE_H_ | 6 #define CONTENT_BROWSER_RENDERER_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/renderer_host/frame_tree_node.h" | 12 #include "content/browser/renderer_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 Navigator; | |
20 class NavigatorObserver; | |
18 class RenderProcessHost; | 21 class RenderProcessHost; |
19 class RenderViewHostImpl; | 22 class RenderViewHostImpl; |
20 | 23 |
21 // Represents the frame tree for a page. With the exception of the main frame, | 24 // 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 | 25 // all FrameTreeNodes will be created/deleted in response to frame attach and |
23 // detach events in the DOM. | 26 // detach events in the DOM. |
24 // | 27 // |
25 // The main frame's FrameTreeNode is special in that it is reused. This allows | 28 // 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 | 29 // it to serve as an anchor for state that needs to persist across top-level |
27 // page navigations. | 30 // page navigations. |
28 // | 31 // |
29 // TODO(ajwong): Move NavigationController ownership to the main frame | 32 // TODO(ajwong): Move NavigationController ownership to the main frame |
30 // FrameTreeNode. Possibly expose access to it from here. | 33 // FrameTreeNode. Possibly expose access to it from here. |
31 // | 34 // |
32 // TODO(ajwong): Currently this class only contains FrameTreeNodes for | 35 // TODO(ajwong): Currently this class only contains FrameTreeNodes for |
33 // subframes if the --site-per-process flag is enabled. | 36 // subframes if the --site-per-process flag is enabled. |
34 // | 37 // |
35 // This object is only used on the UI thread. | 38 // This object is only used on the UI thread. |
36 class CONTENT_EXPORT FrameTree { | 39 class CONTENT_EXPORT FrameTree { |
37 public: | 40 public: |
38 FrameTree(); | 41 FrameTree(); |
39 ~FrameTree(); | 42 ~FrameTree(); |
40 | 43 |
44 // Initializes the frame tree with a NavigationController which keeps | |
45 // session history for it and NavigationObserver which dispatches | |
Charlie Reis
2013/10/17 00:17:25
This doesn't seem to match the observer pattern, w
| |
46 // notifications for navigation events. | |
47 void Init( | |
48 NavigationControllerImpl* navigation_controller, | |
49 NavigatorObserver* navigator_observer); | |
50 | |
41 // Returns the FrameTreeNode with the given |frame_id|. | 51 // Returns the FrameTreeNode with the given |frame_id|. |
42 FrameTreeNode* FindByID(int64 frame_id); | 52 FrameTreeNode* FindByID(int64 frame_id); |
43 | 53 |
44 // Executes |on_node| on each node in the frame tree. If |on_node| returns | 54 // Executes |on_node| on each node in the frame tree. If |on_node| returns |
45 // false, terminates the iteration immediately. Returning false is useful | 55 // false, terminates the iteration immediately. Returning false is useful |
46 // if |on_node| is just doing a search over the tree. | 56 // if |on_node| is just doing a search over the tree. |
47 void ForEach(const base::Callback<bool(FrameTreeNode*)>& on_node) const; | 57 void ForEach(const base::Callback<bool(FrameTreeNode*)>& on_node) const; |
48 | 58 |
49 // After the FrameTree is created, or after SwapMainFrame() has been called, | 59 // 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 | 60 // the root node does not yet have a frame id. This is allocated by the |
(...skipping 27 matching lines...) Expand all Loading... | |
78 | 88 |
79 // Convenience accessor for the main frame's RenderFrameHostImpl. | 89 // Convenience accessor for the main frame's RenderFrameHostImpl. |
80 RenderFrameHostImpl* GetMainFrame() const; | 90 RenderFrameHostImpl* GetMainFrame() const; |
81 | 91 |
82 // Allows a client to listen for frame removal. | 92 // Allows a client to listen for frame removal. |
83 void SetFrameRemoveListener( | 93 void SetFrameRemoveListener( |
84 const base::Callback<void(RenderViewHostImpl*, int64)>& on_frame_removed); | 94 const base::Callback<void(RenderViewHostImpl*, int64)>& on_frame_removed); |
85 | 95 |
86 FrameTreeNode* GetRootForTesting() { return root_.get(); } | 96 FrameTreeNode* GetRootForTesting() { return root_.get(); } |
87 | 97 |
98 Navigator* navigator() { | |
99 return navigator_.get(); | |
100 } | |
101 | |
88 private: | 102 private: |
89 scoped_ptr<FrameTreeNode> CreateNode(int64 frame_id, | 103 scoped_ptr<FrameTreeNode> CreateNode(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 |
115 // This is passed in to all FrameTreeNode objects which use it for | |
116 // performing navigations. | |
117 scoped_ptr<Navigator> navigator_; | |
118 | |
98 DISALLOW_COPY_AND_ASSIGN(FrameTree); | 119 DISALLOW_COPY_AND_ASSIGN(FrameTree); |
99 }; | 120 }; |
100 | 121 |
101 } // namespace content | 122 } // namespace content |
102 | 123 |
103 #endif // CONTENT_BROWSER_RENDERER_HOST_FRAME_TREE_H_ | 124 #endif // CONTENT_BROWSER_RENDERER_HOST_FRAME_TREE_H_ |
OLD | NEW |