Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(512)

Side by Side Diff: chrome/browser/ui/views/frame/browser_view.cc

Issue 9295049: Allow focus to be sent between browser window and launcher/status window (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix special index Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« ash/focus_cycler.cc ('K') | « ash/shell.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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(forwards);
1009 break;
1010 #endif
1011 } else if (index < pane_count) {
1000 if (accessible_panes[index]->SetPaneFocusAndFocusDefault()) 1012 if (accessible_panes[index]->SetPaneFocusAndFocusDefault())
1001 break; 1013 break;
1002 } else { 1014 } else {
1003 accessible_views[index]->RequestFocus(); 1015 accessible_views[index]->RequestFocus();
1004 break; 1016 break;
1005 } 1017 }
1006 } 1018 }
1007 } 1019 }
1008 1020
1009 void BrowserView::DestroyBrowser() { 1021 void BrowserView::DestroyBrowser() {
(...skipping 1549 matching lines...) Expand 10 before | Expand all | Expand 10 after
2559 browser::CreateViewsBubble(bubble); 2571 browser::CreateViewsBubble(bubble);
2560 bubble->SetAlignment(views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE); 2572 bubble->SetAlignment(views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE);
2561 bubble->Show(); 2573 bubble->Show();
2562 } 2574 }
2563 2575
2564 void BrowserView::ShowAvatarBubbleFromAvatarButton() { 2576 void BrowserView::ShowAvatarBubbleFromAvatarButton() {
2565 AvatarMenuButton* button = frame_->GetAvatarMenuButton(); 2577 AvatarMenuButton* button = frame_->GetAvatarMenuButton();
2566 if (button) 2578 if (button)
2567 button->ShowAvatarBubble(); 2579 button->ShowAvatarBubble();
2568 } 2580 }
OLDNEW
« ash/focus_cycler.cc ('K') | « ash/shell.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698