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

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

Issue 1412623006: Developer Feature: Add Debug Accelerators to Toggle Touchscreen/Touchpad On or Off (CrOS) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: sadrul's comment Created 5 years, 1 month 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 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/accelerators/debug_commands.h" 5 #include "ash/accelerators/debug_commands.h"
6 6
7 #include "ash/accelerators/accelerator_commands.h" 7 #include "ash/accelerators/accelerator_commands.h"
8 #include "ash/ash_switches.h" 8 #include "ash/ash_switches.h"
9 #include "ash/debug.h" 9 #include "ash/debug.h"
10 #include "ash/desktop_background/desktop_background_controller.h" 10 #include "ash/desktop_background/desktop_background_controller.h"
11 #include "ash/desktop_background/user_wallpaper_delegate.h" 11 #include "ash/desktop_background/user_wallpaper_delegate.h"
12 #include "ash/display/display_manager.h" 12 #include "ash/display/display_manager.h"
13 #include "ash/host/ash_window_tree_host.h" 13 #include "ash/host/ash_window_tree_host.h"
14 #include "ash/root_window_controller.h" 14 #include "ash/root_window_controller.h"
15 #include "ash/shell.h" 15 #include "ash/shell.h"
16 #include "ash/shell_delegate.h"
16 #include "ash/wm/window_util.h" 17 #include "ash/wm/window_util.h"
17 #include "base/command_line.h" 18 #include "base/command_line.h"
19 #include "base/metrics/user_metrics.h"
20 #include "base/metrics/user_metrics_action.h"
18 #include "third_party/skia/include/core/SkColor.h" 21 #include "third_party/skia/include/core/SkColor.h"
19 #include "third_party/skia/include/core/SkPaint.h" 22 #include "third_party/skia/include/core/SkPaint.h"
20 #include "ui/aura/window.h" 23 #include "ui/aura/window.h"
21 #include "ui/aura/window_event_dispatcher.h" 24 #include "ui/aura/window_event_dispatcher.h"
22 #include "ui/compositor/debug_utils.h" 25 #include "ui/compositor/debug_utils.h"
23 #include "ui/compositor/layer.h" 26 #include "ui/compositor/layer.h"
24 #include "ui/gfx/canvas.h" 27 #include "ui/gfx/canvas.h"
25 #include "ui/gfx/image/image_skia.h" 28 #include "ui/gfx/image/image_skia.h"
26 #include "ui/views/debug_utils.h" 29 #include "ui/views/debug_utils.h"
27 #include "ui/views/widget/widget.h" 30 #include "ui/views/widget/widget.h"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 wallpaper::WALLPAPER_LAYOUT_CENTER); 119 wallpaper::WALLPAPER_LAYOUT_CENTER);
117 break; 120 break;
118 case 3: 121 case 3:
119 desktop_background_controller->SetWallpaperImage( 122 desktop_background_controller->SetWallpaperImage(
120 CreateWallpaperImage(SK_ColorGREEN, SK_ColorRED), 123 CreateWallpaperImage(SK_ColorGREEN, SK_ColorRED),
121 wallpaper::WALLPAPER_LAYOUT_CENTER_CROPPED); 124 wallpaper::WALLPAPER_LAYOUT_CENTER_CROPPED);
122 break; 125 break;
123 } 126 }
124 } 127 }
125 128
129 #if defined(OS_CHROMEOS)
130
131 void HandleToggleTouchpad() {
132 base::RecordAction(base::UserMetricsAction("Accel_Toggle_Touchpad"));
133
134 ash::Shell::GetInstance()->delegate()->ToggleTouchpad();
135 }
136
137 void HandleToggleTouchscreen() {
138 base::RecordAction(base::UserMetricsAction("Accel_Toggle_Touchscreen"));
139
140 ash::Shell::GetInstance()->delegate()->ToggleTouchscreen();
141 }
142
143 #endif // defined(OS_CHROMEOS)
144
126 } // namespace 145 } // namespace
127 146
128 void PrintUIHierarchies() { 147 void PrintUIHierarchies() {
129 // This is a separate command so the user only has to hit one key to generate 148 // This is a separate command so the user only has to hit one key to generate
130 // all the logs. Developers use the individual dumps repeatedly, so keep 149 // all the logs. Developers use the individual dumps repeatedly, so keep
131 // those as separate commands to avoid spamming their logs. 150 // those as separate commands to avoid spamming their logs.
132 HandlePrintLayerHierarchy(); 151 HandlePrintLayerHierarchy();
133 HandlePrintWindowHierarchy(); 152 HandlePrintWindowHierarchy();
134 HandlePrintViewHierarchy(); 153 HandlePrintViewHierarchy();
135 } 154 }
136 155
137 bool DebugAcceleratorsEnabled() { 156 bool DebugAcceleratorsEnabled() {
138 return base::CommandLine::ForCurrentProcess()->HasSwitch( 157 return base::CommandLine::ForCurrentProcess()->HasSwitch(
139 switches::kAshDebugShortcuts); 158 switches::kAshDebugShortcuts);
140 } 159 }
141 160
142 void PerformDebugActionIfEnabled(AcceleratorAction action) { 161 void PerformDebugActionIfEnabled(AcceleratorAction action) {
143 if (!DebugAcceleratorsEnabled()) 162 if (!DebugAcceleratorsEnabled())
144 return; 163 return;
145 164
146 switch (action) { 165 switch (action) {
147 #if defined(OS_CHROMEOS) 166 #if defined(OS_CHROMEOS)
148 case DEBUG_ADD_REMOVE_DISPLAY: 167 case DEBUG_ADD_REMOVE_DISPLAY:
149 Shell::GetInstance()->display_manager()->AddRemoveDisplay(); 168 Shell::GetInstance()->display_manager()->AddRemoveDisplay();
150 break; 169 break;
170 case DEBUG_TOGGLE_TOUCH_PAD:
171 HandleToggleTouchpad();
172 break;
173 case DEBUG_TOGGLE_TOUCH_SCREEN:
174 HandleToggleTouchscreen();
175 break;
151 case DEBUG_TOGGLE_UNIFIED_DESKTOP: 176 case DEBUG_TOGGLE_UNIFIED_DESKTOP:
152 Shell::GetInstance()->display_manager()->SetUnifiedDesktopEnabled( 177 Shell::GetInstance()->display_manager()->SetUnifiedDesktopEnabled(
153 !Shell::GetInstance()->display_manager()->unified_desktop_enabled()); 178 !Shell::GetInstance()->display_manager()->unified_desktop_enabled());
154 break; 179 break;
155 #endif 180 #endif
156 case DEBUG_PRINT_LAYER_HIERARCHY: 181 case DEBUG_PRINT_LAYER_HIERARCHY:
157 HandlePrintLayerHierarchy(); 182 HandlePrintLayerHierarchy();
158 break; 183 break;
159 case DEBUG_PRINT_VIEW_HIERARCHY: 184 case DEBUG_PRINT_VIEW_HIERARCHY:
160 HandlePrintViewHierarchy(); 185 HandlePrintViewHierarchy();
(...skipping 19 matching lines...) Expand all
180 case DEBUG_TOGGLE_SHOW_PAINT_RECTS: 205 case DEBUG_TOGGLE_SHOW_PAINT_RECTS:
181 ToggleShowPaintRects(); 206 ToggleShowPaintRects();
182 break; 207 break;
183 default: 208 default:
184 break; 209 break;
185 } 210 }
186 } 211 }
187 212
188 } // namespace debug 213 } // namespace debug
189 } // namespace ash 214 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698