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 mus::ViewObserver, public FrameTreeServer { | 52 class Frame : public mojo::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 mus::View* view, | 57 mojo::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(mus::View* view); | 72 static Frame* FindFirstFrameAncestor(mojo::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 mus::View* view() { return view_; } | 79 mojo::View* view() { return view_; } |
80 const mus::View* view() const { return view_; } | 80 const mojo::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, mus::ConnectionSpecificId connection_id); | 140 void OnEmbedAck(bool success, mojo::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(mus::View* view); | 149 void SetView(mojo::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 25 matching lines...) Expand all Loading... |
185 void NotifyAdded(const Frame* source, | 185 void NotifyAdded(const Frame* source, |
186 const Frame* added_node, | 186 const Frame* added_node, |
187 uint32_t change_id); | 187 uint32_t change_id); |
188 void NotifyRemoved(const Frame* source, | 188 void NotifyRemoved(const Frame* source, |
189 const Frame* removed_node, | 189 const Frame* removed_node, |
190 uint32_t change_id); | 190 uint32_t change_id); |
191 void NotifyClientPropertyChanged(const Frame* source, | 191 void NotifyClientPropertyChanged(const Frame* source, |
192 const mojo::String& name, | 192 const mojo::String& name, |
193 const mojo::Array<uint8_t>& value); | 193 const mojo::Array<uint8_t>& value); |
194 | 194 |
195 // mus::ViewObserver: | 195 // mojo::ViewObserver: |
196 void OnTreeChanged(const TreeChangeParams& params) override; | 196 void OnTreeChanged(const TreeChangeParams& params) override; |
197 void OnViewDestroying(mus::View* view) override; | 197 void OnViewDestroying(mojo::View* view) override; |
198 void OnViewEmbeddedAppDisconnected(mus::View* view) override; | 198 void OnViewEmbeddedAppDisconnected(mojo::View* view) override; |
199 | 199 |
200 // FrameTreeServer: | 200 // FrameTreeServer: |
201 void PostMessageEventToFrame(uint32_t source_frame_id, | 201 void PostMessageEventToFrame(uint32_t source_frame_id, |
202 uint32_t target_frame_id, | 202 uint32_t target_frame_id, |
203 HTMLMessageEventPtr event) override; | 203 HTMLMessageEventPtr event) override; |
204 void LoadingStarted(uint32_t frame_id) override; | 204 void LoadingStarted(uint32_t frame_id) override; |
205 void LoadingStopped(uint32_t frame_id) override; | 205 void LoadingStopped(uint32_t frame_id) override; |
206 void ProgressChanged(uint32_t frame_id, double progress) override; | 206 void ProgressChanged(uint32_t frame_id, double progress) override; |
207 void TitleChanged(uint32_t frame_id, const mojo::String& title) override; | 207 void TitleChanged(uint32_t frame_id, const mojo::String& title) override; |
208 void SetClientProperty(uint32_t frame_id, | 208 void SetClientProperty(uint32_t frame_id, |
209 const mojo::String& name, | 209 const mojo::String& name, |
210 mojo::Array<uint8_t> value) override; | 210 mojo::Array<uint8_t> value) override; |
211 void OnCreatedFrame( | 211 void OnCreatedFrame( |
212 uint32_t parent_id, | 212 uint32_t parent_id, |
213 uint32_t frame_id, | 213 uint32_t frame_id, |
214 mojo::Map<mojo::String, mojo::Array<uint8_t>> client_properties) override; | 214 mojo::Map<mojo::String, mojo::Array<uint8_t>> client_properties) override; |
215 void RequestNavigate(NavigationTargetType target_type, | 215 void RequestNavigate(NavigationTargetType target_type, |
216 uint32_t target_frame_id, | 216 uint32_t target_frame_id, |
217 mojo::URLRequestPtr request) override; | 217 mojo::URLRequestPtr request) override; |
218 void DidNavigateLocally(uint32_t frame_id, const mojo::String& url) override; | 218 void DidNavigateLocally(uint32_t frame_id, const mojo::String& url) override; |
219 | 219 |
220 FrameTree* const tree_; | 220 FrameTree* const tree_; |
221 // WARNING: this may be null. See class description for details. | 221 // WARNING: this may be null. See class description for details. |
222 mus::View* view_; | 222 mojo::View* view_; |
223 // The connection id returned from ViewManager::Embed(). Frames created by | 223 // The connection id returned from ViewManager::Embed(). Frames created by |
224 // way of OnCreatedFrame() inherit the id from the parent. | 224 // way of OnCreatedFrame() inherit the id from the parent. |
225 mus::ConnectionSpecificId embedded_connection_id_; | 225 mojo::ConnectionSpecificId embedded_connection_id_; |
226 // ID for the frame, which is the same as that of the view. | 226 // ID for the frame, which is the same as that of the view. |
227 const uint32_t id_; | 227 const uint32_t id_; |
228 // ID of the app providing the FrameTreeClient and ViewTreeClient. | 228 // ID of the app providing the FrameTreeClient and ViewTreeClient. |
229 uint32_t app_id_; | 229 uint32_t app_id_; |
230 Frame* parent_; | 230 Frame* parent_; |
231 ViewOwnership view_ownership_; | 231 ViewOwnership view_ownership_; |
232 std::vector<Frame*> children_; | 232 std::vector<Frame*> children_; |
233 scoped_ptr<FrameUserData> user_data_; | 233 scoped_ptr<FrameUserData> user_data_; |
234 | 234 |
235 // WARNING: this may be null. See class description for details. | 235 // WARNING: this may be null. See class description for details. |
(...skipping 13 matching lines...) Expand all Loading... |
249 base::WeakPtrFactory<Frame> embed_weak_ptr_factory_; | 249 base::WeakPtrFactory<Frame> embed_weak_ptr_factory_; |
250 | 250 |
251 base::WeakPtrFactory<Frame> navigate_weak_ptr_factory_; | 251 base::WeakPtrFactory<Frame> navigate_weak_ptr_factory_; |
252 | 252 |
253 DISALLOW_COPY_AND_ASSIGN(Frame); | 253 DISALLOW_COPY_AND_ASSIGN(Frame); |
254 }; | 254 }; |
255 | 255 |
256 } // namespace web_view | 256 } // namespace web_view |
257 | 257 |
258 #endif // COMPONENTS_WEB_VIEW_FRAME_H_ | 258 #endif // COMPONENTS_WEB_VIEW_FRAME_H_ |
OLD | NEW |