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 11 matching lines...) Expand all Loading... | |
| 22 #include "base/utf_string_conversions.h" | 22 #include "base/utf_string_conversions.h" |
| 23 #include "base/win/shortcut.h" | 23 #include "base/win/shortcut.h" |
| 24 #include "base/win/windows_version.h" | 24 #include "base/win/windows_version.h" |
| 25 #include "chrome/common/chrome_constants.h" | 25 #include "chrome/common/chrome_constants.h" |
| 26 #include "chrome/common/chrome_switches.h" | 26 #include "chrome/common/chrome_switches.h" |
| 27 #include "chrome/installer/launcher_support/chrome_launcher_support.h" | 27 #include "chrome/installer/launcher_support/chrome_launcher_support.h" |
| 28 #include "chrome/installer/setup/install_worker.h" | 28 #include "chrome/installer/setup/install_worker.h" |
| 29 #include "chrome/installer/setup/setup_constants.h" | 29 #include "chrome/installer/setup/setup_constants.h" |
| 30 #include "chrome/installer/util/auto_launch_util.h" | 30 #include "chrome/installer/util/auto_launch_util.h" |
| 31 #include "chrome/installer/util/browser_distribution.h" | 31 #include "chrome/installer/util/browser_distribution.h" |
| 32 #include "chrome/installer/util/chrome_app_host_distribution.h" | |
| 32 #include "chrome/installer/util/create_reg_key_work_item.h" | 33 #include "chrome/installer/util/create_reg_key_work_item.h" |
| 33 #include "chrome/installer/util/delete_after_reboot_helper.h" | 34 #include "chrome/installer/util/delete_after_reboot_helper.h" |
| 34 #include "chrome/installer/util/google_update_constants.h" | 35 #include "chrome/installer/util/google_update_constants.h" |
| 35 #include "chrome/installer/util/helper.h" | 36 #include "chrome/installer/util/helper.h" |
| 36 #include "chrome/installer/util/install_util.h" | 37 #include "chrome/installer/util/install_util.h" |
| 37 #include "chrome/installer/util/master_preferences.h" | 38 #include "chrome/installer/util/master_preferences.h" |
| 38 #include "chrome/installer/util/master_preferences_constants.h" | 39 #include "chrome/installer/util/master_preferences_constants.h" |
| 39 #include "chrome/installer/util/set_reg_value_work_item.h" | 40 #include "chrome/installer/util/set_reg_value_work_item.h" |
| 40 #include "chrome/installer/util/shell_util.h" | 41 #include "chrome/installer/util/shell_util.h" |
| 41 #include "chrome/installer/util/util_constants.h" | 42 #include "chrome/installer/util/util_constants.h" |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 72 switch (location) { | 73 switch (location) { |
| 73 case ShellUtil::SHORTCUT_LOCATION_DESKTOP: | 74 case ShellUtil::SHORTCUT_LOCATION_DESKTOP: |
| 74 message.append("Desktop "); | 75 message.append("Desktop "); |
| 75 break; | 76 break; |
| 76 case ShellUtil::SHORTCUT_LOCATION_QUICK_LAUNCH: | 77 case ShellUtil::SHORTCUT_LOCATION_QUICK_LAUNCH: |
| 77 message.append("Quick Launch "); | 78 message.append("Quick Launch "); |
| 78 break; | 79 break; |
| 79 case ShellUtil::SHORTCUT_LOCATION_START_MENU: | 80 case ShellUtil::SHORTCUT_LOCATION_START_MENU: |
| 80 message.append("Start menu "); | 81 message.append("Start menu "); |
| 81 break; | 82 break; |
| 83 case ShellUtil::SHORTCUT_LOCATION_START_MENU_ROOT: | |
|
gab
2013/05/15 22:42:20
We will never create Chrome shortcuts at the root,
huangs
2013/05/17 20:59:24
Removing.
| |
| 84 message.append("Start menu root "); | |
| 85 break; | |
| 82 default: | 86 default: |
| 83 NOTREACHED(); | 87 NOTREACHED(); |
| 84 } | 88 } |
| 85 | 89 |
| 86 message.push_back('"'); | 90 message.push_back('"'); |
| 87 if (properties.has_shortcut_name()) | 91 if (properties.has_shortcut_name()) |
| 88 message.append(UTF16ToUTF8(properties.shortcut_name)); | 92 message.append(UTF16ToUTF8(properties.shortcut_name)); |
| 89 else | 93 else |
| 90 message.append(UTF16ToUTF8(dist->GetAppShortCutName())); | 94 message.append(UTF16ToUTF8(dist->GetAppShortCutName())); |
| 91 message.push_back('"'); | 95 message.push_back('"'); |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 240 << ", old version: " << (*current_version)->GetString(); | 244 << ", old version: " << (*current_version)->GetString(); |
| 241 | 245 |
| 242 return installer::INSTALL_FAILED; | 246 return installer::INSTALL_FAILED; |
| 243 } | 247 } |
| 244 | 248 |
| 245 // Deletes the old "Uninstall Google Chrome" shortcut in the Start menu and, if | 249 // 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 | 250 // 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, | 251 // 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 | 252 // the uninstall shortcut was removed and the Default user Quick Launch shortcut |
| 249 // was replaced by per-user shortcuts created via Active Setup. | 253 // was replaced by per-user shortcuts created via Active Setup. |
| 250 void CleanupLegacyShortcuts(const InstallerState& installer_state, | 254 void CleanupLegacyChromeShortcuts(const InstallerState& installer_state, |
| 251 BrowserDistribution* dist, | 255 BrowserDistribution* dist, |
| 252 const base::FilePath& chrome_exe) { | 256 const base::FilePath& chrome_exe) { |
| 253 ShellUtil::ShellChange shortcut_level = installer_state.system_install() ? | 257 ShellUtil::ShellChange shortcut_level = installer_state.system_install() ? |
| 254 ShellUtil::SYSTEM_LEVEL : ShellUtil::CURRENT_USER; | 258 ShellUtil::SYSTEM_LEVEL : ShellUtil::CURRENT_USER; |
| 255 base::FilePath uninstall_shortcut_path; | 259 base::FilePath uninstall_shortcut_path; |
| 256 ShellUtil::GetShortcutPath(ShellUtil::SHORTCUT_LOCATION_START_MENU, dist, | 260 ShellUtil::GetShortcutPath(ShellUtil::SHORTCUT_LOCATION_START_MENU, dist, |
| 257 shortcut_level, &uninstall_shortcut_path); | 261 shortcut_level, &uninstall_shortcut_path); |
| 258 uninstall_shortcut_path = uninstall_shortcut_path.Append( | 262 uninstall_shortcut_path = uninstall_shortcut_path.Append( |
| 259 dist->GetUninstallLinkName() + installer::kLnkExt); | 263 dist->GetUninstallLinkName() + installer::kLnkExt); |
| 260 file_util::Delete(uninstall_shortcut_path, false); | 264 file_util::Delete(uninstall_shortcut_path, false); |
| 261 | 265 |
| 262 if (installer_state.system_install()) { | 266 if (installer_state.system_install()) { |
| 263 ShellUtil::RemoveShortcuts( | 267 ShellUtil::RemoveShortcuts( |
| 264 ShellUtil::SHORTCUT_LOCATION_QUICK_LAUNCH, dist, | 268 ShellUtil::SHORTCUT_LOCATION_QUICK_LAUNCH, dist, |
| 265 ShellUtil::SYSTEM_LEVEL, chrome_exe); | 269 ShellUtil::SYSTEM_LEVEL, chrome_exe); |
| 266 } | 270 } |
| 267 } | 271 } |
| 268 | 272 |
| 269 // Returns the appropriate shortcut operations for App Launcher, | 273 // Returns the appropriate shortcut operations for App Launcher, |
| 270 // based on state of installation and master_preferences. | 274 // based on state of installation and master_preferences. |
| 271 installer::InstallShortcutOperation GetAppLauncherShortcutOperation( | 275 installer::InstallShortcutOperation GetAppLauncherShortcutOperation( |
| 272 const InstallationState& original_state, | 276 const InstallationState& original_state, |
| 273 const InstallerState& installer_state) { | 277 const InstallerState& installer_state) { |
| 274 const installer::ProductState* original_app_host_state = | 278 const installer::ProductState* original_app_host_state = |
| 275 original_state.GetProductState(installer_state.system_install(), | 279 original_state.GetProductState(installer_state.system_install(), |
| 276 BrowserDistribution::CHROME_APP_HOST); | 280 BrowserDistribution::CHROME_APP_HOST); |
| 281 if (installer_state.need_to_migrate_legacy_app_launcher() || | |
| 282 installer_state.create_app_launcher_shortcuts()) | |
| 283 return installer::INSTALL_SHORTCUT_CREATE_ALL; | |
|
gab
2013/05/15 22:42:20
nit: wrap in {}
huangs
2013/05/17 20:59:24
Done.
| |
| 284 | |
| 277 bool app_launcher_exists = original_app_host_state && | 285 bool app_launcher_exists = original_app_host_state && |
| 278 original_app_host_state->uninstall_command() | 286 original_app_host_state->uninstall_command() |
| 279 .HasSwitch(installer::switches::kChromeAppLauncher); | 287 .HasSwitch(installer::switches::kChromeAppLauncher); |
| 280 if (!app_launcher_exists) | 288 if (!app_launcher_exists) |
| 281 return installer::INSTALL_SHORTCUT_CREATE_ALL; | 289 return installer::INSTALL_SHORTCUT_CREATE_ALL; |
| 282 | 290 |
| 283 return installer::INSTALL_SHORTCUT_REPLACE_EXISTING; | 291 return installer::INSTALL_SHORTCUT_REPLACE_EXISTING; |
| 284 } | 292 } |
| 285 | 293 |
| 294 // As of M29, App Launcher is unified with Chrome. app_host.exe is deleted, and | |
| 295 // all shortcuts that target app_host.exe must now target chrome.exe. | |
| 296 // Shortcuts to the App Launcher also require icons update. | |
| 297 void MigrateLegacyAppLauncherShortcuts(const InstallerState& installer_state) { | |
| 298 LegacyChromeAppHostDistribution legacy_dist; | |
| 299 BrowserDistribution* dist = BrowserDistribution::GetSpecificDistribution( | |
| 300 BrowserDistribution::CHROME_APP_HOST); | |
| 301 base::FilePath app_host_exe( | |
| 302 installer_state.target_path().Append(installer::kChromeAppHostExe)); | |
| 303 base::FilePath chrome_exe( | |
| 304 installer_state.target_path().Append(installer::kChromeExe)); | |
| 305 | |
| 306 // Remove deprecated start menu folder "Google Chrome App Launcher". | |
| 307 ShellUtil::RemoveShortcuts( | |
| 308 ShellUtil::SHORTCUT_LOCATION_START_MENU, &legacy_dist, | |
| 309 ShellUtil::CURRENT_USER, app_host_exe); | |
| 310 | |
| 311 VLOG(1) << "Migrating legacy App Launcher shortcuts."; | |
| 312 ShellUtil::ShortcutLocation update_location_list[] = { | |
| 313 ShellUtil::SHORTCUT_LOCATION_DESKTOP, | |
| 314 ShellUtil::SHORTCUT_LOCATION_QUICK_LAUNCH, | |
| 315 ShellUtil::SHORTCUT_LOCATION_START_MENU_ROOT, | |
| 316 ShellUtil::SHORTCUT_LOCATION_TASKBAR_PINS, | |
| 317 ShellUtil::SHORTCUT_LOCATION_APP_SHORTCUTS | |
| 318 }; | |
| 319 | |
| 320 // Using wild card in case duplicate shortcuts exist. | |
| 321 string16 name_filter_main(dist->GetAppShortCutName() + L"*" + | |
| 322 installer::kLnkExt); | |
| 323 | |
| 324 ShellUtil::ShortcutProperties updated_properties_app_host_exe( | |
| 325 installer_state.system_install() ? ShellUtil::SYSTEM_LEVEL : | |
| 326 ShellUtil::CURRENT_USER); | |
| 327 updated_properties_app_host_exe.set_target(chrome_exe); | |
| 328 updated_properties_app_host_exe.set_icon( | |
| 329 installer_state.target_path().Append(dist->GetIconFilename()), | |
| 330 dist->GetIconIndex()); | |
| 331 | |
| 332 ShellUtil::ShortcutProperties updated_properties_user_generated( | |
| 333 installer_state.system_install() ? ShellUtil::SYSTEM_LEVEL : | |
| 334 ShellUtil::CURRENT_USER); | |
| 335 updated_properties_user_generated.set_target(chrome_exe); | |
| 336 | |
| 337 for (int i = 0; i < arraysize(update_location_list); ++i) { | |
| 338 // Migrate App Launcher shortcuts (executable and icon changes). | |
| 339 ShellUtil::UpdateShortcutsFilteredByName( | |
| 340 update_location_list[i], dist, ShellUtil::CURRENT_USER, | |
| 341 name_filter_main, app_host_exe, updated_properties_app_host_exe); | |
| 342 // Migrate user-generated shortcuts (executable changes only). | |
| 343 ShellUtil::UpdateShortcuts( | |
| 344 update_location_list[i], dist, ShellUtil::CURRENT_USER, | |
| 345 app_host_exe, updated_properties_user_generated); | |
| 346 } | |
| 347 } | |
| 348 | |
| 286 } // end namespace | 349 } // end namespace |
| 287 | 350 |
| 288 namespace installer { | 351 namespace installer { |
| 289 | 352 |
| 290 void EscapeXmlAttributeValueInSingleQuotes(string16* att_value) { | 353 void EscapeXmlAttributeValueInSingleQuotes(string16* att_value) { |
| 291 ReplaceChars(*att_value, L"&", L"&", att_value); | 354 ReplaceChars(*att_value, L"&", L"&", att_value); |
| 292 ReplaceChars(*att_value, L"'", L"'", att_value); | 355 ReplaceChars(*att_value, L"'", L"'", att_value); |
| 293 ReplaceChars(*att_value, L"<", L"<", att_value); | 356 ReplaceChars(*att_value, L"<", L"<", att_value); |
| 294 } | 357 } |
| 295 | 358 |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 525 // installed and for the binaries in case of multi-install. | 588 // installed and for the binaries in case of multi-install. |
| 526 installer_state.UpdateChannels(); | 589 installer_state.UpdateChannels(); |
| 527 | 590 |
| 528 installer_state.UpdateStage(installer::COPYING_PREFERENCES_FILE); | 591 installer_state.UpdateStage(installer::COPYING_PREFERENCES_FILE); |
| 529 | 592 |
| 530 if (result == FIRST_INSTALL_SUCCESS && !prefs_path.empty()) | 593 if (result == FIRST_INSTALL_SUCCESS && !prefs_path.empty()) |
| 531 CopyPreferenceFileForFirstRun(installer_state, prefs_path); | 594 CopyPreferenceFileForFirstRun(installer_state, prefs_path); |
| 532 | 595 |
| 533 installer_state.UpdateStage(installer::CREATING_SHORTCUTS); | 596 installer_state.UpdateStage(installer::CREATING_SHORTCUTS); |
| 534 | 597 |
| 598 InstallShortcutLevel install_level = installer_state.system_install() ? | |
| 599 ALL_USERS : CURRENT_USER; | |
| 600 const base::FilePath chrome_exe( | |
| 601 installer_state.target_path().Append(kChromeExe)); | |
| 602 | |
| 535 const Product* app_launcher_product = | 603 const Product* app_launcher_product = |
| 536 installer_state.FindProduct(BrowserDistribution::CHROME_APP_HOST); | 604 installer_state.FindProduct(BrowserDistribution::CHROME_APP_HOST); |
| 537 // Creates shortcuts for App Launcher. | 605 // Creates shortcuts for App Launcher. |
| 538 if (app_launcher_product) { | 606 if (app_launcher_product) { |
| 539 // TODO(huangs): Remove this check once we have system-level App Host. | 607 if (installer_state.need_to_migrate_legacy_app_launcher()) { |
| 540 DCHECK(!installer_state.system_install()); | 608 MigrateLegacyAppLauncherShortcuts(installer_state); |
|
grt (UTC plus 2)
2013/05/16 14:55:52
Are legacy shortcuts only per-user shortcuts?
huangs
2013/05/17 20:59:24
Yes for the installer, I think so, also for user-c
| |
| 541 const base::FilePath app_host_exe( | 609 } |
| 542 installer_state.target_path().Append(kChromeAppHostExe)); | 610 if (installer_state.create_app_launcher_shortcuts()) { |
| 543 InstallShortcutOperation app_launcher_shortcut_operation = | 611 InstallShortcutOperation app_launcher_shortcut_operation = |
| 544 GetAppLauncherShortcutOperation(original_state, installer_state); | 612 GetAppLauncherShortcutOperation(original_state, installer_state); |
| 545 | 613 CreateOrUpdateShortcuts(chrome_exe, *app_launcher_product, prefs, |
| 546 // Always install per-user shortcuts for App Launcher. | 614 install_level, app_launcher_shortcut_operation); |
|
gab
2013/05/15 22:42:20
I would prefer that we keep installing App Launche
huangs
2013/05/17 20:59:24
"per-user shortcuts" doesn't mean what I thought i
| |
| 547 CreateOrUpdateShortcuts(app_host_exe, *app_launcher_product, prefs, | 615 } |
| 548 CURRENT_USER, app_launcher_shortcut_operation); | |
| 549 } | 616 } |
| 550 | 617 |
| 551 const Product* chrome_product = | 618 const Product* chrome_product = |
| 552 installer_state.FindProduct(BrowserDistribution::CHROME_BROWSER); | 619 installer_state.FindProduct(BrowserDistribution::CHROME_BROWSER); |
| 553 // Creates shortcuts for Chrome. | 620 // Creates shortcuts for Chrome. |
| 554 if (chrome_product) { | 621 if (chrome_product) { |
| 555 BrowserDistribution* chrome_dist = chrome_product->distribution(); | 622 BrowserDistribution* chrome_dist = chrome_product->distribution(); |
| 556 const base::FilePath chrome_exe( | 623 CleanupLegacyChromeShortcuts(installer_state, chrome_dist, chrome_exe); |
| 557 installer_state.target_path().Append(kChromeExe)); | |
| 558 CleanupLegacyShortcuts(installer_state, chrome_dist, chrome_exe); | |
| 559 | 624 |
| 560 // Install per-user shortcuts on user-level installs and all-users | 625 // Install per-user shortcuts on user-level installs and all-users |
| 561 // shortcuts on system-level installs. Note that Active Setup will take | 626 // shortcuts on system-level installs. Note that Active Setup will take |
| 562 // care of installing missing per-user shortcuts on system-level install | 627 // care of installing missing per-user shortcuts on system-level install |
| 563 // (i.e., quick launch, taskbar pin, and possibly deleted all-users | 628 // (i.e., quick launch, taskbar pin, and possibly deleted all-users |
| 564 // shortcuts). | 629 // shortcuts). |
| 565 InstallShortcutLevel install_level = installer_state.system_install() ? | |
| 566 ALL_USERS : CURRENT_USER; | |
| 567 | |
| 568 InstallShortcutOperation install_operation = | 630 InstallShortcutOperation install_operation = |
| 569 INSTALL_SHORTCUT_REPLACE_EXISTING; | 631 INSTALL_SHORTCUT_REPLACE_EXISTING; |
| 570 if (result == installer::FIRST_INSTALL_SUCCESS || | 632 if (result == installer::FIRST_INSTALL_SUCCESS || |
| 571 result == installer::INSTALL_REPAIRED || | 633 result == installer::INSTALL_REPAIRED || |
| 572 !original_state.GetProductState(installer_state.system_install(), | 634 !original_state.GetProductState(installer_state.system_install(), |
| 573 chrome_dist->GetType())) { | 635 chrome_dist->GetType())) { |
| 574 // Always create the shortcuts on a new install, a repair install, and | 636 // Always create the shortcuts on a new install, a repair install, and |
| 575 // when the Chrome product is being added to the current install. | 637 // when the Chrome product is being added to the current install. |
| 576 install_operation = INSTALL_SHORTCUT_CREATE_ALL; | 638 install_operation = INSTALL_SHORTCUT_CREATE_ALL; |
| 577 } | 639 } |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 677 INSTALL_SHORTCUT_REPLACE_EXISTING : | 739 INSTALL_SHORTCUT_REPLACE_EXISTING : |
| 678 INSTALL_SHORTCUT_CREATE_EACH_IF_NO_SYSTEM_LEVEL); | 740 INSTALL_SHORTCUT_CREATE_EACH_IF_NO_SYSTEM_LEVEL); |
| 679 | 741 |
| 680 // Read master_preferences copied beside chrome.exe at install. | 742 // Read master_preferences copied beside chrome.exe at install. |
| 681 MasterPreferences prefs(installation_root.AppendASCII(kDefaultMasterPrefs)); | 743 MasterPreferences prefs(installation_root.AppendASCII(kDefaultMasterPrefs)); |
| 682 base::FilePath chrome_exe(installation_root.Append(kChromeExe)); | 744 base::FilePath chrome_exe(installation_root.Append(kChromeExe)); |
| 683 CreateOrUpdateShortcuts( | 745 CreateOrUpdateShortcuts( |
| 684 chrome_exe, chrome, prefs, CURRENT_USER, install_operation); | 746 chrome_exe, chrome, prefs, CURRENT_USER, install_operation); |
| 685 } | 747 } |
| 686 | 748 |
| 687 bool InstallFromWebstore(const std::string& app_code) { | 749 bool InstallFromWebstore(const std::string& app_code) { |
|
gab
2013/05/15 22:42:20
I can't find any callers of this in codesearch...
grt (UTC plus 2)
2013/05/16 14:55:52
It's called by setup_main.cc, which may not be ind
huangs
2013/05/17 20:59:24
No-op.
huangs
2013/05/17 20:59:24
No-op.
| |
| 688 base::FilePath app_host_path(chrome_launcher_support::GetAnyAppHostPath()); | 750 base::FilePath chrome_path(chrome_launcher_support::GetAnyChromePath()); |
| 689 if (app_host_path.empty()) | 751 if (chrome_path.empty()) |
| 690 return false; | 752 return false; |
| 691 | 753 |
| 692 CommandLine cmd(app_host_path); | 754 CommandLine cmd(chrome_path); |
| 693 cmd.AppendSwitchASCII(::switches::kInstallFromWebstore, app_code); | 755 cmd.AppendSwitchASCII(::switches::kInstallFromWebstore, app_code); |
| 694 VLOG(1) << "App install command: " << cmd.GetCommandLineString(); | 756 VLOG(1) << "App install command: " << cmd.GetCommandLineString(); |
| 695 return base::LaunchProcess(cmd, base::LaunchOptions(), NULL); | 757 return base::LaunchProcess(cmd, base::LaunchOptions(), NULL); |
| 696 } | 758 } |
| 697 | 759 |
| 698 } // namespace installer | 760 } // namespace installer |
| OLD | NEW |