Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(855)

Side by Side Diff: ash/common/accelerators/accelerator_controller.cc

Issue 2766543002: Move even more from WmShell to Shell (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 base::RecordAction(UserMetricsAction("Accel_Launch_App")); 213 base::RecordAction(UserMetricsAction("Accel_Launch_App"));
214 WmShelf::LaunchShelfItem(n); 214 WmShelf::LaunchShelfItem(n);
215 } 215 }
216 216
217 void HandleLaunchLastApp() { 217 void HandleLaunchLastApp() {
218 base::RecordAction(UserMetricsAction("Accel_Launch_Last_App")); 218 base::RecordAction(UserMetricsAction("Accel_Launch_Last_App"));
219 WmShelf::LaunchShelfItem(-1); 219 WmShelf::LaunchShelfItem(-1);
220 } 220 }
221 221
222 void HandleMediaNextTrack() { 222 void HandleMediaNextTrack() {
223 WmShell::Get()->media_controller()->HandleMediaNextTrack(); 223 Shell::Get()->media_controller()->HandleMediaNextTrack();
224 } 224 }
225 225
226 void HandleMediaPlayPause() { 226 void HandleMediaPlayPause() {
227 WmShell::Get()->media_controller()->HandleMediaPlayPause(); 227 Shell::Get()->media_controller()->HandleMediaPlayPause();
228 } 228 }
229 229
230 void HandleMediaPrevTrack() { 230 void HandleMediaPrevTrack() {
231 WmShell::Get()->media_controller()->HandleMediaPrevTrack(); 231 Shell::Get()->media_controller()->HandleMediaPrevTrack();
232 } 232 }
233 233
234 bool CanHandleNewIncognitoWindow() { 234 bool CanHandleNewIncognitoWindow() {
235 return Shell::Get()->shell_delegate()->IsIncognitoAllowed(); 235 return Shell::Get()->shell_delegate()->IsIncognitoAllowed();
236 } 236 }
237 237
238 void HandleNewIncognitoWindow() { 238 void HandleNewIncognitoWindow() {
239 base::RecordAction(UserMetricsAction("Accel_New_Incognito_Window")); 239 base::RecordAction(UserMetricsAction("Accel_New_Incognito_Window"));
240 WmShell::Get()->new_window_controller()->NewWindow(true /* is_incognito */); 240 Shell::Get()->new_window_controller()->NewWindow(true /* is_incognito */);
241 } 241 }
242 242
243 void HandleNewTab(const ui::Accelerator& accelerator) { 243 void HandleNewTab(const ui::Accelerator& accelerator) {
244 if (accelerator.key_code() == ui::VKEY_T) 244 if (accelerator.key_code() == ui::VKEY_T)
245 base::RecordAction(UserMetricsAction("Accel_NewTab_T")); 245 base::RecordAction(UserMetricsAction("Accel_NewTab_T"));
246 WmShell::Get()->new_window_controller()->NewTab(); 246 Shell::Get()->new_window_controller()->NewTab();
247 } 247 }
248 248
249 void HandleNewWindow() { 249 void HandleNewWindow() {
250 base::RecordAction(UserMetricsAction("Accel_New_Window")); 250 base::RecordAction(UserMetricsAction("Accel_New_Window"));
251 WmShell::Get()->new_window_controller()->NewWindow(false /* is_incognito */); 251 Shell::Get()->new_window_controller()->NewWindow(false /* is_incognito */);
252 } 252 }
253 253
254 bool CanHandleNextIme(ImeControlDelegate* ime_control_delegate) { 254 bool CanHandleNextIme(ImeControlDelegate* ime_control_delegate) {
255 return ime_control_delegate && ime_control_delegate->CanCycleIme(); 255 return ime_control_delegate && ime_control_delegate->CanCycleIme();
256 } 256 }
257 257
258 bool CanHandleCycleMru(const ui::Accelerator& accelerator) { 258 bool CanHandleCycleMru(const ui::Accelerator& accelerator) {
259 // Don't do anything when Alt+Tab is hit while a virtual keyboard is showing. 259 // Don't do anything when Alt+Tab is hit while a virtual keyboard is showing.
260 // Touchscreen users have better window switching options. It would be 260 // Touchscreen users have better window switching options. It would be
261 // preferable if we could tell whether this event actually came from a virtual 261 // preferable if we could tell whether this event actually came from a virtual
262 // keyboard, but there's no easy way to do so, thus we block Alt+Tab when the 262 // keyboard, but there's no easy way to do so, thus we block Alt+Tab when the
263 // virtual keyboard is showing, even if it came from a real keyboard. See 263 // virtual keyboard is showing, even if it came from a real keyboard. See
264 // http://crbug.com/638269 264 // http://crbug.com/638269
265 keyboard::KeyboardController* keyboard_controller = 265 keyboard::KeyboardController* keyboard_controller =
266 keyboard::KeyboardController::GetInstance(); 266 keyboard::KeyboardController::GetInstance();
267 return !(keyboard_controller && keyboard_controller->keyboard_visible()); 267 return !(keyboard_controller && keyboard_controller->keyboard_visible());
268 } 268 }
269 269
270 void HandleNextIme(ImeControlDelegate* ime_control_delegate) { 270 void HandleNextIme(ImeControlDelegate* ime_control_delegate) {
271 base::RecordAction(UserMetricsAction("Accel_Next_Ime")); 271 base::RecordAction(UserMetricsAction("Accel_Next_Ime"));
272 ime_control_delegate->HandleNextIme(); 272 ime_control_delegate->HandleNextIme();
273 } 273 }
274 274
275 void HandleOpenFeedbackPage() { 275 void HandleOpenFeedbackPage() {
276 base::RecordAction(UserMetricsAction("Accel_Open_Feedback_Page")); 276 base::RecordAction(UserMetricsAction("Accel_Open_Feedback_Page"));
277 WmShell::Get()->new_window_controller()->OpenFeedbackPage(); 277 Shell::Get()->new_window_controller()->OpenFeedbackPage();
278 } 278 }
279 279
280 bool CanHandlePreviousIme(ImeControlDelegate* ime_control_delegate) { 280 bool CanHandlePreviousIme(ImeControlDelegate* ime_control_delegate) {
281 return ime_control_delegate && ime_control_delegate->CanCycleIme(); 281 return ime_control_delegate && ime_control_delegate->CanCycleIme();
282 } 282 }
283 283
284 void HandlePreviousIme(ImeControlDelegate* ime_control_delegate, 284 void HandlePreviousIme(ImeControlDelegate* ime_control_delegate,
285 const ui::Accelerator& accelerator) { 285 const ui::Accelerator& accelerator) {
286 base::RecordAction(UserMetricsAction("Accel_Previous_Ime")); 286 base::RecordAction(UserMetricsAction("Accel_Previous_Ime"));
287 if (accelerator.key_state() == ui::Accelerator::KeyState::PRESSED) 287 if (accelerator.key_state() == ui::Accelerator::KeyState::PRESSED)
288 ime_control_delegate->HandlePreviousIme(); 288 ime_control_delegate->HandlePreviousIme();
289 // Else: consume the Ctrl+Space ET_KEY_RELEASED event but do not do anything. 289 // Else: consume the Ctrl+Space ET_KEY_RELEASED event but do not do anything.
290 } 290 }
291 291
292 void HandleRestoreTab() { 292 void HandleRestoreTab() {
293 base::RecordAction(UserMetricsAction("Accel_Restore_Tab")); 293 base::RecordAction(UserMetricsAction("Accel_Restore_Tab"));
294 WmShell::Get()->new_window_controller()->RestoreTab(); 294 Shell::Get()->new_window_controller()->RestoreTab();
295 } 295 }
296 296
297 // Rotate the active window. 297 // Rotate the active window.
298 void HandleRotateActiveWindow() { 298 void HandleRotateActiveWindow() {
299 base::RecordAction(UserMetricsAction("Accel_Rotate_Active_Window")); 299 base::RecordAction(UserMetricsAction("Accel_Rotate_Active_Window"));
300 aura::Window* active_window = wm::GetActiveWindow(); 300 aura::Window* active_window = wm::GetActiveWindow();
301 if (!active_window) 301 if (!active_window)
302 return; 302 return;
303 // The rotation animation bases its target transform on the current 303 // The rotation animation bases its target transform on the current
304 // rotation and position. Since there could be an animation in progress 304 // rotation and position. Since there could be an animation in progress
305 // right now, queue this animation so when it starts it picks up a neutral 305 // right now, queue this animation so when it starts it picks up a neutral
306 // rotation and position. Use replace so we only enqueue one at a time. 306 // rotation and position. Use replace so we only enqueue one at a time.
307 active_window->layer()->GetAnimator()->set_preemption_strategy( 307 active_window->layer()->GetAnimator()->set_preemption_strategy(
308 ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS); 308 ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS);
309 active_window->layer()->GetAnimator()->StartAnimation( 309 active_window->layer()->GetAnimator()->StartAnimation(
310 new ui::LayerAnimationSequence( 310 new ui::LayerAnimationSequence(
311 base::MakeUnique<WindowRotation>(360, active_window->layer()))); 311 base::MakeUnique<WindowRotation>(360, active_window->layer())));
312 } 312 }
313 313
314 void HandleShowKeyboardOverlay() { 314 void HandleShowKeyboardOverlay() {
315 base::RecordAction(UserMetricsAction("Accel_Show_Keyboard_Overlay")); 315 base::RecordAction(UserMetricsAction("Accel_Show_Keyboard_Overlay"));
316 WmShell::Get()->new_window_controller()->ShowKeyboardOverlay(); 316 Shell::Get()->new_window_controller()->ShowKeyboardOverlay();
317 } 317 }
318 318
319 bool CanHandleShowMessageCenterBubble() { 319 bool CanHandleShowMessageCenterBubble() {
320 WmWindow* target_root = Shell::GetWmRootWindowForNewWindows(); 320 WmWindow* target_root = Shell::GetWmRootWindowForNewWindows();
321 StatusAreaWidget* status_area_widget = 321 StatusAreaWidget* status_area_widget =
322 WmShelf::ForWindow(target_root)->shelf_widget()->status_area_widget(); 322 WmShelf::ForWindow(target_root)->shelf_widget()->status_area_widget();
323 return status_area_widget && 323 return status_area_widget &&
324 status_area_widget->web_notification_tray()->visible(); 324 status_area_widget->web_notification_tray()->visible();
325 } 325 }
326 326
(...skipping 15 matching lines...) Expand all
342 WmWindow* target_root = Shell::GetWmRootWindowForNewWindows(); 342 WmWindow* target_root = Shell::GetWmRootWindowForNewWindows();
343 SystemTray* tray = target_root->GetRootWindowController()->GetSystemTray(); 343 SystemTray* tray = target_root->GetRootWindowController()->GetSystemTray();
344 if (!tray->HasSystemBubble()) { 344 if (!tray->HasSystemBubble()) {
345 tray->ShowDefaultView(BUBBLE_CREATE_NEW); 345 tray->ShowDefaultView(BUBBLE_CREATE_NEW);
346 tray->ActivateBubble(); 346 tray->ActivateBubble();
347 } 347 }
348 } 348 }
349 349
350 void HandleShowTaskManager() { 350 void HandleShowTaskManager() {
351 base::RecordAction(UserMetricsAction("Accel_Show_Task_Manager")); 351 base::RecordAction(UserMetricsAction("Accel_Show_Task_Manager"));
352 WmShell::Get()->new_window_controller()->ShowTaskManager(); 352 Shell::Get()->new_window_controller()->ShowTaskManager();
353 } 353 }
354 354
355 bool CanHandleSwitchIme(ImeControlDelegate* ime_control_delegate, 355 bool CanHandleSwitchIme(ImeControlDelegate* ime_control_delegate,
356 const ui::Accelerator& accelerator) { 356 const ui::Accelerator& accelerator) {
357 return ime_control_delegate && 357 return ime_control_delegate &&
358 ime_control_delegate->CanSwitchIme(accelerator); 358 ime_control_delegate->CanSwitchIme(accelerator);
359 } 359 }
360 360
361 void HandleSwitchIme(ImeControlDelegate* ime_control_delegate, 361 void HandleSwitchIme(ImeControlDelegate* ime_control_delegate,
362 const ui::Accelerator& accelerator) { 362 const ui::Accelerator& accelerator) {
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 if (ime_menu_tray && ime_menu_tray->visible() && 456 if (ime_menu_tray && ime_menu_tray->visible() &&
457 !ime_menu_tray->IsImeMenuBubbleShown()) { 457 !ime_menu_tray->IsImeMenuBubbleShown()) {
458 ime_menu_tray->ShowImeMenuBubble(); 458 ime_menu_tray->ShowImeMenuBubble();
459 } 459 }
460 } 460 }
461 } 461 }
462 462
463 void HandleCrosh() { 463 void HandleCrosh() {
464 base::RecordAction(UserMetricsAction("Accel_Open_Crosh")); 464 base::RecordAction(UserMetricsAction("Accel_Open_Crosh"));
465 465
466 WmShell::Get()->new_window_controller()->OpenCrosh(); 466 Shell::Get()->new_window_controller()->OpenCrosh();
467 } 467 }
468 468
469 bool CanHandleDisableCapsLock(const ui::Accelerator& previous_accelerator) { 469 bool CanHandleDisableCapsLock(const ui::Accelerator& previous_accelerator) {
470 ui::KeyboardCode previous_key_code = previous_accelerator.key_code(); 470 ui::KeyboardCode previous_key_code = previous_accelerator.key_code();
471 if (previous_accelerator.key_state() == ui::Accelerator::KeyState::RELEASED || 471 if (previous_accelerator.key_state() == ui::Accelerator::KeyState::RELEASED ||
472 (previous_key_code != ui::VKEY_LSHIFT && 472 (previous_key_code != ui::VKEY_LSHIFT &&
473 previous_key_code != ui::VKEY_SHIFT && 473 previous_key_code != ui::VKEY_SHIFT &&
474 previous_key_code != ui::VKEY_RSHIFT)) { 474 previous_key_code != ui::VKEY_RSHIFT)) {
475 // If something else was pressed between the Shift key being pressed 475 // If something else was pressed between the Shift key being pressed
476 // and released, then ignore the release of the Shift key. 476 // and released, then ignore the release of the Shift key.
477 return false; 477 return false;
478 } 478 }
479 chromeos::input_method::InputMethodManager* ime = 479 chromeos::input_method::InputMethodManager* ime =
480 chromeos::input_method::InputMethodManager::Get(); 480 chromeos::input_method::InputMethodManager::Get();
481 chromeos::input_method::ImeKeyboard* keyboard = 481 chromeos::input_method::ImeKeyboard* keyboard =
482 ime ? ime->GetImeKeyboard() : NULL; 482 ime ? ime->GetImeKeyboard() : NULL;
483 return (keyboard && keyboard->CapsLockIsEnabled()); 483 return (keyboard && keyboard->CapsLockIsEnabled());
484 } 484 }
485 485
486 void HandleDisableCapsLock() { 486 void HandleDisableCapsLock() {
487 base::RecordAction(UserMetricsAction("Accel_Disable_Caps_Lock")); 487 base::RecordAction(UserMetricsAction("Accel_Disable_Caps_Lock"));
488 chromeos::input_method::InputMethodManager* ime = 488 chromeos::input_method::InputMethodManager* ime =
489 chromeos::input_method::InputMethodManager::Get(); 489 chromeos::input_method::InputMethodManager::Get();
490 ime->GetImeKeyboard()->SetCapsLockEnabled(false); 490 ime->GetImeKeyboard()->SetCapsLockEnabled(false);
491 } 491 }
492 492
493 void HandleFileManager() { 493 void HandleFileManager() {
494 base::RecordAction(UserMetricsAction("Accel_Open_File_Manager")); 494 base::RecordAction(UserMetricsAction("Accel_Open_File_Manager"));
495 495
496 WmShell::Get()->new_window_controller()->OpenFileManager(); 496 Shell::Get()->new_window_controller()->OpenFileManager();
497 } 497 }
498 498
499 void HandleGetHelp() { 499 void HandleGetHelp() {
500 WmShell::Get()->new_window_controller()->OpenGetHelp(); 500 Shell::Get()->new_window_controller()->OpenGetHelp();
501 } 501 }
502 502
503 bool CanHandleLock() { 503 bool CanHandleLock() {
504 return WmShell::Get()->session_controller()->CanLockScreen(); 504 return WmShell::Get()->session_controller()->CanLockScreen();
505 } 505 }
506 506
507 void HandleLock() { 507 void HandleLock() {
508 base::RecordAction(UserMetricsAction("Accel_LockScreen_L")); 508 base::RecordAction(UserMetricsAction("Accel_LockScreen_L"));
509 WmShell::Get()->session_controller()->LockScreen(); 509 WmShell::Get()->session_controller()->LockScreen();
510 } 510 }
(...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after
1235 if (wm_shell->session_controller()->IsScreenLocked() && 1235 if (wm_shell->session_controller()->IsScreenLocked() &&
1236 actions_allowed_at_lock_screen_.find(action) == 1236 actions_allowed_at_lock_screen_.find(action) ==
1237 actions_allowed_at_lock_screen_.end()) { 1237 actions_allowed_at_lock_screen_.end()) {
1238 return RESTRICTION_PREVENT_PROCESSING; 1238 return RESTRICTION_PREVENT_PROCESSING;
1239 } 1239 }
1240 if (Shell::Get()->shell_delegate()->IsRunningInForcedAppMode() && 1240 if (Shell::Get()->shell_delegate()->IsRunningInForcedAppMode() &&
1241 actions_allowed_in_app_mode_.find(action) == 1241 actions_allowed_in_app_mode_.find(action) ==
1242 actions_allowed_in_app_mode_.end()) { 1242 actions_allowed_in_app_mode_.end()) {
1243 return RESTRICTION_PREVENT_PROCESSING; 1243 return RESTRICTION_PREVENT_PROCESSING;
1244 } 1244 }
1245 if (WmShell::Get()->IsSystemModalWindowOpen() && 1245 if (wm_shell->IsSystemModalWindowOpen() &&
1246 actions_allowed_at_modal_window_.find(action) == 1246 actions_allowed_at_modal_window_.find(action) ==
1247 actions_allowed_at_modal_window_.end()) { 1247 actions_allowed_at_modal_window_.end()) {
1248 // Note we prevent the shortcut from propagating so it will not 1248 // Note we prevent the shortcut from propagating so it will not
1249 // be passed to the modal window. This is important for things like 1249 // be passed to the modal window. This is important for things like
1250 // Alt+Tab that would cause an undesired effect in the modal window by 1250 // Alt+Tab that would cause an undesired effect in the modal window by
1251 // cycling through its window elements. 1251 // cycling through its window elements.
1252 return RESTRICTION_PREVENT_PROCESSING_AND_PROPAGATION; 1252 return RESTRICTION_PREVENT_PROCESSING_AND_PROPAGATION;
1253 } 1253 }
1254 if (wm_shell->mru_window_tracker()->BuildMruWindowList().empty() && 1254 if (Shell::Get()->mru_window_tracker()->BuildMruWindowList().empty() &&
1255 actions_needing_window_.find(action) != actions_needing_window_.end()) { 1255 actions_needing_window_.find(action) != actions_needing_window_.end()) {
1256 Shell::GetInstance()->accessibility_delegate()->TriggerAccessibilityAlert( 1256 Shell::GetInstance()->accessibility_delegate()->TriggerAccessibilityAlert(
1257 A11Y_ALERT_WINDOW_NEEDED); 1257 A11Y_ALERT_WINDOW_NEEDED);
1258 return RESTRICTION_PREVENT_PROCESSING_AND_PROPAGATION; 1258 return RESTRICTION_PREVENT_PROCESSING_AND_PROPAGATION;
1259 } 1259 }
1260 return RESTRICTION_NONE; 1260 return RESTRICTION_NONE;
1261 } 1261 }
1262 1262
1263 AcceleratorController::AcceleratorProcessingStatus 1263 AcceleratorController::AcceleratorProcessingStatus
1264 AcceleratorController::MaybeDeprecatedAcceleratorPressed( 1264 AcceleratorController::MaybeDeprecatedAcceleratorPressed(
(...skipping 27 matching lines...) Expand all
1292 data->uma_histogram_name, data->notification_message_id, 1292 data->uma_histogram_name, data->notification_message_id,
1293 data->old_shortcut_id, data->new_shortcut_id); 1293 data->old_shortcut_id, data->new_shortcut_id);
1294 1294
1295 if (!data->deprecated_enabled) 1295 if (!data->deprecated_enabled)
1296 return AcceleratorProcessingStatus::STOP; 1296 return AcceleratorProcessingStatus::STOP;
1297 1297
1298 return AcceleratorProcessingStatus::PROCEED; 1298 return AcceleratorProcessingStatus::PROCEED;
1299 } 1299 }
1300 1300
1301 } // namespace ash 1301 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/accelerators/accelerator_commands.cc ('k') | ash/common/accelerators/debug_commands.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698