Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(141)

Side by Side Diff: chrome/installer/setup/install.cc

Issue 14031025: Implementing unified Chrome / App Launcher flow, and migrating old stand-alone App Launcher. (Closed) Base URL: http://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removing Start Menu root stuff; cleanups. Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 << ", old version: " << (*current_version)->GetString(); 241 << ", old version: " << (*current_version)->GetString();
241 242
242 return installer::INSTALL_FAILED; 243 return installer::INSTALL_FAILED;
243 } 244 }
244 245
245 // Deletes the old "Uninstall Google Chrome" shortcut in the Start menu and, if 246 // 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 247 // 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, 248 // 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 249 // the uninstall shortcut was removed and the Default user Quick Launch shortcut
249 // was replaced by per-user shortcuts created via Active Setup. 250 // was replaced by per-user shortcuts created via Active Setup.
250 void CleanupLegacyShortcuts(const InstallerState& installer_state, 251 void CleanupLegacyChromeShortcuts(const InstallerState& installer_state,
251 BrowserDistribution* dist, 252 BrowserDistribution* dist,
252 const base::FilePath& chrome_exe) { 253 const base::FilePath& chrome_exe) {
253 ShellUtil::ShellChange shortcut_level = installer_state.system_install() ? 254 ShellUtil::ShellChange shortcut_level = installer_state.system_install() ?
254 ShellUtil::SYSTEM_LEVEL : ShellUtil::CURRENT_USER; 255 ShellUtil::SYSTEM_LEVEL : ShellUtil::CURRENT_USER;
255 base::FilePath uninstall_shortcut_path; 256 base::FilePath uninstall_shortcut_path;
256 ShellUtil::GetShortcutPath(ShellUtil::SHORTCUT_LOCATION_START_MENU, dist, 257 ShellUtil::GetShortcutPath(ShellUtil::SHORTCUT_LOCATION_START_MENU, dist,
257 shortcut_level, &uninstall_shortcut_path); 258 shortcut_level, &uninstall_shortcut_path);
258 uninstall_shortcut_path = uninstall_shortcut_path.Append( 259 uninstall_shortcut_path = uninstall_shortcut_path.Append(
259 dist->GetUninstallLinkName() + installer::kLnkExt); 260 dist->GetUninstallLinkName() + installer::kLnkExt);
260 file_util::Delete(uninstall_shortcut_path, false); 261 file_util::Delete(uninstall_shortcut_path, false);
261 262
262 if (installer_state.system_install()) { 263 if (installer_state.system_install()) {
263 ShellUtil::RemoveShortcuts( 264 ShellUtil::RemoveShortcuts(
264 ShellUtil::SHORTCUT_LOCATION_QUICK_LAUNCH, dist, 265 ShellUtil::SHORTCUT_LOCATION_QUICK_LAUNCH, dist,
265 ShellUtil::SYSTEM_LEVEL, chrome_exe); 266 ShellUtil::SYSTEM_LEVEL, chrome_exe);
266 } 267 }
267 } 268 }
268 269
269 // Returns the appropriate shortcut operations for App Launcher, 270 // Returns the appropriate shortcut operations for App Launcher,
270 // based on state of installation and master_preferences. 271 // based on state of installation and master_preferences.
271 installer::InstallShortcutOperation GetAppLauncherShortcutOperation( 272 installer::InstallShortcutOperation GetAppLauncherShortcutOperation(
272 const InstallationState& original_state, 273 const InstallationState& original_state,
273 const InstallerState& installer_state) { 274 const InstallerState& installer_state) {
274 const installer::ProductState* original_app_host_state = 275 const installer::ProductState* original_app_host_state =
275 original_state.GetProductState(installer_state.system_install(), 276 original_state.GetProductState(installer_state.system_install(),
276 BrowserDistribution::CHROME_APP_HOST); 277 BrowserDistribution::CHROME_APP_HOST);
278 if (installer_state.need_to_migrate_legacy_app_launcher() ||
279 installer_state.create_app_launcher_shortcuts()) {
280 return installer::INSTALL_SHORTCUT_CREATE_ALL;
281 }
282
277 bool app_launcher_exists = original_app_host_state && 283 bool app_launcher_exists = original_app_host_state &&
278 original_app_host_state->uninstall_command() 284 original_app_host_state->uninstall_command()
279 .HasSwitch(installer::switches::kChromeAppLauncher); 285 .HasSwitch(installer::switches::kChromeAppLauncher);
280 if (!app_launcher_exists) 286 if (!app_launcher_exists)
281 return installer::INSTALL_SHORTCUT_CREATE_ALL; 287 return installer::INSTALL_SHORTCUT_CREATE_ALL;
282 288
283 return installer::INSTALL_SHORTCUT_REPLACE_EXISTING; 289 return installer::INSTALL_SHORTCUT_REPLACE_EXISTING;
284 } 290 }
285 291
292 // As of M29, App Launcher is unified with Chrome. app_host.exe is deleted, and
293 // all shortcuts that target app_host.exe must now target chrome.exe.
294 // Shortcuts to the App Launcher also require icons update.
295 void MigrateLegacyAppLauncherShortcuts(const InstallerState& installer_state) {
296 LegacyChromeAppHostDistribution legacy_dist;
297 BrowserDistribution* dist = BrowserDistribution::GetSpecificDistribution(
298 BrowserDistribution::CHROME_APP_HOST);
299 base::FilePath app_host_exe(
300 installer_state.target_path().Append(installer::kChromeAppHostExe));
301 base::FilePath chrome_exe(
302 installer_state.target_path().Append(installer::kChromeExe));
303
304 // Remove deprecated start menu folder "Google Chrome App Launcher".
305 ShellUtil::RemoveShortcuts(
306 ShellUtil::SHORTCUT_LOCATION_START_MENU, &legacy_dist,
307 ShellUtil::CURRENT_USER, app_host_exe);
308
309 VLOG(1) << "Migrating legacy App Launcher shortcuts.";
310 ShellUtil::ShortcutLocation update_location_list[] = {
311 ShellUtil::SHORTCUT_LOCATION_DESKTOP,
312 ShellUtil::SHORTCUT_LOCATION_QUICK_LAUNCH,
313 ShellUtil::SHORTCUT_LOCATION_TASKBAR_PINS,
314 ShellUtil::SHORTCUT_LOCATION_APP_SHORTCUTS
315 };
316
317 // Using wild card in case duplicate shortcuts exist.
318 string16 name_filter_main(dist->GetAppShortCutName() + L"*" +
319 installer::kLnkExt);
320
321 ShellUtil::ShortcutProperties updated_properties_app_host_exe(
322 installer_state.system_install() ? ShellUtil::SYSTEM_LEVEL :
323 ShellUtil::CURRENT_USER);
324 updated_properties_app_host_exe.set_target(chrome_exe);
325 updated_properties_app_host_exe.set_icon(
326 installer_state.target_path().Append(dist->GetIconFilename()),
327 dist->GetIconIndex());
328
329 ShellUtil::ShortcutProperties updated_properties_user_generated(
330 installer_state.system_install() ? ShellUtil::SYSTEM_LEVEL :
331 ShellUtil::CURRENT_USER);
332 updated_properties_user_generated.set_target(chrome_exe);
333
334 for (int i = 0; i < arraysize(update_location_list); ++i) {
335 // Migrate App Launcher shortcuts (executable and icon changes).
336 ShellUtil::UpdateShortcutsFilteredByName(
337 update_location_list[i], dist, ShellUtil::CURRENT_USER,
338 name_filter_main, app_host_exe, updated_properties_app_host_exe);
339 // Migrate user-generated shortcuts (executable changes only).
340 ShellUtil::UpdateShortcuts(
341 update_location_list[i], dist, ShellUtil::CURRENT_USER,
342 app_host_exe, updated_properties_user_generated);
343 }
344 }
345
286 } // end namespace 346 } // end namespace
287 347
288 namespace installer { 348 namespace installer {
289 349
290 void EscapeXmlAttributeValueInSingleQuotes(string16* att_value) { 350 void EscapeXmlAttributeValueInSingleQuotes(string16* att_value) {
291 ReplaceChars(*att_value, L"&", L"&amp;", att_value); 351 ReplaceChars(*att_value, L"&", L"&amp;", att_value);
292 ReplaceChars(*att_value, L"'", L"&apos;", att_value); 352 ReplaceChars(*att_value, L"'", L"&apos;", att_value);
293 ReplaceChars(*att_value, L"<", L"&lt;", att_value); 353 ReplaceChars(*att_value, L"<", L"&lt;", att_value);
294 } 354 }
295 355
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 // installed and for the binaries in case of multi-install. 585 // installed and for the binaries in case of multi-install.
526 installer_state.UpdateChannels(); 586 installer_state.UpdateChannels();
527 587
528 installer_state.UpdateStage(installer::COPYING_PREFERENCES_FILE); 588 installer_state.UpdateStage(installer::COPYING_PREFERENCES_FILE);
529 589
530 if (result == FIRST_INSTALL_SUCCESS && !prefs_path.empty()) 590 if (result == FIRST_INSTALL_SUCCESS && !prefs_path.empty())
531 CopyPreferenceFileForFirstRun(installer_state, prefs_path); 591 CopyPreferenceFileForFirstRun(installer_state, prefs_path);
532 592
533 installer_state.UpdateStage(installer::CREATING_SHORTCUTS); 593 installer_state.UpdateStage(installer::CREATING_SHORTCUTS);
534 594
595 InstallShortcutLevel install_level = installer_state.system_install() ?
596 ALL_USERS : CURRENT_USER;
597 const base::FilePath chrome_exe(
598 installer_state.target_path().Append(kChromeExe));
599
535 const Product* app_launcher_product = 600 const Product* app_launcher_product =
536 installer_state.FindProduct(BrowserDistribution::CHROME_APP_HOST); 601 installer_state.FindProduct(BrowserDistribution::CHROME_APP_HOST);
537 // Creates shortcuts for App Launcher. 602 // Creates shortcuts for App Launcher.
538 if (app_launcher_product) { 603 if (app_launcher_product) {
539 // TODO(huangs): Remove this check once we have system-level App Host. 604 if (installer_state.need_to_migrate_legacy_app_launcher()) {
540 DCHECK(!installer_state.system_install()); 605 MigrateLegacyAppLauncherShortcuts(installer_state);
huangs 2013/06/04 13:50:31 Do this only for user-level installs and updates,
541 const base::FilePath app_host_exe( 606 }
542 installer_state.target_path().Append(kChromeAppHostExe)); 607 if (installer_state.create_app_launcher_shortcuts()) {
543 InstallShortcutOperation app_launcher_shortcut_operation = 608 InstallShortcutOperation app_launcher_shortcut_operation =
544 GetAppLauncherShortcutOperation(original_state, installer_state); 609 GetAppLauncherShortcutOperation(original_state, installer_state);
545 610 CreateOrUpdateShortcuts(chrome_exe, *app_launcher_product, prefs,
546 // Always install per-user shortcuts for App Launcher. 611 CURRENT_USER, app_launcher_shortcut_operation);
547 CreateOrUpdateShortcuts(app_host_exe, *app_launcher_product, prefs, 612 }
548 CURRENT_USER, app_launcher_shortcut_operation);
549 } 613 }
550 614
551 const Product* chrome_product = 615 const Product* chrome_product =
552 installer_state.FindProduct(BrowserDistribution::CHROME_BROWSER); 616 installer_state.FindProduct(BrowserDistribution::CHROME_BROWSER);
553 // Creates shortcuts for Chrome. 617 // Creates shortcuts for Chrome.
554 if (chrome_product) { 618 if (chrome_product) {
555 BrowserDistribution* chrome_dist = chrome_product->distribution(); 619 BrowserDistribution* chrome_dist = chrome_product->distribution();
556 const base::FilePath chrome_exe( 620 CleanupLegacyChromeShortcuts(installer_state, chrome_dist, chrome_exe);
557 installer_state.target_path().Append(kChromeExe));
558 CleanupLegacyShortcuts(installer_state, chrome_dist, chrome_exe);
559 621
560 // Install per-user shortcuts on user-level installs and all-users 622 // Install per-user shortcuts on user-level installs and all-users
561 // shortcuts on system-level installs. Note that Active Setup will take 623 // shortcuts on system-level installs. Note that Active Setup will take
562 // care of installing missing per-user shortcuts on system-level install 624 // care of installing missing per-user shortcuts on system-level install
563 // (i.e., quick launch, taskbar pin, and possibly deleted all-users 625 // (i.e., quick launch, taskbar pin, and possibly deleted all-users
564 // shortcuts). 626 // shortcuts).
565 InstallShortcutLevel install_level = installer_state.system_install() ?
566 ALL_USERS : CURRENT_USER;
567
568 InstallShortcutOperation install_operation = 627 InstallShortcutOperation install_operation =
569 INSTALL_SHORTCUT_REPLACE_EXISTING; 628 INSTALL_SHORTCUT_REPLACE_EXISTING;
570 if (result == installer::FIRST_INSTALL_SUCCESS || 629 if (result == installer::FIRST_INSTALL_SUCCESS ||
571 result == installer::INSTALL_REPAIRED || 630 result == installer::INSTALL_REPAIRED ||
572 !original_state.GetProductState(installer_state.system_install(), 631 !original_state.GetProductState(installer_state.system_install(),
573 chrome_dist->GetType())) { 632 chrome_dist->GetType())) {
574 // Always create the shortcuts on a new install, a repair install, and 633 // Always create the shortcuts on a new install, a repair install, and
575 // when the Chrome product is being added to the current install. 634 // when the Chrome product is being added to the current install.
576 install_operation = INSTALL_SHORTCUT_CREATE_ALL; 635 install_operation = INSTALL_SHORTCUT_CREATE_ALL;
577 } 636 }
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 INSTALL_SHORTCUT_CREATE_EACH_IF_NO_SYSTEM_LEVEL); 737 INSTALL_SHORTCUT_CREATE_EACH_IF_NO_SYSTEM_LEVEL);
679 738
680 // Read master_preferences copied beside chrome.exe at install. 739 // Read master_preferences copied beside chrome.exe at install.
681 MasterPreferences prefs(installation_root.AppendASCII(kDefaultMasterPrefs)); 740 MasterPreferences prefs(installation_root.AppendASCII(kDefaultMasterPrefs));
682 base::FilePath chrome_exe(installation_root.Append(kChromeExe)); 741 base::FilePath chrome_exe(installation_root.Append(kChromeExe));
683 CreateOrUpdateShortcuts( 742 CreateOrUpdateShortcuts(
684 chrome_exe, chrome, prefs, CURRENT_USER, install_operation); 743 chrome_exe, chrome, prefs, CURRENT_USER, install_operation);
685 } 744 }
686 745
687 bool InstallFromWebstore(const std::string& app_code) { 746 bool InstallFromWebstore(const std::string& app_code) {
688 base::FilePath app_host_path(chrome_launcher_support::GetAnyAppHostPath()); 747 base::FilePath chrome_path(chrome_launcher_support::GetAnyChromePath());
689 if (app_host_path.empty()) 748 if (chrome_path.empty())
690 return false; 749 return false;
691 750
692 CommandLine cmd(app_host_path); 751 CommandLine cmd(chrome_path);
693 cmd.AppendSwitchASCII(::switches::kInstallFromWebstore, app_code); 752 cmd.AppendSwitchASCII(::switches::kInstallFromWebstore, app_code);
694 VLOG(1) << "App install command: " << cmd.GetCommandLineString(); 753 VLOG(1) << "App install command: " << cmd.GetCommandLineString();
695 return base::LaunchProcess(cmd, base::LaunchOptions(), NULL); 754 return base::LaunchProcess(cmd, base::LaunchOptions(), NULL);
696 } 755 }
697 756
698 } // namespace installer 757 } // namespace installer
OLDNEW
« no previous file with comments | « no previous file | chrome/installer/setup/install_worker.cc » ('j') | chrome/installer/setup/setup_main.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698