| OLD | NEW | 
|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 #include "chrome/browser/ui/views/dropdown_bar_host.h" | 5 #include "chrome/browser/ui/views/dropdown_bar_host.h" | 
| 6 | 6 | 
| 7 #include <algorithm> | 7 #include <algorithm> | 
| 8 | 8 | 
| 9 #include "chrome/browser/ui/view_ids.h" | 9 #include "chrome/browser/ui/view_ids.h" | 
| 10 #include "chrome/browser/ui/views/dropdown_bar_view.h" | 10 #include "chrome/browser/ui/views/dropdown_bar_view.h" | 
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 124 bool DropdownBarHost::IsVisible() const { | 124 bool DropdownBarHost::IsVisible() const { | 
| 125   return is_visible_; | 125   return is_visible_; | 
| 126 } | 126 } | 
| 127 | 127 | 
| 128 //////////////////////////////////////////////////////////////////////////////// | 128 //////////////////////////////////////////////////////////////////////////////// | 
| 129 // DropdownBarHost, views::FocusChangeListener implementation: | 129 // DropdownBarHost, views::FocusChangeListener implementation: | 
| 130 void DropdownBarHost::FocusWillChange(views::View* focused_before, | 130 void DropdownBarHost::FocusWillChange(views::View* focused_before, | 
| 131                                       views::View* focused_now) { | 131                                       views::View* focused_now) { | 
| 132   // First we need to determine if one or both of the views passed in are child | 132   // First we need to determine if one or both of the views passed in are child | 
| 133   // views of our view. | 133   // views of our view. | 
| 134   bool our_view_before = focused_before && view_->IsParentOf(focused_before); | 134   bool our_view_before = focused_before && view_->Contains(focused_before); | 
| 135   bool our_view_now = focused_now && view_->IsParentOf(focused_now); | 135   bool our_view_now = focused_now && view_->Contains(focused_now); | 
| 136 | 136 | 
| 137   // When both our_view_before and our_view_now are false, it means focus is | 137   // When both our_view_before and our_view_now are false, it means focus is | 
| 138   // changing hands elsewhere in the application (and we shouldn't do anything). | 138   // changing hands elsewhere in the application (and we shouldn't do anything). | 
| 139   // Similarly, when both are true, focus is changing hands within the dropdown | 139   // Similarly, when both are true, focus is changing hands within the dropdown | 
| 140   // widget (and again, we should not do anything). We therefore only need to | 140   // widget (and again, we should not do anything). We therefore only need to | 
| 141   // look at when we gain initial focus and when we loose it. | 141   // look at when we gain initial focus and when we loose it. | 
| 142   if (!our_view_before && our_view_now) { | 142   if (!our_view_before && our_view_now) { | 
| 143     // We are gaining focus from outside the dropdown widget so we must register | 143     // We are gaining focus from outside the dropdown widget so we must register | 
| 144     // a handler for Escape. | 144     // a handler for Escape. | 
| 145     RegisterAccelerators(); | 145     RegisterAccelerators(); | 
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 310   focus_manager_->RegisterAccelerator(escape, this); | 310   focus_manager_->RegisterAccelerator(escape, this); | 
| 311   esc_accel_target_registered_ = true; | 311   esc_accel_target_registered_ = true; | 
| 312 } | 312 } | 
| 313 | 313 | 
| 314 void DropdownBarHost::UnregisterAccelerators() { | 314 void DropdownBarHost::UnregisterAccelerators() { | 
| 315   DCHECK(esc_accel_target_registered_); | 315   DCHECK(esc_accel_target_registered_); | 
| 316   views::Accelerator escape(ui::VKEY_ESCAPE, false, false, false); | 316   views::Accelerator escape(ui::VKEY_ESCAPE, false, false, false); | 
| 317   focus_manager_->UnregisterAccelerator(escape, this); | 317   focus_manager_->UnregisterAccelerator(escape, this); | 
| 318   esc_accel_target_registered_ = false; | 318   esc_accel_target_registered_ = false; | 
| 319 } | 319 } | 
| OLD | NEW | 
|---|