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.mojom.h" |
16 | 16 |
17 namespace blink { | 17 namespace blink { |
18 class WebView; | 18 class WebView; |
19 } | 19 } |
20 | 20 |
21 namespace mus { | 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 server Frame, 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 mus::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 mus::View* view, | 45 mus::View* view, |
(...skipping 19 matching lines...) Expand all Loading... |
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 mus::View* local_view, | 74 mus::View* local_view, |
75 const mojo::Array<web_view::FrameDataPtr>& frame_data, | 75 const mojo::Array<web_view::mojom::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::mojom::FrameDataPtr>& frame_data, |
82 uint32_t local_frame_id, | 82 uint32_t local_frame_id, |
83 mus::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. |
94 bool PrepareForStructureChange(HTMLFrame* source, uint32_t change_id); | 94 bool PrepareForStructureChange(HTMLFrame* source, uint32_t change_id); |
95 | 95 |
96 // Each HTMLFrame delegates FrameTreeClient methods to the | 96 // Each HTMLFrame delegates FrameClient methods to the HTMLFrameTreeManager |
97 // HTMLFrameTreeManager the frame is in. HTMLFrameTreeManager only responds | 97 // the frame is in. HTMLFrameTreeManager only responds to changes from the |
98 // to changes from the |local_root_| (this is because each FrameTreeClient | 98 // |local_root_| (this is because each FrameClient sees the same change, and |
99 // sees the same change, and a change only need be processed once). | 99 // a change only need be processed once). |
100 void ProcessOnFrameAdded(HTMLFrame* source, | 100 void ProcessOnFrameAdded(HTMLFrame* source, |
101 uint32_t change_id, | 101 uint32_t change_id, |
102 web_view::FrameDataPtr frame_data); | 102 web_view::mojom::FrameDataPtr frame_data); |
103 void ProcessOnFrameRemoved(HTMLFrame* source, | 103 void ProcessOnFrameRemoved(HTMLFrame* source, |
104 uint32_t change_id, | 104 uint32_t change_id, |
105 uint32_t frame_id); | 105 uint32_t frame_id); |
106 void ProcessOnFrameClientPropertyChanged(HTMLFrame* source, | 106 void ProcessOnFrameClientPropertyChanged(HTMLFrame* source, |
107 uint32_t frame_id, | 107 uint32_t frame_id, |
108 const mojo::String& name, | 108 const mojo::String& name, |
109 mojo::Array<uint8_t> new_data); | 109 mojo::Array<uint8_t> new_data); |
110 | 110 |
111 static TreeMap* instances_; | 111 static TreeMap* instances_; |
112 | 112 |
(...skipping 19 matching lines...) Expand all 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 |