diff options
-rw-r--r-- | chrome/browser/find_in_page_controller.cc | 19 | ||||
-rw-r--r-- | chrome/views/focus_manager.h | 13 |
2 files changed, 16 insertions, 16 deletions
diff --git a/chrome/browser/find_in_page_controller.cc b/chrome/browser/find_in_page_controller.cc index aa73a18..1b624a7 100644 --- a/chrome/browser/find_in_page_controller.cc +++ b/chrome/browser/find_in_page_controller.cc @@ -410,7 +410,6 @@ bool FindInPageController::AcceleratorPressed( return true; } - //////////////////////////////////////////////////////////////////////////////// // FindInPageController, AnimationDelegate implementation: @@ -654,24 +653,24 @@ void FindInPageController::RestoreSavedFocus() { void FindInPageController::RegisterEscAccelerator() { ChromeViews::Accelerator escape(VK_ESCAPE, false, false, false); + // TODO(finnur): Once we fix issue 1307173 we should not remember any old + // accelerator targets and just Register and Unregister when needed. ChromeViews::AcceleratorTarget* old_target = focus_manager_->RegisterAccelerator(escape, this); - // We can get a FocusWillChange event setting focus to something that is - // already focused, without loosing focus first, for example when you switch - // to another application and come back. We must take care not to overwrite - // what the old accelerator target is in that case. - if (old_target != this) + if (!old_accel_target_for_esc_) old_accel_target_for_esc_ = old_target; } void FindInPageController::UnregisterEscAccelerator() { - // This DCHECK can happen if we get FocusWillChange events in incorrect order - // so that we think we are loosing focus twice. + // TODO(finnur): Once we fix issue 1307173 we should not remember any old + // accelerator targets and just Register and Unregister when needed. DCHECK(old_accel_target_for_esc_ != NULL); ChromeViews::Accelerator escape(VK_ESCAPE, false, false, false); - focus_manager_->RegisterAccelerator(escape, old_accel_target_for_esc_); - old_accel_target_for_esc_ = NULL; + ChromeViews::AcceleratorTarget* current_target = + focus_manager_->GetTargetForAccelerator(escape); + if (current_target == this) + focus_manager_->RegisterAccelerator(escape, old_accel_target_for_esc_); } void FindInPageController::Observe(NotificationType type, diff --git a/chrome/views/focus_manager.h b/chrome/views/focus_manager.h index 0537e5c..4b99420 100644 --- a/chrome/views/focus_manager.h +++ b/chrome/views/focus_manager.h @@ -292,6 +292,13 @@ class FocusManager : public NotificationObserver { void AddFocusChangeListener(FocusChangeListener* listener); void RemoveFocusChangeListener(FocusChangeListener* listener); + // Returns the AcceleratorTarget that should be activated for the specified + // keyboard accelerator, or NULL if no view is registered for that keyboard + // accelerator. + // TODO(finnur): http://b/1307173 Make this private once the bug is fixed. + AcceleratorTarget* GetTargetForAccelerator( + const Accelerator& accelerator) const; + private: explicit FocusManager(HWND root, RootView* root_view); ~FocusManager(); @@ -311,12 +318,6 @@ class FocusManager : public NotificationObserver { bool reverse, bool dont_loop); - // Returns the AcceleratorTarget that should be activated for the specified - // keyboard accelerator, or NULL if no view is registered for that keyboard - // accelerator. - AcceleratorTarget* GetTargetForAccelerator( - const Accelerator& accelerator) const; - // The RootView of the window associated with this FocusManager. RootView* top_root_view_; |