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 | 8 |
9 #include "ash/accelerators/accelerator_table.h" | |
9 #include "ash/app_list/app_list.h" | 10 #include "ash/app_list/app_list.h" |
10 #include "ash/ash_switches.h" | 11 #include "ash/ash_switches.h" |
11 #include "ash/desktop_background/desktop_background_controller.h" | 12 #include "ash/desktop_background/desktop_background_controller.h" |
12 #include "ash/desktop_background/desktop_background_resources.h" | 13 #include "ash/desktop_background/desktop_background_resources.h" |
13 #include "ash/desktop_background/desktop_background_view.h" | 14 #include "ash/desktop_background/desktop_background_view.h" |
14 #include "ash/drag_drop/drag_drop_controller.h" | 15 #include "ash/drag_drop/drag_drop_controller.h" |
15 #include "ash/focus_cycler.h" | 16 #include "ash/focus_cycler.h" |
16 #include "ash/ime/input_method_event_filter.h" | 17 #include "ash/ime/input_method_event_filter.h" |
17 #include "ash/launcher/launcher.h" | 18 #include "ash/launcher/launcher.h" |
18 #include "ash/magnifier/magnification_controller.h" | 19 #include "ash/magnifier/magnification_controller.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
63 #include "grit/ui_resources.h" | 64 #include "grit/ui_resources.h" |
64 #include "third_party/skia/include/core/SkBitmap.h" | 65 #include "third_party/skia/include/core/SkBitmap.h" |
65 #include "ui/aura/client/aura_constants.h" | 66 #include "ui/aura/client/aura_constants.h" |
66 #include "ui/aura/env.h" | 67 #include "ui/aura/env.h" |
67 #include "ui/aura/layout_manager.h" | 68 #include "ui/aura/layout_manager.h" |
68 #include "ui/aura/monitor_manager.h" | 69 #include "ui/aura/monitor_manager.h" |
69 #include "ui/aura/monitor_manager.h" | 70 #include "ui/aura/monitor_manager.h" |
70 #include "ui/aura/root_window.h" | 71 #include "ui/aura/root_window.h" |
71 #include "ui/aura/ui_controls_aura.h" | 72 #include "ui/aura/ui_controls_aura.h" |
72 #include "ui/aura/window.h" | 73 #include "ui/aura/window.h" |
74 #include "ui/base/accelerators/accelerator_manager.h" | |
73 #include "ui/compositor/layer.h" | 75 #include "ui/compositor/layer.h" |
74 #include "ui/compositor/layer_animator.h" | 76 #include "ui/compositor/layer_animator.h" |
75 #include "ui/gfx/monitor.h" | 77 #include "ui/gfx/monitor.h" |
76 #include "ui/gfx/screen.h" | 78 #include "ui/gfx/screen.h" |
77 #include "ui/gfx/size.h" | 79 #include "ui/gfx/size.h" |
78 #include "ui/ui_controls/ui_controls.h" | 80 #include "ui/ui_controls/ui_controls.h" |
81 #include "ui/views/focus/focus_manager_delegate.h" | |
82 #include "ui/views/focus/focus_manager_factory.h" | |
79 #include "ui/views/widget/native_widget_aura.h" | 83 #include "ui/views/widget/native_widget_aura.h" |
80 #include "ui/views/widget/widget.h" | 84 #include "ui/views/widget/widget.h" |
81 | 85 |
82 #if !defined(OS_MACOSX) | 86 #if !defined(OS_MACOSX) |
83 #include "ash/accelerators/accelerator_controller.h" | 87 #include "ash/accelerators/accelerator_controller.h" |
84 #include "ash/accelerators/accelerator_filter.h" | 88 #include "ash/accelerators/accelerator_filter.h" |
85 #include "ash/accelerators/nested_dispatcher_controller.h" | 89 #include "ash/accelerators/nested_dispatcher_controller.h" |
86 #endif | 90 #endif |
87 | 91 |
88 namespace ash { | 92 namespace ash { |
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
491 bool wifi_enabled_; | 495 bool wifi_enabled_; |
492 bool cellular_enabled_; | 496 bool cellular_enabled_; |
493 bool bluetooth_enabled_; | 497 bool bluetooth_enabled_; |
494 float volume_; | 498 float volume_; |
495 bool caps_lock_enabled_; | 499 bool caps_lock_enabled_; |
496 SkBitmap null_image_; | 500 SkBitmap null_image_; |
497 | 501 |
498 DISALLOW_COPY_AND_ASSIGN(DummySystemTrayDelegate); | 502 DISALLOW_COPY_AND_ASSIGN(DummySystemTrayDelegate); |
499 }; | 503 }; |
500 | 504 |
505 class AshFocusManagerFactory : public views::FocusManagerFactory { | |
Ben Goodger (Google)
2012/05/07 15:42:51
Can we move this closer to the accelerators stuff
Yusuke Sato
2012/05/08 02:15:57
Done.
| |
506 public: | |
507 AshFocusManagerFactory() {} | |
508 virtual ~AshFocusManagerFactory() {} | |
509 | |
510 protected: | |
511 virtual views::FocusManager* CreateFocusManager(Widget* widget) OVERRIDE { | |
512 return new views::FocusManager(widget, new Delegate); | |
513 } | |
514 | |
515 private: | |
516 class Delegate : public views::FocusManagerDelegate { | |
517 public: | |
518 // views::FocusManagerDelegate overrides: | |
519 virtual bool ProcessAccelerator( | |
520 const ui::Accelerator& accelerator) OVERRIDE { | |
521 #if !defined(OS_MACOSX) | |
Ben Goodger (Google)
2012/05/07 15:42:51
dhollowa has become distracted from implementing M
Yusuke Sato
2012/05/08 02:15:57
Done.
| |
522 AcceleratorController* controller = | |
523 Shell::GetInstance()->accelerator_controller(); | |
524 if (controller) | |
525 return controller->Process(accelerator); | |
526 #endif | |
527 return false; | |
528 } | |
529 | |
530 virtual ui::AcceleratorTarget* GetCurrentTargetForAccelerator( | |
531 const ui::Accelerator& accelerator) const OVERRIDE { | |
532 #if !defined(OS_MACOSX) | |
533 AcceleratorController* controller = | |
534 Shell::GetInstance()->accelerator_controller(); | |
535 if (controller && controller->IsRegistered(accelerator)) | |
536 return controller; | |
537 #endif | |
538 return NULL; | |
539 } | |
540 }; | |
541 | |
542 DISALLOW_COPY_AND_ASSIGN(AshFocusManagerFactory); | |
543 }; | |
544 | |
501 } // namespace | 545 } // namespace |
502 | 546 |
503 // static | 547 // static |
504 Shell* Shell::instance_ = NULL; | 548 Shell* Shell::instance_ = NULL; |
505 // static | 549 // static |
506 bool Shell::initially_hide_cursor_ = false; | 550 bool Shell::initially_hide_cursor_ = false; |
507 | 551 |
508 //////////////////////////////////////////////////////////////////////////////// | 552 //////////////////////////////////////////////////////////////////////////////// |
509 // Shell::TestApi | 553 // Shell::TestApi |
510 | 554 |
(...skipping 25 matching lines...) Expand all Loading... | |
536 root_filter_(NULL), | 580 root_filter_(NULL), |
537 delegate_(delegate), | 581 delegate_(delegate), |
538 shelf_(NULL), | 582 shelf_(NULL), |
539 panel_layout_manager_(NULL), | 583 panel_layout_manager_(NULL), |
540 root_window_layout_(NULL) { | 584 root_window_layout_(NULL) { |
541 gfx::Screen::SetInstance(screen_); | 585 gfx::Screen::SetInstance(screen_); |
542 ui_controls::InstallUIControlsAura(CreateUIControlsAura(root_window_.get())); | 586 ui_controls::InstallUIControlsAura(CreateUIControlsAura(root_window_.get())); |
543 } | 587 } |
544 | 588 |
545 Shell::~Shell() { | 589 Shell::~Shell() { |
590 views::FocusManagerFactory::Install(NULL); | |
591 | |
546 RemoveRootWindowEventFilter(key_rewriter_filter_.get()); | 592 RemoveRootWindowEventFilter(key_rewriter_filter_.get()); |
547 RemoveRootWindowEventFilter(partial_screenshot_filter_.get()); | 593 RemoveRootWindowEventFilter(partial_screenshot_filter_.get()); |
548 RemoveRootWindowEventFilter(input_method_filter_.get()); | 594 RemoveRootWindowEventFilter(input_method_filter_.get()); |
549 RemoveRootWindowEventFilter(window_modality_controller_.get()); | 595 RemoveRootWindowEventFilter(window_modality_controller_.get()); |
550 RemoveRootWindowEventFilter(system_gesture_filter_.get()); | 596 RemoveRootWindowEventFilter(system_gesture_filter_.get()); |
551 #if !defined(OS_MACOSX) | 597 #if !defined(OS_MACOSX) |
552 RemoveRootWindowEventFilter(accelerator_filter_.get()); | 598 RemoveRootWindowEventFilter(accelerator_filter_.get()); |
553 #endif | 599 #endif |
554 | 600 |
555 // Close background widget now so that the focus manager of the | 601 // Close background widget now so that the focus manager of the |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
734 AddRootWindowEventFilter(tooltip_controller_.get()); | 780 AddRootWindowEventFilter(tooltip_controller_.get()); |
735 | 781 |
736 drag_drop_controller_.reset(new internal::DragDropController); | 782 drag_drop_controller_.reset(new internal::DragDropController); |
737 magnification_controller_.reset(new internal::MagnificationController); | 783 magnification_controller_.reset(new internal::MagnificationController); |
738 power_button_controller_.reset(new PowerButtonController); | 784 power_button_controller_.reset(new PowerButtonController); |
739 AddShellObserver(power_button_controller_.get()); | 785 AddShellObserver(power_button_controller_.get()); |
740 video_detector_.reset(new VideoDetector); | 786 video_detector_.reset(new VideoDetector); |
741 window_cycle_controller_.reset(new WindowCycleController); | 787 window_cycle_controller_.reset(new WindowCycleController); |
742 monitor_controller_.reset(new internal::MonitorController); | 788 monitor_controller_.reset(new internal::MonitorController); |
743 screen_dimmer_.reset(new internal::ScreenDimmer); | 789 screen_dimmer_.reset(new internal::ScreenDimmer); |
790 | |
791 views::FocusManagerFactory::Install(new AshFocusManagerFactory); | |
744 } | 792 } |
745 | 793 |
746 aura::Window* Shell::GetContainer(int container_id) { | 794 aura::Window* Shell::GetContainer(int container_id) { |
747 return const_cast<aura::Window*>( | 795 return const_cast<aura::Window*>( |
748 const_cast<const Shell*>(this)->GetContainer(container_id)); | 796 const_cast<const Shell*>(this)->GetContainer(container_id)); |
749 } | 797 } |
750 | 798 |
751 const aura::Window* Shell::GetContainer(int container_id) const { | 799 const aura::Window* Shell::GetContainer(int container_id) const { |
752 return GetRootWindow()->GetChildById(container_id); | 800 return GetRootWindow()->GetChildById(container_id); |
753 } | 801 } |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
928 panel_container->SetLayoutManager(panel_layout_manager_); | 976 panel_container->SetLayoutManager(panel_layout_manager_); |
929 } | 977 } |
930 } | 978 } |
931 | 979 |
932 void Shell::DisableWorkspaceGridLayout() { | 980 void Shell::DisableWorkspaceGridLayout() { |
933 if (workspace_controller_.get()) | 981 if (workspace_controller_.get()) |
934 workspace_controller_->workspace_manager()->set_grid_size(0); | 982 workspace_controller_->workspace_manager()->set_grid_size(0); |
935 } | 983 } |
936 | 984 |
937 } // namespace ash | 985 } // namespace ash |
OLD | NEW |