OLD | NEW |
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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 #include "ui/base/animation/animation.h" | 184 #include "ui/base/animation/animation.h" |
185 #include "ui/base/l10n/l10n_util.h" | 185 #include "ui/base/l10n/l10n_util.h" |
186 #include "ui/gfx/point.h" | 186 #include "ui/gfx/point.h" |
187 #include "webkit/glue/web_intent_data.h" | 187 #include "webkit/glue/web_intent_data.h" |
188 #include "webkit/glue/web_intent_service_data.h" | 188 #include "webkit/glue/web_intent_service_data.h" |
189 #include "webkit/glue/webkit_glue.h" | 189 #include "webkit/glue/webkit_glue.h" |
190 #include "webkit/glue/window_open_disposition.h" | 190 #include "webkit/glue/window_open_disposition.h" |
191 #include "webkit/plugins/webplugininfo.h" | 191 #include "webkit/plugins/webplugininfo.h" |
192 | 192 |
193 #if defined(OS_WIN) | 193 #if defined(OS_WIN) |
| 194 #include "base/win/metro.h" |
194 #include "chrome/browser/autofill/autofill_ie_toolbar_import_win.h" | 195 #include "chrome/browser/autofill/autofill_ie_toolbar_import_win.h" |
195 #include "chrome/browser/shell_integration.h" | 196 #include "chrome/browser/shell_integration.h" |
196 #include "chrome/browser/ssl/ssl_error_info.h" | 197 #include "chrome/browser/ssl/ssl_error_info.h" |
197 #include "chrome/browser/task_manager/task_manager.h" | 198 #include "chrome/browser/task_manager/task_manager.h" |
198 #include "chrome/browser/ui/view_ids.h" | 199 #include "chrome/browser/ui/view_ids.h" |
199 #include "ui/base/win/shell.h" | 200 #include "ui/base/win/shell.h" |
200 #endif // OS_WIN | 201 #endif // OS_WIN |
201 | 202 |
202 #if defined(OS_MACOSX) | 203 #if defined(OS_MACOSX) |
203 #include "ui/base/cocoa/find_pasteboard.h" | 204 #include "ui/base/cocoa/find_pasteboard.h" |
(...skipping 1082 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1286 browser::NavigateParams params( | 1287 browser::NavigateParams params( |
1287 this, url, content::PAGE_TRANSITION_AUTO_BOOKMARK); | 1288 this, url, content::PAGE_TRANSITION_AUTO_BOOKMARK); |
1288 params.disposition = SINGLETON_TAB; | 1289 params.disposition = SINGLETON_TAB; |
1289 params.window_action = browser::NavigateParams::SHOW_WINDOW; | 1290 params.window_action = browser::NavigateParams::SHOW_WINDOW; |
1290 params.user_gesture = true; | 1291 params.user_gesture = true; |
1291 return params; | 1292 return params; |
1292 } | 1293 } |
1293 | 1294 |
1294 void Browser::WindowFullscreenStateChanged() { | 1295 void Browser::WindowFullscreenStateChanged() { |
1295 fullscreen_controller_->WindowFullscreenStateChanged(); | 1296 fullscreen_controller_->WindowFullscreenStateChanged(); |
1296 UpdateCommandsForFullscreenMode(window_->IsFullscreen()); | 1297 FullScreenMode fullscreen_mode = FULLSCREEN_DISABLED; |
| 1298 if (window_->IsFullscreen()) { |
| 1299 #if defined(OS_WIN) |
| 1300 fullscreen_mode = window_->IsInMetroSnapMode() ? FULLSCREEN_METRO_SNAP : |
| 1301 FULLSCREEN_NORMAL; |
| 1302 #else |
| 1303 fullscreen_mode = FULLSCREEN_NORMAL; |
| 1304 #endif |
| 1305 } |
| 1306 UpdateCommandsForFullscreenMode(fullscreen_mode); |
1297 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TOGGLE_FULLSCREEN); | 1307 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TOGGLE_FULLSCREEN); |
1298 } | 1308 } |
1299 | 1309 |
1300 /////////////////////////////////////////////////////////////////////////////// | 1310 /////////////////////////////////////////////////////////////////////////////// |
1301 // Browser, Assorted browser commands: | 1311 // Browser, Assorted browser commands: |
1302 | 1312 |
1303 bool Browser::CanGoBack() const { | 1313 bool Browser::CanGoBack() const { |
1304 return GetActiveWebContents()->GetController().CanGoBack(); | 1314 return GetActiveWebContents()->GetController().CanGoBack(); |
1305 } | 1315 } |
1306 | 1316 |
(...skipping 1187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2494 case IDC_SELECT_TAB_5: | 2504 case IDC_SELECT_TAB_5: |
2495 case IDC_SELECT_TAB_6: | 2505 case IDC_SELECT_TAB_6: |
2496 case IDC_SELECT_TAB_7: SelectNumberedTab(id - IDC_SELECT_TAB_0); | 2506 case IDC_SELECT_TAB_7: SelectNumberedTab(id - IDC_SELECT_TAB_0); |
2497 break; | 2507 break; |
2498 case IDC_SELECT_LAST_TAB: SelectLastTab(); break; | 2508 case IDC_SELECT_LAST_TAB: SelectLastTab(); break; |
2499 case IDC_DUPLICATE_TAB: DuplicateTab(); break; | 2509 case IDC_DUPLICATE_TAB: DuplicateTab(); break; |
2500 case IDC_RESTORE_TAB: RestoreTab(); break; | 2510 case IDC_RESTORE_TAB: RestoreTab(); break; |
2501 case IDC_COPY_URL: WriteCurrentURLToClipboard(); break; | 2511 case IDC_COPY_URL: WriteCurrentURLToClipboard(); break; |
2502 case IDC_SHOW_AS_TAB: ConvertPopupToTabbedBrowser(); break; | 2512 case IDC_SHOW_AS_TAB: ConvertPopupToTabbedBrowser(); break; |
2503 case IDC_FULLSCREEN: ToggleFullscreenMode(); break; | 2513 case IDC_FULLSCREEN: ToggleFullscreenMode(); break; |
| 2514 #if defined(OS_WIN) |
| 2515 case IDC_METRO_SNAP_ENABLE: SetMetroSnapMode(true); break; |
| 2516 case IDC_METRO_SNAP_DISABLE: SetMetroSnapMode(false); break; |
| 2517 #endif |
2504 #if defined(OS_MACOSX) | 2518 #if defined(OS_MACOSX) |
2505 case IDC_PRESENTATION_MODE: TogglePresentationMode(); break; | 2519 case IDC_PRESENTATION_MODE: TogglePresentationMode(); break; |
2506 #endif | 2520 #endif |
2507 case IDC_EXIT: Exit(); break; | 2521 case IDC_EXIT: Exit(); break; |
2508 | 2522 |
2509 // Page-related commands | 2523 // Page-related commands |
2510 case IDC_SAVE_PAGE: SavePage(); break; | 2524 case IDC_SAVE_PAGE: SavePage(); break; |
2511 case IDC_BOOKMARK_PAGE: BookmarkCurrentPage(); break; | 2525 case IDC_BOOKMARK_PAGE: BookmarkCurrentPage(); break; |
2512 case IDC_PIN_TO_START_SCREEN: PinCurrentPageToStartScreen(); break; | 2526 case IDC_PIN_TO_START_SCREEN: PinCurrentPageToStartScreen(); break; |
2513 case IDC_BOOKMARK_ALL_TABS: BookmarkAllTabs(); break; | 2527 case IDC_BOOKMARK_ALL_TABS: BookmarkAllTabs(); break; |
(...skipping 1638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4152 command_updater_.UpdateCommandEnabled(IDC_MOVE_TAB_PREVIOUS, normal_window); | 4166 command_updater_.UpdateCommandEnabled(IDC_MOVE_TAB_PREVIOUS, normal_window); |
4153 command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_0, normal_window); | 4167 command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_0, normal_window); |
4154 command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_1, normal_window); | 4168 command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_1, normal_window); |
4155 command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_2, normal_window); | 4169 command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_2, normal_window); |
4156 command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_3, normal_window); | 4170 command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_3, normal_window); |
4157 command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_4, normal_window); | 4171 command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_4, normal_window); |
4158 command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_5, normal_window); | 4172 command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_5, normal_window); |
4159 command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_6, normal_window); | 4173 command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_6, normal_window); |
4160 command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_7, normal_window); | 4174 command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_7, normal_window); |
4161 command_updater_.UpdateCommandEnabled(IDC_SELECT_LAST_TAB, normal_window); | 4175 command_updater_.UpdateCommandEnabled(IDC_SELECT_LAST_TAB, normal_window); |
| 4176 #if defined(OS_WIN) |
| 4177 const bool metro_mode = (base::win::GetMetroModule() != NULL); |
| 4178 command_updater_.UpdateCommandEnabled(IDC_METRO_SNAP_ENABLE, metro_mode); |
| 4179 command_updater_.UpdateCommandEnabled(IDC_METRO_SNAP_DISABLE, metro_mode); |
| 4180 #endif |
4162 #if defined(OS_MACOSX) | 4181 #if defined(OS_MACOSX) |
4163 command_updater_.UpdateCommandEnabled(IDC_TABPOSE, normal_window); | 4182 command_updater_.UpdateCommandEnabled(IDC_TABPOSE, normal_window); |
4164 command_updater_.UpdateCommandEnabled(IDC_PRESENTATION_MODE, | 4183 command_updater_.UpdateCommandEnabled(IDC_PRESENTATION_MODE, |
4165 !(is_type_panel() && is_app())); | 4184 !(is_type_panel() && is_app())); |
4166 #endif | 4185 #endif |
4167 | 4186 |
4168 // Clipboard commands | 4187 // Clipboard commands |
4169 command_updater_.UpdateCommandEnabled(IDC_COPY_URL, !is_devtools()); | 4188 command_updater_.UpdateCommandEnabled(IDC_COPY_URL, !is_devtools()); |
4170 | 4189 |
4171 // Find-in-page | 4190 // Find-in-page |
(...skipping 11 matching lines...) Expand all Loading... |
4183 command_updater_.UpdateCommandEnabled(IDC_VIEW_INCOMPATIBILITIES, true); | 4202 command_updater_.UpdateCommandEnabled(IDC_VIEW_INCOMPATIBILITIES, true); |
4184 | 4203 |
4185 // View Background Pages entry is always enabled, but is hidden if there are | 4204 // View Background Pages entry is always enabled, but is hidden if there are |
4186 // no background pages. | 4205 // no background pages. |
4187 command_updater_.UpdateCommandEnabled(IDC_VIEW_BACKGROUND_PAGES, true); | 4206 command_updater_.UpdateCommandEnabled(IDC_VIEW_BACKGROUND_PAGES, true); |
4188 | 4207 |
4189 // Toggle speech input | 4208 // Toggle speech input |
4190 command_updater_.UpdateCommandEnabled(IDC_TOGGLE_SPEECH_INPUT, true); | 4209 command_updater_.UpdateCommandEnabled(IDC_TOGGLE_SPEECH_INPUT, true); |
4191 | 4210 |
4192 // Initialize other commands whose state changes based on fullscreen mode. | 4211 // Initialize other commands whose state changes based on fullscreen mode. |
4193 UpdateCommandsForFullscreenMode(false); | 4212 UpdateCommandsForFullscreenMode(FULLSCREEN_DISABLED); |
4194 | 4213 |
4195 UpdateCommandsForContentRestrictionState(); | 4214 UpdateCommandsForContentRestrictionState(); |
4196 | 4215 |
4197 UpdateCommandsForBookmarkEditing(); | 4216 UpdateCommandsForBookmarkEditing(); |
4198 | 4217 |
4199 UpdateCommandsForIncognitoAvailability(); | 4218 UpdateCommandsForIncognitoAvailability(); |
4200 } | 4219 } |
4201 | 4220 |
4202 void Browser::UpdateCommandsForIncognitoAvailability() { | 4221 void Browser::UpdateCommandsForIncognitoAvailability() { |
4203 IncognitoModePrefs::Availability incognito_availability = | 4222 IncognitoModePrefs::Availability incognito_availability = |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4323 command_updater_.UpdateCommandEnabled(IDC_SHOW_BOOKMARK_BAR, | 4342 command_updater_.UpdateCommandEnabled(IDC_SHOW_BOOKMARK_BAR, |
4324 browser_defaults::bookmarks_enabled && | 4343 browser_defaults::bookmarks_enabled && |
4325 !profile_->GetPrefs()->IsManagedPreference(prefs::kShowBookmarkBar) && | 4344 !profile_->GetPrefs()->IsManagedPreference(prefs::kShowBookmarkBar) && |
4326 show_main_ui); | 4345 show_main_ui); |
4327 } | 4346 } |
4328 | 4347 |
4329 void Browser::MarkHomePageAsChanged(PrefService* pref_service) { | 4348 void Browser::MarkHomePageAsChanged(PrefService* pref_service) { |
4330 pref_service->SetBoolean(prefs::kHomePageChanged, true); | 4349 pref_service->SetBoolean(prefs::kHomePageChanged, true); |
4331 } | 4350 } |
4332 | 4351 |
4333 void Browser::UpdateCommandsForFullscreenMode(bool is_fullscreen) { | 4352 void Browser::UpdateCommandsForFullscreenMode(FullScreenMode fullscreen_mode) { |
4334 const bool show_main_ui = IsShowingMainUI(is_fullscreen); | 4353 const bool show_main_ui = |
4335 bool main_not_fullscreen = show_main_ui && !is_fullscreen; | 4354 IsShowingMainUI(fullscreen_mode != FULLSCREEN_DISABLED); |
| 4355 bool main_not_fullscreen = show_main_ui && |
| 4356 (fullscreen_mode == FULLSCREEN_DISABLED); |
4336 | 4357 |
4337 // Navigation commands | 4358 // Navigation commands |
4338 command_updater_.UpdateCommandEnabled(IDC_OPEN_CURRENT_URL, show_main_ui); | 4359 command_updater_.UpdateCommandEnabled(IDC_OPEN_CURRENT_URL, show_main_ui); |
4339 | 4360 |
4340 // Window management commands | 4361 // Window management commands |
4341 command_updater_.UpdateCommandEnabled(IDC_SHOW_AS_TAB, | 4362 command_updater_.UpdateCommandEnabled(IDC_SHOW_AS_TAB, |
4342 type_ != TYPE_TABBED && !is_fullscreen); | 4363 type_ != TYPE_TABBED && (fullscreen_mode == FULLSCREEN_DISABLED)); |
4343 | 4364 |
4344 // Focus various bits of UI | 4365 // Focus various bits of UI |
4345 command_updater_.UpdateCommandEnabled(IDC_FOCUS_TOOLBAR, show_main_ui); | 4366 command_updater_.UpdateCommandEnabled(IDC_FOCUS_TOOLBAR, show_main_ui); |
4346 command_updater_.UpdateCommandEnabled(IDC_FOCUS_LOCATION, show_main_ui); | 4367 command_updater_.UpdateCommandEnabled(IDC_FOCUS_LOCATION, show_main_ui); |
4347 command_updater_.UpdateCommandEnabled(IDC_FOCUS_SEARCH, show_main_ui); | 4368 command_updater_.UpdateCommandEnabled(IDC_FOCUS_SEARCH, show_main_ui); |
4348 command_updater_.UpdateCommandEnabled( | 4369 command_updater_.UpdateCommandEnabled( |
4349 IDC_FOCUS_MENU_BAR, main_not_fullscreen); | 4370 IDC_FOCUS_MENU_BAR, main_not_fullscreen); |
4350 command_updater_.UpdateCommandEnabled( | 4371 command_updater_.UpdateCommandEnabled( |
4351 IDC_FOCUS_NEXT_PANE, main_not_fullscreen); | 4372 IDC_FOCUS_NEXT_PANE, main_not_fullscreen); |
4352 command_updater_.UpdateCommandEnabled( | 4373 command_updater_.UpdateCommandEnabled( |
(...skipping 16 matching lines...) Expand all Loading... |
4369 command_updater_.UpdateCommandEnabled(IDC_IMPORT_SETTINGS, options_enabled); | 4390 command_updater_.UpdateCommandEnabled(IDC_IMPORT_SETTINGS, options_enabled); |
4370 | 4391 |
4371 command_updater_.UpdateCommandEnabled(IDC_EDIT_SEARCH_ENGINES, show_main_ui); | 4392 command_updater_.UpdateCommandEnabled(IDC_EDIT_SEARCH_ENGINES, show_main_ui); |
4372 command_updater_.UpdateCommandEnabled(IDC_VIEW_PASSWORDS, show_main_ui); | 4393 command_updater_.UpdateCommandEnabled(IDC_VIEW_PASSWORDS, show_main_ui); |
4373 command_updater_.UpdateCommandEnabled(IDC_ABOUT, show_main_ui); | 4394 command_updater_.UpdateCommandEnabled(IDC_ABOUT, show_main_ui); |
4374 command_updater_.UpdateCommandEnabled(IDC_SHOW_APP_MENU, show_main_ui); | 4395 command_updater_.UpdateCommandEnabled(IDC_SHOW_APP_MENU, show_main_ui); |
4375 #if defined (ENABLE_PROFILING) && !defined(NO_TCMALLOC) | 4396 #if defined (ENABLE_PROFILING) && !defined(NO_TCMALLOC) |
4376 command_updater_.UpdateCommandEnabled(IDC_PROFILING_ENABLED, show_main_ui); | 4397 command_updater_.UpdateCommandEnabled(IDC_PROFILING_ENABLED, show_main_ui); |
4377 #endif | 4398 #endif |
4378 | 4399 |
| 4400 // Disable explicit fullscreen toggling when in metro snap mode. |
| 4401 command_updater_.UpdateCommandEnabled( |
| 4402 IDC_FULLSCREEN, |
| 4403 fullscreen_mode != FULLSCREEN_METRO_SNAP); |
| 4404 |
4379 UpdateCommandsForBookmarkBar(); | 4405 UpdateCommandsForBookmarkBar(); |
4380 UpdateCommandsForMultipleProfiles(); | 4406 UpdateCommandsForMultipleProfiles(); |
4381 } | 4407 } |
4382 | 4408 |
4383 void Browser::UpdateCommandsForMultipleProfiles() { | 4409 void Browser::UpdateCommandsForMultipleProfiles() { |
4384 bool show_main_ui = IsShowingMainUI(window_ && window_->IsFullscreen()); | 4410 bool show_main_ui = IsShowingMainUI(window_ && window_->IsFullscreen()); |
4385 command_updater_.UpdateCommandEnabled(IDC_SHOW_AVATAR_MENU, | 4411 command_updater_.UpdateCommandEnabled(IDC_SHOW_AVATAR_MENU, |
4386 show_main_ui && | 4412 show_main_ui && |
4387 !profile()->IsOffTheRecord() && | 4413 !profile()->IsOffTheRecord() && |
4388 ProfileManager::IsMultipleProfilesEnabled()); | 4414 ProfileManager::IsMultipleProfilesEnabled()); |
(...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5188 if (contents && !allow_js_access) { | 5214 if (contents && !allow_js_access) { |
5189 contents->web_contents()->GetController().LoadURL( | 5215 contents->web_contents()->GetController().LoadURL( |
5190 target_url, | 5216 target_url, |
5191 content::Referrer(), | 5217 content::Referrer(), |
5192 content::PAGE_TRANSITION_LINK, | 5218 content::PAGE_TRANSITION_LINK, |
5193 std::string()); // No extra headers. | 5219 std::string()); // No extra headers. |
5194 } | 5220 } |
5195 | 5221 |
5196 return contents != NULL; | 5222 return contents != NULL; |
5197 } | 5223 } |
OLD | NEW |