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

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

Issue 18732: Wire the eula and the dialog display code... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « chrome/installer/setup/eula/oem_en.html ('k') | chrome/installer/setup/setup.rc » ('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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 <string> 5 #include <string>
6 #include <windows.h> 6 #include <windows.h>
7 #include <msi.h> 7 #include <msi.h>
8 #include <shlobj.h> 8 #include <shlobj.h>
9 9
10 #include "base/at_exit.h" 10 #include "base/at_exit.h"
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/file_util.h" 13 #include "base/file_util.h"
14 #include "base/path_service.h" 14 #include "base/path_service.h"
15 #include "base/registry.h" 15 #include "base/registry.h"
16 #include "base/string_util.h" 16 #include "base/string_util.h"
17 #include "base/win_util.h" 17 #include "base/win_util.h"
18 #include "chrome/installer/setup/setup.h" 18 #include "chrome/installer/setup/setup.h"
19 #include "chrome/installer/setup/setup_constants.h" 19 #include "chrome/installer/setup/setup_constants.h"
20 #include "chrome/installer/setup/uninstall.h" 20 #include "chrome/installer/setup/uninstall.h"
21 #include "chrome/installer/util/browser_distribution.h" 21 #include "chrome/installer/util/browser_distribution.h"
22 #include "chrome/installer/util/delete_tree_work_item.h" 22 #include "chrome/installer/util/delete_tree_work_item.h"
23 #include "chrome/installer/util/helper.h" 23 #include "chrome/installer/util/helper.h"
24 #include "chrome/installer/util/html_dialog.h" 24 #include "chrome/installer/util/html_dialog.h"
25 #include "chrome/installer/util/install_util.h" 25 #include "chrome/installer/util/install_util.h"
26 #include "chrome/installer/util/l10n_string_util.h"
26 #include "chrome/installer/util/logging_installer.h" 27 #include "chrome/installer/util/logging_installer.h"
27 #include "chrome/installer/util/lzma_util.h" 28 #include "chrome/installer/util/lzma_util.h"
28 #include "chrome/installer/util/google_update_constants.h" 29 #include "chrome/installer/util/google_update_constants.h"
29 #include "chrome/installer/util/master_preferences.h" 30 #include "chrome/installer/util/master_preferences.h"
30 #include "chrome/installer/util/shell_util.h" 31 #include "chrome/installer/util/shell_util.h"
31 #include "chrome/installer/util/util_constants.h" 32 #include "chrome/installer/util/util_constants.h"
32 #include "chrome/installer/util/work_item.h" 33 #include "chrome/installer/util/work_item.h"
33 #include "third_party/bspatch/mbspatch.h" 34 #include "third_party/bspatch/mbspatch.h"
34 35
35 #include "installer_util_strings.h" 36 #include "installer_util_strings.h"
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 220
220 if (cmd_line.HasSwitch(installer_util::switches::kInstallerData)) { 221 if (cmd_line.HasSwitch(installer_util::switches::kInstallerData)) {
221 std::wstring prefs_path = cmd_line.GetSwitchValue( 222 std::wstring prefs_path = cmd_line.GetSwitchValue(
222 installer_util::switches::kInstallerData); 223 installer_util::switches::kInstallerData);
223 preferences = installer_util::ParseDistributionPreferences(prefs_path); 224 preferences = installer_util::ParseDistributionPreferences(prefs_path);
224 if ((preferences & installer_util::MASTER_PROFILE_NOT_FOUND) == 0) { 225 if ((preferences & installer_util::MASTER_PROFILE_NOT_FOUND) == 0) {
225 options |= installer_util::MASTER_PROFILE_PRESENT; 226 options |= installer_util::MASTER_PROFILE_PRESENT;
226 if ((preferences & installer_util::MASTER_PROFILE_ERROR) == 0) 227 if ((preferences & installer_util::MASTER_PROFILE_ERROR) == 0)
227 options |= installer_util::MASTER_PROFILE_VALID; 228 options |= installer_util::MASTER_PROFILE_VALID;
228 } 229 }
230 // While there is a --show-eula command line flag, we don't process
231 // it in this function because it requires special handling.
232 if (preferences & installer_util::MASTER_PROFILE_REQUIRE_EULA)
233 options |= installer_util::MASTER_PROFILE_REQUIRE_EULA;
huanr 2009/01/27 06:19:16 There are two sets of constants, MasterPrefResult
229 } 234 }
230 235
231 if (preferences & installer_util::MASTER_PROFILE_CREATE_ALL_SHORTCUTS || 236 if (preferences & installer_util::MASTER_PROFILE_CREATE_ALL_SHORTCUTS ||
232 cmd_line.HasSwitch(installer_util::switches::kCreateAllShortcuts)) 237 cmd_line.HasSwitch(installer_util::switches::kCreateAllShortcuts))
233 options |= installer_util::CREATE_ALL_SHORTCUTS; 238 options |= installer_util::CREATE_ALL_SHORTCUTS;
234 239
235 if (preferences & installer_util::MASTER_PROFILE_DO_NOT_LAUNCH_CHROME || 240 if (preferences & installer_util::MASTER_PROFILE_DO_NOT_LAUNCH_CHROME ||
236 cmd_line.HasSwitch(installer_util::switches::kDoNotLaunchChrome)) 241 cmd_line.HasSwitch(installer_util::switches::kDoNotLaunchChrome))
237 options |= installer_util::DO_NOT_LAUNCH_CHROME; 242 options |= installer_util::DO_NOT_LAUNCH_CHROME;
238 243
239 if (preferences & installer_util::MASTER_PROFILE_MAKE_CHROME_DEFAULT || 244 if (preferences & installer_util::MASTER_PROFILE_MAKE_CHROME_DEFAULT ||
240 cmd_line.HasSwitch(installer_util::switches::kMakeChromeDefault)) 245 cmd_line.HasSwitch(installer_util::switches::kMakeChromeDefault))
241 options |= installer_util::MAKE_CHROME_DEFAULT; 246 options |= installer_util::MAKE_CHROME_DEFAULT;
242 247
243 if (preferences & installer_util::MASTER_PROFILE_SYSTEM_LEVEL || 248 if (preferences & installer_util::MASTER_PROFILE_SYSTEM_LEVEL ||
244 cmd_line.HasSwitch(installer_util::switches::kSystemLevel)) 249 cmd_line.HasSwitch(installer_util::switches::kSystemLevel))
245 options |= installer_util::SYSTEM_LEVEL; 250 options |= installer_util::SYSTEM_LEVEL;
246 251
247 if (preferences & installer_util::MASTER_PROFILE_VERBOSE_LOGGING || 252 if (preferences & installer_util::MASTER_PROFILE_VERBOSE_LOGGING ||
248 cmd_line.HasSwitch(installer_util::switches::kVerboseLogging)) 253 cmd_line.HasSwitch(installer_util::switches::kVerboseLogging))
249 options |= installer_util::VERBOSE_LOGGING; 254 options |= installer_util::VERBOSE_LOGGING;
250 255
251 return options; 256 return options;
252 } 257 }
253 258
254 // Copy master preference file if provided to installer to the same path 259 // Copy master preference file if provided to installer to the same path
255 // of chrome.exe so Chrome first run can find it. 260 // of chrome.exe so Chrome first run can find it.
256 // This function will be called only when Chrome is launched the first time. 261 // This function will be called only when Chrome is launched the first time.
257 void CopyPreferenceFileForFirstRun(int options, const CommandLine& cmd_line) { 262 void CopyPreferenceFileForFirstRun(int options, const CommandLine& cmd_line) {
258 if (options & installer_util::MASTER_PROFILE_VALID) { 263 if (options & installer_util::MASTER_PROFILE_VALID) {
259 std::wstring prefs_source_path = cmd_line.GetSwitchValue( 264 std::wstring prefs_source_path = cmd_line.GetSwitchValue(
260 installer_util::switches::kInstallerData); 265 installer_util::switches::kInstallerData);
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 return installer_util::CHROME_NOT_INSTALLED; 437 return installer_util::CHROME_NOT_INSTALLED;
433 } 438 }
434 439
435 bool remove_all = !cmd_line.HasSwitch( 440 bool remove_all = !cmd_line.HasSwitch(
436 installer_util::switches::kDoNotRemoveSharedItems); 441 installer_util::switches::kDoNotRemoveSharedItems);
437 bool force = cmd_line.HasSwitch(installer_util::switches::kForceUninstall); 442 bool force = cmd_line.HasSwitch(installer_util::switches::kForceUninstall);
438 return installer_setup::UninstallChrome(cmd_line.program(), system_install, 443 return installer_setup::UninstallChrome(cmd_line.program(), system_install,
439 *version, remove_all, force); 444 *version, remove_all, force);
440 } 445 }
441 446
442 // This function is temporary and meant to live while we get our eula dialogs 447 bool ShowEULADialog() {
443 // looking sharp. If the cmd line has --eula-test=path then the eula dialog 448 LOG(INFO) << "About to show EULA";
444 // will be shown and no matter what the selection is the installer will exit. 449 std::wstring eula_path = installer_util::GetLocalizedEulaResource();
445 bool HandleEULADialog(const CommandLine& cmdline) { 450 if (eula_path.empty()) {
446 std:: wstring eula_path(cmdline.GetSwitchValue(L"eula-test")); 451 LOG(ERROR) << "No EULA path available";
447 if (eula_path.empty()) 452 return false;
448 return true; 453 }
449 installer::EulaHTMLDialog dlg(eula_path); 454 installer::EulaHTMLDialog dlg(eula_path);
450 dlg.ShowModal(); 455 if (!dlg.ShowModal()) {
451 return false; 456 LOG(ERROR) << "EULA rejected or EULA failure";
457 return false;
458 }
459 return true;
452 } 460 }
453 461
454 } // namespace 462 } // namespace
455 463
456 int WINAPI wWinMain(HINSTANCE instance, HINSTANCE prev_instance, 464 int WINAPI wWinMain(HINSTANCE instance, HINSTANCE prev_instance,
457 wchar_t* command_line, int show_command) { 465 wchar_t* command_line, int show_command) {
458 // The exit manager is in charge of calling the dtors of singletons. 466 // The exit manager is in charge of calling the dtors of singletons.
459 base::AtExitManager exit_manager; 467 base::AtExitManager exit_manager;
460 CommandLine::Init(0, NULL); 468 CommandLine::Init(0, NULL);
461 const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); 469 const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess();
462 installer::InitInstallerLogging(parsed_command_line); 470 installer::InitInstallerLogging(parsed_command_line);
463 int options = GetInstallOptions(parsed_command_line); 471 int options = GetInstallOptions(parsed_command_line);
464 if (options & installer_util::VERBOSE_LOGGING) 472 if (options & installer_util::VERBOSE_LOGGING)
465 logging::SetMinLogLevel(logging::LOG_INFO); 473 logging::SetMinLogLevel(logging::LOG_INFO);
466 474
467 bool system_install = (options & installer_util::SYSTEM_LEVEL) != 0; 475 bool system_install = (options & installer_util::SYSTEM_LEVEL) != 0;
468 LOG(INFO) << "system install is " << system_install; 476 LOG(INFO) << "system install is " << system_install;
469 477
470 if (!HandleEULADialog(parsed_command_line))
471 return 0;
472
473 // Check to make sure current system is WinXP or later. If not, log 478 // Check to make sure current system is WinXP or later. If not, log
474 // error message and get out. 479 // error message and get out.
475 if (!InstallUtil::IsOSSupported()) { 480 if (!InstallUtil::IsOSSupported()) {
476 LOG(ERROR) << "Chrome only supports Windows XP or later."; 481 LOG(ERROR) << "Chrome only supports Windows XP or later.";
477 InstallUtil::WriteInstallerResult(system_install, 482 InstallUtil::WriteInstallerResult(system_install,
478 installer_util::OS_NOT_SUPPORTED, 483 installer_util::OS_NOT_SUPPORTED,
479 IDS_INSTALL_OS_NOT_SUPPORTED_BASE, NULL); 484 IDS_INSTALL_OS_NOT_SUPPORTED_BASE, NULL);
480 return installer_util::OS_NOT_SUPPORTED; 485 return installer_util::OS_NOT_SUPPORTED;
481 } 486 }
482 487
483 // Initialize COM for use later. 488 // Initialize COM for use later.
484 if (CoInitializeEx(NULL, COINIT_APARTMENTTHREADED) != S_OK) { 489 if (CoInitializeEx(NULL, COINIT_APARTMENTTHREADED) != S_OK) {
485 LOG(ERROR) << "COM initialization failed."; 490 LOG(ERROR) << "COM initialization failed.";
486 InstallUtil::WriteInstallerResult(system_install, 491 InstallUtil::WriteInstallerResult(system_install,
487 installer_util::OS_ERROR, 492 installer_util::OS_ERROR,
488 IDS_INSTALL_OS_ERROR_BASE, NULL); 493 IDS_INSTALL_OS_ERROR_BASE, NULL);
489 return installer_util::OS_ERROR; 494 return installer_util::OS_ERROR;
490 } 495 }
491 496
497 // Check if we need to show the EULA. There are two cases:
498 // 1- If it is passed as a command line (--show-eula), then the dialog is
499 // shown and regardless of the outcome setup exits here.
500 // 2- If it is found in the installerdata file then the eula is shown
501 // and the installation proceeds if the user acepts.
502 if (parsed_command_line.HasSwitch(installer_util::switches::kShowEula)) {
503 return (ShowEULADialog() ?
504 installer_util::EULA_ACCEPTED : installer_util::EULA_REJECTED);
505 } else if (installer_util::MASTER_PROFILE_REQUIRE_EULA & options) {
huanr 2009/01/27 06:19:16 Same change here.
506 if (!ShowEULADialog())
507 return installer_util::EULA_REJECTED;
508 }
509
492 // If --register-chrome-browser option is specified, register all 510 // If --register-chrome-browser option is specified, register all
493 // Chrome protocol/file associations as well as register it as a valid 511 // Chrome protocol/file associations as well as register it as a valid
494 // browser for StarMenu->Internet shortcut. This option should only 512 // browser for StarMenu->Internet shortcut. This option should only
495 // be used when setup.exe is launched with admin rights. We do not 513 // be used when setup.exe is launched with admin rights. We do not
496 // make any user specific changes in this option. 514 // make any user specific changes in this option.
497 if (parsed_command_line.HasSwitch( 515 if (parsed_command_line.HasSwitch(
498 installer_util::switches::kRegisterChromeBrowser)) { 516 installer_util::switches::kRegisterChromeBrowser)) {
499 std::wstring chrome_exe(parsed_command_line.GetSwitchValue( 517 std::wstring chrome_exe(parsed_command_line.GetSwitchValue(
500 installer_util::switches::kRegisterChromeBrowser)); 518 installer_util::switches::kRegisterChromeBrowser));
501 return ShellUtil::AddChromeToSetAccessDefaults(chrome_exe, true); 519 return ShellUtil::AddChromeToSetAccessDefaults(chrome_exe, true);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 578
561 install_status = InstallChrome(parsed_command_line, 579 install_status = InstallChrome(parsed_command_line,
562 installed_version.get(), 580 installed_version.get(),
563 options); 581 options);
564 } 582 }
565 583
566 CoUninitialize(); 584 CoUninitialize();
567 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); 585 BrowserDistribution* dist = BrowserDistribution::GetDistribution();
568 return dist->GetInstallReturnCode(install_status); 586 return dist->GetInstallReturnCode(install_status);
569 } 587 }
OLDNEW
« no previous file with comments | « chrome/installer/setup/eula/oem_en.html ('k') | chrome/installer/setup/setup.rc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698