| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ash/common/accelerators/accelerator_controller.h" | 5 #include "ash/common/accelerators/accelerator_controller.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "ash/common/accelerators/accelerator_commands.h" | 9 #include "ash/common/accelerators/accelerator_commands.h" |
| 10 #include "ash/common/accelerators/accelerator_controller_delegate.h" | 10 #include "ash/common/accelerators/accelerator_controller_delegate.h" |
| 11 #include "ash/common/accelerators/debug_commands.h" | 11 #include "ash/common/accelerators/debug_commands.h" |
| 12 #include "ash/common/accessibility_delegate.h" | 12 #include "ash/common/accessibility_delegate.h" |
| 13 #include "ash/common/accessibility_types.h" | 13 #include "ash/common/accessibility_types.h" |
| 14 #include "ash/common/focus_cycler.h" | 14 #include "ash/common/focus_cycler.h" |
| 15 #include "ash/common/ime_control_delegate.h" | 15 #include "ash/common/ime_control_delegate.h" |
| 16 #include "ash/common/media_delegate.h" | 16 #include "ash/common/media_delegate.h" |
| 17 #include "ash/common/multi_profile_uma.h" | 17 #include "ash/common/multi_profile_uma.h" |
| 18 #include "ash/common/new_window_controller.h" |
| 18 #include "ash/common/session/session_state_delegate.h" | 19 #include "ash/common/session/session_state_delegate.h" |
| 19 #include "ash/common/shelf/shelf_widget.h" | 20 #include "ash/common/shelf/shelf_widget.h" |
| 20 #include "ash/common/shelf/wm_shelf.h" | 21 #include "ash/common/shelf/wm_shelf.h" |
| 21 #include "ash/common/shell_delegate.h" | 22 #include "ash/common/shell_delegate.h" |
| 22 #include "ash/common/system/brightness_control_delegate.h" | 23 #include "ash/common/system/brightness_control_delegate.h" |
| 23 #include "ash/common/system/keyboard_brightness_control_delegate.h" | 24 #include "ash/common/system/keyboard_brightness_control_delegate.h" |
| 24 #include "ash/common/system/status_area_widget.h" | 25 #include "ash/common/system/status_area_widget.h" |
| 25 #include "ash/common/system/tray/system_tray_delegate.h" | 26 #include "ash/common/system/tray/system_tray_delegate.h" |
| 26 #include "ash/common/system/tray/system_tray_notifier.h" | 27 #include "ash/common/system/tray/system_tray_notifier.h" |
| 27 #include "ash/common/system/web_notification/web_notification_tray.h" | 28 #include "ash/common/system/web_notification/web_notification_tray.h" |
| 28 #include "ash/common/wm/mru_window_tracker.h" | 29 #include "ash/common/wm/mru_window_tracker.h" |
| 29 #include "ash/common/wm/overview/window_selector_controller.h" | 30 #include "ash/common/wm/overview/window_selector_controller.h" |
| 30 #include "ash/common/wm/window_cycle_controller.h" | 31 #include "ash/common/wm/window_cycle_controller.h" |
| 31 #include "ash/common/wm/window_positioning_utils.h" | 32 #include "ash/common/wm/window_positioning_utils.h" |
| 32 #include "ash/common/wm/window_state.h" | 33 #include "ash/common/wm/window_state.h" |
| 33 #include "ash/common/wm/wm_event.h" | 34 #include "ash/common/wm/wm_event.h" |
| 34 #include "ash/common/wm_root_window_controller.h" | 35 #include "ash/common/wm_root_window_controller.h" |
| 35 #include "ash/common/wm_shell.h" | 36 #include "ash/common/wm_shell.h" |
| 36 #include "ash/common/wm_window.h" | 37 #include "ash/common/wm_window.h" |
| 37 #include "ash/public/interfaces/new_window.mojom.h" | |
| 38 #include "base/metrics/histogram_macros.h" | 38 #include "base/metrics/histogram_macros.h" |
| 39 #include "base/metrics/user_metrics.h" | 39 #include "base/metrics/user_metrics.h" |
| 40 #include "ui/base/accelerators/accelerator.h" | 40 #include "ui/base/accelerators/accelerator.h" |
| 41 #include "ui/base/accelerators/accelerator_manager.h" | 41 #include "ui/base/accelerators/accelerator_manager.h" |
| 42 #include "ui/keyboard/keyboard_controller.h" | 42 #include "ui/keyboard/keyboard_controller.h" |
| 43 | 43 |
| 44 #if defined(OS_CHROMEOS) | 44 #if defined(OS_CHROMEOS) |
| 45 #include "ash/common/palette_delegate.h" | 45 #include "ash/common/palette_delegate.h" |
| 46 #include "ash/common/shelf/wm_shelf.h" | 46 #include "ash/common/shelf/wm_shelf.h" |
| 47 #include "ash/common/system/chromeos/ime_menu/ime_menu_tray.h" | 47 #include "ash/common/system/chromeos/ime_menu/ime_menu_tray.h" |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 void HandleMediaPrevTrack() { | 143 void HandleMediaPrevTrack() { |
| 144 WmShell::Get()->media_delegate()->HandleMediaPrevTrack(); | 144 WmShell::Get()->media_delegate()->HandleMediaPrevTrack(); |
| 145 } | 145 } |
| 146 | 146 |
| 147 bool CanHandleNewIncognitoWindow() { | 147 bool CanHandleNewIncognitoWindow() { |
| 148 return WmShell::Get()->delegate()->IsIncognitoAllowed(); | 148 return WmShell::Get()->delegate()->IsIncognitoAllowed(); |
| 149 } | 149 } |
| 150 | 150 |
| 151 void HandleNewIncognitoWindow() { | 151 void HandleNewIncognitoWindow() { |
| 152 base::RecordAction(UserMetricsAction("Accel_New_Incognito_Window")); | 152 base::RecordAction(UserMetricsAction("Accel_New_Incognito_Window")); |
| 153 WmShell::Get()->new_window_client()->NewWindow(true /* is_incognito */); | 153 WmShell::Get()->new_window_controller()->NewWindow(true /* is_incognito */); |
| 154 } | 154 } |
| 155 | 155 |
| 156 void HandleNewTab(const ui::Accelerator& accelerator) { | 156 void HandleNewTab(const ui::Accelerator& accelerator) { |
| 157 if (accelerator.key_code() == ui::VKEY_T) | 157 if (accelerator.key_code() == ui::VKEY_T) |
| 158 base::RecordAction(UserMetricsAction("Accel_NewTab_T")); | 158 base::RecordAction(UserMetricsAction("Accel_NewTab_T")); |
| 159 WmShell::Get()->new_window_client()->NewTab(); | 159 WmShell::Get()->new_window_controller()->NewTab(); |
| 160 } | 160 } |
| 161 | 161 |
| 162 void HandleNewWindow() { | 162 void HandleNewWindow() { |
| 163 base::RecordAction(UserMetricsAction("Accel_New_Window")); | 163 base::RecordAction(UserMetricsAction("Accel_New_Window")); |
| 164 WmShell::Get()->new_window_client()->NewWindow(false /* is_incognito */); | 164 WmShell::Get()->new_window_controller()->NewWindow(false /* is_incognito */); |
| 165 } | 165 } |
| 166 | 166 |
| 167 bool CanHandleNextIme(ImeControlDelegate* ime_control_delegate) { | 167 bool CanHandleNextIme(ImeControlDelegate* ime_control_delegate) { |
| 168 return ime_control_delegate && ime_control_delegate->CanCycleIme(); | 168 return ime_control_delegate && ime_control_delegate->CanCycleIme(); |
| 169 } | 169 } |
| 170 | 170 |
| 171 bool CanHandleCycleMru(const ui::Accelerator& accelerator) { | 171 bool CanHandleCycleMru(const ui::Accelerator& accelerator) { |
| 172 // Don't do anything when Alt+Tab comes from a virtual keyboard. Touchscreen | 172 // Don't do anything when Alt+Tab comes from a virtual keyboard. Touchscreen |
| 173 // users have better window switching options. See http://crbug.com/638269 | 173 // users have better window switching options. See http://crbug.com/638269 |
| 174 keyboard::KeyboardController* keyboard_controller = | 174 keyboard::KeyboardController* keyboard_controller = |
| (...skipping 22 matching lines...) Expand all Loading... |
| 197 } | 197 } |
| 198 } | 198 } |
| 199 | 199 |
| 200 void HandleNextIme(ImeControlDelegate* ime_control_delegate) { | 200 void HandleNextIme(ImeControlDelegate* ime_control_delegate) { |
| 201 base::RecordAction(UserMetricsAction("Accel_Next_Ime")); | 201 base::RecordAction(UserMetricsAction("Accel_Next_Ime")); |
| 202 ime_control_delegate->HandleNextIme(); | 202 ime_control_delegate->HandleNextIme(); |
| 203 } | 203 } |
| 204 | 204 |
| 205 void HandleOpenFeedbackPage() { | 205 void HandleOpenFeedbackPage() { |
| 206 base::RecordAction(UserMetricsAction("Accel_Open_Feedback_Page")); | 206 base::RecordAction(UserMetricsAction("Accel_Open_Feedback_Page")); |
| 207 WmShell::Get()->new_window_client()->OpenFeedbackPage(); | 207 WmShell::Get()->new_window_controller()->OpenFeedbackPage(); |
| 208 } | 208 } |
| 209 | 209 |
| 210 bool CanHandlePreviousIme(ImeControlDelegate* ime_control_delegate) { | 210 bool CanHandlePreviousIme(ImeControlDelegate* ime_control_delegate) { |
| 211 return ime_control_delegate && ime_control_delegate->CanCycleIme(); | 211 return ime_control_delegate && ime_control_delegate->CanCycleIme(); |
| 212 } | 212 } |
| 213 | 213 |
| 214 void HandlePreviousIme(ImeControlDelegate* ime_control_delegate, | 214 void HandlePreviousIme(ImeControlDelegate* ime_control_delegate, |
| 215 const ui::Accelerator& accelerator) { | 215 const ui::Accelerator& accelerator) { |
| 216 base::RecordAction(UserMetricsAction("Accel_Previous_Ime")); | 216 base::RecordAction(UserMetricsAction("Accel_Previous_Ime")); |
| 217 if (accelerator.type() == ui::ET_KEY_PRESSED) | 217 if (accelerator.type() == ui::ET_KEY_PRESSED) |
| 218 ime_control_delegate->HandlePreviousIme(); | 218 ime_control_delegate->HandlePreviousIme(); |
| 219 // Else: consume the Ctrl+Space ET_KEY_RELEASED event but do not do anything. | 219 // Else: consume the Ctrl+Space ET_KEY_RELEASED event but do not do anything. |
| 220 } | 220 } |
| 221 | 221 |
| 222 void HandleRestoreTab() { | 222 void HandleRestoreTab() { |
| 223 base::RecordAction(UserMetricsAction("Accel_Restore_Tab")); | 223 base::RecordAction(UserMetricsAction("Accel_Restore_Tab")); |
| 224 WmShell::Get()->new_window_client()->RestoreTab(); | 224 WmShell::Get()->new_window_controller()->RestoreTab(); |
| 225 } | 225 } |
| 226 | 226 |
| 227 void HandleShowKeyboardOverlay() { | 227 void HandleShowKeyboardOverlay() { |
| 228 base::RecordAction(UserMetricsAction("Accel_Show_Keyboard_Overlay")); | 228 base::RecordAction(UserMetricsAction("Accel_Show_Keyboard_Overlay")); |
| 229 WmShell::Get()->new_window_client()->ShowKeyboardOverlay(); | 229 WmShell::Get()->new_window_controller()->ShowKeyboardOverlay(); |
| 230 } | 230 } |
| 231 | 231 |
| 232 bool CanHandleShowMessageCenterBubble() { | 232 bool CanHandleShowMessageCenterBubble() { |
| 233 WmWindow* target_root = WmShell::Get()->GetRootWindowForNewWindows(); | 233 WmWindow* target_root = WmShell::Get()->GetRootWindowForNewWindows(); |
| 234 StatusAreaWidget* status_area_widget = | 234 StatusAreaWidget* status_area_widget = |
| 235 WmShelf::ForWindow(target_root)->shelf_widget()->status_area_widget(); | 235 WmShelf::ForWindow(target_root)->shelf_widget()->status_area_widget(); |
| 236 return status_area_widget && | 236 return status_area_widget && |
| 237 status_area_widget->web_notification_tray()->visible(); | 237 status_area_widget->web_notification_tray()->visible(); |
| 238 } | 238 } |
| 239 | 239 |
| 240 void HandleShowMessageCenterBubble() { | 240 void HandleShowMessageCenterBubble() { |
| 241 base::RecordAction(UserMetricsAction("Accel_Show_Message_Center_Bubble")); | 241 base::RecordAction(UserMetricsAction("Accel_Show_Message_Center_Bubble")); |
| 242 WmWindow* target_root = WmShell::Get()->GetRootWindowForNewWindows(); | 242 WmWindow* target_root = WmShell::Get()->GetRootWindowForNewWindows(); |
| 243 StatusAreaWidget* status_area_widget = | 243 StatusAreaWidget* status_area_widget = |
| 244 WmShelf::ForWindow(target_root)->shelf_widget()->status_area_widget(); | 244 WmShelf::ForWindow(target_root)->shelf_widget()->status_area_widget(); |
| 245 if (status_area_widget) { | 245 if (status_area_widget) { |
| 246 WebNotificationTray* notification_tray = | 246 WebNotificationTray* notification_tray = |
| 247 status_area_widget->web_notification_tray(); | 247 status_area_widget->web_notification_tray(); |
| 248 if (notification_tray->visible()) | 248 if (notification_tray->visible()) |
| 249 notification_tray->ShowMessageCenterBubble(); | 249 notification_tray->ShowMessageCenterBubble(); |
| 250 } | 250 } |
| 251 } | 251 } |
| 252 | 252 |
| 253 void HandleShowTaskManager() { | 253 void HandleShowTaskManager() { |
| 254 base::RecordAction(UserMetricsAction("Accel_Show_Task_Manager")); | 254 base::RecordAction(UserMetricsAction("Accel_Show_Task_Manager")); |
| 255 WmShell::Get()->new_window_client()->ShowTaskManager(); | 255 WmShell::Get()->new_window_controller()->ShowTaskManager(); |
| 256 } | 256 } |
| 257 | 257 |
| 258 bool CanHandleSwitchIme(ImeControlDelegate* ime_control_delegate, | 258 bool CanHandleSwitchIme(ImeControlDelegate* ime_control_delegate, |
| 259 const ui::Accelerator& accelerator) { | 259 const ui::Accelerator& accelerator) { |
| 260 return ime_control_delegate && | 260 return ime_control_delegate && |
| 261 ime_control_delegate->CanSwitchIme(accelerator); | 261 ime_control_delegate->CanSwitchIme(accelerator); |
| 262 } | 262 } |
| 263 | 263 |
| 264 void HandleSwitchIme(ImeControlDelegate* ime_control_delegate, | 264 void HandleSwitchIme(ImeControlDelegate* ime_control_delegate, |
| 265 const ui::Accelerator& accelerator) { | 265 const ui::Accelerator& accelerator) { |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 if (ime_menu_tray && ime_menu_tray->visible() && | 364 if (ime_menu_tray && ime_menu_tray->visible() && |
| 365 !ime_menu_tray->IsImeMenuBubbleShown()) { | 365 !ime_menu_tray->IsImeMenuBubbleShown()) { |
| 366 ime_menu_tray->ShowImeMenuBubble(); | 366 ime_menu_tray->ShowImeMenuBubble(); |
| 367 } | 367 } |
| 368 } | 368 } |
| 369 } | 369 } |
| 370 | 370 |
| 371 void HandleCrosh() { | 371 void HandleCrosh() { |
| 372 base::RecordAction(UserMetricsAction("Accel_Open_Crosh")); | 372 base::RecordAction(UserMetricsAction("Accel_Open_Crosh")); |
| 373 | 373 |
| 374 WmShell::Get()->new_window_client()->OpenCrosh(); | 374 WmShell::Get()->new_window_controller()->OpenCrosh(); |
| 375 } | 375 } |
| 376 | 376 |
| 377 bool CanHandleDisableCapsLock(const ui::Accelerator& previous_accelerator) { | 377 bool CanHandleDisableCapsLock(const ui::Accelerator& previous_accelerator) { |
| 378 ui::KeyboardCode previous_key_code = previous_accelerator.key_code(); | 378 ui::KeyboardCode previous_key_code = previous_accelerator.key_code(); |
| 379 if (previous_accelerator.type() == ui::ET_KEY_RELEASED || | 379 if (previous_accelerator.type() == ui::ET_KEY_RELEASED || |
| 380 (previous_key_code != ui::VKEY_LSHIFT && | 380 (previous_key_code != ui::VKEY_LSHIFT && |
| 381 previous_key_code != ui::VKEY_SHIFT && | 381 previous_key_code != ui::VKEY_SHIFT && |
| 382 previous_key_code != ui::VKEY_RSHIFT)) { | 382 previous_key_code != ui::VKEY_RSHIFT)) { |
| 383 // If something else was pressed between the Shift key being pressed | 383 // If something else was pressed between the Shift key being pressed |
| 384 // and released, then ignore the release of the Shift key. | 384 // and released, then ignore the release of the Shift key. |
| 385 return false; | 385 return false; |
| 386 } | 386 } |
| 387 chromeos::input_method::InputMethodManager* ime = | 387 chromeos::input_method::InputMethodManager* ime = |
| 388 chromeos::input_method::InputMethodManager::Get(); | 388 chromeos::input_method::InputMethodManager::Get(); |
| 389 chromeos::input_method::ImeKeyboard* keyboard = | 389 chromeos::input_method::ImeKeyboard* keyboard = |
| 390 ime ? ime->GetImeKeyboard() : NULL; | 390 ime ? ime->GetImeKeyboard() : NULL; |
| 391 return (keyboard && keyboard->CapsLockIsEnabled()); | 391 return (keyboard && keyboard->CapsLockIsEnabled()); |
| 392 } | 392 } |
| 393 | 393 |
| 394 void HandleDisableCapsLock() { | 394 void HandleDisableCapsLock() { |
| 395 base::RecordAction(UserMetricsAction("Accel_Disable_Caps_Lock")); | 395 base::RecordAction(UserMetricsAction("Accel_Disable_Caps_Lock")); |
| 396 chromeos::input_method::InputMethodManager* ime = | 396 chromeos::input_method::InputMethodManager* ime = |
| 397 chromeos::input_method::InputMethodManager::Get(); | 397 chromeos::input_method::InputMethodManager::Get(); |
| 398 ime->GetImeKeyboard()->SetCapsLockEnabled(false); | 398 ime->GetImeKeyboard()->SetCapsLockEnabled(false); |
| 399 } | 399 } |
| 400 | 400 |
| 401 void HandleFileManager() { | 401 void HandleFileManager() { |
| 402 base::RecordAction(UserMetricsAction("Accel_Open_File_Manager")); | 402 base::RecordAction(UserMetricsAction("Accel_Open_File_Manager")); |
| 403 | 403 |
| 404 WmShell::Get()->new_window_client()->OpenFileManager(); | 404 WmShell::Get()->new_window_controller()->OpenFileManager(); |
| 405 } | 405 } |
| 406 | 406 |
| 407 void HandleGetHelp() { | 407 void HandleGetHelp() { |
| 408 WmShell::Get()->new_window_client()->OpenGetHelp(); | 408 WmShell::Get()->new_window_controller()->OpenGetHelp(); |
| 409 } | 409 } |
| 410 | 410 |
| 411 bool CanHandleLock() { | 411 bool CanHandleLock() { |
| 412 return WmShell::Get()->GetSessionStateDelegate()->CanLockScreen(); | 412 return WmShell::Get()->GetSessionStateDelegate()->CanLockScreen(); |
| 413 } | 413 } |
| 414 | 414 |
| 415 void HandleLock() { | 415 void HandleLock() { |
| 416 base::RecordAction(UserMetricsAction("Accel_LockScreen_L")); | 416 base::RecordAction(UserMetricsAction("Accel_LockScreen_L")); |
| 417 WmShell::Get()->GetSessionStateDelegate()->LockScreen(); | 417 WmShell::Get()->GetSessionStateDelegate()->LockScreen(); |
| 418 } | 418 } |
| (...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1168 if (wm_shell->mru_window_tracker()->BuildMruWindowList().empty() && | 1168 if (wm_shell->mru_window_tracker()->BuildMruWindowList().empty() && |
| 1169 actions_needing_window_.find(action) != actions_needing_window_.end()) { | 1169 actions_needing_window_.find(action) != actions_needing_window_.end()) { |
| 1170 wm_shell->accessibility_delegate()->TriggerAccessibilityAlert( | 1170 wm_shell->accessibility_delegate()->TriggerAccessibilityAlert( |
| 1171 A11Y_ALERT_WINDOW_NEEDED); | 1171 A11Y_ALERT_WINDOW_NEEDED); |
| 1172 return RESTRICTION_PREVENT_PROCESSING_AND_PROPAGATION; | 1172 return RESTRICTION_PREVENT_PROCESSING_AND_PROPAGATION; |
| 1173 } | 1173 } |
| 1174 return RESTRICTION_NONE; | 1174 return RESTRICTION_NONE; |
| 1175 } | 1175 } |
| 1176 | 1176 |
| 1177 } // namespace ash | 1177 } // namespace ash |
| OLD | NEW |