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

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

Issue 2168733002: Splits debug_commands into aura and non-aura parts (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: moar Created 4 years, 5 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
« no previous file with comments | « ash/accelerators/debug_commands.h ('k') | ash/aura/wm_root_window_controller_aura.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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" 12 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h"
13 #include "ash/common/wm_root_window_controller.h"
13 #include "ash/common/wm_shell.h" 14 #include "ash/common/wm_shell.h"
14 #include "ash/debug.h" 15 #include "ash/common/wm_window.h"
15 #include "ash/desktop_background/desktop_background_controller.h"
16 #include "ash/desktop_background/user_wallpaper_delegate.h"
17 #include "ash/display/display_manager.h"
18 #include "ash/host/ash_window_tree_host.h"
19 #include "ash/root_window_controller.h"
20 #include "ash/shell.h"
21 #include "ash/wm/window_util.h"
22 #include "base/command_line.h" 16 #include "base/command_line.h"
23 #include "base/metrics/user_metrics.h" 17 #include "base/metrics/user_metrics.h"
24 #include "base/metrics/user_metrics_action.h" 18 #include "base/metrics/user_metrics_action.h"
25 #include "third_party/skia/include/core/SkColor.h"
26 #include "third_party/skia/include/core/SkPaint.h"
27 #include "ui/aura/window.h"
28 #include "ui/aura/window_event_dispatcher.h"
29 #include "ui/compositor/debug_utils.h" 19 #include "ui/compositor/debug_utils.h"
30 #include "ui/compositor/layer.h"
31 #include "ui/gfx/canvas.h"
32 #include "ui/gfx/image/image_skia.h"
33 #include "ui/views/debug_utils.h" 20 #include "ui/views/debug_utils.h"
34 #include "ui/views/widget/widget.h" 21 #include "ui/views/widget/widget.h"
35 22
36 namespace ash { 23 namespace ash {
37 namespace debug { 24 namespace debug {
38 namespace { 25 namespace {
39 26
40 void HandlePrintLayerHierarchy() { 27 void HandlePrintLayerHierarchy() {
41 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 28 for (WmWindow* root : WmShell::Get()->GetAllRootWindows()) {
42 for (size_t i = 0; i < root_windows.size(); ++i) { 29 ui::Layer* layer = root->GetLayer();
43 ui::PrintLayerHierarchy( 30 if (layer)
44 root_windows[i]->layer(), 31 ui::PrintLayerHierarchy(
45 root_windows[i]->GetHost()->dispatcher()->GetLastMouseLocationInRoot()); 32 layer, root->GetRootWindowController()->GetLastMouseLocationInRoot());
46 } 33 }
47 } 34 }
48 35
49 void HandlePrintViewHierarchy() { 36 void HandlePrintViewHierarchy() {
50 aura::Window* active_window = ash::wm::GetActiveWindow(); 37 WmWindow* active_window = WmShell::Get()->GetActiveWindow();
51 if (!active_window) 38 if (!active_window)
52 return; 39 return;
53 views::Widget* browser_widget = 40 views::Widget* widget = active_window->GetInternalWidget();
54 views::Widget::GetWidgetForNativeWindow(active_window); 41 if (!widget)
55 if (!browser_widget)
56 return; 42 return;
57 views::PrintViewHierarchy(browser_widget->GetRootView()); 43 views::PrintViewHierarchy(widget->GetRootView());
58 } 44 }
59 45
60 void PrintWindowHierarchy(aura::Window* window, 46 void PrintWindowHierarchy(const WmWindow* active_window,
James Cook 2016/07/21 00:54:08 Hooray! We'll be able to dump the window hierarchy
47 WmWindow* window,
61 int indent, 48 int indent,
62 std::ostringstream* out) { 49 std::ostringstream* out) {
63 std::string indent_str(indent, ' '); 50 std::string indent_str(indent, ' ');
64 std::string name(window->name()); 51 std::string name(window->GetName());
65 if (name.empty()) 52 if (name.empty())
66 name = "\"\""; 53 name = "\"\"";
67 *out << indent_str << name << " (" << window << ")" 54 *out << indent_str << name << " (" << window << ")"
68 << " type=" << window->type() 55 << " type=" << window->GetType()
69 << (wm::IsActiveWindow(window) ? " [active] " : " ") 56 << ((window == active_window) ? " [active] " : " ")
70 << (window->IsVisible() ? " visible " : " ") 57 << (window->IsVisible() ? " visible " : " ")
71 << window->bounds().ToString() << '\n'; 58 << window->GetBounds().ToString() << '\n';
72 59
73 for (size_t i = 0; i < window->children().size(); ++i) 60 for (WmWindow* child : window->GetChildren())
74 PrintWindowHierarchy(window->children()[i], indent + 3, out); 61 PrintWindowHierarchy(active_window, child, indent + 3, out);
75 } 62 }
76 63
77 void HandlePrintWindowHierarchy() { 64 void HandlePrintWindowHierarchy() {
78 Shell::RootWindowControllerList controllers = 65 WmWindow* active_window = WmShell::Get()->GetActiveWindow();
79 Shell::GetAllRootWindowControllers(); 66 WmWindow::Windows roots = WmShell::Get()->GetAllRootWindows();
80 for (size_t i = 0; i < controllers.size(); ++i) { 67 for (size_t i = 0; i < roots.size(); ++i) {
81 std::ostringstream out; 68 std::ostringstream out;
82 out << "RootWindow " << i << ":\n"; 69 out << "RootWindow " << i << ":\n";
83 PrintWindowHierarchy(controllers[i]->GetRootWindow(), 0, &out); 70 PrintWindowHierarchy(active_window, roots[i], 0, &out);
84 // Error so logs can be collected from end-users. 71 // Error so logs can be collected from end-users.
85 LOG(ERROR) << out.str(); 72 LOG(ERROR) << out.str();
86 } 73 }
87 } 74 }
88 75
89 gfx::ImageSkia CreateWallpaperImage(SkColor fill, SkColor rect) {
90 // TODO(oshima): Consider adding a command line option to control
91 // wallpaper images for testing.
92 // The size is randomly picked.
93 gfx::Size image_size(1366, 768);
94 gfx::Canvas canvas(image_size, 1.0f, true);
95 canvas.DrawColor(fill);
96 SkPaint paint;
97 paint.setColor(rect);
98 paint.setStrokeWidth(10);
99 paint.setStyle(SkPaint::kStroke_Style);
100 paint.setXfermodeMode(SkXfermode::kSrcOver_Mode);
101 canvas.DrawRoundRect(gfx::Rect(image_size), 100, paint);
102 return gfx::ImageSkia(canvas.ExtractImageRep());
103 }
104
105 void HandleToggleDesktopBackgroundMode() {
106 static int index = 0;
107 DesktopBackgroundController* desktop_background_controller =
108 Shell::GetInstance()->desktop_background_controller();
109 switch (++index % 4) {
110 case 0:
111 ash::Shell::GetInstance()
112 ->user_wallpaper_delegate()
113 ->InitializeWallpaper();
114 break;
115 case 1:
116 desktop_background_controller->SetWallpaperImage(
117 CreateWallpaperImage(SK_ColorRED, SK_ColorBLUE),
118 wallpaper::WALLPAPER_LAYOUT_STRETCH);
119 break;
120 case 2:
121 desktop_background_controller->SetWallpaperImage(
122 CreateWallpaperImage(SK_ColorBLUE, SK_ColorGREEN),
123 wallpaper::WALLPAPER_LAYOUT_CENTER);
124 break;
125 case 3:
126 desktop_background_controller->SetWallpaperImage(
127 CreateWallpaperImage(SK_ColorGREEN, SK_ColorRED),
128 wallpaper::WALLPAPER_LAYOUT_CENTER_CROPPED);
129 break;
130 }
131 }
132
133 #if defined(OS_CHROMEOS) 76 #if defined(OS_CHROMEOS)
134 77
135 void HandleToggleTouchpad() { 78 void HandleToggleTouchpad() {
136 base::RecordAction(base::UserMetricsAction("Accel_Toggle_Touchpad")); 79 base::RecordAction(base::UserMetricsAction("Accel_Toggle_Touchpad"));
137 ash::WmShell::Get()->delegate()->ToggleTouchpad(); 80 ash::WmShell::Get()->delegate()->ToggleTouchpad();
138 } 81 }
139 82
140 void HandleToggleTouchscreen() { 83 void HandleToggleTouchscreen() {
141 base::RecordAction(base::UserMetricsAction("Accel_Toggle_Touchscreen")); 84 base::RecordAction(base::UserMetricsAction("Accel_Toggle_Touchscreen"));
142 ash::WmShell::Get()->delegate()->ToggleTouchscreen(); 85 ash::WmShell::Get()->delegate()->ToggleTouchscreen();
(...skipping 23 matching lines...) Expand all
166 return base::CommandLine::ForCurrentProcess()->HasSwitch( 109 return base::CommandLine::ForCurrentProcess()->HasSwitch(
167 switches::kAshDebugShortcuts); 110 switches::kAshDebugShortcuts);
168 } 111 }
169 112
170 void PerformDebugActionIfEnabled(AcceleratorAction action) { 113 void PerformDebugActionIfEnabled(AcceleratorAction action) {
171 if (!DebugAcceleratorsEnabled()) 114 if (!DebugAcceleratorsEnabled())
172 return; 115 return;
173 116
174 switch (action) { 117 switch (action) {
175 #if defined(OS_CHROMEOS) 118 #if defined(OS_CHROMEOS)
176 case DEBUG_ADD_REMOVE_DISPLAY:
177 Shell::GetInstance()->display_manager()->AddRemoveDisplay();
178 break;
179 case DEBUG_SHOW_TOAST: 119 case DEBUG_SHOW_TOAST:
180 WmShell::Get()->toast_manager()->Show( 120 WmShell::Get()->toast_manager()->Show(
181 ToastData("id", "Toast", 5000 /* duration_ms */, "Dismiss")); 121 ToastData("id", "Toast", 5000 /* duration_ms */, "Dismiss"));
182 break; 122 break;
183 case DEBUG_TOGGLE_TOUCH_PAD: 123 case DEBUG_TOGGLE_TOUCH_PAD:
184 HandleToggleTouchpad(); 124 HandleToggleTouchpad();
185 break; 125 break;
186 case DEBUG_TOGGLE_TOUCH_SCREEN: 126 case DEBUG_TOGGLE_TOUCH_SCREEN:
187 HandleToggleTouchscreen(); 127 HandleToggleTouchscreen();
188 break; 128 break;
189 case DEBUG_TOGGLE_TOUCH_VIEW: 129 case DEBUG_TOGGLE_TOUCH_VIEW:
190 HandleToggleToggleTouchView(); 130 HandleToggleToggleTouchView();
191 break; 131 break;
192 case DEBUG_TOGGLE_UNIFIED_DESKTOP:
193 Shell::GetInstance()->display_manager()->SetUnifiedDesktopEnabled(
194 !Shell::GetInstance()->display_manager()->unified_desktop_enabled());
195 break;
196 #endif 132 #endif
197 case DEBUG_PRINT_LAYER_HIERARCHY: 133 case DEBUG_PRINT_LAYER_HIERARCHY:
198 HandlePrintLayerHierarchy(); 134 HandlePrintLayerHierarchy();
199 break; 135 break;
200 case DEBUG_PRINT_VIEW_HIERARCHY: 136 case DEBUG_PRINT_VIEW_HIERARCHY:
201 HandlePrintViewHierarchy(); 137 HandlePrintViewHierarchy();
202 break; 138 break;
203 case DEBUG_PRINT_WINDOW_HIERARCHY: 139 case DEBUG_PRINT_WINDOW_HIERARCHY:
204 HandlePrintWindowHierarchy(); 140 HandlePrintWindowHierarchy();
205 break; 141 break;
206 case DEBUG_TOGGLE_DESKTOP_BACKGROUND_MODE:
207 HandleToggleDesktopBackgroundMode();
208 break;
209 case DEBUG_TOGGLE_DEVICE_SCALE_FACTOR:
210 Shell::GetInstance()->display_manager()->ToggleDisplayScaleFactor();
211 break;
212 case DEBUG_TOGGLE_ROOT_WINDOW_FULL_SCREEN:
213 Shell::GetPrimaryRootWindowController()->ash_host()->ToggleFullScreen();
214 break;
215 case DEBUG_TOGGLE_SHOW_DEBUG_BORDERS:
216 ToggleShowDebugBorders();
217 break;
218 case DEBUG_TOGGLE_SHOW_FPS_COUNTER:
219 ToggleShowFpsCounter();
220 break;
221 case DEBUG_TOGGLE_SHOW_PAINT_RECTS:
222 ToggleShowPaintRects();
223 break;
224 default: 142 default:
225 break; 143 break;
226 } 144 }
227 } 145 }
228 146
229 } // namespace debug 147 } // namespace debug
230 } // namespace ash 148 } // namespace ash
OLDNEW
« no previous file with comments | « ash/accelerators/debug_commands.h ('k') | ash/aura/wm_root_window_controller_aura.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698