Commit df99bbce authored by pkotwicz's avatar pkotwicz Committed by Commit bot

This CL:

- Alphabetises the switch statement in AcceleratorController::PerformAction()
- Removes "default" from switch statement in
  AcceleratorController::PerformAction()
- Makes several methods in AcceleratorController take AcceleratorAction instead
  of int as input
- Rearranges methods in accelerator_controller.cc to match order in .h file

BUG=404473
TEST=None
R=oshima
TBR=sky (For trivial addition of ifdef to chrome/browser/ui/views/accelerator_table.cc)

Review URL: https://codereview.chromium.org/729993002

Cr-Commit-Position: refs/heads/master@{#305066}
parent 03cbc9db
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
#include <string> #include <string>
#include "ash/accelerators/accelerator_commands.h" #include "ash/accelerators/accelerator_commands.h"
#include "ash/accelerators/accelerator_table.h"
#include "ash/accelerators/debug_commands.h" #include "ash/accelerators/debug_commands.h"
#include "ash/ash_switches.h" #include "ash/ash_switches.h"
#include "ash/debug.h" #include "ash/debug.h"
...@@ -127,9 +126,21 @@ bool HandleCycleForwardMRU(const ui::Accelerator& accelerator) { ...@@ -127,9 +126,21 @@ bool HandleCycleForwardMRU(const ui::Accelerator& accelerator) {
return true; return true;
} }
bool ToggleOverview(const ui::Accelerator& accelerator) { bool HandleRotatePaneFocus(Shell::Direction direction) {
base::RecordAction(base::UserMetricsAction("Accel_Overview_F5")); Shell* shell = Shell::GetInstance();
Shell::GetInstance()->window_selector_controller()->ToggleOverview(); switch (direction) {
// TODO(stevet): Not sure if this is the same as IDC_FOCUS_NEXT_PANE.
case Shell::FORWARD: {
base::RecordAction(UserMetricsAction("Accel_Focus_Next_Pane"));
shell->focus_cycler()->RotateFocus(FocusCycler::FORWARD);
break;
}
case Shell::BACKWARD: {
base::RecordAction(UserMetricsAction("Accel_Focus_Previous_Pane"));
shell->focus_cycler()->RotateFocus(FocusCycler::BACKWARD);
break;
}
}
return true; return true;
} }
...@@ -247,17 +258,6 @@ bool HandleOpenFeedbackPage() { ...@@ -247,17 +258,6 @@ bool HandleOpenFeedbackPage() {
return true; return true;
} }
bool HandlePositionCenter() {
base::RecordAction(UserMetricsAction("Accel_Window_Position_Center"));
aura::Window* window = wm::GetActiveWindow();
// Docked windows do not support centering and ignore accelerator.
if (window && !wm::GetWindowState(window)->IsDocked()) {
wm::CenterWindow(window);
return true;
}
return false;
}
bool HandlePreviousIme(ImeControlDelegate* ime_control_delegate, bool HandlePreviousIme(ImeControlDelegate* ime_control_delegate,
const ui::Accelerator& accelerator) { const ui::Accelerator& accelerator) {
base::RecordAction(UserMetricsAction("Accel_Previous_Ime")); base::RecordAction(UserMetricsAction("Accel_Previous_Ime"));
...@@ -272,42 +272,6 @@ bool HandleRestoreTab() { ...@@ -272,42 +272,6 @@ bool HandleRestoreTab() {
return true; return true;
} }
bool HandleRotatePaneFocus(Shell::Direction direction) {
Shell* shell = Shell::GetInstance();
switch (direction) {
// TODO(stevet): Not sure if this is the same as IDC_FOCUS_NEXT_PANE.
case Shell::FORWARD: {
base::RecordAction(UserMetricsAction("Accel_Focus_Next_Pane"));
shell->focus_cycler()->RotateFocus(FocusCycler::FORWARD);
break;
}
case Shell::BACKWARD: {
base::RecordAction(UserMetricsAction("Accel_Focus_Previous_Pane"));
shell->focus_cycler()->RotateFocus(FocusCycler::BACKWARD);
break;
}
}
return true;
}
// Rotate the active window.
bool HandleRotateActiveWindow() {
base::RecordAction(UserMetricsAction("Accel_Rotate_Window"));
aura::Window* active_window = wm::GetActiveWindow();
if (active_window) {
// The rotation animation bases its target transform on the current
// rotation and position. Since there could be an animation in progress
// right now, queue this animation so when it starts it picks up a neutral
// rotation and position. Use replace so we only enqueue one at a time.
active_window->layer()->GetAnimator()->
set_preemption_strategy(ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS);
active_window->layer()->GetAnimator()->StartAnimation(
new ui::LayerAnimationSequence(
new ash::ScreenRotation(360, active_window->layer())));
}
return true;
}
gfx::Display::Rotation GetNextRotation(gfx::Display::Rotation current) { gfx::Display::Rotation GetNextRotation(gfx::Display::Rotation current) {
switch (current) { switch (current) {
case gfx::Display::ROTATE_0: case gfx::Display::ROTATE_0:
...@@ -335,6 +299,24 @@ bool HandleRotateScreen() { ...@@ -335,6 +299,24 @@ bool HandleRotateScreen() {
return true; return true;
} }
// Rotate the active window.
bool HandleRotateActiveWindow() {
base::RecordAction(UserMetricsAction("Accel_Rotate_Window"));
aura::Window* active_window = wm::GetActiveWindow();
if (active_window) {
// The rotation animation bases its target transform on the current
// rotation and position. Since there could be an animation in progress
// right now, queue this animation so when it starts it picks up a neutral
// rotation and position. Use replace so we only enqueue one at a time.
active_window->layer()->GetAnimator()->
set_preemption_strategy(ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS);
active_window->layer()->GetAnimator()->StartAnimation(
new ui::LayerAnimationSequence(
new ash::ScreenRotation(360, active_window->layer())));
}
return true;
}
bool HandleScaleReset() { bool HandleScaleReset() {
DisplayManager* display_manager = Shell::GetInstance()->display_manager(); DisplayManager* display_manager = Shell::GetInstance()->display_manager();
int64 display_id = display_manager->GetDisplayIdForUIScaling(); int64 display_id = display_manager->GetDisplayIdForUIScaling();
...@@ -370,14 +352,6 @@ bool HandleScaleUI(bool up) { ...@@ -370,14 +352,6 @@ bool HandleScaleUI(bool up) {
return true; return true;
} }
#if defined(OS_CHROMEOS)
bool HandleSwapPrimaryDisplay() {
base::RecordAction(UserMetricsAction("Accel_Swap_Primary_Display"));
Shell::GetInstance()->display_controller()->SwapPrimaryDisplay();
return true;
}
#endif
bool HandleShowKeyboardOverlay() { bool HandleShowKeyboardOverlay() {
base::RecordAction(UserMetricsAction("Accel_Show_Keyboard_Overlay")); base::RecordAction(UserMetricsAction("Accel_Show_Keyboard_Overlay"));
ash::Shell::GetInstance()->new_window_delegate()->ShowKeyboardOverlay(); ash::Shell::GetInstance()->new_window_delegate()->ShowKeyboardOverlay();
...@@ -419,18 +393,6 @@ bool HandleShowTaskManager() { ...@@ -419,18 +393,6 @@ bool HandleShowTaskManager() {
return true; return true;
} }
#if defined(OS_CHROMEOS)
void HandleSilenceSpokenFeedback() {
base::RecordAction(UserMetricsAction("Accel_Silence_Spoken_Feedback"));
AccessibilityDelegate* delegate =
Shell::GetInstance()->accessibility_delegate();
if (!delegate->IsSpokenFeedbackEnabled())
return;
delegate->SilenceSpokenFeedback();
}
#endif
bool HandleSwitchIme(ImeControlDelegate* ime_control_delegate, bool HandleSwitchIme(ImeControlDelegate* ime_control_delegate,
const ui::Accelerator& accelerator) { const ui::Accelerator& accelerator) {
base::RecordAction(UserMetricsAction("Accel_Switch_Ime")); base::RecordAction(UserMetricsAction("Accel_Switch_Ime"));
...@@ -492,7 +454,13 @@ bool HandleToggleFullscreen(ui::KeyboardCode key_code) { ...@@ -492,7 +454,13 @@ bool HandleToggleFullscreen(ui::KeyboardCode key_code) {
return true; return true;
} }
bool HandleWindowSnapOrDock(int action) { bool HandleToggleOverview(const ui::Accelerator& accelerator) {
base::RecordAction(base::UserMetricsAction("Accel_Overview_F5"));
Shell::GetInstance()->window_selector_controller()->ToggleOverview();
return true;
}
bool HandleWindowSnapOrDock(AcceleratorAction action) {
wm::WindowState* window_state = wm::GetActiveWindowState(); wm::WindowState* window_state = wm::GetActiveWindowState();
// Disable window snapping shortcut key for full screen window due to // Disable window snapping shortcut key for full screen window due to
// http://crbug.com/135487. // http://crbug.com/135487.
...@@ -521,7 +489,47 @@ bool HandleWindowMinimize() { ...@@ -521,7 +489,47 @@ bool HandleWindowMinimize() {
return accelerators::ToggleMinimized(); return accelerators::ToggleMinimized();
} }
bool HandlePositionCenter() {
base::RecordAction(UserMetricsAction("Accel_Window_Position_Center"));
aura::Window* window = wm::GetActiveWindow();
// Docked windows do not support centering and ignore accelerator.
if (window && !wm::GetWindowState(window)->IsDocked()) {
wm::CenterWindow(window);
return true;
}
return false;
}
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
bool HandleDisableCapsLock(ui::KeyboardCode key_code,
ui::EventType previous_event_type,
ui::KeyboardCode previous_key_code) {
if (previous_event_type == ui::ET_KEY_RELEASED ||
(previous_key_code != ui::VKEY_LSHIFT &&
previous_key_code != ui::VKEY_SHIFT &&
previous_key_code != ui::VKEY_RSHIFT)) {
// If something else was pressed between the Shift key being pressed
// and released, then ignore the release of the Shift key.
return false;
}
base::RecordAction(UserMetricsAction("Accel_Disable_Caps_Lock"));
chromeos::input_method::InputMethodManager* ime =
chromeos::input_method::InputMethodManager::Get();
chromeos::input_method::ImeKeyboard* keyboard =
ime ? ime->GetImeKeyboard() : NULL;
if (keyboard && keyboard->CapsLockIsEnabled()) {
keyboard->SetCapsLockEnabled(false);
return true;
}
return false;
}
bool HandleLock(ui::KeyboardCode key_code) {
base::RecordAction(UserMetricsAction("Accel_LockScreen_L"));
Shell::GetInstance()->session_state_delegate()->LockScreen();
return true;
}
bool HandleCrosh() { bool HandleCrosh() {
base::RecordAction(UserMetricsAction("Accel_Open_Crosh")); base::RecordAction(UserMetricsAction("Accel_Open_Crosh"));
...@@ -536,9 +544,19 @@ bool HandleFileManager() { ...@@ -536,9 +544,19 @@ bool HandleFileManager() {
return true; return true;
} }
bool HandleLock(ui::KeyboardCode key_code) { void HandleSilenceSpokenFeedback() {
base::RecordAction(UserMetricsAction("Accel_LockScreen_L")); base::RecordAction(UserMetricsAction("Accel_Silence_Spoken_Feedback"));
Shell::GetInstance()->session_state_delegate()->LockScreen();
AccessibilityDelegate* delegate =
Shell::GetInstance()->accessibility_delegate();
if (!delegate->IsSpokenFeedbackEnabled())
return;
delegate->SilenceSpokenFeedback();
}
bool HandleSwapPrimaryDisplay() {
base::RecordAction(UserMetricsAction("Accel_Swap_Primary_Display"));
Shell::GetInstance()->display_controller()->SwapPrimaryDisplay();
return true; return true;
} }
...@@ -563,6 +581,28 @@ bool HandleCycleUser(SessionStateDelegate::CycleUser cycle_user) { ...@@ -563,6 +581,28 @@ bool HandleCycleUser(SessionStateDelegate::CycleUser cycle_user) {
return true; return true;
} }
bool HandleToggleCapsLock(ui::KeyboardCode key_code,
ui::EventType previous_event_type,
ui::KeyboardCode previous_key_code) {
if (key_code == ui::VKEY_LWIN) {
// If something else was pressed between the Search key (LWIN)
// being pressed and released, then ignore the release of the
// Search key.
// TODO(danakj): Releasing Alt first breaks this: crbug.com/166495
if (previous_event_type == ui::ET_KEY_RELEASED ||
previous_key_code != ui::VKEY_LWIN)
return false;
}
base::RecordAction(UserMetricsAction("Accel_Toggle_Caps_Lock"));
chromeos::input_method::InputMethodManager* ime =
chromeos::input_method::InputMethodManager::Get();
chromeos::input_method::ImeKeyboard* keyboard =
ime ? ime->GetImeKeyboard() : NULL;
if (keyboard)
keyboard->SetCapsLockEnabled(!keyboard->CapsLockIsEnabled());
return true;
}
bool HandleToggleMirrorMode() { bool HandleToggleMirrorMode() {
base::RecordAction(UserMetricsAction("Accel_Toggle_Mirror_Mode")); base::RecordAction(UserMetricsAction("Accel_Toggle_Mirror_Mode"));
Shell::GetInstance()->display_controller()->ToggleMirrorMode(); Shell::GetInstance()->display_controller()->ToggleMirrorMode();
...@@ -610,51 +650,6 @@ bool HandleTouchHudModeChange() { ...@@ -610,51 +650,6 @@ bool HandleTouchHudModeChange() {
return false; return false;
} }
bool HandleDisableCapsLock(ui::KeyboardCode key_code,
ui::EventType previous_event_type,
ui::KeyboardCode previous_key_code) {
if (previous_event_type == ui::ET_KEY_RELEASED ||
(previous_key_code != ui::VKEY_LSHIFT &&
previous_key_code != ui::VKEY_SHIFT &&
previous_key_code != ui::VKEY_RSHIFT)) {
// If something else was pressed between the Shift key being pressed
// and released, then ignore the release of the Shift key.
return false;
}
base::RecordAction(UserMetricsAction("Accel_Disable_Caps_Lock"));
chromeos::input_method::InputMethodManager* ime =
chromeos::input_method::InputMethodManager::Get();
chromeos::input_method::ImeKeyboard* keyboard =
ime ? ime->GetImeKeyboard() : NULL;
if (keyboard && keyboard->CapsLockIsEnabled()) {
keyboard->SetCapsLockEnabled(false);
return true;
}
return false;
}
bool HandleToggleCapsLock(ui::KeyboardCode key_code,
ui::EventType previous_event_type,
ui::KeyboardCode previous_key_code) {
if (key_code == ui::VKEY_LWIN) {
// If something else was pressed between the Search key (LWIN)
// being pressed and released, then ignore the release of the
// Search key.
// TODO(danakj): Releasing Alt first breaks this: crbug.com/166495
if (previous_event_type == ui::ET_KEY_RELEASED ||
previous_key_code != ui::VKEY_LWIN)
return false;
}
base::RecordAction(UserMetricsAction("Accel_Toggle_Caps_Lock"));
chromeos::input_method::InputMethodManager* ime =
chromeos::input_method::InputMethodManager::Get();
chromeos::input_method::ImeKeyboard* keyboard =
ime ? ime->GetImeKeyboard() : NULL;
if (keyboard)
keyboard->SetCapsLockEnabled(!keyboard->CapsLockIsEnabled());
return true;
}
#endif // defined(OS_CHROMEOS) #endif // defined(OS_CHROMEOS)
class AutoSet { class AutoSet {
...@@ -683,44 +678,6 @@ AcceleratorController::AcceleratorController() ...@@ -683,44 +678,6 @@ AcceleratorController::AcceleratorController()
AcceleratorController::~AcceleratorController() { AcceleratorController::~AcceleratorController() {
} }
void AcceleratorController::Init() {
previous_accelerator_.set_type(ui::ET_UNKNOWN);
for (size_t i = 0; i < kActionsAllowedAtLoginOrLockScreenLength; ++i) {
actions_allowed_at_login_screen_.insert(
kActionsAllowedAtLoginOrLockScreen[i]);
actions_allowed_at_lock_screen_.insert(
kActionsAllowedAtLoginOrLockScreen[i]);
}
for (size_t i = 0; i < kActionsAllowedAtLockScreenLength; ++i)
actions_allowed_at_lock_screen_.insert(kActionsAllowedAtLockScreen[i]);
for (size_t i = 0; i < kActionsAllowedAtModalWindowLength; ++i)
actions_allowed_at_modal_window_.insert(kActionsAllowedAtModalWindow[i]);
for (size_t i = 0; i < kPreferredActionsLength; ++i)
preferred_actions_.insert(kPreferredActions[i]);
for (size_t i = 0; i < kReservedActionsLength; ++i)
reserved_actions_.insert(kReservedActions[i]);
for (size_t i = 0; i < kNonrepeatableActionsLength; ++i)
nonrepeatable_actions_.insert(kNonrepeatableActions[i]);
for (size_t i = 0; i < kActionsAllowedInAppModeLength; ++i)
actions_allowed_in_app_mode_.insert(kActionsAllowedInAppMode[i]);
for (size_t i = 0; i < kActionsNeedingWindowLength; ++i)
actions_needing_window_.insert(kActionsNeedingWindow[i]);
RegisterAccelerators(kAcceleratorData, kAcceleratorDataLength);
if (debug::DebugAcceleratorsEnabled()) {
RegisterAccelerators(kDebugAcceleratorData, kDebugAcceleratorDataLength);
// All debug accelerators are reserved.
for (size_t i = 0; i < kDebugAcceleratorDataLength; ++i)
reserved_actions_.insert(kDebugAcceleratorData[i].action);
}
#if defined(OS_CHROMEOS)
keyboard_brightness_control_delegate_.reset(
new KeyboardBrightnessController());
#endif
}
void AcceleratorController::Register(const ui::Accelerator& accelerator, void AcceleratorController::Register(const ui::Accelerator& accelerator,
ui::AcceleratorTarget* target) { ui::AcceleratorTarget* target) {
accelerator_manager_->Register(accelerator, accelerator_manager_->Register(accelerator,
...@@ -757,7 +714,7 @@ bool AcceleratorController::IsPreferred( ...@@ -757,7 +714,7 @@ bool AcceleratorController::IsPreferred(
const ui::Accelerator remapped_accelerator = ime_control_delegate_.get() ? const ui::Accelerator remapped_accelerator = ime_control_delegate_.get() ?
ime_control_delegate_->RemapAccelerator(accelerator) : accelerator; ime_control_delegate_->RemapAccelerator(accelerator) : accelerator;
std::map<ui::Accelerator, int>::const_iterator iter = std::map<ui::Accelerator, AcceleratorAction>::const_iterator iter =
accelerators_.find(remapped_accelerator); accelerators_.find(remapped_accelerator);
if (iter == accelerators_.end()) if (iter == accelerators_.end())
return false; // not an accelerator. return false; // not an accelerator.
...@@ -770,7 +727,7 @@ bool AcceleratorController::IsReserved( ...@@ -770,7 +727,7 @@ bool AcceleratorController::IsReserved(
const ui::Accelerator remapped_accelerator = ime_control_delegate_.get() ? const ui::Accelerator remapped_accelerator = ime_control_delegate_.get() ?
ime_control_delegate_->RemapAccelerator(accelerator) : accelerator; ime_control_delegate_->RemapAccelerator(accelerator) : accelerator;
std::map<ui::Accelerator, int>::const_iterator iter = std::map<ui::Accelerator, AcceleratorAction>::const_iterator iter =
accelerators_.find(remapped_accelerator); accelerators_.find(remapped_accelerator);
if (iter == accelerators_.end()) if (iter == accelerators_.end())
return false; // not an accelerator. return false; // not an accelerator.
...@@ -778,11 +735,101 @@ bool AcceleratorController::IsReserved( ...@@ -778,11 +735,101 @@ bool AcceleratorController::IsReserved(
return reserved_actions_.find(iter->second) != reserved_actions_.end(); return reserved_actions_.find(iter->second) != reserved_actions_.end();
} }
bool AcceleratorController::PerformActionIfEnabled(int action) { bool AcceleratorController::PerformActionIfEnabled(AcceleratorAction action) {
return PerformAction(action, ui::Accelerator()); return PerformAction(action, ui::Accelerator());
} }
bool AcceleratorController::PerformAction(int action, AcceleratorController::AcceleratorProcessingRestriction
AcceleratorController::GetCurrentAcceleratorRestriction() {
return GetAcceleratorProcessingRestriction(-1);
}
void AcceleratorController::SetBrightnessControlDelegate(
scoped_ptr<BrightnessControlDelegate> brightness_control_delegate) {
brightness_control_delegate_ = brightness_control_delegate.Pass();
}
void AcceleratorController::SetImeControlDelegate(
scoped_ptr<ImeControlDelegate> ime_control_delegate) {
ime_control_delegate_ = ime_control_delegate.Pass();
}
void AcceleratorController::SetScreenshotDelegate(
scoped_ptr<ScreenshotDelegate> screenshot_delegate) {
screenshot_delegate_ = screenshot_delegate.Pass();
}
////////////////////////////////////////////////////////////////////////////////
// AcceleratorController, ui::AcceleratorTarget implementation:
bool AcceleratorController::AcceleratorPressed(
const ui::Accelerator& accelerator) {
std::map<ui::Accelerator, AcceleratorAction>::const_iterator it =
accelerators_.find(accelerator);
DCHECK(it != accelerators_.end());
return PerformAction(it->second, accelerator);
}
bool AcceleratorController::CanHandleAccelerators() const {
return true;
}
///////////////////////////////////////////////////////////////////////////////
// AcceleratorController, private:
void AcceleratorController::Init() {
previous_accelerator_.set_type(ui::ET_UNKNOWN);
for (size_t i = 0; i < kActionsAllowedAtLoginOrLockScreenLength; ++i) {
actions_allowed_at_login_screen_.insert(
kActionsAllowedAtLoginOrLockScreen[i]);
actions_allowed_at_lock_screen_.insert(
kActionsAllowedAtLoginOrLockScreen[i]);
}
for (size_t i = 0; i < kActionsAllowedAtLockScreenLength; ++i)
actions_allowed_at_lock_screen_.insert(kActionsAllowedAtLockScreen[i]);
for (size_t i = 0; i < kActionsAllowedAtModalWindowLength; ++i)
actions_allowed_at_modal_window_.insert(kActionsAllowedAtModalWindow[i]);
for (size_t i = 0; i < kPreferredActionsLength; ++i)
preferred_actions_.insert(kPreferredActions[i]);
for (size_t i = 0; i < kReservedActionsLength; ++i)
reserved_actions_.insert(kReservedActions[i]);
for (size_t i = 0; i < kNonrepeatableActionsLength; ++i)
nonrepeatable_actions_.insert(kNonrepeatableActions[i]);
for (size_t i = 0; i < kActionsAllowedInAppModeLength; ++i)
actions_allowed_in_app_mode_.insert(kActionsAllowedInAppMode[i]);
for (size_t i = 0; i < kActionsNeedingWindowLength; ++i)
actions_needing_window_.insert(kActionsNeedingWindow[i]);
RegisterAccelerators(kAcceleratorData, kAcceleratorDataLength);
if (debug::DebugAcceleratorsEnabled()) {
RegisterAccelerators(kDebugAcceleratorData, kDebugAcceleratorDataLength);
// All debug accelerators are reserved.
for (size_t i = 0; i < kDebugAcceleratorDataLength; ++i)
reserved_actions_.insert(kDebugAcceleratorData[i].action);
}
#if defined(OS_CHROMEOS)
keyboard_brightness_control_delegate_.reset(
new KeyboardBrightnessController());
#endif
}
void AcceleratorController::RegisterAccelerators(
const AcceleratorData accelerators[],
size_t accelerators_length) {
for (size_t i = 0; i < accelerators_length; ++i) {
ui::Accelerator accelerator(accelerators[i].keycode,
accelerators[i].modifiers);
accelerator.set_type(accelerators[i].trigger_on_press ?
ui::ET_KEY_PRESSED : ui::ET_KEY_RELEASED);
Register(accelerator, this);
accelerators_.insert(
std::make_pair(accelerator, accelerators[i].action));
}
}
bool AcceleratorController::PerformAction(AcceleratorAction action,
const ui::Accelerator& accelerator) { const ui::Accelerator& accelerator) {
ash::Shell* shell = ash::Shell::GetInstance(); ash::Shell* shell = ash::Shell::GetInstance();
AcceleratorProcessingRestriction restriction = AcceleratorProcessingRestriction restriction =
...@@ -813,75 +860,6 @@ bool AcceleratorController::PerformAction(int action, ...@@ -813,75 +860,6 @@ bool AcceleratorController::PerformAction(int action,
return HandleAccessibleFocusCycle(false); return HandleAccessibleFocusCycle(false);
case ACCESSIBLE_FOCUS_PREVIOUS: case ACCESSIBLE_FOCUS_PREVIOUS:
return HandleAccessibleFocusCycle(true); return HandleAccessibleFocusCycle(true);
case CYCLE_BACKWARD_MRU:
return HandleCycleBackwardMRU(accelerator);
case CYCLE_FORWARD_MRU:
return HandleCycleForwardMRU(accelerator);
case TOGGLE_OVERVIEW:
return ToggleOverview(accelerator);
#if defined(OS_CHROMEOS)
case TOGGLE_MIRROR_MODE:
return HandleToggleMirrorMode();
case LOCK_SCREEN:
return HandleLock(key_code);
case OPEN_FILE_MANAGER:
return HandleFileManager();
case OPEN_CROSH:
return HandleCrosh();
case SILENCE_SPOKEN_FEEDBACK:
HandleSilenceSpokenFeedback();
return false;
case SWAP_PRIMARY_DISPLAY:
return HandleSwapPrimaryDisplay();
case SWITCH_TO_NEXT_USER:
return HandleCycleUser(SessionStateDelegate::CYCLE_TO_NEXT_USER);
case SWITCH_TO_PREVIOUS_USER:
return HandleCycleUser(SessionStateDelegate::CYCLE_TO_PREVIOUS_USER);
case TOGGLE_SPOKEN_FEEDBACK:
return HandleToggleSpokenFeedback();
case TOGGLE_TOUCH_VIEW_TESTING:
return HandleToggleTouchViewTesting();
case TOGGLE_WIFI:
Shell::GetInstance()->system_tray_notifier()->NotifyRequestToggleWifi();
return true;
case TOUCH_HUD_CLEAR:
return HandleTouchHudClear();
case TOUCH_HUD_MODE_CHANGE:
return HandleTouchHudModeChange();
case TOUCH_HUD_PROJECTION_TOGGLE:
accelerators::ToggleTouchHudProjection();
return true;
case DISABLE_GPU_WATCHDOG:
Shell::GetInstance()->gpu_support()->DisableGpuWatchdog();
return true;
case DISABLE_CAPS_LOCK:
return HandleDisableCapsLock(
key_code, previous_event_type, previous_key_code);
case TOGGLE_CAPS_LOCK:
return HandleToggleCapsLock(
key_code, previous_event_type, previous_key_code);
#endif // OS_CHROMEOS
case OPEN_FEEDBACK_PAGE:
return HandleOpenFeedbackPage();
case EXIT:
// UMA metrics are recorded in the handler.
exit_warning_handler_.HandleAccelerator();
return true;
case NEW_INCOGNITO_WINDOW:
return HandleNewIncognitoWindow();
case NEW_TAB:
return HandleNewTab(key_code);
case NEW_WINDOW:
return HandleNewWindow();
case RESTORE_TAB:
return HandleRestoreTab();
case TAKE_SCREENSHOT:
return HandleTakeScreenshot(screenshot_delegate_.get());
case TAKE_PARTIAL_SCREENSHOT:
return HandleTakePartialScreenshot(screenshot_delegate_.get());
case TOGGLE_APP_LIST:
return HandleToggleAppList(
key_code, previous_event_type, previous_key_code, accelerator);
case BRIGHTNESS_DOWN: case BRIGHTNESS_DOWN:
if (brightness_control_delegate_) if (brightness_control_delegate_)
return brightness_control_delegate_->HandleBrightnessDown(accelerator); return brightness_control_delegate_->HandleBrightnessDown(accelerator);
...@@ -890,58 +868,30 @@ bool AcceleratorController::PerformAction(int action, ...@@ -890,58 +868,30 @@ bool AcceleratorController::PerformAction(int action,
if (brightness_control_delegate_) if (brightness_control_delegate_)
return brightness_control_delegate_->HandleBrightnessUp(accelerator); return brightness_control_delegate_->HandleBrightnessUp(accelerator);
return false; return false;
case KEYBOARD_BRIGHTNESS_DOWN: case CYCLE_BACKWARD_MRU:
if (keyboard_brightness_control_delegate_) return HandleCycleBackwardMRU(accelerator);
return keyboard_brightness_control_delegate_-> case CYCLE_FORWARD_MRU:
HandleKeyboardBrightnessDown(accelerator); return HandleCycleForwardMRU(accelerator);
return false; case DEBUG_PRINT_LAYER_HIERARCHY:
case KEYBOARD_BRIGHTNESS_UP: case DEBUG_PRINT_VIEW_HIERARCHY:
if (keyboard_brightness_control_delegate_) case DEBUG_PRINT_WINDOW_HIERARCHY:
return keyboard_brightness_control_delegate_-> case DEBUG_TOGGLE_DESKTOP_BACKGROUND_MODE:
HandleKeyboardBrightnessUp(accelerator); case DEBUG_TOGGLE_DEVICE_SCALE_FACTOR:
return false; case DEBUG_TOGGLE_ROOT_WINDOW_FULL_SCREEN:
case VOLUME_MUTE: { case DEBUG_TOGGLE_SHOW_DEBUG_BORDERS:
ash::VolumeControlDelegate* volume_delegate = case DEBUG_TOGGLE_SHOW_FPS_COUNTER:
shell->system_tray_delegate()->GetVolumeControlDelegate(); case DEBUG_TOGGLE_SHOW_PAINT_RECTS:
return volume_delegate && volume_delegate->HandleVolumeMute(accelerator); return debug::PerformDebugAction(action);
} case EXIT:
case VOLUME_DOWN: { // UMA metrics are recorded in the handler.
ash::VolumeControlDelegate* volume_delegate = exit_warning_handler_.HandleAccelerator();
shell->system_tray_delegate()->GetVolumeControlDelegate(); return true;
return volume_delegate && volume_delegate->HandleVolumeDown(accelerator);
}
case VOLUME_UP: {
ash::VolumeControlDelegate* volume_delegate =
shell->system_tray_delegate()->GetVolumeControlDelegate();
return volume_delegate && volume_delegate->HandleVolumeUp(accelerator);
}
case FOCUS_SHELF:
return HandleFocusShelf();
case FOCUS_NEXT_PANE: case FOCUS_NEXT_PANE:
return HandleRotatePaneFocus(Shell::FORWARD); return HandleRotatePaneFocus(Shell::FORWARD);
case FOCUS_PREVIOUS_PANE: case FOCUS_PREVIOUS_PANE:
return HandleRotatePaneFocus(Shell::BACKWARD); return HandleRotatePaneFocus(Shell::BACKWARD);
case SHOW_KEYBOARD_OVERLAY: case FOCUS_SHELF:
return HandleShowKeyboardOverlay(); return HandleFocusShelf();
case SHOW_SYSTEM_TRAY_BUBBLE:
return HandleShowSystemTrayBubble();
case SHOW_MESSAGE_CENTER_BUBBLE:
return HandleShowMessageCenterBubble();
case SHOW_TASK_MANAGER:
return HandleShowTaskManager();
case NEXT_IME:
HandleNextIme(
ime_control_delegate_.get(), previous_event_type, previous_key_code);
// NEXT_IME is bound to Alt-Shift key up event. To be consistent with
// Windows behavior, do not consume the key event here.
return false;
case PREVIOUS_IME:
return HandlePreviousIme(ime_control_delegate_.get(), accelerator);
case PRINT_UI_HIERARCHIES:
debug::PrintUIHierarchies();
return true;
case SWITCH_IME:
return HandleSwitchIme(ime_control_delegate_.get(), accelerator);
case LAUNCH_APP_0: case LAUNCH_APP_0:
return HandleLaunchAppN(0); return HandleLaunchAppN(0);
case LAUNCH_APP_1: case LAUNCH_APP_1:
...@@ -960,28 +910,6 @@ bool AcceleratorController::PerformAction(int action, ...@@ -960,28 +910,6 @@ bool AcceleratorController::PerformAction(int action,
return HandleLaunchAppN(7); return HandleLaunchAppN(7);
case LAUNCH_LAST_APP: case LAUNCH_LAST_APP:
return HandleLaunchLastApp(); return HandleLaunchLastApp();
case WINDOW_CYCLE_SNAP_DOCK_LEFT:
case WINDOW_CYCLE_SNAP_DOCK_RIGHT:
return HandleWindowSnapOrDock(action);
case WINDOW_MINIMIZE:
return HandleWindowMinimize();
case TOGGLE_FULLSCREEN:
return HandleToggleFullscreen(key_code);
case TOGGLE_MAXIMIZED:
accelerators::ToggleMaximized();
return true;
case WINDOW_POSITION_CENTER:
return HandlePositionCenter();
case SCALE_UI_UP:
return HandleScaleUI(true /* up */);
case SCALE_UI_DOWN:
return HandleScaleUI(false /* down */);
case SCALE_UI_RESET:
return HandleScaleReset();
case ROTATE_WINDOW:
return HandleRotateActiveWindow();
case ROTATE_SCREEN:
return HandleRotateScreen();
case MAGNIFY_SCREEN_ZOOM_IN: case MAGNIFY_SCREEN_ZOOM_IN:
return HandleMagnifyScreen(1); return HandleMagnifyScreen(1);
case MAGNIFY_SCREEN_ZOOM_OUT: case MAGNIFY_SCREEN_ZOOM_OUT:
...@@ -992,38 +920,161 @@ bool AcceleratorController::PerformAction(int action, ...@@ -992,38 +920,161 @@ bool AcceleratorController::PerformAction(int action,
return HandleMediaPlayPause(); return HandleMediaPlayPause();
case MEDIA_PREV_TRACK: case MEDIA_PREV_TRACK:
return HandleMediaPrevTrack(); return HandleMediaPrevTrack();
case NEW_INCOGNITO_WINDOW:
return HandleNewIncognitoWindow();
case NEW_TAB:
return HandleNewTab(key_code);
case NEW_WINDOW:
return HandleNewWindow();
case NEXT_IME:
HandleNextIme(
ime_control_delegate_.get(), previous_event_type, previous_key_code);
// NEXT_IME is bound to Alt-Shift key up event. To be consistent with
// Windows behavior, do not consume the key event here.
return false;
case OPEN_FEEDBACK_PAGE:
return HandleOpenFeedbackPage();
case PREVIOUS_IME:
return HandlePreviousIme(ime_control_delegate_.get(), accelerator);
case PRINT_UI_HIERARCHIES:
debug::PrintUIHierarchies();
return true;
case RESTORE_TAB:
return HandleRestoreTab();
case ROTATE_SCREEN:
return HandleRotateScreen();
case ROTATE_WINDOW:
return HandleRotateActiveWindow();
case SCALE_UI_DOWN:
return HandleScaleUI(false /* down */);
case SCALE_UI_RESET:
return HandleScaleReset();
case SCALE_UI_UP:
return HandleScaleUI(true /* up */);
case SHOW_KEYBOARD_OVERLAY:
return HandleShowKeyboardOverlay();
case SHOW_MESSAGE_CENTER_BUBBLE:
return HandleShowMessageCenterBubble();
case SHOW_SYSTEM_TRAY_BUBBLE:
return HandleShowSystemTrayBubble();
case SHOW_TASK_MANAGER:
return HandleShowTaskManager();
case SWITCH_IME:
return HandleSwitchIme(ime_control_delegate_.get(), accelerator);
case TAKE_PARTIAL_SCREENSHOT:
return HandleTakePartialScreenshot(screenshot_delegate_.get());
case TAKE_SCREENSHOT:
return HandleTakeScreenshot(screenshot_delegate_.get());
case TOGGLE_APP_LIST:
return HandleToggleAppList(
key_code, previous_event_type, previous_key_code, accelerator);
case TOGGLE_FULLSCREEN:
return HandleToggleFullscreen(key_code);
case TOGGLE_MAXIMIZED:
accelerators::ToggleMaximized();
return true;
case TOGGLE_OVERVIEW:
return HandleToggleOverview(accelerator);
case VOLUME_DOWN: {
ash::VolumeControlDelegate* volume_delegate =
shell->system_tray_delegate()->GetVolumeControlDelegate();
return volume_delegate && volume_delegate->HandleVolumeDown(accelerator);
}
case VOLUME_MUTE: {
ash::VolumeControlDelegate* volume_delegate =
shell->system_tray_delegate()->GetVolumeControlDelegate();
return volume_delegate && volume_delegate->HandleVolumeMute(accelerator);
}
case VOLUME_UP: {
ash::VolumeControlDelegate* volume_delegate =
shell->system_tray_delegate()->GetVolumeControlDelegate();
return volume_delegate && volume_delegate->HandleVolumeUp(accelerator);
}
case WINDOW_CYCLE_SNAP_DOCK_LEFT:
case WINDOW_CYCLE_SNAP_DOCK_RIGHT:
return HandleWindowSnapOrDock(action);
case WINDOW_MINIMIZE:
return HandleWindowMinimize();
case WINDOW_POSITION_CENTER:
return HandlePositionCenter();
#if defined(OS_CHROMEOS)
case DEBUG_ADD_REMOVE_DISPLAY:
return debug::PerformDebugAction(action);
case DISABLE_CAPS_LOCK:
return HandleDisableCapsLock(
key_code, previous_event_type, previous_key_code);
case DISABLE_GPU_WATCHDOG:
Shell::GetInstance()->gpu_support()->DisableGpuWatchdog();
return true;
case KEYBOARD_BRIGHTNESS_DOWN:
if (keyboard_brightness_control_delegate_)
return keyboard_brightness_control_delegate_->
HandleKeyboardBrightnessDown(accelerator);
return false;
case KEYBOARD_BRIGHTNESS_UP:
if (keyboard_brightness_control_delegate_)
return keyboard_brightness_control_delegate_->
HandleKeyboardBrightnessUp(accelerator);
return false;
case LOCK_PRESSED:
case LOCK_RELEASED:
Shell::GetInstance()->power_button_controller()->
OnLockButtonEvent(action == LOCK_PRESSED, base::TimeTicks());
return true;
case LOCK_SCREEN:
return HandleLock(key_code);
case OPEN_CROSH:
return HandleCrosh();
case OPEN_FILE_MANAGER:
return HandleFileManager();
case POWER_PRESSED: // fallthrough case POWER_PRESSED: // fallthrough
case POWER_RELEASED: case POWER_RELEASED:
#if defined(OS_CHROMEOS)
if (!base::SysInfo::IsRunningOnChromeOS()) { if (!base::SysInfo::IsRunningOnChromeOS()) {
// There is no powerd in linux desktop, so call the // There is no powerd in linux desktop, so call the
// PowerButtonController here. // PowerButtonController here.
Shell::GetInstance()->power_button_controller()-> Shell::GetInstance()->power_button_controller()->
OnPowerButtonEvent(action == POWER_PRESSED, base::TimeTicks()); OnPowerButtonEvent(action == POWER_PRESSED, base::TimeTicks());
} }
#endif
// We don't do anything with these at present on the device, // We don't do anything with these at present on the device,
// (power button events are reported to us from powerm via // (power button events are reported to us from powerm via
// D-BUS), but we consume them to prevent them from getting // D-BUS), but we consume them to prevent them from getting
// passed to apps -- see http://crbug.com/146609. // passed to apps -- see http://crbug.com/146609.
return true; return true;
case LOCK_PRESSED: case SILENCE_SPOKEN_FEEDBACK:
case LOCK_RELEASED: HandleSilenceSpokenFeedback();
Shell::GetInstance()->power_button_controller()-> return false;
OnLockButtonEvent(action == LOCK_PRESSED, base::TimeTicks()); case SWAP_PRIMARY_DISPLAY:
return HandleSwapPrimaryDisplay();
case SWITCH_TO_NEXT_USER:
return HandleCycleUser(SessionStateDelegate::CYCLE_TO_NEXT_USER);
case SWITCH_TO_PREVIOUS_USER:
return HandleCycleUser(SessionStateDelegate::CYCLE_TO_PREVIOUS_USER);
case TOGGLE_CAPS_LOCK:
return HandleToggleCapsLock(
key_code, previous_event_type, previous_key_code);
case TOGGLE_MIRROR_MODE:
return HandleToggleMirrorMode();
case TOGGLE_SPOKEN_FEEDBACK:
return HandleToggleSpokenFeedback();
case TOGGLE_TOUCH_VIEW_TESTING:
return HandleToggleTouchViewTesting();
case TOGGLE_WIFI:
Shell::GetInstance()->system_tray_notifier()->NotifyRequestToggleWifi();
return true;
case TOUCH_HUD_CLEAR:
return HandleTouchHudClear();
case TOUCH_HUD_MODE_CHANGE:
return HandleTouchHudModeChange();
case TOUCH_HUD_PROJECTION_TOGGLE:
accelerators::ToggleTouchHudProjection();
return true; return true;
default: #else
DCHECK(debug::DebugAcceleratorsEnabled()) case DUMMY_FOR_RESERVED:
<< "Unhandled action " << action; NOTREACHED();
return false;
#endif // OS_CHROMEOS
} }
return false;
// If |action| is a debug action, run it.
return debug::PerformDebugAction(action);
}
AcceleratorController::AcceleratorProcessingRestriction
AcceleratorController::GetCurrentAcceleratorRestriction() {
return GetAcceleratorProcessingRestriction(-1);
} }
AcceleratorController::AcceleratorProcessingRestriction AcceleratorController::AcceleratorProcessingRestriction
...@@ -1062,46 +1113,6 @@ AcceleratorController::GetAcceleratorProcessingRestriction(int action) { ...@@ -1062,46 +1113,6 @@ AcceleratorController::GetAcceleratorProcessingRestriction(int action) {
return RESTRICTION_NONE; return RESTRICTION_NONE;
} }
void AcceleratorController::SetBrightnessControlDelegate(
scoped_ptr<BrightnessControlDelegate> brightness_control_delegate) {
brightness_control_delegate_ = brightness_control_delegate.Pass();
}
void AcceleratorController::SetImeControlDelegate(
scoped_ptr<ImeControlDelegate> ime_control_delegate) {
ime_control_delegate_ = ime_control_delegate.Pass();
}
void AcceleratorController::SetScreenshotDelegate(
scoped_ptr<ScreenshotDelegate> screenshot_delegate) {
screenshot_delegate_ = screenshot_delegate.Pass();
}
////////////////////////////////////////////////////////////////////////////////
// AcceleratorController, ui::AcceleratorTarget implementation:
bool AcceleratorController::AcceleratorPressed(
const ui::Accelerator& accelerator) {
std::map<ui::Accelerator, int>::const_iterator it =
accelerators_.find(accelerator);
DCHECK(it != accelerators_.end());
return PerformAction(static_cast<AcceleratorAction>(it->second), accelerator);
}
void AcceleratorController::RegisterAccelerators(
const AcceleratorData accelerators[],
size_t accelerators_length) {
for (size_t i = 0; i < accelerators_length; ++i) {
ui::Accelerator accelerator(accelerators[i].keycode,
accelerators[i].modifiers);
accelerator.set_type(accelerators[i].trigger_on_press ?
ui::ET_KEY_PRESSED : ui::ET_KEY_RELEASED);
Register(accelerator, this);
accelerators_.insert(
std::make_pair(accelerator, accelerators[i].action));
}
}
void AcceleratorController::SetKeyboardBrightnessControlDelegate( void AcceleratorController::SetKeyboardBrightnessControlDelegate(
scoped_ptr<KeyboardBrightnessControlDelegate> scoped_ptr<KeyboardBrightnessControlDelegate>
keyboard_brightness_control_delegate) { keyboard_brightness_control_delegate) {
...@@ -1109,8 +1120,4 @@ void AcceleratorController::SetKeyboardBrightnessControlDelegate( ...@@ -1109,8 +1120,4 @@ void AcceleratorController::SetKeyboardBrightnessControlDelegate(
keyboard_brightness_control_delegate.Pass(); keyboard_brightness_control_delegate.Pass();
} }
bool AcceleratorController::CanHandleAccelerators() const {
return true;
}
} // namespace ash } // namespace ash
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <map> #include <map>
#include <set> #include <set>
#include "ash/accelerators/accelerator_table.h"
#include "ash/accelerators/exit_warning_handler.h" #include "ash/accelerators/exit_warning_handler.h"
#include "ash/ash_export.h" #include "ash/ash_export.h"
#include "base/basictypes.h" #include "base/basictypes.h"
...@@ -88,15 +89,11 @@ class ASH_EXPORT AcceleratorController : public ui::AcceleratorTarget { ...@@ -88,15 +89,11 @@ class ASH_EXPORT AcceleratorController : public ui::AcceleratorTarget {
// Performs the specified action if it is enabled. Returns whether the action // Performs the specified action if it is enabled. Returns whether the action
// was performed successfully. // was performed successfully.
bool PerformActionIfEnabled(int action); bool PerformActionIfEnabled(AcceleratorAction action);
// Returns the restriction for the current context. // Returns the restriction for the current context.
AcceleratorProcessingRestriction GetCurrentAcceleratorRestriction(); AcceleratorProcessingRestriction GetCurrentAcceleratorRestriction();
// Overridden from ui::AcceleratorTarget:
bool AcceleratorPressed(const ui::Accelerator& accelerator) override;
bool CanHandleAccelerators() const override;
void SetBrightnessControlDelegate( void SetBrightnessControlDelegate(
scoped_ptr<BrightnessControlDelegate> brightness_control_delegate); scoped_ptr<BrightnessControlDelegate> brightness_control_delegate);
void SetImeControlDelegate( void SetImeControlDelegate(
...@@ -119,6 +116,10 @@ class ASH_EXPORT AcceleratorController : public ui::AcceleratorTarget { ...@@ -119,6 +116,10 @@ class ASH_EXPORT AcceleratorController : public ui::AcceleratorTarget {
return previous_accelerator_; return previous_accelerator_;
} }
// Overridden from ui::AcceleratorTarget:
bool AcceleratorPressed(const ui::Accelerator& accelerator) override;
bool CanHandleAccelerators() const override;
private: private:
FRIEND_TEST_ALL_PREFIXES(AcceleratorControllerTest, GlobalAccelerators); FRIEND_TEST_ALL_PREFIXES(AcceleratorControllerTest, GlobalAccelerators);
FRIEND_TEST_ALL_PREFIXES(AcceleratorControllerTest, FRIEND_TEST_ALL_PREFIXES(AcceleratorControllerTest,
...@@ -134,7 +135,7 @@ class ASH_EXPORT AcceleratorController : public ui::AcceleratorTarget { ...@@ -134,7 +135,7 @@ class ASH_EXPORT AcceleratorController : public ui::AcceleratorTarget {
// Performs the specified action. The |accelerator| may provide additional // Performs the specified action. The |accelerator| may provide additional
// data the action needs. Returns whether an action was performed // data the action needs. Returns whether an action was performed
// successfully. // successfully.
bool PerformAction(int action, bool PerformAction(AcceleratorAction action,
const ui::Accelerator& accelerator); const ui::Accelerator& accelerator);
// Get the accelerator restriction for the given action. Supply an |action| // Get the accelerator restriction for the given action. Supply an |action|
...@@ -166,7 +167,7 @@ class ASH_EXPORT AcceleratorController : public ui::AcceleratorTarget { ...@@ -166,7 +167,7 @@ class ASH_EXPORT AcceleratorController : public ui::AcceleratorTarget {
// A map from accelerators to the AcceleratorAction values, which are used in // A map from accelerators to the AcceleratorAction values, which are used in
// the implementation. // the implementation.
std::map<ui::Accelerator, int> accelerators_; std::map<ui::Accelerator, AcceleratorAction> accelerators_;
// Actions allowed when the user is not signed in. // Actions allowed when the user is not signed in.
std::set<int> actions_allowed_at_login_screen_; std::set<int> actions_allowed_at_login_screen_;
......
...@@ -254,9 +254,6 @@ const AcceleratorAction kActionsAllowedAtLoginOrLockScreen[] = { ...@@ -254,9 +254,6 @@ const AcceleratorAction kActionsAllowedAtLoginOrLockScreen[] = {
DEBUG_PRINT_LAYER_HIERARCHY, DEBUG_PRINT_LAYER_HIERARCHY,
DEBUG_PRINT_VIEW_HIERARCHY, DEBUG_PRINT_VIEW_HIERARCHY,
DEBUG_PRINT_WINDOW_HIERARCHY, DEBUG_PRINT_WINDOW_HIERARCHY,
DISABLE_CAPS_LOCK,
KEYBOARD_BRIGHTNESS_DOWN,
KEYBOARD_BRIGHTNESS_UP,
MAGNIFY_SCREEN_ZOOM_IN, // Control+F7 MAGNIFY_SCREEN_ZOOM_IN, // Control+F7
MAGNIFY_SCREEN_ZOOM_OUT, // Control+F6 MAGNIFY_SCREEN_ZOOM_OUT, // Control+F6
NEXT_IME, NEXT_IME,
...@@ -267,18 +264,21 @@ const AcceleratorAction kActionsAllowedAtLoginOrLockScreen[] = { ...@@ -267,18 +264,21 @@ const AcceleratorAction kActionsAllowedAtLoginOrLockScreen[] = {
SWITCH_IME, // Switch to another IME depending on the accelerator. SWITCH_IME, // Switch to another IME depending on the accelerator.
TAKE_PARTIAL_SCREENSHOT, TAKE_PARTIAL_SCREENSHOT,
TAKE_SCREENSHOT, TAKE_SCREENSHOT,
TOGGLE_CAPS_LOCK,
TOGGLE_WIFI,
TOUCH_HUD_CLEAR,
VOLUME_DOWN, VOLUME_DOWN,
VOLUME_MUTE, VOLUME_MUTE,
VOLUME_UP, VOLUME_UP,
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
DEBUG_ADD_REMOVE_DISPLAY, DEBUG_ADD_REMOVE_DISPLAY,
DISABLE_CAPS_LOCK,
DISABLE_GPU_WATCHDOG, DISABLE_GPU_WATCHDOG,
KEYBOARD_BRIGHTNESS_DOWN,
KEYBOARD_BRIGHTNESS_UP,
TOGGLE_CAPS_LOCK,
TOGGLE_SPOKEN_FEEDBACK, TOGGLE_SPOKEN_FEEDBACK,
TOGGLE_TOUCH_VIEW_TESTING, TOGGLE_TOUCH_VIEW_TESTING,
TOGGLE_MIRROR_MODE, TOGGLE_MIRROR_MODE,
TOGGLE_WIFI,
TOUCH_HUD_CLEAR,
#endif #endif
#if defined(OS_CHROMEOS) && !defined(NDEBUG) #if defined(OS_CHROMEOS) && !defined(NDEBUG)
POWER_PRESSED, POWER_PRESSED,
...@@ -299,10 +299,7 @@ const size_t kActionsAllowedAtLockScreenLength = ...@@ -299,10 +299,7 @@ const size_t kActionsAllowedAtLockScreenLength =
const AcceleratorAction kActionsAllowedAtModalWindow[] = { const AcceleratorAction kActionsAllowedAtModalWindow[] = {
BRIGHTNESS_DOWN, BRIGHTNESS_DOWN,
BRIGHTNESS_UP, BRIGHTNESS_UP,
DISABLE_CAPS_LOCK,
EXIT, EXIT,
KEYBOARD_BRIGHTNESS_DOWN,
KEYBOARD_BRIGHTNESS_UP,
MAGNIFY_SCREEN_ZOOM_IN, MAGNIFY_SCREEN_ZOOM_IN,
MAGNIFY_SCREEN_ZOOM_OUT, MAGNIFY_SCREEN_ZOOM_OUT,
MEDIA_NEXT_TRACK, MEDIA_NEXT_TRACK,
...@@ -310,8 +307,6 @@ const AcceleratorAction kActionsAllowedAtModalWindow[] = { ...@@ -310,8 +307,6 @@ const AcceleratorAction kActionsAllowedAtModalWindow[] = {
MEDIA_PREV_TRACK, MEDIA_PREV_TRACK,
NEXT_IME, NEXT_IME,
OPEN_FEEDBACK_PAGE, OPEN_FEEDBACK_PAGE,
POWER_PRESSED,
POWER_RELEASED,
PREVIOUS_IME, PREVIOUS_IME,
PRINT_UI_HIERARCHIES, PRINT_UI_HIERARCHIES,
ROTATE_SCREEN, ROTATE_SCREEN,
...@@ -322,17 +317,22 @@ const AcceleratorAction kActionsAllowedAtModalWindow[] = { ...@@ -322,17 +317,22 @@ const AcceleratorAction kActionsAllowedAtModalWindow[] = {
SWITCH_IME, SWITCH_IME,
TAKE_PARTIAL_SCREENSHOT, TAKE_PARTIAL_SCREENSHOT,
TAKE_SCREENSHOT, TAKE_SCREENSHOT,
TOGGLE_CAPS_LOCK,
TOGGLE_WIFI,
VOLUME_DOWN, VOLUME_DOWN,
VOLUME_MUTE, VOLUME_MUTE,
VOLUME_UP, VOLUME_UP,
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
DEBUG_ADD_REMOVE_DISPLAY, DEBUG_ADD_REMOVE_DISPLAY,
DISABLE_CAPS_LOCK,
KEYBOARD_BRIGHTNESS_DOWN,
KEYBOARD_BRIGHTNESS_UP,
LOCK_SCREEN, LOCK_SCREEN,
POWER_PRESSED,
POWER_RELEASED,
SWAP_PRIMARY_DISPLAY, SWAP_PRIMARY_DISPLAY,
TOGGLE_CAPS_LOCK,
TOGGLE_MIRROR_MODE, TOGGLE_MIRROR_MODE,
TOGGLE_SPOKEN_FEEDBACK, TOGGLE_SPOKEN_FEEDBACK,
TOGGLE_WIFI,
#endif #endif
}; };
...@@ -365,17 +365,12 @@ const AcceleratorAction kActionsAllowedInAppMode[] = { ...@@ -365,17 +365,12 @@ const AcceleratorAction kActionsAllowedInAppMode[] = {
DEBUG_PRINT_LAYER_HIERARCHY, DEBUG_PRINT_LAYER_HIERARCHY,
DEBUG_PRINT_VIEW_HIERARCHY, DEBUG_PRINT_VIEW_HIERARCHY,
DEBUG_PRINT_WINDOW_HIERARCHY, DEBUG_PRINT_WINDOW_HIERARCHY,
DISABLE_CAPS_LOCK,
KEYBOARD_BRIGHTNESS_DOWN,
KEYBOARD_BRIGHTNESS_UP,
MAGNIFY_SCREEN_ZOOM_IN, // Control+F7 MAGNIFY_SCREEN_ZOOM_IN, // Control+F7
MAGNIFY_SCREEN_ZOOM_OUT, // Control+F6 MAGNIFY_SCREEN_ZOOM_OUT, // Control+F6
MEDIA_NEXT_TRACK, MEDIA_NEXT_TRACK,
MEDIA_PLAY_PAUSE, MEDIA_PLAY_PAUSE,
MEDIA_PREV_TRACK, MEDIA_PREV_TRACK,
NEXT_IME, NEXT_IME,
POWER_PRESSED,
POWER_RELEASED,
PREVIOUS_IME, PREVIOUS_IME,
PRINT_UI_HIERARCHIES, PRINT_UI_HIERARCHIES,
ROTATE_SCREEN, ROTATE_SCREEN,
...@@ -383,18 +378,23 @@ const AcceleratorAction kActionsAllowedInAppMode[] = { ...@@ -383,18 +378,23 @@ const AcceleratorAction kActionsAllowedInAppMode[] = {
SCALE_UI_RESET, SCALE_UI_RESET,
SCALE_UI_UP, SCALE_UI_UP,
SWITCH_IME, // Switch to another IME depending on the accelerator. SWITCH_IME, // Switch to another IME depending on the accelerator.
TOGGLE_CAPS_LOCK,
TOGGLE_WIFI,
TOUCH_HUD_CLEAR,
VOLUME_DOWN, VOLUME_DOWN,
VOLUME_MUTE, VOLUME_MUTE,
VOLUME_UP, VOLUME_UP,
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
DEBUG_ADD_REMOVE_DISPLAY, DEBUG_ADD_REMOVE_DISPLAY,
DISABLE_CAPS_LOCK,
DISABLE_GPU_WATCHDOG, DISABLE_GPU_WATCHDOG,
KEYBOARD_BRIGHTNESS_DOWN,
KEYBOARD_BRIGHTNESS_UP,
POWER_PRESSED,
POWER_RELEASED,
SWAP_PRIMARY_DISPLAY, SWAP_PRIMARY_DISPLAY,
TOGGLE_CAPS_LOCK,
TOGGLE_MIRROR_MODE, TOGGLE_MIRROR_MODE,
TOGGLE_SPOKEN_FEEDBACK, TOGGLE_SPOKEN_FEEDBACK,
TOGGLE_WIFI,
TOUCH_HUD_CLEAR,
#endif // defined(OS_CHROMEOS) #endif // defined(OS_CHROMEOS)
}; };
......
...@@ -66,13 +66,10 @@ enum AcceleratorAction { ...@@ -66,13 +66,10 @@ enum AcceleratorAction {
DEBUG_TOGGLE_SHOW_DEBUG_BORDERS, DEBUG_TOGGLE_SHOW_DEBUG_BORDERS,
DEBUG_TOGGLE_SHOW_FPS_COUNTER, DEBUG_TOGGLE_SHOW_FPS_COUNTER,
DEBUG_TOGGLE_SHOW_PAINT_RECTS, DEBUG_TOGGLE_SHOW_PAINT_RECTS,
DISABLE_CAPS_LOCK,
EXIT, EXIT,
FOCUS_NEXT_PANE, FOCUS_NEXT_PANE,
FOCUS_PREVIOUS_PANE, FOCUS_PREVIOUS_PANE,
FOCUS_SHELF, FOCUS_SHELF,
KEYBOARD_BRIGHTNESS_DOWN,
KEYBOARD_BRIGHTNESS_UP,
LAUNCH_APP_0, LAUNCH_APP_0,
LAUNCH_APP_1, LAUNCH_APP_1,
LAUNCH_APP_2, LAUNCH_APP_2,
...@@ -82,8 +79,6 @@ enum AcceleratorAction { ...@@ -82,8 +79,6 @@ enum AcceleratorAction {
LAUNCH_APP_6, LAUNCH_APP_6,
LAUNCH_APP_7, LAUNCH_APP_7,
LAUNCH_LAST_APP, LAUNCH_LAST_APP,
LOCK_PRESSED,
LOCK_RELEASED,
MAGNIFY_SCREEN_ZOOM_IN, MAGNIFY_SCREEN_ZOOM_IN,
MAGNIFY_SCREEN_ZOOM_OUT, MAGNIFY_SCREEN_ZOOM_OUT,
MEDIA_NEXT_TRACK, MEDIA_NEXT_TRACK,
...@@ -94,8 +89,6 @@ enum AcceleratorAction { ...@@ -94,8 +89,6 @@ enum AcceleratorAction {
NEW_WINDOW, NEW_WINDOW,
NEXT_IME, NEXT_IME,
OPEN_FEEDBACK_PAGE, OPEN_FEEDBACK_PAGE,
POWER_PRESSED,
POWER_RELEASED,
PREVIOUS_IME, PREVIOUS_IME,
PRINT_UI_HIERARCHIES, PRINT_UI_HIERARCHIES,
RESTORE_TAB, RESTORE_TAB,
...@@ -108,23 +101,13 @@ enum AcceleratorAction { ...@@ -108,23 +101,13 @@ enum AcceleratorAction {
SHOW_MESSAGE_CENTER_BUBBLE, SHOW_MESSAGE_CENTER_BUBBLE,
SHOW_SYSTEM_TRAY_BUBBLE, SHOW_SYSTEM_TRAY_BUBBLE,
SHOW_TASK_MANAGER, SHOW_TASK_MANAGER,
SILENCE_SPOKEN_FEEDBACK,
SWAP_PRIMARY_DISPLAY,
SWITCH_IME, // Switch to another IME depending on the accelerator. SWITCH_IME, // Switch to another IME depending on the accelerator.
TAKE_PARTIAL_SCREENSHOT, TAKE_PARTIAL_SCREENSHOT,
TAKE_SCREENSHOT, TAKE_SCREENSHOT,
TOGGLE_APP_LIST, TOGGLE_APP_LIST,
TOGGLE_CAPS_LOCK,
TOGGLE_CAPS_LOCK_BY_ALT_LWIN,
TOGGLE_FULLSCREEN, TOGGLE_FULLSCREEN,
TOGGLE_MAXIMIZED, TOGGLE_MAXIMIZED,
TOGGLE_OVERVIEW, TOGGLE_OVERVIEW,
TOGGLE_SPOKEN_FEEDBACK,
TOGGLE_TOUCH_VIEW_TESTING,
TOGGLE_WIFI,
TOUCH_HUD_CLEAR,
TOUCH_HUD_MODE_CHANGE,
TOUCH_HUD_PROJECTION_TOGGLE,
VOLUME_DOWN, VOLUME_DOWN,
VOLUME_MUTE, VOLUME_MUTE,
VOLUME_UP, VOLUME_UP,
...@@ -134,13 +117,29 @@ enum AcceleratorAction { ...@@ -134,13 +117,29 @@ enum AcceleratorAction {
WINDOW_CYCLE_SNAP_DOCK_RIGHT, WINDOW_CYCLE_SNAP_DOCK_RIGHT,
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
DEBUG_ADD_REMOVE_DISPLAY, DEBUG_ADD_REMOVE_DISPLAY,
DISABLE_CAPS_LOCK,
DISABLE_GPU_WATCHDOG, DISABLE_GPU_WATCHDOG,
KEYBOARD_BRIGHTNESS_DOWN,
KEYBOARD_BRIGHTNESS_UP,
LOCK_PRESSED,
LOCK_RELEASED,
LOCK_SCREEN, LOCK_SCREEN,
OPEN_CROSH, OPEN_CROSH,
OPEN_FILE_MANAGER, OPEN_FILE_MANAGER,
POWER_PRESSED,
POWER_RELEASED,
SILENCE_SPOKEN_FEEDBACK,
SWAP_PRIMARY_DISPLAY,
SWITCH_TO_NEXT_USER, SWITCH_TO_NEXT_USER,
SWITCH_TO_PREVIOUS_USER, SWITCH_TO_PREVIOUS_USER,
TOGGLE_CAPS_LOCK,
TOGGLE_MIRROR_MODE, TOGGLE_MIRROR_MODE,
TOGGLE_SPOKEN_FEEDBACK,
TOGGLE_TOUCH_VIEW_TESTING,
TOGGLE_WIFI,
TOUCH_HUD_CLEAR,
TOUCH_HUD_MODE_CHANGE,
TOUCH_HUD_PROJECTION_TOGGLE,
#else #else
DUMMY_FOR_RESERVED, DUMMY_FOR_RESERVED,
#endif #endif
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "ash/accelerators/accelerator_commands.h" #include "ash/accelerators/debug_commands.h"
#include "ash/accelerators/accelerator_table.h" #include "ash/accelerators/accelerator_commands.h"
#include "ash/ash_switches.h" #include "ash/ash_switches.h"
#include "ash/debug.h" #include "ash/debug.h"
#include "ash/desktop_background/desktop_background_controller.h" #include "ash/desktop_background/desktop_background_controller.h"
...@@ -139,7 +139,7 @@ bool DebugAcceleratorsEnabled() { ...@@ -139,7 +139,7 @@ bool DebugAcceleratorsEnabled() {
switches::kAshDebugShortcuts); switches::kAshDebugShortcuts);
} }
bool PerformDebugAction(int action) { bool PerformDebugAction(AcceleratorAction action) {
if (!DebugAcceleratorsEnabled()) if (!DebugAcceleratorsEnabled())
return false; return false;
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#ifndef ASH_ACCELERATORS_DEBUG_COMMANDS_H_ #ifndef ASH_ACCELERATORS_DEBUG_COMMANDS_H_
#define ASH_ACCELERATORS_DEBUG_COMMANDS_H_ #define ASH_ACCELERATORS_DEBUG_COMMANDS_H_
#include "ash/accelerators/accelerator_table.h"
#include "ash/ash_export.h" #include "ash/ash_export.h"
// This file contains implementations of commands that are used only // This file contains implementations of commands that are used only
...@@ -21,7 +22,7 @@ ASH_EXPORT bool DebugAcceleratorsEnabled(); ...@@ -21,7 +22,7 @@ ASH_EXPORT bool DebugAcceleratorsEnabled();
// Performs |action| and returns true if |action| belongs to a // Performs |action| and returns true if |action| belongs to a
// debug-only accelerator and debug accelerators are enabled. // debug-only accelerator and debug accelerators are enabled.
ASH_EXPORT bool PerformDebugAction(int action); ASH_EXPORT bool PerformDebugAction(AcceleratorAction action);
} // namespace debug } // namespace debug
} // namespace ash } // namespace ash
......
...@@ -99,7 +99,7 @@ class LoggedInSpokenFeedbackTest : public InProcessBrowserTest { ...@@ -99,7 +99,7 @@ class LoggedInSpokenFeedbackTest : public InProcessBrowserTest {
"window.ontouchstart = function() {};"); "window.ontouchstart = function() {};");
} }
bool PerformAcceleratorAction(int action) { bool PerformAcceleratorAction(ash::AcceleratorAction action) {
ash::AcceleratorController* controller = ash::AcceleratorController* controller =
ash::Shell::GetInstance()->accelerator_controller(); ash::Shell::GetInstance()->accelerator_controller();
return controller->PerformActionIfEnabled(action); return controller->PerformActionIfEnabled(action);
......
...@@ -205,7 +205,9 @@ const ChromeCmdId2AshActionId kChromeCmdId2AshActionId[] = { ...@@ -205,7 +205,9 @@ const ChromeCmdId2AshActionId kChromeCmdId2AshActionId[] = {
{ IDC_NEW_WINDOW, ash::NEW_WINDOW }, { IDC_NEW_WINDOW, ash::NEW_WINDOW },
{ IDC_RESTORE_TAB, ash::RESTORE_TAB }, { IDC_RESTORE_TAB, ash::RESTORE_TAB },
{ IDC_TASK_MANAGER, ash::SHOW_TASK_MANAGER }, { IDC_TASK_MANAGER, ash::SHOW_TASK_MANAGER },
#if defined(OS_CHROMEOS)
{ IDC_TOUCH_HUD_PROJECTION_TOGGLE, ash::TOUCH_HUD_PROJECTION_TOGGLE }, { IDC_TOUCH_HUD_PROJECTION_TOGGLE, ash::TOUCH_HUD_PROJECTION_TOGGLE },
#endif
}; };
const size_t kChromeCmdId2AshActionIdLength = const size_t kChromeCmdId2AshActionIdLength =
arraysize(kChromeCmdId2AshActionId); arraysize(kChromeCmdId2AshActionId);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment