Chromium Code Reviews| 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/installer/setup/install.h" | 5 #include "chrome/installer/setup/install.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 #include <shlobj.h> | 8 #include <shlobj.h> |
| 9 #include <time.h> | 9 #include <time.h> |
| 10 | 10 |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 240 << ", old version: " << (*current_version)->GetString(); | 240 << ", old version: " << (*current_version)->GetString(); |
| 241 | 241 |
| 242 return installer::INSTALL_FAILED; | 242 return installer::INSTALL_FAILED; |
| 243 } | 243 } |
| 244 | 244 |
| 245 // Deletes the old "Uninstall Google Chrome" shortcut in the Start menu and, if | 245 // Deletes the old "Uninstall Google Chrome" shortcut in the Start menu and, if |
| 246 // this is a system-level install, also deletes the old Default user Quick | 246 // this is a system-level install, also deletes the old Default user Quick |
| 247 // Launch shortcut. Both of these were created prior to Chrome 24; in Chrome 24, | 247 // Launch shortcut. Both of these were created prior to Chrome 24; in Chrome 24, |
| 248 // the uninstall shortcut was removed and the Default user Quick Launch shortcut | 248 // the uninstall shortcut was removed and the Default user Quick Launch shortcut |
| 249 // was replaced by per-user shortcuts created via Active Setup. | 249 // was replaced by per-user shortcuts created via Active Setup. |
| 250 void CleanupLegacyShortcuts(const InstallerState& installer_state, | 250 void CleanupLegacyChromeShortcuts(const InstallerState& installer_state, |
| 251 BrowserDistribution* dist, | 251 BrowserDistribution* dist, |
| 252 const base::FilePath& chrome_exe) { | 252 const base::FilePath& chrome_exe) { |
| 253 ShellUtil::ShellChange shortcut_level = installer_state.system_install() ? | 253 ShellUtil::ShellChange shortcut_level = installer_state.system_install() ? |
| 254 ShellUtil::SYSTEM_LEVEL : ShellUtil::CURRENT_USER; | 254 ShellUtil::SYSTEM_LEVEL : ShellUtil::CURRENT_USER; |
| 255 base::FilePath uninstall_shortcut_path; | 255 base::FilePath uninstall_shortcut_path; |
| 256 ShellUtil::GetShortcutPath(ShellUtil::SHORTCUT_LOCATION_START_MENU, dist, | 256 ShellUtil::GetShortcutPath(ShellUtil::SHORTCUT_LOCATION_START_MENU, dist, |
| 257 shortcut_level, &uninstall_shortcut_path); | 257 shortcut_level, &uninstall_shortcut_path); |
| 258 uninstall_shortcut_path = uninstall_shortcut_path.Append( | 258 uninstall_shortcut_path = uninstall_shortcut_path.Append( |
| 259 dist->GetUninstallLinkName() + installer::kLnkExt); | 259 dist->GetUninstallLinkName() + installer::kLnkExt); |
| 260 file_util::Delete(uninstall_shortcut_path, false); | 260 file_util::Delete(uninstall_shortcut_path, false); |
| 261 | 261 |
| 262 if (installer_state.system_install()) { | 262 if (installer_state.system_install()) { |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 276 BrowserDistribution::CHROME_APP_HOST); | 276 BrowserDistribution::CHROME_APP_HOST); |
| 277 bool app_launcher_exists = original_app_host_state && | 277 bool app_launcher_exists = original_app_host_state && |
| 278 original_app_host_state->uninstall_command() | 278 original_app_host_state->uninstall_command() |
| 279 .HasSwitch(installer::switches::kChromeAppLauncher); | 279 .HasSwitch(installer::switches::kChromeAppLauncher); |
| 280 if (!app_launcher_exists) | 280 if (!app_launcher_exists) |
| 281 return installer::INSTALL_SHORTCUT_CREATE_ALL; | 281 return installer::INSTALL_SHORTCUT_CREATE_ALL; |
| 282 | 282 |
| 283 return installer::INSTALL_SHORTCUT_REPLACE_EXISTING; | 283 return installer::INSTALL_SHORTCUT_REPLACE_EXISTING; |
| 284 } | 284 } |
| 285 | 285 |
| 286 void MigrateLagacyAppLauncherShortcuts(const InstallerState& installer_state) { | |
| 287 const base::FilePath app_host_exe( | |
| 288 installer_state.target_path().Append(installer::kChromeAppHostExe)); | |
| 289 const base::FilePath chrome_exe( | |
| 290 installer_state.target_path().Append(installer::kChromeExe)); | |
| 291 } | |
|
gab
2013/04/29 20:25:41
This doesn't do anything :)
huangs
2013/04/30 14:01:49
This is a stub to call code in
https://chromiumcod
| |
| 292 | |
| 286 } // end namespace | 293 } // end namespace |
| 287 | 294 |
| 288 namespace installer { | 295 namespace installer { |
| 289 | 296 |
| 290 void EscapeXmlAttributeValueInSingleQuotes(string16* att_value) { | 297 void EscapeXmlAttributeValueInSingleQuotes(string16* att_value) { |
| 291 ReplaceChars(*att_value, L"&", L"&", att_value); | 298 ReplaceChars(*att_value, L"&", L"&", att_value); |
| 292 ReplaceChars(*att_value, L"'", L"'", att_value); | 299 ReplaceChars(*att_value, L"'", L"'", att_value); |
| 293 ReplaceChars(*att_value, L"<", L"<", att_value); | 300 ReplaceChars(*att_value, L"<", L"<", att_value); |
| 294 } | 301 } |
| 295 | 302 |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 525 // installed and for the binaries in case of multi-install. | 532 // installed and for the binaries in case of multi-install. |
| 526 installer_state.UpdateChannels(); | 533 installer_state.UpdateChannels(); |
| 527 | 534 |
| 528 installer_state.UpdateStage(installer::COPYING_PREFERENCES_FILE); | 535 installer_state.UpdateStage(installer::COPYING_PREFERENCES_FILE); |
| 529 | 536 |
| 530 if (result == FIRST_INSTALL_SUCCESS && !prefs_path.empty()) | 537 if (result == FIRST_INSTALL_SUCCESS && !prefs_path.empty()) |
| 531 CopyPreferenceFileForFirstRun(installer_state, prefs_path); | 538 CopyPreferenceFileForFirstRun(installer_state, prefs_path); |
| 532 | 539 |
| 533 installer_state.UpdateStage(installer::CREATING_SHORTCUTS); | 540 installer_state.UpdateStage(installer::CREATING_SHORTCUTS); |
| 534 | 541 |
| 542 InstallShortcutLevel install_level = installer_state.system_install() ? | |
| 543 ALL_USERS : CURRENT_USER; | |
| 544 const base::FilePath chrome_exe( | |
|
gab
2013/04/29 20:25:41
indent
huangs
2013/04/30 14:01:49
Done.
| |
| 545 installer_state.target_path().Append(kChromeExe)); | |
| 546 | |
| 535 const Product* app_launcher_product = | 547 const Product* app_launcher_product = |
| 536 installer_state.FindProduct(BrowserDistribution::CHROME_APP_HOST); | 548 installer_state.FindProduct(BrowserDistribution::CHROME_APP_HOST); |
| 537 // Creates shortcuts for App Launcher. | 549 // Creates shortcuts for App Launcher. |
| 538 if (app_launcher_product) { | 550 if (app_launcher_product) { |
| 539 // TODO(huangs): Remove this check once we have system-level App Host. | 551 // If we have a legacy user-level App Launcher that uses app_host.exe, |
| 540 DCHECK(!installer_state.system_install()); | 552 // then migrate shortcuts. |
| 541 const base::FilePath app_host_exe( | 553 if (!installer_state.system_install()) { |
| 542 installer_state.target_path().Append(kChromeAppHostExe)); | 554 const ProductState* orig_product = original_state.GetProductState( |
| 543 InstallShortcutOperation app_launcher_shortcut_operation = | 555 false, BrowserDistribution::CHROME_APP_HOST); |
| 544 GetAppLauncherShortcutOperation(original_state, installer_state); | 556 if (orig_product && chrome_launcher_support::HasLegacyAppHostExe( |
| 545 | 557 orig_product->version())) { |
| 546 // Always install per-user shortcuts for App Launcher. | 558 MigrateLagacyAppLauncherShortcuts(installer_state); |
| 547 CreateOrUpdateShortcuts(app_host_exe, *app_launcher_product, prefs, | 559 } |
| 548 CURRENT_USER, app_launcher_shortcut_operation); | 560 } |
| 561 if (installer_state.create_app_launcher_shortcuts()) { | |
| 562 InstallShortcutOperation app_launcher_shortcut_operation = | |
| 563 GetAppLauncherShortcutOperation(original_state, installer_state); | |
| 564 CreateOrUpdateShortcuts(chrome_exe, *app_launcher_product, prefs, | |
| 565 install_level, app_launcher_shortcut_operation); | |
|
gab
2013/04/29 20:25:41
Wait, are we creating All-users app launcher short
huangs
2013/04/30 14:01:49
Chrome and App Launcher are unified, so whatever C
| |
| 566 } | |
| 549 } | 567 } |
| 550 | 568 |
| 551 const Product* chrome_product = | 569 const Product* chrome_product = |
| 552 installer_state.FindProduct(BrowserDistribution::CHROME_BROWSER); | 570 installer_state.FindProduct(BrowserDistribution::CHROME_BROWSER); |
| 553 // Creates shortcuts for Chrome. | 571 // Creates shortcuts for Chrome. |
| 554 if (chrome_product) { | 572 if (chrome_product) { |
| 555 BrowserDistribution* chrome_dist = chrome_product->distribution(); | 573 BrowserDistribution* chrome_dist = chrome_product->distribution(); |
| 556 const base::FilePath chrome_exe( | 574 CleanupLegacyChromeShortcuts(installer_state, chrome_dist, chrome_exe); |
| 557 installer_state.target_path().Append(kChromeExe)); | |
| 558 CleanupLegacyShortcuts(installer_state, chrome_dist, chrome_exe); | |
| 559 | 575 |
| 560 // Install per-user shortcuts on user-level installs and all-users | 576 // Install per-user shortcuts on user-level installs and all-users |
|
gab
2013/04/29 20:25:41
This comment belonged with the code that moved.
huangs
2013/04/30 14:01:49
I thought this refers to CreateOrUpdateShortcuts()
| |
| 561 // shortcuts on system-level installs. Note that Active Setup will take | 577 // shortcuts on system-level installs. Note that Active Setup will take |
| 562 // care of installing missing per-user shortcuts on system-level install | 578 // care of installing missing per-user shortcuts on system-level install |
| 563 // (i.e., quick launch, taskbar pin, and possibly deleted all-users | 579 // (i.e., quick launch, taskbar pin, and possibly deleted all-users |
| 564 // shortcuts). | 580 // shortcuts). |
| 565 InstallShortcutLevel install_level = installer_state.system_install() ? | |
| 566 ALL_USERS : CURRENT_USER; | |
| 567 | |
| 568 InstallShortcutOperation install_operation = | 581 InstallShortcutOperation install_operation = |
| 569 INSTALL_SHORTCUT_REPLACE_EXISTING; | 582 INSTALL_SHORTCUT_REPLACE_EXISTING; |
| 570 if (result == installer::FIRST_INSTALL_SUCCESS || | 583 if (result == installer::FIRST_INSTALL_SUCCESS || |
| 571 result == installer::INSTALL_REPAIRED || | 584 result == installer::INSTALL_REPAIRED || |
| 572 !original_state.GetProductState(installer_state.system_install(), | 585 !original_state.GetProductState(installer_state.system_install(), |
| 573 chrome_dist->GetType())) { | 586 chrome_dist->GetType())) { |
| 574 // Always create the shortcuts on a new install, a repair install, and | 587 // Always create the shortcuts on a new install, a repair install, and |
| 575 // when the Chrome product is being added to the current install. | 588 // when the Chrome product is being added to the current install. |
| 576 install_operation = INSTALL_SHORTCUT_CREATE_ALL; | 589 install_operation = INSTALL_SHORTCUT_CREATE_ALL; |
| 577 } | 590 } |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 689 if (app_host_path.empty()) | 702 if (app_host_path.empty()) |
| 690 return false; | 703 return false; |
| 691 | 704 |
| 692 CommandLine cmd(app_host_path); | 705 CommandLine cmd(app_host_path); |
| 693 cmd.AppendSwitchASCII(::switches::kInstallFromWebstore, app_code); | 706 cmd.AppendSwitchASCII(::switches::kInstallFromWebstore, app_code); |
| 694 VLOG(1) << "App install command: " << cmd.GetCommandLineString(); | 707 VLOG(1) << "App install command: " << cmd.GetCommandLineString(); |
| 695 return base::LaunchProcess(cmd, base::LaunchOptions(), NULL); | 708 return base::LaunchProcess(cmd, base::LaunchOptions(), NULL); |
| 696 } | 709 } |
| 697 | 710 |
| 698 } // namespace installer | 711 } // namespace installer |
| OLD | NEW |