Index: ash/accelerators/accelerator_controller.cc |
diff --git a/ash/accelerators/accelerator_controller.cc b/ash/accelerators/accelerator_controller.cc |
index 96ee265d23b84e862c260c41ea42eceaa55c1b82..b1b77ccec02d351404cca2bb545d86971624eec0 100644 |
--- a/ash/accelerators/accelerator_controller.cc |
+++ b/ash/accelerators/accelerator_controller.cc |
@@ -743,21 +743,20 @@ bool HandlePrintUIHierarchies() { |
return true; |
} |
-} // namespace |
+class AutoSet { |
+ public: |
+ AutoSet(ui::Accelerator* scoped, ui::Accelerator new_value) |
+ : scoped_(scoped), new_value_(new_value) {} |
+ ~AutoSet() { *scoped_ = new_value_; } |
-//////////////////////////////////////////////////////////////////////////////// |
-// AcceleratorControllerContext, public: |
+ private: |
+ ui::Accelerator* scoped_; |
+ const ui::Accelerator new_value_; |
-AcceleratorControllerContext::AcceleratorControllerContext() { |
- current_accelerator_.set_type(ui::ET_UNKNOWN); |
- previous_accelerator_.set_type(ui::ET_UNKNOWN); |
-} |
+ DISALLOW_COPY_AND_ASSIGN(AutoSet); |
+}; |
-void AcceleratorControllerContext::UpdateContext( |
- const ui::Accelerator& accelerator) { |
- previous_accelerator_ = current_accelerator_; |
- current_accelerator_ = accelerator; |
-} |
+} // namespace |
//////////////////////////////////////////////////////////////////////////////// |
// AcceleratorController, public: |
@@ -771,6 +770,7 @@ AcceleratorController::~AcceleratorController() { |
} |
void AcceleratorController::Init() { |
+ previous_accelerator_.set_type(ui::ET_UNKNOWN); |
for (size_t i = 0; i < kActionsAllowedAtLoginOrLockScreenLength; ++i) { |
actions_allowed_at_login_screen_.insert( |
kActionsAllowedAtLoginOrLockScreen[i]); |
@@ -825,6 +825,8 @@ void AcceleratorController::UnregisterAll(ui::AcceleratorTarget* target) { |
} |
bool AcceleratorController::Process(const ui::Accelerator& accelerator) { |
+ AutoSet auto_set(&previous_accelerator_, accelerator); |
+ |
if (ime_control_delegate_) { |
return accelerator_manager_->Process( |
ime_control_delegate_->RemapAccelerator(accelerator)); |
@@ -889,18 +891,15 @@ bool AcceleratorController::PerformAction(int action, |
// empty Accelerator() instance as the second argument. Such events |
// should never be suspended. |
const bool gesture_event = key_code == ui::VKEY_UNKNOWN; |
- |
// Ignore accelerators invoked as repeated (while holding a key for a long |
// time, if their handling is nonrepeatable. |
if (nonrepeatable_actions_.find(action) != nonrepeatable_actions_.end() && |
- context_.repeated() && !gesture_event) { |
+ accelerator.IsRepeat() && !gesture_event) { |
return true; |
} |
// Type of the previous accelerator. Used by NEXT_IME and DISABLE_CAPS_LOCK. |
- const ui::EventType previous_event_type = |
- context_.previous_accelerator().type(); |
- const ui::KeyboardCode previous_key_code = |
- context_.previous_accelerator().key_code(); |
+ const ui::EventType previous_event_type = previous_accelerator_.type(); |
+ const ui::KeyboardCode previous_key_code = previous_accelerator_.key_code(); |
// You *MUST* return true when some action is performed. Otherwise, this |
// function might be called *twice*, via BrowserView::PreHandleKeyboardEvent |