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