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 <shlobj.h> | 7 #include <shlobj.h> |
8 #include <time.h> | 8 #include <time.h> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
80 // uninstalling chrome. | 80 // uninstalling chrome. |
81 // If first_install is false, the function only updates the shortcut for | 81 // If first_install is false, the function only updates the shortcut for |
82 // uninstalling chrome. According to | 82 // uninstalling chrome. According to |
83 // http://blogs.msdn.com/oldnewthing/archive/2005/11/24/496690.aspx, | 83 // http://blogs.msdn.com/oldnewthing/archive/2005/11/24/496690.aspx, |
84 // updating uninstall shortcut should not trigger Windows "new application | 84 // updating uninstall shortcut should not trigger Windows "new application |
85 // installed" notification. | 85 // installed" notification. |
86 // | 86 // |
87 // If the shortcuts do not exist, the function does not recreate them during | 87 // If the shortcuts do not exist, the function does not recreate them during |
88 // update. | 88 // update. |
89 // |options|: bitfield for which the options come from ChromeShortcutOptions. | 89 // |options|: bitfield for which the options come from ChromeShortcutOptions. |
90 void CreateOrUpdateChromeShortcuts(const InstallerState& installer_state, | 90 void CreateOrUpdateChromeShortcuts( |
91 const FilePath& setup_path, | 91 const InstallerState& installer_state, |
92 const Version& new_version, | 92 const FilePath& setup_path, |
93 installer::InstallStatus install_status, | 93 const Version& new_version, |
94 const Product& product, | 94 const installer::InstallStatus& install_status, |
grt (UTC plus 2)
2012/06/15 03:03:03
why pass a value of an enum by const ref?
gab
2012/06/15 19:01:04
Good question, I somehow thought it was an Object
| |
95 uint32 options) { | 95 const Product& product, |
96 uint32 options) { | |
96 // TODO(tommi): Change this function to use WorkItemList. | 97 // TODO(tommi): Change this function to use WorkItemList. |
97 DCHECK(product.is_chrome()); | 98 DCHECK(product.is_chrome()); |
98 | 99 |
99 // Information used for all shortcut types | 100 // Information used for all shortcut types |
100 BrowserDistribution* browser_dist = product.distribution(); | 101 BrowserDistribution* browser_dist = product.distribution(); |
101 const std::wstring product_name(browser_dist->GetAppShortCutName()); | 102 const std::wstring product_name(browser_dist->GetAppShortCutName()); |
102 const std::wstring product_desc(browser_dist->GetAppDescription()); | 103 const std::wstring product_desc(browser_dist->GetAppDescription()); |
103 // Chrome link target | 104 // Chrome link target |
104 FilePath chrome_exe( | 105 FilePath chrome_exe( |
105 installer_state.target_path().Append(installer::kChromeExe)); | 106 installer_state.target_path().Append(installer::kChromeExe)); |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
461 | 462 |
462 // Update the modifiers on the channel values for the product(s) being | 463 // Update the modifiers on the channel values for the product(s) being |
463 // installed and for the binaries in case of multi-install. | 464 // installed and for the binaries in case of multi-install. |
464 installer_state.UpdateChannels(); | 465 installer_state.UpdateChannels(); |
465 | 466 |
466 installer_state.UpdateStage(installer::COPYING_PREFERENCES_FILE); | 467 installer_state.UpdateStage(installer::COPYING_PREFERENCES_FILE); |
467 | 468 |
468 if (result == FIRST_INSTALL_SUCCESS && !prefs_path.empty()) | 469 if (result == FIRST_INSTALL_SUCCESS && !prefs_path.empty()) |
469 CopyPreferenceFileForFirstRun(installer_state, prefs_path); | 470 CopyPreferenceFileForFirstRun(installer_state, prefs_path); |
470 | 471 |
471 bool do_not_create_shortcuts = false; | |
472 prefs.GetBool(master_preferences::kDoNotCreateShortcuts, | |
grt (UTC plus 2)
2012/06/15 03:03:03
robert added this in http://crrev.com/25870. it e
robertshield
2012/06/15 03:27:59
This was added long ago for Chrome Frame, so that
grt (UTC plus 2)
2012/06/15 03:33:51
Do you know who we should ask about that?
gab
2012/06/15 19:01:04
This sounds like its wrong/unused, we should proba
| |
473 &do_not_create_shortcuts); | |
474 | |
475 // Currently this only creates shortcuts for Chrome, but for other products | 472 // Currently this only creates shortcuts for Chrome, but for other products |
476 // we might want to create shortcuts. | 473 // we might want to create shortcuts. |
477 const Product* chrome_install = | 474 const Product* chrome_install = |
478 installer_state.FindProduct(BrowserDistribution::CHROME_BROWSER); | 475 installer_state.FindProduct(BrowserDistribution::CHROME_BROWSER); |
479 if (chrome_install && !do_not_create_shortcuts) { | 476 if (chrome_install) { |
480 installer_state.UpdateStage(installer::CREATING_SHORTCUTS); | |
481 | |
482 bool create_all_shortcut = false; | |
483 prefs.GetBool(master_preferences::kCreateAllShortcuts, | |
484 &create_all_shortcut); | |
485 bool alt_shortcut = false; | |
486 prefs.GetBool(master_preferences::kAltShortcutText, &alt_shortcut); | |
487 uint32 shortcut_options = ShellUtil::SHORTCUT_NO_OPTIONS; | |
488 if (create_all_shortcut) | |
489 shortcut_options |= ShellUtil::SHORTCUT_CREATE_ALWAYS; | |
490 if (alt_shortcut) | |
491 shortcut_options |= ShellUtil::SHORTCUT_ALTERNATE; | |
492 CreateOrUpdateChromeShortcuts(installer_state, setup_path, | |
493 new_version, result, *chrome_install, | |
494 shortcut_options); | |
495 | |
496 bool make_chrome_default = false; | 477 bool make_chrome_default = false; |
497 prefs.GetBool(master_preferences::kMakeChromeDefault, | 478 prefs.GetBool(master_preferences::kMakeChromeDefault, |
498 &make_chrome_default); | 479 &make_chrome_default); |
499 | 480 |
500 // If this is not the user's first Chrome install, but they have chosen | 481 // If this is not the user's first Chrome install, but they have chosen |
501 // Chrome to become their default browser on the download page, we must | 482 // Chrome to become their default browser on the download page, we must |
502 // force it here because the master_preferences file will not get copied | 483 // force it here because the master_preferences file will not get copied |
503 // into the build. | 484 // into the build. |
504 bool force_chrome_default_for_user = false; | 485 bool force_chrome_default_for_user = false; |
505 if (result == NEW_VERSION_UPDATED || | 486 if (result == NEW_VERSION_UPDATED || |
506 result == INSTALL_REPAIRED) { | 487 result == INSTALL_REPAIRED) { |
507 prefs.GetBool(master_preferences::kMakeChromeDefaultForUser, | 488 prefs.GetBool(master_preferences::kMakeChromeDefaultForUser, |
508 &force_chrome_default_for_user); | 489 &force_chrome_default_for_user); |
509 } | 490 } |
510 | 491 |
511 installer_state.UpdateStage(installer::REGISTERING_CHROME); | 492 installer_state.UpdateStage(installer::REGISTERING_CHROME); |
512 | 493 |
494 // Chrome must be registered before creating shortcuts as the registration | |
495 // determines the appid that will later be embedded in the shortcut. | |
513 RegisterChromeOnMachine(installer_state, *chrome_install, | 496 RegisterChromeOnMachine(installer_state, *chrome_install, |
514 make_chrome_default || force_chrome_default_for_user); | 497 make_chrome_default || force_chrome_default_for_user); |
515 | 498 |
499 bool do_not_create_shortcuts = false; | |
500 prefs.GetBool(master_preferences::kDoNotCreateShortcuts, | |
501 &do_not_create_shortcuts); | |
502 | |
503 if (!do_not_create_shortcuts) { | |
504 installer_state.UpdateStage(installer::CREATING_SHORTCUTS); | |
505 | |
506 bool create_all_shortcut = false; | |
507 prefs.GetBool(master_preferences::kCreateAllShortcuts, | |
508 &create_all_shortcut); | |
509 bool alt_shortcut = false; | |
510 prefs.GetBool(master_preferences::kAltShortcutText, &alt_shortcut); | |
511 uint32 shortcut_options = ShellUtil::SHORTCUT_NO_OPTIONS; | |
512 if (create_all_shortcut) | |
513 shortcut_options |= ShellUtil::SHORTCUT_CREATE_ALWAYS; | |
514 if (alt_shortcut) | |
515 shortcut_options |= ShellUtil::SHORTCUT_ALTERNATE; | |
516 CreateOrUpdateChromeShortcuts(installer_state, setup_path, | |
517 new_version, result, *chrome_install, | |
518 shortcut_options); | |
519 } | |
520 | |
516 if (result == FIRST_INSTALL_SUCCESS) { | 521 if (result == FIRST_INSTALL_SUCCESS) { |
517 installer_state.UpdateStage(installer::CONFIGURE_AUTO_LAUNCH); | 522 installer_state.UpdateStage(installer::CONFIGURE_AUTO_LAUNCH); |
518 | 523 |
519 // Add auto-launch key if specified in master preferences. | 524 // Add auto-launch key if specified in master preferences. |
520 bool auto_launch_chrome = false; | 525 bool auto_launch_chrome = false; |
521 prefs.GetBool( | 526 prefs.GetBool( |
522 installer::master_preferences::kAutoLaunchChrome, | 527 installer::master_preferences::kAutoLaunchChrome, |
523 &auto_launch_chrome); | 528 &auto_launch_chrome); |
524 if (auto_launch_chrome) { | 529 if (auto_launch_chrome) { |
525 auto_launch_util::EnableForegroundStartAtLogin( | 530 auto_launch_util::EnableForegroundStartAtLogin( |
526 ASCIIToUTF16(chrome::kInitialProfile), | 531 ASCIIToUTF16(chrome::kInitialProfile), |
527 installer_state.target_path()); | 532 installer_state.target_path()); |
528 } | 533 } |
529 } | 534 } |
530 } | 535 } |
531 | 536 |
532 installer_state.UpdateStage(installer::REMOVING_OLD_VERSIONS); | 537 installer_state.UpdateStage(installer::REMOVING_OLD_VERSIONS); |
533 | 538 |
534 installer_state.RemoveOldVersionDirectories( | 539 installer_state.RemoveOldVersionDirectories( |
535 new_version, | 540 new_version, |
536 existing_version.get(), | 541 existing_version.get(), |
537 install_temp_path); | 542 install_temp_path); |
538 } | 543 } |
539 | 544 |
540 return result; | 545 return result; |
541 } | 546 } |
542 | 547 |
543 } // namespace installer | 548 } // namespace installer |
OLD | NEW |