Chromium Code Reviews| 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/gfx/compositor/layer.h" | 75 #include "ui/gfx/compositor/layer.h" |
| 74 #include "ui/gfx/compositor/layer_animator.h" | 76 #include "ui/gfx/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_factory.h" | |
| 79 #include "ui/views/widget/native_widget_aura.h" | 82 #include "ui/views/widget/native_widget_aura.h" |
| 80 #include "ui/views/widget/widget.h" | 83 #include "ui/views/widget/widget.h" |
| 81 | 84 |
| 82 #if !defined(OS_MACOSX) | 85 #if !defined(OS_MACOSX) |
| 83 #include "ash/accelerators/accelerator_controller.h" | 86 #include "ash/accelerators/accelerator_controller.h" |
| 84 #include "ash/accelerators/accelerator_filter.h" | 87 #include "ash/accelerators/accelerator_filter.h" |
| 85 #include "ash/accelerators/nested_dispatcher_controller.h" | 88 #include "ash/accelerators/nested_dispatcher_controller.h" |
| 86 #endif | 89 #endif |
| 87 | 90 |
| 88 namespace ash { | 91 namespace ash { |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 491 bool wifi_enabled_; | 494 bool wifi_enabled_; |
| 492 bool cellular_enabled_; | 495 bool cellular_enabled_; |
| 493 bool bluetooth_enabled_; | 496 bool bluetooth_enabled_; |
| 494 float volume_; | 497 float volume_; |
| 495 bool caps_lock_enabled_; | 498 bool caps_lock_enabled_; |
| 496 SkBitmap null_image_; | 499 SkBitmap null_image_; |
| 497 | 500 |
| 498 DISALLOW_COPY_AND_ASSIGN(DummySystemTrayDelegate); | 501 DISALLOW_COPY_AND_ASSIGN(DummySystemTrayDelegate); |
| 499 }; | 502 }; |
| 500 | 503 |
| 504 class AshFocusManagerFactory : public views::FocusManagerFactory { | |
| 505 public: | |
| 506 AshFocusManagerFactory() {} | |
| 507 virtual ~AshFocusManagerFactory() {} | |
| 508 | |
| 509 protected: | |
| 510 virtual views::FocusManager* CreateFocusManager(Widget* widget) OVERRIDE { | |
| 511 views::FocusManager* manager = new views::FocusManager(widget); | |
| 512 #if !defined(OS_MACOSX) | |
|
Ben Goodger (Google)
2012/05/04 16:25:33
why the OS_MACOSX?
Yusuke Sato
2012/05/07 08:27:28
Because accelerator_controller() is currently not
| |
| 513 AcceleratorController* target = | |
| 514 Shell::GetInstance()->accelerator_controller(); | |
| 515 DCHECK(target); | |
| 516 for (size_t i = 0; i < kAcceleratorDataLength; ++i) { | |
| 517 ui::Accelerator accelerator(kAcceleratorData[i].keycode, | |
| 518 kAcceleratorData[i].shift, | |
| 519 kAcceleratorData[i].ctrl, | |
| 520 kAcceleratorData[i].alt); | |
| 521 accelerator.set_type(kAcceleratorData[i].trigger_on_press ? | |
| 522 ui::ET_KEY_PRESSED : ui::ET_KEY_RELEASED); | |
| 523 manager->RegisterAccelerator(accelerator, | |
| 524 ui::AcceleratorManager::kNormalPriority, | |
| 525 target); | |
|
Ben Goodger (Google)
2012/05/04 16:25:33
This injection makes me a little scared. Is there
Yusuke Sato
2012/05/07 08:27:28
Done.
On 2012/05/04 16:25:33, Ben Goodger (Google
| |
| 526 } | |
| 527 #endif | |
| 528 return manager; | |
| 529 } | |
| 530 | |
| 531 private: | |
| 532 DISALLOW_COPY_AND_ASSIGN(AshFocusManagerFactory); | |
| 533 }; | |
| 534 | |
| 501 } // namespace | 535 } // namespace |
| 502 | 536 |
| 503 // static | 537 // static |
| 504 Shell* Shell::instance_ = NULL; | 538 Shell* Shell::instance_ = NULL; |
| 505 // static | 539 // static |
| 506 bool Shell::initially_hide_cursor_ = false; | 540 bool Shell::initially_hide_cursor_ = false; |
| 507 | 541 |
| 508 //////////////////////////////////////////////////////////////////////////////// | 542 //////////////////////////////////////////////////////////////////////////////// |
| 509 // Shell::TestApi | 543 // Shell::TestApi |
| 510 | 544 |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 536 root_filter_(NULL), | 570 root_filter_(NULL), |
| 537 delegate_(delegate), | 571 delegate_(delegate), |
| 538 shelf_(NULL), | 572 shelf_(NULL), |
| 539 panel_layout_manager_(NULL), | 573 panel_layout_manager_(NULL), |
| 540 root_window_layout_(NULL) { | 574 root_window_layout_(NULL) { |
| 541 gfx::Screen::SetInstance(screen_); | 575 gfx::Screen::SetInstance(screen_); |
| 542 ui_controls::InstallUIControlsAura(CreateUIControlsAura(root_window_.get())); | 576 ui_controls::InstallUIControlsAura(CreateUIControlsAura(root_window_.get())); |
| 543 } | 577 } |
| 544 | 578 |
| 545 Shell::~Shell() { | 579 Shell::~Shell() { |
| 580 views::FocusManagerFactory::Install(NULL); | |
| 581 | |
| 546 RemoveRootWindowEventFilter(key_rewriter_filter_.get()); | 582 RemoveRootWindowEventFilter(key_rewriter_filter_.get()); |
| 547 RemoveRootWindowEventFilter(partial_screenshot_filter_.get()); | 583 RemoveRootWindowEventFilter(partial_screenshot_filter_.get()); |
| 548 RemoveRootWindowEventFilter(input_method_filter_.get()); | 584 RemoveRootWindowEventFilter(input_method_filter_.get()); |
| 549 RemoveRootWindowEventFilter(window_modality_controller_.get()); | 585 RemoveRootWindowEventFilter(window_modality_controller_.get()); |
| 550 RemoveRootWindowEventFilter(system_gesture_filter_.get()); | 586 RemoveRootWindowEventFilter(system_gesture_filter_.get()); |
| 551 #if !defined(OS_MACOSX) | 587 #if !defined(OS_MACOSX) |
| 552 RemoveRootWindowEventFilter(accelerator_filter_.get()); | 588 RemoveRootWindowEventFilter(accelerator_filter_.get()); |
| 553 #endif | 589 #endif |
| 554 | 590 |
| 555 // Close background widget now so that the focus manager of the | 591 // 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()); | 770 AddRootWindowEventFilter(tooltip_controller_.get()); |
| 735 | 771 |
| 736 drag_drop_controller_.reset(new internal::DragDropController); | 772 drag_drop_controller_.reset(new internal::DragDropController); |
| 737 magnification_controller_.reset(new internal::MagnificationController); | 773 magnification_controller_.reset(new internal::MagnificationController); |
| 738 power_button_controller_.reset(new PowerButtonController); | 774 power_button_controller_.reset(new PowerButtonController); |
| 739 AddShellObserver(power_button_controller_.get()); | 775 AddShellObserver(power_button_controller_.get()); |
| 740 video_detector_.reset(new VideoDetector); | 776 video_detector_.reset(new VideoDetector); |
| 741 window_cycle_controller_.reset(new WindowCycleController); | 777 window_cycle_controller_.reset(new WindowCycleController); |
| 742 monitor_controller_.reset(new internal::MonitorController); | 778 monitor_controller_.reset(new internal::MonitorController); |
| 743 screen_dimmer_.reset(new internal::ScreenDimmer); | 779 screen_dimmer_.reset(new internal::ScreenDimmer); |
| 780 | |
| 781 views::FocusManagerFactory::Install(new AshFocusManagerFactory); | |
| 744 } | 782 } |
| 745 | 783 |
| 746 aura::Window* Shell::GetContainer(int container_id) { | 784 aura::Window* Shell::GetContainer(int container_id) { |
| 747 return const_cast<aura::Window*>( | 785 return const_cast<aura::Window*>( |
| 748 const_cast<const Shell*>(this)->GetContainer(container_id)); | 786 const_cast<const Shell*>(this)->GetContainer(container_id)); |
| 749 } | 787 } |
| 750 | 788 |
| 751 const aura::Window* Shell::GetContainer(int container_id) const { | 789 const aura::Window* Shell::GetContainer(int container_id) const { |
| 752 return GetRootWindow()->GetChildById(container_id); | 790 return GetRootWindow()->GetChildById(container_id); |
| 753 } | 791 } |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 928 panel_container->SetLayoutManager(panel_layout_manager_); | 966 panel_container->SetLayoutManager(panel_layout_manager_); |
| 929 } | 967 } |
| 930 } | 968 } |
| 931 | 969 |
| 932 void Shell::DisableWorkspaceGridLayout() { | 970 void Shell::DisableWorkspaceGridLayout() { |
| 933 if (workspace_controller_.get()) | 971 if (workspace_controller_.get()) |
| 934 workspace_controller_->workspace_manager()->set_grid_size(0); | 972 workspace_controller_->workspace_manager()->set_grid_size(0); |
| 935 } | 973 } |
| 936 | 974 |
| 937 } // namespace ash | 975 } // namespace ash |
| OLD | NEW |