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

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

Issue 14080005: Remove ImmersiveModeController::MaybeStartReveal() / ImmersiveModeController::CancelReveal() (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebased Created 7 years, 8 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 980 matching lines...) Expand 10 before | Expand all | Expand 10 after
991 void BrowserView::SetFocusToLocationBar(bool select_all) { 991 void BrowserView::SetFocusToLocationBar(bool select_all) {
992 // On Windows, changing focus to the location bar causes the browser 992 // On Windows, changing focus to the location bar causes the browser
993 // window to become active. This can steal focus if the user has 993 // window to become active. This can steal focus if the user has
994 // another window open already. On ChromeOS, changing focus makes a 994 // another window open already. On ChromeOS, changing focus makes a
995 // view believe it has a focus even if the widget doens't have a 995 // view believe it has a focus even if the widget doens't have a
996 // focus. Either cases, we need to ignore this when the browser 996 // focus. Either cases, we need to ignore this when the browser
997 // window isn't active. 997 // window isn't active.
998 if (!force_location_bar_focus_ && !IsActive()) 998 if (!force_location_bar_focus_ && !IsActive())
999 return; 999 return;
1000 1000
1001 // The location bar view must be visible for it to be considered focusable, 1001 // Temporarily reveal the top-of-window views (if not already revealed) so
1002 // so always reveal it before testing for focusable. 1002 // that the location bar view is visible and is considered focusable. If the
1003 immersive_mode_controller_->MaybeStartReveal(); 1003 // location bar view gains focus, |immersive_mode_controller_| will keep the
1004 // top-of-window views revealed.
1005 scoped_ptr<ImmersiveModeController::RevealedLock> focus_reveal_lock(
1006 immersive_mode_controller_->GetRevealedLock());
1004 1007
1005 LocationBarView* location_bar = GetLocationBarView(); 1008 LocationBarView* location_bar = GetLocationBarView();
1006 if (location_bar->IsLocationEntryFocusableInRootView()) { 1009 if (location_bar->IsLocationEntryFocusableInRootView()) {
1007 // Location bar got focus. 1010 // Location bar got focus.
1008 location_bar->FocusLocation(select_all); 1011 location_bar->FocusLocation(select_all);
1009 } else { 1012 } else {
1010 // If none of location bar got focus, 1013 // If none of location bar got focus,
1011 // then clear focus. 1014 // then clear focus.
1012 views::FocusManager* focus_manager = GetFocusManager(); 1015 views::FocusManager* focus_manager = GetFocusManager();
1013 DCHECK(focus_manager); 1016 DCHECK(focus_manager);
1014 focus_manager->ClearFocus(); 1017 focus_manager->ClearFocus();
1015 // The view doesn't need to be revealed after all.
1016 immersive_mode_controller_->CancelReveal();
1017 } 1018 }
1018 } 1019 }
1019 1020
1020 void BrowserView::UpdateReloadStopState(bool is_loading, bool force) { 1021 void BrowserView::UpdateReloadStopState(bool is_loading, bool force) {
1021 toolbar_->reload_button()->ChangeMode( 1022 toolbar_->reload_button()->ChangeMode(
1022 is_loading ? ReloadButton::MODE_STOP : ReloadButton::MODE_RELOAD, force); 1023 is_loading ? ReloadButton::MODE_STOP : ReloadButton::MODE_RELOAD, force);
1023 } 1024 }
1024 1025
1025 void BrowserView::UpdateToolbar(content::WebContents* contents, 1026 void BrowserView::UpdateToolbar(content::WebContents* contents,
1026 bool should_restore_state) { 1027 bool should_restore_state) {
1027 toolbar_->Update(contents, should_restore_state); 1028 toolbar_->Update(contents, should_restore_state);
1028 } 1029 }
1029 1030
1030 void BrowserView::FocusToolbar() { 1031 void BrowserView::FocusToolbar() {
1031 immersive_mode_controller_->MaybeStartReveal(); 1032 // Temporarily reveal the top-of-window views (if not already revealed) so
1033 // that the toolbar is visible and is considered focusable. If the
1034 // toolbar gains focus, |immersive_mode_controller_| will keep the
1035 // top-of-window views revealed.
1036 scoped_ptr<ImmersiveModeController::RevealedLock> focus_reveal_lock(
1037 immersive_mode_controller_->GetRevealedLock());
1038
1032 // Start the traversal within the main toolbar. SetPaneFocus stores 1039 // Start the traversal within the main toolbar. SetPaneFocus stores
1033 // the current focused view before changing focus. 1040 // the current focused view before changing focus.
1034 toolbar_->SetPaneFocus(NULL); 1041 toolbar_->SetPaneFocus(NULL);
1035 } 1042 }
1036 1043
1037 void BrowserView::FocusBookmarksToolbar() { 1044 void BrowserView::FocusBookmarksToolbar() {
1038 // Don't use IsBookmarkBarVisible() because that might return false in 1045 DCHECK(!immersive_mode_controller_->IsEnabled());
1039 // immersive fullscreen and shifting focus should cause a reveal.
1040 if (bookmark_bar_view_.get() && 1046 if (bookmark_bar_view_.get() &&
1041 bookmark_bar_view_->visible() && 1047 bookmark_bar_view_->visible() &&
1042 bookmark_bar_view_->GetPreferredSize().height() != 0) { 1048 bookmark_bar_view_->GetPreferredSize().height() != 0) {
1043 immersive_mode_controller_->MaybeStartReveal();
1044 bookmark_bar_view_->SetPaneFocus(bookmark_bar_view_.get()); 1049 bookmark_bar_view_->SetPaneFocus(bookmark_bar_view_.get());
1045 } 1050 }
1046 } 1051 }
1047 1052
1048 void BrowserView::FocusAppMenu() { 1053 void BrowserView::FocusAppMenu() {
1049 // Chrome doesn't have a traditional menu bar, but it has a menu button in the 1054 // Chrome doesn't have a traditional menu bar, but it has a menu button in the
1050 // main toolbar that plays the same role. If the user presses a key that 1055 // main toolbar that plays the same role. If the user presses a key that
1051 // would typically focus the menu bar, tell the toolbar to focus the menu 1056 // would typically focus the menu bar, tell the toolbar to focus the menu
1052 // button. If the user presses the key again, return focus to the previous 1057 // button. If the user presses the key again, return focus to the previous
1053 // location. 1058 // location.
1054 // 1059 //
1055 // Not used on the Mac, which has a normal menu bar. 1060 // Not used on the Mac, which has a normal menu bar.
1056 if (toolbar_->IsAppMenuFocused()) { 1061 if (toolbar_->IsAppMenuFocused()) {
1057 RestoreFocus(); 1062 RestoreFocus();
1058 } else { 1063 } else {
1059 immersive_mode_controller_->MaybeStartReveal(); 1064 DCHECK(!immersive_mode_controller_->IsEnabled());
1060 toolbar_->SetPaneFocusAndFocusAppMenu(); 1065 toolbar_->SetPaneFocusAndFocusAppMenu();
1061 } 1066 }
1062 } 1067 }
1063 1068
1064 void BrowserView::RotatePaneFocus(bool forwards) { 1069 void BrowserView::RotatePaneFocus(bool forwards) {
1065 // This gets called when the user presses F6 (forwards) or Shift+F6 1070 // This gets called when the user presses F6 (forwards) or Shift+F6
1066 // (backwards) to rotate to the next pane. Here, our "panes" are the 1071 // (backwards) to rotate to the next pane. Here, our "panes" are the
1067 // tab contents and each of our accessible toolbars, infobars, downloads 1072 // tab contents and each of our accessible toolbars, infobars, downloads
1068 // shelf, etc. When a pane has focus, all of its controls are accessible 1073 // shelf, etc. When a pane has focus, all of its controls are accessible
1069 // in the tab traversal, and the tab traversal is "trapped" within that pane. 1074 // in the tab traversal, and the tab traversal is "trapped" within that pane.
(...skipping 1648 matching lines...) Expand 10 before | Expand all | Expand 10 after
2718 2723
2719 Browser* modal_browser = 2724 Browser* modal_browser =
2720 chrome::FindBrowserWithWebContents(active_dialog->web_contents()); 2725 chrome::FindBrowserWithWebContents(active_dialog->web_contents());
2721 if (modal_browser && (browser_ != modal_browser)) { 2726 if (modal_browser && (browser_ != modal_browser)) {
2722 modal_browser->window()->FlashFrame(true); 2727 modal_browser->window()->FlashFrame(true);
2723 modal_browser->window()->Activate(); 2728 modal_browser->window()->Activate();
2724 } 2729 }
2725 2730
2726 AppModalDialogQueue::GetInstance()->ActivateModalDialog(); 2731 AppModalDialogQueue::GetInstance()->ActivateModalDialog();
2727 } 2732 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698