| 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/window_manager/window_manager_app.h" | 5 #include "services/window_manager/window_manager_app.h" |
| 6 | 6 |
| 7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.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 25 matching lines...) Expand all Loading... |
| 36 Id GetIdForView(View* view) { | 36 Id GetIdForView(View* view) { |
| 37 return view ? view->id() : 0; | 37 return view ? view->id() : 0; |
| 38 } | 38 } |
| 39 | 39 |
| 40 } // namespace | 40 } // namespace |
| 41 | 41 |
| 42 // Used for calls to Embed() that occur before we've connected to the | 42 // Used for calls to Embed() that occur before we've connected to the |
| 43 // ViewManager. | 43 // ViewManager. |
| 44 struct WindowManagerApp::PendingEmbed { | 44 struct WindowManagerApp::PendingEmbed { |
| 45 mojo::String url; | 45 mojo::String url; |
| 46 mojo::InterfaceRequest<ServiceProvider> service_provider; | 46 mojo::InterfaceRequest<ServiceProvider> services; |
| 47 mojo::ServiceProviderPtr exposed_services; |
| 47 }; | 48 }; |
| 48 | 49 |
| 49 //////////////////////////////////////////////////////////////////////////////// | 50 //////////////////////////////////////////////////////////////////////////////// |
| 50 // WindowManagerApp, public: | 51 // WindowManagerApp, public: |
| 51 | 52 |
| 52 WindowManagerApp::WindowManagerApp( | 53 WindowManagerApp::WindowManagerApp( |
| 53 ViewManagerDelegate* view_manager_delegate, | 54 ViewManagerDelegate* view_manager_delegate, |
| 54 WindowManagerDelegate* window_manager_delegate) | 55 WindowManagerDelegate* window_manager_delegate) |
| 55 : shell_(nullptr), | 56 : shell_(nullptr), |
| 56 native_viewport_event_dispatcher_factory_(this), | 57 native_viewport_event_dispatcher_factory_(this), |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 focus_controller_->AddObserver(this); | 117 focus_controller_->AddObserver(this); |
| 117 SetFocusController(root_, focus_controller_.get()); | 118 SetFocusController(root_, focus_controller_.get()); |
| 118 | 119 |
| 119 capture_controller_.reset(new CaptureController); | 120 capture_controller_.reset(new CaptureController); |
| 120 capture_controller_->AddObserver(this); | 121 capture_controller_->AddObserver(this); |
| 121 SetCaptureController(root_, capture_controller_.get()); | 122 SetCaptureController(root_, capture_controller_.get()); |
| 122 } | 123 } |
| 123 | 124 |
| 124 void WindowManagerApp::Embed( | 125 void WindowManagerApp::Embed( |
| 125 const mojo::String& url, | 126 const mojo::String& url, |
| 126 mojo::InterfaceRequest<ServiceProvider> service_provider) { | 127 mojo::InterfaceRequest<mojo::ServiceProvider> services, |
| 128 mojo::ServiceProviderPtr exposed_services) { |
| 127 if (view_manager()) { | 129 if (view_manager()) { |
| 128 window_manager_delegate_->Embed(url, service_provider.Pass()); | 130 window_manager_delegate_->Embed(url, services.Pass(), |
| 131 exposed_services.Pass()); |
| 129 return; | 132 return; |
| 130 } | 133 } |
| 131 scoped_ptr<PendingEmbed> pending_embed(new PendingEmbed); | 134 scoped_ptr<PendingEmbed> pending_embed(new PendingEmbed); |
| 132 pending_embed->url = url; | 135 pending_embed->url = url; |
| 133 pending_embed->service_provider = service_provider.Pass(); | 136 pending_embed->services = services.Pass(); |
| 137 pending_embed->exposed_services = exposed_services.Pass(); |
| 134 pending_embeds_.push_back(pending_embed.release()); | 138 pending_embeds_.push_back(pending_embed.release()); |
| 135 } | 139 } |
| 136 | 140 |
| 137 //////////////////////////////////////////////////////////////////////////////// | 141 //////////////////////////////////////////////////////////////////////////////// |
| 138 // WindowManagerApp, ApplicationDelegate implementation: | 142 // WindowManagerApp, ApplicationDelegate implementation: |
| 139 | 143 |
| 140 void WindowManagerApp::Initialize(mojo::ApplicationImpl* impl) { | 144 void WindowManagerApp::Initialize(mojo::ApplicationImpl* impl) { |
| 141 shell_ = impl->shell(); | 145 shell_ = impl->shell(); |
| 142 LaunchViewManager(impl); | 146 LaunchViewManager(impl); |
| 143 } | 147 } |
| 144 | 148 |
| 145 bool WindowManagerApp::ConfigureIncomingConnection( | 149 bool WindowManagerApp::ConfigureIncomingConnection( |
| 146 ApplicationConnection* connection) { | 150 ApplicationConnection* connection) { |
| 147 connection->AddService(static_cast<InterfaceFactory<WindowManager>*>(this)); | 151 connection->AddService(static_cast<InterfaceFactory<WindowManager>*>(this)); |
| 148 return true; | 152 return true; |
| 149 } | 153 } |
| 150 | 154 |
| 151 //////////////////////////////////////////////////////////////////////////////// | 155 //////////////////////////////////////////////////////////////////////////////// |
| 152 // WindowManagerApp, ViewManagerDelegate implementation: | 156 // WindowManagerApp, ViewManagerDelegate implementation: |
| 153 | 157 |
| 154 void WindowManagerApp::OnEmbed(View* root, | 158 void WindowManagerApp::OnEmbed( |
| 155 mojo::ServiceProviderImpl* exported_services, | 159 View* root, |
| 156 scoped_ptr<ServiceProvider> imported_services) { | 160 mojo::InterfaceRequest<mojo::ServiceProvider> services, |
| 161 mojo::ServiceProviderPtr exposed_services) { |
| 157 DCHECK(!root_); | 162 DCHECK(!root_); |
| 158 root_ = root; | 163 root_ = root; |
| 159 | 164 |
| 160 view_event_dispatcher_.reset(new ViewEventDispatcher); | 165 view_event_dispatcher_.reset(new ViewEventDispatcher); |
| 161 | 166 |
| 162 RegisterSubtree(root_); | 167 RegisterSubtree(root_); |
| 163 | 168 |
| 164 if (wrapped_view_manager_delegate_) { | 169 if (wrapped_view_manager_delegate_) { |
| 165 wrapped_view_manager_delegate_->OnEmbed(root, exported_services, | 170 wrapped_view_manager_delegate_->OnEmbed(root, services.Pass(), |
| 166 imported_services.Pass()); | 171 exposed_services.Pass()); |
| 167 } | 172 } |
| 168 | 173 |
| 169 for (PendingEmbed* pending_embed : pending_embeds_) | 174 for (PendingEmbed* pending_embed : pending_embeds_) { |
| 170 Embed(pending_embed->url, pending_embed->service_provider.Pass()); | 175 Embed(pending_embed->url, pending_embed->services.Pass(), |
| 176 pending_embed->exposed_services.Pass()); |
| 177 } |
| 171 pending_embeds_.clear(); | 178 pending_embeds_.clear(); |
| 172 } | 179 } |
| 173 | 180 |
| 174 void WindowManagerApp::OnViewManagerDisconnected( | 181 void WindowManagerApp::OnViewManagerDisconnected( |
| 175 mojo::ViewManager* view_manager) { | 182 mojo::ViewManager* view_manager) { |
| 176 if (wrapped_view_manager_delegate_) | 183 if (wrapped_view_manager_delegate_) |
| 177 wrapped_view_manager_delegate_->OnViewManagerDisconnected(view_manager); | 184 wrapped_view_manager_delegate_->OnViewManagerDisconnected(view_manager); |
| 178 | 185 |
| 179 base::MessageLoop* message_loop = base::MessageLoop::current(); | 186 base::MessageLoop* message_loop = base::MessageLoop::current(); |
| 180 if (message_loop && message_loop->is_running()) | 187 if (message_loop && message_loop->is_running()) |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 uint16_t connection_id, | 393 uint16_t connection_id, |
| 387 mojo::ScopedMessagePipeHandle window_manager_pipe) { | 394 mojo::ScopedMessagePipeHandle window_manager_pipe) { |
| 388 // TODO(sky): pass in |connection_id| for validation. | 395 // TODO(sky): pass in |connection_id| for validation. |
| 389 WindowManagerImpl* wm = new WindowManagerImpl(this, true); | 396 WindowManagerImpl* wm = new WindowManagerImpl(this, true); |
| 390 wm->Bind(window_manager_pipe.Pass()); | 397 wm->Bind(window_manager_pipe.Pass()); |
| 391 // WindowManagerImpl is deleted when the connection has an error, or from our | 398 // WindowManagerImpl is deleted when the connection has an error, or from our |
| 392 // destructor. | 399 // destructor. |
| 393 } | 400 } |
| 394 | 401 |
| 395 } // namespace window_manager | 402 } // namespace window_manager |
| OLD | NEW |