| 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/first_run/first_run.h" | 5 #include "chrome/browser/first_run/first_run.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 #include <shellapi.h> | 8 #include <shellapi.h> |
| 9 #include <shlobj.h> | 9 #include <shlobj.h> |
| 10 | 10 |
| 11 #include <set> | 11 #include <set> |
| 12 #include <sstream> | 12 #include <sstream> |
| 13 | 13 |
| 14 // TODO(port): trim this include list once first run has been refactored fully. | |
| 15 #include "app/app_switches.h" | 14 #include "app/app_switches.h" |
| 16 #include "app/l10n_util.h" | 15 #include "app/l10n_util.h" |
| 17 #include "app/resource_bundle.h" | 16 #include "app/resource_bundle.h" |
| 18 #include "base/command_line.h" | |
| 19 #include "base/environment.h" | 17 #include "base/environment.h" |
| 20 #include "base/file_util.h" | 18 #include "base/file_util.h" |
| 21 #include "base/logging.h" | |
| 22 #include "base/object_watcher.h" | 19 #include "base/object_watcher.h" |
| 23 #include "base/path_service.h" | 20 #include "base/path_service.h" |
| 24 #include "base/process.h" | |
| 25 #include "base/process_util.h" | |
| 26 #include "base/registry.h" | 21 #include "base/registry.h" |
| 27 #include "base/scoped_comptr_win.h" | 22 #include "base/scoped_comptr_win.h" |
| 28 #include "base/scoped_ptr.h" | 23 #include "base/scoped_ptr.h" |
| 29 #include "base/string_number_conversions.h" | 24 #include "base/string_number_conversions.h" |
| 30 #include "base/string_util.h" | |
| 31 #include "base/utf_string_conversions.h" | 25 #include "base/utf_string_conversions.h" |
| 32 #include "base/win_util.h" | 26 #include "base/win_util.h" |
| 33 #include "chrome/common/chrome_constants.h" | |
| 34 #include "chrome/common/chrome_switches.h" | |
| 35 #include "chrome/common/notification_registrar.h" | |
| 36 #include "chrome/common/notification_service.h" | |
| 37 #include "chrome/common/notification_type.h" | |
| 38 #include "chrome/common/pref_names.h" | |
| 39 #include "chrome/browser/browser_process.h" | |
| 40 #include "chrome/browser/extensions/extensions_service.h" | 27 #include "chrome/browser/extensions/extensions_service.h" |
| 41 #include "chrome/browser/extensions/extension_updater.h" | 28 #include "chrome/browser/extensions/extension_updater.h" |
| 42 #include "chrome/browser/hang_monitor/hung_window_detector.h" | |
| 43 #include "chrome/browser/importer/importer.h" | 29 #include "chrome/browser/importer/importer.h" |
| 44 #include "chrome/browser/importer/importer_data_types.h" | |
| 45 #include "chrome/browser/metrics/user_metrics.h" | 30 #include "chrome/browser/metrics/user_metrics.h" |
| 46 #include "chrome/browser/pref_service.h" | |
| 47 #include "chrome/browser/process_singleton.h" | 31 #include "chrome/browser/process_singleton.h" |
| 48 #include "chrome/browser/profile.h" | 32 #include "chrome/browser/profile.h" |
| 49 #include "chrome/browser/profile_manager.h" | |
| 50 #include "chrome/browser/shell_integration.h" | |
| 51 #include "chrome/browser/views/first_run_search_engine_view.h" | 33 #include "chrome/browser/views/first_run_search_engine_view.h" |
| 52 #include "chrome/common/chrome_paths.h" | 34 #include "chrome/common/chrome_switches.h" |
| 53 #include "chrome/common/result_codes.h" | 35 #include "chrome/common/notification_service.h" |
| 36 #include "chrome/common/pref_names.h" |
| 37 #include "chrome/common/worker_thread_ticker.h" |
| 54 #include "chrome/installer/util/browser_distribution.h" | 38 #include "chrome/installer/util/browser_distribution.h" |
| 55 #include "chrome/installer/util/google_update_constants.h" | 39 #include "chrome/installer/util/google_update_constants.h" |
| 56 #include "chrome/installer/util/google_update_settings.h" | 40 #include "chrome/installer/util/google_update_settings.h" |
| 57 #include "chrome/installer/util/install_util.h" | 41 #include "chrome/installer/util/install_util.h" |
| 58 #include "chrome/installer/util/master_preferences.h" | |
| 59 #include "chrome/installer/util/shell_util.h" | 42 #include "chrome/installer/util/shell_util.h" |
| 60 #include "chrome/installer/util/util_constants.h" | 43 #include "chrome/installer/util/util_constants.h" |
| 61 #include "google_update_idl.h" | 44 #include "google_update_idl.h" |
| 62 #include "grit/app_resources.h" | |
| 63 #include "grit/chromium_strings.h" | 45 #include "grit/chromium_strings.h" |
| 64 #include "grit/generated_resources.h" | 46 #include "grit/generated_resources.h" |
| 65 #include "grit/locale_settings.h" | 47 #include "grit/locale_settings.h" |
| 66 #include "grit/theme_resources.h" | 48 #include "grit/theme_resources.h" |
| 67 #include "views/background.h" | |
| 68 #include "views/controls/button/image_button.h" | 49 #include "views/controls/button/image_button.h" |
| 69 #include "views/controls/button/native_button.h" | |
| 70 #include "views/controls/button/radio_button.h" | 50 #include "views/controls/button/radio_button.h" |
| 71 #include "views/controls/image_view.h" | 51 #include "views/controls/image_view.h" |
| 72 #include "views/controls/label.h" | |
| 73 #include "views/controls/link.h" | 52 #include "views/controls/link.h" |
| 74 #include "views/focus/accelerator_handler.h" | 53 #include "views/focus/accelerator_handler.h" |
| 75 #include "views/grid_layout.h" | 54 #include "views/grid_layout.h" |
| 76 #include "views/standard_layout.h" | 55 #include "views/standard_layout.h" |
| 77 #include "views/widget/root_view.h" | 56 #include "views/widget/root_view.h" |
| 78 #include "views/widget/widget_win.h" | 57 #include "views/widget/widget_win.h" |
| 79 #include "views/window/window.h" | 58 #include "views/window/window.h" |
| 80 #include "views/window/window_delegate.h" | |
| 81 #include "views/window/window_win.h" | |
| 82 | 59 |
| 83 namespace { | 60 namespace { |
| 84 | 61 |
| 85 bool GetNewerChromeFile(FilePath* path) { | 62 bool GetNewerChromeFile(FilePath* path) { |
| 86 if (!PathService::Get(base::DIR_EXE, path)) | 63 if (!PathService::Get(base::DIR_EXE, path)) |
| 87 return false; | 64 return false; |
| 88 *path = path->Append(installer_util::kChromeNewExe); | 65 *path = path->Append(installer_util::kChromeNewExe); |
| 89 return true; | 66 return true; |
| 90 } | 67 } |
| 91 | 68 |
| 92 bool GetBackupChromeFile(std::wstring* path) { | 69 bool GetBackupChromeFile(std::wstring* path) { |
| 93 if (!PathService::Get(base::DIR_EXE, path)) | 70 if (!PathService::Get(base::DIR_EXE, path)) |
| 94 return false; | 71 return false; |
| 95 file_util::AppendToPath(path, installer_util::kChromeOldExe); | 72 file_util::AppendToPath(path, installer_util::kChromeOldExe); |
| 96 return true; | 73 return true; |
| 97 } | 74 } |
| 98 | 75 |
| 99 FilePath GetDefaultPrefFilePath(bool create_profile_dir, | |
| 100 const FilePath& user_data_dir) { | |
| 101 FilePath default_pref_dir = | |
| 102 ProfileManager::GetDefaultProfileDir(user_data_dir); | |
| 103 if (create_profile_dir) { | |
| 104 if (!file_util::PathExists(default_pref_dir)) { | |
| 105 if (!file_util::CreateDirectory(default_pref_dir)) | |
| 106 return FilePath(); | |
| 107 } | |
| 108 } | |
| 109 return ProfileManager::GetProfilePrefsPath(default_pref_dir); | |
| 110 } | |
| 111 | |
| 112 bool InvokeGoogleUpdateForRename() { | 76 bool InvokeGoogleUpdateForRename() { |
| 113 ScopedComPtr<IProcessLauncher> ipl; | 77 ScopedComPtr<IProcessLauncher> ipl; |
| 114 if (!FAILED(ipl.CreateInstance(__uuidof(ProcessLauncherClass)))) { | 78 if (!FAILED(ipl.CreateInstance(__uuidof(ProcessLauncherClass)))) { |
| 115 ULONG_PTR phandle = NULL; | 79 ULONG_PTR phandle = NULL; |
| 116 DWORD id = GetCurrentProcessId(); | 80 DWORD id = GetCurrentProcessId(); |
| 117 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | 81 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
| 118 if (!FAILED(ipl->LaunchCmdElevated(dist->GetAppGuid().c_str(), | 82 if (!FAILED(ipl->LaunchCmdElevated(dist->GetAppGuid().c_str(), |
| 119 google_update::kRegRenameCmdField, | 83 google_update::kRegRenameCmdField, |
| 120 id, &phandle))) { | 84 id, &phandle))) { |
| 121 HANDLE handle = HANDLE(phandle); | 85 HANDLE handle = HANDLE(phandle); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 return; | 170 return; |
| 207 service->updater()->CheckNow(); | 171 service->updater()->CheckNow(); |
| 208 return; | 172 return; |
| 209 } | 173 } |
| 210 | 174 |
| 211 NotificationRegistrar registrar_; | 175 NotificationRegistrar registrar_; |
| 212 }; | 176 }; |
| 213 | 177 |
| 214 } // namespace | 178 } // namespace |
| 215 | 179 |
| 180 bool FirstRun::LaunchSetupWithParam(const std::string& param, |
| 181 const std::wstring& value, |
| 182 int* ret_code) { |
| 183 FilePath exe_path; |
| 184 if (!PathService::Get(base::DIR_MODULE, &exe_path)) |
| 185 return false; |
| 186 exe_path = exe_path.Append(installer_util::kInstallerDir); |
| 187 exe_path = exe_path.Append(installer_util::kSetupExe); |
| 188 base::ProcessHandle ph; |
| 189 CommandLine cl(exe_path); |
| 190 cl.AppendSwitchNative(param, value); |
| 191 |
| 192 CommandLine* browser_command_line = CommandLine::ForCurrentProcess(); |
| 193 if (browser_command_line->HasSwitch(switches::kChromeFrame)) { |
| 194 cl.AppendSwitch(switches::kChromeFrame); |
| 195 } |
| 196 |
| 197 if (!base::LaunchApp(cl, false, false, &ph)) |
| 198 return false; |
| 199 DWORD wr = ::WaitForSingleObject(ph, INFINITE); |
| 200 if (wr != WAIT_OBJECT_0) |
| 201 return false; |
| 202 return (TRUE == ::GetExitCodeProcess(ph, reinterpret_cast<DWORD*>(ret_code))); |
| 203 } |
| 204 |
| 205 bool FirstRun::WriteEULAtoTempFile(FilePath* eula_path) { |
| 206 base::StringPiece terms = |
| 207 ResourceBundle::GetSharedInstance().GetRawDataResource(IDR_TERMS_HTML); |
| 208 if (terms.empty()) |
| 209 return false; |
| 210 FILE *file = file_util::CreateAndOpenTemporaryFile(eula_path); |
| 211 if (!file) |
| 212 return false; |
| 213 bool good = fwrite(terms.data(), terms.size(), 1, file) == 1; |
| 214 fclose(file); |
| 215 return good; |
| 216 } |
| 217 |
| 218 void FirstRun::DoDelayedInstallExtensions() { |
| 219 new FirstRunDelayedTasks(FirstRunDelayedTasks::INSTALL_EXTENSIONS); |
| 220 } |
| 221 |
| 216 CommandLine* Upgrade::new_command_line_ = NULL; | 222 CommandLine* Upgrade::new_command_line_ = NULL; |
| 217 | 223 |
| 218 bool FirstRun::CreateChromeDesktopShortcut() { | 224 bool FirstRun::CreateChromeDesktopShortcut() { |
| 219 std::wstring chrome_exe; | 225 std::wstring chrome_exe; |
| 220 if (!PathService::Get(base::FILE_EXE, &chrome_exe)) | 226 if (!PathService::Get(base::FILE_EXE, &chrome_exe)) |
| 221 return false; | 227 return false; |
| 222 BrowserDistribution *dist = BrowserDistribution::GetDistribution(); | 228 BrowserDistribution *dist = BrowserDistribution::GetDistribution(); |
| 223 if (!dist) | 229 if (!dist) |
| 224 return false; | 230 return false; |
| 225 return ShellUtil::CreateChromeDesktopShortcut(chrome_exe, | 231 return ShellUtil::CreateChromeDesktopShortcut(chrome_exe, |
| 226 dist->GetAppDescription(), ShellUtil::CURRENT_USER, | 232 dist->GetAppDescription(), ShellUtil::CURRENT_USER, |
| 227 false, true); // create if doesn't exist. | 233 false, true); // create if doesn't exist. |
| 228 } | 234 } |
| 229 | 235 |
| 230 bool FirstRun::CreateChromeQuickLaunchShortcut() { | 236 bool FirstRun::CreateChromeQuickLaunchShortcut() { |
| 231 std::wstring chrome_exe; | 237 std::wstring chrome_exe; |
| 232 if (!PathService::Get(base::FILE_EXE, &chrome_exe)) | 238 if (!PathService::Get(base::FILE_EXE, &chrome_exe)) |
| 233 return false; | 239 return false; |
| 234 return ShellUtil::CreateChromeQuickLaunchShortcut(chrome_exe, | 240 return ShellUtil::CreateChromeQuickLaunchShortcut(chrome_exe, |
| 235 ShellUtil::CURRENT_USER, // create only for current user. | 241 ShellUtil::CURRENT_USER, // create only for current user. |
| 236 true); // create if doesn't exist. | 242 true); // create if doesn't exist. |
| 237 } | 243 } |
| 238 | 244 |
| 239 bool FirstRun::ProcessMasterPreferences(const FilePath& user_data_dir, | |
| 240 MasterPrefs* out_prefs) { | |
| 241 DCHECK(!user_data_dir.empty()); | |
| 242 | |
| 243 // The standard location of the master prefs is next to the chrome exe. | |
| 244 FilePath master_prefs; | |
| 245 if (!PathService::Get(base::DIR_EXE, &master_prefs)) | |
| 246 return true; | |
| 247 master_prefs = master_prefs.AppendASCII(installer_util::kDefaultMasterPrefs); | |
| 248 | |
| 249 scoped_ptr<DictionaryValue> prefs( | |
| 250 installer_util::ParseDistributionPreferences(master_prefs)); | |
| 251 if (!prefs.get()) | |
| 252 return true; | |
| 253 | |
| 254 out_prefs->new_tabs = installer_util::GetFirstRunTabs(prefs.get()); | |
| 255 | |
| 256 if (!installer_util::GetDistroIntegerPreference(prefs.get(), | |
| 257 installer_util::master_preferences::kDistroPingDelay, | |
| 258 &out_prefs->ping_delay)) { | |
| 259 // 90 seconds is the default that we want to use in case master | |
| 260 // preferences is missing, corrupt or ping_delay is missing. | |
| 261 out_prefs->ping_delay = 90; | |
| 262 } | |
| 263 | |
| 264 std::string not_used; | |
| 265 out_prefs->homepage_defined = prefs->GetString(prefs::kHomePage, ¬_used); | |
| 266 | |
| 267 bool value = false; | |
| 268 if (installer_util::GetDistroBooleanPreference(prefs.get(), | |
| 269 installer_util::master_preferences::kRequireEula, &value) && value) { | |
| 270 // Show the post-installation EULA. This is done by setup.exe and the | |
| 271 // result determines if we continue or not. We wait here until the user | |
| 272 // dismisses the dialog. | |
| 273 | |
| 274 // The actual eula text is in a resource in chrome. We extract it to | |
| 275 // a text file so setup.exe can use it as an inner frame. | |
| 276 FilePath inner_html; | |
| 277 if (WriteEULAtoTempFile(&inner_html)) { | |
| 278 int retcode = 0; | |
| 279 if (!LaunchSetupWithParam(installer_util::switches::kShowEula, | |
| 280 inner_html.ToWStringHack(), &retcode) || | |
| 281 (retcode == installer_util::EULA_REJECTED)) { | |
| 282 LOG(WARNING) << "EULA rejected. Fast exit."; | |
| 283 ::ExitProcess(1); | |
| 284 } | |
| 285 if (retcode == installer_util::EULA_ACCEPTED) { | |
| 286 LOG(INFO) << "EULA : no collection"; | |
| 287 GoogleUpdateSettings::SetCollectStatsConsent(false); | |
| 288 } else if (retcode == installer_util::EULA_ACCEPTED_OPT_IN) { | |
| 289 LOG(INFO) << "EULA : collection consent"; | |
| 290 GoogleUpdateSettings::SetCollectStatsConsent(true); | |
| 291 } | |
| 292 } | |
| 293 } | |
| 294 | |
| 295 if (installer_util::GetDistroBooleanPreference(prefs.get(), | |
| 296 installer_util::master_preferences::kAltFirstRunBubble, &value) && value) | |
| 297 FirstRun::SetOEMFirstRunBubblePref(); | |
| 298 | |
| 299 FilePath user_prefs = GetDefaultPrefFilePath(true, user_data_dir); | |
| 300 if (user_prefs.empty()) | |
| 301 return true; | |
| 302 | |
| 303 // The master prefs are regular prefs so we can just copy the file | |
| 304 // to the default place and they just work. | |
| 305 if (!file_util::CopyFile(master_prefs, user_prefs)) | |
| 306 return true; | |
| 307 | |
| 308 DictionaryValue* extensions = 0; | |
| 309 if (installer_util::HasExtensionsBlock(prefs.get(), &extensions)) { | |
| 310 LOG(INFO) << "Extensions block found in master preferences"; | |
| 311 new FirstRunDelayedTasks(FirstRunDelayedTasks::INSTALL_EXTENSIONS); | |
| 312 } | |
| 313 | |
| 314 if (installer_util::GetDistroBooleanPreference(prefs.get(), | |
| 315 installer_util::master_preferences::kDistroImportSearchPref, &value)) { | |
| 316 if (value) { | |
| 317 out_prefs->do_import_items |= importer::SEARCH_ENGINES; | |
| 318 } else { | |
| 319 out_prefs->dont_import_items |= importer::SEARCH_ENGINES; | |
| 320 } | |
| 321 } | |
| 322 | |
| 323 // Check to see if search engine logos should be randomized. | |
| 324 if (installer_util::GetDistroBooleanPreference(prefs.get(), | |
| 325 installer_util::master_preferences::kSearchEngineExperimentRandomizePref, | |
| 326 &value) && value) | |
| 327 out_prefs->randomize_search_engine_experiment = true; | |
| 328 | |
| 329 // If we're suppressing the first-run bubble, set that preference now. | |
| 330 // Otherwise, wait until the user has completed first run to set it, so the | |
| 331 // user is guaranteed to see the bubble iff he or she has completed the first | |
| 332 // run process. | |
| 333 if (installer_util::GetDistroBooleanPreference(prefs.get(), | |
| 334 installer_util::master_preferences::kDistroSuppressFirstRunBubble, | |
| 335 &value) && value) | |
| 336 FirstRun::SetShowFirstRunBubblePref(false); | |
| 337 | |
| 338 | |
| 339 if (installer_util::GetDistroBooleanPreference(prefs.get(), | |
| 340 installer_util::master_preferences::kDistroImportHistoryPref, &value)) { | |
| 341 if (value) { | |
| 342 out_prefs->do_import_items |= importer::HISTORY; | |
| 343 } else { | |
| 344 out_prefs->dont_import_items |= importer::HISTORY; | |
| 345 } | |
| 346 } | |
| 347 | |
| 348 if (installer_util::GetDistroBooleanPreference(prefs.get(), | |
| 349 installer_util::master_preferences::kDistroImportHomePagePref, &value)) { | |
| 350 if (value) { | |
| 351 out_prefs->do_import_items |= importer::HOME_PAGE; | |
| 352 } else { | |
| 353 out_prefs->dont_import_items |= importer::HOME_PAGE; | |
| 354 } | |
| 355 } | |
| 356 | |
| 357 // Bookmarks are never imported unless specifically turned on. | |
| 358 if (installer_util::GetDistroBooleanPreference(prefs.get(), | |
| 359 installer_util::master_preferences::kDistroImportBookmarksPref, &value) | |
| 360 && value) { | |
| 361 out_prefs->do_import_items |= importer::FAVORITES; | |
| 362 } | |
| 363 | |
| 364 if (installer_util::GetDistroBooleanPreference(prefs.get(), | |
| 365 installer_util::master_preferences::kMakeChromeDefaultForUser, &value) && | |
| 366 value) | |
| 367 ShellIntegration::SetAsDefaultBrowser(); | |
| 368 | |
| 369 // TODO(mirandac): Refactor skip-first-run-ui process into regular first run | |
| 370 // import process. http://crbug.com/49647 | |
| 371 // Note we are skipping all other master preferences if skip-first-run-ui | |
| 372 // is *not* specified. (That is, we continue only if skipping first run ui.) | |
| 373 if (!installer_util::GetDistroBooleanPreference(prefs.get(), | |
| 374 installer_util::master_preferences::kDistroSkipFirstRunPref, &value) || | |
| 375 !value) | |
| 376 return true; | |
| 377 | |
| 378 // We need to be able to create the first run sentinel or else we cannot | |
| 379 // proceed because ImportSettings will launch the importer process which | |
| 380 // would end up here if the sentinel is not present. | |
| 381 if (!FirstRun::CreateSentinel()) | |
| 382 return false; | |
| 383 | |
| 384 if (installer_util::GetDistroBooleanPreference(prefs.get(), | |
| 385 installer_util::master_preferences::kDistroShowWelcomePage, &value) && | |
| 386 value) | |
| 387 FirstRun::SetShowWelcomePagePref(); | |
| 388 | |
| 389 std::string import_bookmarks_path; | |
| 390 installer_util::GetDistroStringPreference(prefs.get(), | |
| 391 installer_util::master_preferences::kDistroImportBookmarksFromFilePref, | |
| 392 &import_bookmarks_path); | |
| 393 | |
| 394 std::wstring brand; | |
| 395 GoogleUpdateSettings::GetBrand(&brand); | |
| 396 // This should generally be true, as skip_first_run_ui is a setting used for | |
| 397 // non-organic builds. | |
| 398 if (!GoogleUpdateSettings::IsOrganic(brand)) { | |
| 399 // If search engines aren't explicitly imported, don't import. | |
| 400 if (!(out_prefs->do_import_items & importer::SEARCH_ENGINES)) { | |
| 401 out_prefs->dont_import_items |= importer::SEARCH_ENGINES; | |
| 402 } | |
| 403 // If home page isn't explicitly imported, don't import. | |
| 404 if (!(out_prefs->do_import_items & importer::HOME_PAGE)) { | |
| 405 out_prefs->dont_import_items |= importer::HOME_PAGE; | |
| 406 } | |
| 407 // If history isn't explicitly forbidden, do import. | |
| 408 if (!(out_prefs->dont_import_items & importer::HISTORY)) { | |
| 409 out_prefs->do_import_items |= importer::HISTORY; | |
| 410 } | |
| 411 } | |
| 412 | |
| 413 if (out_prefs->do_import_items || !import_bookmarks_path.empty()) { | |
| 414 // There is something to import from the default browser. This launches | |
| 415 // the importer process and blocks until done or until it fails. | |
| 416 scoped_refptr<ImporterHost> importer_host = new ImporterHost(); | |
| 417 if (!FirstRun::ImportSettings(NULL, | |
| 418 importer_host->GetSourceProfileInfoAt(0).browser_type, | |
| 419 out_prefs->do_import_items, | |
| 420 FilePath::FromWStringHack(UTF8ToWide(import_bookmarks_path)), | |
| 421 true, NULL)) { | |
| 422 LOG(WARNING) << "silent import failed"; | |
| 423 } | |
| 424 } | |
| 425 | |
| 426 return false; | |
| 427 } | |
| 428 | |
| 429 bool Upgrade::IsBrowserAlreadyRunning() { | 245 bool Upgrade::IsBrowserAlreadyRunning() { |
| 430 static HANDLE handle = NULL; | 246 static HANDLE handle = NULL; |
| 431 std::wstring exe; | 247 std::wstring exe; |
| 432 PathService::Get(base::FILE_EXE, &exe); | 248 PathService::Get(base::FILE_EXE, &exe); |
| 433 std::replace(exe.begin(), exe.end(), '\\', '!'); | 249 std::replace(exe.begin(), exe.end(), '\\', '!'); |
| 434 std::transform(exe.begin(), exe.end(), exe.begin(), tolower); | 250 std::transform(exe.begin(), exe.end(), exe.begin(), tolower); |
| 435 exe = L"Global\\" + exe; | 251 exe = L"Global\\" + exe; |
| 436 if (handle != NULL) | 252 if (handle != NULL) |
| 437 CloseHandle(handle); | 253 CloseHandle(handle); |
| 438 handle = CreateEvent(NULL, TRUE, TRUE, exe.c_str()); | 254 handle = CreateEvent(NULL, TRUE, TRUE, exe.c_str()); |
| (...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 839 // This class displays a modal dialog using the views system. The dialog asks | 655 // This class displays a modal dialog using the views system. The dialog asks |
| 840 // the user to give chrome another try. This class only handles the UI so the | 656 // the user to give chrome another try. This class only handles the UI so the |
| 841 // resulting actions are up to the caller. One version looks like this: | 657 // resulting actions are up to the caller. One version looks like this: |
| 842 // | 658 // |
| 843 // /----------------------------------------\ | 659 // /----------------------------------------\ |
| 844 // | |icon| You stopped using Google [x] | | 660 // | |icon| You stopped using Google [x] | |
| 845 // | |icon| Chrome. Would you like to.. | | 661 // | |icon| Chrome. Would you like to.. | |
| 846 // | [o] Give the new version a try | | 662 // | [o] Give the new version a try | |
| 847 // | [ ] Uninstall Google Chrome | | 663 // | [ ] Uninstall Google Chrome | |
| 848 // | [ OK ] [Don't bug me] | | 664 // | [ OK ] [Don't bug me] | |
| 849 // | _why_am_I_seeign this?__ | | 665 // | _why_am_I_seeing this?__ | |
| 850 // ------------------------------------------ | 666 // ------------------------------------------ |
| 851 class TryChromeDialog : public views::ButtonListener, | 667 class TryChromeDialog : public views::ButtonListener, |
| 852 public views::LinkController { | 668 public views::LinkController { |
| 853 public: | 669 public: |
| 854 TryChromeDialog() | 670 TryChromeDialog() |
| 855 : popup_(NULL), | 671 : popup_(NULL), |
| 856 try_chrome_(NULL), | 672 try_chrome_(NULL), |
| 857 kill_chrome_(NULL), | 673 kill_chrome_(NULL), |
| 858 result_(Upgrade::TD_LAST_ENUM) { | 674 result_(Upgrade::TD_LAST_ENUM) { |
| 859 } | 675 } |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1097 | 913 |
| 1098 Upgrade::TryResult Upgrade::ShowTryChromeDialog(size_t version) { | 914 Upgrade::TryResult Upgrade::ShowTryChromeDialog(size_t version) { |
| 1099 if (version > 10000) { | 915 if (version > 10000) { |
| 1100 // This is a test value. We want to make sure we exercise | 916 // This is a test value. We want to make sure we exercise |
| 1101 // returning this early. See EarlyReturnTest test harness. | 917 // returning this early. See EarlyReturnTest test harness. |
| 1102 return Upgrade::TD_NOT_NOW; | 918 return Upgrade::TD_NOT_NOW; |
| 1103 } | 919 } |
| 1104 TryChromeDialog td; | 920 TryChromeDialog td; |
| 1105 return td.ShowModal(); | 921 return td.ShowModal(); |
| 1106 } | 922 } |
| OLD | NEW |