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

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

Issue 198413003: Enable immersive fullscreen on Windows Ash. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix issues from previous review comment. Created 6 years, 9 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 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 895 matching lines...) Expand 10 before | Expand all | Expand 10 after
906 906
907 void BrowserView::Restore() { 907 void BrowserView::Restore() {
908 frame_->Restore(); 908 frame_->Restore();
909 } 909 }
910 910
911 void BrowserView::EnterFullscreen( 911 void BrowserView::EnterFullscreen(
912 const GURL& url, FullscreenExitBubbleType bubble_type) { 912 const GURL& url, FullscreenExitBubbleType bubble_type) {
913 if (IsFullscreen()) 913 if (IsFullscreen())
914 return; // Nothing to do. 914 return; // Nothing to do.
915 915
916 ProcessFullscreen(true, FOR_DESKTOP, url, bubble_type); 916 ProcessFullscreen(true, NORMAL_FULLSCREEN, url, bubble_type);
917 } 917 }
918 918
919 void BrowserView::ExitFullscreen() { 919 void BrowserView::ExitFullscreen() {
920 if (!IsFullscreen()) 920 if (!IsFullscreen())
921 return; // Nothing to do. 921 return; // Nothing to do.
922 922
923 ProcessFullscreen(false, FOR_DESKTOP, GURL(), FEB_TYPE_NONE); 923 ProcessFullscreen(false, NORMAL_FULLSCREEN, GURL(), FEB_TYPE_NONE);
924 } 924 }
925 925
926 void BrowserView::UpdateFullscreenExitBubbleContent( 926 void BrowserView::UpdateFullscreenExitBubbleContent(
927 const GURL& url, 927 const GURL& url,
928 FullscreenExitBubbleType bubble_type) { 928 FullscreenExitBubbleType bubble_type) {
929 // Immersive mode has no exit bubble because it has a visible strip at the 929 // Immersive mode has no exit bubble because it has a visible strip at the
930 // top that gives the user a hover target. 930 // top that gives the user a hover target.
931 // TODO(jamescook): Figure out what to do with mouse-lock. 931 // TODO(jamescook): Figure out what to do with mouse-lock.
932 if (bubble_type == FEB_TYPE_NONE || ShouldUseImmersiveFullscreenForUrl(url)) { 932 if (bubble_type == FEB_TYPE_NONE || ShouldUseImmersiveFullscreenForUrl(url)) {
933 fullscreen_bubble_.reset(); 933 fullscreen_bubble_.reset();
(...skipping 17 matching lines...) Expand all
951 return frame_->IsFullscreen(); 951 return frame_->IsFullscreen();
952 } 952 }
953 953
954 bool BrowserView::IsFullscreenBubbleVisible() const { 954 bool BrowserView::IsFullscreenBubbleVisible() const {
955 return fullscreen_bubble_ != NULL; 955 return fullscreen_bubble_ != NULL;
956 } 956 }
957 957
958 #if defined(OS_WIN) 958 #if defined(OS_WIN)
959 void BrowserView::SetMetroSnapMode(bool enable) { 959 void BrowserView::SetMetroSnapMode(bool enable) {
960 HISTOGRAM_COUNTS("Metro.SnapModeToggle", enable); 960 HISTOGRAM_COUNTS("Metro.SnapModeToggle", enable);
961 ProcessFullscreen(enable, FOR_METRO, GURL(), FEB_TYPE_NONE); 961 ProcessFullscreen(enable, METRO_SNAP_FULLSCREEN, GURL(), FEB_TYPE_NONE);
962 } 962 }
963 963
964 bool BrowserView::IsInMetroSnapMode() const { 964 bool BrowserView::IsInMetroSnapMode() const {
965 return false; 965 return false;
966 } 966 }
967 #endif // defined(OS_WIN) 967 #endif // defined(OS_WIN)
968 968
969 void BrowserView::RestoreFocus() { 969 void BrowserView::RestoreFocus() {
970 WebContents* selected_web_contents = GetActiveWebContents(); 970 WebContents* selected_web_contents = GetActiveWebContents();
971 if (selected_web_contents) 971 if (selected_web_contents)
972 selected_web_contents->GetView()->RestoreFocus(); 972 selected_web_contents->GetView()->RestoreFocus();
973 } 973 }
974 974
975 void BrowserView::SetWindowSwitcherButton(views::Button* button) { 975 void BrowserView::SetWindowSwitcherButton(views::Button* button) {
976 if (window_switcher_button_) 976 if (window_switcher_button_)
977 RemoveChildView(window_switcher_button_); 977 RemoveChildView(window_switcher_button_);
978 window_switcher_button_ = button; 978 window_switcher_button_ = button;
979 } 979 }
980 980
981 void BrowserView::FullscreenStateChanged() { 981 void BrowserView::FullscreenStateChanged() {
982 CHECK(!IsFullscreen()); 982 CHECK(!IsFullscreen());
983 ProcessFullscreen(false, FOR_DESKTOP, GURL(), FEB_TYPE_NONE); 983 ProcessFullscreen(false, NORMAL_FULLSCREEN, GURL(), FEB_TYPE_NONE);
984 } 984 }
985 985
986 void BrowserView::ToolbarSizeChanged(bool is_animating) { 986 void BrowserView::ToolbarSizeChanged(bool is_animating) {
987 // The call to InfoBarContainer::SetMaxTopArrowHeight() below can result in 987 // The call to InfoBarContainer::SetMaxTopArrowHeight() below can result in
988 // reentrancy; |call_state| tracks whether we're reentrant. We can't just 988 // reentrancy; |call_state| tracks whether we're reentrant. We can't just
989 // early-return in this case because we need to layout again so the infobar 989 // early-return in this case because we need to layout again so the infobar
990 // container's bounds are set correctly. 990 // container's bounds are set correctly.
991 static CallState call_state = NORMAL; 991 static CallState call_state = NORMAL;
992 992
993 // A reentrant call can (and should) use the fast resize path unless both it 993 // A reentrant call can (and should) use the fast resize path unless both it
(...skipping 1172 matching lines...) Expand 10 before | Expand all | Expand 10 after
2166 void BrowserView::UpdateUIForContents(WebContents* contents) { 2166 void BrowserView::UpdateUIForContents(WebContents* contents) {
2167 bool needs_layout = MaybeShowBookmarkBar(contents); 2167 bool needs_layout = MaybeShowBookmarkBar(contents);
2168 // TODO(jamescook): This function always returns true. Remove it and figure 2168 // TODO(jamescook): This function always returns true. Remove it and figure
2169 // out when layout is actually required. 2169 // out when layout is actually required.
2170 needs_layout |= MaybeShowInfoBar(contents); 2170 needs_layout |= MaybeShowInfoBar(contents);
2171 if (needs_layout) 2171 if (needs_layout)
2172 Layout(); 2172 Layout();
2173 } 2173 }
2174 2174
2175 void BrowserView::ProcessFullscreen(bool fullscreen, 2175 void BrowserView::ProcessFullscreen(bool fullscreen,
2176 FullscreenType type, 2176 FullscreenMode mode,
2177 const GURL& url, 2177 const GURL& url,
2178 FullscreenExitBubbleType bubble_type) { 2178 FullscreenExitBubbleType bubble_type) {
2179 if (in_process_fullscreen_) 2179 if (in_process_fullscreen_)
2180 return; 2180 return;
2181 in_process_fullscreen_ = true; 2181 in_process_fullscreen_ = true;
2182 2182
2183 // Reduce jankiness during the following position changes by: 2183 // Reduce jankiness during the following position changes by:
2184 // * Hiding the window until it's in the final position 2184 // * Hiding the window until it's in the final position
2185 // * Ignoring all intervening Layout() calls, which resize the webpage and 2185 // * Ignoring all intervening Layout() calls, which resize the webpage and
2186 // thus are slow and look ugly (enforced via |in_process_fullscreen_|). 2186 // thus are slow and look ugly (enforced via |in_process_fullscreen_|).
2187 LocationBarView* location_bar = GetLocationBarView(); 2187 LocationBarView* location_bar = GetLocationBarView();
2188 2188
2189 if (type == FOR_METRO || !fullscreen) { 2189 if (mode == METRO_SNAP_FULLSCREEN || !fullscreen) {
2190 // Hide the fullscreen bubble as soon as possible, since the mode toggle can 2190 // Hide the fullscreen bubble as soon as possible, since the mode toggle can
2191 // take enough time for the user to notice. 2191 // take enough time for the user to notice.
2192 fullscreen_bubble_.reset(); 2192 fullscreen_bubble_.reset();
2193 } 2193 }
2194 2194
2195 if (fullscreen) { 2195 if (fullscreen) {
2196 // Move focus out of the location bar if necessary. 2196 // Move focus out of the location bar if necessary.
2197 views::FocusManager* focus_manager = GetFocusManager(); 2197 views::FocusManager* focus_manager = GetFocusManager();
2198 DCHECK(focus_manager); 2198 DCHECK(focus_manager);
2199 // Look for focus in the location bar itself or any child view. 2199 // Look for focus in the location bar itself or any child view.
2200 if (location_bar->Contains(focus_manager->GetFocusedView())) 2200 if (location_bar->Contains(focus_manager->GetFocusedView()))
2201 focus_manager->ClearFocus(); 2201 focus_manager->ClearFocus();
2202 } 2202 }
2203 2203
2204 // Toggle fullscreen mode. 2204 // Toggle fullscreen mode.
2205 frame_->SetFullscreen(fullscreen); 2205 frame_->SetFullscreen(fullscreen);
2206 2206
2207 // Enable immersive before the browser refreshes its list of enabled commands. 2207 // Enable immersive before the browser refreshes its list of enabled commands.
2208 if (ShouldUseImmersiveFullscreenForUrl(url)) 2208 if (mode != METRO_SNAP_FULLSCREEN && ShouldUseImmersiveFullscreenForUrl(url))
2209 immersive_mode_controller_->SetEnabled(fullscreen); 2209 immersive_mode_controller_->SetEnabled(fullscreen);
2210 2210
2211 browser_->WindowFullscreenStateChanged(); 2211 browser_->WindowFullscreenStateChanged();
2212 2212
2213 if (fullscreen && !chrome::IsRunningInAppMode() && type != FOR_METRO) 2213 if (fullscreen && !chrome::IsRunningInAppMode() &&
2214 mode != METRO_SNAP_FULLSCREEN) {
2214 UpdateFullscreenExitBubbleContent(url, bubble_type); 2215 UpdateFullscreenExitBubbleContent(url, bubble_type);
2216 }
2215 2217
2216 // Undo our anti-jankiness hacks and force a re-layout. We also need to 2218 // Undo our anti-jankiness hacks and force a re-layout. We also need to
2217 // recompute the height of the infobar top arrow because toggling in and out 2219 // recompute the height of the infobar top arrow because toggling in and out
2218 // of fullscreen changes it. Calling ToolbarSizeChanged() will do both these 2220 // of fullscreen changes it. Calling ToolbarSizeChanged() will do both these
2219 // things since it computes the arrow height directly and forces a layout 2221 // things since it computes the arrow height directly and forces a layout
2220 // indirectly via UpdateUIForContents(). Reset |in_process_fullscreen_| in 2222 // indirectly via UpdateUIForContents(). Reset |in_process_fullscreen_| in
2221 // order to let the layout occur. 2223 // order to let the layout occur.
2222 in_process_fullscreen_ = false; 2224 in_process_fullscreen_ = false;
2223 ToolbarSizeChanged(false); 2225 ToolbarSizeChanged(false);
2224 } 2226 }
2225 2227
2226 bool BrowserView::ShouldUseImmersiveFullscreenForUrl(const GURL& url) const { 2228 bool BrowserView::ShouldUseImmersiveFullscreenForUrl(const GURL& url) const {
2227 #if defined(OS_CHROMEOS) 2229 // Kiosk mode needs the whole screen, and if we're not in an Ash desktop
2228 // Kiosk mode needs the whole screen. 2230 // immersive fullscreen doesn't exist.
2229 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode)) 2231 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode) ||
2232 browser()->host_desktop_type() != chrome::HOST_DESKTOP_TYPE_ASH) {
2230 return false; 2233 return false;
2231 bool is_browser_fullscreen = url.is_empty(); 2234 }
2232 return is_browser_fullscreen; 2235
2233 #else 2236 return url.is_empty();
2234 return false;
2235 #endif
2236 } 2237 }
2237 2238
2238 void BrowserView::LoadAccelerators() { 2239 void BrowserView::LoadAccelerators() {
2239 views::FocusManager* focus_manager = GetFocusManager(); 2240 views::FocusManager* focus_manager = GetFocusManager();
2240 DCHECK(focus_manager); 2241 DCHECK(focus_manager);
2241 2242
2242 // Let's fill our own accelerator table. 2243 // Let's fill our own accelerator table.
2243 const bool is_app_mode = chrome::IsRunningInForcedAppMode(); 2244 const bool is_app_mode = chrome::IsRunningInForcedAppMode();
2244 const std::vector<chrome::AcceleratorMapping> accelerator_list( 2245 const std::vector<chrome::AcceleratorMapping> accelerator_list(
2245 chrome::GetAcceleratorList()); 2246 chrome::GetAcceleratorList());
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
2558 !GetLocationBar()->GetOmniboxView()->model()->popup_model()->IsOpen()) { 2559 !GetLocationBar()->GetOmniboxView()->model()->popup_model()->IsOpen()) {
2559 gfx::Point icon_bottom( 2560 gfx::Point icon_bottom(
2560 toolbar_->location_bar()->GetLocationBarAnchorPoint()); 2561 toolbar_->location_bar()->GetLocationBarAnchorPoint());
2561 ConvertPointToTarget(toolbar_->location_bar(), this, &icon_bottom); 2562 ConvertPointToTarget(toolbar_->location_bar(), this, &icon_bottom);
2562 gfx::Point infobar_top(0, infobar_container_->GetVerticalOverlap(NULL)); 2563 gfx::Point infobar_top(0, infobar_container_->GetVerticalOverlap(NULL));
2563 ConvertPointToTarget(infobar_container_, this, &infobar_top); 2564 ConvertPointToTarget(infobar_container_, this, &infobar_top);
2564 top_arrow_height = infobar_top.y() - icon_bottom.y(); 2565 top_arrow_height = infobar_top.y() - icon_bottom.y();
2565 } 2566 }
2566 return top_arrow_height; 2567 return top_arrow_height;
2567 } 2568 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/frame/browser_view.h ('k') | chrome/browser/ui/views/frame/immersive_mode_controller_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698