| 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 // See the corresponding header file for description of the functions in this | 5 // See the corresponding header file for description of the functions in this |
| 6 // file. | 6 // file. |
| 7 | 7 |
| 8 #include "chrome/installer/util/install_util.h" | 8 #include "chrome/installer/util/install_util.h" |
| 9 | 9 |
| 10 #include <shellapi.h> | 10 #include <shellapi.h> |
| 11 #include <shlobj.h> | 11 #include <shlobj.h> |
| 12 #include <shlwapi.h> | 12 #include <shlwapi.h> |
| 13 | 13 |
| 14 #include <algorithm> | 14 #include <algorithm> |
| 15 | 15 |
| 16 #include "base/command_line.h" | 16 #include "base/command_line.h" |
| 17 #include "base/file_util.h" | 17 #include "base/file_util.h" |
| 18 #include "base/logging.h" | 18 #include "base/logging.h" |
| 19 #include "base/memory/scoped_ptr.h" | 19 #include "base/memory/scoped_ptr.h" |
| 20 #include "base/path_service.h" | 20 #include "base/path_service.h" |
| 21 #include "base/process_util.h" | 21 #include "base/process_util.h" |
| 22 #include "base/string_util.h" | 22 #include "base/string_util.h" |
| 23 #include "base/sys_info.h" | 23 #include "base/sys_info.h" |
| 24 #include "base/values.h" | 24 #include "base/values.h" |
| 25 #include "base/version.h" | 25 #include "base/version.h" |
| 26 #include "base/win/metro.h" |
| 26 #include "base/win/registry.h" | 27 #include "base/win/registry.h" |
| 27 #include "base/win/windows_version.h" | 28 #include "base/win/windows_version.h" |
| 28 #include "chrome/installer/util/browser_distribution.h" | 29 #include "chrome/installer/util/browser_distribution.h" |
| 29 #include "chrome/installer/util/google_update_constants.h" | 30 #include "chrome/installer/util/google_update_constants.h" |
| 30 #include "chrome/installer/util/helper.h" | 31 #include "chrome/installer/util/helper.h" |
| 31 #include "chrome/installer/util/installation_state.h" | 32 #include "chrome/installer/util/installation_state.h" |
| 32 #include "chrome/installer/util/l10n_string_util.h" | 33 #include "chrome/installer/util/l10n_string_util.h" |
| 33 #include "chrome/installer/util/util_constants.h" | 34 #include "chrome/installer/util/util_constants.h" |
| 34 #include "chrome/installer/util/work_item_list.h" | 35 #include "chrome/installer/util/work_item_list.h" |
| 35 | 36 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 } | 120 } |
| 120 | 121 |
| 121 } // namespace | 122 } // namespace |
| 122 | 123 |
| 123 string16 InstallUtil::GetActiveSetupPath(BrowserDistribution* dist) { | 124 string16 InstallUtil::GetActiveSetupPath(BrowserDistribution* dist) { |
| 124 static const wchar_t kInstalledComponentsPath[] = | 125 static const wchar_t kInstalledComponentsPath[] = |
| 125 L"Software\\Microsoft\\Active Setup\\Installed Components\\"; | 126 L"Software\\Microsoft\\Active Setup\\Installed Components\\"; |
| 126 return kInstalledComponentsPath + dist->GetAppGuid(); | 127 return kInstalledComponentsPath + dist->GetAppGuid(); |
| 127 } | 128 } |
| 128 | 129 |
| 129 void InstallUtil::TriggerActiveSetupCommandIfNeeded() { | 130 void InstallUtil::TriggerActiveSetupCommand() { |
| 130 FilePath chrome_exe; | |
| 131 if (!PathService::Get(base::FILE_EXE, &chrome_exe)) { | |
| 132 NOTREACHED(); | |
| 133 } else if (InstallUtil::IsPerUserInstall(chrome_exe.value().c_str())) { | |
| 134 return; | |
| 135 } | |
| 136 | |
| 137 string16 active_setup_reg( | 131 string16 active_setup_reg( |
| 138 GetActiveSetupPath(BrowserDistribution::GetDistribution())); | 132 GetActiveSetupPath(BrowserDistribution::GetDistribution())); |
| 139 base::win::RegKey active_setup_key( | 133 base::win::RegKey active_setup_key( |
| 140 HKEY_LOCAL_MACHINE, active_setup_reg.c_str(), KEY_QUERY_VALUE); | 134 HKEY_LOCAL_MACHINE, active_setup_reg.c_str(), KEY_QUERY_VALUE); |
| 141 string16 cmd_str; | 135 string16 cmd_str; |
| 142 LONG read_status = active_setup_key.ReadValue(L"StubPath", &cmd_str); | 136 LONG read_status = active_setup_key.ReadValue(L"StubPath", &cmd_str); |
| 143 if (read_status != ERROR_SUCCESS) { | 137 if (read_status != ERROR_SUCCESS) { |
| 144 LOG(ERROR) << active_setup_reg << ", " << read_status; | 138 LOG(ERROR) << active_setup_reg << ", " << read_status; |
| 145 // This should never fail if Chrome is registered at system-level, but if it | 139 // This should never fail if Chrome is registered at system-level, but if it |
| 146 // does there is not much else to be done. | 140 // does there is not much else to be done. |
| 147 return; | 141 return; |
| 148 } | 142 } |
| 149 | 143 |
| 150 CommandLine cmd(CommandLine::FromString(cmd_str)); | 144 CommandLine cmd(CommandLine::FromString(cmd_str)); |
| 151 // Force creation of shortcuts as the First Run beacon might land between now | 145 // Force creation of shortcuts as the First Run beacon might land between now |
| 152 // and the time setup.exe checks for it. | 146 // and the time setup.exe checks for it. |
| 153 cmd.AppendSwitch(installer::switches::kForceConfigureUserSettings); | 147 cmd.AppendSwitch(installer::switches::kForceConfigureUserSettings); |
| 154 | 148 |
| 155 base::LaunchOptions default_options; | 149 base::LaunchOptions launch_options; |
| 156 if (!base::LaunchProcess(cmd.GetCommandLineString(), default_options, NULL)) | 150 if (base::win::IsMetroProcess()) |
| 151 launch_options.force_breakaway_from_job_ = true; |
| 152 if (!base::LaunchProcess(cmd.GetCommandLineString(), launch_options, NULL)) |
| 157 PLOG(ERROR) << cmd.GetCommandLineString(); | 153 PLOG(ERROR) << cmd.GetCommandLineString(); |
| 158 } | 154 } |
| 159 | 155 |
| 160 bool InstallUtil::ExecuteExeAsAdmin(const CommandLine& cmd, DWORD* exit_code) { | 156 bool InstallUtil::ExecuteExeAsAdmin(const CommandLine& cmd, DWORD* exit_code) { |
| 161 FilePath::StringType program(cmd.GetProgram().value()); | 157 FilePath::StringType program(cmd.GetProgram().value()); |
| 162 DCHECK(!program.empty()); | 158 DCHECK(!program.empty()); |
| 163 DCHECK_NE(program[0], L'\"'); | 159 DCHECK_NE(program[0], L'\"'); |
| 164 | 160 |
| 165 CommandLine::StringType params(cmd.GetCommandLineString()); | 161 CommandLine::StringType params(cmd.GetCommandLineString()); |
| 166 if (params[0] == '"') { | 162 if (params[0] == '"') { |
| (...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 585 // Open the program and see if it references the expected file. | 581 // Open the program and see if it references the expected file. |
| 586 base::win::ScopedHandle handle; | 582 base::win::ScopedHandle handle; |
| 587 BY_HANDLE_FILE_INFORMATION info = {}; | 583 BY_HANDLE_FILE_INFORMATION info = {}; |
| 588 | 584 |
| 589 return (OpenForInfo(program, &handle) && | 585 return (OpenForInfo(program, &handle) && |
| 590 GetInfo(handle, &info) && | 586 GetInfo(handle, &info) && |
| 591 info.dwVolumeSerialNumber == file_info_.dwVolumeSerialNumber && | 587 info.dwVolumeSerialNumber == file_info_.dwVolumeSerialNumber && |
| 592 info.nFileIndexHigh == file_info_.nFileIndexHigh && | 588 info.nFileIndexHigh == file_info_.nFileIndexHigh && |
| 593 info.nFileIndexLow == file_info_.nFileIndexLow); | 589 info.nFileIndexLow == file_info_.nFileIndexLow); |
| 594 } | 590 } |
| OLD | NEW |