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

Unified Diff: ash/accelerators/accelerator_delegate.cc

Issue 308193002: Simplify AcceleratorDelegate interface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed condition Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/accelerators/accelerator_delegate.h ('k') | ui/wm/core/accelerator_delegate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/accelerators/accelerator_delegate.cc
diff --git a/ash/accelerators/accelerator_delegate.cc b/ash/accelerators/accelerator_delegate.cc
index dc83437aceef6f0d5863cfbd4a42a14e9081e8be..687c2f0385fd874ff36b6eb5735323b295ac346c 100644
--- a/ash/accelerators/accelerator_delegate.cc
+++ b/ash/accelerators/accelerator_delegate.cc
@@ -27,6 +27,24 @@ void AcceleratorDelegate::PreProcessAccelerator(
accelerator);
}
+bool AcceleratorDelegate::ProcessAccelerator(const ui::KeyEvent& key_event,
+ const ui::Accelerator& accelerator,
+ KeyType key_type) {
+ // Special hardware keys like brightness and volume are handled in
+ // special way. However, some windows can override this behavior
+ // (e.g. Chrome v1 apps by default and Chrome v2 apps with
+ // permission) by setting a window property.
+ if (key_type == KEY_TYPE_SYSTEM && !CanConsumeSystemKeys(key_event)) {
+ // System keys are always consumed regardless of whether they trigger an
+ // accelerator to prevent windows from seeing unexpected key up events.
+ Shell::GetInstance()->accelerator_controller()->Process(accelerator);
+ return true;
+ }
+ if (!ShouldProcessAcceleratorNow(key_event, accelerator))
oshima 2014/05/30 23:50:28 FYI: The rest of code has to be run for both OTHER
+ return false;
+ return Shell::GetInstance()->accelerator_controller()->Process(accelerator);
+}
+
// Uses the top level window so if the target is a web contents window the
// containing parent window will be checked for the property.
bool AcceleratorDelegate::CanConsumeSystemKeys(const ui::KeyEvent& event) {
@@ -53,7 +71,9 @@ bool AcceleratorDelegate::ShouldProcessAcceleratorNow(
// A full screen window should be able to handle all key events including the
// reserved ones.
- if (wm::GetWindowState(target)->IsFullscreen()) {
+ aura::Window* top_level = ::wm::GetToplevelWindow(target);
+
+ if (top_level && wm::GetWindowState(top_level)->IsFullscreen()) {
// TODO(yusukes): On Chrome OS, only browser and flash windows can be full
// screen. Launching an app in "open full-screen" mode is not supported yet.
// That makes the IsWindowFullscreen() check above almost meaningless
@@ -71,9 +91,4 @@ bool AcceleratorDelegate::ShouldProcessAcceleratorNow(
accelerator);
}
-bool AcceleratorDelegate::ProcessAccelerator(
- const ui::Accelerator& accelerator) {
- return Shell::GetInstance()->accelerator_controller()->Process(accelerator);
-}
-
} // namespace ash
« no previous file with comments | « ash/accelerators/accelerator_delegate.h ('k') | ui/wm/core/accelerator_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698