summaryrefslogtreecommitdiffstats
path: root/athena
diff options
context:
space:
mode:
authorhashimoto <hashimoto@chromium.org>2014-10-29 21:09:39 -0700
committerCommit bot <commit-bot@chromium.org>2014-10-30 04:09:59 +0000
commit999736ca77e02f4cb62b4a0c6b1739ffde7c2988 (patch)
tree1f107bc78cd30b90e93532931e8090024274c15f /athena
parent448146f6973ea1850e8beccf9c921c97c48b8a1b (diff)
downloadchromium_src-999736ca77e02f4cb62b4a0c6b1739ffde7c2988.zip
chromium_src-999736ca77e02f4cb62b4a0c6b1739ffde7c2988.tar.gz
chromium_src-999736ca77e02f4cb62b4a0c6b1739ffde7c2988.tar.bz2
Print activity state when Ctrl+Shift+Alt+W is pressed
This should be useful when debugging resource management. BUG=None TBR=sky@chromium.org as an owner of new DEPS dependency ui/wm/public Review URL: https://codereview.chromium.org/687533002 Cr-Commit-Position: refs/heads/master@{#302029}
Diffstat (limited to 'athena')
-rw-r--r--athena/main/DEPS1
-rw-r--r--athena/main/athena_launcher.cc5
-rw-r--r--athena/main/athena_main.gyp2
-rw-r--r--athena/main/debug_accelerator_handler.cc106
-rw-r--r--athena/main/debug_accelerator_handler.h36
-rw-r--r--athena/screen/screen_accelerator_handler.cc59
-rw-r--r--athena/screen/screen_accelerator_handler.h8
-rw-r--r--athena/screen/screen_manager_impl.cc2
8 files changed, 154 insertions, 65 deletions
diff --git a/athena/main/DEPS b/athena/main/DEPS
index d2d826a..d0ff633 100644
--- a/athena/main/DEPS
+++ b/athena/main/DEPS
@@ -27,6 +27,7 @@ include_rules = [
"+ui/native_theme",
"+ui/views",
"+ui/wm/core",
+ "+ui/wm/public",
]
specific_include_rules = {
diff --git a/athena/main/athena_launcher.cc b/athena/main/athena_launcher.cc
index b31f53c..6ac68cb 100644
--- a/athena/main/athena_launcher.cc
+++ b/athena/main/athena_launcher.cc
@@ -16,6 +16,7 @@
#include "athena/home/public/search_controller_factory.h"
#include "athena/input/public/input_manager.h"
#include "athena/main/athena_views_delegate.h"
+#include "athena/main/debug_accelerator_handler.h"
#include "athena/main/placeholder.h"
#include "athena/main/placeholder.h"
#include "athena/resource_manager/public/resource_manager.h"
@@ -59,6 +60,7 @@ class VirtualKeyboardObserver;
struct AthenaEnvState {
scoped_ptr< ::wm::VisibilityController> visibility_client;
scoped_ptr<VirtualKeyboardObserver> virtual_keyboard_observer;
+ scoped_ptr<DebugAcceleratorHandler> debug_accelerator_handler;
};
DEFINE_OWNED_WINDOW_PROPERTY_KEY(athena::AthenaEnvState,
@@ -120,6 +122,9 @@ void StartAthenaEnv(scoped_refptr<base::TaskRunner> blocking_task_runner) {
athena::AppRegistry::Create();
SetupBackgroundImage();
+ env_state->debug_accelerator_handler.reset(
+ new DebugAcceleratorHandler(root_window));
+
athena::ScreenManager::Get()->GetContext()->SetProperty(
kAthenaEnvStateKey, env_state);
}
diff --git a/athena/main/athena_main.gyp b/athena/main/athena_main.gyp
index 24b3274..c829ad6 100644
--- a/athena/main/athena_main.gyp
+++ b/athena/main/athena_main.gyp
@@ -43,6 +43,8 @@
'athena_renderer_pdf_helper.h',
'athena_views_delegate.cc',
'athena_views_delegate.h',
+ 'debug_accelerator_handler.cc',
+ 'debug_accelerator_handler.h',
'placeholder.cc',
'placeholder.h',
'public/athena_launcher.h',
diff --git a/athena/main/debug_accelerator_handler.cc b/athena/main/debug_accelerator_handler.cc
new file mode 100644
index 0000000..1a223ab
--- /dev/null
+++ b/athena/main/debug_accelerator_handler.cc
@@ -0,0 +1,106 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "athena/main/debug_accelerator_handler.h"
+
+#include "athena/activity/public/activity.h"
+#include "athena/activity/public/activity_manager.h"
+#include "athena/input/public/accelerator_manager.h"
+#include "ui/aura/window.h"
+#include "ui/aura/window_event_dispatcher.h"
+#include "ui/aura/window_tree_host.h"
+#include "ui/compositor/debug_utils.h"
+#include "ui/wm/public/activation_client.h"
+
+namespace athena {
+namespace {
+
+enum Command {
+ CMD_PRINT_LAYER_HIERARCHY,
+ CMD_PRINT_WINDOW_HIERARCHY,
+};
+
+const int EF_ALL_DOWN =
+ ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN;
+
+const AcceleratorData accelerator_data[] = {
+ {TRIGGER_ON_PRESS, ui::VKEY_L, EF_ALL_DOWN, CMD_PRINT_LAYER_HIERARCHY,
+ AF_DEBUG},
+ {TRIGGER_ON_PRESS, ui::VKEY_W, EF_ALL_DOWN, CMD_PRINT_WINDOW_HIERARCHY,
+ AF_DEBUG},
+};
+
+void PrintLayerHierarchy(aura::Window* root_window) {
+ ui::PrintLayerHierarchy(
+ root_window->layer(),
+ root_window->GetHost()->dispatcher()->GetLastMouseLocationInRoot());
+}
+
+void PrintWindowHierarchy(aura::Window* window,
+ aura::Window* active,
+ 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()
+ << ((window == active) ? " [active] " : " ")
+ << (window->IsVisible() ? " visible " : " ")
+ << window->bounds().ToString();
+ Activity* activity = ActivityManager::Get()->GetActivityForWindow(window);
+ if (activity) {
+ *out << " <activity:"
+ << " state=" << activity->GetCurrentState()
+ << " visible=" << activity->IsVisible()
+ << " media_state=" << activity->GetMediaState()
+ << ">";
+ }
+ *out << '\n';
+
+ for (size_t i = 0; i < window->children().size(); ++i)
+ PrintWindowHierarchy(window->children()[i], active, indent + 3, out);
+}
+
+void HandlePrintWindowHierarchy(aura::Window* root_window) {
+ aura::Window* active =
+ aura::client::GetActivationClient(root_window)->GetActiveWindow();
+ std::ostringstream out;
+ out << "RootWindow :\n";
+ PrintWindowHierarchy(root_window, active, 0, &out);
+ // Error so logs can be collected from end-users.
+ LOG(ERROR) << out.str();
+}
+
+} // namespace
+
+DebugAcceleratorHandler::DebugAcceleratorHandler(aura::Window* root_window)
+ : root_window_(root_window) {
+ AcceleratorManager::Get()->RegisterAccelerators(
+ accelerator_data, arraysize(accelerator_data), this);
+}
+
+DebugAcceleratorHandler::~DebugAcceleratorHandler() {
+}
+
+bool DebugAcceleratorHandler::IsCommandEnabled(int command_id) const {
+ return true;
+}
+
+bool DebugAcceleratorHandler::OnAcceleratorFired(
+ int command_id,
+ const ui::Accelerator& accelerator) {
+ switch (command_id) {
+ case CMD_PRINT_LAYER_HIERARCHY:
+ PrintLayerHierarchy(root_window_);
+ return true;
+ case CMD_PRINT_WINDOW_HIERARCHY:
+ HandlePrintWindowHierarchy(root_window_);
+ return true;
+ }
+ return false;
+}
+
+} // namesapce athena
diff --git a/athena/main/debug_accelerator_handler.h b/athena/main/debug_accelerator_handler.h
new file mode 100644
index 0000000..e259597
--- /dev/null
+++ b/athena/main/debug_accelerator_handler.h
@@ -0,0 +1,36 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+#ifndef ATHENA_MAIN_DEBUG_ACCELERATOR_HANDLER_H_
+#define ATHENA_MAIN_DEBUG_ACCELERATOR_HANDLER_H_
+
+#include "athena/input/public/accelerator_manager.h"
+
+#include "base/macros.h"
+
+namespace aura {
+class Window;
+}
+
+namespace athena {
+
+// Handles accelerators useful for debugging.
+class DebugAcceleratorHandler : public AcceleratorHandler {
+ public:
+ explicit DebugAcceleratorHandler(aura::Window* root_window);
+ ~DebugAcceleratorHandler() override;
+
+ // AcceleratorHandler:
+ bool IsCommandEnabled(int command_id) const override;
+ bool OnAcceleratorFired(int command_id,
+ const ui::Accelerator& accelerator) override;
+
+ private:
+ aura::Window* root_window_;
+
+ DISALLOW_COPY_AND_ASSIGN(DebugAcceleratorHandler);
+};
+
+} // namespace athena
+
+#endif // ATHENA_MAIN_DEBUG_ACCELERATOR_HANDLER_H_
diff --git a/athena/screen/screen_accelerator_handler.cc b/athena/screen/screen_accelerator_handler.cc
index 97c08ec..90d990f 100644
--- a/athena/screen/screen_accelerator_handler.cc
+++ b/athena/screen/screen_accelerator_handler.cc
@@ -6,70 +6,23 @@
#include "athena/input/public/accelerator_manager.h"
#include "athena/screen/public/screen_manager.h"
-#include "ui/aura/window.h"
-#include "ui/aura/window_event_dispatcher.h"
-#include "ui/aura/window_tree_host.h"
-#include "ui/compositor/debug_utils.h"
+#include "ui/events/event_constants.h"
#include "ui/gfx/display.h"
#include "ui/gfx/screen.h"
-#include "ui/wm/public/activation_client.h"
namespace athena {
namespace {
enum Command {
- CMD_PRINT_LAYER_HIERARCHY,
- CMD_PRINT_WINDOW_HIERARCHY,
CMD_ROTATE_SCREEN,
};
-const int EF_ALL_DOWN =
- ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN;
-
const AcceleratorData accelerator_data[] = {
- {TRIGGER_ON_PRESS, ui::VKEY_L, EF_ALL_DOWN, CMD_PRINT_LAYER_HIERARCHY,
- AF_DEBUG},
- {TRIGGER_ON_PRESS, ui::VKEY_W, EF_ALL_DOWN, CMD_PRINT_WINDOW_HIERARCHY,
- AF_DEBUG},
{TRIGGER_ON_PRESS, ui::VKEY_F3,
ui::EF_CONTROL_DOWN | ui::EF_SHIFT_DOWN,
CMD_ROTATE_SCREEN, AF_NONE},
};
-void PrintLayerHierarchy(aura::Window* root_window) {
- ui::PrintLayerHierarchy(
- root_window->layer(),
- root_window->GetHost()->dispatcher()->GetLastMouseLocationInRoot());
-}
-
-void PrintWindowHierarchy(aura::Window* window,
- aura::Window* active,
- 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()
- << ((window == active) ? " [active] " : " ")
- << (window->IsVisible() ? " visible " : " ")
- << window->bounds().ToString() << '\n';
-
- for (size_t i = 0; i < window->children().size(); ++i)
- PrintWindowHierarchy(window->children()[i], active, indent + 3, out);
-}
-
-void HandlePrintWindowHierarchy(aura::Window* root_window) {
- aura::Window* active =
- aura::client::GetActivationClient(root_window)->GetActiveWindow();
- std::ostringstream out;
- out << "RootWindow :\n";
- PrintWindowHierarchy(root_window, active, 0, &out);
- // Error so logs can be collected from end-users.
- LOG(ERROR) << out.str();
-}
-
void HandleRotateScreen() {
ScreenManager* screen_manager = ScreenManager::Get();
gfx::Display::Rotation current_rotation =
@@ -86,9 +39,7 @@ void HandleRotateScreen() {
} // namespace
-// static
-ScreenAcceleratorHandler::ScreenAcceleratorHandler(aura::Window* root_window)
- : root_window_(root_window) {
+ScreenAcceleratorHandler::ScreenAcceleratorHandler() {
AcceleratorManager::Get()->RegisterAccelerators(
accelerator_data, arraysize(accelerator_data), this);
}
@@ -104,12 +55,6 @@ bool ScreenAcceleratorHandler::OnAcceleratorFired(
int command_id,
const ui::Accelerator& accelerator) {
switch (command_id) {
- case CMD_PRINT_LAYER_HIERARCHY:
- PrintLayerHierarchy(root_window_);
- return true;
- case CMD_PRINT_WINDOW_HIERARCHY:
- HandlePrintWindowHierarchy(root_window_);
- return true;
case CMD_ROTATE_SCREEN:
HandleRotateScreen();
return true;
diff --git a/athena/screen/screen_accelerator_handler.h b/athena/screen/screen_accelerator_handler.h
index 089bf09b..76794f2 100644
--- a/athena/screen/screen_accelerator_handler.h
+++ b/athena/screen/screen_accelerator_handler.h
@@ -8,16 +8,12 @@
#include "base/macros.h"
-namespace aura {
-class Window;
-}
-
namespace athena {
// Handles screen related accelerators.
class ScreenAcceleratorHandler : public AcceleratorHandler {
public:
- explicit ScreenAcceleratorHandler(aura::Window* root_window);
+ ScreenAcceleratorHandler();
private:
~ScreenAcceleratorHandler() override;
@@ -27,8 +23,6 @@ class ScreenAcceleratorHandler : public AcceleratorHandler {
virtual bool OnAcceleratorFired(int command_id,
const ui::Accelerator& accelerator) override;
- aura::Window* root_window_;
-
DISALLOW_COPY_AND_ASSIGN(ScreenAcceleratorHandler);
};
diff --git a/athena/screen/screen_manager_impl.cc b/athena/screen/screen_manager_impl.cc
index 2ee1844..bb33212 100644
--- a/athena/screen/screen_manager_impl.cc
+++ b/athena/screen/screen_manager_impl.cc
@@ -243,7 +243,7 @@ void ScreenManagerImpl::Init() {
root_window_->SetLayoutManager(new FillLayoutManager(root_window_));
capture_client_.reset(new ::wm::ScopedCaptureClient(root_window_));
- accelerator_handler_.reset(new ScreenAcceleratorHandler(root_window_));
+ accelerator_handler_.reset(new ScreenAcceleratorHandler());
aura::client::SetWindowTreeClient(root_window_, this);