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/window_manager/window_manager_app.h" | 5 #include "mojo/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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
116 focus_controller_->ActivateView(view); | 116 focus_controller_->ActivateView(view); |
117 } | 117 } |
118 | 118 |
119 bool WindowManagerApp::IsReady() const { | 119 bool WindowManagerApp::IsReady() const { |
120 return view_manager_ && root_; | 120 return view_manager_ && root_; |
121 } | 121 } |
122 | 122 |
123 void WindowManagerApp::InitFocus(scoped_ptr<mojo::FocusRules> rules) { | 123 void WindowManagerApp::InitFocus(scoped_ptr<mojo::FocusRules> rules) { |
124 focus_controller_.reset(new mojo::FocusController(rules.Pass())); | 124 focus_controller_.reset(new mojo::FocusController(rules.Pass())); |
125 focus_controller_->AddObserver(this); | 125 focus_controller_->AddObserver(this); |
126 | |
127 if (root_) | |
128 ViewTarget::TargetFromView(root_) | |
129 ->set_focus_controller(focus_controller_.get()); | |
126 } | 130 } |
127 | 131 |
128 void WindowManagerApp::Embed( | 132 void WindowManagerApp::Embed( |
129 const String& url, | 133 const String& url, |
130 InterfaceRequest<ServiceProvider> service_provider) { | 134 InterfaceRequest<ServiceProvider> service_provider) { |
131 if (view_manager_) { | 135 if (view_manager_) { |
132 window_manager_delegate_->Embed(url, service_provider.Pass()); | 136 window_manager_delegate_->Embed(url, service_provider.Pass()); |
133 return; | 137 return; |
134 } | 138 } |
135 scoped_ptr<PendingEmbed> pending_embed(new PendingEmbed); | 139 scoped_ptr<PendingEmbed> pending_embed(new PendingEmbed); |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
270 // WindowManagerApp, private: | 274 // WindowManagerApp, private: |
271 | 275 |
272 void WindowManagerApp::RegisterSubtree(View* view) { | 276 void WindowManagerApp::RegisterSubtree(View* view) { |
273 view->AddObserver(this); | 277 view->AddObserver(this); |
274 DCHECK(registered_view_id_set_.find(view->id()) == | 278 DCHECK(registered_view_id_set_.find(view->id()) == |
275 registered_view_id_set_.end()); | 279 registered_view_id_set_.end()); |
276 // All events pass through the root during dispatch, so we only need a handler | 280 // All events pass through the root during dispatch, so we only need a handler |
277 // installed there. | 281 // installed there. |
278 if (view == root_) { | 282 if (view == root_) { |
279 ViewTarget* target = ViewTarget::TargetFromView(view); | 283 ViewTarget* target = ViewTarget::TargetFromView(view); |
284 if (focus_controller_) | |
sky
2014/11/18 22:36:38
Is it really possible to get here with no focuscon
Elliot Glaysher
2014/11/18 23:52:30
Not only is it possible, it is the default.
Regis
| |
285 target->set_focus_controller(focus_controller_.get()); | |
280 target->SetEventTargeter(scoped_ptr<ViewTargeter>(new ViewTargeter())); | 286 target->SetEventTargeter(scoped_ptr<ViewTargeter>(new ViewTargeter())); |
281 target->AddPreTargetHandler(this); | 287 target->AddPreTargetHandler(this); |
282 view_event_dispatcher_->SetRootViewTarget(target); | 288 view_event_dispatcher_->SetRootViewTarget(target); |
283 } | 289 } |
290 | |
284 registered_view_id_set_.insert(view->id()); | 291 registered_view_id_set_.insert(view->id()); |
285 View::Children::const_iterator it = view->children().begin(); | 292 View::Children::const_iterator it = view->children().begin(); |
286 for (; it != view->children().end(); ++it) | 293 for (; it != view->children().end(); ++it) |
287 RegisterSubtree(*it); | 294 RegisterSubtree(*it); |
288 } | 295 } |
289 | 296 |
290 void WindowManagerApp::UnregisterSubtree(View* view) { | 297 void WindowManagerApp::UnregisterSubtree(View* view) { |
291 for (View* child : view->children()) | 298 for (View* child : view->children()) |
292 UnregisterSubtree(child); | 299 UnregisterSubtree(child); |
293 Unregister(view); | 300 Unregister(view); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
334 view_manager_app->ConnectToService(&window_manager_client_); | 341 view_manager_app->ConnectToService(&window_manager_client_); |
335 } | 342 } |
336 | 343 |
337 void WindowManagerApp::Create(ApplicationConnection* connection, | 344 void WindowManagerApp::Create(ApplicationConnection* connection, |
338 InterfaceRequest<WindowManagerInternal> request) { | 345 InterfaceRequest<WindowManagerInternal> request) { |
339 WindowManagerInternalImpl* impl = new WindowManagerInternalImpl(this); | 346 WindowManagerInternalImpl* impl = new WindowManagerInternalImpl(this); |
340 BindToRequest(impl, &request); | 347 BindToRequest(impl, &request); |
341 } | 348 } |
342 | 349 |
343 } // namespace mojo | 350 } // namespace mojo |
OLD | NEW |