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 "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/accessible_pane_view.h" | 7 #include "chrome/browser/ui/views/accessible_pane_view.h" |
8 #include "chrome/browser/ui/views/frame/browser_view.h" | 8 #include "chrome/browser/ui/views/frame/browser_view.h" |
9 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 9 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
10 #include "ui/base/accessibility/accessible_view_state.h" | 10 #include "ui/base/accessibility/accessible_view_state.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 } | 29 } |
30 | 30 |
31 AccessiblePaneView::~AccessiblePaneView() { | 31 AccessiblePaneView::~AccessiblePaneView() { |
32 if (pane_has_focus_) { | 32 if (pane_has_focus_) { |
33 focus_manager_->RemoveFocusChangeListener(this); | 33 focus_manager_->RemoveFocusChangeListener(this); |
34 } | 34 } |
35 } | 35 } |
36 | 36 |
37 bool AccessiblePaneView::SetPaneFocus(int view_storage_id, | 37 bool AccessiblePaneView::SetPaneFocus(int view_storage_id, |
38 views::View* initial_focus) { | 38 views::View* initial_focus) { |
39 if (!IsVisible()) | 39 if (!visible()) |
40 return false; | 40 return false; |
41 | 41 |
42 // Save the storage id to the last focused view. This would be used to request | 42 // Save the storage id to the last focused view. This would be used to request |
43 // focus to the view when the traversal is ended. | 43 // focus to the view when the traversal is ended. |
44 last_focused_view_storage_id_ = view_storage_id; | 44 last_focused_view_storage_id_ = view_storage_id; |
45 | 45 |
46 if (!focus_manager_) | 46 if (!focus_manager_) |
47 focus_manager_ = GetFocusManager(); | 47 focus_manager_ = GetFocusManager(); |
48 | 48 |
49 // Use the provided initial focus if it's visible and enabled, otherwise | 49 // Use the provided initial focus if it's visible and enabled, otherwise |
50 // use the first focusable child. | 50 // use the first focusable child. |
51 if (!initial_focus || | 51 if (!initial_focus || |
52 !Contains(initial_focus) || | 52 !Contains(initial_focus) || |
53 !initial_focus->IsVisible() || | 53 !initial_focus->visible() || |
54 !initial_focus->IsEnabled()) { | 54 !initial_focus->IsEnabled()) { |
55 initial_focus = GetFirstFocusableChild(); | 55 initial_focus = GetFirstFocusableChild(); |
56 } | 56 } |
57 | 57 |
58 // Return false if there are no focusable children. | 58 // Return false if there are no focusable children. |
59 if (!initial_focus) | 59 if (!initial_focus) |
60 return false; | 60 return false; |
61 | 61 |
62 // Set focus to the initial view. If it's a location bar, use a special | 62 // Set focus to the initial view. If it's a location bar, use a special |
63 // method that tells it to select all, also. | 63 // method that tells it to select all, also. |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 case ui::VKEY_END: | 183 case ui::VKEY_END: |
184 focus_manager_->SetFocusedViewWithReason( | 184 focus_manager_->SetFocusedViewWithReason( |
185 GetLastFocusableChild(), views::FocusManager::kReasonFocusTraversal); | 185 GetLastFocusableChild(), views::FocusManager::kReasonFocusTraversal); |
186 return true; | 186 return true; |
187 default: | 187 default: |
188 return false; | 188 return false; |
189 } | 189 } |
190 } | 190 } |
191 | 191 |
192 void AccessiblePaneView::SetVisible(bool flag) { | 192 void AccessiblePaneView::SetVisible(bool flag) { |
193 if (IsVisible() && !flag && pane_has_focus_) { | 193 if (visible() && !flag && pane_has_focus_) { |
194 RemovePaneFocus(); | 194 RemovePaneFocus(); |
195 RestoreLastFocusedView(); | 195 RestoreLastFocusedView(); |
196 } | 196 } |
197 View::SetVisible(flag); | 197 View::SetVisible(flag); |
198 } | 198 } |
199 | 199 |
200 void AccessiblePaneView::GetAccessibleState(ui::AccessibleViewState* state) { | 200 void AccessiblePaneView::GetAccessibleState(ui::AccessibleViewState* state) { |
201 state->role = ui::AccessibilityTypes::ROLE_PANE; | 201 state->role = ui::AccessibilityTypes::ROLE_PANE; |
202 } | 202 } |
203 | 203 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 | 247 |
248 views::FocusTraversable* AccessiblePaneView::GetFocusTraversableParent() { | 248 views::FocusTraversable* AccessiblePaneView::GetFocusTraversableParent() { |
249 DCHECK(pane_has_focus_); | 249 DCHECK(pane_has_focus_); |
250 return NULL; | 250 return NULL; |
251 } | 251 } |
252 | 252 |
253 views::View* AccessiblePaneView::GetFocusTraversableParentView() { | 253 views::View* AccessiblePaneView::GetFocusTraversableParentView() { |
254 DCHECK(pane_has_focus_); | 254 DCHECK(pane_has_focus_); |
255 return NULL; | 255 return NULL; |
256 } | 256 } |
OLD | NEW |