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

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: Aura compile fixes. 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
« no previous file with comments | « chrome/browser/ui/views/frame/browser_view.h ('k') | chrome/test/base/test_browser_window.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 752 matching lines...) Expand 10 before | Expand all | Expand 10 after
763 763
764 void BrowserView::Restore() { 764 void BrowserView::Restore() {
765 frame_->Restore(); 765 frame_->Restore();
766 } 766 }
767 767
768 void BrowserView::EnterFullscreen( 768 void BrowserView::EnterFullscreen(
769 const GURL& url, FullscreenExitBubbleType bubble_type) { 769 const GURL& url, FullscreenExitBubbleType bubble_type) {
770 if (IsFullscreen()) 770 if (IsFullscreen())
771 return; // Nothing to do. 771 return; // Nothing to do.
772 772
773 ProcessFullscreen(true, url, bubble_type); 773 ProcessFullscreen(true, FOR_DESKTOP, url, bubble_type);
774 } 774 }
775 775
776 void BrowserView::ExitFullscreen() { 776 void BrowserView::ExitFullscreen() {
777 if (!IsFullscreen()) 777 if (!IsFullscreen())
778 return; // Nothing to do. 778 return; // Nothing to do.
779 779
780 ProcessFullscreen(false, GURL(), FEB_TYPE_NONE); 780 ProcessFullscreen(false, FOR_DESKTOP, GURL(), FEB_TYPE_NONE);
781 } 781 }
782 782
783 void BrowserView::UpdateFullscreenExitBubbleContent( 783 void BrowserView::UpdateFullscreenExitBubbleContent(
784 const GURL& url, 784 const GURL& url,
785 FullscreenExitBubbleType bubble_type) { 785 FullscreenExitBubbleType bubble_type) {
786 if (bubble_type == FEB_TYPE_NONE) { 786 if (bubble_type == FEB_TYPE_NONE) {
787 fullscreen_bubble_.reset(); 787 fullscreen_bubble_.reset();
788 } else if (fullscreen_bubble_.get()) { 788 } else if (fullscreen_bubble_.get()) {
789 fullscreen_bubble_->UpdateContent(url, bubble_type); 789 fullscreen_bubble_->UpdateContent(url, bubble_type);
790 } else { 790 } else {
791 fullscreen_bubble_.reset(new FullscreenExitBubbleViews( 791 fullscreen_bubble_.reset(new FullscreenExitBubbleViews(
792 GetWidget(), browser_.get(), url, bubble_type)); 792 GetWidget(), browser_.get(), url, bubble_type));
793 } 793 }
794 } 794 }
795 795
796 bool BrowserView::IsFullscreen() const { 796 bool BrowserView::IsFullscreen() const {
797 return frame_->IsFullscreen(); 797 return frame_->IsFullscreen();
798 } 798 }
799 799
800 bool BrowserView::IsFullscreenBubbleVisible() const { 800 bool BrowserView::IsFullscreenBubbleVisible() const {
801 return fullscreen_bubble_ != NULL; 801 return fullscreen_bubble_ != NULL;
802 } 802 }
803 803
804 void BrowserView::FullScreenStateChanged() { 804 void BrowserView::FullScreenStateChanged() {
805 if (IsFullscreen()) { 805 if (IsFullscreen()) {
806 if (fullscreen_request_.pending) { 806 if (fullscreen_request_.pending) {
807 fullscreen_request_.pending = false; 807 fullscreen_request_.pending = false;
808 ProcessFullscreen(true, fullscreen_request_.url, 808 ProcessFullscreen(true, FOR_DESKTOP,
809 fullscreen_request_.url,
809 fullscreen_request_.bubble_type); 810 fullscreen_request_.bubble_type);
810 } else { 811 } else {
811 ProcessFullscreen(true, GURL(), 812 ProcessFullscreen(true, FOR_DESKTOP, GURL(),
812 FEB_TYPE_BROWSER_FULLSCREEN_EXIT_INSTRUCTION); 813 FEB_TYPE_BROWSER_FULLSCREEN_EXIT_INSTRUCTION);
813 } 814 }
814 } else { 815 } else {
815 ProcessFullscreen(false, GURL(), FEB_TYPE_NONE); 816 ProcessFullscreen(false, FOR_DESKTOP, GURL(), FEB_TYPE_NONE);
816 } 817 }
817 } 818 }
818 819
820 #if defined(OS_WIN)
821 void BrowserView::SetMetroSnapMode(bool enable) {
822 ProcessFullscreen(enable, FOR_METRO, GURL(), FEB_TYPE_NONE);
823 }
824
825 bool BrowserView::IsInMetroSnapMode() const {
826 #if defined(USE_AURA)
827 return false;
828 #else
829 return static_cast<views::NativeWidgetWin*>(
830 frame_->native_widget())->IsInMetroSnapMode();
831 #endif
832 }
833 #endif // defined(OS_WIN)
834
819 void BrowserView::RestoreFocus() { 835 void BrowserView::RestoreFocus() {
820 WebContents* selected_web_contents = GetActiveWebContents(); 836 WebContents* selected_web_contents = GetActiveWebContents();
821 if (selected_web_contents) 837 if (selected_web_contents)
822 selected_web_contents->GetView()->RestoreFocus(); 838 selected_web_contents->GetView()->RestoreFocus();
823 } 839 }
824 840
825 void BrowserView::SetWindowSwitcherButton(views::Button* button) { 841 void BrowserView::SetWindowSwitcherButton(views::Button* button) {
826 if (window_switcher_button_) 842 if (window_switcher_button_)
827 RemoveChildView(window_switcher_button_); 843 RemoveChildView(window_switcher_button_);
828 window_switcher_button_ = button; 844 window_switcher_button_ = button;
(...skipping 1250 matching lines...) Expand 10 before | Expand all | Expand 10 after
2079 DCHECK_EQ(0, new_height); 2095 DCHECK_EQ(0, new_height);
2080 // The heights are the same, but the old view is null. This only happens 2096 // The heights are the same, but the old view is null. This only happens
2081 // when the height is zero. Zero out the bounds. 2097 // when the height is zero. Zero out the bounds.
2082 new_view->SetBounds(0, 0, 0, 0); 2098 new_view->SetBounds(0, 0, 0, 0);
2083 } 2099 }
2084 *old_view = new_view; 2100 *old_view = new_view;
2085 return changed; 2101 return changed;
2086 } 2102 }
2087 2103
2088 void BrowserView::ProcessFullscreen(bool fullscreen, 2104 void BrowserView::ProcessFullscreen(bool fullscreen,
2105 FullscreenType type,
2089 const GURL& url, 2106 const GURL& url,
2090 FullscreenExitBubbleType bubble_type) { 2107 FullscreenExitBubbleType bubble_type) {
2091 // Reduce jankiness during the following position changes by: 2108 // Reduce jankiness during the following position changes by:
2092 // * Hiding the window until it's in the final position 2109 // * Hiding the window until it's in the final position
2093 // * Ignoring all intervening Layout() calls, which resize the webpage and 2110 // * Ignoring all intervening Layout() calls, which resize the webpage and
2094 // thus are slow and look ugly 2111 // thus are slow and look ugly
2095 ignore_layout_ = true; 2112 ignore_layout_ = true;
2096 LocationBarView* location_bar = GetLocationBarView(); 2113 LocationBarView* location_bar = GetLocationBarView();
2097 #if defined(OS_WIN) && !defined(USE_AURA) 2114 #if defined(OS_WIN) && !defined(USE_AURA)
2098 OmniboxViewWin* omnibox_view = 2115 OmniboxViewWin* omnibox_view =
2099 static_cast<OmniboxViewWin*>(location_bar->GetLocationEntry()); 2116 static_cast<OmniboxViewWin*>(location_bar->GetLocationEntry());
2100 #endif 2117 #endif
2101 if (!fullscreen) { 2118
2119 if (!fullscreen && type != FOR_METRO) {
2102 // Hide the fullscreen bubble as soon as possible, since the mode toggle can 2120 // Hide the fullscreen bubble as soon as possible, since the mode toggle can
2103 // take enough time for the user to notice. 2121 // take enough time for the user to notice.
2104 fullscreen_bubble_.reset(); 2122 fullscreen_bubble_.reset();
2105 } else { 2123 } else {
2106 // Move focus out of the location bar if necessary. 2124 // Move focus out of the location bar if necessary.
2107 views::FocusManager* focus_manager = GetFocusManager(); 2125 views::FocusManager* focus_manager = GetFocusManager();
2108 DCHECK(focus_manager); 2126 DCHECK(focus_manager);
2109 // Look for focus in the location bar itself or any child view. 2127 // Look for focus in the location bar itself or any child view.
2110 if (location_bar->Contains(focus_manager->GetFocusedView())) 2128 if (location_bar->Contains(focus_manager->GetFocusedView()))
2111 focus_manager->ClearFocus(); 2129 focus_manager->ClearFocus();
2112 2130
2113 #if defined(OS_WIN) && !defined(USE_AURA) 2131 #if defined(OS_WIN) && !defined(USE_AURA)
2114 // If we don't hide the edit and force it to not show until we come out of 2132 // If we don't hide the edit and force it to not show until we come out of
2115 // fullscreen, then if the user was on the New Tab Page, the edit contents 2133 // fullscreen, then if the user was on the New Tab Page, the edit contents
2116 // will appear atop the web contents once we go into fullscreen mode. This 2134 // will appear atop the web contents once we go into fullscreen mode. This
2117 // has something to do with how we move the main window while it's hidden; 2135 // has something to do with how we move the main window while it's hidden;
2118 // if we don't hide the main window below, we don't get this problem. 2136 // if we don't hide the main window below, we don't get this problem.
2119 omnibox_view->set_force_hidden(true); 2137 omnibox_view->set_force_hidden(true);
2120 ShowWindow(omnibox_view->m_hWnd, SW_HIDE); 2138 ShowWindow(omnibox_view->m_hWnd, SW_HIDE);
2121 #endif 2139 #endif
2122 } 2140 }
2123 #if defined(OS_WIN) && !defined(USE_AURA) 2141 #if defined(OS_WIN) && !defined(USE_AURA)
2124 static_cast<views::NativeWidgetWin*>(frame_->native_widget())-> 2142 static_cast<views::NativeWidgetWin*>(frame_->native_widget())->
2125 PushForceHidden(); 2143 PushForceHidden();
2126 #endif 2144 #endif
2127 2145
2128 // Toggle fullscreen mode. 2146 if (type == FOR_METRO) {
2129 frame_->SetFullscreen(fullscreen); 2147 #if defined(OS_WIN) && !defined(USE_AURA)
2148 // Enter metro snap mode.
2149 static_cast<views::NativeWidgetWin*>(
2150 frame_->native_widget())->SetMetroSnapFullscreen(fullscreen);
2151 #endif
2152 } else {
2153 // Toggle fullscreen mode.
2154 frame_->SetFullscreen(fullscreen);
2155 }
2130 2156
2131 browser_->WindowFullscreenStateChanged(); 2157 browser_->WindowFullscreenStateChanged();
2132 2158
2133 if (fullscreen) { 2159 if (fullscreen) {
2134 bool is_kiosk = 2160 bool is_kiosk =
2135 CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode); 2161 CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode);
2136 if (!is_kiosk) { 2162 if (!is_kiosk && type != FOR_METRO) {
2137 fullscreen_bubble_.reset(new FullscreenExitBubbleViews( 2163 fullscreen_bubble_.reset(new FullscreenExitBubbleViews(
2138 GetWidget(), browser_.get(), url, bubble_type)); 2164 GetWidget(), browser_.get(), url, bubble_type));
2139 } 2165 }
2140 } else { 2166 } else {
2141 #if defined(OS_WIN) && !defined(USE_AURA) 2167 #if defined(OS_WIN) && !defined(USE_AURA)
2142 // Show the edit again since we're no longer in fullscreen mode. 2168 // Show the edit again since we're no longer in fullscreen mode.
2143 omnibox_view->set_force_hidden(false); 2169 omnibox_view->set_force_hidden(false);
2144 ShowWindow(omnibox_view->m_hWnd, SW_SHOW); 2170 ShowWindow(omnibox_view->m_hWnd, SW_SHOW);
2145 #endif 2171 #endif
2146 } 2172 }
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
2447 this, 2473 this,
2448 tab_contents->web_contents()->GetRenderViewHost(), 2474 tab_contents->web_contents()->GetRenderViewHost(),
2449 password_generator, 2475 password_generator,
2450 browser_.get(), 2476 browser_.get(),
2451 tab_contents->password_manager()); 2477 tab_contents->password_manager());
2452 2478
2453 views::BubbleDelegateView::CreateBubble(bubble); 2479 views::BubbleDelegateView::CreateBubble(bubble);
2454 bubble->SetAlignment(views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE); 2480 bubble->SetAlignment(views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE);
2455 bubble->Show(); 2481 bubble->Show();
2456 } 2482 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/frame/browser_view.h ('k') | chrome/test/base/test_browser_window.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698