summaryrefslogtreecommitdiffstats
path: root/ash/accelerators/debug_commands.cc
diff options
context:
space:
mode:
authorpkotwicz <pkotwicz@chromium.org>2014-10-22 19:48:31 -0700
committerCommit bot <commit-bot@chromium.org>2014-10-23 02:48:54 +0000
commit01abb76a01ef6a4858bf2eb891a86ff40cccf513 (patch)
tree6c40efa71b8de65c57e3ae13198459b047dfe16b /ash/accelerators/debug_commands.cc
parent26d859a2ddfd2aeac5d944831cd454d30d5a5d6b (diff)
downloadchromium_src-01abb76a01ef6a4858bf2eb891a86ff40cccf513.zip
chromium_src-01abb76a01ef6a4858bf2eb891a86ff40cccf513.tar.gz
chromium_src-01abb76a01ef6a4858bf2eb891a86ff40cccf513.tar.bz2
Move handling for debug accelerators to debug_commands.*
This CL also: - Adds the 'DEBUG' prefix to all debug accelerators actions - Enables all debug accelerators when --ash-debug-shortcuts is passed. - Removes special logic to enable certain accelerators only in a debug build. - Makes Chrome handle debug accelerators before sending the accelerators to the renderer. Previously some debug accelerators (but not all) could be disabled by apps. This CL removes this functionality. BUG=404473 TEST=None Review URL: https://codereview.chromium.org/662983002 Cr-Commit-Position: refs/heads/master@{#300827}
Diffstat (limited to 'ash/accelerators/debug_commands.cc')
-rw-r--r--ash/accelerators/debug_commands.cc127
1 files changed, 123 insertions, 4 deletions
diff --git a/ash/accelerators/debug_commands.cc b/ash/accelerators/debug_commands.cc
index beca39f..7bd4e71 100644
--- a/ash/accelerators/debug_commands.cc
+++ b/ash/accelerators/debug_commands.cc
@@ -4,18 +4,82 @@
#include "ash/accelerators/accelerator_commands.h"
+#include "ash/accelerators/accelerator_table.h"
+#include "ash/ash_switches.h"
+#include "ash/debug.h"
#include "ash/desktop_background/desktop_background_controller.h"
#include "ash/desktop_background/user_wallpaper_delegate.h"
+#include "ash/display/display_manager.h"
+#include "ash/host/ash_window_tree_host.h"
+#include "ash/root_window_controller.h"
#include "ash/shell.h"
+#include "ash/wm/window_util.h"
+#include "base/command_line.h"
#include "third_party/skia/include/core/SkColor.h"
#include "third_party/skia/include/core/SkPaint.h"
+#include "ui/aura/window.h"
+#include "ui/aura/window_event_dispatcher.h"
+#include "ui/compositor/debug_utils.h"
+#include "ui/compositor/layer.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/image/image_skia.h"
+#include "ui/views/debug_utils.h"
+#include "ui/views/widget/widget.h"
namespace ash {
namespace debug {
namespace {
+void HandlePrintLayerHierarchy() {
+ aura::Window::Windows root_windows = Shell::GetAllRootWindows();
+ for (size_t i = 0; i < root_windows.size(); ++i) {
+ ui::PrintLayerHierarchy(
+ root_windows[i]->layer(),
+ root_windows[i]->GetHost()->dispatcher()->GetLastMouseLocationInRoot());
+ }
+}
+
+void HandlePrintViewHierarchy() {
+ aura::Window* active_window = ash::wm::GetActiveWindow();
+ if (!active_window)
+ return;
+ views::Widget* browser_widget =
+ views::Widget::GetWidgetForNativeWindow(active_window);
+ if (!browser_widget)
+ return;
+ views::PrintViewHierarchy(browser_widget->GetRootView());
+}
+
+void PrintWindowHierarchy(aura::Window* window,
+ int indent,
+ std::ostringstream* out) {
+ std::string indent_str(indent, ' ');
+ std::string name(window->name());
+ if (name.empty())
+ name = "\"\"";
+ *out << indent_str << name << " (" << window << ")"
+ << " type=" << window->type()
+ << (wm::IsActiveWindow(window) ? " [active] " : " ")
+ << (window->IsVisible() ? " visible " : " ")
+ << window->bounds().ToString()
+ << '\n';
+
+ for (size_t i = 0; i < window->children().size(); ++i)
+ PrintWindowHierarchy(window->children()[i], indent + 3, out);
+}
+
+void HandlePrintWindowHierarchy() {
+ Shell::RootWindowControllerList controllers =
+ Shell::GetAllRootWindowControllers();
+ for (size_t i = 0; i < controllers.size(); ++i) {
+ std::ostringstream out;
+ out << "RootWindow " << i << ":\n";
+ PrintWindowHierarchy(controllers[i]->GetRootWindow(), 0, &out);
+ // Error so logs can be collected from end-users.
+ LOG(ERROR) << out.str();
+ }
+}
+
gfx::ImageSkia CreateWallpaperImage(SkColor fill, SkColor rect) {
// TODO(oshima): Consider adding a command line option to control
// wallpaper images for testing.
@@ -32,9 +96,7 @@ gfx::ImageSkia CreateWallpaperImage(SkColor fill, SkColor rect) {
return gfx::ImageSkia(canvas.ExtractImageRep());
}
-} // namespace
-
-bool CycleDesktopBackgroundMode() {
+void HandleToggleDesktopBackgroundMode() {
static int index = 0;
DesktopBackgroundController* desktop_background_controller =
Shell::GetInstance()->desktop_background_controller();
@@ -59,7 +121,64 @@ bool CycleDesktopBackgroundMode() {
WALLPAPER_LAYOUT_CENTER_CROPPED);
break;
}
- return true;
+}
+
+} // namespace
+
+void PrintUIHierarchies() {
+ // This is a separate command so the user only has to hit one key to generate
+ // all the logs. Developers use the individual dumps repeatedly, so keep
+ // those as separate commands to avoid spamming their logs.
+ HandlePrintLayerHierarchy();
+ HandlePrintWindowHierarchy();
+ HandlePrintViewHierarchy();
+}
+
+bool DebugAcceleratorsEnabled() {
+ return CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kAshDebugShortcuts);
+}
+
+void PerformDebugAction(int action) {
+ if (!DebugAcceleratorsEnabled())
+ return;
+
+ switch (action) {
+#if defined(OS_CHROMEOS)
+ case DEBUG_ADD_REMOVE_DISPLAY:
+ Shell::GetInstance()->display_manager()->AddRemoveDisplay();
+ break;
+#endif
+ case DEBUG_PRINT_LAYER_HIERARCHY:
+ HandlePrintLayerHierarchy();
+ break;
+ case DEBUG_PRINT_VIEW_HIERARCHY:
+ HandlePrintViewHierarchy();
+ break;
+ case DEBUG_PRINT_WINDOW_HIERARCHY:
+ HandlePrintWindowHierarchy();
+ break;
+ case DEBUG_TOGGLE_DESKTOP_BACKGROUND_MODE:
+ HandleToggleDesktopBackgroundMode();
+ break;
+ case DEBUG_TOGGLE_DEVICE_SCALE_FACTOR:
+ Shell::GetInstance()->display_manager()->ToggleDisplayScaleFactor();
+ break;
+ case DEBUG_TOGGLE_ROOT_WINDOW_FULL_SCREEN:
+ Shell::GetPrimaryRootWindowController()->ash_host()->ToggleFullScreen();
+ break;
+ case DEBUG_TOGGLE_SHOW_DEBUG_BORDERS:
+ ToggleShowDebugBorders();
+ break;
+ case DEBUG_TOGGLE_SHOW_FPS_COUNTER:
+ ToggleShowFpsCounter();
+ break;
+ case DEBUG_TOGGLE_SHOW_PAINT_RECTS:
+ ToggleShowPaintRects();
+ break;
+ default:
+ break;
+ }
}
} // namespace debug