OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_init.h" | 5 #include "chrome/browser/ui/browser_init.h" |
6 | 6 |
7 #include <algorithm> // For max(). | 7 #include <algorithm> // For max(). |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/environment.h" | 10 #include "base/environment.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "chrome/browser/automation/testing_automation_provider.h" | 23 #include "chrome/browser/automation/testing_automation_provider.h" |
24 #include "chrome/browser/browser_process.h" | 24 #include "chrome/browser/browser_process.h" |
25 #include "chrome/browser/component_updater/component_updater_service.h" | 25 #include "chrome/browser/component_updater/component_updater_service.h" |
26 #include "chrome/browser/component_updater/pepper_flash_component_installer.h" | 26 #include "chrome/browser/component_updater/pepper_flash_component_installer.h" |
27 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" | 27 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" |
28 #include "chrome/browser/defaults.h" | 28 #include "chrome/browser/defaults.h" |
29 #include "chrome/browser/extensions/extension_creator.h" | 29 #include "chrome/browser/extensions/extension_creator.h" |
30 #include "chrome/browser/extensions/extension_service.h" | 30 #include "chrome/browser/extensions/extension_service.h" |
31 #include "chrome/browser/extensions/pack_extension_job.h" | 31 #include "chrome/browser/extensions/pack_extension_job.h" |
32 #include "chrome/browser/first_run/first_run.h" | 32 #include "chrome/browser/first_run/first_run.h" |
| 33 #include "chrome/browser/infobars/infobar_tab_helper.h" |
33 #include "chrome/browser/net/predictor_api.h" | 34 #include "chrome/browser/net/predictor_api.h" |
34 #include "chrome/browser/net/url_fixer_upper.h" | 35 #include "chrome/browser/net/url_fixer_upper.h" |
35 #include "chrome/browser/notifications/desktop_notification_service.h" | 36 #include "chrome/browser/notifications/desktop_notification_service.h" |
36 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 37 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
37 #include "chrome/browser/prefs/pref_service.h" | 38 #include "chrome/browser/prefs/pref_service.h" |
38 #include "chrome/browser/prefs/session_startup_pref.h" | 39 #include "chrome/browser/prefs/session_startup_pref.h" |
39 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h" | 40 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h" |
40 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory.
h" | 41 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory.
h" |
41 #include "chrome/browser/printing/print_dialog_cloud.h" | 42 #include "chrome/browser/printing/print_dialog_cloud.h" |
42 #include "chrome/browser/profiles/profile.h" | 43 #include "chrome/browser/profiles/profile.h" |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 } | 252 } |
252 | 253 |
253 void NotifyNotDefaultBrowserTask::Run() { | 254 void NotifyNotDefaultBrowserTask::Run() { |
254 Browser* browser = BrowserList::GetLastActive(); | 255 Browser* browser = BrowserList::GetLastActive(); |
255 if (!browser) | 256 if (!browser) |
256 return; // Reached during ui tests. | 257 return; // Reached during ui tests. |
257 // Don't show the info-bar if there are already info-bars showing. | 258 // Don't show the info-bar if there are already info-bars showing. |
258 // In ChromeBot tests, there might be a race. This line appears to get | 259 // In ChromeBot tests, there might be a race. This line appears to get |
259 // called during shutdown and |tab| can be NULL. | 260 // called during shutdown and |tab| can be NULL. |
260 TabContentsWrapper* tab = browser->GetSelectedTabContentsWrapper(); | 261 TabContentsWrapper* tab = browser->GetSelectedTabContentsWrapper(); |
261 if (!tab || tab->infobar_count() > 0) | 262 if (!tab || tab->infobar_tab_helper()->infobar_count() > 0) |
262 return; | 263 return; |
263 tab->AddInfoBar(new DefaultBrowserInfoBarDelegate(tab->tab_contents())); | 264 tab->infobar_tab_helper()->AddInfoBar( |
| 265 new DefaultBrowserInfoBarDelegate(tab->tab_contents())); |
264 } | 266 } |
265 | 267 |
266 | 268 |
267 // CheckDefaultBrowserTask ---------------------------------------------------- | 269 // CheckDefaultBrowserTask ---------------------------------------------------- |
268 | 270 |
269 class CheckDefaultBrowserTask : public Task { | 271 class CheckDefaultBrowserTask : public Task { |
270 public: | 272 public: |
271 CheckDefaultBrowserTask(); | 273 CheckDefaultBrowserTask(); |
272 virtual ~CheckDefaultBrowserTask(); | 274 virtual ~CheckDefaultBrowserTask(); |
273 | 275 |
(...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1081 | 1083 |
1082 void BrowserInit::LaunchWithProfile::AddCrashedInfoBarIfNecessary( | 1084 void BrowserInit::LaunchWithProfile::AddCrashedInfoBarIfNecessary( |
1083 Browser* browser, | 1085 Browser* browser, |
1084 TabContentsWrapper* tab) { | 1086 TabContentsWrapper* tab) { |
1085 // Assume that if the user is launching incognito they were previously | 1087 // Assume that if the user is launching incognito they were previously |
1086 // running incognito so that we have nothing to restore from. | 1088 // running incognito so that we have nothing to restore from. |
1087 if (!profile_->DidLastSessionExitCleanly() && !profile_->IsOffTheRecord()) { | 1089 if (!profile_->DidLastSessionExitCleanly() && !profile_->IsOffTheRecord()) { |
1088 // The last session didn't exit cleanly. Show an infobar to the user | 1090 // The last session didn't exit cleanly. Show an infobar to the user |
1089 // so that they can restore if they want. The delegate deletes itself when | 1091 // so that they can restore if they want. The delegate deletes itself when |
1090 // it is closed. | 1092 // it is closed. |
1091 tab->AddInfoBar( | 1093 tab->infobar_tab_helper()->AddInfoBar( |
1092 new SessionCrashedInfoBarDelegate(profile_, tab->tab_contents())); | 1094 new SessionCrashedInfoBarDelegate(profile_, tab->tab_contents())); |
1093 } | 1095 } |
1094 } | 1096 } |
1095 | 1097 |
1096 void BrowserInit::LaunchWithProfile::AddBadFlagsInfoBarIfNecessary( | 1098 void BrowserInit::LaunchWithProfile::AddBadFlagsInfoBarIfNecessary( |
1097 TabContentsWrapper* tab) { | 1099 TabContentsWrapper* tab) { |
1098 // Unsupported flags for which to display a warning that "stability and | 1100 // Unsupported flags for which to display a warning that "stability and |
1099 // security will suffer". | 1101 // security will suffer". |
1100 static const char* kBadFlags[] = { | 1102 static const char* kBadFlags[] = { |
1101 // These imply disabling the sandbox. | 1103 // These imply disabling the sandbox. |
1102 switches::kSingleProcess, | 1104 switches::kSingleProcess, |
1103 switches::kNoSandbox, | 1105 switches::kNoSandbox, |
1104 switches::kInProcessWebGL, | 1106 switches::kInProcessWebGL, |
1105 NULL | 1107 NULL |
1106 }; | 1108 }; |
1107 | 1109 |
1108 const char* bad_flag = NULL; | 1110 const char* bad_flag = NULL; |
1109 for (const char** flag = kBadFlags; *flag; ++flag) { | 1111 for (const char** flag = kBadFlags; *flag; ++flag) { |
1110 if (command_line_.HasSwitch(*flag)) { | 1112 if (command_line_.HasSwitch(*flag)) { |
1111 bad_flag = *flag; | 1113 bad_flag = *flag; |
1112 break; | 1114 break; |
1113 } | 1115 } |
1114 } | 1116 } |
1115 | 1117 |
1116 if (bad_flag) { | 1118 if (bad_flag) { |
1117 tab->AddInfoBar(new SimpleAlertInfoBarDelegate(tab->tab_contents(), NULL, | 1119 tab->infobar_tab_helper()->AddInfoBar( |
1118 l10n_util::GetStringFUTF16(IDS_BAD_FLAGS_WARNING_MESSAGE, | 1120 new SimpleAlertInfoBarDelegate( |
1119 UTF8ToUTF16(std::string("--") + bad_flag)), | 1121 tab->tab_contents(), NULL, |
1120 false)); | 1122 l10n_util::GetStringFUTF16( |
| 1123 IDS_BAD_FLAGS_WARNING_MESSAGE, |
| 1124 UTF8ToUTF16(std::string("--") + bad_flag)), |
| 1125 false)); |
1121 } | 1126 } |
1122 } | 1127 } |
1123 | 1128 |
1124 class LearnMoreInfoBar : public LinkInfoBarDelegate { | 1129 class LearnMoreInfoBar : public LinkInfoBarDelegate { |
1125 public: | 1130 public: |
1126 LearnMoreInfoBar(TabContents* tab_contents, | 1131 LearnMoreInfoBar(TabContents* tab_contents, |
1127 const string16& message, | 1132 const string16& message, |
1128 const GURL& url); | 1133 const GURL& url); |
1129 virtual ~LearnMoreInfoBar(); | 1134 virtual ~LearnMoreInfoBar(); |
1130 | 1135 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1174 void BrowserInit::LaunchWithProfile:: | 1179 void BrowserInit::LaunchWithProfile:: |
1175 AddDNSCertProvenanceCheckingWarningInfoBarIfNecessary( | 1180 AddDNSCertProvenanceCheckingWarningInfoBarIfNecessary( |
1176 TabContentsWrapper* tab) { | 1181 TabContentsWrapper* tab) { |
1177 if (!command_line_.HasSwitch(switches::kEnableDNSCertProvenanceChecking)) | 1182 if (!command_line_.HasSwitch(switches::kEnableDNSCertProvenanceChecking)) |
1178 return; | 1183 return; |
1179 | 1184 |
1180 const char* kLearnMoreURL = | 1185 const char* kLearnMoreURL = |
1181 "http://dev.chromium.org/dnscertprovenancechecking"; | 1186 "http://dev.chromium.org/dnscertprovenancechecking"; |
1182 string16 message = l10n_util::GetStringUTF16( | 1187 string16 message = l10n_util::GetStringUTF16( |
1183 IDS_DNS_CERT_PROVENANCE_CHECKING_WARNING_MESSAGE); | 1188 IDS_DNS_CERT_PROVENANCE_CHECKING_WARNING_MESSAGE); |
1184 tab->AddInfoBar(new LearnMoreInfoBar(tab->tab_contents(), | 1189 tab->infobar_tab_helper()->AddInfoBar( |
1185 message, | 1190 new LearnMoreInfoBar(tab->tab_contents(), |
1186 GURL(kLearnMoreURL))); | 1191 message, |
| 1192 GURL(kLearnMoreURL))); |
1187 } | 1193 } |
1188 | 1194 |
1189 void BrowserInit::LaunchWithProfile::AddObsoleteSystemInfoBarIfNecessary( | 1195 void BrowserInit::LaunchWithProfile::AddObsoleteSystemInfoBarIfNecessary( |
1190 TabContentsWrapper* tab) { | 1196 TabContentsWrapper* tab) { |
1191 #if defined(TOOLKIT_USES_GTK) | 1197 #if defined(TOOLKIT_USES_GTK) |
1192 // We've deprecated support for Ubuntu Hardy. Rather than attempting to | 1198 // We've deprecated support for Ubuntu Hardy. Rather than attempting to |
1193 // determine whether you're using that, we instead key off the GTK version; | 1199 // determine whether you're using that, we instead key off the GTK version; |
1194 // this will also deprecate other distributions (including variants of Ubuntu) | 1200 // this will also deprecate other distributions (including variants of Ubuntu) |
1195 // that are of a similar age. | 1201 // that are of a similar age. |
1196 // Version key: | 1202 // Version key: |
1197 // Ubuntu Hardy: GTK 2.12 | 1203 // Ubuntu Hardy: GTK 2.12 |
1198 // RHEL 6: GTK 2.18 | 1204 // RHEL 6: GTK 2.18 |
1199 // Ubuntu Lucid: GTK 2.20 | 1205 // Ubuntu Lucid: GTK 2.20 |
1200 if (gtk_check_version(2, 18, 0)) { | 1206 if (gtk_check_version(2, 18, 0)) { |
1201 string16 message = | 1207 string16 message = |
1202 l10n_util::GetStringFUTF16(IDS_SYSTEM_OBSOLETE_MESSAGE, | 1208 l10n_util::GetStringFUTF16(IDS_SYSTEM_OBSOLETE_MESSAGE, |
1203 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); | 1209 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); |
1204 // Link to an article in the help center on minimum system requirements. | 1210 // Link to an article in the help center on minimum system requirements. |
1205 const char* kLearnMoreURL = | 1211 const char* kLearnMoreURL = |
1206 "http://www.google.com/support/chrome/bin/answer.py?answer=95411"; | 1212 "http://www.google.com/support/chrome/bin/answer.py?answer=95411"; |
1207 tab->AddInfoBar(new LearnMoreInfoBar(tab->tab_contents(), | 1213 tab->infobar_tab_helper()->AddInfoBar( |
1208 message, | 1214 new LearnMoreInfoBar(tab->tab_contents(), |
1209 GURL(kLearnMoreURL))); | 1215 message, |
| 1216 GURL(kLearnMoreURL))); |
1210 } | 1217 } |
1211 #endif | 1218 #endif |
1212 } | 1219 } |
1213 | 1220 |
1214 void BrowserInit::LaunchWithProfile::AddStartupURLs( | 1221 void BrowserInit::LaunchWithProfile::AddStartupURLs( |
1215 std::vector<GURL>* startup_urls) const { | 1222 std::vector<GURL>* startup_urls) const { |
1216 // If we have urls specified beforehand (i.e. from command line) use them | 1223 // If we have urls specified beforehand (i.e. from command line) use them |
1217 // and nothing else. | 1224 // and nothing else. |
1218 if (!startup_urls->empty()) | 1225 if (!startup_urls->empty()) |
1219 return; | 1226 return; |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1478 return false; | 1485 return false; |
1479 automation->SetExpectedTabCount(expected_tabs); | 1486 automation->SetExpectedTabCount(expected_tabs); |
1480 | 1487 |
1481 AutomationProviderList* list = | 1488 AutomationProviderList* list = |
1482 g_browser_process->InitAutomationProviderList(); | 1489 g_browser_process->InitAutomationProviderList(); |
1483 DCHECK(list); | 1490 DCHECK(list); |
1484 list->AddProvider(automation); | 1491 list->AddProvider(automation); |
1485 | 1492 |
1486 return true; | 1493 return true; |
1487 } | 1494 } |
OLD | NEW |