diff options
author | yusukes@chromium.org <yusukes@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-14 07:05:41 +0000 |
---|---|---|
committer | yusukes@chromium.org <yusukes@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-14 07:05:41 +0000 |
commit | ce711ac2f9c0f72b8347a381eea8106f9b57811c (patch) | |
tree | b416b659efe875090302b8e55f2fe7f1cac2cc50 /ash/focus_cycler.cc | |
parent | f292c05203ef92c03912031b9193ac5dbbeea241 (diff) | |
download | chromium_src-ce711ac2f9c0f72b8347a381eea8106f9b57811c.zip chromium_src-ce711ac2f9c0f72b8347a381eea8106f9b57811c.tar.gz chromium_src-ce711ac2f9c0f72b8347a381eea8106f9b57811c.tar.bz2 |
Handle Ctrl+F1 and Ctrl+F2 correctly even when no browser window is available.
- Remove accelerators from ash/focus_cycler.cc and chrome/browser/ui/views/accelerator_table.cc. Instead, handle it in ash/accelerator/accelerator_controller.cc.
- Do not try to focus a browser window in ash/focus_cycler.cc when it's not available. Unit tests added.
BUG=129307
TEST=ran aura_shell_unittests + manually checked
Review URL: https://chromiumcodereview.appspot.com/10545132
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@142107 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/focus_cycler.cc')
-rw-r--r-- | ash/focus_cycler.cc | 47 |
1 files changed, 15 insertions, 32 deletions
diff --git a/ash/focus_cycler.cc b/ash/focus_cycler.cc index f0854c0..d439644 100644 --- a/ash/focus_cycler.cc +++ b/ash/focus_cycler.cc @@ -7,14 +7,22 @@ #include "ash/shell.h" #include "ash/system/tray/system_tray.h" #include "ash/wm/window_cycle_controller.h" -#include "ui/views/widget/widget.h" -#include "ui/views/focus/focus_search.h" -#include "ui/aura/window.h" #include "ui/aura/client/activation_client.h" +#include "ui/aura/window.h" #include "ui/views/accessible_pane_view.h" +#include "ui/views/focus/focus_search.h" +#include "ui/views/widget/widget.h" namespace ash { +namespace { + +bool HasFocusableWindow() { + return !WindowCycleController::BuildWindowList().empty(); +} + +} // namespace + namespace internal { FocusCycler::FocusCycler() : widget_activating_(NULL) { @@ -25,21 +33,13 @@ FocusCycler::~FocusCycler() { void FocusCycler::AddWidget(views::Widget* widget) { widgets_.push_back(widget); - - widget->GetFocusManager()->RegisterAccelerator( - ui::Accelerator(ui::VKEY_F2, ui::EF_CONTROL_DOWN), - ui::AcceleratorManager::kNormalPriority, - this); - widget->GetFocusManager()->RegisterAccelerator( - ui::Accelerator(ui::VKEY_F1, ui::EF_CONTROL_DOWN), - ui::AcceleratorManager::kNormalPriority, - this); } void FocusCycler::RotateFocus(Direction direction) { + const bool has_window = HasFocusableWindow(); int index = 0; int count = static_cast<int>(widgets_.size()); - int browser_index = count; + int browser_index = has_window ? count : -1; for (; index < count; ++index) { if (widgets_[index]->IsActive()) @@ -48,7 +48,8 @@ void FocusCycler::RotateFocus(Direction direction) { int start_index = index; - count = count + 1; + if (has_window) + ++count; for (;;) { if (direction == FORWARD) @@ -88,24 +89,6 @@ bool FocusCycler::FocusWidget(views::Widget* widget) { return false; } -bool FocusCycler::AcceleratorPressed(const ui::Accelerator& accelerator) { - switch (accelerator.key_code()) { - case ui::VKEY_F1: - RotateFocus(BACKWARD); - return true; - case ui::VKEY_F2: - RotateFocus(FORWARD); - return true; - default: - NOTREACHED(); - return false; - } -} - -bool FocusCycler::CanHandleAccelerators() const { - return true; -} - } // namespace internal } // namespace ash |