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

Side by Side Diff: ash/accelerators/accelerator_controller_delegate_aura.cc

Issue 2276233002: ash/chromeos: Add shift-alt-p shortcut to open palette. (Closed)
Patch Set: Initial upload Created 4 years, 3 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/accelerators/accelerator_controller_delegate_aura.h" 5 #include "ash/accelerators/accelerator_controller_delegate_aura.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 #include "ui/display/screen.h" 61 #include "ui/display/screen.h"
62 #include "ui/events/event.h" 62 #include "ui/events/event.h"
63 #include "ui/events/keycodes/keyboard_codes.h" 63 #include "ui/events/keycodes/keyboard_codes.h"
64 #include "ui/gfx/canvas.h" 64 #include "ui/gfx/canvas.h"
65 #include "ui/gfx/image/image_skia.h" 65 #include "ui/gfx/image/image_skia.h"
66 #include "ui/message_center/message_center.h" 66 #include "ui/message_center/message_center.h"
67 #include "ui/message_center/notification.h" 67 #include "ui/message_center/notification.h"
68 #include "ui/message_center/notifier_settings.h" 68 #include "ui/message_center/notifier_settings.h"
69 69
70 #if defined(OS_CHROMEOS) 70 #if defined(OS_CHROMEOS)
71 #include "ash/common/palette_delegate.h"
James Cook 2016/08/26 01:05:51 Since this code is in ash/common you should be abl
jdufault 2016/08/26 02:44:56 Done.
72 #include "ash/common/system/chromeos/palette/palette_tray.h"
73 #include "ash/common/system/chromeos/palette/palette_utils.h"
71 #include "ash/display/display_configuration_controller.h" 74 #include "ash/display/display_configuration_controller.h"
72 #include "base/sys_info.h" 75 #include "base/sys_info.h"
73 #endif // defined(OS_CHROMEOS) 76 #endif // defined(OS_CHROMEOS)
74 77
75 namespace ash { 78 namespace ash {
76 namespace { 79 namespace {
77 80
78 using base::UserMetricsAction; 81 using base::UserMetricsAction;
79 82
80 // The notification delegate that will be used to open the keyboard shortcut 83 // The notification delegate that will be used to open the keyboard shortcut
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 break; 317 break;
315 } 318 }
316 } 319 }
317 320
318 bool CanHandleUnpin() { 321 bool CanHandleUnpin() {
319 wm::WindowState* window_state = wm::GetActiveWindowState(); 322 wm::WindowState* window_state = wm::GetActiveWindowState();
320 return window_state && window_state->IsPinned(); 323 return window_state && window_state->IsPinned();
321 } 324 }
322 325
323 #if defined(OS_CHROMEOS) 326 #if defined(OS_CHROMEOS)
327 bool CanHandleShowStylusTools() {
328 RootWindowController* controller =
329 RootWindowController::ForTargetRootWindow();
330 StatusAreaWidget* status_area_widget =
331 controller->shelf_widget()->status_area_widget();
332 return status_area_widget && ash::IsPaletteFeatureEnabled() &&
James Cook 2016/08/26 01:05:51 nit: StatusAreaWidget is created in the SHelfWidge
jdufault 2016/08/26 02:44:56 Done.
333 WmShell::Get()->palette_delegate()->ShouldShowPalette();
334 }
335
336 void HandleShowStylusTools() {
337 base::RecordAction(UserMetricsAction("Accel_Show_Stylus_Tools"));
338 RootWindowController* controller =
339 RootWindowController::ForTargetRootWindow();
340 StatusAreaWidget* status_area_widget =
341 controller->shelf_widget()->status_area_widget();
342 if (status_area_widget) {
James Cook 2016/08/26 01:05:51 ditto
jdufault 2016/08/26 02:44:56 Done.
343 PaletteTray* palette_tray = status_area_widget->palette_tray();
344 palette_tray->OpenBubble();
345 }
346 }
347
324 void HandleSwapPrimaryDisplay() { 348 void HandleSwapPrimaryDisplay() {
325 base::RecordAction(UserMetricsAction("Accel_Swap_Primary_Display")); 349 base::RecordAction(UserMetricsAction("Accel_Swap_Primary_Display"));
326 Shell::GetInstance()->display_configuration_controller()->SetPrimaryDisplayId( 350 Shell::GetInstance()->display_configuration_controller()->SetPrimaryDisplayId(
327 ScreenUtil::GetSecondaryDisplay().id(), true /* user_action */); 351 ScreenUtil::GetSecondaryDisplay().id(), true /* user_action */);
328 } 352 }
329 353
330 void HandleToggleMirrorMode() { 354 void HandleToggleMirrorMode() {
331 base::RecordAction(UserMetricsAction("Accel_Toggle_Mirror_Mode")); 355 base::RecordAction(UserMetricsAction("Accel_Toggle_Mirror_Mode"));
332 bool mirror = !Shell::GetInstance()->display_manager()->IsInMirrorMode(); 356 bool mirror = !Shell::GetInstance()->display_manager()->IsInMirrorMode();
333 Shell::GetInstance()->display_configuration_controller()->SetMirrorMode( 357 Shell::GetInstance()->display_configuration_controller()->SetMirrorMode(
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 return true; 420 return true;
397 421
398 #if defined(OS_CHROMEOS) 422 #if defined(OS_CHROMEOS)
399 case DEBUG_ADD_REMOVE_DISPLAY: 423 case DEBUG_ADD_REMOVE_DISPLAY:
400 case DEBUG_TOGGLE_UNIFIED_DESKTOP: 424 case DEBUG_TOGGLE_UNIFIED_DESKTOP:
401 case DISABLE_GPU_WATCHDOG: 425 case DISABLE_GPU_WATCHDOG:
402 case LOCK_PRESSED: 426 case LOCK_PRESSED:
403 case LOCK_RELEASED: 427 case LOCK_RELEASED:
404 case POWER_PRESSED: 428 case POWER_PRESSED:
405 case POWER_RELEASED: 429 case POWER_RELEASED:
430 case SHOW_STYLUS_TOOLS:
406 case SWAP_PRIMARY_DISPLAY: 431 case SWAP_PRIMARY_DISPLAY:
407 case TOGGLE_MIRROR_MODE: 432 case TOGGLE_MIRROR_MODE:
408 case TOUCH_HUD_CLEAR: 433 case TOUCH_HUD_CLEAR:
409 case TOUCH_HUD_MODE_CHANGE: 434 case TOUCH_HUD_MODE_CHANGE:
410 case TOUCH_HUD_PROJECTION_TOGGLE: 435 case TOUCH_HUD_PROJECTION_TOGGLE:
411 return true; 436 return true;
412 #endif 437 #endif
413 438
414 default: 439 default:
415 break; 440 break;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 case TAKE_PARTIAL_SCREENSHOT: 483 case TAKE_PARTIAL_SCREENSHOT:
459 case TAKE_SCREENSHOT: 484 case TAKE_SCREENSHOT:
460 case TAKE_WINDOW_SCREENSHOT: 485 case TAKE_WINDOW_SCREENSHOT:
461 return true; 486 return true;
462 487
463 #if defined(OS_CHROMEOS) 488 #if defined(OS_CHROMEOS)
464 case DEBUG_ADD_REMOVE_DISPLAY: 489 case DEBUG_ADD_REMOVE_DISPLAY:
465 case DEBUG_TOGGLE_UNIFIED_DESKTOP: 490 case DEBUG_TOGGLE_UNIFIED_DESKTOP:
466 return debug::DebugAcceleratorsEnabled(); 491 return debug::DebugAcceleratorsEnabled();
467 492
493 case SHOW_STYLUS_TOOLS:
494 return CanHandleShowStylusTools();
468 case SWAP_PRIMARY_DISPLAY: 495 case SWAP_PRIMARY_DISPLAY:
469 return display::Screen::GetScreen()->GetNumDisplays() > 1; 496 return display::Screen::GetScreen()->GetNumDisplays() > 1;
470 case TOUCH_HUD_CLEAR: 497 case TOUCH_HUD_CLEAR:
471 case TOUCH_HUD_MODE_CHANGE: 498 case TOUCH_HUD_MODE_CHANGE:
472 return CanHandleTouchHud(); 499 return CanHandleTouchHud();
473 500
474 // Following are always enabled. 501 // Following are always enabled.
475 case DISABLE_GPU_WATCHDOG: 502 case DISABLE_GPU_WATCHDOG:
476 case LOCK_PRESSED: 503 case LOCK_PRESSED:
477 case LOCK_RELEASED: 504 case LOCK_RELEASED:
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 // There is no powerd, the Chrome OS power manager, in linux desktop, 629 // There is no powerd, the Chrome OS power manager, in linux desktop,
603 // so call the PowerButtonController here. 630 // so call the PowerButtonController here.
604 Shell::GetInstance()->power_button_controller()->OnPowerButtonEvent( 631 Shell::GetInstance()->power_button_controller()->OnPowerButtonEvent(
605 action == POWER_PRESSED, base::TimeTicks()); 632 action == POWER_PRESSED, base::TimeTicks());
606 } 633 }
607 // We don't do anything with these at present on the device, 634 // We don't do anything with these at present on the device,
608 // (power button events are reported to us from powerm via 635 // (power button events are reported to us from powerm via
609 // D-BUS), but we consume them to prevent them from getting 636 // D-BUS), but we consume them to prevent them from getting
610 // passed to apps -- see http://crbug.com/146609. 637 // passed to apps -- see http://crbug.com/146609.
611 break; 638 break;
639 case SHOW_STYLUS_TOOLS:
640 HandleShowStylusTools();
641 break;
612 case SWAP_PRIMARY_DISPLAY: 642 case SWAP_PRIMARY_DISPLAY:
613 HandleSwapPrimaryDisplay(); 643 HandleSwapPrimaryDisplay();
614 break; 644 break;
615 case TOGGLE_MIRROR_MODE: 645 case TOGGLE_MIRROR_MODE:
616 HandleToggleMirrorMode(); 646 HandleToggleMirrorMode();
617 break; 647 break;
618 case TOUCH_HUD_CLEAR: 648 case TOUCH_HUD_CLEAR:
619 HandleTouchHudClear(); 649 HandleTouchHudClear();
620 break; 650 break;
621 case TOUCH_HUD_MODE_CHANGE: 651 case TOUCH_HUD_MODE_CHANGE:
(...skipping 24 matching lines...) Expand all
646 message_center::NotifierId( 676 message_center::NotifierId(
647 message_center::NotifierId::SYSTEM_COMPONENT, 677 message_center::NotifierId::SYSTEM_COMPONENT,
648 system_notifier::kNotifierDeprecatedAccelerator), 678 system_notifier::kNotifierDeprecatedAccelerator),
649 message_center::RichNotificationData(), 679 message_center::RichNotificationData(),
650 new DeprecatedAcceleratorNotificationDelegate)); 680 new DeprecatedAcceleratorNotificationDelegate));
651 message_center::MessageCenter::Get()->AddNotification( 681 message_center::MessageCenter::Get()->AddNotification(
652 std::move(notification)); 682 std::move(notification));
653 } 683 }
654 684
655 } // namespace ash 685 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/common/accelerators/accelerator_table.h » ('j') | tools/metrics/actions/actions.xml » ('J')

Powered by Google App Engine
This is Rietveld 408576698