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