OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/frame/browser_view.h" | 5 #include "chrome/browser/ui/views/frame/browser_view.h" |
6 | 6 |
7 #if defined(TOOLKIT_USES_GTK) | 7 #if defined(TOOLKIT_USES_GTK) |
8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
9 #endif | 9 #endif |
10 | 10 |
(...skipping 943 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
954 // shelf, etc. When a pane has focus, all of its controls are accessible | 954 // shelf, etc. When a pane has focus, all of its controls are accessible |
955 // in the tab traversal, and the tab traversal is "trapped" within that pane. | 955 // in the tab traversal, and the tab traversal is "trapped" within that pane. |
956 // | 956 // |
957 // Get a vector of all panes in the order we want them to be focused, | 957 // Get a vector of all panes in the order we want them to be focused, |
958 // with NULL to represent the tab contents getting focus. If one of these | 958 // with NULL to represent the tab contents getting focus. If one of these |
959 // is currently invisible or has no focusable children it will be | 959 // is currently invisible or has no focusable children it will be |
960 // automatically skipped. | 960 // automatically skipped. |
961 std::vector<views::AccessiblePaneView*> accessible_panes; | 961 std::vector<views::AccessiblePaneView*> accessible_panes; |
962 GetAccessiblePanes(&accessible_panes); | 962 GetAccessiblePanes(&accessible_panes); |
963 int pane_count = static_cast<int>(accessible_panes.size()); | 963 int pane_count = static_cast<int>(accessible_panes.size()); |
| 964 int special_index = -1; |
964 | 965 |
965 std::vector<views::View*> accessible_views( | 966 std::vector<views::View*> accessible_views( |
966 accessible_panes.begin(), accessible_panes.end()); | 967 accessible_panes.begin(), accessible_panes.end()); |
967 accessible_views.push_back(GetTabContentsContainerView()); | 968 accessible_views.push_back(GetTabContentsContainerView()); |
968 if (devtools_container_->visible()) | 969 if (devtools_container_->visible()) |
969 accessible_views.push_back(devtools_container_->GetFocusView()); | 970 accessible_views.push_back(devtools_container_->GetFocusView()); |
970 int count = static_cast<int>(accessible_views.size()); | 971 int count = static_cast<int>(accessible_views.size()); |
971 | 972 |
972 // Figure out which view (if any) currently has the focus. | 973 // Figure out which view (if any) currently has the focus. |
973 const views::View* focused_view = GetFocusManager()->GetFocusedView(); | 974 const views::View* focused_view = GetFocusManager()->GetFocusedView(); |
974 int index = -1; | 975 int index = -1; |
975 if (focused_view) { | 976 if (focused_view) { |
976 for (int i = 0; i < count; ++i) { | 977 for (int i = 0; i < count; ++i) { |
977 if (accessible_views[i] == focused_view || | 978 if (accessible_views[i] == focused_view || |
978 accessible_views[i]->Contains(focused_view)) { | 979 accessible_views[i]->Contains(focused_view)) { |
979 index = i; | 980 index = i; |
980 break; | 981 break; |
981 } | 982 } |
982 } | 983 } |
983 } | 984 } |
984 | 985 |
985 // If the focus isn't currently in a pane, save the focus so we | 986 // If the focus isn't currently in a pane, save the focus so we |
986 // can restore it if the user presses Escape. | 987 // can restore it if the user presses Escape. |
987 if (focused_view && index >= pane_count) | 988 if (focused_view && index >= pane_count) |
988 GetFocusManager()->StoreFocusedView(); | 989 GetFocusManager()->StoreFocusedView(); |
989 | 990 |
| 991 #if defined(OS_CHROMEOS) && defined(USE_AURA) |
| 992 // Add the special panes to the rotation. |
| 993 special_index = count; |
| 994 ++count; |
| 995 #endif |
| 996 |
990 // Try to focus the next pane; if SetPaneFocusAndFocusDefault returns | 997 // Try to focus the next pane; if SetPaneFocusAndFocusDefault returns |
991 // false it means the pane didn't have any focusable controls, so skip | 998 // false it means the pane didn't have any focusable controls, so skip |
992 // it and try the next one. | 999 // it and try the next one. |
993 for (;;) { | 1000 for (;;) { |
994 if (forwards) | 1001 if (forwards) |
995 index = (index + 1) % count; | 1002 index = (index + 1) % count; |
996 else | 1003 else |
997 index = ((index - 1) + count) % count; | 1004 index = ((index - 1) + count) % count; |
998 | 1005 |
999 if (index < pane_count) { | 1006 if (index == special_index) { |
| 1007 #if defined(OS_CHROMEOS) && defined(USE_AURA) |
| 1008 ash::Shell::GetInstance()->RotateFocus( |
| 1009 forwards ? ash::Shell::FORWARD : ash::Shell::BACKWARD); |
| 1010 break; |
| 1011 #endif |
| 1012 } else if (index < pane_count) { |
1000 if (accessible_panes[index]->SetPaneFocusAndFocusDefault()) | 1013 if (accessible_panes[index]->SetPaneFocusAndFocusDefault()) |
1001 break; | 1014 break; |
1002 } else { | 1015 } else { |
1003 accessible_views[index]->RequestFocus(); | 1016 accessible_views[index]->RequestFocus(); |
1004 break; | 1017 break; |
1005 } | 1018 } |
1006 } | 1019 } |
1007 } | 1020 } |
1008 | 1021 |
1009 void BrowserView::DestroyBrowser() { | 1022 void BrowserView::DestroyBrowser() { |
(...skipping 1545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2555 browser::CreateViewsBubble(bubble); | 2568 browser::CreateViewsBubble(bubble); |
2556 bubble->SetAlignment(views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE); | 2569 bubble->SetAlignment(views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE); |
2557 bubble->Show(); | 2570 bubble->Show(); |
2558 } | 2571 } |
2559 | 2572 |
2560 void BrowserView::ShowAvatarBubbleFromAvatarButton() { | 2573 void BrowserView::ShowAvatarBubbleFromAvatarButton() { |
2561 AvatarMenuButton* button = frame_->GetAvatarMenuButton(); | 2574 AvatarMenuButton* button = frame_->GetAvatarMenuButton(); |
2562 if (button) | 2575 if (button) |
2563 button->ShowAvatarBubble(); | 2576 button->ShowAvatarBubble(); |
2564 } | 2577 } |
OLD | NEW |