| 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 "views/controls/button/menu_button.h" | 10 #include "views/controls/button/menu_button.h" | 
| (...skipping 30 matching lines...) Expand all  Loading... | 
| 41   // Save the storage id to the last focused view. This would be used to request | 41   // Save the storage id to the last focused view. This would be used to request | 
| 42   // focus to the view when the traversal is ended. | 42   // focus to the view when the traversal is ended. | 
| 43   last_focused_view_storage_id_ = view_storage_id; | 43   last_focused_view_storage_id_ = view_storage_id; | 
| 44 | 44 | 
| 45   if (!focus_manager_) | 45   if (!focus_manager_) | 
| 46     focus_manager_ = GetFocusManager(); | 46     focus_manager_ = GetFocusManager(); | 
| 47 | 47 | 
| 48   // Use the provided initial focus if it's visible and enabled, otherwise | 48   // Use the provided initial focus if it's visible and enabled, otherwise | 
| 49   // use the first focusable child. | 49   // use the first focusable child. | 
| 50   if (!initial_focus || | 50   if (!initial_focus || | 
| 51       !IsParentOf(initial_focus) || | 51       !Contains(initial_focus) || | 
| 52       !initial_focus->IsVisible() || | 52       !initial_focus->IsVisible() || | 
| 53       !initial_focus->IsEnabled()) { | 53       !initial_focus->IsEnabled()) { | 
| 54     initial_focus = GetFirstFocusableChild(); | 54     initial_focus = GetFirstFocusableChild(); | 
| 55   } | 55   } | 
| 56 | 56 | 
| 57   // Return false if there are no focusable children. | 57   // Return false if there are no focusable children. | 
| 58   if (!initial_focus) | 58   if (!initial_focus) | 
| 59     return false; | 59     return false; | 
| 60 | 60 | 
| 61   // Set focus to the initial view. If it's a location bar, use a special | 61   // Set focus to the initial view. If it's a location bar, use a special | 
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 209 | 209 | 
| 210   if (focused_now->GetClassName() == LocationBarView::kViewClassName && | 210   if (focused_now->GetClassName() == LocationBarView::kViewClassName && | 
| 211       reason == views::FocusManager::kReasonFocusTraversal) { | 211       reason == views::FocusManager::kReasonFocusTraversal) { | 
| 212     // Tabbing to the location bar should select all. Defer so that it happens | 212     // Tabbing to the location bar should select all. Defer so that it happens | 
| 213     // after the focus. | 213     // after the focus. | 
| 214     MessageLoop::current()->PostTask( | 214     MessageLoop::current()->PostTask( | 
| 215         FROM_HERE, method_factory_.NewRunnableMethod( | 215         FROM_HERE, method_factory_.NewRunnableMethod( | 
| 216             &AccessiblePaneView::LocationBarSelectAll)); | 216             &AccessiblePaneView::LocationBarSelectAll)); | 
| 217   } | 217   } | 
| 218 | 218 | 
| 219   if (!IsParentOf(focused_now) || | 219   if (!Contains(focused_now) || | 
| 220       reason == views::FocusManager::kReasonDirectFocusChange) { | 220       reason == views::FocusManager::kReasonDirectFocusChange) { | 
| 221     // We should remove pane focus (i.e. make most of the controls | 221     // We should remove pane focus (i.e. make most of the controls | 
| 222     // not focusable again) either because the focus is leaving the pane, | 222     // not focusable again) either because the focus is leaving the pane, | 
| 223     // or because the focus changed within the pane due to the user | 223     // or because the focus changed within the pane due to the user | 
| 224     // directly focusing to a specific view (e.g., clicking on it). | 224     // directly focusing to a specific view (e.g., clicking on it). | 
| 225     // | 225     // | 
| 226     // Defer rather than calling RemovePaneFocus right away, because we can't | 226     // Defer rather than calling RemovePaneFocus right away, because we can't | 
| 227     // remove |this| as a focus change listener while FocusManager is in the | 227     // remove |this| as a focus change listener while FocusManager is in the | 
| 228     // middle of iterating over the list of listeners. | 228     // middle of iterating over the list of listeners. | 
| 229     MessageLoop::current()->PostTask( | 229     MessageLoop::current()->PostTask( | 
| (...skipping 12 matching lines...) Expand all  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 | 
|---|