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

Side by Side Diff: ash/shell.cc

Issue 224113005: Eliminate ash::internal namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « ash/shell.h ('k') | ash/shell/lock_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ash/shell.h" 5 #include "ash/shell.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "ash/accelerators/accelerator_controller.h" 10 #include "ash/accelerators/accelerator_controller.h"
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 return !!instance_; 190 return !!instance_;
191 } 191 }
192 192
193 // static 193 // static
194 void Shell::DeleteInstance() { 194 void Shell::DeleteInstance() {
195 delete instance_; 195 delete instance_;
196 instance_ = NULL; 196 instance_ = NULL;
197 } 197 }
198 198
199 // static 199 // static
200 internal::RootWindowController* Shell::GetPrimaryRootWindowController() { 200 RootWindowController* Shell::GetPrimaryRootWindowController() {
201 return internal::GetRootWindowController(GetPrimaryRootWindow()); 201 return GetRootWindowController(GetPrimaryRootWindow());
202 } 202 }
203 203
204 // static 204 // static
205 Shell::RootWindowControllerList Shell::GetAllRootWindowControllers() { 205 Shell::RootWindowControllerList Shell::GetAllRootWindowControllers() {
206 return Shell::GetInstance()->display_controller()-> 206 return Shell::GetInstance()->display_controller()->
207 GetAllRootWindowControllers(); 207 GetAllRootWindowControllers();
208 } 208 }
209 209
210 // static 210 // static
211 aura::Window* Shell::GetPrimaryRootWindow() { 211 aura::Window* Shell::GetPrimaryRootWindow() {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 ui::MenuSourceType source_type) { 266 ui::MenuSourceType source_type) {
267 // No context menus if there is no session with an active user. 267 // No context menus if there is no session with an active user.
268 if (!session_state_delegate_->NumberOfLoggedInUsers()) 268 if (!session_state_delegate_->NumberOfLoggedInUsers())
269 return; 269 return;
270 // No context menus when screen is locked. 270 // No context menus when screen is locked.
271 if (session_state_delegate_->IsScreenLocked()) 271 if (session_state_delegate_->IsScreenLocked())
272 return; 272 return;
273 273
274 aura::Window* root = 274 aura::Window* root =
275 wm::GetRootWindowMatching(gfx::Rect(location_in_screen, gfx::Size())); 275 wm::GetRootWindowMatching(gfx::Rect(location_in_screen, gfx::Size()));
276 internal::GetRootWindowController(root)-> 276 GetRootWindowController(root)
277 ShowContextMenu(location_in_screen, source_type); 277 ->ShowContextMenu(location_in_screen, source_type);
278 } 278 }
279 279
280 void Shell::ToggleAppList(aura::Window* window) { 280 void Shell::ToggleAppList(aura::Window* window) {
281 // If the context window is not given, show it on the target root window. 281 // If the context window is not given, show it on the target root window.
282 if (!window) 282 if (!window)
283 window = GetTargetRootWindow(); 283 window = GetTargetRootWindow();
284 if (!app_list_controller_) 284 if (!app_list_controller_)
285 app_list_controller_.reset(new internal::AppListController); 285 app_list_controller_.reset(new AppListController);
286 app_list_controller_->SetVisible(!app_list_controller_->IsVisible(), window); 286 app_list_controller_->SetVisible(!app_list_controller_->IsVisible(), window);
287 } 287 }
288 288
289 bool Shell::GetAppListTargetVisibility() const { 289 bool Shell::GetAppListTargetVisibility() const {
290 return app_list_controller_.get() && 290 return app_list_controller_.get() &&
291 app_list_controller_->GetTargetVisibility(); 291 app_list_controller_->GetTargetVisibility();
292 } 292 }
293 293
294 aura::Window* Shell::GetAppListWindow() { 294 aura::Window* Shell::GetAppListWindow() {
295 return app_list_controller_.get() ? app_list_controller_->GetWindow() : NULL; 295 return app_list_controller_.get() ? app_list_controller_->GetWindow() : NULL;
296 } 296 }
297 297
298 app_list::AppListView* Shell::GetAppListView() { 298 app_list::AppListView* Shell::GetAppListView() {
299 return app_list_controller_.get() ? app_list_controller_->GetView() : NULL; 299 return app_list_controller_.get() ? app_list_controller_->GetView() : NULL;
300 } 300 }
301 301
302 bool Shell::IsSystemModalWindowOpen() const { 302 bool Shell::IsSystemModalWindowOpen() const {
303 if (simulate_modal_window_open_for_testing_) 303 if (simulate_modal_window_open_for_testing_)
304 return true; 304 return true;
305 const std::vector<aura::Window*> containers = GetContainersFromAllRootWindows( 305 const std::vector<aura::Window*> containers = GetContainersFromAllRootWindows(
306 internal::kShellWindowId_SystemModalContainer, NULL); 306 kShellWindowId_SystemModalContainer, NULL);
307 for (std::vector<aura::Window*>::const_iterator cit = containers.begin(); 307 for (std::vector<aura::Window*>::const_iterator cit = containers.begin();
308 cit != containers.end(); ++cit) { 308 cit != containers.end(); ++cit) {
309 for (aura::Window::Windows::const_iterator wit = (*cit)->children().begin(); 309 for (aura::Window::Windows::const_iterator wit = (*cit)->children().begin();
310 wit != (*cit)->children().end(); ++wit) { 310 wit != (*cit)->children().end(); ++wit) {
311 if ((*wit)->GetProperty(aura::client::kModalKey) == 311 if ((*wit)->GetProperty(aura::client::kModalKey) ==
312 ui::MODAL_TYPE_SYSTEM && (*wit)->TargetVisibility()) { 312 ui::MODAL_TYPE_SYSTEM && (*wit)->TargetVisibility()) {
313 return true; 313 return true;
314 } 314 }
315 } 315 }
316 } 316 }
317 return false; 317 return false;
318 } 318 }
319 319
320 views::NonClientFrameView* Shell::CreateDefaultNonClientFrameView( 320 views::NonClientFrameView* Shell::CreateDefaultNonClientFrameView(
321 views::Widget* widget) { 321 views::Widget* widget) {
322 // Use translucent-style window frames for dialogs. 322 // Use translucent-style window frames for dialogs.
323 return new CustomFrameViewAsh(widget); 323 return new CustomFrameViewAsh(widget);
324 } 324 }
325 325
326 void Shell::RotateFocus(Direction direction) { 326 void Shell::RotateFocus(Direction direction) {
327 focus_cycler_->RotateFocus( 327 focus_cycler_->RotateFocus(direction == FORWARD ? FocusCycler::FORWARD
328 direction == FORWARD ? internal::FocusCycler::FORWARD : 328 : FocusCycler::BACKWARD);
329 internal::FocusCycler::BACKWARD);
330 } 329 }
331 330
332 void Shell::SetDisplayWorkAreaInsets(Window* contains, 331 void Shell::SetDisplayWorkAreaInsets(Window* contains,
333 const gfx::Insets& insets) { 332 const gfx::Insets& insets) {
334 if (!display_controller_->UpdateWorkAreaOfDisplayNearestWindow( 333 if (!display_controller_->UpdateWorkAreaOfDisplayNearestWindow(
335 contains, insets)) { 334 contains, insets)) {
336 return; 335 return;
337 } 336 }
338 FOR_EACH_OBSERVER(ShellObserver, observers_, 337 FOR_EACH_OBSERVER(ShellObserver, observers_,
339 OnDisplayWorkAreaInsetsChanged()); 338 OnDisplayWorkAreaInsetsChanged());
(...skipping 18 matching lines...) Expand all
358 void Shell::OnAppTerminating() { 357 void Shell::OnAppTerminating() {
359 FOR_EACH_OBSERVER(ShellObserver, observers_, OnAppTerminating()); 358 FOR_EACH_OBSERVER(ShellObserver, observers_, OnAppTerminating());
360 } 359 }
361 360
362 void Shell::OnLockStateChanged(bool locked) { 361 void Shell::OnLockStateChanged(bool locked) {
363 FOR_EACH_OBSERVER(ShellObserver, observers_, OnLockStateChanged(locked)); 362 FOR_EACH_OBSERVER(ShellObserver, observers_, OnLockStateChanged(locked));
364 #ifndef NDEBUG 363 #ifndef NDEBUG
365 // Make sure that there is no system modal in Lock layer when unlocked. 364 // Make sure that there is no system modal in Lock layer when unlocked.
366 if (!locked) { 365 if (!locked) {
367 std::vector<aura::Window*> containers = GetContainersFromAllRootWindows( 366 std::vector<aura::Window*> containers = GetContainersFromAllRootWindows(
368 internal::kShellWindowId_LockSystemModalContainer, 367 kShellWindowId_LockSystemModalContainer, GetPrimaryRootWindow());
369 GetPrimaryRootWindow());
370 for (std::vector<aura::Window*>::const_iterator iter = containers.begin(); 368 for (std::vector<aura::Window*>::const_iterator iter = containers.begin();
371 iter != containers.end(); ++iter) { 369 iter != containers.end(); ++iter) {
372 DCHECK_EQ(0u, (*iter)->children().size()); 370 DCHECK_EQ(0u, (*iter)->children().size());
373 } 371 }
374 } 372 }
375 #endif 373 #endif
376 } 374 }
377 375
378 void Shell::OnCastingSessionStartedOrStopped(bool started) { 376 void Shell::OnCastingSessionStartedOrStopped(bool started) {
379 #if defined(OS_CHROMEOS) && defined(USE_X11) 377 #if defined(OS_CHROMEOS) && defined(USE_X11)
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 void Shell::AddShellObserver(ShellObserver* observer) { 437 void Shell::AddShellObserver(ShellObserver* observer) {
440 observers_.AddObserver(observer); 438 observers_.AddObserver(observer);
441 } 439 }
442 440
443 void Shell::RemoveShellObserver(ShellObserver* observer) { 441 void Shell::RemoveShellObserver(ShellObserver* observer) {
444 observers_.RemoveObserver(observer); 442 observers_.RemoveObserver(observer);
445 } 443 }
446 444
447 void Shell::EnableMaximizeModeWindowManager(bool enable) { 445 void Shell::EnableMaximizeModeWindowManager(bool enable) {
448 if (enable && !maximize_mode_window_manager_.get()) { 446 if (enable && !maximize_mode_window_manager_.get()) {
449 maximize_mode_window_manager_.reset( 447 maximize_mode_window_manager_.reset(new MaximizeModeWindowManager());
450 new internal::MaximizeModeWindowManager());
451 } else if (!enable && maximize_mode_window_manager_.get()) { 448 } else if (!enable && maximize_mode_window_manager_.get()) {
452 maximize_mode_window_manager_.reset(); 449 maximize_mode_window_manager_.reset();
453 } 450 }
454 } 451 }
455 452
456 bool Shell::IsMaximizeModeWindowManagerEnabled() { 453 bool Shell::IsMaximizeModeWindowManagerEnabled() {
457 return maximize_mode_window_manager_.get() != NULL; 454 return maximize_mode_window_manager_.get() != NULL;
458 } 455 }
459 456
460 void Shell::UpdateShelfVisibility() { 457 void Shell::UpdateShelfVisibility() {
461 RootWindowControllerList controllers = GetAllRootWindowControllers(); 458 RootWindowControllerList controllers = GetAllRootWindowControllers();
462 for (RootWindowControllerList::iterator iter = controllers.begin(); 459 for (RootWindowControllerList::iterator iter = controllers.begin();
463 iter != controllers.end(); ++iter) 460 iter != controllers.end(); ++iter)
464 if ((*iter)->shelf()) 461 if ((*iter)->shelf())
465 (*iter)->UpdateShelfVisibility(); 462 (*iter)->UpdateShelfVisibility();
466 } 463 }
467 464
468 void Shell::SetShelfAutoHideBehavior(ShelfAutoHideBehavior behavior, 465 void Shell::SetShelfAutoHideBehavior(ShelfAutoHideBehavior behavior,
469 aura::Window* root_window) { 466 aura::Window* root_window) {
470 ash::internal::ShelfLayoutManager::ForShelf(root_window)-> 467 ash::ShelfLayoutManager::ForShelf(root_window)->SetAutoHideBehavior(behavior);
471 SetAutoHideBehavior(behavior);
472 } 468 }
473 469
474 ShelfAutoHideBehavior Shell::GetShelfAutoHideBehavior( 470 ShelfAutoHideBehavior Shell::GetShelfAutoHideBehavior(
475 aura::Window* root_window) const { 471 aura::Window* root_window) const {
476 return ash::internal::ShelfLayoutManager::ForShelf(root_window)-> 472 return ash::ShelfLayoutManager::ForShelf(root_window)->auto_hide_behavior();
477 auto_hide_behavior();
478 } 473 }
479 474
480 void Shell::SetShelfAlignment(ShelfAlignment alignment, 475 void Shell::SetShelfAlignment(ShelfAlignment alignment,
481 aura::Window* root_window) { 476 aura::Window* root_window) {
482 if (ash::internal::ShelfLayoutManager::ForShelf(root_window)-> 477 if (ash::ShelfLayoutManager::ForShelf(root_window)->SetAlignment(alignment)) {
483 SetAlignment(alignment)) {
484 FOR_EACH_OBSERVER( 478 FOR_EACH_OBSERVER(
485 ShellObserver, observers_, OnShelfAlignmentChanged(root_window)); 479 ShellObserver, observers_, OnShelfAlignmentChanged(root_window));
486 } 480 }
487 } 481 }
488 482
489 ShelfAlignment Shell::GetShelfAlignment(aura::Window* root_window) { 483 ShelfAlignment Shell::GetShelfAlignment(aura::Window* root_window) {
490 return internal::GetRootWindowController(root_window)-> 484 return GetRootWindowController(root_window)
491 GetShelfLayoutManager()->GetAlignment(); 485 ->GetShelfLayoutManager()
486 ->GetAlignment();
492 } 487 }
493 488
494 void Shell::SetDimming(bool should_dim) { 489 void Shell::SetDimming(bool should_dim) {
495 RootWindowControllerList controllers = GetAllRootWindowControllers(); 490 RootWindowControllerList controllers = GetAllRootWindowControllers();
496 for (RootWindowControllerList::iterator iter = controllers.begin(); 491 for (RootWindowControllerList::iterator iter = controllers.begin();
497 iter != controllers.end(); ++iter) 492 iter != controllers.end(); ++iter)
498 (*iter)->screen_dimmer()->SetDimming(should_dim); 493 (*iter)->screen_dimmer()->SetDimming(should_dim);
499 } 494 }
500 495
501 void Shell::NotifyFullscreenStateChange(bool is_fullscreen, 496 void Shell::NotifyFullscreenStateChange(bool is_fullscreen,
502 aura::Window* root_window) { 497 aura::Window* root_window) {
503 FOR_EACH_OBSERVER(ShellObserver, observers_, OnFullscreenStateChanged( 498 FOR_EACH_OBSERVER(ShellObserver, observers_, OnFullscreenStateChanged(
504 is_fullscreen, root_window)); 499 is_fullscreen, root_window));
505 } 500 }
506 501
507 void Shell::CreateModalBackground(aura::Window* window) { 502 void Shell::CreateModalBackground(aura::Window* window) {
508 if (!modality_filter_) { 503 if (!modality_filter_) {
509 modality_filter_.reset(new internal::SystemModalContainerEventFilter(this)); 504 modality_filter_.reset(new SystemModalContainerEventFilter(this));
510 AddPreTargetHandler(modality_filter_.get()); 505 AddPreTargetHandler(modality_filter_.get());
511 } 506 }
512 RootWindowControllerList controllers = GetAllRootWindowControllers(); 507 RootWindowControllerList controllers = GetAllRootWindowControllers();
513 for (RootWindowControllerList::iterator iter = controllers.begin(); 508 for (RootWindowControllerList::iterator iter = controllers.begin();
514 iter != controllers.end(); ++iter) 509 iter != controllers.end(); ++iter)
515 (*iter)->GetSystemModalLayoutManager(window)->CreateModalBackground(); 510 (*iter)->GetSystemModalLayoutManager(window)->CreateModalBackground();
516 } 511 }
517 512
518 void Shell::OnModalWindowRemoved(aura::Window* removed) { 513 void Shell::OnModalWindowRemoved(aura::Window* removed) {
519 RootWindowControllerList controllers = GetAllRootWindowControllers(); 514 RootWindowControllerList controllers = GetAllRootWindowControllers();
(...skipping 27 matching lines...) Expand all
547 } 542 }
548 543
549 ShelfDelegate* Shell::GetShelfDelegate() { 544 ShelfDelegate* Shell::GetShelfDelegate() {
550 if (!shelf_delegate_) { 545 if (!shelf_delegate_) {
551 shelf_model_.reset(new ShelfModel); 546 shelf_model_.reset(new ShelfModel);
552 // Creates ShelfItemDelegateManager before ShelfDelegate. 547 // Creates ShelfItemDelegateManager before ShelfDelegate.
553 shelf_item_delegate_manager_.reset( 548 shelf_item_delegate_manager_.reset(
554 new ShelfItemDelegateManager(shelf_model_.get())); 549 new ShelfItemDelegateManager(shelf_model_.get()));
555 550
556 shelf_delegate_.reset(delegate_->CreateShelfDelegate(shelf_model_.get())); 551 shelf_delegate_.reset(delegate_->CreateShelfDelegate(shelf_model_.get()));
557 scoped_ptr<ShelfItemDelegate> controller( 552 scoped_ptr<ShelfItemDelegate> controller(new AppListShelfItemDelegate);
558 new internal::AppListShelfItemDelegate);
559 553
560 // Finding the shelf model's location of the app list and setting its 554 // Finding the shelf model's location of the app list and setting its
561 // ShelfItemDelegate. 555 // ShelfItemDelegate.
562 int app_list_index = shelf_model_->GetItemIndexForType(TYPE_APP_LIST); 556 int app_list_index = shelf_model_->GetItemIndexForType(TYPE_APP_LIST);
563 DCHECK_GE(app_list_index, 0); 557 DCHECK_GE(app_list_index, 0);
564 ShelfID app_list_id = shelf_model_->items()[app_list_index].id; 558 ShelfID app_list_id = shelf_model_->items()[app_list_index].id;
565 DCHECK(app_list_id); 559 DCHECK(app_list_id);
566 shelf_item_delegate_manager_->SetShelfItemDelegate(app_list_id, 560 shelf_item_delegate_manager_->SetShelfItemDelegate(app_list_id,
567 controller.Pass()); 561 controller.Pass());
568 shelf_window_watcher_.reset(new internal::ShelfWindowWatcher( 562 shelf_window_watcher_.reset(new ShelfWindowWatcher(
569 shelf_model_.get(), 563 shelf_model_.get(), shelf_item_delegate_manager_.get()));
570 shelf_item_delegate_manager_.get()));
571 } 564 }
572 return shelf_delegate_.get(); 565 return shelf_delegate_.get();
573 } 566 }
574 567
575 void Shell::SetTouchHudProjectionEnabled(bool enabled) { 568 void Shell::SetTouchHudProjectionEnabled(bool enabled) {
576 if (is_touch_hud_projection_enabled_ == enabled) 569 if (is_touch_hud_projection_enabled_ == enabled)
577 return; 570 return;
578 571
579 is_touch_hud_projection_enabled_ = enabled; 572 is_touch_hud_projection_enabled_ = enabled;
580 FOR_EACH_OBSERVER(ShellObserver, observers_, 573 FOR_EACH_OBSERVER(ShellObserver, observers_,
(...skipping 30 matching lines...) Expand all
611 #if defined(OS_CHROMEOS) 604 #if defined(OS_CHROMEOS)
612 output_configurator_(new ui::OutputConfigurator()), 605 output_configurator_(new ui::OutputConfigurator()),
613 #endif // defined(OS_CHROMEOS) 606 #endif // defined(OS_CHROMEOS)
614 native_cursor_manager_(new AshNativeCursorManager), 607 native_cursor_manager_(new AshNativeCursorManager),
615 cursor_manager_( 608 cursor_manager_(
616 scoped_ptr< ::wm::NativeCursorManager>(native_cursor_manager_)), 609 scoped_ptr< ::wm::NativeCursorManager>(native_cursor_manager_)),
617 simulate_modal_window_open_for_testing_(false), 610 simulate_modal_window_open_for_testing_(false),
618 is_touch_hud_projection_enabled_(false) { 611 is_touch_hud_projection_enabled_(false) {
619 DCHECK(delegate_.get()); 612 DCHECK(delegate_.get());
620 gpu_support_.reset(delegate_->CreateGPUSupport()); 613 gpu_support_.reset(delegate_->CreateGPUSupport());
621 display_manager_.reset(new internal::DisplayManager); 614 display_manager_.reset(new DisplayManager);
622 display_controller_.reset(new DisplayController); 615 display_controller_.reset(new DisplayController);
623 #if defined(OS_CHROMEOS) && defined(USE_X11) 616 #if defined(OS_CHROMEOS) && defined(USE_X11)
624 user_metrics_recorder_.reset(new UserMetricsRecorder); 617 user_metrics_recorder_.reset(new UserMetricsRecorder);
625 #endif // defined(OS_CHROMEOS) 618 #endif // defined(OS_CHROMEOS)
626 619
627 #if defined(OS_CHROMEOS) 620 #if defined(OS_CHROMEOS)
628 internal::PowerStatus::Initialize(); 621 PowerStatus::Initialize();
629 #endif 622 #endif
630 } 623 }
631 624
632 Shell::~Shell() { 625 Shell::~Shell() {
633 TRACE_EVENT0("shutdown", "ash::Shell::Destructor"); 626 TRACE_EVENT0("shutdown", "ash::Shell::Destructor");
634 627
635 delegate_->PreShutdown(); 628 delegate_->PreShutdown();
636 629
637 views::FocusManagerFactory::Install(NULL); 630 views::FocusManagerFactory::Install(NULL);
638 631
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
770 if (output_configurator_animation_) 763 if (output_configurator_animation_)
771 output_configurator_->RemoveObserver(output_configurator_animation_.get()); 764 output_configurator_->RemoveObserver(output_configurator_animation_.get());
772 if (display_error_observer_) 765 if (display_error_observer_)
773 output_configurator_->RemoveObserver(display_error_observer_.get()); 766 output_configurator_->RemoveObserver(display_error_observer_.get());
774 if (projecting_observer_) 767 if (projecting_observer_)
775 output_configurator_->RemoveObserver(projecting_observer_.get()); 768 output_configurator_->RemoveObserver(projecting_observer_.get());
776 display_change_observer_.reset(); 769 display_change_observer_.reset();
777 #endif // defined(OS_CHROMEOS) 770 #endif // defined(OS_CHROMEOS)
778 771
779 #if defined(OS_CHROMEOS) 772 #if defined(OS_CHROMEOS)
780 internal::PowerStatus::Shutdown(); 773 PowerStatus::Shutdown();
781 #endif 774 #endif
782 775
783 DCHECK(instance_ == this); 776 DCHECK(instance_ == this);
784 instance_ = NULL; 777 instance_ = NULL;
785 } 778 }
786 779
787 void Shell::Init() { 780 void Shell::Init() {
788 delegate_->PreInit(); 781 delegate_->PreInit();
789 if (keyboard::IsKeyboardUsabilityExperimentEnabled()) { 782 if (keyboard::IsKeyboardUsabilityExperimentEnabled()) {
790 display_manager_->SetSecondDisplayMode( 783 display_manager_->SetSecondDisplayMode(DisplayManager::VIRTUAL_KEYBOARD);
791 internal::DisplayManager::VIRTUAL_KEYBOARD);
792 } 784 }
793 bool display_initialized = display_manager_->InitFromCommandLine(); 785 bool display_initialized = display_manager_->InitFromCommandLine();
794 #if defined(OS_CHROMEOS) 786 #if defined(OS_CHROMEOS)
795 output_configurator_->Init(!gpu_support_->IsPanelFittingDisabled()); 787 output_configurator_->Init(!gpu_support_->IsPanelFittingDisabled());
796 output_configurator_animation_.reset( 788 output_configurator_animation_.reset(new OutputConfiguratorAnimation());
797 new internal::OutputConfiguratorAnimation());
798 output_configurator_->AddObserver(output_configurator_animation_.get()); 789 output_configurator_->AddObserver(output_configurator_animation_.get());
799 790
800 projecting_observer_.reset(new internal::ProjectingObserver()); 791 projecting_observer_.reset(new ProjectingObserver());
801 output_configurator_->AddObserver(projecting_observer_.get()); 792 output_configurator_->AddObserver(projecting_observer_.get());
802 793
803 if (!display_initialized && base::SysInfo::IsRunningOnChromeOS()) { 794 if (!display_initialized && base::SysInfo::IsRunningOnChromeOS()) {
804 display_change_observer_.reset(new internal::DisplayChangeObserver); 795 display_change_observer_.reset(new DisplayChangeObserver);
805 // Register |display_change_observer_| first so that the rest of 796 // Register |display_change_observer_| first so that the rest of
806 // observer gets invoked after the root windows are configured. 797 // observer gets invoked after the root windows are configured.
807 output_configurator_->AddObserver(display_change_observer_.get()); 798 output_configurator_->AddObserver(display_change_observer_.get());
808 display_error_observer_.reset(new internal::DisplayErrorObserver()); 799 display_error_observer_.reset(new DisplayErrorObserver());
809 output_configurator_->AddObserver(display_error_observer_.get()); 800 output_configurator_->AddObserver(display_error_observer_.get());
810 output_configurator_->set_state_controller(display_change_observer_.get()); 801 output_configurator_->set_state_controller(display_change_observer_.get());
811 output_configurator_->set_mirroring_controller(display_manager_.get()); 802 output_configurator_->set_mirroring_controller(display_manager_.get());
812 output_configurator_->ForceInitialConfigure( 803 output_configurator_->ForceInitialConfigure(
813 delegate_->IsFirstRunAfterBoot() ? kChromeOsBootColor : 0); 804 delegate_->IsFirstRunAfterBoot() ? kChromeOsBootColor : 0);
814 display_initialized = true; 805 display_initialized = true;
815 } 806 }
816 #endif // defined(OS_CHROMEOS) 807 #endif // defined(OS_CHROMEOS)
817 if (!display_initialized) 808 if (!display_initialized)
818 display_manager_->InitDefaultDisplay(); 809 display_manager_->InitDefaultDisplay();
(...skipping 16 matching lines...) Expand all
835 AddPreTargetHandler(this); 826 AddPreTargetHandler(this);
836 827
837 env_filter_.reset(new ::wm::CompoundEventFilter); 828 env_filter_.reset(new ::wm::CompoundEventFilter);
838 AddPreTargetHandler(env_filter_.get()); 829 AddPreTargetHandler(env_filter_.get());
839 830
840 ::wm::FocusController* focus_controller = 831 ::wm::FocusController* focus_controller =
841 new ::wm::FocusController(new wm::AshFocusRules); 832 new ::wm::FocusController(new wm::AshFocusRules);
842 focus_client_.reset(focus_controller); 833 focus_client_.reset(focus_controller);
843 activation_client_ = focus_controller; 834 activation_client_ = focus_controller;
844 activation_client_->AddObserver(this); 835 activation_client_->AddObserver(this);
845 focus_cycler_.reset(new internal::FocusCycler()); 836 focus_cycler_.reset(new FocusCycler());
846 837
847 screen_position_controller_.reset(new internal::ScreenPositionController); 838 screen_position_controller_.reset(new ScreenPositionController);
848 window_tree_host_factory_.reset(delegate_->CreateWindowTreeHostFactory()); 839 window_tree_host_factory_.reset(delegate_->CreateWindowTreeHostFactory());
849 840
850 display_controller_->Start(); 841 display_controller_->Start();
851 display_controller_->InitPrimaryDisplay(); 842 display_controller_->InitPrimaryDisplay();
852 aura::Window* root_window = display_controller_->GetPrimaryRootWindow(); 843 aura::Window* root_window = display_controller_->GetPrimaryRootWindow();
853 target_root_window_ = root_window; 844 target_root_window_ = root_window;
854 845
855 #if defined(OS_CHROMEOS) 846 #if defined(OS_CHROMEOS)
856 resolution_notification_controller_.reset( 847 resolution_notification_controller_.reset(
857 new internal::ResolutionNotificationController); 848 new ResolutionNotificationController);
858 #endif 849 #endif
859 850
860 cursor_manager_.SetDisplay(GetScreen()->GetPrimaryDisplay()); 851 cursor_manager_.SetDisplay(GetScreen()->GetPrimaryDisplay());
861 852
862 nested_dispatcher_controller_.reset(new NestedDispatcherController); 853 nested_dispatcher_controller_.reset(new NestedDispatcherController);
863 accelerator_controller_.reset(new AcceleratorController); 854 accelerator_controller_.reset(new AcceleratorController);
864 855
865 #if defined(OS_CHROMEOS) && defined(USE_X11) 856 #if defined(OS_CHROMEOS) && defined(USE_X11)
866 magnifier_key_scroll_handler_ = MagnifierKeyScroller::CreateHandler().Pass(); 857 magnifier_key_scroll_handler_ = MagnifierKeyScroller::CreateHandler().Pass();
867 AddPreTargetHandler(magnifier_key_scroll_handler_.get()); 858 AddPreTargetHandler(magnifier_key_scroll_handler_.get());
868 speech_feedback_handler_ = SpokenFeedbackToggler::CreateHandler().Pass(); 859 speech_feedback_handler_ = SpokenFeedbackToggler::CreateHandler().Pass();
869 AddPreTargetHandler(speech_feedback_handler_.get()); 860 AddPreTargetHandler(speech_feedback_handler_.get());
870 #endif 861 #endif
871 862
872 // The order in which event filters are added is significant. 863 // The order in which event filters are added is significant.
873 864
874 #if defined(OS_CHROMEOS) 865 #if defined(OS_CHROMEOS)
875 // The StickyKeysController also rewrites events and must be added 866 // The StickyKeysController also rewrites events and must be added
876 // before observers, but after the EventRewriterEventFilter. 867 // before observers, but after the EventRewriterEventFilter.
877 sticky_keys_controller_.reset(new StickyKeysController); 868 sticky_keys_controller_.reset(new StickyKeysController);
878 AddPreTargetHandler(sticky_keys_controller_.get()); 869 AddPreTargetHandler(sticky_keys_controller_.get());
879 #endif 870 #endif
880 871
881 // wm::UserActivityDetector passes events to observers, so let them get 872 // wm::UserActivityDetector passes events to observers, so let them get
882 // rewritten first. 873 // rewritten first.
883 user_activity_detector_.reset(new ::wm::UserActivityDetector); 874 user_activity_detector_.reset(new ::wm::UserActivityDetector);
884 AddPreTargetHandler(user_activity_detector_.get()); 875 AddPreTargetHandler(user_activity_detector_.get());
885 876
886 overlay_filter_.reset(new internal::OverlayEventFilter); 877 overlay_filter_.reset(new OverlayEventFilter);
887 AddPreTargetHandler(overlay_filter_.get()); 878 AddPreTargetHandler(overlay_filter_.get());
888 AddShellObserver(overlay_filter_.get()); 879 AddShellObserver(overlay_filter_.get());
889 880
890 input_method_filter_.reset(new ::wm::InputMethodEventFilter( 881 input_method_filter_.reset(new ::wm::InputMethodEventFilter(
891 root_window->GetHost()->GetAcceleratedWidget())); 882 root_window->GetHost()->GetAcceleratedWidget()));
892 AddPreTargetHandler(input_method_filter_.get()); 883 AddPreTargetHandler(input_method_filter_.get());
893 884
894 accelerator_filter_.reset(new internal::AcceleratorFilter); 885 accelerator_filter_.reset(new AcceleratorFilter);
895 AddPreTargetHandler(accelerator_filter_.get()); 886 AddPreTargetHandler(accelerator_filter_.get());
896 887
897 event_transformation_handler_.reset(new internal::EventTransformationHandler); 888 event_transformation_handler_.reset(new EventTransformationHandler);
898 AddPreTargetHandler(event_transformation_handler_.get()); 889 AddPreTargetHandler(event_transformation_handler_.get());
899 890
900 toplevel_window_event_handler_.reset(new ToplevelWindowEventHandler); 891 toplevel_window_event_handler_.reset(new ToplevelWindowEventHandler);
901 892
902 system_gesture_filter_.reset(new internal::SystemGestureEventFilter); 893 system_gesture_filter_.reset(new SystemGestureEventFilter);
903 AddPreTargetHandler(system_gesture_filter_.get()); 894 AddPreTargetHandler(system_gesture_filter_.get());
904 895
905 keyboard_metrics_filter_.reset(new internal::KeyboardUMAEventFilter); 896 keyboard_metrics_filter_.reset(new KeyboardUMAEventFilter);
906 AddPreTargetHandler(keyboard_metrics_filter_.get()); 897 AddPreTargetHandler(keyboard_metrics_filter_.get());
907 898
908 // The keyboard system must be initialized before the RootWindowController is 899 // The keyboard system must be initialized before the RootWindowController is
909 // created. 900 // created.
910 #if defined(OS_CHROMEOS) 901 #if defined(OS_CHROMEOS)
911 keyboard::InitializeKeyboard(); 902 keyboard::InitializeKeyboard();
912 #endif 903 #endif
913 904
914 lock_state_controller_.reset(new LockStateController); 905 lock_state_controller_.reset(new LockStateController);
915 power_button_controller_.reset(new PowerButtonController( 906 power_button_controller_.reset(new PowerButtonController(
916 lock_state_controller_.get())); 907 lock_state_controller_.get()));
917 #if defined(OS_CHROMEOS) 908 #if defined(OS_CHROMEOS)
918 // Pass the initial display state to PowerButtonController. 909 // Pass the initial display state to PowerButtonController.
919 power_button_controller_->OnDisplayModeChanged( 910 power_button_controller_->OnDisplayModeChanged(
920 output_configurator_->cached_outputs()); 911 output_configurator_->cached_outputs());
921 #endif 912 #endif
922 AddShellObserver(lock_state_controller_.get()); 913 AddShellObserver(lock_state_controller_.get());
923 914
924 drag_drop_controller_.reset(new internal::DragDropController); 915 drag_drop_controller_.reset(new DragDropController);
925 mouse_cursor_filter_.reset(new internal::MouseCursorEventFilter()); 916 mouse_cursor_filter_.reset(new MouseCursorEventFilter());
926 PrependPreTargetHandler(mouse_cursor_filter_.get()); 917 PrependPreTargetHandler(mouse_cursor_filter_.get());
927 918
928 // Create Controllers that may need root window. 919 // Create Controllers that may need root window.
929 // TODO(oshima): Move as many controllers before creating 920 // TODO(oshima): Move as many controllers before creating
930 // RootWindowController as possible. 921 // RootWindowController as possible.
931 visibility_controller_.reset(new AshVisibilityController); 922 visibility_controller_.reset(new AshVisibilityController);
932 923
933 magnification_controller_.reset( 924 magnification_controller_.reset(
934 MagnificationController::CreateInstance()); 925 MagnificationController::CreateInstance());
935 mru_window_tracker_.reset(new MruWindowTracker(activation_client_)); 926 mru_window_tracker_.reset(new MruWindowTracker(activation_client_));
936 927
937 partial_magnification_controller_.reset( 928 partial_magnification_controller_.reset(
938 new PartialMagnificationController()); 929 new PartialMagnificationController());
939 930
940 autoclick_controller_.reset(AutoclickController::CreateInstance()); 931 autoclick_controller_.reset(AutoclickController::CreateInstance());
941 932
942 high_contrast_controller_.reset(new HighContrastController); 933 high_contrast_controller_.reset(new HighContrastController);
943 video_detector_.reset(new VideoDetector); 934 video_detector_.reset(new VideoDetector);
944 window_selector_controller_.reset(new WindowSelectorController()); 935 window_selector_controller_.reset(new WindowSelectorController());
945 936
946 tooltip_controller_.reset( 937 tooltip_controller_.reset(
947 new views::corewm::TooltipController( 938 new views::corewm::TooltipController(
948 scoped_ptr<views::corewm::Tooltip>( 939 scoped_ptr<views::corewm::Tooltip>(
949 new views::corewm::TooltipAura(gfx::SCREEN_TYPE_ALTERNATE)))); 940 new views::corewm::TooltipAura(gfx::SCREEN_TYPE_ALTERNATE))));
950 AddPreTargetHandler(tooltip_controller_.get()); 941 AddPreTargetHandler(tooltip_controller_.get());
951 942
952 event_client_.reset(new internal::EventClientImpl); 943 event_client_.reset(new EventClientImpl);
953 944
954 // This controller needs to be set before SetupManagedWindowMode. 945 // This controller needs to be set before SetupManagedWindowMode.
955 desktop_background_controller_.reset(new DesktopBackgroundController()); 946 desktop_background_controller_.reset(new DesktopBackgroundController());
956 user_wallpaper_delegate_.reset(delegate_->CreateUserWallpaperDelegate()); 947 user_wallpaper_delegate_.reset(delegate_->CreateUserWallpaperDelegate());
957 948
958 session_state_delegate_.reset(delegate_->CreateSessionStateDelegate()); 949 session_state_delegate_.reset(delegate_->CreateSessionStateDelegate());
959 accessibility_delegate_.reset(delegate_->CreateAccessibilityDelegate()); 950 accessibility_delegate_.reset(delegate_->CreateAccessibilityDelegate());
960 new_window_delegate_.reset(delegate_->CreateNewWindowDelegate()); 951 new_window_delegate_.reset(delegate_->CreateNewWindowDelegate());
961 media_delegate_.reset(delegate_->CreateMediaDelegate()); 952 media_delegate_.reset(delegate_->CreateMediaDelegate());
962 953
963 resize_shadow_controller_.reset(new internal::ResizeShadowController()); 954 resize_shadow_controller_.reset(new ResizeShadowController());
964 shadow_controller_.reset( 955 shadow_controller_.reset(
965 new ::wm::ShadowController(activation_client_)); 956 new ::wm::ShadowController(activation_client_));
966 957
967 // Create system_tray_notifier_ before the delegate. 958 // Create system_tray_notifier_ before the delegate.
968 system_tray_notifier_.reset(new ash::SystemTrayNotifier()); 959 system_tray_notifier_.reset(new ash::SystemTrayNotifier());
969 960
970 // Initialize system_tray_delegate_ before initializing StatusAreaWidget. 961 // Initialize system_tray_delegate_ before initializing StatusAreaWidget.
971 system_tray_delegate_.reset(delegate()->CreateSystemTrayDelegate()); 962 system_tray_delegate_.reset(delegate()->CreateSystemTrayDelegate());
972 DCHECK(system_tray_delegate_.get()); 963 DCHECK(system_tray_delegate_.get());
973 964
974 locale_notification_controller_.reset( 965 locale_notification_controller_.reset(new LocaleNotificationController);
975 new internal::LocaleNotificationController);
976 966
977 // Initialize system_tray_delegate_ after StatusAreaWidget is created. 967 // Initialize system_tray_delegate_ after StatusAreaWidget is created.
978 system_tray_delegate_->Initialize(); 968 system_tray_delegate_->Initialize();
979 969
980 #if defined(OS_CHROMEOS) 970 #if defined(OS_CHROMEOS)
981 // Create the LogoutConfirmationController after the SystemTrayDelegate. 971 // Create the LogoutConfirmationController after the SystemTrayDelegate.
982 logout_confirmation_controller_.reset( 972 logout_confirmation_controller_.reset(new LogoutConfirmationController(
983 new internal::LogoutConfirmationController( 973 base::Bind(&SystemTrayDelegate::SignOut,
984 base::Bind(&SystemTrayDelegate::SignOut, 974 base::Unretained(system_tray_delegate_.get()))));
985 base::Unretained(system_tray_delegate_.get()))));
986 #endif 975 #endif
987 976
988 // TODO(oshima): Initialize all RootWindowControllers once, and 977 // TODO(oshima): Initialize all RootWindowControllers once, and
989 // initialize controller/delegates above when initializing the 978 // initialize controller/delegates above when initializing the
990 // primary root window controller. 979 // primary root window controller.
991 internal::RootWindowController::CreateForPrimaryDisplay( 980 RootWindowController::CreateForPrimaryDisplay(root_window->GetHost());
992 root_window->GetHost());
993 981
994 display_controller_->InitSecondaryDisplays(); 982 display_controller_->InitSecondaryDisplays();
995 983
996 // It needs to be created after RootWindowController has been created 984 // It needs to be created after RootWindowController has been created
997 // (which calls OnWindowResized has been called, otherwise the 985 // (which calls OnWindowResized has been called, otherwise the
998 // widget will not paint when restoring after a browser crash. Also it needs 986 // widget will not paint when restoring after a browser crash. Also it needs
999 // to be created after InitSecondaryDisplays() to initialize the wallpapers in 987 // to be created after InitSecondaryDisplays() to initialize the wallpapers in
1000 // the correct size. 988 // the correct size.
1001 user_wallpaper_delegate_->InitializeWallpaper(); 989 user_wallpaper_delegate_->InitializeWallpaper();
1002 990
1003 if (initially_hide_cursor_) 991 if (initially_hide_cursor_)
1004 cursor_manager_.HideCursor(); 992 cursor_manager_.HideCursor();
1005 cursor_manager_.SetCursor(ui::kCursorPointer); 993 cursor_manager_.SetCursor(ui::kCursorPointer);
1006 994
1007 #if defined(OS_CHROMEOS) 995 #if defined(OS_CHROMEOS)
1008 // Set accelerator controller delegates. 996 // Set accelerator controller delegates.
1009 accelerator_controller_->SetBrightnessControlDelegate( 997 accelerator_controller_->SetBrightnessControlDelegate(
1010 scoped_ptr<ash::BrightnessControlDelegate>( 998 scoped_ptr<ash::BrightnessControlDelegate>(
1011 new ash::system::BrightnessControllerChromeos).Pass()); 999 new ash::system::BrightnessControllerChromeos).Pass());
1012 1000
1013 power_event_observer_.reset(new internal::PowerEventObserver()); 1001 power_event_observer_.reset(new PowerEventObserver());
1014 user_activity_notifier_.reset( 1002 user_activity_notifier_.reset(
1015 new internal::UserActivityNotifier(user_activity_detector_.get())); 1003 new UserActivityNotifier(user_activity_detector_.get()));
1016 video_activity_notifier_.reset( 1004 video_activity_notifier_.reset(
1017 new internal::VideoActivityNotifier(video_detector_.get())); 1005 new VideoActivityNotifier(video_detector_.get()));
1018 bluetooth_notification_controller_.reset( 1006 bluetooth_notification_controller_.reset(new BluetoothNotificationController);
1019 new internal::BluetoothNotificationController); 1007 last_window_closed_logout_reminder_.reset(new LastWindowClosedLogoutReminder);
1020 last_window_closed_logout_reminder_.reset(
1021 new internal::LastWindowClosedLogoutReminder);
1022 #endif 1008 #endif
1023 1009
1024 weak_display_manager_factory_.reset( 1010 weak_display_manager_factory_.reset(
1025 new base::WeakPtrFactory<internal::DisplayManager>( 1011 new base::WeakPtrFactory<DisplayManager>(display_manager_.get()));
1026 display_manager_.get()));
1027 // The compositor thread and main message loop have to be running in 1012 // The compositor thread and main message loop have to be running in
1028 // order to create mirror window. Run it after the main message loop 1013 // order to create mirror window. Run it after the main message loop
1029 // is started. 1014 // is started.
1030 base::MessageLoopForUI::current()->PostTask( 1015 base::MessageLoopForUI::current()->PostTask(
1031 FROM_HERE, 1016 FROM_HERE,
1032 base::Bind(&internal::DisplayManager::CreateMirrorWindowIfAny, 1017 base::Bind(&DisplayManager::CreateMirrorWindowIfAny,
1033 weak_display_manager_factory_->GetWeakPtr())); 1018 weak_display_manager_factory_->GetWeakPtr()));
1034 } 1019 }
1035 1020
1036 void Shell::InitKeyboard() { 1021 void Shell::InitKeyboard() {
1037 if (keyboard::IsKeyboardEnabled()) { 1022 if (keyboard::IsKeyboardEnabled()) {
1038 if (keyboard_controller_.get()) { 1023 if (keyboard_controller_.get()) {
1039 RootWindowControllerList controllers = GetAllRootWindowControllers(); 1024 RootWindowControllerList controllers = GetAllRootWindowControllers();
1040 for (RootWindowControllerList::iterator iter = controllers.begin(); 1025 for (RootWindowControllerList::iterator iter = controllers.begin();
1041 iter != controllers.end(); ++iter) { 1026 iter != controllers.end(); ++iter) {
1042 (*iter)->DeactivateKeyboard(keyboard_controller_.get()); 1027 (*iter)->DeactivateKeyboard(keyboard_controller_.get());
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1076 if (nested_dispatcher_controller_) { 1061 if (nested_dispatcher_controller_) {
1077 aura::client::SetDispatcherClient(root_window, 1062 aura::client::SetDispatcherClient(root_window,
1078 nested_dispatcher_controller_.get()); 1063 nested_dispatcher_controller_.get());
1079 } 1064 }
1080 } 1065 }
1081 1066
1082 bool Shell::CanWindowReceiveEvents(aura::Window* window) { 1067 bool Shell::CanWindowReceiveEvents(aura::Window* window) {
1083 RootWindowControllerList controllers = GetAllRootWindowControllers(); 1068 RootWindowControllerList controllers = GetAllRootWindowControllers();
1084 for (RootWindowControllerList::iterator iter = controllers.begin(); 1069 for (RootWindowControllerList::iterator iter = controllers.begin();
1085 iter != controllers.end(); ++iter) { 1070 iter != controllers.end(); ++iter) {
1086 internal::SystemModalContainerLayoutManager* layout_manager = 1071 SystemModalContainerLayoutManager* layout_manager =
1087 (*iter)->GetSystemModalLayoutManager(window); 1072 (*iter)->GetSystemModalLayoutManager(window);
1088 if (layout_manager && layout_manager->CanWindowReceiveEvents(window)) 1073 if (layout_manager && layout_manager->CanWindowReceiveEvents(window))
1089 return true; 1074 return true;
1090 // Allow events to fall through to the virtual keyboard even if displaying 1075 // Allow events to fall through to the virtual keyboard even if displaying
1091 // a system modal dialog. 1076 // a system modal dialog.
1092 if ((*iter)->IsVirtualKeyboardWindow(window)) 1077 if ((*iter)->IsVirtualKeyboardWindow(window))
1093 return true; 1078 return true;
1094 } 1079 }
1095 1080
1096 return false; 1081 return false;
(...skipping 25 matching lines...) Expand all
1122 //////////////////////////////////////////////////////////////////////////////// 1107 ////////////////////////////////////////////////////////////////////////////////
1123 // Shell, aura::client::ActivationChangeObserver implementation: 1108 // Shell, aura::client::ActivationChangeObserver implementation:
1124 1109
1125 void Shell::OnWindowActivated(aura::Window* gained_active, 1110 void Shell::OnWindowActivated(aura::Window* gained_active,
1126 aura::Window* lost_active) { 1111 aura::Window* lost_active) {
1127 if (gained_active) 1112 if (gained_active)
1128 target_root_window_ = gained_active->GetRootWindow(); 1113 target_root_window_ = gained_active->GetRootWindow();
1129 } 1114 }
1130 1115
1131 } // namespace ash 1116 } // namespace ash
OLDNEW
« no previous file with comments | « ash/shell.h ('k') | ash/shell/lock_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698