OLD | NEW |
---|---|
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 <string> | 9 #include <string> |
10 | 10 |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
267 bool HandleMediaPlayPause() { | 267 bool HandleMediaPlayPause() { |
268 Shell::GetInstance()->delegate()->HandleMediaPlayPause(); | 268 Shell::GetInstance()->delegate()->HandleMediaPlayPause(); |
269 return true; | 269 return true; |
270 } | 270 } |
271 | 271 |
272 bool HandleMediaPrevTrack() { | 272 bool HandleMediaPrevTrack() { |
273 Shell::GetInstance()->delegate()->HandleMediaPrevTrack(); | 273 Shell::GetInstance()->delegate()->HandleMediaPrevTrack(); |
274 return true; | 274 return true; |
275 } | 275 } |
276 | 276 |
277 #if !defined(NDEBUG) | |
278 bool HandlePrintLayerHierarchy() { | 277 bool HandlePrintLayerHierarchy() { |
279 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 278 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
280 for (size_t i = 0; i < root_windows.size(); ++i) { | 279 for (size_t i = 0; i < root_windows.size(); ++i) { |
281 ui::PrintLayerHierarchy(root_windows[i]->layer(), | 280 ui::PrintLayerHierarchy(root_windows[i]->layer(), |
282 root_windows[i]->GetLastMouseLocationInRoot()); | 281 root_windows[i]->GetLastMouseLocationInRoot()); |
283 } | 282 } |
284 return true; | 283 return true; |
285 } | 284 } |
286 | 285 |
287 bool HandlePrintViewHierarchy() { | 286 bool HandlePrintViewHierarchy() { |
288 aura::Window* active_window = ash::wm::GetActiveWindow(); | 287 aura::Window* active_window = ash::wm::GetActiveWindow(); |
289 if (!active_window) | 288 if (!active_window) |
290 return true; | 289 return true; |
291 views::Widget* browser_widget = | 290 views::Widget* browser_widget = |
292 views::Widget::GetWidgetForNativeWindow(active_window); | 291 views::Widget::GetWidgetForNativeWindow(active_window); |
293 if (browser_widget) | 292 if (!browser_widget) |
294 views::PrintViewHierarchy(browser_widget->GetRootView()); | 293 return true; |
294 // Error so logs can be collected from end-users. | |
295 LOG(ERROR) << "View hierarchy:"; | |
296 views::PrintViewHierarchy(browser_widget->GetRootView()); | |
295 return true; | 297 return true; |
296 } | 298 } |
297 | 299 |
298 void PrintWindowHierarchy(aura::Window* window, int indent) { | 300 void PrintWindowHierarchy(aura::Window* window, int indent) { |
299 std::string indent_str(indent, ' '); | 301 std::string indent_str(indent, ' '); |
300 std::string name(window->name()); | 302 std::string name(window->name()); |
301 if (name.empty()) | 303 if (name.empty()) |
302 name = "\"\""; | 304 name = "\"\""; |
303 DLOG(INFO) << indent_str << name << " (" << window << ")" | 305 // Error so logs can be collected from end-users. |
304 << " type=" << window->type() | 306 LOG(ERROR) << indent_str << name << " (" << window << ")" |
305 << (wm::IsActiveWindow(window) ? " [active] " : " ") | 307 << " type=" << window->type() |
Daniel Erat
2013/03/16 03:32:23
nit: fix indenting on this and following lines
James Cook
2013/03/16 04:09:24
Done.
| |
306 << (window->IsVisible() ? " visible " : " ") | 308 << (wm::IsActiveWindow(window) ? " [active] " : " ") |
307 << window->bounds().ToString(); | 309 << (window->IsVisible() ? " visible " : " ") |
310 << window->bounds().ToString(); | |
308 | 311 |
309 for (size_t i = 0; i < window->children().size(); ++i) | 312 for (size_t i = 0; i < window->children().size(); ++i) |
310 PrintWindowHierarchy(window->children()[i], indent + 3); | 313 PrintWindowHierarchy(window->children()[i], indent + 3); |
311 } | 314 } |
312 | 315 |
313 bool HandlePrintWindowHierarchy() { | 316 bool HandlePrintWindowHierarchy() { |
314 DLOG(INFO) << "Window hierarchy:"; | |
315 Shell::RootWindowControllerList controllers = | 317 Shell::RootWindowControllerList controllers = |
316 Shell::GetAllRootWindowControllers(); | 318 Shell::GetAllRootWindowControllers(); |
317 for (size_t i = 0; i < controllers.size(); ++i) { | 319 for (size_t i = 0; i < controllers.size(); ++i) { |
318 DLOG(INFO) << "RootWindow " << i << ":"; | 320 // Error so logs can be collected from end-users. |
321 LOG(ERROR) << "RootWindow " << i << ":"; | |
319 PrintWindowHierarchy(controllers[i]->root_window(), 0); | 322 PrintWindowHierarchy(controllers[i]->root_window(), 0); |
320 } | 323 } |
321 return true; | 324 return true; |
322 } | 325 } |
323 | 326 |
324 #endif // !defined(NDEBUG) | 327 bool HandlePrintUIHierarchies() { |
328 // This is a separate command so the user only has to hit one key to generate | |
329 // all the logs. Developers use the individual dumps repeatedly, so keep | |
330 // those as separate commands to avoid spamming their logs. | |
331 HandlePrintLayerHierarchy(); | |
332 HandlePrintWindowHierarchy(); | |
333 HandlePrintViewHierarchy(); | |
334 return true; | |
335 } | |
325 | 336 |
326 } // namespace | 337 } // namespace |
327 | 338 |
328 //////////////////////////////////////////////////////////////////////////////// | 339 //////////////////////////////////////////////////////////////////////////////// |
329 // AcceleratorControllerContext, public: | 340 // AcceleratorControllerContext, public: |
330 | 341 |
331 AcceleratorControllerContext::AcceleratorControllerContext() { | 342 AcceleratorControllerContext::AcceleratorControllerContext() { |
332 current_accelerator_.set_type(ui::ET_UNKNOWN); | 343 current_accelerator_.set_type(ui::ET_UNKNOWN); |
333 previous_accelerator_.set_type(ui::ET_UNKNOWN); | 344 previous_accelerator_.set_type(ui::ET_UNKNOWN); |
334 } | 345 } |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
705 // TODO(mazda): Fix crbug.com/158217 | 716 // TODO(mazda): Fix crbug.com/158217 |
706 return false; | 717 return false; |
707 } | 718 } |
708 if (ime_control_delegate_.get()) | 719 if (ime_control_delegate_.get()) |
709 return ime_control_delegate_->HandleNextIme(); | 720 return ime_control_delegate_->HandleNextIme(); |
710 break; | 721 break; |
711 case PREVIOUS_IME: | 722 case PREVIOUS_IME: |
712 if (ime_control_delegate_.get()) | 723 if (ime_control_delegate_.get()) |
713 return ime_control_delegate_->HandlePreviousIme(); | 724 return ime_control_delegate_->HandlePreviousIme(); |
714 break; | 725 break; |
726 case PRINT_UI_HIERARCHIES: | |
727 return HandlePrintUIHierarchies(); | |
715 case SWITCH_IME: | 728 case SWITCH_IME: |
716 if (ime_control_delegate_.get()) | 729 if (ime_control_delegate_.get()) |
717 return ime_control_delegate_->HandleSwitchIme(accelerator); | 730 return ime_control_delegate_->HandleSwitchIme(accelerator); |
718 break; | 731 break; |
719 case SELECT_WIN_0: | 732 case SELECT_WIN_0: |
720 Launcher::ForPrimaryDisplay()->SwitchToWindow(0); | 733 Launcher::ForPrimaryDisplay()->SwitchToWindow(0); |
721 return true; | 734 return true; |
722 case SELECT_WIN_1: | 735 case SELECT_WIN_1: |
723 Launcher::ForPrimaryDisplay()->SwitchToWindow(1); | 736 Launcher::ForPrimaryDisplay()->SwitchToWindow(1); |
724 return true; | 737 return true; |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
900 keyboard_brightness_control_delegate) { | 913 keyboard_brightness_control_delegate) { |
901 keyboard_brightness_control_delegate_ = | 914 keyboard_brightness_control_delegate_ = |
902 keyboard_brightness_control_delegate.Pass(); | 915 keyboard_brightness_control_delegate.Pass(); |
903 } | 916 } |
904 | 917 |
905 bool AcceleratorController::CanHandleAccelerators() const { | 918 bool AcceleratorController::CanHandleAccelerators() const { |
906 return true; | 919 return true; |
907 } | 920 } |
908 | 921 |
909 } // namespace ash | 922 } // namespace ash |
OLD | NEW |