| 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 "components/view_manager/public/cpp/types.h" |
| 13 #include "components/view_manager/public/cpp/view_observer.h" | 14 #include "components/view_manager/public/cpp/view_observer.h" |
| 14 #include "components/web_view/public/interfaces/frame_tree.mojom.h" | 15 #include "components/web_view/public/interfaces/frame_tree.mojom.h" |
| 15 #include "third_party/mojo/src/mojo/public/cpp/bindings/binding.h" | 16 #include "third_party/mojo/src/mojo/public/cpp/bindings/binding.h" |
| 16 | 17 |
| 17 namespace web_view { | 18 namespace web_view { |
| 18 | 19 |
| 19 class FrameTree; | 20 class FrameTree; |
| 20 class FrameTreeClient; | 21 class FrameTreeClient; |
| 21 class FrameUserData; | 22 class FrameUserData; |
| 22 | 23 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 Frame(FrameTree* tree, | 55 Frame(FrameTree* tree, |
| 55 mojo::View* view, | 56 mojo::View* view, |
| 56 uint32_t frame_id, | 57 uint32_t frame_id, |
| 57 uint32_t app_id, | 58 uint32_t app_id, |
| 58 ViewOwnership view_ownership, | 59 ViewOwnership view_ownership, |
| 59 FrameTreeClient* frame_tree_client, | 60 FrameTreeClient* frame_tree_client, |
| 60 scoped_ptr<FrameUserData> user_data, | 61 scoped_ptr<FrameUserData> user_data, |
| 61 const ClientPropertyMap& client_properties); | 62 const ClientPropertyMap& client_properties); |
| 62 ~Frame() override; | 63 ~Frame() override; |
| 63 | 64 |
| 64 void Init(Frame* parent); | 65 void Init(Frame* parent, mojo::ViewTreeClientPtr view_tree_client); |
| 65 | 66 |
| 66 // Walks the View tree starting at |view| going up returning the first | 67 // Walks the View tree starting at |view| going up returning the first |
| 67 // Frame that is associated with |view|. For example, if |view| | 68 // Frame that is associated with |view|. For example, if |view| |
| 68 // has a Frame associated with it, then that is returned. Otherwise | 69 // has a Frame associated with it, then that is returned. Otherwise |
| 69 // this checks view->parent() and so on. | 70 // this checks view->parent() and so on. |
| 70 static Frame* FindFirstFrameAncestor(mojo::View* view); | 71 static Frame* FindFirstFrameAncestor(mojo::View* view); |
| 71 | 72 |
| 72 FrameTree* tree() { return tree_; } | 73 FrameTree* tree() { return tree_; } |
| 73 | 74 |
| 74 Frame* parent() { return parent_; } | 75 Frame* parent() { return parent_; } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 // |frame_tree_server_binding| contains the current FrameTreeServerBinding | 118 // |frame_tree_server_binding| contains the current FrameTreeServerBinding |
| 118 // (if any) and is destroyed after the connection responds to OnConnect(). | 119 // (if any) and is destroyed after the connection responds to OnConnect(). |
| 119 // | 120 // |
| 120 // If |client_type| is SAME_APP we can't destroy the existing client | 121 // If |client_type| is SAME_APP we can't destroy the existing client |
| 121 // (and related data) until we get back the ack from OnConnect(). This way | 122 // (and related data) until we get back the ack from OnConnect(). This way |
| 122 // we know the client has completed the switch. If we did not do this it | 123 // we know the client has completed the switch. If we did not do this it |
| 123 // would be possible for the app to see it's existing FrameTreeServer | 124 // would be possible for the app to see it's existing FrameTreeServer |
| 124 // connection lost (and assume the frame is being torn down) before the | 125 // connection lost (and assume the frame is being torn down) before the |
| 125 // OnConnect(). | 126 // OnConnect(). |
| 126 void InitClient(ClientType client_type, | 127 void InitClient(ClientType client_type, |
| 127 scoped_ptr<FrameTreeServerBinding> frame_tree_server_binding); | 128 scoped_ptr<FrameTreeServerBinding> frame_tree_server_binding, |
| 129 mojo::ViewTreeClientPtr view_tree_client); |
| 128 | 130 |
| 129 // Callback from OnConnect(). This does nothing (other than destroying | 131 // Callback from OnConnect(). This does nothing (other than destroying |
| 130 // |frame_tree_server_binding|). See InitClient() for details as to why | 132 // |frame_tree_server_binding|). See InitClient() for details as to why |
| 131 // destruction of |frame_tree_server_binding| happens after OnConnect(). | 133 // destruction of |frame_tree_server_binding| happens after OnConnect(). |
| 132 static void OnConnectAck( | 134 static void OnConnectAck( |
| 133 scoped_ptr<FrameTreeServerBinding> frame_tree_server_binding); | 135 scoped_ptr<FrameTreeServerBinding> frame_tree_server_binding); |
| 134 | 136 |
| 137 // Callback from OnEmbed(). |
| 138 void OnEmbedAck(bool success, mojo::ConnectionSpecificId connection_id); |
| 139 |
| 135 // Completes a navigation request; swapping the existing FrameTreeClient to | 140 // Completes a navigation request; swapping the existing FrameTreeClient to |
| 136 // the supplied arguments. | 141 // the supplied arguments. |
| 137 void ChangeClient(FrameTreeClient* frame_tree_client, | 142 void ChangeClient(FrameTreeClient* frame_tree_client, |
| 138 scoped_ptr<FrameUserData> user_data, | 143 scoped_ptr<FrameUserData> user_data, |
| 139 mojo::ViewTreeClientPtr view_tree_client, | 144 mojo::ViewTreeClientPtr view_tree_client, |
| 140 uint32 app_id); | 145 uint32 app_id); |
| 141 | 146 |
| 142 void SetView(mojo::View* view); | 147 void SetView(mojo::View* view); |
| 143 | 148 |
| 144 // Returns the first ancestor (starting at |this|) that has a | 149 // Returns the first ancestor (starting at |this|) that has a |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 uint32_t frame_id, | 210 uint32_t frame_id, |
| 206 mojo::Map<mojo::String, mojo::Array<uint8_t>> client_properties) override; | 211 mojo::Map<mojo::String, mojo::Array<uint8_t>> client_properties) override; |
| 207 void RequestNavigate(NavigationTargetType target_type, | 212 void RequestNavigate(NavigationTargetType target_type, |
| 208 uint32_t target_frame_id, | 213 uint32_t target_frame_id, |
| 209 mojo::URLRequestPtr request) override; | 214 mojo::URLRequestPtr request) override; |
| 210 void DidNavigateLocally(uint32_t frame_id, const mojo::String& url) override; | 215 void DidNavigateLocally(uint32_t frame_id, const mojo::String& url) override; |
| 211 | 216 |
| 212 FrameTree* const tree_; | 217 FrameTree* const tree_; |
| 213 // WARNING: this may be null. See class description for details. | 218 // WARNING: this may be null. See class description for details. |
| 214 mojo::View* view_; | 219 mojo::View* view_; |
| 220 // The connection id returned from ViewManager::Embed(). Frames created by |
| 221 // way of OnCreatedFrame() inherit the id from the parent. |
| 222 mojo::ConnectionSpecificId embedded_connection_id_; |
| 215 // ID for the frame, which is the same as that of the view. | 223 // ID for the frame, which is the same as that of the view. |
| 216 const uint32_t id_; | 224 const uint32_t id_; |
| 217 // ID of the app providing the FrameTreeClient and ViewTreeClient. | 225 // ID of the app providing the FrameTreeClient and ViewTreeClient. |
| 218 uint32_t app_id_; | 226 uint32_t app_id_; |
| 219 Frame* parent_; | 227 Frame* parent_; |
| 220 ViewOwnership view_ownership_; | 228 ViewOwnership view_ownership_; |
| 221 std::vector<Frame*> children_; | 229 std::vector<Frame*> children_; |
| 222 scoped_ptr<FrameUserData> user_data_; | 230 scoped_ptr<FrameUserData> user_data_; |
| 223 | 231 |
| 224 // WARNING: this may be null. See class description for details. | 232 // WARNING: this may be null. See class description for details. |
| 225 FrameTreeClient* frame_tree_client_; | 233 FrameTreeClient* frame_tree_client_; |
| 226 | 234 |
| 227 bool loading_; | 235 bool loading_; |
| 228 double progress_; | 236 double progress_; |
| 229 | 237 |
| 230 ClientPropertyMap client_properties_; | 238 ClientPropertyMap client_properties_; |
| 231 | 239 |
| 232 // StartNavigate() stores the request here if the view isn't available at | 240 // StartNavigate() stores the request here if the view isn't available at |
| 233 // the time of StartNavigate(). | 241 // the time of StartNavigate(). |
| 234 mojo::URLRequestPtr pending_navigate_; | 242 mojo::URLRequestPtr pending_navigate_; |
| 235 | 243 |
| 236 scoped_ptr<mojo::Binding<FrameTreeServer>> frame_tree_server_binding_; | 244 scoped_ptr<mojo::Binding<FrameTreeServer>> frame_tree_server_binding_; |
| 237 | 245 |
| 238 base::WeakPtrFactory<Frame> weak_factory_; | 246 base::WeakPtrFactory<Frame> embed_weak_ptr_factory_; |
| 239 | 247 |
| 240 base::WeakPtrFactory<Frame> navigate_weak_ptr_factory_; | 248 base::WeakPtrFactory<Frame> navigate_weak_ptr_factory_; |
| 241 | 249 |
| 242 DISALLOW_COPY_AND_ASSIGN(Frame); | 250 DISALLOW_COPY_AND_ASSIGN(Frame); |
| 243 }; | 251 }; |
| 244 | 252 |
| 245 } // namespace web_view | 253 } // namespace web_view |
| 246 | 254 |
| 247 #endif // COMPONENTS_WEB_VIEW_FRAME_H_ | 255 #endif // COMPONENTS_WEB_VIEW_FRAME_H_ |
| OLD | NEW |