| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/debug_commands.h" | 5 #include "ash/common/accelerators/debug_commands.h" |
| 6 | 6 |
| 7 #include "ash/common/accelerators/accelerator_commands.h" | 7 #include "ash/common/accelerators/accelerator_commands.h" |
| 8 #include "ash/common/ash_switches.h" | 8 #include "ash/common/ash_switches.h" |
| 9 #include "ash/common/shell_delegate.h" | 9 #include "ash/common/shell_delegate.h" |
| 10 #include "ash/common/system/toast/toast_data.h" | 10 #include "ash/common/system/toast/toast_data.h" |
| 11 #include "ash/common/system/toast/toast_manager.h" | 11 #include "ash/common/system/toast/toast_manager.h" |
| 12 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" | |
| 13 #include "ash/common/wm_root_window_controller.h" | 12 #include "ash/common/wm_root_window_controller.h" |
| 14 #include "ash/common/wm_shell.h" | 13 #include "ash/common/wm_shell.h" |
| 15 #include "ash/common/wm_window.h" | 14 #include "ash/common/wm_window.h" |
| 16 #include "base/command_line.h" | 15 #include "base/command_line.h" |
| 17 #include "base/metrics/user_metrics.h" | 16 #include "base/metrics/user_metrics.h" |
| 18 #include "base/metrics/user_metrics_action.h" | 17 #include "base/metrics/user_metrics_action.h" |
| 19 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
| 20 #include "ui/compositor/debug_utils.h" | 19 #include "ui/compositor/debug_utils.h" |
| 21 #include "ui/views/debug_utils.h" | 20 #include "ui/views/debug_utils.h" |
| 22 #include "ui/views/widget/widget.h" | 21 #include "ui/views/widget/widget.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 void HandleToggleTouchpad() { | 78 void HandleToggleTouchpad() { |
| 80 base::RecordAction(base::UserMetricsAction("Accel_Toggle_Touchpad")); | 79 base::RecordAction(base::UserMetricsAction("Accel_Toggle_Touchpad")); |
| 81 ash::WmShell::Get()->delegate()->ToggleTouchpad(); | 80 ash::WmShell::Get()->delegate()->ToggleTouchpad(); |
| 82 } | 81 } |
| 83 | 82 |
| 84 void HandleToggleTouchscreen() { | 83 void HandleToggleTouchscreen() { |
| 85 base::RecordAction(base::UserMetricsAction("Accel_Toggle_Touchscreen")); | 84 base::RecordAction(base::UserMetricsAction("Accel_Toggle_Touchscreen")); |
| 86 ash::WmShell::Get()->delegate()->ToggleTouchscreen(); | 85 ash::WmShell::Get()->delegate()->ToggleTouchscreen(); |
| 87 } | 86 } |
| 88 | 87 |
| 89 void HandleToggleToggleTouchView() { | |
| 90 MaximizeModeController* controller = | |
| 91 WmShell::Get()->maximize_mode_controller(); | |
| 92 controller->EnableMaximizeModeWindowManager( | |
| 93 !controller->IsMaximizeModeWindowManagerEnabled()); | |
| 94 } | |
| 95 | |
| 96 #endif // defined(OS_CHROMEOS) | 88 #endif // defined(OS_CHROMEOS) |
| 97 | 89 |
| 98 } // namespace | 90 } // namespace |
| 99 | 91 |
| 100 void PrintUIHierarchies() { | 92 void PrintUIHierarchies() { |
| 101 // This is a separate command so the user only has to hit one key to generate | 93 // This is a separate command so the user only has to hit one key to generate |
| 102 // all the logs. Developers use the individual dumps repeatedly, so keep | 94 // all the logs. Developers use the individual dumps repeatedly, so keep |
| 103 // those as separate commands to avoid spamming their logs. | 95 // those as separate commands to avoid spamming their logs. |
| 104 HandlePrintLayerHierarchy(); | 96 HandlePrintLayerHierarchy(); |
| 105 HandlePrintWindowHierarchy(); | 97 HandlePrintWindowHierarchy(); |
| 106 HandlePrintViewHierarchy(); | 98 HandlePrintViewHierarchy(); |
| 107 } | 99 } |
| 108 | 100 |
| 109 bool DebugAcceleratorsEnabled() { | 101 bool DebugAcceleratorsEnabled() { |
| 110 return base::CommandLine::ForCurrentProcess()->HasSwitch( | 102 return base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 111 switches::kAshDebugShortcuts); | 103 switches::kAshDebugShortcuts); |
| 112 } | 104 } |
| 113 | 105 |
| 106 bool DeveloperAcceleratorsEnabled() { |
| 107 return base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 108 switches::kAshDeveloperShortcuts); |
| 109 } |
| 110 |
| 114 void PerformDebugActionIfEnabled(AcceleratorAction action) { | 111 void PerformDebugActionIfEnabled(AcceleratorAction action) { |
| 115 if (!DebugAcceleratorsEnabled()) | 112 if (!DebugAcceleratorsEnabled()) |
| 116 return; | 113 return; |
| 117 | 114 |
| 118 switch (action) { | 115 switch (action) { |
| 119 #if defined(OS_CHROMEOS) | 116 #if defined(OS_CHROMEOS) |
| 120 case DEBUG_SHOW_TOAST: | 117 case DEBUG_SHOW_TOAST: |
| 121 WmShell::Get()->toast_manager()->Show( | 118 WmShell::Get()->toast_manager()->Show( |
| 122 ToastData("id", base::ASCIIToUTF16("Toast"), 5000 /* duration_ms */, | 119 ToastData("id", base::ASCIIToUTF16("Toast"), 5000 /* duration_ms */, |
| 123 base::ASCIIToUTF16("Dismiss"))); | 120 base::ASCIIToUTF16("Dismiss"))); |
| 124 break; | 121 break; |
| 125 case DEBUG_TOGGLE_TOUCH_PAD: | 122 case DEBUG_TOGGLE_TOUCH_PAD: |
| 126 HandleToggleTouchpad(); | 123 HandleToggleTouchpad(); |
| 127 break; | 124 break; |
| 128 case DEBUG_TOGGLE_TOUCH_SCREEN: | 125 case DEBUG_TOGGLE_TOUCH_SCREEN: |
| 129 HandleToggleTouchscreen(); | 126 HandleToggleTouchscreen(); |
| 130 break; | 127 break; |
| 131 case DEBUG_TOGGLE_TOUCH_VIEW: | |
| 132 HandleToggleToggleTouchView(); | |
| 133 break; | |
| 134 #endif | 128 #endif |
| 135 case DEBUG_PRINT_LAYER_HIERARCHY: | 129 case DEBUG_PRINT_LAYER_HIERARCHY: |
| 136 HandlePrintLayerHierarchy(); | 130 HandlePrintLayerHierarchy(); |
| 137 break; | 131 break; |
| 138 case DEBUG_PRINT_VIEW_HIERARCHY: | 132 case DEBUG_PRINT_VIEW_HIERARCHY: |
| 139 HandlePrintViewHierarchy(); | 133 HandlePrintViewHierarchy(); |
| 140 break; | 134 break; |
| 141 case DEBUG_PRINT_WINDOW_HIERARCHY: | 135 case DEBUG_PRINT_WINDOW_HIERARCHY: |
| 142 HandlePrintWindowHierarchy(); | 136 HandlePrintWindowHierarchy(); |
| 143 break; | 137 break; |
| 144 default: | 138 default: |
| 145 break; | 139 break; |
| 146 } | 140 } |
| 147 } | 141 } |
| 148 | 142 |
| 149 } // namespace debug | 143 } // namespace debug |
| 150 } // namespace ash | 144 } // namespace ash |
| OLD | NEW |