Chromium Code Reviews| Index: ui/views/focus/focus_manager.cc |
| diff --git a/ui/views/focus/focus_manager.cc b/ui/views/focus/focus_manager.cc |
| index 706b3182721dcafe37b86665445094ac5a4d283a..514d8e76b3642069381d820cf0ef23a47ef911a2 100644 |
| --- a/ui/views/focus/focus_manager.cc |
| +++ b/ui/views/focus/focus_manager.cc |
| @@ -17,7 +17,6 @@ |
| #include "ui/base/ui_base_switches_util.h" |
| #include "ui/events/event.h" |
| #include "ui/events/keycodes/keyboard_codes.h" |
| -#include "ui/views/focus/focus_manager_delegate.h" |
| #include "ui/views/focus/focus_search.h" |
| #include "ui/views/focus/view_storage.h" |
| #include "ui/views/focus/widget_focus_manager.h" |
| @@ -44,12 +43,10 @@ static inline int CalculateModifiers(const ui::KeyEvent& event) { |
| } // namespace |
| -bool FocusManager::shortcut_handling_suspended_ = false; |
| bool FocusManager::arrow_key_traversal_enabled_ = false; |
| -FocusManager::FocusManager(Widget* widget, FocusManagerDelegate* delegate) |
| +FocusManager::FocusManager(Widget* widget) |
| : widget_(widget), |
| - delegate_(delegate), |
| focused_view_(NULL), |
| accelerator_manager_(new ui::AcceleratorManager), |
| focus_change_reason_(kReasonDirectFocusChange), |
| @@ -57,6 +54,7 @@ FocusManager::FocusManager(Widget* widget, FocusManagerDelegate* delegate) |
| DCHECK(widget_); |
| stored_focused_view_storage_id_ = |
| ViewStorage::GetInstance()->CreateStorageID(); |
| + accelerator_processors_.push_back(accelerator_manager_.get()); |
| } |
| FocusManager::~FocusManager() { |
| @@ -68,9 +66,6 @@ bool FocusManager::OnKeyEvent(const ui::KeyEvent& event) { |
| if (event.type() != ui::ET_KEY_PRESSED && event.type() != ui::ET_KEY_RELEASED) |
| return false; |
| - if (shortcut_handling_suspended()) |
| - return true; |
| - |
| int modifiers = CalculateModifiers(event); |
| ui::Accelerator accelerator(event.key_code(), modifiers); |
| accelerator.set_type(event.type()); |
| @@ -552,22 +547,39 @@ void FocusManager::UnregisterAccelerators(ui::AcceleratorTarget* target) { |
| } |
| bool FocusManager::ProcessAccelerator(const ui::Accelerator& accelerator) { |
| - if (accelerator_manager_->Process(accelerator)) |
| - return true; |
| - if (delegate_.get()) |
| - return delegate_->ProcessAccelerator(accelerator); |
| + for (ui::AcceleratorProcessor* processor : accelerator_processors_) { |
| + if (processor->ProcessAccelerator(accelerator)) |
| + return true; |
| + } |
| return false; |
| } |
| -ui::AcceleratorTarget* FocusManager::GetCurrentTargetForAccelerator( |
| +ui::AcceleratorTarget* FocusManager::GetTargetForAccelerator( |
| const ui::Accelerator& accelerator) const { |
| - ui::AcceleratorTarget* target = |
| - accelerator_manager_->GetCurrentTarget(accelerator); |
| - if (!target && delegate_.get()) |
| - target = delegate_->GetCurrentTargetForAccelerator(accelerator); |
| + ui::AcceleratorTarget* target = nullptr; |
| + for (ui::AcceleratorProcessor* processor : accelerator_processors_) { |
| + target = processor->GetTargetForAccelerator(accelerator); |
| + if (target) |
| + break; |
|
sky
2015/01/08 23:39:26
nit: make this return target and move 559 into for
Andre
2015/01/09 00:06:15
Done.
|
| + } |
| return target; |
| } |
| +void FocusManager::AddAcceleratorPreProcessor( |
| + ui::AcceleratorProcessor* processor) { |
| + accelerator_processors_.push_front(processor); |
| +} |
| + |
| +void FocusManager::AddAcceleratorPostProcessor( |
| + ui::AcceleratorProcessor* processor) { |
| + accelerator_processors_.push_back(processor); |
| +} |
| + |
| +void FocusManager::RemoveAcceleratorProcessor( |
| + ui::AcceleratorProcessor* processor) { |
| + accelerator_processors_.remove(processor); |
| +} |
| + |
| bool FocusManager::HasPriorityHandler( |
| const ui::Accelerator& accelerator) const { |
| return accelerator_manager_->HasPriorityHandler(accelerator); |