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/accelerators/accelerator_controller.h" | 5 #include "ash/accelerators/accelerator_controller.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <iostream> | 9 #include <iostream> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "ash/accelerators/accelerator_table.h" | 12 #include "ash/accelerators/accelerator_table.h" |
13 #include "ash/accelerators/exit_warning_handler.h" | |
13 #include "ash/ash_switches.h" | 14 #include "ash/ash_switches.h" |
14 #include "ash/caps_lock_delegate.h" | 15 #include "ash/caps_lock_delegate.h" |
15 #include "ash/debug.h" | 16 #include "ash/debug.h" |
16 #include "ash/desktop_background/desktop_background_controller.h" | 17 #include "ash/desktop_background/desktop_background_controller.h" |
17 #include "ash/desktop_background/user_wallpaper_delegate.h" | 18 #include "ash/desktop_background/user_wallpaper_delegate.h" |
18 #include "ash/display/display_controller.h" | 19 #include "ash/display/display_controller.h" |
19 #include "ash/display/display_manager.h" | 20 #include "ash/display/display_manager.h" |
20 #include "ash/focus_cycler.h" | 21 #include "ash/focus_cycler.h" |
21 #include "ash/ime_control_delegate.h" | 22 #include "ash/ime_control_delegate.h" |
22 #include "ash/launcher/launcher.h" | 23 #include "ash/launcher/launcher.h" |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
361 void AcceleratorControllerContext::UpdateContext( | 362 void AcceleratorControllerContext::UpdateContext( |
362 const ui::Accelerator& accelerator) { | 363 const ui::Accelerator& accelerator) { |
363 previous_accelerator_ = current_accelerator_; | 364 previous_accelerator_ = current_accelerator_; |
364 current_accelerator_ = accelerator; | 365 current_accelerator_ = accelerator; |
365 } | 366 } |
366 | 367 |
367 //////////////////////////////////////////////////////////////////////////////// | 368 //////////////////////////////////////////////////////////////////////////////// |
368 // AcceleratorController, public: | 369 // AcceleratorController, public: |
369 | 370 |
370 AcceleratorController::AcceleratorController() | 371 AcceleratorController::AcceleratorController() |
371 : accelerator_manager_(new ui::AcceleratorManager) { | 372 : accelerator_manager_(new ui::AcceleratorManager), |
373 exit_warning_handler_(new ExitWarningHandler) { | |
sky
2013/05/13 15:40:32
If the lifetime of ExitWarningHandler is that of A
sschmitz
2013/05/14 16:49:11
Done.
| |
372 Init(); | 374 Init(); |
373 } | 375 } |
374 | 376 |
375 AcceleratorController::~AcceleratorController() { | 377 AcceleratorController::~AcceleratorController() { |
376 } | 378 } |
377 | 379 |
378 void AcceleratorController::Init() { | 380 void AcceleratorController::Init() { |
379 for (size_t i = 0; i < kActionsAllowedAtLoginOrLockScreenLength; ++i) { | 381 for (size_t i = 0; i < kActionsAllowedAtLoginOrLockScreenLength; ++i) { |
380 actions_allowed_at_login_screen_.insert( | 382 actions_allowed_at_login_screen_.insert( |
381 kActionsAllowedAtLoginOrLockScreen[i]); | 383 kActionsAllowedAtLoginOrLockScreen[i]); |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
567 } | 569 } |
568 return false; | 570 return false; |
569 } | 571 } |
570 case DISABLE_GPU_WATCHDOG: | 572 case DISABLE_GPU_WATCHDOG: |
571 content::GpuDataManager::GetInstance()->DisableGpuWatchdog(); | 573 content::GpuDataManager::GetInstance()->DisableGpuWatchdog(); |
572 return true; | 574 return true; |
573 #endif | 575 #endif |
574 case OPEN_FEEDBACK_PAGE: | 576 case OPEN_FEEDBACK_PAGE: |
575 ash::Shell::GetInstance()->delegate()->OpenFeedbackPage(); | 577 ash::Shell::GetInstance()->delegate()->OpenFeedbackPage(); |
576 return true; | 578 return true; |
577 case EXIT: | 579 case EXIT_PRESSED: |
578 Shell::GetInstance()->delegate()->Exit(); | 580 case EXIT_RELEASED: |
581 exit_warning_handler_->HandleExitKey(action == EXIT_PRESSED); | |
579 return true; | 582 return true; |
580 case NEW_INCOGNITO_WINDOW: | 583 case NEW_INCOGNITO_WINDOW: |
581 Shell::GetInstance()->delegate()->NewWindow(true /* is_incognito */); | 584 Shell::GetInstance()->delegate()->NewWindow(true /* is_incognito */); |
582 return true; | 585 return true; |
583 case NEW_TAB: | 586 case NEW_TAB: |
584 if (key_code == ui::VKEY_T) | 587 if (key_code == ui::VKEY_T) |
585 shell->delegate()->RecordUserMetricsAction(UMA_ACCEL_NEWTAB_T); | 588 shell->delegate()->RecordUserMetricsAction(UMA_ACCEL_NEWTAB_T); |
586 Shell::GetInstance()->delegate()->NewTab(); | 589 Shell::GetInstance()->delegate()->NewTab(); |
587 return true; | 590 return true; |
588 case NEW_WINDOW: | 591 case NEW_WINDOW: |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
961 keyboard_brightness_control_delegate) { | 964 keyboard_brightness_control_delegate) { |
962 keyboard_brightness_control_delegate_ = | 965 keyboard_brightness_control_delegate_ = |
963 keyboard_brightness_control_delegate.Pass(); | 966 keyboard_brightness_control_delegate.Pass(); |
964 } | 967 } |
965 | 968 |
966 bool AcceleratorController::CanHandleAccelerators() const { | 969 bool AcceleratorController::CanHandleAccelerators() const { |
967 return true; | 970 return true; |
968 } | 971 } |
969 | 972 |
970 } // namespace ash | 973 } // namespace ash |
OLD | NEW |