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