| 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_TREE_H_ | 5 #ifndef COMPONENTS_WEB_VIEW_FRAME_TREE_H_ |
| 6 #define COMPONENTS_WEB_VIEW_FRAME_TREE_H_ | 6 #define COMPONENTS_WEB_VIEW_FRAME_TREE_H_ |
| 7 | 7 |
| 8 #include "base/time/time.h" | 8 #include "base/time/time.h" |
| 9 #include "components/mus/public/interfaces/window_tree.mojom.h" | 9 #include "components/mus/public/interfaces/window_tree.mojom.h" |
| 10 #include "components/web_view/frame.h" | 10 #include "components/web_view/frame.h" |
| 11 #include "third_party/mojo/src/mojo/public/cpp/bindings/array.h" | 11 #include "third_party/mojo/src/mojo/public/cpp/bindings/array.h" |
| 12 #include "url/gurl.h" | 12 #include "url/gurl.h" |
| 13 | 13 |
| 14 namespace mojo { | 14 namespace mojo { |
| 15 class String; | 15 class String; |
| 16 } | 16 } |
| 17 | 17 |
| 18 namespace web_view { | 18 namespace web_view { |
| 19 | 19 |
| 20 class FrameTreeDelegate; | 20 class FrameTreeDelegate; |
| 21 class FrameUserData; | 21 class FrameUserData; |
| 22 | 22 |
| 23 namespace mojom { | 23 namespace mojom { |
| 24 class FrameClient; | 24 class FrameClient; |
| 25 } | 25 } |
| 26 | 26 |
| 27 // FrameTree manages the set of Frames that comprise a single url. FrameTree | 27 // FrameTree manages the set of Frames that comprise a single url. FrameTree |
| 28 // owns the root Frame and each Frame owns its children. Frames are | 28 // owns the root Frame and each Frame owns its children. Frames are |
| 29 // automatically deleted and removed from the tree if the corresponding view is | 29 // automatically deleted and removed from the tree if the corresponding window |
| 30 // deleted. This happens if the creator of the view deletes it (say an iframe is | 30 // is |
| 31 // deleted. This happens if the creator of the window deletes it (say an iframe |
| 32 // is |
| 31 // destroyed). | 33 // destroyed). |
| 32 class FrameTree { | 34 class FrameTree { |
| 33 public: | 35 public: |
| 34 // |view| is the view to do the initial embedding in. It is assumed |view| | 36 // |window| is the window to do the initial embedding in. It is assumed |
| 37 // |window| |
| 35 // outlives FrameTree. | 38 // outlives FrameTree. |
| 36 // |client_properties| is the client properties for the root frame. | 39 // |client_properties| is the client properties for the root frame. |
| 37 // |root_app_id| is a unique identifier of the app providing |root_client|. | 40 // |root_app_id| is a unique identifier of the app providing |root_client|. |
| 38 // See Frame for details on app id's. | 41 // See Frame for details on app id's. |
| 39 FrameTree(uint32_t root_app_id, | 42 FrameTree(uint32_t root_app_id, |
| 40 mus::Window* view, | 43 mus::Window* window, |
| 41 mus::mojom::WindowTreeClientPtr view_tree_client, | 44 mus::mojom::WindowTreeClientPtr window_tree_client, |
| 42 FrameTreeDelegate* delegate, | 45 FrameTreeDelegate* delegate, |
| 43 mojom::FrameClient* root_client, | 46 mojom::FrameClient* root_client, |
| 44 scoped_ptr<FrameUserData> user_data, | 47 scoped_ptr<FrameUserData> user_data, |
| 45 const Frame::ClientPropertyMap& client_properties, | 48 const Frame::ClientPropertyMap& client_properties, |
| 46 base::TimeTicks navigation_start_time); | 49 base::TimeTicks navigation_start_time); |
| 47 ~FrameTree(); | 50 ~FrameTree(); |
| 48 | 51 |
| 49 const Frame* root() const { return root_; } | 52 const Frame* root() const { return root_; } |
| 50 Frame* root() { return root_; } | 53 Frame* root() { return root_; } |
| 51 uint32_t change_id() const { return change_id_; } | 54 uint32_t change_id() const { return change_id_; } |
| 52 | 55 |
| 53 private: | 56 private: |
| 54 friend class Frame; | 57 friend class Frame; |
| 55 | 58 |
| 56 // Creates a new Frame parented to |parent|. The Frame is considered shared in | 59 // Creates a new Frame parented to |parent|. The Frame is considered shared in |
| 57 // that it is sharing the FrameClient/Frame of |parent|. There may or may not | 60 // that it is sharing the FrameClient/Frame of |parent|. There may or may not |
| 58 // be a View identified by |frame_id| yet. See Frame for details. | 61 // be a Window identified by |frame_id| yet. See Frame for details. |
| 59 Frame* CreateChildFrame(Frame* parent, | 62 Frame* CreateChildFrame(Frame* parent, |
| 60 mojo::InterfaceRequest<mojom::Frame> frame_request, | 63 mojo::InterfaceRequest<mojom::Frame> frame_request, |
| 61 mojom::FrameClientPtr client, | 64 mojom::FrameClientPtr client, |
| 62 uint32_t frame_id, | 65 uint32_t frame_id, |
| 63 uint32_t app_id, | 66 uint32_t app_id, |
| 64 const Frame::ClientPropertyMap& client_properties); | 67 const Frame::ClientPropertyMap& client_properties); |
| 65 | 68 |
| 66 // Increments the change id, returning the new value. | 69 // Increments the change id, returning the new value. |
| 67 uint32_t AdvanceChangeID(); | 70 uint32_t AdvanceChangeID(); |
| 68 | 71 |
| 69 void LoadingStateChanged(); | 72 void LoadingStateChanged(); |
| 70 void TitleChanged(const mojo::String& title); | 73 void TitleChanged(const mojo::String& title); |
| 71 void DidCommitProvisionalLoad(Frame* source); | 74 void DidCommitProvisionalLoad(Frame* source); |
| 72 void DidNavigateLocally(Frame* source, const GURL& url); | 75 void DidNavigateLocally(Frame* source, const GURL& url); |
| 73 void ClientPropertyChanged(const Frame* source, | 76 void ClientPropertyChanged(const Frame* source, |
| 74 const mojo::String& name, | 77 const mojo::String& name, |
| 75 const mojo::Array<uint8_t>& value); | 78 const mojo::Array<uint8_t>& value); |
| 76 | 79 |
| 77 mus::Window* view_; | 80 mus::Window* window_; |
| 78 | 81 |
| 79 FrameTreeDelegate* delegate_; | 82 FrameTreeDelegate* delegate_; |
| 80 | 83 |
| 81 // |root_| is owned by this, but a raw pointer as during destruction we still | 84 // |root_| is owned by this, but a raw pointer as during destruction we still |
| 82 // want access to it. | 85 // want access to it. |
| 83 Frame* root_; | 86 Frame* root_; |
| 84 | 87 |
| 85 double progress_; | 88 double progress_; |
| 86 | 89 |
| 87 uint32_t change_id_; | 90 uint32_t change_id_; |
| 88 | 91 |
| 89 DISALLOW_COPY_AND_ASSIGN(FrameTree); | 92 DISALLOW_COPY_AND_ASSIGN(FrameTree); |
| 90 }; | 93 }; |
| 91 | 94 |
| 92 } // namespace web_view | 95 } // namespace web_view |
| 93 | 96 |
| 94 #endif // COMPONENTS_WEB_VIEW_FRAME_TREE_H_ | 97 #endif // COMPONENTS_WEB_VIEW_FRAME_TREE_H_ |
| OLD | NEW |