Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(622)

Side by Side Diff: components/view_manager/view_manager_app.cc

Issue 1138073007: Nukes the windowmanager interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "components/view_manager/view_manager_app.h" 5 #include "components/view_manager/view_manager_app.h"
6 6
7 #include "components/view_manager/client_connection.h" 7 #include "components/view_manager/client_connection.h"
8 #include "components/view_manager/connection_manager.h" 8 #include "components/view_manager/connection_manager.h"
9 #include "components/view_manager/display_manager.h" 9 #include "components/view_manager/display_manager.h"
10 #include "components/view_manager/view_manager_service_impl.h" 10 #include "components/view_manager/view_manager_service_impl.h"
11 #include "mojo/application/application_runner_chromium.h" 11 #include "mojo/application/application_runner_chromium.h"
12 #include "mojo/application/public/cpp/application_connection.h" 12 #include "mojo/application/public/cpp/application_connection.h"
13 #include "mojo/application/public/cpp/application_impl.h" 13 #include "mojo/application/public/cpp/application_impl.h"
14 #include "mojo/common/tracing_impl.h" 14 #include "mojo/common/tracing_impl.h"
15 #include "third_party/mojo/src/mojo/public/c/system/main.h" 15 #include "third_party/mojo/src/mojo/public/c/system/main.h"
16 16
17 using mojo::ApplicationConnection; 17 using mojo::ApplicationConnection;
18 using mojo::ApplicationImpl; 18 using mojo::ApplicationImpl;
19 using mojo::InterfaceRequest; 19 using mojo::InterfaceRequest;
20 using mojo::ViewManagerRoot;
20 using mojo::ViewManagerService; 21 using mojo::ViewManagerService;
21 using mojo::WindowManagerInternalClient;
22 22
23 namespace view_manager { 23 namespace view_manager {
24 24
25 ViewManagerApp::ViewManagerApp() 25 ViewManagerApp::ViewManagerApp()
26 : app_impl_(nullptr), wm_app_connection_(nullptr) { 26 : app_impl_(nullptr), wm_app_connection_(nullptr) {
27 } 27 }
28 28
29 ViewManagerApp::~ViewManagerApp() {} 29 ViewManagerApp::~ViewManagerApp() {}
30 30
31 void ViewManagerApp::Initialize(ApplicationImpl* app) { 31 void ViewManagerApp::Initialize(ApplicationImpl* app) {
32 app_impl_ = app; 32 app_impl_ = app;
33 tracing_.Initialize(app); 33 tracing_.Initialize(app);
34 } 34 }
35 35
36 bool ViewManagerApp::ConfigureIncomingConnection( 36 bool ViewManagerApp::ConfigureIncomingConnection(
37 ApplicationConnection* connection) { 37 ApplicationConnection* connection) {
38 if (connection_manager_.get()) { 38 if (connection_manager_.get()) {
39 VLOG(1) << "ViewManager allows only one window manager connection."; 39 VLOG(1) << "ViewManager allows only one window manager connection.";
40 return false; 40 return false;
41 } 41 }
42 wm_app_connection_ = connection; 42 wm_app_connection_ = connection;
43 // |connection| originates from the WindowManager. Let it connect directly 43 // |connection| originates from the WindowManager. Let it connect directly
44 // to the ViewManager and WindowManagerInternalClient. 44 // to the ViewManager.
45 connection->AddService<ViewManagerService>(this); 45 connection->AddService<ViewManagerService>(this);
46 connection->AddService<WindowManagerInternalClient>(this); 46 connection->AddService<ViewManagerRoot>(this);
47 connection->ConnectToService(&wm_internal_);
48 // If no ServiceProvider has been sent, refuse the connection.
49 if (!wm_internal_)
50 return false;
51 wm_internal_.set_error_handler(this);
52 47
53 scoped_ptr<DefaultDisplayManager> display_manager(new DefaultDisplayManager( 48 scoped_ptr<DefaultDisplayManager> display_manager(new DefaultDisplayManager(
54 app_impl_, base::Bind(&ViewManagerApp::OnLostConnectionToWindowManager, 49 app_impl_, base::Bind(&ViewManagerApp::OnLostConnectionToWindowManager,
55 base::Unretained(this)))); 50 base::Unretained(this))));
56 connection_manager_.reset( 51 connection_manager_.reset(
57 new ConnectionManager(this, display_manager.Pass(), wm_internal_.get())); 52 new ConnectionManager(this, display_manager.Pass()));
58 return true; 53 return true;
59 } 54 }
60 55
61 void ViewManagerApp::OnLostConnectionToWindowManager() { 56 void ViewManagerApp::OnLostConnectionToWindowManager() {
62 ApplicationImpl::Terminate(); 57 ApplicationImpl::Terminate();
63 } 58 }
64 59
65 ClientConnection* ViewManagerApp::CreateClientConnectionForEmbedAtView( 60 ClientConnection* ViewManagerApp::CreateClientConnectionForEmbedAtView(
66 ConnectionManager* connection_manager, 61 ConnectionManager* connection_manager,
67 mojo::InterfaceRequest<mojo::ViewManagerService> service_request, 62 mojo::InterfaceRequest<mojo::ViewManagerService> service_request,
(...skipping 19 matching lines...) Expand all
87 mojo::ViewManagerClientPtr view_manager_client) { 82 mojo::ViewManagerClientPtr view_manager_client) {
88 scoped_ptr<ViewManagerServiceImpl> service(new ViewManagerServiceImpl( 83 scoped_ptr<ViewManagerServiceImpl> service(new ViewManagerServiceImpl(
89 connection_manager, creator_id, creator_url, std::string(), root_id)); 84 connection_manager, creator_id, creator_url, std::string(), root_id));
90 return new DefaultClientConnection(service.Pass(), connection_manager, 85 return new DefaultClientConnection(service.Pass(), connection_manager,
91 service_request.Pass(), 86 service_request.Pass(),
92 view_manager_client.Pass()); 87 view_manager_client.Pass());
93 } 88 }
94 89
95 void ViewManagerApp::Create(ApplicationConnection* connection, 90 void ViewManagerApp::Create(ApplicationConnection* connection,
96 InterfaceRequest<ViewManagerService> request) { 91 InterfaceRequest<ViewManagerService> request) {
97 if (connection_manager_->has_window_manager_client_connection()) { 92 if (connection_manager_->has_window_manager_client_connection() ||
93 connection != wm_app_connection_) {
98 VLOG(1) << "ViewManager interface requested more than once."; 94 VLOG(1) << "ViewManager interface requested more than once.";
99 return; 95 return;
100 } 96 }
101 97
102 scoped_ptr<ViewManagerServiceImpl> service(new ViewManagerServiceImpl( 98 scoped_ptr<ViewManagerServiceImpl> service(new ViewManagerServiceImpl(
103 connection_manager_.get(), kInvalidConnectionId, std::string(), 99 connection_manager_.get(), kInvalidConnectionId, std::string(),
104 std::string("mojo:window_manager"), RootViewId())); 100 connection->GetRemoteApplicationURL(), RootViewId()));
105 mojo::ViewManagerClientPtr client; 101 mojo::ViewManagerClientPtr client;
106 wm_internal_client_request_ = GetProxy(&client); 102 wm_app_connection_->ConnectToService(&client);
107 scoped_ptr<ClientConnection> client_connection( 103 scoped_ptr<ClientConnection> client_connection(
108 new DefaultClientConnection(service.Pass(), connection_manager_.get(), 104 new DefaultClientConnection(service.Pass(), connection_manager_.get(),
109 request.Pass(), client.Pass())); 105 request.Pass(), client.Pass()));
110 connection_manager_->SetWindowManagerClientConnection( 106 connection_manager_->SetWindowManagerClientConnection(
111 client_connection.Pass()); 107 client_connection.Pass());
112 } 108 }
113 109
114 void ViewManagerApp::Create( 110 void ViewManagerApp::Create(ApplicationConnection* connection,
115 ApplicationConnection* connection, 111 InterfaceRequest<ViewManagerRoot> request) {
116 InterfaceRequest<WindowManagerInternalClient> request) { 112 if (view_manager_root_binding_.get()) {
117 if (wm_internal_client_binding_.get()) { 113 VLOG(1) << "ViewManagerRoot requested more than once.";
118 VLOG(1) << "WindowManagerInternalClient requested more than once.";
119 return; 114 return;
120 } 115 }
121 116
122 // ConfigureIncomingConnection() must have been called before getting here. 117 // ConfigureIncomingConnection() must have been called before getting here.
123 DCHECK(connection_manager_.get()); 118 DCHECK(connection_manager_.get());
124 wm_internal_client_binding_.reset( 119 view_manager_root_binding_.reset(new mojo::Binding<ViewManagerRoot>(
125 new mojo::Binding<WindowManagerInternalClient>(connection_manager_.get(), 120 connection_manager_.get(), request.Pass()));
126 request.Pass())); 121 view_manager_root_binding_->set_error_handler(this);
127 wm_internal_client_binding_->set_error_handler(this);
128 wm_internal_->SetViewManagerClient(
129 wm_internal_client_request_.PassMessagePipe());
130 } 122 }
131 123
132 void ViewManagerApp::OnConnectionError() { 124 void ViewManagerApp::OnConnectionError() {
133 ApplicationImpl::Terminate(); 125 ApplicationImpl::Terminate();
134 } 126 }
135 127
136 } // namespace view_manager 128 } // namespace view_manager
OLDNEW
« no previous file with comments | « components/view_manager/view_manager_app.h ('k') | components/view_manager/view_manager_client_apptest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698