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

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

Issue 10837222: Enable EULA dialog to be shown from metro Chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Bit o' spit n' polish. Created 8 years, 3 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
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 <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 "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/file_version_info.h" 14 #include "base/file_version_info.h"
15 #include "base/path_service.h" 15 #include "base/path_service.h"
16 #include "base/process_util.h" 16 #include "base/process_util.h"
17 #include "base/scoped_temp_dir.h" 17 #include "base/scoped_temp_dir.h"
18 #include "base/string16.h" 18 #include "base/string16.h"
19 #include "base/string_number_conversions.h" 19 #include "base/string_number_conversions.h"
20 #include "base/string_util.h" 20 #include "base/string_util.h"
21 #include "base/utf_string_conversions.h" 21 #include "base/utf_string_conversions.h"
22 #include "base/values.h" 22 #include "base/values.h"
23 #include "base/win/registry.h" 23 #include "base/win/registry.h"
24 #include "base/win/scoped_comptr.h"
24 #include "base/win/scoped_handle.h" 25 #include "base/win/scoped_handle.h"
25 #include "base/win/win_util.h" 26 #include "base/win/win_util.h"
26 #include "base/win/windows_version.h" 27 #include "base/win/windows_version.h"
27 #include "breakpad/src/client/windows/handler/exception_handler.h" 28 #include "breakpad/src/client/windows/handler/exception_handler.h"
29 #include "chrome/common/chrome_paths.h"
grt (UTC plus 2) 2012/09/20 15:58:31 why?
robertshield 2012/09/21 01:24:43 Done.
28 #include "chrome/common/chrome_switches.h" 30 #include "chrome/common/chrome_switches.h"
29 #include "chrome/installer/setup/chrome_frame_quick_enable.h" 31 #include "chrome/installer/setup/chrome_frame_quick_enable.h"
30 #include "chrome/installer/setup/chrome_frame_ready_mode.h" 32 #include "chrome/installer/setup/chrome_frame_ready_mode.h"
31 #include "chrome/installer/setup/install.h" 33 #include "chrome/installer/setup/install.h"
32 #include "chrome/installer/setup/install_worker.h" 34 #include "chrome/installer/setup/install_worker.h"
33 #include "chrome/installer/setup/setup_constants.h" 35 #include "chrome/installer/setup/setup_constants.h"
34 #include "chrome/installer/setup/setup_util.h" 36 #include "chrome/installer/setup/setup_util.h"
35 #include "chrome/installer/setup/uninstall.h" 37 #include "chrome/installer/setup/uninstall.h"
36 #include "chrome/installer/util/browser_distribution.h" 38 #include "chrome/installer/util/browser_distribution.h"
37 #include "chrome/installer/util/channel_info.h" 39 #include "chrome/installer/util/channel_info.h"
(...skipping 986 matching lines...) Expand 10 before | Expand all | Expand 10 after
1024 return installer::EULA_REJECTED; 1026 return installer::EULA_REJECTED;
1025 } 1027 }
1026 if (installer::EulaHTMLDialog::ACCEPTED_OPT_IN == outcome) { 1028 if (installer::EulaHTMLDialog::ACCEPTED_OPT_IN == outcome) {
1027 VLOG(1) << "EULA accepted (opt-in)"; 1029 VLOG(1) << "EULA accepted (opt-in)";
1028 return installer::EULA_ACCEPTED_OPT_IN; 1030 return installer::EULA_ACCEPTED_OPT_IN;
1029 } 1031 }
1030 VLOG(1) << "EULA accepted (no opt-in)"; 1032 VLOG(1) << "EULA accepted (no opt-in)";
1031 return installer::EULA_ACCEPTED; 1033 return installer::EULA_ACCEPTED;
1032 } 1034 }
1033 1035
1036 // Populates |path| with the path to |file| in the sentinel directory. This is
1037 // the application directory for user-level installs, and the default user data
1038 // dir for system-level installs. Returns false on error.
1039 bool GetSentinelFilePath(const char* file,
grt (UTC plus 2) 2012/09/20 15:58:31 please move this into installer_util so that it ca
robertshield 2012/09/21 01:24:43 The reason I didn't is that the implementations ar
grt (UTC plus 2) 2012/09/21 01:35:41 Ah, I see. Sigh. I guess this is okay, although
1040 BrowserDistribution* dist,
1041 FilePath* path) {
1042 FilePath exe_path;
1043 if (!PathService::Get(base::DIR_EXE, &exe_path))
1044 return false;
1045
1046 if (InstallUtil::IsPerUserInstall(exe_path.value().c_str())) {
1047 *path = exe_path;
1048 } else {
1049 std::vector<FilePath> user_data_dir_paths;
1050 installer::GetChromeUserDataPaths(dist, &user_data_dir_paths);
1051
1052 if (!user_data_dir_paths.empty())
1053 *path = user_data_dir_paths[0];
1054 else
1055 return false;
1056 }
1057
1058 *path = path->AppendASCII(file);
1059 return true;
1060 }
1061
1062 // Creates the sentinel indicating that the EULA was required and has been
1063 // accepted.
1064 bool CreateEULASentinel(BrowserDistribution* dist) {
1065 FilePath eula_sentinel;
1066 if (!GetSentinelFilePath(installer::kEULASentinelFile, dist, &eula_sentinel))
1067 return false;
1068 return file_util::WriteFile(eula_sentinel, "", 0) != -1;
1069 }
1070
1071 void ActivateMetroChrome() {
1072 // Check to see if we're per-user or not. Need to do this since we may
1073 // not have been invoked with --system-level even for a machine install.
1074 wchar_t exe_path[MAX_PATH * 2] = {0};
grt (UTC plus 2) 2012/09/20 15:58:31 nit: {0} -> {}
robertshield 2012/09/21 01:24:43 Done.
1075 GetModuleFileName(NULL, exe_path, arraysize(exe_path));
1076 bool is_per_user_install = InstallUtil::IsPerUserInstall(exe_path);
1077
1078 string16 app_model_id =
1079 ShellUtil::GetBrowserModelId(BrowserDistribution::GetDistribution(),
1080 is_per_user_install);
1081
1082 base::win::ScopedComPtr<IApplicationActivationManager> activator;
1083 HRESULT hr = activator.CreateInstance(CLSID_ApplicationActivationManager);
1084 if (SUCCEEDED(hr)) {
1085 DWORD pid = 0;
1086 hr = activator->ActivateApplication(
1087 app_model_id.c_str(), L"", AO_NONE, &pid);
grt (UTC plus 2) 2012/09/20 15:58:31 note that the version of this in process_singleton
robertshield 2012/09/21 01:24:43 Done.
1088 }
1089
1090 if (FAILED(hr)) {
1091 VLOG(1) << "Tried and failed to launch Metro Chrome.";
grt (UTC plus 2) 2012/09/20 15:58:31 replace 1090 - 1092 with: LOG_IF(ERROR, FAILED(hr)
robertshield 2012/09/21 01:24:43 Done.
1092 }
1093 }
1094
1034 // This method processes any command line options that make setup.exe do 1095 // This method processes any command line options that make setup.exe do
1035 // various tasks other than installation (renaming chrome.exe, showing eula 1096 // various tasks other than installation (renaming chrome.exe, showing eula
1036 // among others). This function returns true if any such command line option 1097 // among others). This function returns true if any such command line option
1037 // has been found and processed (so setup.exe should exit at that point). 1098 // has been found and processed (so setup.exe should exit at that point).
1038 bool HandleNonInstallCmdLineOptions(const InstallationState& original_state, 1099 bool HandleNonInstallCmdLineOptions(const InstallationState& original_state,
1039 const CommandLine& cmd_line, 1100 const CommandLine& cmd_line,
1040 InstallerState* installer_state, 1101 InstallerState* installer_state,
1041 int* exit_code) { 1102 int* exit_code) {
1042 bool handled = true; 1103 bool handled = true;
1043 // TODO(tommi): Split these checks up into functions and use a data driven 1104 // TODO(tommi): Split these checks up into functions and use a data driven
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1083 status, IDS_SETUP_PATCH_FAILED_BASE, NULL); 1144 status, IDS_SETUP_PATCH_FAILED_BASE, NULL);
1084 } 1145 }
1085 // We will be exiting normally, so clear the stage indicator. 1146 // We will be exiting normally, so clear the stage indicator.
1086 installer_state->UpdateStage(installer::NO_STAGE); 1147 installer_state->UpdateStage(installer::NO_STAGE);
1087 } else if (cmd_line.HasSwitch(installer::switches::kShowEula)) { 1148 } else if (cmd_line.HasSwitch(installer::switches::kShowEula)) {
1088 // Check if we need to show the EULA. If it is passed as a command line 1149 // Check if we need to show the EULA. If it is passed as a command line
1089 // then the dialog is shown and regardless of the outcome setup exits here. 1150 // then the dialog is shown and regardless of the outcome setup exits here.
1090 string16 inner_frame = 1151 string16 inner_frame =
1091 cmd_line.GetSwitchValueNative(installer::switches::kShowEula); 1152 cmd_line.GetSwitchValueNative(installer::switches::kShowEula);
1092 *exit_code = ShowEULADialog(inner_frame); 1153 *exit_code = ShowEULADialog(inner_frame);
1154
1093 if (installer::EULA_REJECTED != *exit_code) { 1155 if (installer::EULA_REJECTED != *exit_code) {
grt (UTC plus 2) 2012/09/20 15:58:31 the user is left on the desktop upon rejection? d
robertshield 2012/09/21 01:24:43 Hrm.. good question, I don't know. They were not n
grt (UTC plus 2) 2012/09/21 01:35:41 da
1094 GoogleUpdateSettings::SetEULAConsent( 1156 if (GoogleUpdateSettings::SetEULAConsent(
1095 original_state, BrowserDistribution::GetDistribution(), true); 1157 original_state, BrowserDistribution::GetDistribution(), true)) {
1158 CreateEULASentinel(BrowserDistribution::GetDistribution());
1159 }
1160 // For a metro-originated launch, we now need to launch back into metro.
1161 if (cmd_line.HasSwitch(installer::switches::kShowEulaForMetro)) {
grt (UTC plus 2) 2012/09/20 15:58:31 nit: no braces
robertshield 2012/09/21 01:24:43 Done.
1162 ActivateMetroChrome();
1163 }
1096 } 1164 }
1097 } else if (cmd_line.HasSwitch( 1165 } else if (cmd_line.HasSwitch(
1098 installer::switches::kConfigureUserSettings)) { 1166 installer::switches::kConfigureUserSettings)) {
1099 DCHECK(installer_state->system_install()); 1167 DCHECK(installer_state->system_install());
1100 const Product* chrome_install = 1168 const Product* chrome_install =
1101 installer_state->FindProduct(BrowserDistribution::CHROME_BROWSER); 1169 installer_state->FindProduct(BrowserDistribution::CHROME_BROWSER);
1102 DCHECK(chrome_install); 1170 DCHECK(chrome_install);
1103 // TODO(gab): Implement the new shortcut functionality here. 1171 // TODO(gab): Implement the new shortcut functionality here.
1104 LOG(ERROR) << "--configure-user-settings is not implemented."; 1172 LOG(ERROR) << "--configure-user-settings is not implemented.";
1105 } else if (cmd_line.HasSwitch( 1173 } else if (cmd_line.HasSwitch(
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
1519 if (!(installer_state.is_msi() && is_uninstall)) 1587 if (!(installer_state.is_msi() && is_uninstall))
1520 // Note that we allow the status installer::UNINSTALL_REQUIRES_REBOOT 1588 // Note that we allow the status installer::UNINSTALL_REQUIRES_REBOOT
1521 // to pass through, since this is only returned on uninstall which is 1589 // to pass through, since this is only returned on uninstall which is
1522 // never invoked directly by Google Update. 1590 // never invoked directly by Google Update.
1523 return_code = InstallUtil::GetInstallReturnCode(install_status); 1591 return_code = InstallUtil::GetInstallReturnCode(install_status);
1524 1592
1525 VLOG(1) << "Installation complete, returning: " << return_code; 1593 VLOG(1) << "Installation complete, returning: " << return_code;
1526 1594
1527 return return_code; 1595 return return_code;
1528 } 1596 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698