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

Side by Side Diff: chrome/browser/browser.cc

Issue 20423: Preliminary fullscreen mode support.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 10 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/browser.h ('k') | chrome/browser/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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/browser.h" 5 #include "chrome/browser/browser.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/idle_timer.h" 8 #include "base/idle_timer.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 704
705 void Browser::ConvertPopupToTabbedBrowser() { 705 void Browser::ConvertPopupToTabbedBrowser() {
706 UserMetrics::RecordAction(L"ShowAsTab", profile_); 706 UserMetrics::RecordAction(L"ShowAsTab", profile_);
707 int tab_strip_index = tabstrip_model_.selected_index(); 707 int tab_strip_index = tabstrip_model_.selected_index();
708 TabContents* contents = tabstrip_model_.DetachTabContentsAt(tab_strip_index); 708 TabContents* contents = tabstrip_model_.DetachTabContentsAt(tab_strip_index);
709 Browser* browser = Browser::Create(profile_); 709 Browser* browser = Browser::Create(profile_);
710 browser->tabstrip_model()->AppendTabContents(contents, true); 710 browser->tabstrip_model()->AppendTabContents(contents, true);
711 browser->window()->Show(); 711 browser->window()->Show();
712 } 712 }
713 713
714 void Browser::ToggleFullscreenMode() {
715 UserMetrics::RecordAction(L"ToggleFullscreen", profile_);
716 window_->SetFullscreen(!window_->IsFullscreen());
717 UpdateCommandsForFullscreenMode(window_->IsFullscreen());
718 }
719
714 void Browser::Exit() { 720 void Browser::Exit() {
715 UserMetrics::RecordAction(L"Exit", profile_); 721 UserMetrics::RecordAction(L"Exit", profile_);
716 BrowserList::CloseAllBrowsers(true); 722 BrowserList::CloseAllBrowsers(true);
717 } 723 }
718 724
719 void Browser::BookmarkCurrentPage() { 725 void Browser::BookmarkCurrentPage() {
720 UserMetrics::RecordAction(L"Star", profile_); 726 UserMetrics::RecordAction(L"Star", profile_);
721 727
722 TabContents* contents = GetSelectedTabContents(); 728 TabContents* contents = GetSelectedTabContents();
723 BookmarkModel* model = contents->profile()->GetBookmarkModel(); 729 BookmarkModel* model = contents->profile()->GetBookmarkModel();
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
1096 case IDC_SELECT_TAB_3: 1102 case IDC_SELECT_TAB_3:
1097 case IDC_SELECT_TAB_4: 1103 case IDC_SELECT_TAB_4:
1098 case IDC_SELECT_TAB_5: 1104 case IDC_SELECT_TAB_5:
1099 case IDC_SELECT_TAB_6: 1105 case IDC_SELECT_TAB_6:
1100 case IDC_SELECT_TAB_7: SelectNumberedTab(id - IDC_SELECT_TAB_0); 1106 case IDC_SELECT_TAB_7: SelectNumberedTab(id - IDC_SELECT_TAB_0);
1101 break; 1107 break;
1102 case IDC_SELECT_LAST_TAB: SelectLastTab(); break; 1108 case IDC_SELECT_LAST_TAB: SelectLastTab(); break;
1103 case IDC_DUPLICATE_TAB: DuplicateTab(); break; 1109 case IDC_DUPLICATE_TAB: DuplicateTab(); break;
1104 case IDC_RESTORE_TAB: RestoreTab(); break; 1110 case IDC_RESTORE_TAB: RestoreTab(); break;
1105 case IDC_SHOW_AS_TAB: ConvertPopupToTabbedBrowser(); break; 1111 case IDC_SHOW_AS_TAB: ConvertPopupToTabbedBrowser(); break;
1112 case IDC_FULLSCREEN: ToggleFullscreenMode(); break;
1106 case IDC_EXIT: Exit(); break; 1113 case IDC_EXIT: Exit(); break;
1107 1114
1108 // Page-related commands 1115 // Page-related commands
1109 case IDC_STAR: BookmarkCurrentPage(); break; 1116 case IDC_STAR: BookmarkCurrentPage(); break;
1110 case IDC_VIEW_SOURCE: ViewSource(); break; 1117 case IDC_VIEW_SOURCE: ViewSource(); break;
1111 #if defined(OS_WIN) 1118 #if defined(OS_WIN)
1112 case IDC_CLOSE_POPUPS: ClosePopups(); break; 1119 case IDC_CLOSE_POPUPS: ClosePopups(); break;
1113 case IDC_PRINT: Print(); break; 1120 case IDC_PRINT: Print(); break;
1114 case IDC_SAVE_PAGE: SavePage(); break; 1121 case IDC_SAVE_PAGE: SavePage(); break;
1115 case IDC_ENCODING_AUTO_DETECT: ToggleEncodingAutoDetect(); break; 1122 case IDC_ENCODING_AUTO_DETECT: ToggleEncodingAutoDetect(); break;
(...skipping 810 matching lines...) Expand 10 before | Expand all | Expand 10 after
1926 command_updater_.UpdateCommandEnabled(IDC_NEW_WINDOW_PROFILE_3, true); 1933 command_updater_.UpdateCommandEnabled(IDC_NEW_WINDOW_PROFILE_3, true);
1927 command_updater_.UpdateCommandEnabled(IDC_NEW_WINDOW_PROFILE_4, true); 1934 command_updater_.UpdateCommandEnabled(IDC_NEW_WINDOW_PROFILE_4, true);
1928 command_updater_.UpdateCommandEnabled(IDC_NEW_WINDOW_PROFILE_5, true); 1935 command_updater_.UpdateCommandEnabled(IDC_NEW_WINDOW_PROFILE_5, true);
1929 command_updater_.UpdateCommandEnabled(IDC_NEW_WINDOW_PROFILE_6, true); 1936 command_updater_.UpdateCommandEnabled(IDC_NEW_WINDOW_PROFILE_6, true);
1930 command_updater_.UpdateCommandEnabled(IDC_NEW_WINDOW_PROFILE_7, true); 1937 command_updater_.UpdateCommandEnabled(IDC_NEW_WINDOW_PROFILE_7, true);
1931 command_updater_.UpdateCommandEnabled(IDC_NEW_WINDOW_PROFILE_8, true); 1938 command_updater_.UpdateCommandEnabled(IDC_NEW_WINDOW_PROFILE_8, true);
1932 command_updater_.UpdateCommandEnabled(IDC_CLOSE_WINDOW, true); 1939 command_updater_.UpdateCommandEnabled(IDC_CLOSE_WINDOW, true);
1933 command_updater_.UpdateCommandEnabled(IDC_NEW_TAB, true); 1940 command_updater_.UpdateCommandEnabled(IDC_NEW_TAB, true);
1934 command_updater_.UpdateCommandEnabled(IDC_CLOSE_TAB, true); 1941 command_updater_.UpdateCommandEnabled(IDC_CLOSE_TAB, true);
1935 command_updater_.UpdateCommandEnabled(IDC_DUPLICATE_TAB, true); 1942 command_updater_.UpdateCommandEnabled(IDC_DUPLICATE_TAB, true);
1943 command_updater_.UpdateCommandEnabled(IDC_FULLSCREEN, true);
1936 command_updater_.UpdateCommandEnabled(IDC_EXIT, true); 1944 command_updater_.UpdateCommandEnabled(IDC_EXIT, true);
1937 1945
1938 // Page-related commands 1946 // Page-related commands
1939 command_updater_.UpdateCommandEnabled(IDC_CLOSE_POPUPS, true); 1947 command_updater_.UpdateCommandEnabled(IDC_CLOSE_POPUPS, true);
1940 command_updater_.UpdateCommandEnabled(IDC_ENCODING_AUTO_DETECT, true); 1948 command_updater_.UpdateCommandEnabled(IDC_ENCODING_AUTO_DETECT, true);
1941 command_updater_.UpdateCommandEnabled(IDC_ENCODING_UTF8, true); 1949 command_updater_.UpdateCommandEnabled(IDC_ENCODING_UTF8, true);
1942 command_updater_.UpdateCommandEnabled(IDC_ENCODING_UTF16LE, true); 1950 command_updater_.UpdateCommandEnabled(IDC_ENCODING_UTF16LE, true);
1943 command_updater_.UpdateCommandEnabled(IDC_ENCODING_ISO88591, true); 1951 command_updater_.UpdateCommandEnabled(IDC_ENCODING_ISO88591, true);
1944 command_updater_.UpdateCommandEnabled(IDC_ENCODING_WINDOWS1252, true); 1952 command_updater_.UpdateCommandEnabled(IDC_ENCODING_WINDOWS1252, true);
1945 command_updater_.UpdateCommandEnabled(IDC_ENCODING_GBK, true); 1953 command_updater_.UpdateCommandEnabled(IDC_ENCODING_GBK, true);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1990 command_updater_.UpdateCommandEnabled(IDC_SHOW_BOOKMARK_MANAGER, true); 1998 command_updater_.UpdateCommandEnabled(IDC_SHOW_BOOKMARK_MANAGER, true);
1991 command_updater_.UpdateCommandEnabled(IDC_SHOW_DOWNLOADS, true); 1999 command_updater_.UpdateCommandEnabled(IDC_SHOW_DOWNLOADS, true);
1992 command_updater_.UpdateCommandEnabled(IDC_HELP_PAGE, true); 2000 command_updater_.UpdateCommandEnabled(IDC_HELP_PAGE, true);
1993 2001
1994 // Initialize other commands based on the window type. 2002 // Initialize other commands based on the window type.
1995 { 2003 {
1996 bool normal_window = type() == TYPE_NORMAL; 2004 bool normal_window = type() == TYPE_NORMAL;
1997 2005
1998 // Navigation commands 2006 // Navigation commands
1999 command_updater_.UpdateCommandEnabled(IDC_HOME, normal_window); 2007 command_updater_.UpdateCommandEnabled(IDC_HOME, normal_window);
2000 command_updater_.UpdateCommandEnabled(IDC_OPEN_CURRENT_URL, normal_window);
2001 2008
2002 // Window management commands 2009 // Window management commands
2003 command_updater_.UpdateCommandEnabled(IDC_PROFILE_MENU, normal_window);
2004 command_updater_.UpdateCommandEnabled(IDC_SELECT_NEXT_TAB, normal_window); 2010 command_updater_.UpdateCommandEnabled(IDC_SELECT_NEXT_TAB, normal_window);
2005 command_updater_.UpdateCommandEnabled(IDC_SELECT_PREVIOUS_TAB, 2011 command_updater_.UpdateCommandEnabled(IDC_SELECT_PREVIOUS_TAB,
2006 normal_window); 2012 normal_window);
2007 command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_0, normal_window); 2013 command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_0, normal_window);
2008 command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_1, normal_window); 2014 command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_1, normal_window);
2009 command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_2, normal_window); 2015 command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_2, normal_window);
2010 command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_3, normal_window); 2016 command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_3, normal_window);
2011 command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_4, normal_window); 2017 command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_4, normal_window);
2012 command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_5, normal_window); 2018 command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_5, normal_window);
2013 command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_6, normal_window); 2019 command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_6, normal_window);
2014 command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_7, normal_window); 2020 command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_7, normal_window);
2015 command_updater_.UpdateCommandEnabled(IDC_SELECT_LAST_TAB, normal_window); 2021 command_updater_.UpdateCommandEnabled(IDC_SELECT_LAST_TAB, normal_window);
2016 command_updater_.UpdateCommandEnabled(IDC_RESTORE_TAB, 2022 command_updater_.UpdateCommandEnabled(IDC_RESTORE_TAB,
2017 normal_window && !profile_->IsOffTheRecord()); 2023 normal_window && !profile_->IsOffTheRecord());
2018 command_updater_.UpdateCommandEnabled(IDC_SHOW_AS_TAB, 2024 }
2019 (type() == TYPE_POPUP));
2020 2025
2021 // Focus various bits of UI 2026 // Initialize other commands whose state changes based on fullscreen mode.
2022 command_updater_.UpdateCommandEnabled(IDC_FOCUS_TOOLBAR, normal_window); 2027 UpdateCommandsForFullscreenMode(false);
2023 command_updater_.UpdateCommandEnabled(IDC_FOCUS_LOCATION, normal_window);
2024 command_updater_.UpdateCommandEnabled(IDC_FOCUS_SEARCH, normal_window);
2025
2026 // Show various bits of UI
2027 command_updater_.UpdateCommandEnabled(IDC_DEVELOPER_MENU, normal_window);
2028 #if defined(OS_WIN)
2029 command_updater_.UpdateCommandEnabled(IDC_DEBUGGER,
2030 // The debugger doesn't work in single process mode.
2031 normal_window && !RenderProcessHost::run_renderer_in_process());
2032 #endif
2033 command_updater_.UpdateCommandEnabled(IDC_NEW_PROFILE, normal_window);
2034 command_updater_.UpdateCommandEnabled(IDC_REPORT_BUG, normal_window);
2035 command_updater_.UpdateCommandEnabled(IDC_SHOW_BOOKMARK_BAR, normal_window);
2036 command_updater_.UpdateCommandEnabled(IDC_CLEAR_BROWSING_DATA,
2037 normal_window);
2038 command_updater_.UpdateCommandEnabled(IDC_IMPORT_SETTINGS, normal_window);
2039 command_updater_.UpdateCommandEnabled(IDC_OPTIONS, normal_window);
2040 command_updater_.UpdateCommandEnabled(IDC_EDIT_SEARCH_ENGINES,
2041 normal_window);
2042 command_updater_.UpdateCommandEnabled(IDC_VIEW_PASSWORDS, normal_window);
2043 command_updater_.UpdateCommandEnabled(IDC_ABOUT, normal_window);
2044 }
2045 } 2028 }
2046 2029
2047 void Browser::UpdateCommandsForTabState() { 2030 void Browser::UpdateCommandsForTabState() {
2048 TabContents* current_tab = GetSelectedTabContents(); 2031 TabContents* current_tab = GetSelectedTabContents();
2049 if (!current_tab) // May be NULL during tab restore. 2032 if (!current_tab) // May be NULL during tab restore.
2050 return; 2033 return;
2051 2034
2052 // Navigation commands 2035 // Navigation commands
2053 NavigationController* nc = current_tab->controller(); 2036 NavigationController* nc = current_tab->controller();
2054 command_updater_.UpdateCommandEnabled(IDC_BACK, nc->CanGoBack()); 2037 command_updater_.UpdateCommandEnabled(IDC_BACK, nc->CanGoBack());
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
2091 command_updater_.UpdateCommandEnabled(IDC_ZOOM_NORMAL, is_web_contents); 2074 command_updater_.UpdateCommandEnabled(IDC_ZOOM_NORMAL, is_web_contents);
2092 command_updater_.UpdateCommandEnabled(IDC_ZOOM_MINUS, is_web_contents); 2075 command_updater_.UpdateCommandEnabled(IDC_ZOOM_MINUS, is_web_contents);
2093 2076
2094 // Show various bits of UI 2077 // Show various bits of UI
2095 command_updater_.UpdateCommandEnabled(IDC_JS_CONSOLE, is_web_contents); 2078 command_updater_.UpdateCommandEnabled(IDC_JS_CONSOLE, is_web_contents);
2096 command_updater_.UpdateCommandEnabled(IDC_CREATE_SHORTCUTS, 2079 command_updater_.UpdateCommandEnabled(IDC_CREATE_SHORTCUTS,
2097 is_web_contents && !current_tab->GetFavIcon().isNull()); 2080 is_web_contents && !current_tab->GetFavIcon().isNull());
2098 } 2081 }
2099 } 2082 }
2100 2083
2084 void Browser::UpdateCommandsForFullscreenMode(bool is_fullscreen) {
2085 const bool show_main_ui = (type() == TYPE_NORMAL) && !is_fullscreen;
2086
2087 // Navigation commands
2088 command_updater_.UpdateCommandEnabled(IDC_OPEN_CURRENT_URL, show_main_ui);
2089
2090 // Window management commands
2091 command_updater_.UpdateCommandEnabled(IDC_PROFILE_MENU, show_main_ui);
2092 command_updater_.UpdateCommandEnabled(IDC_SHOW_AS_TAB,
2093 (type() == TYPE_POPUP) && !is_fullscreen);
2094
2095 // Focus various bits of UI
2096 command_updater_.UpdateCommandEnabled(IDC_FOCUS_TOOLBAR, show_main_ui);
2097 command_updater_.UpdateCommandEnabled(IDC_FOCUS_LOCATION, show_main_ui);
2098 command_updater_.UpdateCommandEnabled(IDC_FOCUS_SEARCH, show_main_ui);
2099
2100 // Show various bits of UI
2101 command_updater_.UpdateCommandEnabled(IDC_DEVELOPER_MENU, show_main_ui);
2102 #if defined(OS_WIN)
2103 command_updater_.UpdateCommandEnabled(IDC_DEBUGGER,
2104 // The debugger doesn't work in single process mode.
2105 show_main_ui && !RenderProcessHost::run_renderer_in_process());
2106 #endif
2107 command_updater_.UpdateCommandEnabled(IDC_NEW_PROFILE, show_main_ui);
2108 command_updater_.UpdateCommandEnabled(IDC_REPORT_BUG, show_main_ui);
2109 command_updater_.UpdateCommandEnabled(IDC_SHOW_BOOKMARK_BAR, show_main_ui);
2110 command_updater_.UpdateCommandEnabled(IDC_CLEAR_BROWSING_DATA, show_main_ui);
2111 command_updater_.UpdateCommandEnabled(IDC_IMPORT_SETTINGS, show_main_ui);
2112 command_updater_.UpdateCommandEnabled(IDC_OPTIONS, show_main_ui);
2113 command_updater_.UpdateCommandEnabled(IDC_EDIT_SEARCH_ENGINES, show_main_ui);
2114 command_updater_.UpdateCommandEnabled(IDC_VIEW_PASSWORDS, show_main_ui);
2115 command_updater_.UpdateCommandEnabled(IDC_ABOUT, show_main_ui);
2116 }
2117
2101 void Browser::UpdateStopGoState(bool is_loading) { 2118 void Browser::UpdateStopGoState(bool is_loading) {
2102 window_->UpdateStopGoState(is_loading); 2119 window_->UpdateStopGoState(is_loading);
2103 command_updater_.UpdateCommandEnabled(IDC_GO, !is_loading); 2120 command_updater_.UpdateCommandEnabled(IDC_GO, !is_loading);
2104 command_updater_.UpdateCommandEnabled(IDC_STOP, is_loading); 2121 command_updater_.UpdateCommandEnabled(IDC_STOP, is_loading);
2105 } 2122 }
2106 2123
2107 2124
2108 /////////////////////////////////////////////////////////////////////////////// 2125 ///////////////////////////////////////////////////////////////////////////////
2109 // Browser, UI update coalescing and handling (private): 2126 // Browser, UI update coalescing and handling (private):
2110 2127
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
2424 2441
2425 // We need to register the window position pref. 2442 // We need to register the window position pref.
2426 std::wstring window_pref(prefs::kBrowserWindowPlacement); 2443 std::wstring window_pref(prefs::kBrowserWindowPlacement);
2427 window_pref.append(L"_"); 2444 window_pref.append(L"_");
2428 window_pref.append(app_name); 2445 window_pref.append(app_name);
2429 PrefService* prefs = g_browser_process->local_state(); 2446 PrefService* prefs = g_browser_process->local_state();
2430 DCHECK(prefs); 2447 DCHECK(prefs);
2431 2448
2432 prefs->RegisterDictionaryPref(window_pref.c_str()); 2449 prefs->RegisterDictionaryPref(window_pref.c_str());
2433 } 2450 }
OLDNEW
« no previous file with comments | « chrome/browser/browser.h ('k') | chrome/browser/browser_window.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698