| Index: ash/accelerators/accelerator_filter.cc
|
| diff --git a/ash/accelerators/accelerator_filter.cc b/ash/accelerators/accelerator_filter.cc
|
| index dcc95ba9bd9c037f56383601b29a4ffb724b0278..0a799b1eba39dc59f4902dad0277b96adb2b0ad9 100644
|
| --- a/ash/accelerators/accelerator_filter.cc
|
| +++ b/ash/accelerators/accelerator_filter.cc
|
| @@ -6,15 +6,41 @@
|
|
|
| #include "ash/accelerators/accelerator_controller.h"
|
| #include "ash/shell.h"
|
| +#include "ash/shell_delegate.h"
|
| +#include "ash/wm/window_util.h"
|
| +#include "ui/aura/client/aura_constants.h"
|
| +#include "ui/aura/client/window_types.h"
|
| #include "ui/aura/event.h"
|
| #include "ui/aura/root_window.h"
|
| #include "ui/base/accelerators/accelerator.h"
|
| #include "ui/base/accelerators/accelerator_manager.h"
|
| +#include "ui/base/ui_base_types.h"
|
|
|
| namespace {
|
| +
|
| const int kModifierFlagMask = (ui::EF_SHIFT_DOWN |
|
| ui::EF_CONTROL_DOWN |
|
| ui::EF_ALT_DOWN);
|
| +
|
| +// Returns true if an Ash accelerator should be processed now.
|
| +bool ShouldProcessAcceleratorsNow(aura::Window* target) {
|
| + if (!target)
|
| + return true;
|
| +
|
| + // Check obvious cases before going to the slow path.
|
| + if (target->type() != aura::client::WINDOW_TYPE_UNKNOWN &&
|
| + target->type() != aura::client::WINDOW_TYPE_NORMAL) {
|
| + return true;
|
| + }
|
| + if (target == ash::Shell::GetRootWindow())
|
| + return true;
|
| +
|
| + ash::ShellDelegate* delegate = ash::Shell::GetInstance()->delegate();
|
| + if (!delegate)
|
| + return true;
|
| + return !delegate->IsBrowserWindow(ash::wm::GetActivatableWindow(target));
|
| +}
|
| +
|
| } // namespace
|
|
|
| namespace ash {
|
| @@ -40,6 +66,11 @@ bool AcceleratorFilter::PreHandleKeyEvent(aura::Window* target,
|
| if (event->is_char())
|
| return false;
|
|
|
| + // When a browser or app window is focused, don't process Ash global
|
| + // shortcuts here so the app could check it first. crbug.com/123856
|
| + if (!ShouldProcessAcceleratorsNow(target))
|
| + return false;
|
| +
|
| ui::Accelerator accelerator(event->key_code(),
|
| event->flags() & kModifierFlagMask);
|
| accelerator.set_type(type);
|
|
|