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

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

Issue 4342001: Refactoring the master_preferences functions.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « chrome/installer/setup/install.cc ('k') | chrome/installer/util/install_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <windows.h> 5 #include <windows.h>
6 #include <msi.h> 6 #include <msi.h>
7 #include <shellapi.h> 7 #include <shellapi.h>
8 #include <shlobj.h> 8 #include <shlobj.h>
9 9
10 #include <string> 10 #include <string>
(...skipping 20 matching lines...) Expand all
31 #include "chrome/installer/util/delete_tree_work_item.h" 31 #include "chrome/installer/util/delete_tree_work_item.h"
32 #include "chrome/installer/util/helper.h" 32 #include "chrome/installer/util/helper.h"
33 #include "chrome/installer/util/html_dialog.h" 33 #include "chrome/installer/util/html_dialog.h"
34 #include "chrome/installer/util/install_util.h" 34 #include "chrome/installer/util/install_util.h"
35 #include "chrome/installer/util/l10n_string_util.h" 35 #include "chrome/installer/util/l10n_string_util.h"
36 #include "chrome/installer/util/logging_installer.h" 36 #include "chrome/installer/util/logging_installer.h"
37 #include "chrome/installer/util/lzma_util.h" 37 #include "chrome/installer/util/lzma_util.h"
38 #include "chrome/installer/util/google_update_settings.h" 38 #include "chrome/installer/util/google_update_settings.h"
39 #include "chrome/installer/util/google_update_constants.h" 39 #include "chrome/installer/util/google_update_constants.h"
40 #include "chrome/installer/util/master_preferences.h" 40 #include "chrome/installer/util/master_preferences.h"
41 #include "chrome/installer/util/master_preferences_constants.h"
41 #include "chrome/installer/util/shell_util.h" 42 #include "chrome/installer/util/shell_util.h"
42 #include "chrome/installer/util/util_constants.h" 43 #include "chrome/installer/util/util_constants.h"
43 44
44 #include "installer_util_strings.h" 45 #include "installer_util_strings.h"
45 46
46 namespace { 47 namespace {
47 48
48 // This method unpacks and uncompresses the given archive file. For Chrome 49 // This method unpacks and uncompresses the given archive file. For Chrome
49 // install we are creating a uncompressed archive that contains all the files 50 // install we are creating a uncompressed archive that contains all the files
50 // needed for the installer. This uncompressed archive is later compressed. 51 // needed for the installer. This uncompressed archive is later compressed.
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 int str_id = IDS_INSTALL_DIR_IN_USE_BASE; 211 int str_id = IDS_INSTALL_DIR_IN_USE_BASE;
211 InstallUtil::WriteInstallerResult(system_install, status, str_id, NULL); 212 InstallUtil::WriteInstallerResult(system_install, status, str_id, NULL);
212 return false; 213 return false;
213 } 214 }
214 } 215 }
215 216
216 return true; 217 return true;
217 } 218 }
218 219
219 installer_util::InstallStatus InstallChrome(const CommandLine& cmd_line, 220 installer_util::InstallStatus InstallChrome(const CommandLine& cmd_line,
220 const installer::Version* installed_version, const DictionaryValue* prefs) { 221 const installer::Version* installed_version,
222 const installer_util::MasterPreferences& prefs) {
221 bool system_level = false; 223 bool system_level = false;
222 installer_util::GetDistroBooleanPreference(prefs, 224 prefs.GetBool(installer_util::master_preferences::kSystemLevel,
223 installer_util::master_preferences::kSystemLevel, &system_level); 225 &system_level);
224 installer_util::InstallStatus install_status = installer_util::UNKNOWN_STATUS; 226 installer_util::InstallStatus install_status = installer_util::UNKNOWN_STATUS;
225 if (!CheckPreInstallConditions(installed_version, 227 if (!CheckPreInstallConditions(installed_version,
226 system_level, install_status)) 228 system_level, install_status))
227 return install_status; 229 return install_status;
228 230
229 // For install the default location for chrome.packed.7z is in current 231 // For install the default location for chrome.packed.7z is in current
230 // folder, so get that value first. 232 // folder, so get that value first.
231 FilePath archive = 233 FilePath archive =
232 cmd_line.GetProgram().DirName().Append( 234 cmd_line.GetProgram().DirName().Append(
233 installer::kChromeCompressedArchive); 235 installer::kChromeCompressedArchive);
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 install_msg_base = IDS_INSTALL_OS_ERROR_BASE; 320 install_msg_base = IDS_INSTALL_OS_ERROR_BASE;
319 install_status = installer_util::OS_ERROR; 321 install_status = installer_util::OS_ERROR;
320 } else { 322 } else {
321 file_util::AppendToPath(&chrome_exe, installer_util::kChromeExe); 323 file_util::AppendToPath(&chrome_exe, installer_util::kChromeExe);
322 chrome_exe = L"\"" + chrome_exe + L"\""; 324 chrome_exe = L"\"" + chrome_exe + L"\"";
323 install_msg_base = 0; 325 install_msg_base = 0;
324 } 326 }
325 } 327 }
326 328
327 bool value = false; 329 bool value = false;
328 installer_util::GetDistroBooleanPreference(prefs, 330 prefs.GetBool(
329 installer_util::master_preferences::kDoNotRegisterForUpdateLaunch, 331 installer_util::master_preferences::kDoNotRegisterForUpdateLaunch,
330 &value); 332 &value);
331 bool write_chrome_launch_string = (!value) && 333 bool write_chrome_launch_string = (!value) &&
332 (install_status != installer_util::IN_USE_UPDATED); 334 (install_status != installer_util::IN_USE_UPDATED);
333 335
334 InstallUtil::WriteInstallerResult(system_level, install_status, 336 InstallUtil::WriteInstallerResult(system_level, install_status,
335 install_msg_base, write_chrome_launch_string ? &chrome_exe : NULL); 337 install_msg_base, write_chrome_launch_string ? &chrome_exe : NULL);
336 338
337 if (install_status == installer_util::FIRST_INSTALL_SUCCESS) { 339 if (install_status == installer_util::FIRST_INSTALL_SUCCESS) {
338 VLOG(1) << "First install successful."; 340 VLOG(1) << "First install successful.";
339 // We never want to launch Chrome in system level install mode. 341 // We never want to launch Chrome in system level install mode.
340 bool do_not_launch_chrome = false; 342 bool do_not_launch_chrome = false;
341 installer_util::GetDistroBooleanPreference(prefs, 343 prefs.GetBool(installer_util::master_preferences::kDoNotLaunchChrome,
342 installer_util::master_preferences::kDoNotLaunchChrome, 344 &do_not_launch_chrome);
343 &do_not_launch_chrome);
344 if (!system_level && !do_not_launch_chrome) 345 if (!system_level && !do_not_launch_chrome)
345 installer::LaunchChrome(system_level); 346 installer::LaunchChrome(system_level);
346 } else if ((install_status == installer_util::NEW_VERSION_UPDATED) || 347 } else if ((install_status == installer_util::NEW_VERSION_UPDATED) ||
347 (install_status == installer_util::IN_USE_UPDATED)) { 348 (install_status == installer_util::IN_USE_UPDATED)) {
348 installer_setup::RemoveLegacyRegistryKeys(); 349 installer_setup::RemoveLegacyRegistryKeys();
349 } 350 }
350 } 351 }
351 } 352 }
352 // There might be an experiment (for upgrade usually) that needs to happen. 353 // There might be an experiment (for upgrade usually) that needs to happen.
353 // An experiment's outcome can include chrome's uninstallation. If that is 354 // An experiment's outcome can include chrome's uninstallation. If that is
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 WideToASCII(installer_util::switches::kDoNotCreateShortcuts)); 625 WideToASCII(installer_util::switches::kDoNotCreateShortcuts));
625 mutable_command_line->AppendSwitch( 626 mutable_command_line->AppendSwitch(
626 WideToASCII(installer_util::switches::kDoNotLaunchChrome)); 627 WideToASCII(installer_util::switches::kDoNotLaunchChrome));
627 mutable_command_line->AppendSwitch( 628 mutable_command_line->AppendSwitch(
628 WideToASCII(installer_util::switches::kDoNotRegisterForUpdateLaunch)); 629 WideToASCII(installer_util::switches::kDoNotRegisterForUpdateLaunch));
629 } 630 }
630 631
631 const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); 632 const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess();
632 633
633 installer::InitInstallerLogging(parsed_command_line); 634 installer::InitInstallerLogging(parsed_command_line);
634 scoped_ptr<DictionaryValue> prefs(installer_util::GetInstallPreferences( 635 const installer_util::MasterPreferences& prefs =
635 parsed_command_line)); 636 InstallUtil::GetMasterPreferencesForCurrentProcess();
636 bool value = false; 637 bool value = false;
637 if (installer_util::GetDistroBooleanPreference(prefs.get(), 638 if (prefs.GetBool(installer_util::master_preferences::kVerboseLogging,
638 installer_util::master_preferences::kVerboseLogging, &value) && 639 &value) && value) {
639 value)
640 logging::SetMinLogLevel(logging::LOG_INFO); 640 logging::SetMinLogLevel(logging::LOG_INFO);
641 }
641 642
642 VLOG(1) << "Command Line: " << parsed_command_line.command_line_string(); 643 VLOG(1) << "Command Line: " << parsed_command_line.command_line_string();
643 644
644 bool system_install = false; 645 bool system_install = false;
645 installer_util::GetDistroBooleanPreference(prefs.get(), 646 prefs.GetBool(installer_util::master_preferences::kSystemLevel,
646 installer_util::master_preferences::kSystemLevel, &system_install); 647 &system_install);
647 VLOG(1) << "system install is " << system_install; 648 VLOG(1) << "system install is " << system_install;
648 649
649 // Check to make sure current system is WinXP or later. If not, log 650 // Check to make sure current system is WinXP or later. If not, log
650 // error message and get out. 651 // error message and get out.
651 if (!InstallUtil::IsOSSupported()) { 652 if (!InstallUtil::IsOSSupported()) {
652 LOG(ERROR) << "Chrome only supports Windows XP or later."; 653 LOG(ERROR) << "Chrome only supports Windows XP or later.";
653 InstallUtil::WriteInstallerResult(system_install, 654 InstallUtil::WriteInstallerResult(system_install,
654 installer_util::OS_NOT_SUPPORTED, 655 installer_util::OS_NOT_SUPPORTED,
655 IDS_INSTALL_OS_NOT_SUPPORTED_BASE, NULL); 656 IDS_INSTALL_OS_NOT_SUPPORTED_BASE, NULL);
656 return installer_util::OS_NOT_SUPPORTED; 657 return installer_util::OS_NOT_SUPPORTED;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 717
717 installer_util::InstallStatus install_status = installer_util::UNKNOWN_STATUS; 718 installer_util::InstallStatus install_status = installer_util::UNKNOWN_STATUS;
718 // If --uninstall option is given, uninstall chrome 719 // If --uninstall option is given, uninstall chrome
719 if (parsed_command_line.HasSwitch(installer_util::switches::kUninstall)) { 720 if (parsed_command_line.HasSwitch(installer_util::switches::kUninstall)) {
720 install_status = UninstallChrome(parsed_command_line, 721 install_status = UninstallChrome(parsed_command_line,
721 command_line, 722 command_line,
722 installed_version.get(), 723 installed_version.get(),
723 system_install); 724 system_install);
724 // If --uninstall option is not specified, we assume it is install case. 725 // If --uninstall option is not specified, we assume it is install case.
725 } else { 726 } else {
726 install_status = InstallChrome(parsed_command_line, 727 install_status = InstallChrome(parsed_command_line, installed_version.get(),
727 installed_version.get(), 728 prefs);
728 prefs.get());
729 } 729 }
730 730
731 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); 731 BrowserDistribution* dist = BrowserDistribution::GetDistribution();
732 732
733 if (InstallUtil::IsChromeFrameProcess() && 733 if (InstallUtil::IsChromeFrameProcess() &&
734 !parsed_command_line.HasSwitch( 734 !parsed_command_line.HasSwitch(
735 installer_util::switches::kForceUninstall)) { 735 installer_util::switches::kForceUninstall)) {
736 if (install_status == installer_util::UNINSTALL_REQUIRES_REBOOT) { 736 if (install_status == installer_util::UNINSTALL_REQUIRES_REBOOT) {
737 ShowRebootDialog(); 737 ShowRebootDialog();
738 } else if (parsed_command_line.HasSwitch( 738 } else if (parsed_command_line.HasSwitch(
(...skipping 14 matching lines...) Expand all
753 parsed_command_line.HasSwitch(installer_util::switches::kUninstall))) { 753 parsed_command_line.HasSwitch(installer_util::switches::kUninstall))) {
754 // Note that we allow the status installer_util::UNINSTALL_REQUIRES_REBOOT 754 // Note that we allow the status installer_util::UNINSTALL_REQUIRES_REBOOT
755 // to pass through, since this is only returned on uninstall which is never 755 // to pass through, since this is only returned on uninstall which is never
756 // invoked directly by Google Update. 756 // invoked directly by Google Update.
757 return_code = dist->GetInstallReturnCode(install_status); 757 return_code = dist->GetInstallReturnCode(install_status);
758 } 758 }
759 759
760 VLOG(1) << "Installation complete, returning: " << return_code; 760 VLOG(1) << "Installation complete, returning: " << return_code;
761 return return_code; 761 return return_code;
762 } 762 }
OLDNEW
« no previous file with comments | « chrome/installer/setup/install.cc ('k') | chrome/installer/util/install_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698