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

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: Dear Greg 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
« no previous file with comments | « chrome/common/chrome_result_codes.h ('k') | chrome/installer/util/google_update_settings.cc » ('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) 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"
28 #include "chrome/common/chrome_switches.h" 29 #include "chrome/common/chrome_switches.h"
29 #include "chrome/installer/setup/chrome_frame_quick_enable.h" 30 #include "chrome/installer/setup/chrome_frame_quick_enable.h"
30 #include "chrome/installer/setup/chrome_frame_ready_mode.h" 31 #include "chrome/installer/setup/chrome_frame_ready_mode.h"
31 #include "chrome/installer/setup/install.h" 32 #include "chrome/installer/setup/install.h"
32 #include "chrome/installer/setup/install_worker.h" 33 #include "chrome/installer/setup/install_worker.h"
33 #include "chrome/installer/setup/setup_constants.h" 34 #include "chrome/installer/setup/setup_constants.h"
(...skipping 990 matching lines...) Expand 10 before | Expand all | Expand 10 after
1024 return installer::EULA_REJECTED; 1025 return installer::EULA_REJECTED;
1025 } 1026 }
1026 if (installer::EulaHTMLDialog::ACCEPTED_OPT_IN == outcome) { 1027 if (installer::EulaHTMLDialog::ACCEPTED_OPT_IN == outcome) {
1027 VLOG(1) << "EULA accepted (opt-in)"; 1028 VLOG(1) << "EULA accepted (opt-in)";
1028 return installer::EULA_ACCEPTED_OPT_IN; 1029 return installer::EULA_ACCEPTED_OPT_IN;
1029 } 1030 }
1030 VLOG(1) << "EULA accepted (no opt-in)"; 1031 VLOG(1) << "EULA accepted (no opt-in)";
1031 return installer::EULA_ACCEPTED; 1032 return installer::EULA_ACCEPTED;
1032 } 1033 }
1033 1034
1035 // Populates |path| with the path to |file| in the sentinel directory. This is
1036 // the application directory for user-level installs, and the default user data
1037 // dir for system-level installs. Returns false on error.
1038 bool GetSentinelFilePath(const char* file,
1039 BrowserDistribution* dist,
1040 FilePath* path) {
1041 FilePath exe_path;
1042 if (!PathService::Get(base::DIR_EXE, &exe_path))
1043 return false;
1044
1045 if (InstallUtil::IsPerUserInstall(exe_path.value().c_str())) {
1046 *path = exe_path;
1047 } else {
1048 std::vector<FilePath> user_data_dir_paths;
1049 installer::GetChromeUserDataPaths(dist, &user_data_dir_paths);
1050
1051 if (!user_data_dir_paths.empty())
1052 *path = user_data_dir_paths[0];
1053 else
1054 return false;
1055 }
1056
1057 *path = path->AppendASCII(file);
1058 return true;
1059 }
1060
1061 // Creates the sentinel indicating that the EULA was required and has been
1062 // accepted.
1063 bool CreateEULASentinel(BrowserDistribution* dist) {
1064 FilePath eula_sentinel;
1065 if (!GetSentinelFilePath(installer::kEULASentinelFile, dist, &eula_sentinel))
1066 return false;
1067 return file_util::WriteFile(eula_sentinel, "", 0) != -1;
1068 }
1069
1070 void ActivateMetroChrome() {
1071 // Check to see if we're per-user or not. Need to do this since we may
1072 // not have been invoked with --system-level even for a machine install.
1073 wchar_t exe_path[MAX_PATH * 2] = {};
1074 GetModuleFileName(NULL, exe_path, arraysize(exe_path));
1075 bool is_per_user_install = InstallUtil::IsPerUserInstall(exe_path);
1076
1077 string16 app_model_id =
1078 ShellUtil::GetBrowserModelId(BrowserDistribution::GetDistribution(),
1079 is_per_user_install);
1080
1081 base::win::ScopedComPtr<IApplicationActivationManager> activator;
1082 HRESULT hr = activator.CreateInstance(CLSID_ApplicationActivationManager);
1083 if (SUCCEEDED(hr)) {
1084 DWORD pid = 0;
1085 hr = activator->ActivateApplication(
1086 app_model_id.c_str(), L"open", AO_NONE, &pid);
1087 }
1088
1089 LOG_IF(ERROR, FAILED(hr)) << "Tried and failed to launch Metro Chrome. "
1090 << "hr=" << hr;
grt (UTC plus 2) 2012/09/21 01:35:42 nit: << std::hex << hr so that the log message is
robertshield 2012/09/21 13:12:59 Done.
1091 }
1092
1034 // This method processes any command line options that make setup.exe do 1093 // This method processes any command line options that make setup.exe do
1035 // various tasks other than installation (renaming chrome.exe, showing eula 1094 // various tasks other than installation (renaming chrome.exe, showing eula
1036 // among others). This function returns true if any such command line option 1095 // 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). 1096 // has been found and processed (so setup.exe should exit at that point).
1038 bool HandleNonInstallCmdLineOptions(const InstallationState& original_state, 1097 bool HandleNonInstallCmdLineOptions(const InstallationState& original_state,
1039 const CommandLine& cmd_line, 1098 const CommandLine& cmd_line,
1040 InstallerState* installer_state, 1099 InstallerState* installer_state,
1041 int* exit_code) { 1100 int* exit_code) {
1042 bool handled = true; 1101 bool handled = true;
1043 // TODO(tommi): Split these checks up into functions and use a data driven 1102 // 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); 1142 status, IDS_SETUP_PATCH_FAILED_BASE, NULL);
1084 } 1143 }
1085 // We will be exiting normally, so clear the stage indicator. 1144 // We will be exiting normally, so clear the stage indicator.
1086 installer_state->UpdateStage(installer::NO_STAGE); 1145 installer_state->UpdateStage(installer::NO_STAGE);
1087 } else if (cmd_line.HasSwitch(installer::switches::kShowEula)) { 1146 } 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 1147 // 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. 1148 // then the dialog is shown and regardless of the outcome setup exits here.
1090 string16 inner_frame = 1149 string16 inner_frame =
1091 cmd_line.GetSwitchValueNative(installer::switches::kShowEula); 1150 cmd_line.GetSwitchValueNative(installer::switches::kShowEula);
1092 *exit_code = ShowEULADialog(inner_frame); 1151 *exit_code = ShowEULADialog(inner_frame);
1152
1093 if (installer::EULA_REJECTED != *exit_code) { 1153 if (installer::EULA_REJECTED != *exit_code) {
1094 GoogleUpdateSettings::SetEULAConsent( 1154 if (GoogleUpdateSettings::SetEULAConsent(
1095 original_state, BrowserDistribution::GetDistribution(), true); 1155 original_state, BrowserDistribution::GetDistribution(), true)) {
1156 CreateEULASentinel(BrowserDistribution::GetDistribution());
1157 }
1158 // For a metro-originated launch, we now need to launch back into metro.
1159 if (cmd_line.HasSwitch(installer::switches::kShowEulaForMetro))
1160 ActivateMetroChrome();
1096 } 1161 }
1097 } else if (cmd_line.HasSwitch( 1162 } else if (cmd_line.HasSwitch(
1098 installer::switches::kConfigureUserSettings)) { 1163 installer::switches::kConfigureUserSettings)) {
1099 DCHECK(installer_state->system_install()); 1164 DCHECK(installer_state->system_install());
1100 const Product* chrome_install = 1165 const Product* chrome_install =
1101 installer_state->FindProduct(BrowserDistribution::CHROME_BROWSER); 1166 installer_state->FindProduct(BrowserDistribution::CHROME_BROWSER);
1102 DCHECK(chrome_install); 1167 DCHECK(chrome_install);
1103 // TODO(gab): Implement the new shortcut functionality here. 1168 // TODO(gab): Implement the new shortcut functionality here.
1104 LOG(ERROR) << "--configure-user-settings is not implemented."; 1169 LOG(ERROR) << "--configure-user-settings is not implemented.";
1105 } else if (cmd_line.HasSwitch( 1170 } 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)) 1584 if (!(installer_state.is_msi() && is_uninstall))
1520 // Note that we allow the status installer::UNINSTALL_REQUIRES_REBOOT 1585 // Note that we allow the status installer::UNINSTALL_REQUIRES_REBOOT
1521 // to pass through, since this is only returned on uninstall which is 1586 // to pass through, since this is only returned on uninstall which is
1522 // never invoked directly by Google Update. 1587 // never invoked directly by Google Update.
1523 return_code = InstallUtil::GetInstallReturnCode(install_status); 1588 return_code = InstallUtil::GetInstallReturnCode(install_status);
1524 1589
1525 VLOG(1) << "Installation complete, returning: " << return_code; 1590 VLOG(1) << "Installation complete, returning: " << return_code;
1526 1591
1527 return return_code; 1592 return return_code;
1528 } 1593 }
OLDNEW
« no previous file with comments | « chrome/common/chrome_result_codes.h ('k') | chrome/installer/util/google_update_settings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698