OLD | NEW |
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/focus_manager_factory.h" | 10 #include "ash/accelerators/focus_manager_factory.h" |
11 #include "ash/ash_switches.h" | 11 #include "ash/ash_switches.h" |
12 #include "ash/caps_lock_delegate_stub.h" | 12 #include "ash/caps_lock_delegate_stub.h" |
13 #include "ash/desktop_background/desktop_background_controller.h" | 13 #include "ash/desktop_background/desktop_background_controller.h" |
14 #include "ash/desktop_background/desktop_background_resources.h" | 14 #include "ash/desktop_background/desktop_background_resources.h" |
15 #include "ash/desktop_background/desktop_background_view.h" | 15 #include "ash/desktop_background/desktop_background_view.h" |
16 #include "ash/display/display_controller.h" | 16 #include "ash/display/display_controller.h" |
17 #include "ash/display/mouse_cursor_event_filter.h" | 17 #include "ash/display/mouse_cursor_event_filter.h" |
18 #include "ash/display/multi_display_manager.h" | 18 #include "ash/display/multi_display_manager.h" |
19 #include "ash/display/screen_position_controller.h" | 19 #include "ash/display/screen_position_controller.h" |
20 #include "ash/display/secondary_display_view.h" | 20 #include "ash/display/secondary_display_view.h" |
21 #include "ash/drag_drop/drag_drop_controller.h" | 21 #include "ash/drag_drop/drag_drop_controller.h" |
22 #include "ash/focus_cycler.h" | 22 #include "ash/focus_cycler.h" |
23 #include "ash/high_contrast/high_contrast_controller.h" | 23 #include "ash/high_contrast/high_contrast_controller.h" |
24 #include "ash/launcher/launcher.h" | 24 #include "ash/launcher/launcher.h" |
25 #include "ash/magnifier/magnification_controller.h" | 25 #include "ash/magnifier/magnification_controller.h" |
26 #include "ash/root_window_controller.h" | 26 #include "ash/root_window_controller.h" |
27 #include "ash/screen_ash.h" | 27 #include "ash/screen_ash.h" |
28 #include "ash/shell_context_menu.h" | |
29 #include "ash/shell_delegate.h" | 28 #include "ash/shell_delegate.h" |
30 #include "ash/shell_factory.h" | 29 #include "ash/shell_factory.h" |
31 #include "ash/shell_window_ids.h" | 30 #include "ash/shell_window_ids.h" |
32 #include "ash/system/status_area_widget.h" | 31 #include "ash/system/status_area_widget.h" |
33 #include "ash/system/tray/system_tray.h" | 32 #include "ash/system/tray/system_tray.h" |
34 #include "ash/tooltips/tooltip_controller.h" | 33 #include "ash/tooltips/tooltip_controller.h" |
35 #include "ash/touch/touch_observer_hud.h" | 34 #include "ash/touch/touch_observer_hud.h" |
36 #include "ash/wm/activation_controller.h" | 35 #include "ash/wm/activation_controller.h" |
37 #include "ash/wm/always_on_top_controller.h" | 36 #include "ash/wm/always_on_top_controller.h" |
38 #include "ash/wm/app_list_controller.h" | 37 #include "ash/wm/app_list_controller.h" |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 aura::RootWindow* root_window = display_controller_->GetPrimaryRootWindow(); | 382 aura::RootWindow* root_window = display_controller_->GetPrimaryRootWindow(); |
384 active_root_window_ = root_window; | 383 active_root_window_ = root_window; |
385 | 384 |
386 cursor_manager_.SetDeviceScaleFactor( | 385 cursor_manager_.SetDeviceScaleFactor( |
387 root_window->AsRootWindowHostDelegate()->GetDeviceScaleFactor()); | 386 root_window->AsRootWindowHostDelegate()->GetDeviceScaleFactor()); |
388 | 387 |
389 #if !defined(OS_MACOSX) | 388 #if !defined(OS_MACOSX) |
390 nested_dispatcher_controller_.reset(new NestedDispatcherController); | 389 nested_dispatcher_controller_.reset(new NestedDispatcherController); |
391 accelerator_controller_.reset(new AcceleratorController); | 390 accelerator_controller_.reset(new AcceleratorController); |
392 #endif | 391 #endif |
393 shell_context_menu_.reset(new internal::ShellContextMenu); | |
394 | 392 |
395 // The order in which event filters are added is significant. | 393 // The order in which event filters are added is significant. |
396 user_activity_detector_.reset(new UserActivityDetector); | 394 user_activity_detector_.reset(new UserActivityDetector); |
397 AddEnvEventFilter(user_activity_detector_.get()); | 395 AddEnvEventFilter(user_activity_detector_.get()); |
398 | 396 |
399 event_rewriter_filter_.reset(new internal::EventRewriterEventFilter); | 397 event_rewriter_filter_.reset(new internal::EventRewriterEventFilter); |
400 AddEnvEventFilter(event_rewriter_filter_.get()); | 398 AddEnvEventFilter(event_rewriter_filter_.get()); |
401 | 399 |
402 overlay_filter_.reset(new internal::OverlayEventFilter); | 400 overlay_filter_.reset(new internal::OverlayEventFilter); |
403 AddEnvEventFilter(overlay_filter_.get()); | 401 AddEnvEventFilter(overlay_filter_.get()); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 } | 514 } |
517 | 515 |
518 void Shell::AddEnvEventFilter(aura::EventFilter* filter) { | 516 void Shell::AddEnvEventFilter(aura::EventFilter* filter) { |
519 aura::Env::GetInstance()->AddPreTargetHandler(filter); | 517 aura::Env::GetInstance()->AddPreTargetHandler(filter); |
520 } | 518 } |
521 | 519 |
522 void Shell::RemoveEnvEventFilter(aura::EventFilter* filter) { | 520 void Shell::RemoveEnvEventFilter(aura::EventFilter* filter) { |
523 aura::Env::GetInstance()->RemovePreTargetHandler(filter); | 521 aura::Env::GetInstance()->RemovePreTargetHandler(filter); |
524 } | 522 } |
525 | 523 |
526 void Shell::ShowBackgroundMenu(views::Widget* widget, | 524 void Shell::ShowContextMenu(const gfx::Point& location) { |
527 const gfx::Point& location) { | |
528 // No context menus if user have not logged in. | 525 // No context menus if user have not logged in. |
529 if (!delegate_.get() || !delegate_->IsUserLoggedIn()) | 526 if (!delegate_.get() || !delegate_->IsUserLoggedIn()) |
530 return; | 527 return; |
531 // No context menus when screen is locked. | 528 // No context menus when screen is locked. |
532 if (IsScreenLocked()) | 529 if (IsScreenLocked()) |
533 return; | 530 return; |
534 if (shell_context_menu_.get()) | 531 if (launcher()) |
535 shell_context_menu_->ShowMenu(widget, location); | 532 launcher()->ShowContextMenu(location); |
536 } | 533 } |
537 | 534 |
538 void Shell::ToggleAppList() { | 535 void Shell::ToggleAppList() { |
539 if (!app_list_controller_.get()) | 536 if (!app_list_controller_.get()) |
540 app_list_controller_.reset(new internal::AppListController); | 537 app_list_controller_.reset(new internal::AppListController); |
541 app_list_controller_->SetVisible(!app_list_controller_->IsVisible()); | 538 app_list_controller_->SetVisible(!app_list_controller_->IsVisible()); |
542 } | 539 } |
543 | 540 |
544 bool Shell::GetAppListTargetVisibility() const { | 541 bool Shell::GetAppListTargetVisibility() const { |
545 return app_list_controller_.get() && | 542 return app_list_controller_.get() && |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
825 iter != controllers.end(); ++iter) { | 822 iter != controllers.end(); ++iter) { |
826 if ((*iter)->GetSystemModalLayoutManager()-> | 823 if ((*iter)->GetSystemModalLayoutManager()-> |
827 CanWindowReceiveEvents(window)) { | 824 CanWindowReceiveEvents(window)) { |
828 return true; | 825 return true; |
829 } | 826 } |
830 } | 827 } |
831 return false; | 828 return false; |
832 } | 829 } |
833 | 830 |
834 } // namespace ash | 831 } // namespace ash |
OLD | NEW |