OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 COMPONENTS_HTML_VIEWER_HTML_FRAME_TREE_MANAGER_H_ | 5 #ifndef COMPONENTS_HTML_VIEWER_HTML_FRAME_TREE_MANAGER_H_ |
6 #define COMPONENTS_HTML_VIEWER_HTML_FRAME_TREE_MANAGER_H_ | 6 #define COMPONENTS_HTML_VIEWER_HTML_FRAME_TREE_MANAGER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
14 #include "base/observer_list.h" | 14 #include "base/observer_list.h" |
15 #include "components/web_view/public/interfaces/frame_tree.mojom.h" | 15 #include "components/web_view/public/interfaces/frame_tree.mojom.h" |
16 | 16 |
17 namespace blink { | 17 namespace blink { |
18 class WebView; | 18 class WebView; |
19 } | 19 } |
20 | 20 |
21 namespace mojo { | 21 namespace mus { |
22 class View; | 22 class View; |
23 } | 23 } |
24 | 24 |
25 namespace html_viewer { | 25 namespace html_viewer { |
26 | 26 |
27 class DocumentResourceWaiter; | 27 class DocumentResourceWaiter; |
28 class GlobalState; | 28 class GlobalState; |
29 class HTMLFrame; | 29 class HTMLFrame; |
30 class HTMLFrameDelegate; | 30 class HTMLFrameDelegate; |
31 class HTMLFrameTreeManagerObserver; | 31 class HTMLFrameTreeManagerObserver; |
32 | 32 |
33 // HTMLFrameTreeManager is responsible for managing the frames that comprise a | 33 // HTMLFrameTreeManager is responsible for managing the frames that comprise a |
34 // document. Some of the frames may be remote. HTMLFrameTreeManager updates its | 34 // document. Some of the frames may be remote. HTMLFrameTreeManager updates its |
35 // state in response to changes from the FrameTreeServer, as well as changes | 35 // state in response to changes from the FrameTreeServer, as well as changes |
36 // from the underlying frames. The frame tree has at least one local frame | 36 // from the underlying frames. The frame tree has at least one local frame |
37 // that is backed by a mojo::View. | 37 // that is backed by a mus::View. |
38 class HTMLFrameTreeManager { | 38 class HTMLFrameTreeManager { |
39 public: | 39 public: |
40 // Returns a new HTMLFrame or null if a HTMLFrame does not need to be created. | 40 // Returns a new HTMLFrame or null if a HTMLFrame does not need to be created. |
41 // If this returns non-null the caller owns the return value and must call | 41 // If this returns non-null the caller owns the return value and must call |
42 // Close() when done. | 42 // Close() when done. |
43 static HTMLFrame* CreateFrameAndAttachToTree( | 43 static HTMLFrame* CreateFrameAndAttachToTree( |
44 GlobalState* global_state, | 44 GlobalState* global_state, |
45 mojo::View* view, | 45 mus::View* view, |
46 scoped_ptr<DocumentResourceWaiter> resource_waiter, | 46 scoped_ptr<DocumentResourceWaiter> resource_waiter, |
47 HTMLFrameDelegate* delegate); | 47 HTMLFrameDelegate* delegate); |
48 | 48 |
49 // Returns the HTMLFrameTreeManager with the specified root id. | 49 // Returns the HTMLFrameTreeManager with the specified root id. |
50 static HTMLFrameTreeManager* FindFrameTreeWithRoot(uint32_t root_frame_id); | 50 static HTMLFrameTreeManager* FindFrameTreeWithRoot(uint32_t root_frame_id); |
51 | 51 |
52 GlobalState* global_state() { return global_state_; } | 52 GlobalState* global_state() { return global_state_; } |
53 | 53 |
54 blink::WebView* GetWebView(); | 54 blink::WebView* GetWebView(); |
55 | 55 |
56 // Ever increasing value that is used to identify the state the tree is in. | 56 // Ever increasing value that is used to identify the state the tree is in. |
57 // That is, the value increases every time a structural change is made to | 57 // That is, the value increases every time a structural change is made to |
58 // the tree, eg add or remove. | 58 // the tree, eg add or remove. |
59 uint32_t change_id() const { return change_id_; } | 59 uint32_t change_id() const { return change_id_; } |
60 | 60 |
61 void AddObserver(HTMLFrameTreeManagerObserver* observer); | 61 void AddObserver(HTMLFrameTreeManagerObserver* observer); |
62 void RemoveObserver(HTMLFrameTreeManagerObserver* observer); | 62 void RemoveObserver(HTMLFrameTreeManagerObserver* observer); |
63 | 63 |
64 private: | 64 private: |
65 friend class HTMLFrame; | 65 friend class HTMLFrame; |
66 class ChangeIdAdvancedNotifier; | 66 class ChangeIdAdvancedNotifier; |
67 using TreeMap = std::map<uint32_t, HTMLFrameTreeManager*>; | 67 using TreeMap = std::map<uint32_t, HTMLFrameTreeManager*>; |
68 using ChangeIDSet = std::set<uint32_t>; | 68 using ChangeIDSet = std::set<uint32_t>; |
69 | 69 |
70 explicit HTMLFrameTreeManager(GlobalState* global_state); | 70 explicit HTMLFrameTreeManager(GlobalState* global_state); |
71 ~HTMLFrameTreeManager(); | 71 ~HTMLFrameTreeManager(); |
72 | 72 |
73 void Init(HTMLFrameDelegate* delegate, | 73 void Init(HTMLFrameDelegate* delegate, |
74 mojo::View* local_view, | 74 mus::View* local_view, |
75 const mojo::Array<web_view::FrameDataPtr>& frame_data, | 75 const mojo::Array<web_view::FrameDataPtr>& frame_data, |
76 uint32_t change_id); | 76 uint32_t change_id); |
77 | 77 |
78 // Creates a Frame per FrameData element in |frame_data|. Returns the root. | 78 // Creates a Frame per FrameData element in |frame_data|. Returns the root. |
79 HTMLFrame* BuildFrameTree( | 79 HTMLFrame* BuildFrameTree( |
80 HTMLFrameDelegate* delegate, | 80 HTMLFrameDelegate* delegate, |
81 const mojo::Array<web_view::FrameDataPtr>& frame_data, | 81 const mojo::Array<web_view::FrameDataPtr>& frame_data, |
82 uint32_t local_frame_id, | 82 uint32_t local_frame_id, |
83 mojo::View* local_view); | 83 mus::View* local_view); |
84 | 84 |
85 // Returns this HTMLFrameTreeManager from |instances_|. | 85 // Returns this HTMLFrameTreeManager from |instances_|. |
86 void RemoveFromInstances(); | 86 void RemoveFromInstances(); |
87 | 87 |
88 // Invoked when a Frame is destroyed. | 88 // Invoked when a Frame is destroyed. |
89 void OnFrameDestroyed(HTMLFrame* frame); | 89 void OnFrameDestroyed(HTMLFrame* frame); |
90 | 90 |
91 // Call before applying a structure change from the server. |source| is the | 91 // Call before applying a structure change from the server. |source| is the |
92 // the source of the change, and |change_id| the id from the server. Returns | 92 // the source of the change, and |change_id| the id from the server. Returns |
93 // true if the change should be applied, false otherwise. | 93 // true if the change should be applied, false otherwise. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 base::ObserverList<HTMLFrameTreeManagerObserver> observers_; | 132 base::ObserverList<HTMLFrameTreeManagerObserver> observers_; |
133 | 133 |
134 base::WeakPtrFactory<HTMLFrameTreeManager> weak_factory_; | 134 base::WeakPtrFactory<HTMLFrameTreeManager> weak_factory_; |
135 | 135 |
136 DISALLOW_COPY_AND_ASSIGN(HTMLFrameTreeManager); | 136 DISALLOW_COPY_AND_ASSIGN(HTMLFrameTreeManager); |
137 }; | 137 }; |
138 | 138 |
139 } // namespace html_viewer | 139 } // namespace html_viewer |
140 | 140 |
141 #endif // COMPONENTS_HTML_VIEWER_HTML_FRAME_TREE_MANAGER_H_ | 141 #endif // COMPONENTS_HTML_VIEWER_HTML_FRAME_TREE_MANAGER_H_ |
OLD | NEW |