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

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

Issue 312483002: More accelerator code leanup (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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_filter_unittest.cc » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_delegate.h" 5 #include "ash/accelerators/accelerator_delegate.h"
6 6
7 #include "ash/accelerators/accelerator_controller.h" 7 #include "ash/accelerators/accelerator_controller.h"
8 #include "ash/shell.h" 8 #include "ash/shell.h"
9 #include "ash/wm/window_state.h" 9 #include "ash/wm/window_state.h"
10 #include "ui/base/accelerators/accelerator.h" 10 #include "ui/base/accelerators/accelerator.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 } 42 }
43 if (!ShouldProcessAcceleratorNow(key_event, accelerator)) 43 if (!ShouldProcessAcceleratorNow(key_event, accelerator))
44 return false; 44 return false;
45 return Shell::GetInstance()->accelerator_controller()->Process(accelerator); 45 return Shell::GetInstance()->accelerator_controller()->Process(accelerator);
46 } 46 }
47 47
48 // Uses the top level window so if the target is a web contents window the 48 // Uses the top level window so if the target is a web contents window the
49 // containing parent window will be checked for the property. 49 // containing parent window will be checked for the property.
50 bool AcceleratorDelegate::CanConsumeSystemKeys(const ui::KeyEvent& event) { 50 bool AcceleratorDelegate::CanConsumeSystemKeys(const ui::KeyEvent& event) {
51 aura::Window* target = static_cast<aura::Window*>(event.target()); 51 aura::Window* target = static_cast<aura::Window*>(event.target());
52 if (!target) // Can be NULL in tests. 52 DCHECK(target);
53 return false;
54 aura::Window* top_level = ::wm::GetToplevelWindow(target); 53 aura::Window* top_level = ::wm::GetToplevelWindow(target);
55 return top_level && wm::GetWindowState(top_level)->can_consume_system_keys(); 54 return top_level && wm::GetWindowState(top_level)->can_consume_system_keys();
56 } 55 }
57 56
58 // Returns true if the |accelerator| should be processed now, inside Ash's env 57 // Returns true if the |accelerator| should be processed now, inside Ash's env
59 // event filter. 58 // event filter.
60 bool AcceleratorDelegate::ShouldProcessAcceleratorNow( 59 bool AcceleratorDelegate::ShouldProcessAcceleratorNow(
61 const ui::KeyEvent& event, 60 const ui::KeyEvent& event,
62 const ui::Accelerator& accelerator) { 61 const ui::Accelerator& accelerator) {
63 aura::Window* target = static_cast<aura::Window*>(event.target()); 62 aura::Window* target = static_cast<aura::Window*>(event.target());
64 if (!target) 63 DCHECK(target);
65 return true;
66 64
67 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 65 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
68 if (std::find(root_windows.begin(), root_windows.end(), target) != 66 if (std::find(root_windows.begin(), root_windows.end(), target) !=
69 root_windows.end()) 67 root_windows.end())
70 return true; 68 return true;
71 69
72 // A full screen window should be able to handle all key events including the 70 // A full screen window should be able to handle all key events including the
73 // reserved ones. 71 // reserved ones.
74 aura::Window* top_level = ::wm::GetToplevelWindow(target); 72 aura::Window* top_level = ::wm::GetToplevelWindow(target);
75 73
76 if (top_level && wm::GetWindowState(top_level)->IsFullscreen()) { 74 if (top_level && wm::GetWindowState(top_level)->IsFullscreen()) {
77 // TODO(yusukes): On Chrome OS, only browser and flash windows can be full 75 // TODO(yusukes): On Chrome OS, only browser and flash windows can be full
78 // screen. Launching an app in "open full-screen" mode is not supported yet. 76 // screen. Launching an app in "open full-screen" mode is not supported yet.
79 // That makes the IsWindowFullscreen() check above almost meaningless 77 // That makes the IsWindowFullscreen() check above almost meaningless
80 // because a browser and flash window do handle Ash accelerators anyway 78 // because a browser and flash window do handle Ash accelerators anyway
81 // before they're passed to a page or flash content. 79 // before they're passed to a page or flash content.
82 return false; 80 return false;
83 } 81 }
84 82
85 if (Shell::GetInstance()->GetAppListTargetVisibility()) 83 if (Shell::GetInstance()->GetAppListTargetVisibility())
86 return true; 84 return true;
87 85
88 // Unless |target| is in the full screen state, handle reserved accelerators 86 // Unless |target| is in the full screen state, handle reserved accelerators
89 // such as Alt+Tab now. 87 // such as Alt+Tab now.
90 return Shell::GetInstance()->accelerator_controller()->IsReservedAccelerator( 88 return Shell::GetInstance()->accelerator_controller()->IsReservedAccelerator(
91 accelerator); 89 accelerator);
92 } 90 }
93 91
94 } // namespace ash 92 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/accelerators/accelerator_filter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698