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

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: 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
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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 #include "ui/views/layout/grid_layout.h" 102 #include "ui/views/layout/grid_layout.h"
103 #include "ui/views/widget/native_widget.h" 103 #include "ui/views/widget/native_widget.h"
104 #include "ui/views/widget/root_view.h" 104 #include "ui/views/widget/root_view.h"
105 #include "ui/views/widget/widget.h" 105 #include "ui/views/widget/widget.h"
106 #include "ui/views/window/dialog_delegate.h" 106 #include "ui/views/window/dialog_delegate.h"
107 107
108 #if defined(USE_AURA) 108 #if defined(USE_AURA)
109 #include "ash/launcher/launcher.h" 109 #include "ash/launcher/launcher.h"
110 #include "ash/launcher/launcher_model.h" 110 #include "ash/launcher/launcher_model.h"
111 #include "ash/shell.h" 111 #include "ash/shell.h"
112 #include "chrome/browser/chromeos/status/status_area_view.h"
112 #include "chrome/browser/ui/views/accelerator_table.h" 113 #include "chrome/browser/ui/views/accelerator_table.h"
113 #include "chrome/browser/ui/views/aura/chrome_shell_delegate.h" 114 #include "chrome/browser/ui/views/aura/chrome_shell_delegate.h"
114 #include "chrome/browser/ui/views/aura/launcher_icon_updater.h" 115 #include "chrome/browser/ui/views/aura/launcher_icon_updater.h"
115 #include "ui/gfx/screen.h" 116 #include "ui/gfx/screen.h"
116 #elif defined(OS_WIN) 117 #elif defined(OS_WIN)
117 #include "chrome/browser/aeropeek_manager.h" 118 #include "chrome/browser/aeropeek_manager.h"
118 #include "chrome/browser/jumplist_win.h" 119 #include "chrome/browser/jumplist_win.h"
119 #include "ui/base/message_box_win.h" 120 #include "ui/base/message_box_win.h"
120 #include "ui/views/widget/native_widget_win.h" 121 #include "ui/views/widget/native_widget_win.h"
121 #elif defined(TOOLKIT_USES_GTK) 122 #elif defined(TOOLKIT_USES_GTK)
(...skipping 835 matching lines...) Expand 10 before | Expand all | Expand 10 after
957 // Get a vector of all panes in the order we want them to be focused, 958 // 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 959 // 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 960 // is currently invisible or has no focusable children it will be
960 // automatically skipped. 961 // automatically skipped.
961 std::vector<views::AccessiblePaneView*> accessible_panes; 962 std::vector<views::AccessiblePaneView*> accessible_panes;
962 GetAccessiblePanes(&accessible_panes); 963 GetAccessiblePanes(&accessible_panes);
963 int pane_count = static_cast<int>(accessible_panes.size()); 964 int pane_count = static_cast<int>(accessible_panes.size());
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());
968
967 accessible_views.push_back(GetTabContentsContainerView()); 969 accessible_views.push_back(GetTabContentsContainerView());
968 if (devtools_container_->visible()) 970 if (devtools_container_->visible())
969 accessible_views.push_back(devtools_container_->GetFocusView()); 971 accessible_views.push_back(devtools_container_->GetFocusView());
972
970 int count = static_cast<int>(accessible_views.size()); 973 int count = static_cast<int>(accessible_views.size());
971 974
972 // Figure out which view (if any) currently has the focus. 975 // Figure out which view (if any) currently has the focus.
973 const views::View* focused_view = GetFocusManager()->GetFocusedView(); 976 const views::View* focused_view = GetFocusManager()->GetFocusedView();
974 int index = -1; 977 int index = -1;
975 if (focused_view) { 978 if (focused_view) {
976 for (int i = 0; i < count; ++i) { 979 for (int i = 0; i < count; ++i) {
977 if (accessible_views[i] == focused_view || 980 if (accessible_views[i] == focused_view ||
978 accessible_views[i]->Contains(focused_view)) { 981 accessible_views[i]->Contains(focused_view)) {
979 index = i; 982 index = i;
980 break; 983 break;
981 } 984 }
982 } 985 }
983 } 986 }
984 987
985 // If the focus isn't currently in a pane, save the focus so we 988 // If the focus isn't currently in a pane, save the focus so we
986 // can restore it if the user presses Escape. 989 // can restore it if the user presses Escape.
987 if (focused_view && index >= pane_count) 990 if (focused_view && index >= pane_count)
988 GetFocusManager()->StoreFocusedView(); 991 GetFocusManager()->StoreFocusedView();
989 992
993 // Add the special panes to the rotation.
994 int normal_count = count;
995
996 #if defined(OS_CHROMEOS) && defined(USE_AURA)
997 int status_area_index = count;
998 ++count;
999
1000 int launcher_index = -1;
1001 if (!ash::Shell::GetInstance()->IsWindowModeCompact()) {
1002 // Add the launcher if not in compact mode.
1003 launcher_index = count;
1004 ++count;
1005 }
1006 #endif
1007
990 // Try to focus the next pane; if SetPaneFocusAndFocusDefault returns 1008 // Try to focus the next pane; if SetPaneFocusAndFocusDefault returns
991 // false it means the pane didn't have any focusable controls, so skip 1009 // false it means the pane didn't have any focusable controls, so skip
992 // it and try the next one. 1010 // it and try the next one.
993 for (;;) { 1011 for (;;) {
994 if (forwards) 1012 if (forwards)
995 index = (index + 1) % count; 1013 index = (index + 1) % count;
996 else 1014 else
997 index = ((index - 1) + count) % count; 1015 index = ((index - 1) + count) % count;
998 1016
999 if (index < pane_count) { 1017 if (index >= normal_count) {
1018 #if defined(OS_CHROMEOS) && defined(USE_AURA)
1019 if (index == status_area_index) {
1020 StatusAreaView* status_area =
1021 ChromeShellDelegate::instance()->GetStatusArea();
1022 if (status_area->SetPaneFocusAndFocusDefault()) {
1023 status_area->GetWidget()->Activate();
1024 break;
1025 }
1026 } else if (index == launcher_index) {
1027 if (ash::Shell::GetInstance()->launcher()->Activate()) {
1028 break;
1029 }
1030 }
1031 #endif
1032 } else if (index < pane_count) {
1000 if (accessible_panes[index]->SetPaneFocusAndFocusDefault()) 1033 if (accessible_panes[index]->SetPaneFocusAndFocusDefault())
1001 break; 1034 break;
1002 } else { 1035 } else {
1003 accessible_views[index]->RequestFocus(); 1036 accessible_views[index]->RequestFocus();
1004 break; 1037 break;
1005 } 1038 }
1006 } 1039 }
1007 } 1040 }
1008 1041
1009 void BrowserView::DestroyBrowser() { 1042 void BrowserView::DestroyBrowser() {
(...skipping 1549 matching lines...) Expand 10 before | Expand all | Expand 10 after
2559 browser::CreateViewsBubble(bubble); 2592 browser::CreateViewsBubble(bubble);
2560 bubble->SetAlignment(views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE); 2593 bubble->SetAlignment(views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE);
2561 bubble->Show(); 2594 bubble->Show();
2562 } 2595 }
2563 2596
2564 void BrowserView::ShowAvatarBubbleFromAvatarButton() { 2597 void BrowserView::ShowAvatarBubbleFromAvatarButton() {
2565 AvatarMenuButton* button = frame_->GetAvatarMenuButton(); 2598 AvatarMenuButton* button = frame_->GetAvatarMenuButton();
2566 if (button) 2599 if (button)
2567 button->ShowAvatarBubble(); 2600 button->ShowAvatarBubble();
2568 } 2601 }
OLDNEW
« ash/launcher/launcher.cc ('K') | « chrome/browser/ui/views/aura/chrome_shell_delegate.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698