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 #include "components/web_view/frame_tree.h" | 5 #include "components/web_view/frame_tree.h" |
6 | 6 |
7 #include "components/web_view/frame_tree_delegate.h" | 7 #include "components/web_view/frame_tree_delegate.h" |
8 #include "components/web_view/frame_user_data.h" | 8 #include "components/web_view/frame_user_data.h" |
9 | 9 |
10 namespace web_view { | 10 namespace web_view { |
11 | 11 |
12 FrameTree::FrameTree(uint32_t root_app_id, | 12 FrameTree::FrameTree(uint32_t root_app_id, |
13 mus::Window* view, | 13 mus::Window* window, |
14 mus::mojom::WindowTreeClientPtr view_tree_client, | 14 mus::mojom::WindowTreeClientPtr window_tree_client, |
15 FrameTreeDelegate* delegate, | 15 FrameTreeDelegate* delegate, |
16 mojom::FrameClient* root_client, | 16 mojom::FrameClient* root_client, |
17 scoped_ptr<FrameUserData> user_data, | 17 scoped_ptr<FrameUserData> user_data, |
18 const Frame::ClientPropertyMap& client_properties, | 18 const Frame::ClientPropertyMap& client_properties, |
19 base::TimeTicks navigation_start_time) | 19 base::TimeTicks navigation_start_time) |
20 : view_(view), | 20 : window_(window), |
21 delegate_(delegate), | 21 delegate_(delegate), |
22 root_(new Frame(this, | 22 root_(new Frame(this, |
23 view, | 23 window, |
24 view->id(), | 24 window->id(), |
25 root_app_id, | 25 root_app_id, |
26 ViewOwnership::DOESNT_OWN_VIEW, | 26 WindowOwnership::DOESNT_OWN_WINDOW, |
27 root_client, | 27 root_client, |
28 user_data.Pass(), | 28 user_data.Pass(), |
29 client_properties)), | 29 client_properties)), |
30 progress_(0.f), | 30 progress_(0.f), |
31 change_id_(1u) { | 31 change_id_(1u) { |
32 root_->Init(nullptr, view_tree_client.Pass(), nullptr, navigation_start_time); | 32 root_->Init(nullptr, window_tree_client.Pass(), nullptr, |
| 33 navigation_start_time); |
33 } | 34 } |
34 | 35 |
35 FrameTree::~FrameTree() { | 36 FrameTree::~FrameTree() { |
36 // Destroy the root explicitly in case it calls back to us for state (such | 37 // Destroy the root explicitly in case it calls back to us for state (such |
37 // as to see if it is the root). | 38 // as to see if it is the root). |
38 delete root_; | 39 delete root_; |
39 root_ = nullptr; | 40 root_ = nullptr; |
40 } | 41 } |
41 | 42 |
42 Frame* FrameTree::CreateChildFrame( | 43 Frame* FrameTree::CreateChildFrame( |
43 Frame* parent, | 44 Frame* parent, |
44 mojo::InterfaceRequest<mojom::Frame> frame_request, | 45 mojo::InterfaceRequest<mojom::Frame> frame_request, |
45 mojom::FrameClientPtr client, | 46 mojom::FrameClientPtr client, |
46 uint32_t frame_id, | 47 uint32_t frame_id, |
47 uint32_t app_id, | 48 uint32_t app_id, |
48 const Frame::ClientPropertyMap& client_properties) { | 49 const Frame::ClientPropertyMap& client_properties) { |
49 mojom::FrameClient* raw_client = client.get(); | 50 mojom::FrameClient* raw_client = client.get(); |
50 scoped_ptr<FrameUserData> user_data = | 51 scoped_ptr<FrameUserData> user_data = |
51 delegate_->CreateUserDataForNewFrame(client.Pass()); | 52 delegate_->CreateUserDataForNewFrame(client.Pass()); |
52 mus::Window* frame_view = root_->view()->GetChildById(frame_id); | 53 mus::Window* frame_window = root_->window()->GetChildById(frame_id); |
53 // |frame_view| may be null if the View hasn't been created yet. If this is | 54 // |frame_window| may be null if the Window hasn't been created yet. If this |
54 // the case the View will be connected to the Frame in Frame::OnTreeChanged. | 55 // is the case the Window will be connected to the Frame in |
55 Frame* frame = | 56 // Frame::OnTreeChanged. |
56 new Frame(this, frame_view, frame_id, app_id, ViewOwnership::OWNS_VIEW, | 57 Frame* frame = new Frame(this, frame_window, frame_id, app_id, |
57 raw_client, user_data.Pass(), client_properties); | 58 WindowOwnership::OWNS_WINDOW, raw_client, |
| 59 user_data.Pass(), client_properties); |
58 frame->Init(parent, nullptr, frame_request.Pass(), base::TimeTicks()); | 60 frame->Init(parent, nullptr, frame_request.Pass(), base::TimeTicks()); |
59 return frame; | 61 return frame; |
60 } | 62 } |
61 | 63 |
62 uint32_t FrameTree::AdvanceChangeID() { | 64 uint32_t FrameTree::AdvanceChangeID() { |
63 return ++change_id_; | 65 return ++change_id_; |
64 } | 66 } |
65 | 67 |
66 void FrameTree::LoadingStateChanged() { | 68 void FrameTree::LoadingStateChanged() { |
67 const bool loading = root_->IsLoading(); | 69 const bool loading = root_->IsLoading(); |
(...skipping 19 matching lines...) Expand all Loading... |
87 delegate_->DidNavigateLocally(source, url); | 89 delegate_->DidNavigateLocally(source, url); |
88 } | 90 } |
89 | 91 |
90 void FrameTree::ClientPropertyChanged(const Frame* source, | 92 void FrameTree::ClientPropertyChanged(const Frame* source, |
91 const mojo::String& name, | 93 const mojo::String& name, |
92 const mojo::Array<uint8_t>& value) { | 94 const mojo::Array<uint8_t>& value) { |
93 root_->NotifyClientPropertyChanged(source, name, value); | 95 root_->NotifyClientPropertyChanged(source, name, value); |
94 } | 96 } |
95 | 97 |
96 } // namespace web_view | 98 } // namespace web_view |
OLD | NEW |