OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <shellapi.h> | 8 #include <shellapi.h> |
9 #include <windows.h> | 9 #include <windows.h> |
10 #endif // OS_WIN | 10 #endif // OS_WIN |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 #include "chrome/browser/sessions/tab_restore_service.h" | 67 #include "chrome/browser/sessions/tab_restore_service.h" |
68 #include "chrome/browser/status_bubble.h" | 68 #include "chrome/browser/status_bubble.h" |
69 #include "chrome/browser/sync/profile_sync_service.h" | 69 #include "chrome/browser/sync/profile_sync_service.h" |
70 #include "chrome/browser/sync/sync_ui_util.h" | 70 #include "chrome/browser/sync/sync_ui_util.h" |
71 #include "chrome/browser/tab_contents/interstitial_page.h" | 71 #include "chrome/browser/tab_contents/interstitial_page.h" |
72 #include "chrome/browser/tab_contents/navigation_controller.h" | 72 #include "chrome/browser/tab_contents/navigation_controller.h" |
73 #include "chrome/browser/tab_contents/navigation_entry.h" | 73 #include "chrome/browser/tab_contents/navigation_entry.h" |
74 #include "chrome/browser/tab_contents/tab_contents.h" | 74 #include "chrome/browser/tab_contents/tab_contents.h" |
75 #include "chrome/browser/tab_contents/tab_contents_view.h" | 75 #include "chrome/browser/tab_contents/tab_contents_view.h" |
76 #include "chrome/browser/tab_menu_model.h" | 76 #include "chrome/browser/tab_menu_model.h" |
| 77 #include "chrome/browser/upgrade_detector.h" |
77 #include "chrome/browser/web_applications/web_app.h" | 78 #include "chrome/browser/web_applications/web_app.h" |
78 #include "chrome/browser/window_sizer.h" | 79 #include "chrome/browser/window_sizer.h" |
79 #include "chrome/common/chrome_constants.h" | 80 #include "chrome/common/chrome_constants.h" |
80 #include "chrome/common/chrome_switches.h" | 81 #include "chrome/common/chrome_switches.h" |
81 #include "chrome/common/extensions/extension.h" | 82 #include "chrome/common/extensions/extension.h" |
82 #include "chrome/common/notification_service.h" | 83 #include "chrome/common/notification_service.h" |
83 #include "chrome/common/page_transition_types.h" | 84 #include "chrome/common/page_transition_types.h" |
84 #include "chrome/common/pref_names.h" | 85 #include "chrome/common/pref_names.h" |
85 #include "chrome/common/url_constants.h" | 86 #include "chrome/common/url_constants.h" |
86 #include "grit/chromium_strings.h" | 87 #include "grit/chromium_strings.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 | 123 |
123 // The URL to be loaded to display Help. | 124 // The URL to be loaded to display Help. |
124 static const char* const kHelpContentUrl = | 125 static const char* const kHelpContentUrl = |
125 "http://www.google.com/support/chrome/"; | 126 "http://www.google.com/support/chrome/"; |
126 | 127 |
127 // The URL to be loaded to display the "Report a broken page" form. | 128 // The URL to be loaded to display the "Report a broken page" form. |
128 static const std::string kBrokenPageUrl = | 129 static const std::string kBrokenPageUrl = |
129 "http://www.google.com/support/chrome/bin/request.py?contact_type=" | 130 "http://www.google.com/support/chrome/bin/request.py?contact_type=" |
130 "broken_website&format=inproduct&p.page_title=$1&p.page_url=$2"; | 131 "broken_website&format=inproduct&p.page_title=$1&p.page_url=$2"; |
131 | 132 |
132 | |
133 /////////////////////////////////////////////////////////////////////////////// | 133 /////////////////////////////////////////////////////////////////////////////// |
134 | 134 |
135 namespace { | 135 namespace { |
136 | 136 |
137 // Returns true if the specified TabContents has unload listeners registered. | 137 // Returns true if the specified TabContents has unload listeners registered. |
138 bool TabHasUnloadListener(TabContents* contents) { | 138 bool TabHasUnloadListener(TabContents* contents) { |
139 return contents->notify_disconnection() && | 139 return contents->notify_disconnection() && |
140 !contents->showing_interstitial_page() && | 140 !contents->showing_interstitial_page() && |
141 !contents->render_view_host()->SuddenTerminationAllowed(); | 141 !contents->render_view_host()->SuddenTerminationAllowed(); |
142 } | 142 } |
(...skipping 1602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1745 void Browser::OpenSyncMyBookmarksDialog() { | 1745 void Browser::OpenSyncMyBookmarksDialog() { |
1746 sync_ui_util::OpenSyncMyBookmarksDialog( | 1746 sync_ui_util::OpenSyncMyBookmarksDialog( |
1747 profile_, ProfileSyncService::START_FROM_WRENCH); | 1747 profile_, ProfileSyncService::START_FROM_WRENCH); |
1748 } | 1748 } |
1749 | 1749 |
1750 void Browser::OpenAboutChromeDialog() { | 1750 void Browser::OpenAboutChromeDialog() { |
1751 UserMetrics::RecordAction(UserMetricsAction("AboutChrome"), profile_); | 1751 UserMetrics::RecordAction(UserMetricsAction("AboutChrome"), profile_); |
1752 window_->ShowAboutChromeDialog(); | 1752 window_->ShowAboutChromeDialog(); |
1753 } | 1753 } |
1754 | 1754 |
| 1755 void Browser::OpenUpdateChromeDialog() { |
| 1756 UserMetrics::RecordAction(UserMetricsAction("UpdateChrome"), profile_); |
| 1757 window_->ShowUpdateChromeDialog(); |
| 1758 } |
| 1759 |
1755 void Browser::OpenHelpTab() { | 1760 void Browser::OpenHelpTab() { |
1756 GURL help_url = google_util::AppendGoogleLocaleParam(GURL(kHelpContentUrl)); | 1761 GURL help_url = google_util::AppendGoogleLocaleParam(GURL(kHelpContentUrl)); |
1757 AddTabWithURL(help_url, GURL(), PageTransition::AUTO_BOOKMARK, | 1762 AddTabWithURL(help_url, GURL(), PageTransition::AUTO_BOOKMARK, |
1758 -1, Browser::ADD_SELECTED, NULL, std::string()); | 1763 -1, Browser::ADD_SELECTED, NULL, std::string()); |
1759 } | 1764 } |
1760 | 1765 |
1761 void Browser::OpenThemeGalleryTabAndActivate() { | 1766 void Browser::OpenThemeGalleryTabAndActivate() { |
1762 OpenURL(GURL(l10n_util::GetStringUTF8(IDS_THEMES_GALLERY_URL)), | 1767 OpenURL(GURL(l10n_util::GetStringUTF8(IDS_THEMES_GALLERY_URL)), |
1763 GURL(), NEW_FOREGROUND_TAB, PageTransition::LINK); | 1768 GURL(), NEW_FOREGROUND_TAB, PageTransition::LINK); |
1764 window_->Activate(); | 1769 window_->Activate(); |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2022 case IDC_SHOW_PAGE_MENU: ShowPageMenu(); break; | 2027 case IDC_SHOW_PAGE_MENU: ShowPageMenu(); break; |
2023 case IDC_SHOW_HISTORY: ShowHistoryTab(); break; | 2028 case IDC_SHOW_HISTORY: ShowHistoryTab(); break; |
2024 case IDC_SHOW_DOWNLOADS: ShowDownloadsTab(); break; | 2029 case IDC_SHOW_DOWNLOADS: ShowDownloadsTab(); break; |
2025 case IDC_MANAGE_EXTENSIONS: ShowExtensionsTab(); break; | 2030 case IDC_MANAGE_EXTENSIONS: ShowExtensionsTab(); break; |
2026 case IDC_SYNC_BOOKMARKS: OpenSyncMyBookmarksDialog(); break; | 2031 case IDC_SYNC_BOOKMARKS: OpenSyncMyBookmarksDialog(); break; |
2027 case IDC_OPTIONS: OpenOptionsDialog(); break; | 2032 case IDC_OPTIONS: OpenOptionsDialog(); break; |
2028 case IDC_EDIT_SEARCH_ENGINES: OpenKeywordEditor(); break; | 2033 case IDC_EDIT_SEARCH_ENGINES: OpenKeywordEditor(); break; |
2029 case IDC_VIEW_PASSWORDS: OpenPasswordManager(); break; | 2034 case IDC_VIEW_PASSWORDS: OpenPasswordManager(); break; |
2030 case IDC_CLEAR_BROWSING_DATA: OpenClearBrowsingDataDialog(); break; | 2035 case IDC_CLEAR_BROWSING_DATA: OpenClearBrowsingDataDialog(); break; |
2031 case IDC_IMPORT_SETTINGS: OpenImportSettingsDialog(); break; | 2036 case IDC_IMPORT_SETTINGS: OpenImportSettingsDialog(); break; |
2032 case IDC_ABOUT: OpenAboutChromeDialog(); break; | 2037 case IDC_ABOUT: |
| 2038 if (Singleton<UpgradeDetector>::get()->notify_upgrade()) |
| 2039 OpenUpdateChromeDialog(); |
| 2040 else |
| 2041 OpenAboutChromeDialog(); |
| 2042 break; |
2033 case IDC_HELP_PAGE: OpenHelpTab(); break; | 2043 case IDC_HELP_PAGE: OpenHelpTab(); break; |
2034 #if defined(OS_CHROMEOS) | 2044 #if defined(OS_CHROMEOS) |
2035 case IDC_SYSTEM_OPTIONS: OpenSystemOptionsDialog(); break; | 2045 case IDC_SYSTEM_OPTIONS: OpenSystemOptionsDialog(); break; |
2036 case IDC_INTERNET_OPTIONS: OpenInternetOptionsDialog(); break; | 2046 case IDC_INTERNET_OPTIONS: OpenInternetOptionsDialog(); break; |
2037 #endif | 2047 #endif |
2038 | 2048 |
2039 // AutoFill | 2049 // AutoFill |
2040 case IDC_AUTOFILL_DEFAULT: AutoFillDefaultProfile(); break; | 2050 case IDC_AUTOFILL_DEFAULT: AutoFillDefaultProfile(); break; |
2041 | 2051 |
2042 default: | 2052 default: |
(...skipping 1825 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3868 if (TabHasUnloadListener(contents)) { | 3878 if (TabHasUnloadListener(contents)) { |
3869 // If the page has unload listeners, then we tell the renderer to fire | 3879 // If the page has unload listeners, then we tell the renderer to fire |
3870 // them. Once they have fired, we'll get a message back saying whether | 3880 // them. Once they have fired, we'll get a message back saying whether |
3871 // to proceed closing the page or not, which sends us back to this method | 3881 // to proceed closing the page or not, which sends us back to this method |
3872 // with the HasUnloadListener bit cleared. | 3882 // with the HasUnloadListener bit cleared. |
3873 contents->render_view_host()->FirePageBeforeUnload(false); | 3883 contents->render_view_host()->FirePageBeforeUnload(false); |
3874 return true; | 3884 return true; |
3875 } | 3885 } |
3876 return false; | 3886 return false; |
3877 } | 3887 } |
OLD | NEW |