| 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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 #include "chrome/browser/ui/status_bubble.h" | 125 #include "chrome/browser/ui/status_bubble.h" |
| 126 #include "chrome/browser/ui/sync/browser_synced_window_delegate.h" | 126 #include "chrome/browser/ui/sync/browser_synced_window_delegate.h" |
| 127 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" | 127 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" |
| 128 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 128 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 129 #include "chrome/browser/ui/tabs/dock_info.h" | 129 #include "chrome/browser/ui/tabs/dock_info.h" |
| 130 #include "chrome/browser/ui/tabs/tab_menu_model.h" | 130 #include "chrome/browser/ui/tabs/tab_menu_model.h" |
| 131 #include "chrome/browser/ui/web_applications/web_app_ui.h" | 131 #include "chrome/browser/ui/web_applications/web_app_ui.h" |
| 132 #include "chrome/browser/ui/webui/feedback_ui.h" | 132 #include "chrome/browser/ui/webui/feedback_ui.h" |
| 133 #include "chrome/browser/ui/webui/ntp/new_tab_page_handler.h" | 133 #include "chrome/browser/ui/webui/ntp/new_tab_page_handler.h" |
| 134 #include "chrome/browser/ui/webui/options/content_settings_handler.h" | 134 #include "chrome/browser/ui/webui/options/content_settings_handler.h" |
| 135 #include "chrome/browser/ui/webui/signin/login_ui_service.h" |
| 136 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" |
| 135 #include "chrome/browser/ui/webui/sync_promo/sync_promo_ui.h" | 137 #include "chrome/browser/ui/webui/sync_promo/sync_promo_ui.h" |
| 136 #include "chrome/browser/ui/window_sizer.h" | 138 #include "chrome/browser/ui/window_sizer.h" |
| 137 #include "chrome/browser/upgrade_detector.h" | 139 #include "chrome/browser/upgrade_detector.h" |
| 138 #include "chrome/browser/web_applications/web_app.h" | 140 #include "chrome/browser/web_applications/web_app.h" |
| 139 #include "chrome/common/chrome_constants.h" | 141 #include "chrome/common/chrome_constants.h" |
| 140 #include "chrome/common/chrome_notification_types.h" | 142 #include "chrome/common/chrome_notification_types.h" |
| 141 #include "chrome/common/chrome_switches.h" | 143 #include "chrome/common/chrome_switches.h" |
| 142 #include "chrome/common/custom_handlers/protocol_handler.h" | 144 #include "chrome/common/custom_handlers/protocol_handler.h" |
| 143 #include "chrome/common/extensions/extension.h" | 145 #include "chrome/common/extensions/extension.h" |
| 144 #include "chrome/common/extensions/extension_constants.h" | 146 #include "chrome/common/extensions/extension_constants.h" |
| (...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 924 } | 926 } |
| 925 | 927 |
| 926 // static | 928 // static |
| 927 void Browser::OpenOptionsWindow(Profile* profile) { | 929 void Browser::OpenOptionsWindow(Profile* profile) { |
| 928 Browser* browser = Browser::Create(profile); | 930 Browser* browser = Browser::Create(profile); |
| 929 browser->OpenOptionsDialog(); | 931 browser->OpenOptionsDialog(); |
| 930 browser->window()->Show(); | 932 browser->window()->Show(); |
| 931 } | 933 } |
| 932 | 934 |
| 933 // static | 935 // static |
| 936 void Browser::OpenSyncSetupWindow(Profile* profile) { |
| 937 Browser* browser = Browser::Create(profile); |
| 938 browser->ShowSyncSetup(); |
| 939 browser->window()->Show(); |
| 940 } |
| 941 |
| 942 // static |
| 934 void Browser::OpenClearBrowsingDataDialogWindow(Profile* profile) { | 943 void Browser::OpenClearBrowsingDataDialogWindow(Profile* profile) { |
| 935 Browser* browser = Browser::Create(profile); | 944 Browser* browser = Browser::Create(profile); |
| 936 browser->OpenClearBrowsingDataDialog(); | 945 browser->OpenClearBrowsingDataDialog(); |
| 937 browser->window()->Show(); | 946 browser->window()->Show(); |
| 938 } | 947 } |
| 939 | 948 |
| 940 // static | 949 // static |
| 941 void Browser::OpenImportSettingsDialogWindow(Profile* profile) { | 950 void Browser::OpenImportSettingsDialogWindow(Profile* profile) { |
| 942 Browser* browser = Browser::Create(profile); | 951 Browser* browser = Browser::Create(profile); |
| 943 browser->OpenImportSettingsDialog(); | 952 browser->OpenImportSettingsDialog(); |
| (...skipping 1423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2367 | 2376 |
| 2368 void Browser::OpenImportSettingsDialog() { | 2377 void Browser::OpenImportSettingsDialog() { |
| 2369 content::RecordAction(UserMetricsAction("Import_ShowDlg")); | 2378 content::RecordAction(UserMetricsAction("Import_ShowDlg")); |
| 2370 ShowOptionsTab(chrome::kImportDataSubPage); | 2379 ShowOptionsTab(chrome::kImportDataSubPage); |
| 2371 } | 2380 } |
| 2372 | 2381 |
| 2373 void Browser::OpenInstantConfirmDialog() { | 2382 void Browser::OpenInstantConfirmDialog() { |
| 2374 ShowOptionsTab(chrome::kInstantConfirmPage); | 2383 ShowOptionsTab(chrome::kInstantConfirmPage); |
| 2375 } | 2384 } |
| 2376 | 2385 |
| 2377 void Browser::OpenSyncMyBookmarksDialog() { | |
| 2378 sync_ui_util::OpenSyncMyBookmarksDialog( | |
| 2379 profile_, this, ProfileSyncService::START_FROM_WRENCH); | |
| 2380 } | |
| 2381 | |
| 2382 void Browser::OpenAboutChromeDialog() { | 2386 void Browser::OpenAboutChromeDialog() { |
| 2383 content::RecordAction(UserMetricsAction("AboutChrome")); | 2387 content::RecordAction(UserMetricsAction("AboutChrome")); |
| 2384 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableUberPage)) { | 2388 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableUberPage)) { |
| 2385 #if defined(OS_CHROMEOS) | 2389 #if defined(OS_CHROMEOS) |
| 2386 std::string chrome_settings(chrome::kChromeUISettingsURL); | 2390 std::string chrome_settings(chrome::kChromeUISettingsURL); |
| 2387 ShowSingletonTab( | 2391 ShowSingletonTab( |
| 2388 GURL(chrome_settings.append(chrome::kAboutOptionsSubPage))); | 2392 GURL(chrome_settings.append(chrome::kAboutOptionsSubPage))); |
| 2389 #else | 2393 #else |
| 2390 window_->ShowAboutChromeDialog(); | 2394 window_->ShowAboutChromeDialog(); |
| 2391 #endif | 2395 #endif |
| (...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3062 | 3066 |
| 3063 case IDC_SHOW_BOOKMARK_BAR: ToggleBookmarkBar(); break; | 3067 case IDC_SHOW_BOOKMARK_BAR: ToggleBookmarkBar(); break; |
| 3064 case IDC_PROFILING_ENABLED: Profiling::Toggle(); break; | 3068 case IDC_PROFILING_ENABLED: Profiling::Toggle(); break; |
| 3065 | 3069 |
| 3066 case IDC_SHOW_BOOKMARK_MANAGER: OpenBookmarkManager(); break; | 3070 case IDC_SHOW_BOOKMARK_MANAGER: OpenBookmarkManager(); break; |
| 3067 case IDC_SHOW_APP_MENU: ShowAppMenu(); break; | 3071 case IDC_SHOW_APP_MENU: ShowAppMenu(); break; |
| 3068 case IDC_SHOW_AVATAR_MENU: ShowAvatarMenu(); break; | 3072 case IDC_SHOW_AVATAR_MENU: ShowAvatarMenu(); break; |
| 3069 case IDC_SHOW_HISTORY: ShowHistoryTab(); break; | 3073 case IDC_SHOW_HISTORY: ShowHistoryTab(); break; |
| 3070 case IDC_SHOW_DOWNLOADS: ShowDownloadsTab(); break; | 3074 case IDC_SHOW_DOWNLOADS: ShowDownloadsTab(); break; |
| 3071 case IDC_MANAGE_EXTENSIONS: ShowExtensionsTab(); break; | 3075 case IDC_MANAGE_EXTENSIONS: ShowExtensionsTab(); break; |
| 3072 case IDC_SYNC_BOOKMARKS: OpenSyncMyBookmarksDialog(); break; | |
| 3073 case IDC_OPTIONS: OpenOptionsDialog(); break; | 3076 case IDC_OPTIONS: OpenOptionsDialog(); break; |
| 3074 case IDC_EDIT_SEARCH_ENGINES: OpenSearchEngineOptionsDialog(); break; | 3077 case IDC_EDIT_SEARCH_ENGINES: OpenSearchEngineOptionsDialog(); break; |
| 3075 case IDC_VIEW_PASSWORDS: OpenPasswordManager(); break; | 3078 case IDC_VIEW_PASSWORDS: OpenPasswordManager(); break; |
| 3076 case IDC_CLEAR_BROWSING_DATA: OpenClearBrowsingDataDialog(); break; | 3079 case IDC_CLEAR_BROWSING_DATA: OpenClearBrowsingDataDialog(); break; |
| 3077 case IDC_IMPORT_SETTINGS: OpenImportSettingsDialog(); break; | 3080 case IDC_IMPORT_SETTINGS: OpenImportSettingsDialog(); break; |
| 3078 case IDC_ABOUT: OpenAboutChromeDialog(); break; | 3081 case IDC_ABOUT: OpenAboutChromeDialog(); break; |
| 3079 case IDC_UPGRADE_DIALOG: OpenUpdateChromeDialog(); break; | 3082 case IDC_UPGRADE_DIALOG: OpenUpdateChromeDialog(); break; |
| 3080 case IDC_VIEW_INCOMPATIBILITIES: ShowAboutConflictsTab(); break; | 3083 case IDC_VIEW_INCOMPATIBILITIES: ShowAboutConflictsTab(); break; |
| 3081 case IDC_HELP_PAGE: ShowHelpTab(); break; | 3084 case IDC_HELP_PAGE: ShowHelpTab(); break; |
| 3082 #if defined(OS_CHROMEOS) | 3085 #if defined(OS_CHROMEOS) |
| (...skipping 1366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4449 /////////////////////////////////////////////////////////////////////////////// | 4452 /////////////////////////////////////////////////////////////////////////////// |
| 4450 // Browser, ProfileSyncServiceObserver implementation: | 4453 // Browser, ProfileSyncServiceObserver implementation: |
| 4451 | 4454 |
| 4452 void Browser::OnStateChanged() { | 4455 void Browser::OnStateChanged() { |
| 4453 DCHECK(ProfileSyncServiceFactory::GetInstance()->HasProfileSyncService( | 4456 DCHECK(ProfileSyncServiceFactory::GetInstance()->HasProfileSyncService( |
| 4454 profile_)); | 4457 profile_)); |
| 4455 // For unit tests, we don't have a window. | 4458 // For unit tests, we don't have a window. |
| 4456 if (!window_) | 4459 if (!window_) |
| 4457 return; | 4460 return; |
| 4458 const bool show_main_ui = IsShowingMainUI(window_->IsFullscreen()); | 4461 const bool show_main_ui = IsShowingMainUI(window_->IsFullscreen()); |
| 4459 command_updater_.UpdateCommandEnabled(IDC_SYNC_BOOKMARKS, | 4462 command_updater_.UpdateCommandEnabled(IDC_SHOW_SYNC_SETUP, |
| 4460 show_main_ui && profile_->GetOriginalProfile()->IsSyncAccessible()); | 4463 show_main_ui && profile_->GetOriginalProfile()->IsSyncAccessible()); |
| 4461 } | 4464 } |
| 4462 | 4465 |
| 4463 /////////////////////////////////////////////////////////////////////////////// | 4466 /////////////////////////////////////////////////////////////////////////////// |
| 4464 // Browser, InstantDelegate implementation: | 4467 // Browser, InstantDelegate implementation: |
| 4465 | 4468 |
| 4466 void Browser::ShowInstant(TabContentsWrapper* preview_contents) { | 4469 void Browser::ShowInstant(TabContentsWrapper* preview_contents) { |
| 4467 DCHECK(instant_->tab_contents() == GetSelectedTabContentsWrapper()); | 4470 DCHECK(instant_->tab_contents() == GetSelectedTabContentsWrapper()); |
| 4468 window_->ShowInstant(preview_contents); | 4471 window_->ShowInstant(preview_contents); |
| 4469 | 4472 |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4785 command_updater_.UpdateCommandEnabled( | 4788 command_updater_.UpdateCommandEnabled( |
| 4786 IDC_FOCUS_PREVIOUS_PANE, main_not_fullscreen); | 4789 IDC_FOCUS_PREVIOUS_PANE, main_not_fullscreen); |
| 4787 command_updater_.UpdateCommandEnabled( | 4790 command_updater_.UpdateCommandEnabled( |
| 4788 IDC_FOCUS_BOOKMARKS, main_not_fullscreen); | 4791 IDC_FOCUS_BOOKMARKS, main_not_fullscreen); |
| 4789 command_updater_.UpdateCommandEnabled( | 4792 command_updater_.UpdateCommandEnabled( |
| 4790 IDC_FOCUS_CHROMEOS_STATUS, main_not_fullscreen); | 4793 IDC_FOCUS_CHROMEOS_STATUS, main_not_fullscreen); |
| 4791 | 4794 |
| 4792 // Show various bits of UI | 4795 // Show various bits of UI |
| 4793 command_updater_.UpdateCommandEnabled(IDC_DEVELOPER_MENU, show_main_ui); | 4796 command_updater_.UpdateCommandEnabled(IDC_DEVELOPER_MENU, show_main_ui); |
| 4794 command_updater_.UpdateCommandEnabled(IDC_FEEDBACK, show_main_ui); | 4797 command_updater_.UpdateCommandEnabled(IDC_FEEDBACK, show_main_ui); |
| 4795 command_updater_.UpdateCommandEnabled(IDC_SYNC_BOOKMARKS, | 4798 command_updater_.UpdateCommandEnabled(IDC_SHOW_SYNC_SETUP, |
| 4796 show_main_ui && profile_->GetOriginalProfile()->IsSyncAccessible()); | 4799 show_main_ui && profile_->GetOriginalProfile()->IsSyncAccessible()); |
| 4797 | 4800 |
| 4798 // Settings page/subpages are forced to open in normal mode. We disable these | 4801 // Settings page/subpages are forced to open in normal mode. We disable these |
| 4799 // commands when incognito is forced. | 4802 // commands when incognito is forced. |
| 4800 const bool options_enabled = show_main_ui && | 4803 const bool options_enabled = show_main_ui && |
| 4801 IncognitoModePrefs::GetAvailability( | 4804 IncognitoModePrefs::GetAvailability( |
| 4802 profile_->GetPrefs()) != IncognitoModePrefs::FORCED; | 4805 profile_->GetPrefs()) != IncognitoModePrefs::FORCED; |
| 4803 command_updater_.UpdateCommandEnabled(IDC_OPTIONS, options_enabled); | 4806 command_updater_.UpdateCommandEnabled(IDC_OPTIONS, options_enabled); |
| 4804 command_updater_.UpdateCommandEnabled(IDC_IMPORT_SETTINGS, options_enabled); | 4807 command_updater_.UpdateCommandEnabled(IDC_IMPORT_SETTINGS, options_enabled); |
| 4805 | 4808 |
| (...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5561 (reason == BOOKMARK_BAR_STATE_CHANGE_PREF_CHANGE) ? | 5564 (reason == BOOKMARK_BAR_STATE_CHANGE_PREF_CHANGE) ? |
| 5562 BookmarkBar::ANIMATE_STATE_CHANGE : | 5565 BookmarkBar::ANIMATE_STATE_CHANGE : |
| 5563 BookmarkBar::DONT_ANIMATE_STATE_CHANGE; | 5566 BookmarkBar::DONT_ANIMATE_STATE_CHANGE; |
| 5564 window_->BookmarkBarStateChanged(animate_type); | 5567 window_->BookmarkBarStateChanged(animate_type); |
| 5565 } | 5568 } |
| 5566 | 5569 |
| 5567 void Browser::ShowSyncSetup() { | 5570 void Browser::ShowSyncSetup() { |
| 5568 ProfileSyncService* service = | 5571 ProfileSyncService* service = |
| 5569 ProfileSyncServiceFactory::GetInstance()->GetForProfile( | 5572 ProfileSyncServiceFactory::GetInstance()->GetForProfile( |
| 5570 profile()->GetOriginalProfile()); | 5573 profile()->GetOriginalProfile()); |
| 5574 LoginUIService* login_service = |
| 5575 LoginUIServiceFactory::GetForProfile(profile()->GetOriginalProfile()); |
| 5571 if (service->HasSyncSetupCompleted()) { | 5576 if (service->HasSyncSetupCompleted()) { |
| 5572 ShowOptionsTab(chrome::kPersonalOptionsSubPage); | 5577 ShowOptionsTab(chrome::kPersonalOptionsSubPage); |
| 5573 } else if (SyncPromoUI::ShouldShowSyncPromo(profile())) { | 5578 } else if (SyncPromoUI::ShouldShowSyncPromo(profile()) && |
| 5579 login_service->current_login_ui() == NULL) { |
| 5580 // There is no currently active login UI, so display a new promo page. |
| 5574 GURL url(SyncPromoUI::GetSyncPromoURL(GURL(), false, std::string())); | 5581 GURL url(SyncPromoUI::GetSyncPromoURL(GURL(), false, std::string())); |
| 5575 browser::NavigateParams params(GetSingletonTabNavigateParams(GURL(url))); | 5582 browser::NavigateParams params(GetSingletonTabNavigateParams(GURL(url))); |
| 5576 params.path_behavior = browser::NavigateParams::IGNORE_AND_NAVIGATE; | 5583 params.path_behavior = browser::NavigateParams::IGNORE_AND_NAVIGATE; |
| 5577 ShowSingletonTabOverwritingNTP(params); | 5584 ShowSingletonTabOverwritingNTP(params); |
| 5578 } else { | 5585 } else { |
| 5579 service->ShowLoginDialog(); | 5586 LoginUIServiceFactory::GetForProfile( |
| 5587 profile()->GetOriginalProfile())->ShowLoginUI(); |
| 5580 } | 5588 } |
| 5581 } | 5589 } |
| 5582 | 5590 |
| 5583 void Browser::ToggleSpeechInput() { | 5591 void Browser::ToggleSpeechInput() { |
| 5584 GetSelectedWebContents()->GetRenderViewHost()->ToggleSpeechInput(); | 5592 GetSelectedWebContents()->GetRenderViewHost()->ToggleSpeechInput(); |
| 5585 } | 5593 } |
| OLD | NEW |