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

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

Issue 10536144: First pass at making Chrome support metro snap mode. It creates a fullscreen-alike mode that Chrome… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge fallout in browser_win.cc. Trying again 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/browser.h ('k') | chrome/browser/ui/browser_win.cc » ('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/browser.h" 5 #include "chrome/browser/ui/browser.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windows.h> 8 #include <windows.h>
9 #include <shellapi.h> 9 #include <shellapi.h>
10 #endif // OS_WIN 10 #endif // OS_WIN
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 #include "ui/base/animation/animation.h" 182 #include "ui/base/animation/animation.h"
183 #include "ui/base/l10n/l10n_util.h" 183 #include "ui/base/l10n/l10n_util.h"
184 #include "ui/gfx/point.h" 184 #include "ui/gfx/point.h"
185 #include "webkit/glue/web_intent_data.h" 185 #include "webkit/glue/web_intent_data.h"
186 #include "webkit/glue/web_intent_service_data.h" 186 #include "webkit/glue/web_intent_service_data.h"
187 #include "webkit/glue/webkit_glue.h" 187 #include "webkit/glue/webkit_glue.h"
188 #include "webkit/glue/window_open_disposition.h" 188 #include "webkit/glue/window_open_disposition.h"
189 #include "webkit/plugins/webplugininfo.h" 189 #include "webkit/plugins/webplugininfo.h"
190 190
191 #if defined(OS_WIN) 191 #if defined(OS_WIN)
192 #include "base/win/metro.h"
192 #include "chrome/browser/autofill/autofill_ie_toolbar_import_win.h" 193 #include "chrome/browser/autofill/autofill_ie_toolbar_import_win.h"
193 #include "chrome/browser/shell_integration.h" 194 #include "chrome/browser/shell_integration.h"
194 #include "chrome/browser/ssl/ssl_error_info.h" 195 #include "chrome/browser/ssl/ssl_error_info.h"
195 #include "chrome/browser/task_manager/task_manager.h" 196 #include "chrome/browser/task_manager/task_manager.h"
196 #include "chrome/browser/ui/view_ids.h" 197 #include "chrome/browser/ui/view_ids.h"
197 #include "ui/base/win/shell.h" 198 #include "ui/base/win/shell.h"
198 #endif // OS_WIN 199 #endif // OS_WIN
199 200
200 #if defined(OS_MACOSX) 201 #if defined(OS_MACOSX)
201 #include "ui/base/cocoa/find_pasteboard.h" 202 #include "ui/base/cocoa/find_pasteboard.h"
(...skipping 1072 matching lines...) Expand 10 before | Expand all | Expand 10 after
1274 browser::NavigateParams params( 1275 browser::NavigateParams params(
1275 this, url, content::PAGE_TRANSITION_AUTO_BOOKMARK); 1276 this, url, content::PAGE_TRANSITION_AUTO_BOOKMARK);
1276 params.disposition = SINGLETON_TAB; 1277 params.disposition = SINGLETON_TAB;
1277 params.window_action = browser::NavigateParams::SHOW_WINDOW; 1278 params.window_action = browser::NavigateParams::SHOW_WINDOW;
1278 params.user_gesture = true; 1279 params.user_gesture = true;
1279 return params; 1280 return params;
1280 } 1281 }
1281 1282
1282 void Browser::WindowFullscreenStateChanged() { 1283 void Browser::WindowFullscreenStateChanged() {
1283 fullscreen_controller_->WindowFullscreenStateChanged(); 1284 fullscreen_controller_->WindowFullscreenStateChanged();
1284 UpdateCommandsForFullscreenMode(window_->IsFullscreen()); 1285 FullScreenMode fullscreen_mode = FULLSCREEN_DISABLED;
1286 if (window_->IsFullscreen()) {
1287 #if defined(OS_WIN)
1288 fullscreen_mode = window_->IsInMetroSnapMode() ? FULLSCREEN_METRO_SNAP :
1289 FULLSCREEN_NORMAL;
1290 #else
1291 fullscreen_mode = FULLSCREEN_NORMAL;
1292 #endif
1293 }
1294 UpdateCommandsForFullscreenMode(fullscreen_mode);
1285 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TOGGLE_FULLSCREEN); 1295 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TOGGLE_FULLSCREEN);
1286 } 1296 }
1287 1297
1288 /////////////////////////////////////////////////////////////////////////////// 1298 ///////////////////////////////////////////////////////////////////////////////
1289 // Browser, Assorted browser commands: 1299 // Browser, Assorted browser commands:
1290 1300
1291 bool Browser::CanGoBack() const { 1301 bool Browser::CanGoBack() const {
1292 return GetActiveWebContents()->GetController().CanGoBack(); 1302 return GetActiveWebContents()->GetController().CanGoBack();
1293 } 1303 }
1294 1304
(...skipping 1187 matching lines...) Expand 10 before | Expand all | Expand 10 after
2482 case IDC_SELECT_TAB_5: 2492 case IDC_SELECT_TAB_5:
2483 case IDC_SELECT_TAB_6: 2493 case IDC_SELECT_TAB_6:
2484 case IDC_SELECT_TAB_7: SelectNumberedTab(id - IDC_SELECT_TAB_0); 2494 case IDC_SELECT_TAB_7: SelectNumberedTab(id - IDC_SELECT_TAB_0);
2485 break; 2495 break;
2486 case IDC_SELECT_LAST_TAB: SelectLastTab(); break; 2496 case IDC_SELECT_LAST_TAB: SelectLastTab(); break;
2487 case IDC_DUPLICATE_TAB: DuplicateTab(); break; 2497 case IDC_DUPLICATE_TAB: DuplicateTab(); break;
2488 case IDC_RESTORE_TAB: RestoreTab(); break; 2498 case IDC_RESTORE_TAB: RestoreTab(); break;
2489 case IDC_COPY_URL: WriteCurrentURLToClipboard(); break; 2499 case IDC_COPY_URL: WriteCurrentURLToClipboard(); break;
2490 case IDC_SHOW_AS_TAB: ConvertPopupToTabbedBrowser(); break; 2500 case IDC_SHOW_AS_TAB: ConvertPopupToTabbedBrowser(); break;
2491 case IDC_FULLSCREEN: ToggleFullscreenMode(); break; 2501 case IDC_FULLSCREEN: ToggleFullscreenMode(); break;
2502 #if defined(OS_WIN)
2503 case IDC_METRO_SNAP_ENABLE: SetMetroSnapMode(true); break;
2504 case IDC_METRO_SNAP_DISABLE: SetMetroSnapMode(false); break;
2505 #endif
2492 #if defined(OS_MACOSX) 2506 #if defined(OS_MACOSX)
2493 case IDC_PRESENTATION_MODE: TogglePresentationMode(); break; 2507 case IDC_PRESENTATION_MODE: TogglePresentationMode(); break;
2494 #endif 2508 #endif
2495 case IDC_EXIT: Exit(); break; 2509 case IDC_EXIT: Exit(); break;
2496 2510
2497 // Page-related commands 2511 // Page-related commands
2498 case IDC_SAVE_PAGE: SavePage(); break; 2512 case IDC_SAVE_PAGE: SavePage(); break;
2499 case IDC_BOOKMARK_PAGE: BookmarkCurrentPage(); break; 2513 case IDC_BOOKMARK_PAGE: BookmarkCurrentPage(); break;
2500 case IDC_PIN_TO_START_SCREEN: PinCurrentPageToStartScreen(); break; 2514 case IDC_PIN_TO_START_SCREEN: PinCurrentPageToStartScreen(); break;
2501 case IDC_BOOKMARK_ALL_TABS: BookmarkAllTabs(); break; 2515 case IDC_BOOKMARK_ALL_TABS: BookmarkAllTabs(); break;
(...skipping 1661 matching lines...) Expand 10 before | Expand all | Expand 10 after
4163 command_updater_.UpdateCommandEnabled(IDC_MOVE_TAB_PREVIOUS, normal_window); 4177 command_updater_.UpdateCommandEnabled(IDC_MOVE_TAB_PREVIOUS, normal_window);
4164 command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_0, normal_window); 4178 command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_0, normal_window);
4165 command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_1, normal_window); 4179 command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_1, normal_window);
4166 command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_2, normal_window); 4180 command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_2, normal_window);
4167 command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_3, normal_window); 4181 command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_3, normal_window);
4168 command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_4, normal_window); 4182 command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_4, normal_window);
4169 command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_5, normal_window); 4183 command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_5, normal_window);
4170 command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_6, normal_window); 4184 command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_6, normal_window);
4171 command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_7, normal_window); 4185 command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_7, normal_window);
4172 command_updater_.UpdateCommandEnabled(IDC_SELECT_LAST_TAB, normal_window); 4186 command_updater_.UpdateCommandEnabled(IDC_SELECT_LAST_TAB, normal_window);
4187 #if defined(OS_WIN)
4188 const bool metro_mode = (base::win::GetMetroModule() != NULL);
4189 command_updater_.UpdateCommandEnabled(IDC_METRO_SNAP_ENABLE, metro_mode);
4190 command_updater_.UpdateCommandEnabled(IDC_METRO_SNAP_DISABLE, metro_mode);
4191 #endif
4173 #if defined(OS_MACOSX) 4192 #if defined(OS_MACOSX)
4174 command_updater_.UpdateCommandEnabled(IDC_TABPOSE, normal_window); 4193 command_updater_.UpdateCommandEnabled(IDC_TABPOSE, normal_window);
4175 command_updater_.UpdateCommandEnabled(IDC_PRESENTATION_MODE, 4194 command_updater_.UpdateCommandEnabled(IDC_PRESENTATION_MODE,
4176 !(is_type_panel() && is_app())); 4195 !(is_type_panel() && is_app()));
4177 #endif 4196 #endif
4178 4197
4179 // Clipboard commands 4198 // Clipboard commands
4180 command_updater_.UpdateCommandEnabled(IDC_COPY_URL, !is_devtools()); 4199 command_updater_.UpdateCommandEnabled(IDC_COPY_URL, !is_devtools());
4181 4200
4182 // Find-in-page 4201 // Find-in-page
(...skipping 11 matching lines...) Expand all
4194 command_updater_.UpdateCommandEnabled(IDC_VIEW_INCOMPATIBILITIES, true); 4213 command_updater_.UpdateCommandEnabled(IDC_VIEW_INCOMPATIBILITIES, true);
4195 4214
4196 // View Background Pages entry is always enabled, but is hidden if there are 4215 // View Background Pages entry is always enabled, but is hidden if there are
4197 // no background pages. 4216 // no background pages.
4198 command_updater_.UpdateCommandEnabled(IDC_VIEW_BACKGROUND_PAGES, true); 4217 command_updater_.UpdateCommandEnabled(IDC_VIEW_BACKGROUND_PAGES, true);
4199 4218
4200 // Toggle speech input 4219 // Toggle speech input
4201 command_updater_.UpdateCommandEnabled(IDC_TOGGLE_SPEECH_INPUT, true); 4220 command_updater_.UpdateCommandEnabled(IDC_TOGGLE_SPEECH_INPUT, true);
4202 4221
4203 // Initialize other commands whose state changes based on fullscreen mode. 4222 // Initialize other commands whose state changes based on fullscreen mode.
4204 UpdateCommandsForFullscreenMode(false); 4223 UpdateCommandsForFullscreenMode(FULLSCREEN_DISABLED);
4205 4224
4206 UpdateCommandsForContentRestrictionState(); 4225 UpdateCommandsForContentRestrictionState();
4207 4226
4208 UpdateCommandsForBookmarkEditing(); 4227 UpdateCommandsForBookmarkEditing();
4209 4228
4210 UpdateCommandsForIncognitoAvailability(); 4229 UpdateCommandsForIncognitoAvailability();
4211 } 4230 }
4212 4231
4213 void Browser::UpdateCommandsForIncognitoAvailability() { 4232 void Browser::UpdateCommandsForIncognitoAvailability() {
4214 IncognitoModePrefs::Availability incognito_availability = 4233 IncognitoModePrefs::Availability incognito_availability =
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
4334 command_updater_.UpdateCommandEnabled(IDC_SHOW_BOOKMARK_BAR, 4353 command_updater_.UpdateCommandEnabled(IDC_SHOW_BOOKMARK_BAR,
4335 browser_defaults::bookmarks_enabled && 4354 browser_defaults::bookmarks_enabled &&
4336 !profile_->GetPrefs()->IsManagedPreference(prefs::kShowBookmarkBar) && 4355 !profile_->GetPrefs()->IsManagedPreference(prefs::kShowBookmarkBar) &&
4337 show_main_ui); 4356 show_main_ui);
4338 } 4357 }
4339 4358
4340 void Browser::MarkHomePageAsChanged(PrefService* pref_service) { 4359 void Browser::MarkHomePageAsChanged(PrefService* pref_service) {
4341 pref_service->SetBoolean(prefs::kHomePageChanged, true); 4360 pref_service->SetBoolean(prefs::kHomePageChanged, true);
4342 } 4361 }
4343 4362
4344 void Browser::UpdateCommandsForFullscreenMode(bool is_fullscreen) { 4363 void Browser::UpdateCommandsForFullscreenMode(FullScreenMode fullscreen_mode) {
4345 const bool show_main_ui = IsShowingMainUI(is_fullscreen); 4364 const bool show_main_ui =
4346 bool main_not_fullscreen = show_main_ui && !is_fullscreen; 4365 IsShowingMainUI(fullscreen_mode != FULLSCREEN_DISABLED);
4366 bool main_not_fullscreen = show_main_ui &&
4367 (fullscreen_mode == FULLSCREEN_DISABLED);
4347 4368
4348 // Navigation commands 4369 // Navigation commands
4349 command_updater_.UpdateCommandEnabled(IDC_OPEN_CURRENT_URL, show_main_ui); 4370 command_updater_.UpdateCommandEnabled(IDC_OPEN_CURRENT_URL, show_main_ui);
4350 4371
4351 // Window management commands 4372 // Window management commands
4352 command_updater_.UpdateCommandEnabled(IDC_SHOW_AS_TAB, 4373 command_updater_.UpdateCommandEnabled(IDC_SHOW_AS_TAB,
4353 type_ != TYPE_TABBED && !is_fullscreen); 4374 type_ != TYPE_TABBED && (fullscreen_mode == FULLSCREEN_DISABLED));
4354 4375
4355 // Focus various bits of UI 4376 // Focus various bits of UI
4356 command_updater_.UpdateCommandEnabled(IDC_FOCUS_TOOLBAR, show_main_ui); 4377 command_updater_.UpdateCommandEnabled(IDC_FOCUS_TOOLBAR, show_main_ui);
4357 command_updater_.UpdateCommandEnabled(IDC_FOCUS_LOCATION, show_main_ui); 4378 command_updater_.UpdateCommandEnabled(IDC_FOCUS_LOCATION, show_main_ui);
4358 command_updater_.UpdateCommandEnabled(IDC_FOCUS_SEARCH, show_main_ui); 4379 command_updater_.UpdateCommandEnabled(IDC_FOCUS_SEARCH, show_main_ui);
4359 command_updater_.UpdateCommandEnabled( 4380 command_updater_.UpdateCommandEnabled(
4360 IDC_FOCUS_MENU_BAR, main_not_fullscreen); 4381 IDC_FOCUS_MENU_BAR, main_not_fullscreen);
4361 command_updater_.UpdateCommandEnabled( 4382 command_updater_.UpdateCommandEnabled(
4362 IDC_FOCUS_NEXT_PANE, main_not_fullscreen); 4383 IDC_FOCUS_NEXT_PANE, main_not_fullscreen);
4363 command_updater_.UpdateCommandEnabled( 4384 command_updater_.UpdateCommandEnabled(
(...skipping 16 matching lines...) Expand all
4380 command_updater_.UpdateCommandEnabled(IDC_IMPORT_SETTINGS, options_enabled); 4401 command_updater_.UpdateCommandEnabled(IDC_IMPORT_SETTINGS, options_enabled);
4381 4402
4382 command_updater_.UpdateCommandEnabled(IDC_EDIT_SEARCH_ENGINES, show_main_ui); 4403 command_updater_.UpdateCommandEnabled(IDC_EDIT_SEARCH_ENGINES, show_main_ui);
4383 command_updater_.UpdateCommandEnabled(IDC_VIEW_PASSWORDS, show_main_ui); 4404 command_updater_.UpdateCommandEnabled(IDC_VIEW_PASSWORDS, show_main_ui);
4384 command_updater_.UpdateCommandEnabled(IDC_ABOUT, show_main_ui); 4405 command_updater_.UpdateCommandEnabled(IDC_ABOUT, show_main_ui);
4385 command_updater_.UpdateCommandEnabled(IDC_SHOW_APP_MENU, show_main_ui); 4406 command_updater_.UpdateCommandEnabled(IDC_SHOW_APP_MENU, show_main_ui);
4386 #if defined (ENABLE_PROFILING) && !defined(NO_TCMALLOC) 4407 #if defined (ENABLE_PROFILING) && !defined(NO_TCMALLOC)
4387 command_updater_.UpdateCommandEnabled(IDC_PROFILING_ENABLED, show_main_ui); 4408 command_updater_.UpdateCommandEnabled(IDC_PROFILING_ENABLED, show_main_ui);
4388 #endif 4409 #endif
4389 4410
4411 // Disable explicit fullscreen toggling when in metro snap mode.
4412 command_updater_.UpdateCommandEnabled(
4413 IDC_FULLSCREEN,
4414 fullscreen_mode != FULLSCREEN_METRO_SNAP);
4415
4390 UpdateCommandsForBookmarkBar(); 4416 UpdateCommandsForBookmarkBar();
4391 UpdateCommandsForMultipleProfiles(); 4417 UpdateCommandsForMultipleProfiles();
4392 } 4418 }
4393 4419
4394 void Browser::UpdateCommandsForMultipleProfiles() { 4420 void Browser::UpdateCommandsForMultipleProfiles() {
4395 bool show_main_ui = IsShowingMainUI(window_ && window_->IsFullscreen()); 4421 bool show_main_ui = IsShowingMainUI(window_ && window_->IsFullscreen());
4396 command_updater_.UpdateCommandEnabled(IDC_SHOW_AVATAR_MENU, 4422 command_updater_.UpdateCommandEnabled(IDC_SHOW_AVATAR_MENU,
4397 show_main_ui && 4423 show_main_ui &&
4398 !profile()->IsOffTheRecord() && 4424 !profile()->IsOffTheRecord() &&
4399 ProfileManager::IsMultipleProfilesEnabled()); 4425 ProfileManager::IsMultipleProfilesEnabled());
(...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after
5199 if (contents && !allow_js_access) { 5225 if (contents && !allow_js_access) {
5200 contents->web_contents()->GetController().LoadURL( 5226 contents->web_contents()->GetController().LoadURL(
5201 target_url, 5227 target_url,
5202 content::Referrer(), 5228 content::Referrer(),
5203 content::PAGE_TRANSITION_LINK, 5229 content::PAGE_TRANSITION_LINK,
5204 std::string()); // No extra headers. 5230 std::string()); // No extra headers.
5205 } 5231 }
5206 5232
5207 return contents != NULL; 5233 return contents != NULL;
5208 } 5234 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser.h ('k') | chrome/browser/ui/browser_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698