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

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

Issue 542001: Fixes two fullscreen bugs on views/gtk:... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years, 11 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
« no previous file with comments | « chrome/browser/views/frame/browser_view.h ('k') | no next file » | 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/views/frame/browser_view.h" 5 #include "chrome/browser/views/frame/browser_view.h"
6 6
7 #if defined(OS_LINUX) 7 #if defined(OS_LINUX)
8 #include <gtk/gtk.h> 8 #include <gtk/gtk.h>
9 #endif 9 #endif
10 10
(...skipping 845 matching lines...) Expand 10 before | Expand all | Expand 10 after
856 } 856 }
857 857
858 bool BrowserView::IsMaximized() const { 858 bool BrowserView::IsMaximized() const {
859 return frame_->GetWindow()->IsMaximized(); 859 return frame_->GetWindow()->IsMaximized();
860 } 860 }
861 861
862 void BrowserView::SetFullscreen(bool fullscreen) { 862 void BrowserView::SetFullscreen(bool fullscreen) {
863 if (IsFullscreen() == fullscreen) 863 if (IsFullscreen() == fullscreen)
864 return; // Nothing to do. 864 return; // Nothing to do.
865 865
866 // Reduce jankiness during the following position changes by:
867 // * Hiding the window until it's in the final position
868 // * Ignoring all intervening Layout() calls, which resize the webpage and
869 // thus are slow and look ugly
870 ignore_layout_ = true;
871 LocationBarView* location_bar = toolbar_->location_bar();
872 #if defined(OS_WIN) 866 #if defined(OS_WIN)
873 AutocompleteEditViewWin* edit_view = 867 ProcessFullscreen(fullscreen);
874 static_cast<AutocompleteEditViewWin*>(location_bar->location_entry()); 868 #else
875 #endif 869 // On Linux changing fullscreen is async. Ask the window to change it's
876 if (IsFullscreen()) { 870 // fullscreen state, and when done invoke ProcessFullscreen.
877 // Hide the fullscreen bubble as soon as possible, since the mode toggle can
878 // take enough time for the user to notice.
879 fullscreen_bubble_.reset();
880 } else {
881 // Move focus out of the location bar if necessary.
882 views::FocusManager* focus_manager = GetFocusManager();
883 DCHECK(focus_manager);
884 if (focus_manager->GetFocusedView() == location_bar)
885 focus_manager->ClearFocus();
886
887 #if defined(OS_WIN)
888 // If we don't hide the edit and force it to not show until we come out of
889 // fullscreen, then if the user was on the New Tab Page, the edit contents
890 // will appear atop the web contents once we go into fullscreen mode. This
891 // has something to do with how we move the main window while it's hidden;
892 // if we don't hide the main window below, we don't get this problem.
893 edit_view->set_force_hidden(true);
894 ShowWindow(edit_view->m_hWnd, SW_HIDE);
895 #endif
896 }
897 #if defined(OS_WIN)
898 frame_->GetWindow()->PushForceHidden();
899 #endif
900
901 // Notify bookmark bar, so it can set itself to the appropriate drawing state.
902 if (bookmark_bar_view_.get())
903 bookmark_bar_view_->OnFullscreenToggled(fullscreen);
904
905 // Notify extension shelf, so it can set itself to the appropriate drawing
906 // state.
907 if (extension_shelf_)
908 extension_shelf_->OnFullscreenToggled(fullscreen);
909
910 // Toggle fullscreen mode.
911 frame_->GetWindow()->SetFullscreen(fullscreen); 871 frame_->GetWindow()->SetFullscreen(fullscreen);
912
913 if (fullscreen) {
914 #if !defined(OS_MACOSX)
915 bool is_kiosk =
916 CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode);
917 #else
918 bool is_kiosk = false;
919 #endif
920 if (!is_kiosk) {
921 fullscreen_bubble_.reset(new FullscreenExitBubble(GetWidget(),
922 browser_.get()));
923 }
924 } else {
925 #if defined(OS_WIN)
926 // Show the edit again since we're no longer in fullscreen mode.
927 edit_view->set_force_hidden(false);
928 ShowWindow(edit_view->m_hWnd, SW_SHOW);
929 #endif
930 }
931
932 // Undo our anti-jankiness hacks and force the window to relayout now that
933 // it's in its final position.
934 ignore_layout_ = false;
935 Layout();
936 #if defined(OS_WIN)
937 frame_->GetWindow()->PopForceHidden();
938 #endif 872 #endif
939 } 873 }
940 874
941 bool BrowserView::IsFullscreen() const { 875 bool BrowserView::IsFullscreen() const {
942 return frame_->GetWindow()->IsFullscreen(); 876 return frame_->GetWindow()->IsFullscreen();
943 } 877 }
944 878
945 bool BrowserView::IsFullscreenBubbleVisible() const { 879 bool BrowserView::IsFullscreenBubbleVisible() const {
946 return fullscreen_bubble_.get() ? true : false; 880 return fullscreen_bubble_.get() ? true : false;
947 } 881 }
948 882
883 void BrowserView::FullScreenStateChanged() {
884 ProcessFullscreen(IsFullscreen());
885 }
886
949 LocationBar* BrowserView::GetLocationBar() const { 887 LocationBar* BrowserView::GetLocationBar() const {
950 return toolbar_->location_bar(); 888 return toolbar_->location_bar();
951 } 889 }
952 890
953 void BrowserView::SetFocusToLocationBar() { 891 void BrowserView::SetFocusToLocationBar() {
954 LocationBarView* location_bar = toolbar_->location_bar(); 892 LocationBarView* location_bar = toolbar_->location_bar();
955 if (browser_extender_->SetFocusToCompactNavigationBar()) { 893 if (browser_extender_->SetFocusToCompactNavigationBar()) {
956 // Compact navigation bar got focus. 894 // Compact navigation bar got focus.
957 } else if (location_bar->IsFocusable()) { 895 } else if (location_bar->IsFocusable()) {
958 // Location bar got focus. 896 // Location bar got focus.
(...skipping 1247 matching lines...) Expand 10 before | Expand all | Expand 10 after
2206 } else if (new_view) { 2144 } else if (new_view) {
2207 DCHECK_EQ(0, new_height); 2145 DCHECK_EQ(0, new_height);
2208 // The heights are the same, but the old view is null. This only happens 2146 // The heights are the same, but the old view is null. This only happens
2209 // when the height is zero. Zero out the bounds. 2147 // when the height is zero. Zero out the bounds.
2210 new_view->SetBounds(0, 0, 0, 0); 2148 new_view->SetBounds(0, 0, 0, 0);
2211 } 2149 }
2212 *old_view = new_view; 2150 *old_view = new_view;
2213 return changed; 2151 return changed;
2214 } 2152 }
2215 2153
2154
2155 void BrowserView::ProcessFullscreen(bool fullscreen) {
2156 // Reduce jankiness during the following position changes by:
2157 // * Hiding the window until it's in the final position
2158 // * Ignoring all intervening Layout() calls, which resize the webpage and
2159 // thus are slow and look ugly
2160 ignore_layout_ = true;
2161 LocationBarView* location_bar = toolbar_->location_bar();
2162 #if defined(OS_WIN)
2163 AutocompleteEditViewWin* edit_view =
2164 static_cast<AutocompleteEditViewWin*>(location_bar->location_entry());
2165 #endif
2166 if (!fullscreen) {
2167 // Hide the fullscreen bubble as soon as possible, since the mode toggle can
2168 // take enough time for the user to notice.
2169 fullscreen_bubble_.reset();
2170 } else {
2171 // Move focus out of the location bar if necessary.
2172 views::FocusManager* focus_manager = GetFocusManager();
2173 DCHECK(focus_manager);
2174 if (focus_manager->GetFocusedView() == location_bar)
2175 focus_manager->ClearFocus();
2176
2177 #if defined(OS_WIN)
2178 // If we don't hide the edit and force it to not show until we come out of
2179 // fullscreen, then if the user was on the New Tab Page, the edit contents
2180 // will appear atop the web contents once we go into fullscreen mode. This
2181 // has something to do with how we move the main window while it's hidden;
2182 // if we don't hide the main window below, we don't get this problem.
2183 edit_view->set_force_hidden(true);
2184 ShowWindow(edit_view->m_hWnd, SW_HIDE);
2185 #endif
2186 }
2187 #if defined(OS_WIN)
2188 frame_->GetWindow()->PushForceHidden();
2189 #endif
2190
2191 // Notify bookmark bar, so it can set itself to the appropriate drawing state.
2192 if (bookmark_bar_view_.get())
2193 bookmark_bar_view_->OnFullscreenToggled(fullscreen);
2194
2195 // Notify extension shelf, so it can set itself to the appropriate drawing
2196 // state.
2197 if (extension_shelf_)
2198 extension_shelf_->OnFullscreenToggled(fullscreen);
2199
2200 // Toggle fullscreen mode.
2201 #if defined(OS_WIN)
2202 frame_->GetWindow()->SetFullscreen(fullscreen);
2203 #endif // No need to invoke SetFullscreen for linux as this code is executed
2204 // once we're already fullscreen on linux.
2205
2206 if (fullscreen) {
2207 bool is_kiosk =
2208 CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode);
2209 if (!is_kiosk) {
2210 fullscreen_bubble_.reset(new FullscreenExitBubble(GetWidget(),
2211 browser_.get()));
2212 }
2213 } else {
2214 #if defined(OS_WIN)
2215 // Show the edit again since we're no longer in fullscreen mode.
2216 edit_view->set_force_hidden(false);
2217 ShowWindow(edit_view->m_hWnd, SW_SHOW);
2218 #endif
2219 }
2220
2221 // Undo our anti-jankiness hacks and force the window to relayout now that
2222 // it's in its final position.
2223 ignore_layout_ = false;
2224 Layout();
2225 #if defined(OS_WIN)
2226 frame_->GetWindow()->PopForceHidden();
2227 #endif
2228 }
2229
2230
2216 void BrowserView::LoadAccelerators() { 2231 void BrowserView::LoadAccelerators() {
2217 #if defined(OS_WIN) 2232 #if defined(OS_WIN)
2218 HACCEL accelerator_table = AtlLoadAccelerators(IDR_MAINFRAME); 2233 HACCEL accelerator_table = AtlLoadAccelerators(IDR_MAINFRAME);
2219 DCHECK(accelerator_table); 2234 DCHECK(accelerator_table);
2220 2235
2221 // We have to copy the table to access its contents. 2236 // We have to copy the table to access its contents.
2222 int count = CopyAcceleratorTable(accelerator_table, 0, 0); 2237 int count = CopyAcceleratorTable(accelerator_table, 0, 0);
2223 if (count == 0) { 2238 if (count == 0) {
2224 // Nothing to do in that case. 2239 // Nothing to do in that case.
2225 return; 2240 return;
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
2411 2426
2412 // static 2427 // static
2413 FindBar* BrowserWindow::CreateFindBar(Browser* browser) { 2428 FindBar* BrowserWindow::CreateFindBar(Browser* browser) {
2414 return browser::CreateFindBar(static_cast<BrowserView*>(browser->window())); 2429 return browser::CreateFindBar(static_cast<BrowserView*>(browser->window()));
2415 } 2430 }
2416 2431
2417 // static 2432 // static
2418 void BrowserList::AllBrowsersClosed() { 2433 void BrowserList::AllBrowsersClosed() {
2419 views::Window::CloseAllSecondaryWindows(); 2434 views::Window::CloseAllSecondaryWindows();
2420 } 2435 }
OLDNEW
« no previous file with comments | « chrome/browser/views/frame/browser_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698