| 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 "services/view_manager/connection_manager.h" | 5 #include "services/view_manager/connection_manager.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
| 9 #include "mojo/converters/geometry/geometry_type_converters.h" | 9 #include "mojo/converters/geometry/geometry_type_converters.h" |
| 10 #include "mojo/converters/input_events/input_events_type_converters.h" | 10 #include "mojo/converters/input_events/input_events_type_converters.h" |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 for (auto& pair : connection_map_) { | 157 for (auto& pair : connection_map_) { |
| 158 pair.second->service()->OnWillDestroyViewManagerServiceImpl( | 158 pair.second->service()->OnWillDestroyViewManagerServiceImpl( |
| 159 connection->service()); | 159 connection->service()); |
| 160 } | 160 } |
| 161 } | 161 } |
| 162 | 162 |
| 163 void ConnectionManager::EmbedAtView( | 163 void ConnectionManager::EmbedAtView( |
| 164 ConnectionSpecificId creator_id, | 164 ConnectionSpecificId creator_id, |
| 165 const std::string& url, | 165 const std::string& url, |
| 166 const ViewId& view_id, | 166 const ViewId& view_id, |
| 167 mojo::InterfaceRequest<mojo::ServiceProvider> service_provider) { | 167 mojo::InterfaceRequest<mojo::ServiceProvider> services, |
| 168 mojo::ServiceProviderPtr exposed_services) { |
| 168 std::string creator_url; | 169 std::string creator_url; |
| 169 ConnectionMap::const_iterator it = connection_map_.find(creator_id); | 170 ConnectionMap::const_iterator it = connection_map_.find(creator_id); |
| 170 if (it != connection_map_.end()) | 171 if (it != connection_map_.end()) |
| 171 creator_url = it->second->service()->url(); | 172 creator_url = it->second->service()->url(); |
| 172 | 173 |
| 173 ClientConnection* client_connection = | 174 ClientConnection* client_connection = |
| 174 delegate_->CreateClientConnectionForEmbedAtView( | 175 delegate_->CreateClientConnectionForEmbedAtView( |
| 175 this, creator_id, creator_url, url, view_id); | 176 this, creator_id, creator_url, url, view_id); |
| 176 AddConnection(client_connection); | 177 AddConnection(client_connection); |
| 177 client_connection->service()->Init(client_connection->client(), | 178 client_connection->service()->Init(client_connection->client(), |
| 178 service_provider.Pass()); | 179 services.Pass(), exposed_services.Pass()); |
| 179 OnConnectionMessagedClient(client_connection->service()->id()); | 180 OnConnectionMessagedClient(client_connection->service()->id()); |
| 180 } | 181 } |
| 181 | 182 |
| 182 ViewManagerServiceImpl* ConnectionManager::GetConnection( | 183 ViewManagerServiceImpl* ConnectionManager::GetConnection( |
| 183 ConnectionSpecificId connection_id) { | 184 ConnectionSpecificId connection_id) { |
| 184 ConnectionMap::iterator i = connection_map_.find(connection_id); | 185 ConnectionMap::iterator i = connection_map_.find(connection_id); |
| 185 return i == connection_map_.end() ? nullptr : i->second->service(); | 186 return i == connection_map_.end() ? nullptr : i->second->service(); |
| 186 } | 187 } |
| 187 | 188 |
| 188 ServerView* ConnectionManager::GetView(const ViewId& id) { | 189 ServerView* ConnectionManager::GetView(const ViewId& id) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 209 return pair.second->service(); | 210 return pair.second->service(); |
| 210 } | 211 } |
| 211 return nullptr; | 212 return nullptr; |
| 212 } | 213 } |
| 213 | 214 |
| 214 void ConnectionManager::SetWindowManagerClientConnection( | 215 void ConnectionManager::SetWindowManagerClientConnection( |
| 215 scoped_ptr<ClientConnection> connection) { | 216 scoped_ptr<ClientConnection> connection) { |
| 216 CHECK(!window_manager_client_connection_); | 217 CHECK(!window_manager_client_connection_); |
| 217 window_manager_client_connection_ = connection.release(); | 218 window_manager_client_connection_ = connection.release(); |
| 218 AddConnection(window_manager_client_connection_); | 219 AddConnection(window_manager_client_connection_); |
| 219 mojo::ServiceProviderPtr sp; | |
| 220 window_manager_client_connection_->service()->Init( | 220 window_manager_client_connection_->service()->Init( |
| 221 window_manager_client_connection_->client(), | 221 window_manager_client_connection_->client(), nullptr, nullptr); |
| 222 GetProxy(&sp)); | |
| 223 } | 222 } |
| 224 | 223 |
| 225 bool ConnectionManager::CloneAndAnimate(const ViewId& view_id) { | 224 bool ConnectionManager::CloneAndAnimate(const ViewId& view_id) { |
| 226 ServerView* view = GetView(view_id); | 225 ServerView* view = GetView(view_id); |
| 227 if (!view || !view->IsDrawn(root_.get()) || view == root_.get()) | 226 if (!view || !view->IsDrawn(root_.get()) || view == root_.get()) |
| 228 return false; | 227 return false; |
| 229 if (!animation_timer_.IsRunning()) { | 228 if (!animation_timer_.IsRunning()) { |
| 230 animation_timer_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(100), | 229 animation_timer_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(100), |
| 231 this, &ConnectionManager::DoAnimation); | 230 this, &ConnectionManager::DoAnimation); |
| 232 } | 231 } |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 void ConnectionManager::SetViewportSize(mojo::SizePtr size) { | 449 void ConnectionManager::SetViewportSize(mojo::SizePtr size) { |
| 451 gfx::Size new_size = size.To<gfx::Size>(); | 450 gfx::Size new_size = size.To<gfx::Size>(); |
| 452 display_manager_->SetViewportSize(new_size); | 451 display_manager_->SetViewportSize(new_size); |
| 453 } | 452 } |
| 454 | 453 |
| 455 void ConnectionManager::CloneAndAnimate(mojo::Id transport_view_id) { | 454 void ConnectionManager::CloneAndAnimate(mojo::Id transport_view_id) { |
| 456 CloneAndAnimate(ViewIdFromTransportId(transport_view_id)); | 455 CloneAndAnimate(ViewIdFromTransportId(transport_view_id)); |
| 457 } | 456 } |
| 458 | 457 |
| 459 } // namespace view_manager | 458 } // namespace view_manager |
| OLD | NEW |