| 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/view_manager/public/cpp/view_manager_init.h" | 5 #include "components/view_manager/public/cpp/view_manager_init.h" |
| 6 | 6 |
| 7 #include "components/view_manager/public/cpp/lib/view_manager_client_impl.h" | 7 #include "components/view_manager/public/cpp/lib/view_manager_client_impl.h" |
| 8 #include "mojo/application/public/cpp/application_impl.h" | 8 #include "mojo/application/public/cpp/application_impl.h" |
| 9 | 9 |
| 10 namespace mojo { | 10 namespace mojo { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 }; | 28 }; |
| 29 | 29 |
| 30 ViewManagerInit::ViewManagerInit(ApplicationImpl* app, | 30 ViewManagerInit::ViewManagerInit(ApplicationImpl* app, |
| 31 ViewManagerDelegate* delegate, | 31 ViewManagerDelegate* delegate, |
| 32 ViewManagerRootClient* root_client) | 32 ViewManagerRootClient* root_client) |
| 33 : app_(app), delegate_(delegate), client_factory_(new ClientFactory(this)) { | 33 : app_(app), delegate_(delegate), client_factory_(new ClientFactory(this)) { |
| 34 ApplicationConnection* connection = | 34 ApplicationConnection* connection = |
| 35 app_->ConnectToApplication("mojo:view_manager"); | 35 app_->ConnectToApplication("mojo:view_manager"); |
| 36 connection->AddService(client_factory_.get()); | 36 connection->AddService(client_factory_.get()); |
| 37 connection->ConnectToService(&service_); | 37 connection->ConnectToService(&service_); |
| 38 service_.set_error_handler(this); |
| 38 connection->ConnectToService(&view_manager_root_); | 39 connection->ConnectToService(&view_manager_root_); |
| 39 if (root_client) { | 40 if (root_client) { |
| 40 root_client_binding_.reset(new Binding<ViewManagerRootClient>(root_client)); | 41 root_client_binding_.reset(new Binding<ViewManagerRootClient>(root_client)); |
| 41 ViewManagerRootClientPtr root_client_ptr; | 42 ViewManagerRootClientPtr root_client_ptr; |
| 42 root_client_binding_->Bind(GetProxy(&root_client_ptr)); | 43 root_client_binding_->Bind(GetProxy(&root_client_ptr)); |
| 43 view_manager_root_->SetViewManagerRootClient(root_client_ptr.Pass()); | 44 view_manager_root_->SetViewManagerRootClient(root_client_ptr.Pass()); |
| 44 } | 45 } |
| 45 } | 46 } |
| 46 | 47 |
| 47 ViewManagerInit::~ViewManagerInit() { | 48 ViewManagerInit::~ViewManagerInit() { |
| 48 } | 49 } |
| 49 | 50 |
| 50 void ViewManagerInit::OnCreate(InterfaceRequest<ViewManagerClient> request) { | 51 void ViewManagerInit::OnCreate(InterfaceRequest<ViewManagerClient> request) { |
| 51 // TODO(sky): straighten out lifetime. | 52 // TODO(sky): straighten out lifetime. |
| 52 const bool delete_on_error = false; | 53 const bool delete_on_error = false; |
| 53 ViewManagerClientImpl* client = new ViewManagerClientImpl( | 54 ViewManagerClientImpl* client = new ViewManagerClientImpl( |
| 54 delegate_, app_->shell(), request.Pass(), delete_on_error); | 55 delegate_, app_->shell(), request.Pass(), delete_on_error); |
| 55 client->SetViewManagerService(service_.Pass()); | 56 client->SetViewManagerService(service_.Pass()); |
| 56 } | 57 } |
| 57 | 58 |
| 59 void ViewManagerInit::OnConnectionError() { |
| 60 mojo::ApplicationImpl::Terminate(); |
| 61 } |
| 62 |
| 58 } // namespace mojo | 63 } // namespace mojo |
| OLD | NEW |