| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "mojo/services/view_manager/view_manager_init_connection.h" | 5 #include "mojo/services/view_manager/view_manager_init_connection.h" |
| 6 | 6 |
| 7 #include "mojo/public/interfaces/service_provider/service_provider.mojom.h" | 7 #include "mojo/public/interfaces/service_provider/service_provider.mojom.h" |
| 8 #include "mojo/services/view_manager/ids.h" | 8 #include "mojo/services/view_manager/ids.h" |
| 9 #include "mojo/services/view_manager/view_manager_connection.h" | 9 #include "mojo/services/view_manager/view_manager_connection.h" |
| 10 | 10 |
| 11 namespace mojo { | 11 namespace mojo { |
| 12 namespace view_manager { | 12 namespace view_manager { |
| 13 namespace service { | 13 namespace service { |
| 14 | 14 |
| 15 ViewManagerInitConnection::ConnectParams::ConnectParams() {} | 15 ViewManagerInitConnection::ConnectParams::ConnectParams() {} |
| 16 | 16 |
| 17 ViewManagerInitConnection::ConnectParams::~ConnectParams() {} | 17 ViewManagerInitConnection::ConnectParams::~ConnectParams() {} |
| 18 | 18 |
| 19 ViewManagerInitConnection::ViewManagerInitConnection( | 19 ViewManagerInitConnection::ViewManagerInitConnection( |
| 20 ServiceProvider* service_provider) | 20 ServiceProvider* service_provider) |
| 21 : service_provider_(service_provider), | 21 : service_provider_(service_provider), |
| 22 root_node_manager_(service_provider, this), | 22 root_node_manager_(service_provider, this), |
| 23 is_tree_host_ready_(false) { | 23 is_tree_host_ready_(false) { |
| 24 } | 24 } |
| 25 | 25 |
| 26 ViewManagerInitConnection::~ViewManagerInitConnection() { | 26 ViewManagerInitConnection::~ViewManagerInitConnection() { |
| 27 } | 27 } |
| 28 | 28 |
| 29 void ViewManagerInitConnection::MaybeConnect( | 29 void ViewManagerInitConnection::MaybeEmbedRoot( |
| 30 const std::string& url, | 30 const std::string& url, |
| 31 const Callback<void(bool)>& callback) { | 31 const Callback<void(bool)>& callback) { |
| 32 if (!is_tree_host_ready_) | 32 if (!is_tree_host_ready_) |
| 33 return; | 33 return; |
| 34 | 34 |
| 35 root_node_manager_.InitialConnect(url); | 35 root_node_manager_.EmbedRoot(url); |
| 36 callback.Run(true); | 36 callback.Run(true); |
| 37 } | 37 } |
| 38 | 38 |
| 39 void ViewManagerInitConnection::Connect(const String& url, | 39 void ViewManagerInitConnection::EmbedRoot( |
| 40 const Callback<void(bool)>& callback) { | 40 const String& url, |
| 41 const Callback<void(bool)>& callback) { |
| 41 if (connect_params_.get()) { | 42 if (connect_params_.get()) { |
| 42 DVLOG(1) << "Ignoring second connect"; | 43 DVLOG(1) << "Ignoring second connect"; |
| 43 callback.Run(false); | 44 callback.Run(false); |
| 44 return; | 45 return; |
| 45 } | 46 } |
| 46 connect_params_.reset(new ConnectParams); | 47 connect_params_.reset(new ConnectParams); |
| 47 connect_params_->url = url.To<std::string>(); | 48 connect_params_->url = url.To<std::string>(); |
| 48 connect_params_->callback = callback; | 49 connect_params_->callback = callback; |
| 49 MaybeConnect(url.To<std::string>(), callback); | 50 MaybeEmbedRoot(url.To<std::string>(), callback); |
| 50 } | 51 } |
| 51 | 52 |
| 52 void ViewManagerInitConnection::OnRootViewManagerWindowTreeHostCreated() { | 53 void ViewManagerInitConnection::OnRootViewManagerWindowTreeHostCreated() { |
| 53 DCHECK(!is_tree_host_ready_); | 54 DCHECK(!is_tree_host_ready_); |
| 54 is_tree_host_ready_ = true; | 55 is_tree_host_ready_ = true; |
| 55 if (connect_params_.get()) | 56 if (connect_params_.get()) |
| 56 MaybeConnect(connect_params_->url, connect_params_->callback); | 57 MaybeEmbedRoot(connect_params_->url, connect_params_->callback); |
| 57 } | 58 } |
| 58 | 59 |
| 59 } // namespace service | 60 } // namespace service |
| 60 } // namespace view_manager | 61 } // namespace view_manager |
| 61 } // namespace mojo | 62 } // namespace mojo |
| OLD | NEW |