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

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

Issue 10446106: Preliminary metro snap plumbing. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix test errors, unify fullscreen code in browser view. Created 8 years, 6 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 (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 #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 751 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 762
763 void BrowserView::Restore() { 763 void BrowserView::Restore() {
764 frame_->Restore(); 764 frame_->Restore();
765 } 765 }
766 766
767 void BrowserView::EnterFullscreen( 767 void BrowserView::EnterFullscreen(
768 const GURL& url, FullscreenExitBubbleType bubble_type) { 768 const GURL& url, FullscreenExitBubbleType bubble_type) {
769 if (IsFullscreen()) 769 if (IsFullscreen())
770 return; // Nothing to do. 770 return; // Nothing to do.
771 771
772 ProcessFullscreen(true, url, bubble_type); 772 ProcessFullscreen(true, FOR_DESKTOP, url, bubble_type);
773 } 773 }
774 774
775 void BrowserView::ExitFullscreen() { 775 void BrowserView::ExitFullscreen() {
776 if (!IsFullscreen()) 776 if (!IsFullscreen())
777 return; // Nothing to do. 777 return; // Nothing to do.
778 778
779 ProcessFullscreen(false, GURL(), FEB_TYPE_NONE); 779 ProcessFullscreen(false, FOR_DESKTOP, GURL(), FEB_TYPE_NONE);
780 } 780 }
781 781
782 void BrowserView::UpdateFullscreenExitBubbleContent( 782 void BrowserView::UpdateFullscreenExitBubbleContent(
783 const GURL& url, 783 const GURL& url,
784 FullscreenExitBubbleType bubble_type) { 784 FullscreenExitBubbleType bubble_type) {
785 if (bubble_type == FEB_TYPE_NONE) { 785 if (bubble_type == FEB_TYPE_NONE) {
786 fullscreen_bubble_.reset(); 786 fullscreen_bubble_.reset();
787 } else if (fullscreen_bubble_.get()) { 787 } else if (fullscreen_bubble_.get()) {
788 fullscreen_bubble_->UpdateContent(url, bubble_type); 788 fullscreen_bubble_->UpdateContent(url, bubble_type);
789 } else { 789 } else {
790 fullscreen_bubble_.reset(new FullscreenExitBubbleViews( 790 fullscreen_bubble_.reset(new FullscreenExitBubbleViews(
791 GetWidget(), browser_.get(), url, bubble_type)); 791 GetWidget(), browser_.get(), url, bubble_type));
792 } 792 }
793 } 793 }
794 794
795 bool BrowserView::IsFullscreen() const { 795 bool BrowserView::IsFullscreen() const {
796 return frame_->IsFullscreen(); 796 return frame_->IsFullscreen();
797 } 797 }
798 798
799 bool BrowserView::IsFullscreenBubbleVisible() const { 799 bool BrowserView::IsFullscreenBubbleVisible() const {
800 return fullscreen_bubble_ != NULL; 800 return fullscreen_bubble_ != NULL;
801 } 801 }
802 802
803 void BrowserView::FullScreenStateChanged() { 803 void BrowserView::FullScreenStateChanged() {
804 if (IsFullscreen()) { 804 if (IsFullscreen()) {
805 if (fullscreen_request_.pending) { 805 if (fullscreen_request_.pending) {
806 fullscreen_request_.pending = false; 806 fullscreen_request_.pending = false;
807 ProcessFullscreen(true, fullscreen_request_.url, 807 ProcessFullscreen(true, FOR_DESKTOP,
808 fullscreen_request_.url,
808 fullscreen_request_.bubble_type); 809 fullscreen_request_.bubble_type);
809 } else { 810 } else {
810 ProcessFullscreen(true, GURL(), 811 ProcessFullscreen(true, FOR_DESKTOP, GURL(),
811 FEB_TYPE_BROWSER_FULLSCREEN_EXIT_INSTRUCTION); 812 FEB_TYPE_BROWSER_FULLSCREEN_EXIT_INSTRUCTION);
812 } 813 }
813 } else { 814 } else {
814 ProcessFullscreen(false, GURL(), FEB_TYPE_NONE); 815 ProcessFullscreen(false, FOR_DESKTOP, GURL(), FEB_TYPE_NONE);
815 } 816 }
816 } 817 }
817 818
819 #if defined(OS_WIN)
820 void BrowserView::ToggleMetroSnapMode(bool enable) {
821 ProcessFullscreen(enable, FOR_METRO, GURL(), FEB_TYPE_NONE);
822 }
823 #endif // defined(OS_WIN)
824
818 void BrowserView::RestoreFocus() { 825 void BrowserView::RestoreFocus() {
819 WebContents* selected_web_contents = GetSelectedWebContents(); 826 WebContents* selected_web_contents = GetSelectedWebContents();
820 if (selected_web_contents) 827 if (selected_web_contents)
821 selected_web_contents->GetView()->RestoreFocus(); 828 selected_web_contents->GetView()->RestoreFocus();
822 } 829 }
823 830
824 void BrowserView::SetWindowSwitcherButton(views::Button* button) { 831 void BrowserView::SetWindowSwitcherButton(views::Button* button) {
825 if (window_switcher_button_) 832 if (window_switcher_button_)
826 RemoveChildView(window_switcher_button_); 833 RemoveChildView(window_switcher_button_);
827 window_switcher_button_ = button; 834 window_switcher_button_ = button;
(...skipping 1230 matching lines...) Expand 10 before | Expand all | Expand 10 after
2058 DCHECK_EQ(0, new_height); 2065 DCHECK_EQ(0, new_height);
2059 // The heights are the same, but the old view is null. This only happens 2066 // The heights are the same, but the old view is null. This only happens
2060 // when the height is zero. Zero out the bounds. 2067 // when the height is zero. Zero out the bounds.
2061 new_view->SetBounds(0, 0, 0, 0); 2068 new_view->SetBounds(0, 0, 0, 0);
2062 } 2069 }
2063 *old_view = new_view; 2070 *old_view = new_view;
2064 return changed; 2071 return changed;
2065 } 2072 }
2066 2073
2067 void BrowserView::ProcessFullscreen(bool fullscreen, 2074 void BrowserView::ProcessFullscreen(bool fullscreen,
2075 ProcessFullscreenType type,
2068 const GURL& url, 2076 const GURL& url,
2069 FullscreenExitBubbleType bubble_type) { 2077 FullscreenExitBubbleType bubble_type) {
2070 // Reduce jankiness during the following position changes by: 2078 // Reduce jankiness during the following position changes by:
2071 // * Hiding the window until it's in the final position 2079 // * Hiding the window until it's in the final position
2072 // * Ignoring all intervening Layout() calls, which resize the webpage and 2080 // * Ignoring all intervening Layout() calls, which resize the webpage and
2073 // thus are slow and look ugly 2081 // thus are slow and look ugly
2074 ignore_layout_ = true; 2082 ignore_layout_ = true;
2075 LocationBarView* location_bar = GetLocationBarView(); 2083 LocationBarView* location_bar = GetLocationBarView();
2076 #if defined(OS_WIN) && !defined(USE_AURA) 2084 #if defined(OS_WIN) && !defined(USE_AURA)
2077 OmniboxViewWin* omnibox_view = 2085 OmniboxViewWin* omnibox_view =
2078 static_cast<OmniboxViewWin*>(location_bar->GetLocationEntry()); 2086 static_cast<OmniboxViewWin*>(location_bar->GetLocationEntry());
2079 #endif 2087 #endif
2080 if (!fullscreen) { 2088
2089 if (!fullscreen && type != FOR_METRO) {
2081 // Hide the fullscreen bubble as soon as possible, since the mode toggle can 2090 // Hide the fullscreen bubble as soon as possible, since the mode toggle can
2082 // take enough time for the user to notice. 2091 // take enough time for the user to notice.
2083 fullscreen_bubble_.reset(); 2092 fullscreen_bubble_.reset();
2084 } else { 2093 } else {
2085 // Move focus out of the location bar if necessary. 2094 // Move focus out of the location bar if necessary.
2086 views::FocusManager* focus_manager = GetFocusManager(); 2095 views::FocusManager* focus_manager = GetFocusManager();
2087 DCHECK(focus_manager); 2096 DCHECK(focus_manager);
2088 // Look for focus in the location bar itself or any child view. 2097 // Look for focus in the location bar itself or any child view.
2089 if (location_bar->Contains(focus_manager->GetFocusedView())) 2098 if (location_bar->Contains(focus_manager->GetFocusedView()))
2090 focus_manager->ClearFocus(); 2099 focus_manager->ClearFocus();
2091 2100
2092 #if defined(OS_WIN) && !defined(USE_AURA) 2101 #if defined(OS_WIN) && !defined(USE_AURA)
2093 // If we don't hide the edit and force it to not show until we come out of 2102 // If we don't hide the edit and force it to not show until we come out of
2094 // fullscreen, then if the user was on the New Tab Page, the edit contents 2103 // fullscreen, then if the user was on the New Tab Page, the edit contents
2095 // will appear atop the web contents once we go into fullscreen mode. This 2104 // will appear atop the web contents once we go into fullscreen mode. This
2096 // has something to do with how we move the main window while it's hidden; 2105 // has something to do with how we move the main window while it's hidden;
2097 // if we don't hide the main window below, we don't get this problem. 2106 // if we don't hide the main window below, we don't get this problem.
2098 omnibox_view->set_force_hidden(true); 2107 omnibox_view->set_force_hidden(true);
2099 ShowWindow(omnibox_view->m_hWnd, SW_HIDE); 2108 ShowWindow(omnibox_view->m_hWnd, SW_HIDE);
2100 #endif 2109 #endif
2101 } 2110 }
2102 #if defined(OS_WIN) && !defined(USE_AURA) 2111 #if defined(OS_WIN) && !defined(USE_AURA)
2103 static_cast<views::NativeWidgetWin*>(frame_->native_widget())-> 2112 static_cast<views::NativeWidgetWin*>(frame_->native_widget())->
2104 PushForceHidden(); 2113 PushForceHidden();
2105 #endif 2114 #endif
2106 2115
2107 // Toggle fullscreen mode. 2116 if (type == FOR_METRO) {
2108 frame_->SetFullscreen(fullscreen); 2117 #if defined(OS_WIN)
2109 2118 // Enter metro snap mode.
2110 browser_->WindowFullscreenStateChanged(); 2119 static_cast<views::NativeWidgetWin*>(
2120 frame_->native_widget())->SetMetroSnapFullscreen(fullscreen);
2121 #endif
2122 } else {
2123 // Toggle fullscreen mode.
2124 frame_->SetFullscreen(fullscreen);
2125 browser_->WindowFullscreenStateChanged();
2126 }
2111 2127
2112 if (fullscreen) { 2128 if (fullscreen) {
2113 bool is_kiosk = 2129 bool is_kiosk =
2114 CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode); 2130 CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode);
2115 if (!is_kiosk) { 2131 if (!is_kiosk && type != FOR_METRO) {
2116 fullscreen_bubble_.reset(new FullscreenExitBubbleViews( 2132 fullscreen_bubble_.reset(new FullscreenExitBubbleViews(
2117 GetWidget(), browser_.get(), url, bubble_type)); 2133 GetWidget(), browser_.get(), url, bubble_type));
2118 } 2134 }
2119 } else { 2135 } else {
2120 #if defined(OS_WIN) && !defined(USE_AURA) 2136 #if defined(OS_WIN) && !defined(USE_AURA)
2121 // Show the edit again since we're no longer in fullscreen mode. 2137 // Show the edit again since we're no longer in fullscreen mode.
2122 omnibox_view->set_force_hidden(false); 2138 omnibox_view->set_force_hidden(false);
2123 ShowWindow(omnibox_view->m_hWnd, SW_SHOW); 2139 ShowWindow(omnibox_view->m_hWnd, SW_SHOW);
2124 #endif 2140 #endif
2125 } 2141 }
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
2426 this, 2442 this,
2427 web_contents->GetRenderViewHost(), 2443 web_contents->GetRenderViewHost(),
2428 password_generator, 2444 password_generator,
2429 browser_.get(), 2445 browser_.get(),
2430 wrapper->password_manager()); 2446 wrapper->password_manager());
2431 2447
2432 views::BubbleDelegateView::CreateBubble(bubble); 2448 views::BubbleDelegateView::CreateBubble(bubble);
2433 bubble->SetAlignment(views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE); 2449 bubble->SetAlignment(views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE);
2434 bubble->Show(); 2450 bubble->Show();
2435 } 2451 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698