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

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

Issue 12494011: Keyboard shortcut to log views, layers, windows (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cleanup Created 7 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | ash/accelerators/accelerator_table.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/accelerator_controller.h" 5 #include "ash/accelerators/accelerator_controller.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <iostream>
9 #include <string> 10 #include <string>
10 11
11 #include "ash/accelerators/accelerator_table.h" 12 #include "ash/accelerators/accelerator_table.h"
12 #include "ash/ash_switches.h" 13 #include "ash/ash_switches.h"
13 #include "ash/caps_lock_delegate.h" 14 #include "ash/caps_lock_delegate.h"
14 #include "ash/desktop_background/desktop_background_controller.h" 15 #include "ash/desktop_background/desktop_background_controller.h"
15 #include "ash/desktop_background/user_wallpaper_delegate.h" 16 #include "ash/desktop_background/user_wallpaper_delegate.h"
16 #include "ash/display/display_controller.h" 17 #include "ash/display/display_controller.h"
17 #include "ash/display/display_manager.h" 18 #include "ash/display/display_manager.h"
18 #include "ash/focus_cycler.h" 19 #include "ash/focus_cycler.h"
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 bool HandleMediaPlayPause() { 268 bool HandleMediaPlayPause() {
268 Shell::GetInstance()->delegate()->HandleMediaPlayPause(); 269 Shell::GetInstance()->delegate()->HandleMediaPlayPause();
269 return true; 270 return true;
270 } 271 }
271 272
272 bool HandleMediaPrevTrack() { 273 bool HandleMediaPrevTrack() {
273 Shell::GetInstance()->delegate()->HandleMediaPrevTrack(); 274 Shell::GetInstance()->delegate()->HandleMediaPrevTrack();
274 return true; 275 return true;
275 } 276 }
276 277
277 #if !defined(NDEBUG)
278 bool HandlePrintLayerHierarchy() { 278 bool HandlePrintLayerHierarchy() {
279 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); 279 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
280 for (size_t i = 0; i < root_windows.size(); ++i) { 280 for (size_t i = 0; i < root_windows.size(); ++i) {
281 ui::PrintLayerHierarchy(root_windows[i]->layer(), 281 ui::PrintLayerHierarchy(root_windows[i]->layer(),
282 root_windows[i]->GetLastMouseLocationInRoot()); 282 root_windows[i]->GetLastMouseLocationInRoot());
283 } 283 }
284 return true; 284 return true;
285 } 285 }
286 286
287 bool HandlePrintViewHierarchy() { 287 bool HandlePrintViewHierarchy() {
288 aura::Window* active_window = ash::wm::GetActiveWindow(); 288 aura::Window* active_window = ash::wm::GetActiveWindow();
289 if (!active_window) 289 if (!active_window)
290 return true; 290 return true;
291 views::Widget* browser_widget = 291 views::Widget* browser_widget =
292 views::Widget::GetWidgetForNativeWindow(active_window); 292 views::Widget::GetWidgetForNativeWindow(active_window);
293 if (browser_widget) 293 if (!browser_widget)
294 views::PrintViewHierarchy(browser_widget->GetRootView()); 294 return true;
295 views::PrintViewHierarchy(browser_widget->GetRootView());
295 return true; 296 return true;
296 } 297 }
297 298
298 void PrintWindowHierarchy(aura::Window* window, int indent) { 299 void PrintWindowHierarchy(aura::Window* window,
300 int indent,
301 std::ostringstream* out) {
299 std::string indent_str(indent, ' '); 302 std::string indent_str(indent, ' ');
300 std::string name(window->name()); 303 std::string name(window->name());
301 if (name.empty()) 304 if (name.empty())
302 name = "\"\""; 305 name = "\"\"";
303 DLOG(INFO) << indent_str << name << " (" << window << ")" 306 *out << indent_str << name << " (" << window << ")"
304 << " type=" << window->type() 307 << " type=" << window->type()
305 << (wm::IsActiveWindow(window) ? " [active] " : " ") 308 << (wm::IsActiveWindow(window) ? " [active] " : " ")
306 << (window->IsVisible() ? " visible " : " ") 309 << (window->IsVisible() ? " visible " : " ")
307 << window->bounds().ToString(); 310 << window->bounds().ToString()
311 << '\n';
308 312
309 for (size_t i = 0; i < window->children().size(); ++i) 313 for (size_t i = 0; i < window->children().size(); ++i)
310 PrintWindowHierarchy(window->children()[i], indent + 3); 314 PrintWindowHierarchy(window->children()[i], indent + 3, out);
311 } 315 }
312 316
313 bool HandlePrintWindowHierarchy() { 317 bool HandlePrintWindowHierarchy() {
314 DLOG(INFO) << "Window hierarchy:";
315 Shell::RootWindowControllerList controllers = 318 Shell::RootWindowControllerList controllers =
316 Shell::GetAllRootWindowControllers(); 319 Shell::GetAllRootWindowControllers();
317 for (size_t i = 0; i < controllers.size(); ++i) { 320 for (size_t i = 0; i < controllers.size(); ++i) {
318 DLOG(INFO) << "RootWindow " << i << ":"; 321 std::ostringstream out;
319 PrintWindowHierarchy(controllers[i]->root_window(), 0); 322 out << "RootWindow " << i << ":\n";
323 PrintWindowHierarchy(controllers[i]->root_window(), 0, &out);
324 // Error so logs can be collected from end-users.
325 LOG(ERROR) << out.str();
320 } 326 }
321 return true; 327 return true;
322 } 328 }
323 329
324 #endif // !defined(NDEBUG) 330 bool HandlePrintUIHierarchies() {
331 // This is a separate command so the user only has to hit one key to generate
332 // all the logs. Developers use the individual dumps repeatedly, so keep
333 // those as separate commands to avoid spamming their logs.
334 HandlePrintLayerHierarchy();
335 HandlePrintWindowHierarchy();
336 HandlePrintViewHierarchy();
337 return true;
338 }
325 339
326 } // namespace 340 } // namespace
327 341
328 //////////////////////////////////////////////////////////////////////////////// 342 ////////////////////////////////////////////////////////////////////////////////
329 // AcceleratorControllerContext, public: 343 // AcceleratorControllerContext, public:
330 344
331 AcceleratorControllerContext::AcceleratorControllerContext() { 345 AcceleratorControllerContext::AcceleratorControllerContext() {
332 current_accelerator_.set_type(ui::ET_UNKNOWN); 346 current_accelerator_.set_type(ui::ET_UNKNOWN);
333 previous_accelerator_.set_type(ui::ET_UNKNOWN); 347 previous_accelerator_.set_type(ui::ET_UNKNOWN);
334 } 348 }
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 // TODO(mazda): Fix crbug.com/158217 719 // TODO(mazda): Fix crbug.com/158217
706 return false; 720 return false;
707 } 721 }
708 if (ime_control_delegate_.get()) 722 if (ime_control_delegate_.get())
709 return ime_control_delegate_->HandleNextIme(); 723 return ime_control_delegate_->HandleNextIme();
710 break; 724 break;
711 case PREVIOUS_IME: 725 case PREVIOUS_IME:
712 if (ime_control_delegate_.get()) 726 if (ime_control_delegate_.get())
713 return ime_control_delegate_->HandlePreviousIme(); 727 return ime_control_delegate_->HandlePreviousIme();
714 break; 728 break;
729 case PRINT_UI_HIERARCHIES:
730 return HandlePrintUIHierarchies();
715 case SWITCH_IME: 731 case SWITCH_IME:
716 if (ime_control_delegate_.get()) 732 if (ime_control_delegate_.get())
717 return ime_control_delegate_->HandleSwitchIme(accelerator); 733 return ime_control_delegate_->HandleSwitchIme(accelerator);
718 break; 734 break;
719 case SELECT_WIN_0: 735 case SELECT_WIN_0:
720 Launcher::ForPrimaryDisplay()->SwitchToWindow(0); 736 Launcher::ForPrimaryDisplay()->SwitchToWindow(0);
721 return true; 737 return true;
722 case SELECT_WIN_1: 738 case SELECT_WIN_1:
723 Launcher::ForPrimaryDisplay()->SwitchToWindow(1); 739 Launcher::ForPrimaryDisplay()->SwitchToWindow(1);
724 return true; 740 return true;
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
900 keyboard_brightness_control_delegate) { 916 keyboard_brightness_control_delegate) {
901 keyboard_brightness_control_delegate_ = 917 keyboard_brightness_control_delegate_ =
902 keyboard_brightness_control_delegate.Pass(); 918 keyboard_brightness_control_delegate.Pass();
903 } 919 }
904 920
905 bool AcceleratorController::CanHandleAccelerators() const { 921 bool AcceleratorController::CanHandleAccelerators() const {
906 return true; 922 return true;
907 } 923 }
908 924
909 } // namespace ash 925 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/accelerators/accelerator_table.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698