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 "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "components/web_view/frame_tree_delegate.h" | 8 #include "components/web_view/frame_tree_delegate.h" |
9 #include "components/web_view/frame_user_data.h" | 9 #include "components/web_view/frame_user_data.h" |
10 #include "components/web_view/web_view_switches.h" | 10 #include "components/web_view/web_view_switches.h" |
11 | 11 |
12 namespace web_view { | 12 namespace web_view { |
13 | 13 |
14 FrameTree::FrameTree(uint32_t root_app_id, | 14 FrameTree::FrameTree(uint32_t root_app_id, |
15 mojo::View* view, | 15 mojo::View* view, |
| 16 mojo::ViewTreeClientPtr view_tree_client, |
16 FrameTreeDelegate* delegate, | 17 FrameTreeDelegate* delegate, |
17 FrameTreeClient* root_client, | 18 FrameTreeClient* root_client, |
18 scoped_ptr<FrameUserData> user_data, | 19 scoped_ptr<FrameUserData> user_data, |
19 const Frame::ClientPropertyMap& client_properties) | 20 const Frame::ClientPropertyMap& client_properties) |
20 : view_(view), | 21 : view_(view), |
21 delegate_(delegate), | 22 delegate_(delegate), |
22 root_(this, | 23 root_(this, |
23 view, | 24 view, |
24 view->id(), | 25 view->id(), |
25 root_app_id, | 26 root_app_id, |
26 ViewOwnership::DOESNT_OWN_VIEW, | 27 ViewOwnership::DOESNT_OWN_VIEW, |
27 root_client, | 28 root_client, |
28 user_data.Pass(), | 29 user_data.Pass(), |
29 client_properties), | 30 client_properties), |
30 progress_(0.f), | 31 progress_(0.f), |
31 change_id_(1u) { | 32 change_id_(1u) { |
32 root_.Init(nullptr); | 33 root_.Init(nullptr, view_tree_client.Pass()); |
33 } | 34 } |
34 | 35 |
35 FrameTree::~FrameTree() { | 36 FrameTree::~FrameTree() { |
36 } | 37 } |
37 | 38 |
38 // static | 39 // static |
39 bool FrameTree::AlwaysCreateNewFrameTree() { | 40 bool FrameTree::AlwaysCreateNewFrameTree() { |
40 return base::CommandLine::ForCurrentProcess()->HasSwitch( | 41 return base::CommandLine::ForCurrentProcess()->HasSwitch( |
41 web_view::switches::kOOPIFAlwaysCreateNewFrameTree); | 42 web_view::switches::kOOPIFAlwaysCreateNewFrameTree); |
42 } | 43 } |
43 | 44 |
44 Frame* FrameTree::CreateAndAddFrame(mojo::View* view, | 45 Frame* FrameTree::CreateAndAddFrame(mojo::View* view, |
45 Frame* parent, | 46 Frame* parent, |
46 uint32_t app_id, | 47 uint32_t app_id, |
47 FrameTreeClient* client, | 48 FrameTreeClient* client, |
48 scoped_ptr<FrameUserData> user_data) { | 49 scoped_ptr<FrameUserData> user_data) { |
49 return CreateAndAddFrameImpl(view, view->id(), app_id, parent, client, | 50 return CreateAndAddFrameImpl(view, view->id(), app_id, parent, client, |
50 user_data.Pass(), Frame::ClientPropertyMap()); | 51 user_data.Pass(), Frame::ClientPropertyMap()); |
51 } | 52 } |
52 | 53 |
53 void FrameTree::CreateSharedFrame( | 54 Frame* FrameTree::CreateSharedFrame( |
54 Frame* parent, | 55 Frame* parent, |
55 uint32_t frame_id, | 56 uint32_t frame_id, |
56 uint32_t app_id, | 57 uint32_t app_id, |
57 const Frame::ClientPropertyMap& client_properties) { | 58 const Frame::ClientPropertyMap& client_properties) { |
58 mojo::View* frame_view = root_.view()->GetChildById(frame_id); | 59 mojo::View* frame_view = root_.view()->GetChildById(frame_id); |
59 // |frame_view| may be null if the View hasn't been created yet. If this is | 60 // |frame_view| may be null if the View hasn't been created yet. If this is |
60 // the case the View will be connected to the Frame in Frame::OnTreeChanged. | 61 // the case the View will be connected to the Frame in Frame::OnTreeChanged. |
61 CreateAndAddFrameImpl(frame_view, frame_id, app_id, parent, nullptr, nullptr, | 62 return CreateAndAddFrameImpl(frame_view, frame_id, app_id, parent, nullptr, |
62 client_properties); | 63 nullptr, client_properties); |
63 } | 64 } |
64 | 65 |
65 uint32_t FrameTree::AdvanceChangeID() { | 66 uint32_t FrameTree::AdvanceChangeID() { |
66 return ++change_id_; | 67 return ++change_id_; |
67 } | 68 } |
68 | 69 |
69 Frame* FrameTree::CreateAndAddFrameImpl( | 70 Frame* FrameTree::CreateAndAddFrameImpl( |
70 mojo::View* view, | 71 mojo::View* view, |
71 uint32_t frame_id, | 72 uint32_t frame_id, |
72 uint32_t app_id, | 73 uint32_t app_id, |
73 Frame* parent, | 74 Frame* parent, |
74 FrameTreeClient* client, | 75 FrameTreeClient* client, |
75 scoped_ptr<FrameUserData> user_data, | 76 scoped_ptr<FrameUserData> user_data, |
76 const Frame::ClientPropertyMap& client_properties) { | 77 const Frame::ClientPropertyMap& client_properties) { |
77 Frame* frame = | 78 Frame* frame = |
78 new Frame(this, view, frame_id, app_id, ViewOwnership::OWNS_VIEW, client, | 79 new Frame(this, view, frame_id, app_id, ViewOwnership::OWNS_VIEW, client, |
79 user_data.Pass(), client_properties); | 80 user_data.Pass(), client_properties); |
80 frame->Init(parent); | 81 frame->Init(parent, nullptr); |
81 return frame; | 82 return frame; |
82 } | 83 } |
83 | 84 |
84 void FrameTree::LoadingStateChanged() { | 85 void FrameTree::LoadingStateChanged() { |
85 bool loading = root_.IsLoading(); | 86 bool loading = root_.IsLoading(); |
86 if (delegate_) | 87 if (delegate_) |
87 delegate_->LoadingStateChanged(loading); | 88 delegate_->LoadingStateChanged(loading); |
88 } | 89 } |
89 | 90 |
90 void FrameTree::ProgressChanged() { | 91 void FrameTree::ProgressChanged() { |
(...skipping 11 matching lines...) Expand all Loading... |
102 delegate_->TitleChanged(title); | 103 delegate_->TitleChanged(title); |
103 } | 104 } |
104 | 105 |
105 void FrameTree::ClientPropertyChanged(const Frame* source, | 106 void FrameTree::ClientPropertyChanged(const Frame* source, |
106 const mojo::String& name, | 107 const mojo::String& name, |
107 const mojo::Array<uint8_t>& value) { | 108 const mojo::Array<uint8_t>& value) { |
108 root_.NotifyClientPropertyChanged(source, name, value); | 109 root_.NotifyClientPropertyChanged(source, name, value); |
109 } | 110 } |
110 | 111 |
111 } // namespace web_view | 112 } // namespace web_view |
OLD | NEW |