| 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/wallpaper/wallpaper_controller.h" | 12 #include "ash/common/wallpaper/wallpaper_controller.h" |
| 13 #include "ash/common/wallpaper/wallpaper_delegate.h" | 13 #include "ash/common/wallpaper/wallpaper_delegate.h" |
| 14 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" | |
| 15 #include "ash/common/wm_root_window_controller.h" | 14 #include "ash/common/wm_root_window_controller.h" |
| 16 #include "ash/common/wm_shell.h" | 15 #include "ash/common/wm_shell.h" |
| 17 #include "ash/common/wm_window.h" | 16 #include "ash/common/wm_window.h" |
| 18 #include "base/command_line.h" | 17 #include "base/command_line.h" |
| 19 #include "base/metrics/user_metrics.h" | 18 #include "base/metrics/user_metrics.h" |
| 20 #include "base/metrics/user_metrics_action.h" | 19 #include "base/metrics/user_metrics_action.h" |
| 21 #include "base/strings/utf_string_conversions.h" | 20 #include "base/strings/utf_string_conversions.h" |
| 22 #include "ui/compositor/debug_utils.h" | 21 #include "ui/compositor/debug_utils.h" |
| 23 #include "ui/gfx/canvas.h" | 22 #include "ui/gfx/canvas.h" |
| 24 #include "ui/gfx/image/image_skia.h" | 23 #include "ui/gfx/image/image_skia.h" |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 void HandleToggleTouchpad() { | 123 void HandleToggleTouchpad() { |
| 125 base::RecordAction(base::UserMetricsAction("Accel_Toggle_Touchpad")); | 124 base::RecordAction(base::UserMetricsAction("Accel_Toggle_Touchpad")); |
| 126 ash::WmShell::Get()->delegate()->ToggleTouchpad(); | 125 ash::WmShell::Get()->delegate()->ToggleTouchpad(); |
| 127 } | 126 } |
| 128 | 127 |
| 129 void HandleToggleTouchscreen() { | 128 void HandleToggleTouchscreen() { |
| 130 base::RecordAction(base::UserMetricsAction("Accel_Toggle_Touchscreen")); | 129 base::RecordAction(base::UserMetricsAction("Accel_Toggle_Touchscreen")); |
| 131 ash::WmShell::Get()->delegate()->ToggleTouchscreen(); | 130 ash::WmShell::Get()->delegate()->ToggleTouchscreen(); |
| 132 } | 131 } |
| 133 | 132 |
| 134 void HandleToggleToggleTouchView() { | |
| 135 MaximizeModeController* controller = | |
| 136 WmShell::Get()->maximize_mode_controller(); | |
| 137 controller->EnableMaximizeModeWindowManager( | |
| 138 !controller->IsMaximizeModeWindowManagerEnabled()); | |
| 139 } | |
| 140 | |
| 141 #endif // defined(OS_CHROMEOS) | 133 #endif // defined(OS_CHROMEOS) |
| 142 | 134 |
| 143 } // namespace | 135 } // namespace |
| 144 | 136 |
| 145 void PrintUIHierarchies() { | 137 void PrintUIHierarchies() { |
| 146 // This is a separate command so the user only has to hit one key to generate | 138 // This is a separate command so the user only has to hit one key to generate |
| 147 // all the logs. Developers use the individual dumps repeatedly, so keep | 139 // all the logs. Developers use the individual dumps repeatedly, so keep |
| 148 // those as separate commands to avoid spamming their logs. | 140 // those as separate commands to avoid spamming their logs. |
| 149 HandlePrintLayerHierarchy(); | 141 HandlePrintLayerHierarchy(); |
| 150 HandlePrintWindowHierarchy(); | 142 HandlePrintWindowHierarchy(); |
| 151 HandlePrintViewHierarchy(); | 143 HandlePrintViewHierarchy(); |
| 152 } | 144 } |
| 153 | 145 |
| 154 bool DebugAcceleratorsEnabled() { | 146 bool DebugAcceleratorsEnabled() { |
| 155 return base::CommandLine::ForCurrentProcess()->HasSwitch( | 147 return base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 156 switches::kAshDebugShortcuts); | 148 switches::kAshDebugShortcuts); |
| 157 } | 149 } |
| 158 | 150 |
| 151 bool DeveloperAcceleratorsEnabled() { |
| 152 return base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 153 switches::kAshDeveloperShortcuts); |
| 154 } |
| 155 |
| 159 void PerformDebugActionIfEnabled(AcceleratorAction action) { | 156 void PerformDebugActionIfEnabled(AcceleratorAction action) { |
| 160 if (!DebugAcceleratorsEnabled()) | 157 if (!DebugAcceleratorsEnabled()) |
| 161 return; | 158 return; |
| 162 | 159 |
| 163 switch (action) { | 160 switch (action) { |
| 164 #if defined(OS_CHROMEOS) | 161 #if defined(OS_CHROMEOS) |
| 165 case DEBUG_SHOW_TOAST: | 162 case DEBUG_SHOW_TOAST: |
| 166 WmShell::Get()->toast_manager()->Show( | 163 WmShell::Get()->toast_manager()->Show( |
| 167 ToastData("id", base::ASCIIToUTF16("Toast"), 5000 /* duration_ms */, | 164 ToastData("id", base::ASCIIToUTF16("Toast"), 5000 /* duration_ms */, |
| 168 base::ASCIIToUTF16("Dismiss"))); | 165 base::ASCIIToUTF16("Dismiss"))); |
| 169 break; | 166 break; |
| 170 case DEBUG_TOGGLE_TOUCH_PAD: | 167 case DEBUG_TOGGLE_TOUCH_PAD: |
| 171 HandleToggleTouchpad(); | 168 HandleToggleTouchpad(); |
| 172 break; | 169 break; |
| 173 case DEBUG_TOGGLE_TOUCH_SCREEN: | 170 case DEBUG_TOGGLE_TOUCH_SCREEN: |
| 174 HandleToggleTouchscreen(); | 171 HandleToggleTouchscreen(); |
| 175 break; | 172 break; |
| 176 case DEBUG_TOGGLE_TOUCH_VIEW: | |
| 177 HandleToggleToggleTouchView(); | |
| 178 break; | |
| 179 #endif | 173 #endif |
| 180 case DEBUG_TOGGLE_WALLPAPER_MODE: | 174 case DEBUG_TOGGLE_WALLPAPER_MODE: |
| 181 HandleToggleWallpaperMode(); | 175 HandleToggleWallpaperMode(); |
| 182 break; | 176 break; |
| 183 case DEBUG_PRINT_LAYER_HIERARCHY: | 177 case DEBUG_PRINT_LAYER_HIERARCHY: |
| 184 HandlePrintLayerHierarchy(); | 178 HandlePrintLayerHierarchy(); |
| 185 break; | 179 break; |
| 186 case DEBUG_PRINT_VIEW_HIERARCHY: | 180 case DEBUG_PRINT_VIEW_HIERARCHY: |
| 187 HandlePrintViewHierarchy(); | 181 HandlePrintViewHierarchy(); |
| 188 break; | 182 break; |
| 189 case DEBUG_PRINT_WINDOW_HIERARCHY: | 183 case DEBUG_PRINT_WINDOW_HIERARCHY: |
| 190 HandlePrintWindowHierarchy(); | 184 HandlePrintWindowHierarchy(); |
| 191 break; | 185 break; |
| 192 default: | 186 default: |
| 193 break; | 187 break; |
| 194 } | 188 } |
| 195 } | 189 } |
| 196 | 190 |
| 197 } // namespace debug | 191 } // namespace debug |
| 198 } // namespace ash | 192 } // namespace ash |
| OLD | NEW |