| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "base/logging.h" | 5 #include "base/logging.h" |
| 6 #include "chrome/browser/ui/view_ids.h" | 6 #include "chrome/browser/ui/view_ids.h" |
| 7 #include "chrome/browser/ui/views/frame/browser_view.h" | 7 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 8 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 8 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
| 9 #include "chrome/browser/ui/views/accessible_pane_view.h" | 9 #include "chrome/browser/ui/views/accessible_pane_view.h" |
| 10 #include "views/controls/button/menu_button.h" | 10 #include "views/controls/button/menu_button.h" |
| 11 #include "views/controls/native/native_view_host.h" | 11 #include "views/controls/native/native_view_host.h" |
| 12 #include "views/focus/focus_search.h" | 12 #include "views/focus/focus_search.h" |
| 13 #include "views/focus/view_storage.h" | 13 #include "views/focus/view_storage.h" |
| 14 #include "views/widget/tooltip_manager.h" | 14 #include "views/widget/tooltip_manager.h" |
| 15 #include "views/widget/widget.h" | 15 #include "views/widget/widget.h" |
| 16 | 16 |
| 17 AccessiblePaneView::AccessiblePaneView() | 17 AccessiblePaneView::AccessiblePaneView() |
| 18 : pane_has_focus_(false), | 18 : pane_has_focus_(false), |
| 19 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)), | 19 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)), |
| 20 focus_manager_(NULL), | 20 focus_manager_(NULL), |
| 21 home_key_(app::VKEY_HOME, false, false, false), | 21 home_key_(ui::VKEY_HOME, false, false, false), |
| 22 end_key_(app::VKEY_END, false, false, false), | 22 end_key_(ui::VKEY_END, false, false, false), |
| 23 escape_key_(app::VKEY_ESCAPE, false, false, false), | 23 escape_key_(ui::VKEY_ESCAPE, false, false, false), |
| 24 left_key_(app::VKEY_LEFT, false, false, false), | 24 left_key_(ui::VKEY_LEFT, false, false, false), |
| 25 right_key_(app::VKEY_RIGHT, false, false, false), | 25 right_key_(ui::VKEY_RIGHT, false, false, false), |
| 26 last_focused_view_storage_id_(-1) { | 26 last_focused_view_storage_id_(-1) { |
| 27 focus_search_.reset(new views::FocusSearch(this, true, true)); | 27 focus_search_.reset(new views::FocusSearch(this, true, true)); |
| 28 } | 28 } |
| 29 | 29 |
| 30 AccessiblePaneView::~AccessiblePaneView() { | 30 AccessiblePaneView::~AccessiblePaneView() { |
| 31 if (pane_has_focus_) { | 31 if (pane_has_focus_) { |
| 32 focus_manager_->RemoveFocusChangeListener(this); | 32 focus_manager_->RemoveFocusChangeListener(this); |
| 33 } | 33 } |
| 34 } | 34 } |
| 35 | 35 |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 // Special case: don't handle any accelerators for the location bar, | 154 // Special case: don't handle any accelerators for the location bar, |
| 155 // so that it behaves exactly the same whether you focus it with Ctrl+L | 155 // so that it behaves exactly the same whether you focus it with Ctrl+L |
| 156 // or F6 or Alt+D or Alt+Shift+T. | 156 // or F6 or Alt+D or Alt+Shift+T. |
| 157 views::View* focused_view = focus_manager_->GetFocusedView(); | 157 views::View* focused_view = focus_manager_->GetFocusedView(); |
| 158 if ((focused_view->GetClassName() == LocationBarView::kViewClassName || | 158 if ((focused_view->GetClassName() == LocationBarView::kViewClassName || |
| 159 focused_view->GetClassName() == views::NativeViewHost::kViewClassName)) { | 159 focused_view->GetClassName() == views::NativeViewHost::kViewClassName)) { |
| 160 return false; | 160 return false; |
| 161 } | 161 } |
| 162 | 162 |
| 163 switch (accelerator.GetKeyCode()) { | 163 switch (accelerator.GetKeyCode()) { |
| 164 case app::VKEY_ESCAPE: | 164 case ui::VKEY_ESCAPE: |
| 165 RemovePaneFocus(); | 165 RemovePaneFocus(); |
| 166 RestoreLastFocusedView(); | 166 RestoreLastFocusedView(); |
| 167 return true; | 167 return true; |
| 168 case app::VKEY_LEFT: | 168 case ui::VKEY_LEFT: |
| 169 focus_manager_->AdvanceFocus(true); | 169 focus_manager_->AdvanceFocus(true); |
| 170 return true; | 170 return true; |
| 171 case app::VKEY_RIGHT: | 171 case ui::VKEY_RIGHT: |
| 172 focus_manager_->AdvanceFocus(false); | 172 focus_manager_->AdvanceFocus(false); |
| 173 return true; | 173 return true; |
| 174 case app::VKEY_HOME: | 174 case ui::VKEY_HOME: |
| 175 focus_manager_->SetFocusedViewWithReason( | 175 focus_manager_->SetFocusedViewWithReason( |
| 176 GetFirstFocusableChild(), views::FocusManager::kReasonFocusTraversal); | 176 GetFirstFocusableChild(), views::FocusManager::kReasonFocusTraversal); |
| 177 return true; | 177 return true; |
| 178 case app::VKEY_END: | 178 case ui::VKEY_END: |
| 179 focus_manager_->SetFocusedViewWithReason( | 179 focus_manager_->SetFocusedViewWithReason( |
| 180 GetLastFocusableChild(), views::FocusManager::kReasonFocusTraversal); | 180 GetLastFocusableChild(), views::FocusManager::kReasonFocusTraversal); |
| 181 return true; | 181 return true; |
| 182 default: | 182 default: |
| 183 return false; | 183 return false; |
| 184 } | 184 } |
| 185 } | 185 } |
| 186 | 186 |
| 187 void AccessiblePaneView::SetVisible(bool flag) { | 187 void AccessiblePaneView::SetVisible(bool flag) { |
| 188 if (IsVisible() && !flag && pane_has_focus_) { | 188 if (IsVisible() && !flag && pane_has_focus_) { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 | 242 |
| 243 views::FocusTraversable* AccessiblePaneView::GetFocusTraversableParent() { | 243 views::FocusTraversable* AccessiblePaneView::GetFocusTraversableParent() { |
| 244 DCHECK(pane_has_focus_); | 244 DCHECK(pane_has_focus_); |
| 245 return NULL; | 245 return NULL; |
| 246 } | 246 } |
| 247 | 247 |
| 248 views::View* AccessiblePaneView::GetFocusTraversableParentView() { | 248 views::View* AccessiblePaneView::GetFocusTraversableParentView() { |
| 249 DCHECK(pane_has_focus_); | 249 DCHECK(pane_has_focus_); |
| 250 return NULL; | 250 return NULL; |
| 251 } | 251 } |
| OLD | NEW |