Index: chrome/browser/ui/views/frame/browser_view.cc |
diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc |
index 9f517bfc47420b2889dd38a097d416cc85965e5e..86419fc0e22b86411d7ca653dd9d231381d2327d 100644 |
--- a/chrome/browser/ui/views/frame/browser_view.cc |
+++ b/chrome/browser/ui/views/frame/browser_view.cc |
@@ -815,6 +815,67 @@ void BrowserView::FullScreenStateChanged() { |
} |
} |
+#if defined(OS_WIN) |
+void BrowserView::ToggleMetroSnapMode(bool enable) { |
+ // Reduce jankiness during the following position changes by: |
+ // * Hiding the window until it's in the final position |
+ // * Ignoring all intervening Layout() calls, which resize the webpage and |
+ // thus are slow and look ugly |
+ ignore_layout_ = true; |
+ LocationBarView* location_bar = GetLocationBarView(); |
+#if !defined(USE_AURA) |
+ OmniboxViewWin* omnibox_view = |
+ static_cast<OmniboxViewWin*>(location_bar->GetLocationEntry()); |
+ static_cast<views::NativeWidgetWin*>(frame_->native_widget())-> |
+ PushForceHidden(); |
+#endif |
+ |
+ if (enable) { |
+ // Move focus out of the location bar if necessary. |
+ views::FocusManager* focus_manager = GetFocusManager(); |
+ DCHECK(focus_manager); |
+ // Look for focus in the location bar itself or any child view. |
+ if (location_bar->Contains(focus_manager->GetFocusedView())) |
+ focus_manager->ClearFocus(); |
+ |
+#if !defined(USE_AURA) |
+ // If we don't hide the edit and force it to not show until we come out of |
+ // fullscreen, then if the user was on the New Tab Page, the edit contents |
+ // will appear atop the web contents once we go into fullscreen mode. This |
+ // has something to do with how we move the main window while it's hidden; |
+ // if we don't hide the main window below, we don't get this problem. |
+ omnibox_view->set_force_hidden(true); |
+ ShowWindow(omnibox_view->m_hWnd, SW_HIDE); |
+#endif |
+ } else { |
+#if !defined(USE_AURA) |
+ // Show the edit again since we're no longer in fullscreen mode. |
+ omnibox_view->set_force_hidden(false); |
+ ShowWindow(omnibox_view->m_hWnd, SW_SHOW); |
+#endif |
+ } |
+ |
+ // Enter metro snap mode. |
+ static_cast<views::NativeWidgetWin*>( |
+ frame_->native_widget())->SetMetroSnapFullscreen(enable); |
+ |
+ // Update various state as if we were in fullscreen mode. |
+ // TODO(robertshield): This may need to be modified for metro snap |
+ // mode - especially the command state changes. |
+ browser_->WindowFullscreenStateChanged(); |
+ |
+ // Undo our anti-jankiness hacks and force the window to re-layout now that |
+ // it's in its final position. |
+ ignore_layout_ = false; |
+ Layout(); |
+ |
+#if !defined(USE_AURA) |
+ static_cast<views::NativeWidgetWin*>( |
+ frame_->native_widget())->PopForceHidden(); |
+#endif |
+} |
+#endif // defined(OS_WIN) |
+ |
void BrowserView::RestoreFocus() { |
WebContents* selected_web_contents = GetSelectedWebContents(); |
if (selected_web_contents) |
@@ -2106,7 +2167,6 @@ void BrowserView::ProcessFullscreen(bool fullscreen, |
// Toggle fullscreen mode. |
frame_->SetFullscreen(fullscreen); |
- |
browser_->WindowFullscreenStateChanged(); |
if (fullscreen) { |