| 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 |
| 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/time/time.h" |
| 13 #include "components/mus/public/cpp/types.h" | 14 #include "components/mus/public/cpp/types.h" |
| 14 #include "components/mus/public/cpp/view_observer.h" | 15 #include "components/mus/public/cpp/view_observer.h" |
| 15 #include "components/web_view/public/interfaces/frame.mojom.h" | 16 #include "components/web_view/public/interfaces/frame.mojom.h" |
| 16 #include "third_party/mojo/src/mojo/public/cpp/bindings/binding.h" | 17 #include "third_party/mojo/src/mojo/public/cpp/bindings/binding.h" |
| 17 | 18 |
| 18 class GURL; | 19 class GURL; |
| 19 | 20 |
| 20 namespace web_view { | 21 namespace web_view { |
| 21 | 22 |
| 22 class FrameTest; | 23 class FrameTest; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 uint32_t frame_id, | 62 uint32_t frame_id, |
| 62 uint32_t app_id, | 63 uint32_t app_id, |
| 63 ViewOwnership view_ownership, | 64 ViewOwnership view_ownership, |
| 64 mojom::FrameClient* frame_client, | 65 mojom::FrameClient* frame_client, |
| 65 scoped_ptr<FrameUserData> user_data, | 66 scoped_ptr<FrameUserData> user_data, |
| 66 const ClientPropertyMap& client_properties); | 67 const ClientPropertyMap& client_properties); |
| 67 ~Frame() override; | 68 ~Frame() override; |
| 68 | 69 |
| 69 void Init(Frame* parent, | 70 void Init(Frame* parent, |
| 70 mojo::ViewTreeClientPtr view_tree_client, | 71 mojo::ViewTreeClientPtr view_tree_client, |
| 71 mojo::InterfaceRequest<mojom::Frame> frame_request); | 72 mojo::InterfaceRequest<mojom::Frame> frame_request, |
| 73 base::TimeTicks navigation_start_time); |
| 72 | 74 |
| 73 // Walks the View tree starting at |view| going up returning the first | 75 // Walks the View tree starting at |view| going up returning the first |
| 74 // Frame that is associated with |view|. For example, if |view| | 76 // Frame that is associated with |view|. For example, if |view| |
| 75 // has a Frame associated with it, then that is returned. Otherwise | 77 // has a Frame associated with it, then that is returned. Otherwise |
| 76 // this checks view->parent() and so on. | 78 // this checks view->parent() and so on. |
| 77 static Frame* FindFirstFrameAncestor(mus::View* view); | 79 static Frame* FindFirstFrameAncestor(mus::View* view); |
| 78 | 80 |
| 79 FrameTree* tree() { return tree_; } | 81 FrameTree* tree() { return tree_; } |
| 80 | 82 |
| 81 Frame* parent() { return parent_; } | 83 Frame* parent() { return parent_; } |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 // and is destroyed after the connection responds to OnConnect(). | 150 // and is destroyed after the connection responds to OnConnect(). |
| 149 // | 151 // |
| 150 // If |client_type| is SAME_APP we can't destroy the existing client | 152 // If |client_type| is SAME_APP we can't destroy the existing client |
| 151 // (and related data) until we get back the ack from OnConnect(). This way | 153 // (and related data) until we get back the ack from OnConnect(). This way |
| 152 // we know the client has completed the switch. If we did not do this it | 154 // we know the client has completed the switch. If we did not do this it |
| 153 // would be possible for the app to see it's existing Frame connection lost | 155 // would be possible for the app to see it's existing Frame connection lost |
| 154 // (and assume the frame is being torn down) before the OnConnect(). | 156 // (and assume the frame is being torn down) before the OnConnect(). |
| 155 void InitClient(ClientType client_type, | 157 void InitClient(ClientType client_type, |
| 156 scoped_ptr<FrameUserDataAndBinding> data_and_binding, | 158 scoped_ptr<FrameUserDataAndBinding> data_and_binding, |
| 157 mojo::ViewTreeClientPtr view_tree_client, | 159 mojo::ViewTreeClientPtr view_tree_client, |
| 158 mojo::InterfaceRequest<mojom::Frame> frame_request); | 160 mojo::InterfaceRequest<mojom::Frame> frame_request, |
| 161 base::TimeTicks navigation_start_time); |
| 159 | 162 |
| 160 // Callback from OnConnect(). This does nothing (other than destroying | 163 // Callback from OnConnect(). This does nothing (other than destroying |
| 161 // |data_and_binding|). See InitClient() for details as to why destruction of | 164 // |data_and_binding|). See InitClient() for details as to why destruction of |
| 162 // |data_and_binding| happens after OnConnect(). | 165 // |data_and_binding| happens after OnConnect(). |
| 163 static void OnConnectAck( | 166 static void OnConnectAck( |
| 164 scoped_ptr<FrameUserDataAndBinding> data_and_binding); | 167 scoped_ptr<FrameUserDataAndBinding> data_and_binding); |
| 165 | 168 |
| 166 // Callback from OnEmbed(). | 169 // Callback from OnEmbed(). |
| 167 void OnEmbedAck(bool success, mus::ConnectionSpecificId connection_id); | 170 void OnEmbedAck(bool success, mus::ConnectionSpecificId connection_id); |
| 168 | 171 |
| 169 // Callback from Frame::OnWillNavigate(). Completes navigation. | 172 // Callback from Frame::OnWillNavigate(). Completes navigation. |
| 170 void OnWillNavigateAck(mojom::FrameClient* frame_client, | 173 void OnWillNavigateAck(mojom::FrameClient* frame_client, |
| 171 scoped_ptr<FrameUserData> user_data, | 174 scoped_ptr<FrameUserData> user_data, |
| 172 mojo::ViewTreeClientPtr view_tree_client, | 175 mojo::ViewTreeClientPtr view_tree_client, |
| 173 uint32 app_id); | 176 uint32 app_id, |
| 177 base::TimeTicks navigation_start_time); |
| 174 | 178 |
| 175 // Completes a navigation request; swapping the existing FrameClient to the | 179 // Completes a navigation request; swapping the existing FrameClient to the |
| 176 // supplied arguments. | 180 // supplied arguments. |
| 177 void ChangeClient(mojom::FrameClient* frame_client, | 181 void ChangeClient(mojom::FrameClient* frame_client, |
| 178 scoped_ptr<FrameUserData> user_data, | 182 scoped_ptr<FrameUserData> user_data, |
| 179 mojo::ViewTreeClientPtr view_tree_client, | 183 mojo::ViewTreeClientPtr view_tree_client, |
| 180 uint32 app_id); | 184 uint32 app_id, |
| 185 base::TimeTicks navigation_start_time); |
| 181 | 186 |
| 182 void SetView(mus::View* view); | 187 void SetView(mus::View* view); |
| 183 | 188 |
| 184 // Adds this to |frames| and recurses through the children calling the | 189 // Adds this to |frames| and recurses through the children calling the |
| 185 // same function. | 190 // same function. |
| 186 void BuildFrameTree(std::vector<const Frame*>* frames) const; | 191 void BuildFrameTree(std::vector<const Frame*>* frames) const; |
| 187 | 192 |
| 188 void Add(Frame* node); | 193 void Add(Frame* node); |
| 189 void Remove(Frame* node); | 194 void Remove(Frame* node); |
| 190 | 195 |
| 191 // Starts a new navigation to |request|. The navigation proceeds as long | 196 // Starts a new navigation to |request|. The navigation proceeds as long |
| 192 // as there is a View and once OnWillNavigate() has returned. If there is | 197 // as there is a View and once OnWillNavigate() has returned. If there is |
| 193 // no View the navigation waits until the View is available. | 198 // no View the navigation waits until the View is available. |
| 194 void StartNavigate(mojo::URLRequestPtr request); | 199 void StartNavigate(mojo::URLRequestPtr request); |
| 195 void OnCanNavigateFrame(const GURL& url, | 200 void OnCanNavigateFrame(const GURL& url, |
| 201 base::TimeTicks navigation_start_time, |
| 196 uint32_t app_id, | 202 uint32_t app_id, |
| 197 mojom::FrameClient* frame_client, | 203 mojom::FrameClient* frame_client, |
| 198 scoped_ptr<FrameUserData> user_data, | 204 scoped_ptr<FrameUserData> user_data, |
| 199 mojo::ViewTreeClientPtr view_tree_client); | 205 mojo::ViewTreeClientPtr view_tree_client); |
| 200 | 206 |
| 201 // Notifies the client and all descendants as appropriate. | 207 // Notifies the client and all descendants as appropriate. |
| 202 void NotifyAdded(const Frame* source, | 208 void NotifyAdded(const Frame* source, |
| 203 const Frame* added_node, | 209 const Frame* added_node, |
| 204 uint32_t change_id); | 210 uint32_t change_id); |
| 205 void NotifyRemoved(const Frame* source, | 211 void NotifyRemoved(const Frame* source, |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 base::WeakPtrFactory<Frame> embed_weak_ptr_factory_; | 280 base::WeakPtrFactory<Frame> embed_weak_ptr_factory_; |
| 275 | 281 |
| 276 base::WeakPtrFactory<Frame> navigate_weak_ptr_factory_; | 282 base::WeakPtrFactory<Frame> navigate_weak_ptr_factory_; |
| 277 | 283 |
| 278 DISALLOW_COPY_AND_ASSIGN(Frame); | 284 DISALLOW_COPY_AND_ASSIGN(Frame); |
| 279 }; | 285 }; |
| 280 | 286 |
| 281 } // namespace web_view | 287 } // namespace web_view |
| 282 | 288 |
| 283 #endif // COMPONENTS_WEB_VIEW_FRAME_H_ | 289 #endif // COMPONENTS_WEB_VIEW_FRAME_H_ |
| OLD | NEW |