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_WEB_VIEW_FRAME_H_ | 5 #ifndef COMPONENTS_WEB_VIEW_FRAME_H_ |
6 #define COMPONENTS_WEB_VIEW_FRAME_H_ | 6 #define COMPONENTS_WEB_VIEW_FRAME_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 // | 42 // |
43 // Each frame has an identifier of the app providing the FrameTreeClient | 43 // Each frame has an identifier of the app providing the FrameTreeClient |
44 // (|app_id|). This id is used when servicing a request to navigate the frame. | 44 // (|app_id|). This id is used when servicing a request to navigate the frame. |
45 // When navigating, if the id of the new app matches that of the existing app, | 45 // When navigating, if the id of the new app matches that of the existing app, |
46 // then it is expected that the new FrameTreeClient will take over rendering to | 46 // then it is expected that the new FrameTreeClient will take over rendering to |
47 // the existing view. Because of this a new ViewTreeClient is not obtained and | 47 // the existing view. Because of this a new ViewTreeClient is not obtained and |
48 // Embed() is not invoked on the View. The FrameTreeClient can detect this case | 48 // Embed() is not invoked on the View. The FrameTreeClient can detect this case |
49 // by the argument |reuse_existing_view| supplied to OnConnect(). Typically the | 49 // by the argument |reuse_existing_view| supplied to OnConnect(). Typically the |
50 // id is that of content handler id, but this is left up to the | 50 // id is that of content handler id, but this is left up to the |
51 // FrameTreeDelegate to decide. | 51 // FrameTreeDelegate to decide. |
52 class Frame : public mojo::ViewObserver, public FrameTreeServer { | 52 class Frame : public mus::ViewObserver, public FrameTreeServer { |
53 public: | 53 public: |
54 using ClientPropertyMap = std::map<std::string, std::vector<uint8_t>>; | 54 using ClientPropertyMap = std::map<std::string, std::vector<uint8_t>>; |
55 | 55 |
56 Frame(FrameTree* tree, | 56 Frame(FrameTree* tree, |
57 mojo::View* view, | 57 mus::View* view, |
58 uint32_t frame_id, | 58 uint32_t frame_id, |
59 uint32_t app_id, | 59 uint32_t app_id, |
60 ViewOwnership view_ownership, | 60 ViewOwnership view_ownership, |
61 FrameTreeClient* frame_tree_client, | 61 FrameTreeClient* frame_tree_client, |
62 scoped_ptr<FrameUserData> user_data, | 62 scoped_ptr<FrameUserData> user_data, |
63 const ClientPropertyMap& client_properties); | 63 const ClientPropertyMap& client_properties); |
64 ~Frame() override; | 64 ~Frame() override; |
65 | 65 |
66 void Init(Frame* parent, mojo::ViewTreeClientPtr view_tree_client); | 66 void Init(Frame* parent, mojo::ViewTreeClientPtr view_tree_client); |
67 | 67 |
68 // Walks the View tree starting at |view| going up returning the first | 68 // Walks the View tree starting at |view| going up returning the first |
69 // Frame that is associated with |view|. For example, if |view| | 69 // Frame that is associated with |view|. For example, if |view| |
70 // has a Frame associated with it, then that is returned. Otherwise | 70 // has a Frame associated with it, then that is returned. Otherwise |
71 // this checks view->parent() and so on. | 71 // this checks view->parent() and so on. |
72 static Frame* FindFirstFrameAncestor(mojo::View* view); | 72 static Frame* FindFirstFrameAncestor(mus::View* view); |
73 | 73 |
74 FrameTree* tree() { return tree_; } | 74 FrameTree* tree() { return tree_; } |
75 | 75 |
76 Frame* parent() { return parent_; } | 76 Frame* parent() { return parent_; } |
77 const Frame* parent() const { return parent_; } | 77 const Frame* parent() const { return parent_; } |
78 | 78 |
79 mojo::View* view() { return view_; } | 79 mus::View* view() { return view_; } |
80 const mojo::View* view() const { return view_; } | 80 const mus::View* view() const { return view_; } |
81 | 81 |
82 uint32_t id() const { return id_; } | 82 uint32_t id() const { return id_; } |
83 | 83 |
84 uint32_t app_id() const { return app_id_; } | 84 uint32_t app_id() const { return app_id_; } |
85 | 85 |
86 const ClientPropertyMap& client_properties() const { | 86 const ClientPropertyMap& client_properties() const { |
87 return client_properties_; | 87 return client_properties_; |
88 } | 88 } |
89 | 89 |
90 // Finds the descendant with the specified id. | 90 // Finds the descendant with the specified id. |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 scoped_ptr<FrameTreeServerBinding> frame_tree_server_binding, | 130 scoped_ptr<FrameTreeServerBinding> frame_tree_server_binding, |
131 mojo::ViewTreeClientPtr view_tree_client); | 131 mojo::ViewTreeClientPtr view_tree_client); |
132 | 132 |
133 // Callback from OnConnect(). This does nothing (other than destroying | 133 // Callback from OnConnect(). This does nothing (other than destroying |
134 // |frame_tree_server_binding|). See InitClient() for details as to why | 134 // |frame_tree_server_binding|). See InitClient() for details as to why |
135 // destruction of |frame_tree_server_binding| happens after OnConnect(). | 135 // destruction of |frame_tree_server_binding| happens after OnConnect(). |
136 static void OnConnectAck( | 136 static void OnConnectAck( |
137 scoped_ptr<FrameTreeServerBinding> frame_tree_server_binding); | 137 scoped_ptr<FrameTreeServerBinding> frame_tree_server_binding); |
138 | 138 |
139 // Callback from OnEmbed(). | 139 // Callback from OnEmbed(). |
140 void OnEmbedAck(bool success, mojo::ConnectionSpecificId connection_id); | 140 void OnEmbedAck(bool success, mus::ConnectionSpecificId connection_id); |
141 | 141 |
142 // Completes a navigation request; swapping the existing FrameTreeClient to | 142 // Completes a navigation request; swapping the existing FrameTreeClient to |
143 // the supplied arguments. | 143 // the supplied arguments. |
144 void ChangeClient(FrameTreeClient* frame_tree_client, | 144 void ChangeClient(FrameTreeClient* frame_tree_client, |
145 scoped_ptr<FrameUserData> user_data, | 145 scoped_ptr<FrameUserData> user_data, |
146 mojo::ViewTreeClientPtr view_tree_client, | 146 mojo::ViewTreeClientPtr view_tree_client, |
147 uint32 app_id); | 147 uint32 app_id); |
148 | 148 |
149 void SetView(mojo::View* view); | 149 void SetView(mus::View* view); |
150 | 150 |
151 // Returns the first ancestor (starting at |this|) that has a | 151 // Returns the first ancestor (starting at |this|) that has a |
152 // FrameTreeClient. | 152 // FrameTreeClient. |
153 Frame* GetAncestorWithFrameTreeClient(); | 153 Frame* GetAncestorWithFrameTreeClient(); |
154 | 154 |
155 // Adds this to |frames| and recurses through the children calling the | 155 // Adds this to |frames| and recurses through the children calling the |
156 // same function. | 156 // same function. |
157 void BuildFrameTree(std::vector<const Frame*>* frames) const; | 157 void BuildFrameTree(std::vector<const Frame*>* frames) const; |
158 | 158 |
159 void Add(Frame* node); | 159 void Add(Frame* node); |
(...skipping 23 matching lines...) Expand all Loading... |
183 void NotifyAdded(const Frame* source, | 183 void NotifyAdded(const Frame* source, |
184 const Frame* added_node, | 184 const Frame* added_node, |
185 uint32_t change_id); | 185 uint32_t change_id); |
186 void NotifyRemoved(const Frame* source, | 186 void NotifyRemoved(const Frame* source, |
187 const Frame* removed_node, | 187 const Frame* removed_node, |
188 uint32_t change_id); | 188 uint32_t change_id); |
189 void NotifyClientPropertyChanged(const Frame* source, | 189 void NotifyClientPropertyChanged(const Frame* source, |
190 const mojo::String& name, | 190 const mojo::String& name, |
191 const mojo::Array<uint8_t>& value); | 191 const mojo::Array<uint8_t>& value); |
192 | 192 |
193 // mojo::ViewObserver: | 193 // mus::ViewObserver: |
194 void OnTreeChanged(const TreeChangeParams& params) override; | 194 void OnTreeChanged(const TreeChangeParams& params) override; |
195 void OnViewDestroying(mojo::View* view) override; | 195 void OnViewDestroying(mus::View* view) override; |
196 void OnViewEmbeddedAppDisconnected(mojo::View* view) override; | 196 void OnViewEmbeddedAppDisconnected(mus::View* view) override; |
197 | 197 |
198 // FrameTreeServer: | 198 // FrameTreeServer: |
199 void PostMessageEventToFrame(uint32_t source_frame_id, | 199 void PostMessageEventToFrame(uint32_t source_frame_id, |
200 uint32_t target_frame_id, | 200 uint32_t target_frame_id, |
201 HTMLMessageEventPtr event) override; | 201 HTMLMessageEventPtr event) override; |
202 void LoadingStateChanged(uint32 frame_id, | 202 void LoadingStateChanged(uint32 frame_id, |
203 bool loading, | 203 bool loading, |
204 double progress) override; | 204 double progress) override; |
205 void TitleChanged(uint32_t frame_id, const mojo::String& title) override; | 205 void TitleChanged(uint32_t frame_id, const mojo::String& title) override; |
206 void SetClientProperty(uint32_t frame_id, | 206 void SetClientProperty(uint32_t frame_id, |
207 const mojo::String& name, | 207 const mojo::String& name, |
208 mojo::Array<uint8_t> value) override; | 208 mojo::Array<uint8_t> value) override; |
209 void OnCreatedFrame( | 209 void OnCreatedFrame( |
210 uint32_t parent_id, | 210 uint32_t parent_id, |
211 uint32_t frame_id, | 211 uint32_t frame_id, |
212 mojo::Map<mojo::String, mojo::Array<uint8_t>> client_properties) override; | 212 mojo::Map<mojo::String, mojo::Array<uint8_t>> client_properties) override; |
213 void RequestNavigate(NavigationTargetType target_type, | 213 void RequestNavigate(NavigationTargetType target_type, |
214 uint32_t target_frame_id, | 214 uint32_t target_frame_id, |
215 mojo::URLRequestPtr request) override; | 215 mojo::URLRequestPtr request) override; |
216 void DidNavigateLocally(uint32_t frame_id, const mojo::String& url) override; | 216 void DidNavigateLocally(uint32_t frame_id, const mojo::String& url) override; |
217 | 217 |
218 FrameTree* const tree_; | 218 FrameTree* const tree_; |
219 // WARNING: this may be null. See class description for details. | 219 // WARNING: this may be null. See class description for details. |
220 mojo::View* view_; | 220 mus::View* view_; |
221 // The connection id returned from ViewManager::Embed(). Frames created by | 221 // The connection id returned from ViewManager::Embed(). Frames created by |
222 // way of OnCreatedFrame() inherit the id from the parent. | 222 // way of OnCreatedFrame() inherit the id from the parent. |
223 mojo::ConnectionSpecificId embedded_connection_id_; | 223 mus::ConnectionSpecificId embedded_connection_id_; |
224 // ID for the frame, which is the same as that of the view. | 224 // ID for the frame, which is the same as that of the view. |
225 const uint32_t id_; | 225 const uint32_t id_; |
226 // ID of the app providing the FrameTreeClient and ViewTreeClient. | 226 // ID of the app providing the FrameTreeClient and ViewTreeClient. |
227 uint32_t app_id_; | 227 uint32_t app_id_; |
228 Frame* parent_; | 228 Frame* parent_; |
229 ViewOwnership view_ownership_; | 229 ViewOwnership view_ownership_; |
230 std::vector<Frame*> children_; | 230 std::vector<Frame*> children_; |
231 scoped_ptr<FrameUserData> user_data_; | 231 scoped_ptr<FrameUserData> user_data_; |
232 | 232 |
233 // WARNING: this may be null. See class description for details. | 233 // WARNING: this may be null. See class description for details. |
(...skipping 13 matching lines...) Expand all Loading... |
247 base::WeakPtrFactory<Frame> embed_weak_ptr_factory_; | 247 base::WeakPtrFactory<Frame> embed_weak_ptr_factory_; |
248 | 248 |
249 base::WeakPtrFactory<Frame> navigate_weak_ptr_factory_; | 249 base::WeakPtrFactory<Frame> navigate_weak_ptr_factory_; |
250 | 250 |
251 DISALLOW_COPY_AND_ASSIGN(Frame); | 251 DISALLOW_COPY_AND_ASSIGN(Frame); |
252 }; | 252 }; |
253 | 253 |
254 } // namespace web_view | 254 } // namespace web_view |
255 | 255 |
256 #endif // COMPONENTS_WEB_VIEW_FRAME_H_ | 256 #endif // COMPONENTS_WEB_VIEW_FRAME_H_ |
OLD | NEW |