OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 "app/animation.h" | 7 #include "app/animation.h" |
8 #include "app/l10n_util.h" | 8 #include "app/l10n_util.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/keyboard_codes.h" | 10 #include "base/keyboard_codes.h" |
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
646 command_updater_.UpdateCommandEnabled(IDC_FOCUS_TOOLBAR, show_main_ui); | 646 command_updater_.UpdateCommandEnabled(IDC_FOCUS_TOOLBAR, show_main_ui); |
647 command_updater_.UpdateCommandEnabled(IDC_FOCUS_LOCATION, show_main_ui); | 647 command_updater_.UpdateCommandEnabled(IDC_FOCUS_LOCATION, show_main_ui); |
648 command_updater_.UpdateCommandEnabled(IDC_FOCUS_SEARCH, show_main_ui); | 648 command_updater_.UpdateCommandEnabled(IDC_FOCUS_SEARCH, show_main_ui); |
649 | 649 |
650 // Show various bits of UI | 650 // Show various bits of UI |
651 command_updater_.UpdateCommandEnabled(IDC_DEVELOPER_MENU, show_main_ui); | 651 command_updater_.UpdateCommandEnabled(IDC_DEVELOPER_MENU, show_main_ui); |
652 command_updater_.UpdateCommandEnabled(IDC_NEW_PROFILE, show_main_ui); | 652 command_updater_.UpdateCommandEnabled(IDC_NEW_PROFILE, show_main_ui); |
653 command_updater_.UpdateCommandEnabled(IDC_REPORT_BUG, show_main_ui); | 653 command_updater_.UpdateCommandEnabled(IDC_REPORT_BUG, show_main_ui); |
654 command_updater_.UpdateCommandEnabled(IDC_SHOW_BOOKMARK_BAR, show_main_ui); | 654 command_updater_.UpdateCommandEnabled(IDC_SHOW_BOOKMARK_BAR, show_main_ui); |
655 command_updater_.UpdateCommandEnabled(IDC_IMPORT_SETTINGS, show_main_ui); | 655 command_updater_.UpdateCommandEnabled(IDC_IMPORT_SETTINGS, show_main_ui); |
656 #if defined(BROWSER_SYNC) | |
657 command_updater_.UpdateCommandEnabled( | 656 command_updater_.UpdateCommandEnabled( |
658 IDC_SYNC_BOOKMARKS, | 657 IDC_SYNC_BOOKMARKS, |
659 show_main_ui && profile_->GetProfileSyncService() != NULL); | 658 show_main_ui && profile_->GetProfileSyncService() != NULL); |
660 #endif | |
661 command_updater_.UpdateCommandEnabled(IDC_OPTIONS, show_main_ui); | 659 command_updater_.UpdateCommandEnabled(IDC_OPTIONS, show_main_ui); |
662 command_updater_.UpdateCommandEnabled(IDC_EDIT_SEARCH_ENGINES, show_main_ui); | 660 command_updater_.UpdateCommandEnabled(IDC_EDIT_SEARCH_ENGINES, show_main_ui); |
663 command_updater_.UpdateCommandEnabled(IDC_VIEW_PASSWORDS, show_main_ui); | 661 command_updater_.UpdateCommandEnabled(IDC_VIEW_PASSWORDS, show_main_ui); |
664 command_updater_.UpdateCommandEnabled(IDC_ABOUT, show_main_ui); | 662 command_updater_.UpdateCommandEnabled(IDC_ABOUT, show_main_ui); |
665 command_updater_.UpdateCommandEnabled(IDC_SHOW_APP_MENU, show_main_ui); | 663 command_updater_.UpdateCommandEnabled(IDC_SHOW_APP_MENU, show_main_ui); |
666 command_updater_.UpdateCommandEnabled(IDC_SHOW_PAGE_MENU, show_main_ui); | 664 command_updater_.UpdateCommandEnabled(IDC_SHOW_PAGE_MENU, show_main_ui); |
667 } | 665 } |
668 | 666 |
669 /////////////////////////////////////////////////////////////////////////////// | 667 /////////////////////////////////////////////////////////////////////////////// |
670 // Browser, Assorted browser commands: | 668 // Browser, Assorted browser commands: |
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1195 | 1193 |
1196 void Browser::OpenPasswordManager() { | 1194 void Browser::OpenPasswordManager() { |
1197 window_->ShowPasswordManager(); | 1195 window_->ShowPasswordManager(); |
1198 } | 1196 } |
1199 | 1197 |
1200 void Browser::OpenImportSettingsDialog() { | 1198 void Browser::OpenImportSettingsDialog() { |
1201 UserMetrics::RecordAction(L"Import_ShowDlg", profile_); | 1199 UserMetrics::RecordAction(L"Import_ShowDlg", profile_); |
1202 window_->ShowImportDialog(); | 1200 window_->ShowImportDialog(); |
1203 } | 1201 } |
1204 | 1202 |
1205 #if defined(BROWSER_SYNC) | |
1206 void Browser::OpenSyncMyBookmarksDialog() { | 1203 void Browser::OpenSyncMyBookmarksDialog() { |
1207 ProfileSyncService* service = profile_->GetProfileSyncService(); | 1204 ProfileSyncService* service = profile_->GetProfileSyncService(); |
1208 // TODO(timsteele): Incognito has no sync service for the time being, | 1205 // TODO(timsteele): Incognito has no sync service for the time being, |
1209 // so protect against this case. | 1206 // so protect against this case. |
1210 if (!service) | 1207 if (!service) |
1211 return; | 1208 return; |
1212 if (service->HasSyncSetupCompleted()) { | 1209 if (service->HasSyncSetupCompleted()) { |
1213 ShowOptionsWindow(OPTIONS_PAGE_CONTENT, OPTIONS_GROUP_NONE, profile_); | 1210 ShowOptionsWindow(OPTIONS_PAGE_CONTENT, OPTIONS_GROUP_NONE, profile_); |
1214 } else { | 1211 } else { |
1215 service->EnableForUser(); | 1212 service->EnableForUser(); |
1216 ProfileSyncService::SyncEvent(ProfileSyncService::START_FROM_WRENCH); | 1213 ProfileSyncService::SyncEvent(ProfileSyncService::START_FROM_WRENCH); |
1217 } | 1214 } |
1218 } | 1215 } |
1219 #endif // defined(BROWSER_SYNC) | |
1220 | 1216 |
1221 void Browser::OpenAboutChromeDialog() { | 1217 void Browser::OpenAboutChromeDialog() { |
1222 UserMetrics::RecordAction(L"AboutChrome", profile_); | 1218 UserMetrics::RecordAction(L"AboutChrome", profile_); |
1223 window_->ShowAboutChromeDialog(); | 1219 window_->ShowAboutChromeDialog(); |
1224 } | 1220 } |
1225 | 1221 |
1226 void Browser::OpenHelpTab() { | 1222 void Browser::OpenHelpTab() { |
1227 GURL help_url(WideToASCII(l10n_util::GetString(IDS_HELP_CONTENT_URL))); | 1223 GURL help_url(WideToASCII(l10n_util::GetString(IDS_HELP_CONTENT_URL))); |
1228 AddTabWithURL(help_url, GURL(), PageTransition::AUTO_BOOKMARK, true, -1, | 1224 AddTabWithURL(help_url, GURL(), PageTransition::AUTO_BOOKMARK, true, -1, |
1229 false, NULL); | 1225 false, NULL); |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1455 case IDC_REPORT_BUG: OpenBugReportDialog(); break; | 1451 case IDC_REPORT_BUG: OpenBugReportDialog(); break; |
1456 | 1452 |
1457 case IDC_SHOW_BOOKMARK_BAR: ToggleBookmarkBar(); break; | 1453 case IDC_SHOW_BOOKMARK_BAR: ToggleBookmarkBar(); break; |
1458 case IDC_SHOW_EXTENSION_SHELF: ToggleExtensionShelf(); break; | 1454 case IDC_SHOW_EXTENSION_SHELF: ToggleExtensionShelf(); break; |
1459 | 1455 |
1460 case IDC_SHOW_BOOKMARK_MANAGER: OpenBookmarkManager(); break; | 1456 case IDC_SHOW_BOOKMARK_MANAGER: OpenBookmarkManager(); break; |
1461 case IDC_SHOW_HISTORY: ShowHistoryTab(); break; | 1457 case IDC_SHOW_HISTORY: ShowHistoryTab(); break; |
1462 case IDC_SHOW_DOWNLOADS: ShowDownloadsTab(); break; | 1458 case IDC_SHOW_DOWNLOADS: ShowDownloadsTab(); break; |
1463 case IDC_SHOW_APP_MENU: ShowAppMenu(); break; | 1459 case IDC_SHOW_APP_MENU: ShowAppMenu(); break; |
1464 case IDC_SHOW_PAGE_MENU: ShowPageMenu(); break; | 1460 case IDC_SHOW_PAGE_MENU: ShowPageMenu(); break; |
1465 #if defined(BROWSER_SYNC) | |
1466 case IDC_SYNC_BOOKMARKS: OpenSyncMyBookmarksDialog(); break; | 1461 case IDC_SYNC_BOOKMARKS: OpenSyncMyBookmarksDialog(); break; |
1467 #endif | |
1468 case IDC_OPTIONS: OpenOptionsDialog(); break; | 1462 case IDC_OPTIONS: OpenOptionsDialog(); break; |
1469 case IDC_EDIT_SEARCH_ENGINES: OpenKeywordEditor(); break; | 1463 case IDC_EDIT_SEARCH_ENGINES: OpenKeywordEditor(); break; |
1470 case IDC_VIEW_PASSWORDS: OpenPasswordManager(); break; | 1464 case IDC_VIEW_PASSWORDS: OpenPasswordManager(); break; |
1471 case IDC_CLEAR_BROWSING_DATA: OpenClearBrowsingDataDialog(); break; | 1465 case IDC_CLEAR_BROWSING_DATA: OpenClearBrowsingDataDialog(); break; |
1472 case IDC_IMPORT_SETTINGS: OpenImportSettingsDialog(); break; | 1466 case IDC_IMPORT_SETTINGS: OpenImportSettingsDialog(); break; |
1473 case IDC_ABOUT: OpenAboutChromeDialog(); break; | 1467 case IDC_ABOUT: OpenAboutChromeDialog(); break; |
1474 case IDC_HELP_PAGE: OpenHelpTab(); break; | 1468 case IDC_HELP_PAGE: OpenHelpTab(); break; |
1475 case IDC_MANAGE_EXTENSIONS: OpenExtensionsTab(); break; | 1469 case IDC_MANAGE_EXTENSIONS: OpenExtensionsTab(); break; |
1476 #if defined(OS_CHROMEOS) | 1470 #if defined(OS_CHROMEOS) |
1477 case IDC_CONTROL_PANEL: ShowControlPanel(); break; | 1471 case IDC_CONTROL_PANEL: ShowControlPanel(); break; |
(...skipping 1491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2969 /////////////////////////////////////////////////////////////////////////////// | 2963 /////////////////////////////////////////////////////////////////////////////// |
2970 // BrowserToolbarModel (private): | 2964 // BrowserToolbarModel (private): |
2971 | 2965 |
2972 NavigationController* Browser::BrowserToolbarModel::GetNavigationController() { | 2966 NavigationController* Browser::BrowserToolbarModel::GetNavigationController() { |
2973 // This |current_tab| can be NULL during the initialization of the | 2967 // This |current_tab| can be NULL during the initialization of the |
2974 // toolbar during window creation (i.e. before any tabs have been added | 2968 // toolbar during window creation (i.e. before any tabs have been added |
2975 // to the window). | 2969 // to the window). |
2976 TabContents* current_tab = browser_->GetSelectedTabContents(); | 2970 TabContents* current_tab = browser_->GetSelectedTabContents(); |
2977 return current_tab ? ¤t_tab->controller() : NULL; | 2971 return current_tab ? ¤t_tab->controller() : NULL; |
2978 } | 2972 } |
OLD | NEW |