Index: ash/accelerators/accelerator_controller_delegate_aura.cc |
diff --git a/ash/accelerators/accelerator_controller.cc b/ash/accelerators/accelerator_controller_delegate_aura.cc |
similarity index 41% |
copy from ash/accelerators/accelerator_controller.cc |
copy to ash/accelerators/accelerator_controller_delegate_aura.cc |
index 8b354056338afd208391fd72f395d6a1d869dcef..7a6ee169400ac42544f62d6948ac94d869260f7e 100644 |
--- a/ash/accelerators/accelerator_controller.cc |
+++ b/ash/accelerators/accelerator_controller_delegate_aura.cc |
@@ -1,46 +1,33 @@ |
-// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "ash/accelerators/accelerator_controller.h" |
+#include "ash/accelerators/accelerator_controller_delegate_aura.h" |
#include <algorithm> |
#include <cmath> |
#include <string> |
#include <utility> |
-#include "ash/accelerators/accelerator_commands.h" |
-#include "ash/accelerators/debug_commands.h" |
+#include "ash/accelerators/accelerator_commands_aura.h" |
#include "ash/common/accessibility_delegate.h" |
#include "ash/common/accessibility_types.h" |
#include "ash/common/ash_switches.h" |
#include "ash/common/focus_cycler.h" |
#include "ash/common/gpu_support.h" |
-#include "ash/common/media_delegate.h" |
-#include "ash/common/multi_profile_uma.h" |
#include "ash/common/session/session_state_delegate.h" |
-#include "ash/common/shelf/shelf_model.h" |
#include "ash/common/shell_delegate.h" |
#include "ash/common/shell_window_ids.h" |
-#include "ash/common/system/brightness_control_delegate.h" |
-#include "ash/common/system/keyboard_brightness_control_delegate.h" |
#include "ash/common/system/status_area_widget.h" |
#include "ash/common/system/system_notifier.h" |
#include "ash/common/system/tray/system_tray.h" |
-#include "ash/common/system/tray/system_tray_delegate.h" |
-#include "ash/common/system/tray/system_tray_notifier.h" |
-#include "ash/common/system/volume_control_delegate.h" |
#include "ash/common/system/web_notification/web_notification_tray.h" |
#include "ash/common/wm/maximize_mode/maximize_mode_controller.h" |
-#include "ash/common/wm/mru_window_tracker.h" |
-#include "ash/common/wm/overview/window_selector_controller.h" |
-#include "ash/common/wm/window_cycle_controller.h" |
#include "ash/common/wm/window_state.h" |
#include "ash/common/wm/wm_event.h" |
#include "ash/common/wm_shell.h" |
#include "ash/debug.h" |
#include "ash/display/window_tree_host_manager.h" |
-#include "ash/ime_control_delegate.h" |
#include "ash/magnifier/magnification_controller.h" |
#include "ash/magnifier/partial_magnification_controller.h" |
#include "ash/new_window_delegate.h" |
@@ -50,7 +37,6 @@ |
#include "ash/screen_util.h" |
#include "ash/screenshot_delegate.h" |
#include "ash/shelf/shelf.h" |
-#include "ash/shelf/shelf_delegate.h" |
#include "ash/shelf/shelf_widget.h" |
#include "ash/shell.h" |
#include "ash/touch/touch_hud_debug.h" |
@@ -58,17 +44,12 @@ |
#include "ash/wm/power_button_controller.h" |
#include "ash/wm/window_state_aura.h" |
#include "ash/wm/window_util.h" |
-#include "base/bind.h" |
-#include "base/command_line.h" |
#include "base/metrics/histogram_macros.h" |
#include "base/metrics/user_metrics.h" |
#include "base/strings/string_split.h" |
#include "base/strings/utf_string_conversions.h" |
-#include "ui/aura/env.h" |
#include "ui/base/accelerators/accelerator.h" |
-#include "ui/base/accelerators/accelerator_manager.h" |
#include "ui/base/l10n/l10n_util.h" |
-#include "ui/base/resource/resource_bundle.h" |
#include "ui/compositor/layer.h" |
#include "ui/compositor/layer_animation_sequence.h" |
#include "ui/compositor/layer_animator.h" |
@@ -82,10 +63,6 @@ |
#if defined(OS_CHROMEOS) |
#include "ash/display/display_configuration_controller.h" |
#include "base/sys_info.h" |
-#include "chromeos/dbus/dbus_thread_manager.h" |
-#include "chromeos/dbus/power_manager_client.h" |
-#include "ui/base/ime/chromeos/ime_keyboard.h" |
-#include "ui/base/ime/chromeos/input_method_manager.h" |
#endif // defined(OS_CHROMEOS) |
namespace ash { |
@@ -115,15 +92,6 @@ class DeprecatedAcceleratorNotificationDelegate |
DISALLOW_COPY_AND_ASSIGN(DeprecatedAcceleratorNotificationDelegate); |
}; |
-ui::Accelerator CreateAccelerator(ui::KeyboardCode keycode, |
- int modifiers, |
- bool trigger_on_press) { |
- ui::Accelerator accelerator(keycode, modifiers); |
- accelerator.set_type(trigger_on_press ? ui::ET_KEY_PRESSED |
- : ui::ET_KEY_RELEASED); |
- return accelerator; |
-} |
- |
// Ensures that there are no word breaks at the "+"s in the shortcut texts such |
// as "Ctrl+Shift+Space". |
void EnsureNoWordBreaks(base::string16* shortcut_text) { |
@@ -160,68 +128,8 @@ base::string16 GetNotificationText(int message_id, |
return l10n_util::GetStringFUTF16(message_id, new_shortcut, old_shortcut); |
} |
-void ShowDeprecatedAcceleratorNotification(const char* const notification_id, |
- int message_id, |
- int old_shortcut_id, |
- int new_shortcut_id) { |
- const base::string16 message = |
- GetNotificationText(message_id, old_shortcut_id, new_shortcut_id); |
- std::unique_ptr<message_center::Notification> notification( |
- new message_center::Notification( |
- message_center::NOTIFICATION_TYPE_SIMPLE, notification_id, |
- base::string16(), message, |
- WmShell::Get()->delegate()->GetDeprecatedAcceleratorImage(), |
- base::string16(), GURL(), |
- message_center::NotifierId( |
- message_center::NotifierId::SYSTEM_COMPONENT, |
- system_notifier::kNotifierDeprecatedAccelerator), |
- message_center::RichNotificationData(), |
- new DeprecatedAcceleratorNotificationDelegate)); |
- message_center::MessageCenter::Get()->AddNotification( |
- std::move(notification)); |
-} |
- |
-void RecordUmaHistogram(const char* histogram_name, |
- DeprecatedAcceleratorUsage sample) { |
- auto* histogram = base::LinearHistogram::FactoryGet( |
- histogram_name, 1, DEPRECATED_USAGE_COUNT, DEPRECATED_USAGE_COUNT + 1, |
- base::HistogramBase::kUmaTargetedHistogramFlag); |
- histogram->Add(sample); |
-} |
- |
-void HandleCycleBackwardMRU(const ui::Accelerator& accelerator) { |
- if (accelerator.key_code() == ui::VKEY_TAB) |
- base::RecordAction(base::UserMetricsAction("Accel_PrevWindow_Tab")); |
- |
- WmShell::Get()->window_cycle_controller()->HandleCycleWindow( |
- WindowCycleController::BACKWARD); |
-} |
- |
-void HandleCycleForwardMRU(const ui::Accelerator& accelerator) { |
- if (accelerator.key_code() == ui::VKEY_TAB) |
- base::RecordAction(base::UserMetricsAction("Accel_NextWindow_Tab")); |
- |
- WmShell::Get()->window_cycle_controller()->HandleCycleWindow( |
- WindowCycleController::FORWARD); |
-} |
- |
-void HandleRotatePaneFocus(FocusCycler::Direction direction) { |
- switch (direction) { |
- // TODO(stevet): Not sure if this is the same as IDC_FOCUS_NEXT_PANE. |
- case FocusCycler::FORWARD: { |
- base::RecordAction(UserMetricsAction("Accel_Focus_Next_Pane")); |
- break; |
- } |
- case FocusCycler::BACKWARD: { |
- base::RecordAction(UserMetricsAction("Accel_Focus_Previous_Pane")); |
- break; |
- } |
- } |
- WmShell::Get()->focus_cycler()->RotateFocus(direction); |
-} |
- |
void HandleFocusShelf() { |
- base::RecordAction(base::UserMetricsAction("Accel_Focus_Shelf")); |
+ base::RecordAction(UserMetricsAction("Accel_Focus_Shelf")); |
WmShell::Get()->focus_cycler()->FocusWidget( |
Shelf::ForPrimaryDisplay()->shelf_widget()); |
} |
@@ -263,18 +171,6 @@ void HandleMagnifyScreen(int delta_index) { |
} |
} |
-void HandleMediaNextTrack() { |
- WmShell::Get()->media_delegate()->HandleMediaNextTrack(); |
-} |
- |
-void HandleMediaPlayPause() { |
- WmShell::Get()->media_delegate()->HandleMediaPlayPause(); |
-} |
- |
-void HandleMediaPrevTrack() { |
- WmShell::Get()->media_delegate()->HandleMediaPrevTrack(); |
-} |
- |
bool CanHandleNewIncognitoWindow() { |
return WmShell::Get()->delegate()->IsIncognitoAllowed(); |
} |
@@ -287,64 +183,23 @@ void HandleNewIncognitoWindow() { |
void HandleNewTab(const ui::Accelerator& accelerator) { |
if (accelerator.key_code() == ui::VKEY_T) |
- base::RecordAction(base::UserMetricsAction("Accel_NewTab_T")); |
+ base::RecordAction(UserMetricsAction("Accel_NewTab_T")); |
Shell::GetInstance()->new_window_delegate()->NewTab(); |
} |
void HandleNewWindow() { |
- base::RecordAction(base::UserMetricsAction("Accel_New_Window")); |
+ base::RecordAction(UserMetricsAction("Accel_New_Window")); |
Shell::GetInstance()->new_window_delegate()->NewWindow( |
false /* is_incognito */); |
} |
-bool CanHandleNextIme(ImeControlDelegate* ime_control_delegate) { |
- return ime_control_delegate && ime_control_delegate->CanCycleIme(); |
-} |
- |
-// We must avoid showing the Deprecated NEXT_IME notification erronously. |
-bool ShouldShowDeprecatedNextImeNotification( |
- const ui::Accelerator& previous_accelerator) { |
- // We only show the deprecation notification if the previous accelerator key |
- // is ONLY either Shift, or Alt. |
- const ui::KeyboardCode previous_key_code = previous_accelerator.key_code(); |
- switch (previous_key_code) { |
- case ui::VKEY_SHIFT: |
- case ui::VKEY_LSHIFT: |
- case ui::VKEY_RSHIFT: |
- case ui::VKEY_MENU: |
- case ui::VKEY_LMENU: |
- case ui::VKEY_RMENU: |
- return true; |
- |
- default: |
- return false; |
- } |
-} |
- |
-void HandleNextIme(ImeControlDelegate* ime_control_delegate) { |
- base::RecordAction(UserMetricsAction("Accel_Next_Ime")); |
- ime_control_delegate->HandleNextIme(); |
-} |
- |
void HandleOpenFeedbackPage() { |
base::RecordAction(UserMetricsAction("Accel_Open_Feedback_Page")); |
Shell::GetInstance()->new_window_delegate()->OpenFeedbackPage(); |
} |
-bool CanHandlePreviousIme(ImeControlDelegate* ime_control_delegate) { |
- return ime_control_delegate && ime_control_delegate->CanCycleIme(); |
-} |
- |
-void HandlePreviousIme(ImeControlDelegate* ime_control_delegate, |
- const ui::Accelerator& accelerator) { |
- base::RecordAction(UserMetricsAction("Accel_Previous_Ime")); |
- if (accelerator.type() == ui::ET_KEY_PRESSED) |
- ime_control_delegate->HandlePreviousIme(); |
- // Else: consume the Ctrl+Space ET_KEY_RELEASED event but do not do anything. |
-} |
- |
void HandleRestoreTab() { |
- base::RecordAction(base::UserMetricsAction("Accel_Restore_Tab")); |
+ base::RecordAction(UserMetricsAction("Accel_Restore_Tab")); |
Shell::GetInstance()->new_window_delegate()->RestoreTab(); |
} |
@@ -437,18 +292,6 @@ void HandleShowTaskManager() { |
Shell::GetInstance()->new_window_delegate()->ShowTaskManager(); |
} |
-bool CanHandleSwitchIme(ImeControlDelegate* ime_control_delegate, |
- const ui::Accelerator& accelerator) { |
- return ime_control_delegate && |
- ime_control_delegate->CanSwitchIme(accelerator); |
-} |
- |
-void HandleSwitchIme(ImeControlDelegate* ime_control_delegate, |
- const ui::Accelerator& accelerator) { |
- base::RecordAction(UserMetricsAction("Accel_Switch_Ime")); |
- ime_control_delegate->HandleSwitchIme(accelerator); |
-} |
- |
void HandleTakeWindowScreenshot(ScreenshotDelegate* screenshot_delegate) { |
base::RecordAction(UserMetricsAction("Accel_Take_Window_Screenshot")); |
DCHECK(screenshot_delegate); |
@@ -492,55 +335,8 @@ bool CanHandleToggleAppList(const ui::Accelerator& accelerator, |
void HandleToggleAppList(const ui::Accelerator& accelerator) { |
if (accelerator.key_code() == ui::VKEY_LWIN) |
- base::RecordAction(base::UserMetricsAction("Accel_Search_LWin")); |
- Shell::GetInstance()->ToggleAppList(NULL); |
-} |
- |
-void HandleToggleFullscreen(const ui::Accelerator& accelerator) { |
- if (accelerator.key_code() == ui::VKEY_MEDIA_LAUNCH_APP2) |
- base::RecordAction(UserMetricsAction("Accel_Fullscreen_F4")); |
- accelerators::ToggleFullscreen(); |
-} |
- |
-void HandleToggleOverview() { |
- base::RecordAction(base::UserMetricsAction("Accel_Overview_F5")); |
- WmShell::Get()->window_selector_controller()->ToggleOverview(); |
-} |
- |
-bool CanHandleWindowSnapOrDock() { |
- wm::WindowState* window_state = wm::GetActiveWindowState(); |
- // Disable window snapping shortcut key for full screen window due to |
- // http://crbug.com/135487. |
- return (window_state && window_state->IsUserPositionable() && |
- !window_state->IsFullscreen()); |
-} |
- |
-void HandleWindowSnapOrDock(AcceleratorAction action) { |
- if (action == WINDOW_CYCLE_SNAP_DOCK_LEFT) |
- base::RecordAction(UserMetricsAction("Accel_Window_Snap_Left")); |
- else |
- base::RecordAction(UserMetricsAction("Accel_Window_Snap_Right")); |
- |
- const wm::WMEvent event(action == WINDOW_CYCLE_SNAP_DOCK_LEFT |
- ? wm::WM_EVENT_CYCLE_SNAP_DOCK_LEFT |
- : wm::WM_EVENT_CYCLE_SNAP_DOCK_RIGHT); |
- wm::GetActiveWindowState()->OnWMEvent(&event); |
-} |
- |
-void HandleWindowMinimize() { |
- base::RecordAction(base::UserMetricsAction("Accel_Toggle_Minimized_Minus")); |
- accelerators::ToggleMinimized(); |
-} |
- |
-bool CanHandlePositionCenter() { |
- // Docked windows do not support centering. |
- wm::WindowState* window_state = wm::GetActiveWindowState(); |
- return (window_state && !window_state->IsDocked()); |
-} |
- |
-void HandlePositionCenter() { |
- base::RecordAction(UserMetricsAction("Accel_Window_Position_Center")); |
- wm::CenterWindow(wm::GetActiveWindow()); |
+ base::RecordAction(UserMetricsAction("Accel_Search_LWin")); |
+ Shell::GetInstance()->ToggleAppList(nullptr); |
} |
bool CanHandleUnpin() { |
@@ -548,49 +344,7 @@ bool CanHandleUnpin() { |
return window_state && window_state->IsPinned(); |
} |
-void HandleUnpin() { |
- accelerators::Unpin(); |
-} |
- |
#if defined(OS_CHROMEOS) |
-bool CanHandleDisableCapsLock(const ui::Accelerator& previous_accelerator) { |
- ui::KeyboardCode previous_key_code = previous_accelerator.key_code(); |
- if (previous_accelerator.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; |
- } |
- chromeos::input_method::InputMethodManager* ime = |
- chromeos::input_method::InputMethodManager::Get(); |
- chromeos::input_method::ImeKeyboard* keyboard = |
- ime ? ime->GetImeKeyboard() : NULL; |
- return (keyboard && keyboard->CapsLockIsEnabled()); |
-} |
- |
-void HandleDisableCapsLock() { |
- base::RecordAction(UserMetricsAction("Accel_Disable_Caps_Lock")); |
- chromeos::input_method::InputMethodManager* ime = |
- chromeos::input_method::InputMethodManager::Get(); |
- ime->GetImeKeyboard()->SetCapsLockEnabled(false); |
-} |
- |
-bool CanHandleLock() { |
- return WmShell::Get()->GetSessionStateDelegate()->CanLockScreen(); |
-} |
- |
-void HandleLock() { |
- base::RecordAction(UserMetricsAction("Accel_LockScreen_L")); |
- WmShell::Get()->GetSessionStateDelegate()->LockScreen(); |
-} |
- |
-void HandleSuspend() { |
- base::RecordAction(UserMetricsAction("Accel_Suspend")); |
- chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->RequestSuspend(); |
-} |
- |
void HandleCrosh() { |
base::RecordAction(UserMetricsAction("Accel_Open_Crosh")); |
@@ -613,49 +367,6 @@ void HandleSwapPrimaryDisplay() { |
ScreenUtil::GetSecondaryDisplay().id(), true /* user_action */); |
} |
-bool CanHandleCycleUser() { |
- return WmShell::Get()->delegate()->IsMultiProfilesEnabled() && |
- WmShell::Get()->GetSessionStateDelegate()->NumberOfLoggedInUsers() > 1; |
-} |
- |
-void HandleCycleUser(SessionStateDelegate::CycleUser cycle_user) { |
- MultiProfileUMA::RecordSwitchActiveUser( |
- MultiProfileUMA::SWITCH_ACTIVE_USER_BY_ACCELERATOR); |
- switch (cycle_user) { |
- case SessionStateDelegate::CYCLE_TO_NEXT_USER: |
- base::RecordAction(UserMetricsAction("Accel_Switch_To_Next_User")); |
- break; |
- case SessionStateDelegate::CYCLE_TO_PREVIOUS_USER: |
- base::RecordAction(UserMetricsAction("Accel_Switch_To_Previous_User")); |
- break; |
- } |
- WmShell::Get()->GetSessionStateDelegate()->CycleActiveUser(cycle_user); |
-} |
- |
-bool CanHandleToggleCapsLock(const ui::Accelerator& accelerator, |
- const ui::Accelerator& previous_accelerator) { |
- if (accelerator.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_accelerator.type() == ui::ET_KEY_RELEASED || |
- previous_accelerator.key_code() != ui::VKEY_LWIN) |
- return false; |
- } |
- chromeos::input_method::InputMethodManager* ime = |
- chromeos::input_method::InputMethodManager::Get(); |
- return ime && ime->GetImeKeyboard(); |
-} |
- |
-void HandleToggleCapsLock() { |
- base::RecordAction(UserMetricsAction("Accel_Toggle_Caps_Lock")); |
- chromeos::input_method::InputMethodManager* ime = |
- chromeos::input_method::InputMethodManager::Get(); |
- chromeos::input_method::ImeKeyboard* keyboard = ime->GetImeKeyboard(); |
- keyboard->SetCapsLockEnabled(!keyboard->CapsLockIsEnabled()); |
-} |
- |
void HandleToggleMirrorMode() { |
base::RecordAction(UserMetricsAction("Accel_Toggle_Mirror_Mode")); |
bool mirror = !Shell::GetInstance()->display_manager()->IsInMirrorMode(); |
@@ -663,13 +374,6 @@ void HandleToggleMirrorMode() { |
mirror, true /* user_action */); |
} |
-void HandleToggleSpokenFeedback() { |
- base::RecordAction(UserMetricsAction("Accel_Toggle_Spoken_Feedback")); |
- |
- WmShell::Get()->accessibility_delegate()->ToggleSpokenFeedback( |
- A11Y_NOTIFICATION_SHOW); |
-} |
- |
bool CanHandleTouchHud() { |
return RootWindowController::ForTargetRootWindow()->touch_hud_debug(); |
} |
@@ -684,336 +388,100 @@ void HandleTouchHudModeChange() { |
controller->touch_hud_debug()->ChangeToNextMode(); |
} |
-void HandleVolumeDown(const ui::Accelerator& accelerator) { |
- VolumeControlDelegate* volume_delegate = |
- WmShell::Get()->system_tray_delegate()->GetVolumeControlDelegate(); |
- if (volume_delegate) |
- volume_delegate->HandleVolumeDown(accelerator); |
-} |
- |
-void HandleVolumeMute(const ui::Accelerator& accelerator) { |
- VolumeControlDelegate* volume_delegate = |
- WmShell::Get()->system_tray_delegate()->GetVolumeControlDelegate(); |
- if (volume_delegate) |
- volume_delegate->HandleVolumeMute(accelerator); |
-} |
- |
-void HandleVolumeUp(const ui::Accelerator& accelerator) { |
- VolumeControlDelegate* volume_delegate = |
- WmShell::Get()->system_tray_delegate()->GetVolumeControlDelegate(); |
- if (volume_delegate) |
- volume_delegate->HandleVolumeUp(accelerator); |
-} |
- |
#endif // defined(OS_CHROMEOS) |
} // namespace |
-//////////////////////////////////////////////////////////////////////////////// |
-// AcceleratorController, public: |
- |
-AcceleratorController::AcceleratorController() |
- : accelerator_manager_(new ui::AcceleratorManager), |
- accelerator_history_(new ui::AcceleratorHistory) { |
- Init(); |
-} |
- |
-AcceleratorController::~AcceleratorController() {} |
- |
-void AcceleratorController::Register(const ui::Accelerator& accelerator, |
- ui::AcceleratorTarget* target) { |
- accelerator_manager_->Register( |
- accelerator, ui::AcceleratorManager::kNormalPriority, target); |
-} |
+AcceleratorControllerDelegateAura::AcceleratorControllerDelegateAura() {} |
-void AcceleratorController::Unregister(const ui::Accelerator& accelerator, |
- ui::AcceleratorTarget* target) { |
- accelerator_manager_->Unregister(accelerator, target); |
-} |
+AcceleratorControllerDelegateAura::~AcceleratorControllerDelegateAura() {} |
-void AcceleratorController::UnregisterAll(ui::AcceleratorTarget* target) { |
- accelerator_manager_->UnregisterAll(target); |
-} |
- |
-bool AcceleratorController::Process(const ui::Accelerator& accelerator) { |
- return accelerator_manager_->Process(accelerator); |
-} |
- |
-bool AcceleratorController::IsRegistered( |
- const ui::Accelerator& accelerator) const { |
- return accelerator_manager_->IsRegistered(accelerator); |
-} |
- |
-bool AcceleratorController::IsPreferred( |
- const ui::Accelerator& accelerator) const { |
- std::map<ui::Accelerator, AcceleratorAction>::const_iterator iter = |
- accelerators_.find(accelerator); |
- if (iter == accelerators_.end()) |
- return false; // not an accelerator. |
- |
- return preferred_actions_.find(iter->second) != preferred_actions_.end(); |
-} |
- |
-bool AcceleratorController::IsReserved( |
- const ui::Accelerator& accelerator) const { |
- std::map<ui::Accelerator, AcceleratorAction>::const_iterator iter = |
- accelerators_.find(accelerator); |
- if (iter == accelerators_.end()) |
- return false; // not an accelerator. |
- |
- return reserved_actions_.find(iter->second) != reserved_actions_.end(); |
-} |
- |
-bool AcceleratorController::IsDeprecated( |
- const ui::Accelerator& accelerator) const { |
- return deprecated_accelerators_.count(accelerator) != 0; |
-} |
- |
-bool AcceleratorController::PerformActionIfEnabled(AcceleratorAction action) { |
- if (CanPerformAction(action, ui::Accelerator())) { |
- PerformAction(action, ui::Accelerator()); |
- return true; |
- } |
- return false; |
-} |
- |
-AcceleratorController::AcceleratorProcessingRestriction |
-AcceleratorController::GetCurrentAcceleratorRestriction() { |
- return GetAcceleratorProcessingRestriction(-1); |
-} |
- |
-void AcceleratorController::SetImeControlDelegate( |
- std::unique_ptr<ImeControlDelegate> ime_control_delegate) { |
- ime_control_delegate_ = std::move(ime_control_delegate); |
-} |
- |
-void AcceleratorController::SetScreenshotDelegate( |
+void AcceleratorControllerDelegateAura::SetScreenshotDelegate( |
std::unique_ptr<ScreenshotDelegate> screenshot_delegate) { |
screenshot_delegate_ = std::move(screenshot_delegate); |
} |
-bool AcceleratorController::ShouldCloseMenuAndRepostAccelerator( |
- const ui::Accelerator& accelerator) const { |
- auto itr = accelerators_.find(accelerator); |
- if (itr == accelerators_.end()) |
- return false; // Menu shouldn't be closed for an invalid accelerator. |
- |
- AcceleratorAction action = itr->second; |
- return actions_keeping_menu_open_.count(action) == 0; |
-} |
- |
-//////////////////////////////////////////////////////////////////////////////// |
-// 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()); |
- AcceleratorAction action = it->second; |
- if (CanPerformAction(action, accelerator)) { |
- // Handling the deprecated accelerators (if any) only if action can be |
- // performed. |
- auto itr = actions_with_deprecations_.find(action); |
- if (itr != actions_with_deprecations_.end()) { |
- const DeprecatedAcceleratorData* data = itr->second; |
- if (deprecated_accelerators_.count(accelerator)) { |
- // This accelerator has been deprecated and should be treated according |
- // to its |DeprecatedAcceleratorData|. |
- |
- // Record UMA stats. |
- RecordUmaHistogram(data->uma_histogram_name, DEPRECATED_USED); |
- |
- // We always display the notification as long as this entry exists, |
- // except for NEXT_IME, we must check to avoid showing it for the wrong |
- // shortcut, as Alt+Shift is tricky and trigger the action on release. |
- if (action != NEXT_IME || |
- (action == NEXT_IME && |
- ShouldShowDeprecatedNextImeNotification( |
- accelerator_history_->previous_accelerator()))) { |
- ShowDeprecatedAcceleratorNotification( |
- data->uma_histogram_name, data->notification_message_id, |
- data->old_shortcut_id, data->new_shortcut_id); |
- } |
- |
- if (!data->deprecated_enabled) |
- return false; |
- } else { |
- // This is a new accelerator replacing the old deprecated one. |
- // Record UMA stats and proceed normally. |
- RecordUmaHistogram(data->uma_histogram_name, NEW_USED); |
- } |
- } |
- |
- PerformAction(action, accelerator); |
- return ShouldActionConsumeKeyEvent(action); |
- } |
- return false; |
-} |
- |
-bool AcceleratorController::CanHandleAccelerators() const { |
- return true; |
-} |
- |
-/////////////////////////////////////////////////////////////////////////////// |
-// AcceleratorController, private: |
- |
-void AcceleratorController::Init() { |
- 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 < kRepeatableActionsLength; ++i) |
- repeatable_actions_.insert(kRepeatableActions[i]); |
- for (size_t i = 0; i < kActionsAllowedInAppModeOrPinnedModeLength; ++i) { |
- actions_allowed_in_app_mode_.insert( |
- kActionsAllowedInAppModeOrPinnedMode[i]); |
- actions_allowed_in_pinned_mode_.insert( |
- kActionsAllowedInAppModeOrPinnedMode[i]); |
- } |
- for (size_t i = 0; i < kActionsAllowedInPinnedModeLength; ++i) |
- actions_allowed_in_pinned_mode_.insert(kActionsAllowedInPinnedMode[i]); |
- for (size_t i = 0; i < kActionsNeedingWindowLength; ++i) |
- actions_needing_window_.insert(kActionsNeedingWindow[i]); |
- for (size_t i = 0; i < kActionsKeepingMenuOpenLength; ++i) |
- actions_keeping_menu_open_.insert(kActionsKeepingMenuOpen[i]); |
- |
- RegisterAccelerators(kAcceleratorData, kAcceleratorDataLength); |
- |
- RegisterDeprecatedAccelerators(); |
- |
- 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); |
- } |
-} |
- |
-void AcceleratorController::RegisterAccelerators( |
- const AcceleratorData accelerators[], |
- size_t accelerators_length) { |
- for (size_t i = 0; i < accelerators_length; ++i) { |
- ui::Accelerator accelerator = |
- CreateAccelerator(accelerators[i].keycode, accelerators[i].modifiers, |
- accelerators[i].trigger_on_press); |
- Register(accelerator, this); |
- accelerators_.insert(std::make_pair(accelerator, accelerators[i].action)); |
- } |
-} |
+bool AcceleratorControllerDelegateAura::HandlesAction( |
+ AcceleratorAction action) { |
+ switch (action) { |
+ case FOCUS_SHELF: |
+ case LAUNCH_APP_0: |
+ case LAUNCH_APP_1: |
+ case LAUNCH_APP_2: |
+ case LAUNCH_APP_3: |
+ case LAUNCH_APP_4: |
+ case LAUNCH_APP_5: |
+ case LAUNCH_APP_6: |
+ case LAUNCH_APP_7: |
+ case LAUNCH_LAST_APP: |
+ case MAGNIFY_SCREEN_ZOOM_IN: |
+ case MAGNIFY_SCREEN_ZOOM_OUT: |
+ case NEW_INCOGNITO_WINDOW: |
+ case NEW_TAB: |
+ case NEW_WINDOW: |
+ case OPEN_FEEDBACK_PAGE: |
+ case RESTORE_TAB: |
+ case ROTATE_SCREEN: |
+ case ROTATE_WINDOW: |
+ case SCALE_UI_DOWN: |
+ case SCALE_UI_RESET: |
+ case SCALE_UI_UP: |
+ case SHOW_KEYBOARD_OVERLAY: |
+ case SHOW_MESSAGE_CENTER_BUBBLE: |
+ case SHOW_SYSTEM_TRAY_BUBBLE: |
+ case SHOW_TASK_MANAGER: |
+ case TAKE_PARTIAL_SCREENSHOT: |
+ case TAKE_SCREENSHOT: |
+ case TAKE_WINDOW_SCREENSHOT: |
+ case TOGGLE_APP_LIST: |
+ case UNPIN: |
+ return true; |
-void AcceleratorController::RegisterDeprecatedAccelerators() { |
#if defined(OS_CHROMEOS) |
- for (size_t i = 0; i < kDeprecatedAcceleratorsDataLength; ++i) { |
- const DeprecatedAcceleratorData* data = &kDeprecatedAcceleratorsData[i]; |
- actions_with_deprecations_[data->action] = data; |
- } |
- |
- for (size_t i = 0; i < kDeprecatedAcceleratorsLength; ++i) { |
- const AcceleratorData& accelerator_data = kDeprecatedAccelerators[i]; |
- const ui::Accelerator deprecated_accelerator = |
- CreateAccelerator(accelerator_data.keycode, accelerator_data.modifiers, |
- accelerator_data.trigger_on_press); |
+ case DISABLE_GPU_WATCHDOG: |
+ case LOCK_PRESSED: |
+ case LOCK_RELEASED: |
+ case OPEN_CROSH: |
+ case OPEN_FILE_MANAGER: |
+ case OPEN_GET_HELP: |
+ case POWER_PRESSED: |
+ case POWER_RELEASED: |
+ case SWAP_PRIMARY_DISPLAY: |
+ case TOGGLE_MIRROR_MODE: |
+ case TOUCH_HUD_CLEAR: |
+ case TOUCH_HUD_MODE_CHANGE: |
+ case TOUCH_HUD_PROJECTION_TOGGLE: |
+ return true; |
+#endif |
- Register(deprecated_accelerator, this); |
- accelerators_[deprecated_accelerator] = accelerator_data.action; |
- deprecated_accelerators_.insert(deprecated_accelerator); |
+ default: |
+ break; |
} |
-#endif // defined(OS_CHROMEOS) |
+ return false; |
} |
-bool AcceleratorController::CanPerformAction( |
+bool AcceleratorControllerDelegateAura::CanPerformAction( |
AcceleratorAction action, |
- const ui::Accelerator& accelerator) { |
- if (accelerator.IsRepeat() && !repeatable_actions_.count(action)) |
- return false; |
- |
- AcceleratorProcessingRestriction restriction = |
- GetAcceleratorProcessingRestriction(action); |
- if (restriction != RESTRICTION_NONE) |
- return restriction == RESTRICTION_PREVENT_PROCESSING_AND_PROPAGATION; |
- |
- const ui::Accelerator& previous_accelerator = |
- accelerator_history_->previous_accelerator(); |
- |
- // True should be returned if running |action| does something. Otherwise, |
- // false should be returned to give the web contents a chance at handling the |
- // accelerator. |
+ const ui::Accelerator& accelerator, |
+ const ui::Accelerator& previous_accelerator) { |
switch (action) { |
- case DEBUG_PRINT_LAYER_HIERARCHY: |
- case DEBUG_PRINT_VIEW_HIERARCHY: |
- case DEBUG_PRINT_WINDOW_HIERARCHY: |
- case DEBUG_TOGGLE_DESKTOP_BACKGROUND_MODE: |
- case DEBUG_TOGGLE_DEVICE_SCALE_FACTOR: |
- case DEBUG_TOGGLE_ROOT_WINDOW_FULL_SCREEN: |
- case DEBUG_TOGGLE_SHOW_DEBUG_BORDERS: |
- case DEBUG_TOGGLE_SHOW_FPS_COUNTER: |
- case DEBUG_TOGGLE_SHOW_PAINT_RECTS: |
- return debug::DebugAcceleratorsEnabled(); |
case MAGNIFY_SCREEN_ZOOM_IN: |
case MAGNIFY_SCREEN_ZOOM_OUT: |
return CanHandleMagnifyScreen(); |
case NEW_INCOGNITO_WINDOW: |
return CanHandleNewIncognitoWindow(); |
- case NEXT_IME: |
- return CanHandleNextIme(ime_control_delegate_.get()); |
- case PREVIOUS_IME: |
- return CanHandlePreviousIme(ime_control_delegate_.get()); |
+ case SCALE_UI_DOWN: |
case SCALE_UI_RESET: |
case SCALE_UI_UP: |
- case SCALE_UI_DOWN: |
return accelerators::IsInternalDisplayZoomEnabled(); |
case SHOW_MESSAGE_CENTER_BUBBLE: |
return CanHandleShowMessageCenterBubble(); |
- case SWITCH_IME: |
- return CanHandleSwitchIme(ime_control_delegate_.get(), accelerator); |
case TOGGLE_APP_LIST: |
return CanHandleToggleAppList(accelerator, previous_accelerator); |
- case WINDOW_CYCLE_SNAP_DOCK_LEFT: |
- case WINDOW_CYCLE_SNAP_DOCK_RIGHT: |
- return CanHandleWindowSnapOrDock(); |
- case WINDOW_POSITION_CENTER: |
- return CanHandlePositionCenter(); |
case UNPIN: |
return CanHandleUnpin(); |
-#if defined(OS_CHROMEOS) |
- case DEBUG_ADD_REMOVE_DISPLAY: |
- case DEBUG_SHOW_TOAST: |
- case DEBUG_TOGGLE_TOUCH_PAD: |
- case DEBUG_TOGGLE_TOUCH_SCREEN: |
- case DEBUG_TOGGLE_TOUCH_VIEW: |
- case DEBUG_TOGGLE_UNIFIED_DESKTOP: |
- return debug::DebugAcceleratorsEnabled(); |
- case DISABLE_CAPS_LOCK: |
- return CanHandleDisableCapsLock(previous_accelerator); |
- case LOCK_SCREEN: |
- return CanHandleLock(); |
- case SWITCH_TO_PREVIOUS_USER: |
- case SWITCH_TO_NEXT_USER: |
- return CanHandleCycleUser(); |
- case TOGGLE_CAPS_LOCK: |
- return CanHandleToggleCapsLock(accelerator, previous_accelerator); |
- case TOUCH_HUD_CLEAR: |
- case TOUCH_HUD_MODE_CHANGE: |
- return CanHandleTouchHud(); |
- case SWAP_PRIMARY_DISPLAY: |
- return display::Screen::GetScreen()->GetNumDisplays() > 1; |
-#endif |
- case CYCLE_BACKWARD_MRU: |
- case CYCLE_FORWARD_MRU: |
- case EXIT: |
- case FOCUS_NEXT_PANE: |
- case FOCUS_PREVIOUS_PANE: |
+ |
+ // Following are always enabled: |
case FOCUS_SHELF: |
case LAUNCH_APP_0: |
case LAUNCH_APP_1: |
@@ -1024,32 +492,29 @@ bool AcceleratorController::CanPerformAction( |
case LAUNCH_APP_6: |
case LAUNCH_APP_7: |
case LAUNCH_LAST_APP: |
- case MEDIA_NEXT_TRACK: |
- case MEDIA_PLAY_PAUSE: |
- case MEDIA_PREV_TRACK: |
case NEW_TAB: |
case NEW_WINDOW: |
case OPEN_FEEDBACK_PAGE: |
- case PRINT_UI_HIERARCHIES: |
case RESTORE_TAB: |
case ROTATE_SCREEN: |
case ROTATE_WINDOW: |
case SHOW_KEYBOARD_OVERLAY: |
case SHOW_SYSTEM_TRAY_BUBBLE: |
case SHOW_TASK_MANAGER: |
- case TAKE_WINDOW_SCREENSHOT: |
case TAKE_PARTIAL_SCREENSHOT: |
case TAKE_SCREENSHOT: |
- case TOGGLE_FULLSCREEN: |
- case TOGGLE_MAXIMIZED: |
- case TOGGLE_OVERVIEW: |
- case WINDOW_MINIMIZE: |
+ case TAKE_WINDOW_SCREENSHOT: |
+ return true; |
+ |
#if defined(OS_CHROMEOS) |
- case BRIGHTNESS_DOWN: |
- case BRIGHTNESS_UP: |
+ case SWAP_PRIMARY_DISPLAY: |
+ return display::Screen::GetScreen()->GetNumDisplays() > 1; |
+ case TOUCH_HUD_CLEAR: |
+ case TOUCH_HUD_MODE_CHANGE: |
+ return CanHandleTouchHud(); |
+ |
+ // Following are always enabled. |
case DISABLE_GPU_WATCHDOG: |
- case KEYBOARD_BRIGHTNESS_DOWN: |
- case KEYBOARD_BRIGHTNESS_UP: |
case LOCK_PRESSED: |
case LOCK_RELEASED: |
case OPEN_CROSH: |
@@ -1057,60 +522,22 @@ bool AcceleratorController::CanPerformAction( |
case OPEN_GET_HELP: |
case POWER_PRESSED: |
case POWER_RELEASED: |
- case SUSPEND: |
case TOGGLE_MIRROR_MODE: |
- case TOGGLE_SPOKEN_FEEDBACK: |
- case TOGGLE_WIFI: |
case TOUCH_HUD_PROJECTION_TOGGLE: |
- case VOLUME_DOWN: |
- case VOLUME_MUTE: |
- case VOLUME_UP: |
-#else |
- case DUMMY_FOR_RESERVED: |
-#endif |
return true; |
+#endif |
+ |
+ default: |
+ NOTREACHED(); |
+ break; |
} |
return false; |
} |
-void AcceleratorController::PerformAction(AcceleratorAction action, |
- const ui::Accelerator& accelerator) { |
- AcceleratorProcessingRestriction restriction = |
- GetAcceleratorProcessingRestriction(action); |
- if (restriction != RESTRICTION_NONE) |
- return; |
- |
- // If your accelerator invokes more than one line of code, please either |
- // implement it in your module's controller code (like TOGGLE_MIRROR_MODE |
- // below) or pull it into a HandleFoo() function above. |
+void AcceleratorControllerDelegateAura::PerformAction( |
+ AcceleratorAction action, |
+ const ui::Accelerator& accelerator) { |
switch (action) { |
- case CYCLE_BACKWARD_MRU: |
- HandleCycleBackwardMRU(accelerator); |
- break; |
- case CYCLE_FORWARD_MRU: |
- HandleCycleForwardMRU(accelerator); |
- break; |
- case DEBUG_PRINT_LAYER_HIERARCHY: |
- case DEBUG_PRINT_VIEW_HIERARCHY: |
- case DEBUG_PRINT_WINDOW_HIERARCHY: |
- case DEBUG_TOGGLE_DESKTOP_BACKGROUND_MODE: |
- case DEBUG_TOGGLE_DEVICE_SCALE_FACTOR: |
- case DEBUG_TOGGLE_ROOT_WINDOW_FULL_SCREEN: |
- case DEBUG_TOGGLE_SHOW_DEBUG_BORDERS: |
- case DEBUG_TOGGLE_SHOW_FPS_COUNTER: |
- case DEBUG_TOGGLE_SHOW_PAINT_RECTS: |
- debug::PerformDebugActionIfEnabled(action); |
- break; |
- case EXIT: |
- // UMA metrics are recorded in the handler. |
- exit_warning_handler_.HandleAccelerator(); |
- break; |
- case FOCUS_NEXT_PANE: |
- HandleRotatePaneFocus(FocusCycler::FORWARD); |
- break; |
- case FOCUS_PREVIOUS_PANE: |
- HandleRotatePaneFocus(FocusCycler::BACKWARD); |
- break; |
case FOCUS_SHELF: |
HandleFocusShelf(); |
break; |
@@ -1147,15 +574,6 @@ void AcceleratorController::PerformAction(AcceleratorAction action, |
case MAGNIFY_SCREEN_ZOOM_OUT: |
HandleMagnifyScreen(-1); |
break; |
- case MEDIA_NEXT_TRACK: |
- HandleMediaNextTrack(); |
- break; |
- case MEDIA_PLAY_PAUSE: |
- HandleMediaPlayPause(); |
- break; |
- case MEDIA_PREV_TRACK: |
- HandleMediaPrevTrack(); |
- break; |
case NEW_INCOGNITO_WINDOW: |
HandleNewIncognitoWindow(); |
break; |
@@ -1165,18 +583,9 @@ void AcceleratorController::PerformAction(AcceleratorAction action, |
case NEW_WINDOW: |
HandleNewWindow(); |
break; |
- case NEXT_IME: |
- HandleNextIme(ime_control_delegate_.get()); |
- break; |
case OPEN_FEEDBACK_PAGE: |
HandleOpenFeedbackPage(); |
break; |
- case PREVIOUS_IME: |
- HandlePreviousIme(ime_control_delegate_.get(), accelerator); |
- break; |
- case PRINT_UI_HIERARCHIES: |
- debug::PrintUIHierarchies(); |
- break; |
case RESTORE_TAB: |
HandleRestoreTab(); |
break; |
@@ -1207,94 +616,30 @@ void AcceleratorController::PerformAction(AcceleratorAction action, |
case SHOW_TASK_MANAGER: |
HandleShowTaskManager(); |
break; |
- case SWITCH_IME: |
- HandleSwitchIme(ime_control_delegate_.get(), accelerator); |
- break; |
- case TAKE_WINDOW_SCREENSHOT: |
- HandleTakeWindowScreenshot(screenshot_delegate_.get()); |
- break; |
case TAKE_PARTIAL_SCREENSHOT: |
HandleTakePartialScreenshot(screenshot_delegate_.get()); |
break; |
case TAKE_SCREENSHOT: |
HandleTakeScreenshot(screenshot_delegate_.get()); |
break; |
+ case TAKE_WINDOW_SCREENSHOT: |
+ HandleTakeWindowScreenshot(screenshot_delegate_.get()); |
+ break; |
case TOGGLE_APP_LIST: |
HandleToggleAppList(accelerator); |
break; |
- case TOGGLE_FULLSCREEN: |
- HandleToggleFullscreen(accelerator); |
- break; |
- case TOGGLE_MAXIMIZED: |
- accelerators::ToggleMaximized(); |
- break; |
- case TOGGLE_OVERVIEW: |
- HandleToggleOverview(); |
- break; |
- case WINDOW_CYCLE_SNAP_DOCK_LEFT: |
- case WINDOW_CYCLE_SNAP_DOCK_RIGHT: |
- HandleWindowSnapOrDock(action); |
- break; |
- case WINDOW_MINIMIZE: |
- HandleWindowMinimize(); |
- break; |
- case WINDOW_POSITION_CENTER: |
- HandlePositionCenter(); |
- break; |
case UNPIN: |
- HandleUnpin(); |
+ accelerators::Unpin(); |
break; |
#if defined(OS_CHROMEOS) |
- case BRIGHTNESS_DOWN: { |
- BrightnessControlDelegate* delegate = |
- WmShell::Get()->brightness_control_delegate(); |
- if (delegate) |
- delegate->HandleBrightnessDown(accelerator); |
- break; |
- } |
- case BRIGHTNESS_UP: { |
- BrightnessControlDelegate* delegate = |
- WmShell::Get()->brightness_control_delegate(); |
- if (delegate) |
- delegate->HandleBrightnessUp(accelerator); |
- break; |
- } |
- case DEBUG_ADD_REMOVE_DISPLAY: |
- case DEBUG_SHOW_TOAST: |
- case DEBUG_TOGGLE_TOUCH_PAD: |
- case DEBUG_TOGGLE_TOUCH_SCREEN: |
- case DEBUG_TOGGLE_TOUCH_VIEW: |
- case DEBUG_TOGGLE_UNIFIED_DESKTOP: |
- debug::PerformDebugActionIfEnabled(action); |
- break; |
- case DISABLE_CAPS_LOCK: |
- HandleDisableCapsLock(); |
- break; |
case DISABLE_GPU_WATCHDOG: |
Shell::GetInstance()->gpu_support()->DisableGpuWatchdog(); |
break; |
- case KEYBOARD_BRIGHTNESS_DOWN: { |
- KeyboardBrightnessControlDelegate* delegate = |
- WmShell::Get()->keyboard_brightness_control_delegate(); |
- if (delegate) |
- delegate->HandleKeyboardBrightnessDown(accelerator); |
- break; |
- } |
- case KEYBOARD_BRIGHTNESS_UP: { |
- KeyboardBrightnessControlDelegate* delegate = |
- WmShell::Get()->keyboard_brightness_control_delegate(); |
- if (delegate) |
- delegate->HandleKeyboardBrightnessUp(accelerator); |
- break; |
- } |
case LOCK_PRESSED: |
case LOCK_RELEASED: |
Shell::GetInstance()->power_button_controller()->OnLockButtonEvent( |
action == LOCK_PRESSED, base::TimeTicks()); |
break; |
- case LOCK_SCREEN: |
- HandleLock(); |
- break; |
case OPEN_CROSH: |
HandleCrosh(); |
break; |
@@ -1317,30 +662,12 @@ void AcceleratorController::PerformAction(AcceleratorAction action, |
// D-BUS), but we consume them to prevent them from getting |
// passed to apps -- see http://crbug.com/146609. |
break; |
- case SUSPEND: |
- HandleSuspend(); |
- break; |
case SWAP_PRIMARY_DISPLAY: |
HandleSwapPrimaryDisplay(); |
break; |
- case SWITCH_TO_NEXT_USER: |
- HandleCycleUser(SessionStateDelegate::CYCLE_TO_NEXT_USER); |
- break; |
- case SWITCH_TO_PREVIOUS_USER: |
- HandleCycleUser(SessionStateDelegate::CYCLE_TO_PREVIOUS_USER); |
- break; |
- case TOGGLE_CAPS_LOCK: |
- HandleToggleCapsLock(); |
- break; |
case TOGGLE_MIRROR_MODE: |
HandleToggleMirrorMode(); |
break; |
- case TOGGLE_SPOKEN_FEEDBACK: |
- HandleToggleSpokenFeedback(); |
- break; |
- case TOGGLE_WIFI: |
- WmShell::Get()->system_tray_notifier()->NotifyRequestToggleWifi(); |
- break; |
case TOUCH_HUD_CLEAR: |
HandleTouchHudClear(); |
break; |
@@ -1350,68 +677,32 @@ void AcceleratorController::PerformAction(AcceleratorAction action, |
case TOUCH_HUD_PROJECTION_TOGGLE: |
accelerators::ToggleTouchHudProjection(); |
break; |
- case VOLUME_DOWN: |
- HandleVolumeDown(accelerator); |
- break; |
- case VOLUME_MUTE: |
- HandleVolumeMute(accelerator); |
- break; |
- case VOLUME_UP: |
- HandleVolumeUp(accelerator); |
- break; |
-#else |
- case DUMMY_FOR_RESERVED: |
- NOTREACHED(); |
- break; |
#endif |
+ default: |
+ break; |
} |
} |
-bool AcceleratorController::ShouldActionConsumeKeyEvent( |
- AcceleratorAction action) { |
- // Adding new exceptions is *STRONGLY* discouraged. |
- return true; |
-} |
- |
-AcceleratorController::AcceleratorProcessingRestriction |
-AcceleratorController::GetAcceleratorProcessingRestriction(int action) { |
- if (WmShell::Get()->IsPinned() && |
- actions_allowed_in_pinned_mode_.find(action) == |
- actions_allowed_in_pinned_mode_.end()) { |
- return RESTRICTION_PREVENT_PROCESSING_AND_PROPAGATION; |
- } |
- WmShell* wm_shell = WmShell::Get(); |
- if (!wm_shell->GetSessionStateDelegate()->IsActiveUserSessionStarted() && |
- actions_allowed_at_login_screen_.find(action) == |
- actions_allowed_at_login_screen_.end()) { |
- return RESTRICTION_PREVENT_PROCESSING; |
- } |
- if (wm_shell->GetSessionStateDelegate()->IsScreenLocked() && |
- actions_allowed_at_lock_screen_.find(action) == |
- actions_allowed_at_lock_screen_.end()) { |
- return RESTRICTION_PREVENT_PROCESSING; |
- } |
- if (wm_shell->delegate()->IsRunningInForcedAppMode() && |
- actions_allowed_in_app_mode_.find(action) == |
- actions_allowed_in_app_mode_.end()) { |
- return RESTRICTION_PREVENT_PROCESSING; |
- } |
- if (WmShell::Get()->IsSystemModalWindowOpen() && |
- actions_allowed_at_modal_window_.find(action) == |
- actions_allowed_at_modal_window_.end()) { |
- // Note we prevent the shortcut from propagating so it will not |
- // be passed to the modal window. This is important for things like |
- // Alt+Tab that would cause an undesired effect in the modal window by |
- // cycling through its window elements. |
- return RESTRICTION_PREVENT_PROCESSING_AND_PROPAGATION; |
- } |
- if (wm_shell->mru_window_tracker()->BuildMruWindowList().empty() && |
- actions_needing_window_.find(action) != actions_needing_window_.end()) { |
- wm_shell->accessibility_delegate()->TriggerAccessibilityAlert( |
- A11Y_ALERT_WINDOW_NEEDED); |
- return RESTRICTION_PREVENT_PROCESSING_AND_PROPAGATION; |
- } |
- return RESTRICTION_NONE; |
+void AcceleratorControllerDelegateAura::ShowDeprecatedAcceleratorNotification( |
+ const char* const notification_id, |
+ int message_id, |
+ int old_shortcut_id, |
+ int new_shortcut_id) { |
+ const base::string16 message = |
+ GetNotificationText(message_id, old_shortcut_id, new_shortcut_id); |
+ std::unique_ptr<message_center::Notification> notification( |
+ new message_center::Notification( |
+ message_center::NOTIFICATION_TYPE_SIMPLE, notification_id, |
+ base::string16(), message, |
+ WmShell::Get()->delegate()->GetDeprecatedAcceleratorImage(), |
+ base::string16(), GURL(), |
+ message_center::NotifierId( |
+ message_center::NotifierId::SYSTEM_COMPONENT, |
+ system_notifier::kNotifierDeprecatedAccelerator), |
+ message_center::RichNotificationData(), |
+ new DeprecatedAcceleratorNotificationDelegate)); |
+ message_center::MessageCenter::Get()->AddNotification( |
+ std::move(notification)); |
} |
} // namespace ash |