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

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

Issue 79060: In system level install case go back to copying files instead of moving them. (Closed)
Patch Set: Created 11 years, 8 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
« no previous file with comments | « no previous file | no next file » | 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 <time.h> 5 #include <time.h>
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/registry.h" 8 #include "base/registry.h"
9 #include "base/scoped_ptr.h" 9 #include "base/scoped_ptr.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 L"InstallDate", 91 L"InstallDate",
92 buffer, false); 92 buffer, false);
93 } 93 }
94 } 94 }
95 95
96 void AddInstallerCopyTasks(const std::wstring& exe_path, 96 void AddInstallerCopyTasks(const std::wstring& exe_path,
97 const std::wstring& archive_path, 97 const std::wstring& archive_path,
98 const std::wstring& temp_path, 98 const std::wstring& temp_path,
99 const std::wstring& install_path, 99 const std::wstring& install_path,
100 const std::wstring& new_version, 100 const std::wstring& new_version,
101 WorkItemList* install_list) { 101 WorkItemList* install_list,
102 bool system_level) {
102 std::wstring installer_dir(installer::GetInstallerPathUnderChrome( 103 std::wstring installer_dir(installer::GetInstallerPathUnderChrome(
103 install_path, new_version)); 104 install_path, new_version));
104 install_list->AddCreateDirWorkItem(installer_dir); 105 install_list->AddCreateDirWorkItem(installer_dir);
105 106
106 std::wstring exe_dst(installer_dir); 107 std::wstring exe_dst(installer_dir);
107 std::wstring archive_dst(installer_dir); 108 std::wstring archive_dst(installer_dir);
108 file_util::AppendToPath(&exe_dst, 109 file_util::AppendToPath(&exe_dst,
109 file_util::GetFilenameFromPath(exe_path)); 110 file_util::GetFilenameFromPath(exe_path));
110 file_util::AppendToPath(&archive_dst, 111 file_util::AppendToPath(&archive_dst,
111 file_util::GetFilenameFromPath(archive_path)); 112 file_util::GetFilenameFromPath(archive_path));
112 113
113 install_list->AddCopyTreeWorkItem(exe_path, exe_dst, temp_path, 114 install_list->AddCopyTreeWorkItem(exe_path, exe_dst, temp_path,
114 WorkItem::ALWAYS); 115 WorkItem::ALWAYS);
115 install_list->AddMoveTreeWorkItem(archive_path, archive_dst, temp_path); 116 if (system_level) {
117 install_list->AddCopyTreeWorkItem(archive_path, archive_dst, temp_path,
118 WorkItem::ALWAYS);
119 } else {
120 install_list->AddMoveTreeWorkItem(archive_path, archive_dst, temp_path);
121 }
116 } 122 }
117 123
118 // This method tells if we are running on 64 bit platform so that we can copy 124 // This method tells if we are running on 64 bit platform so that we can copy
119 // one extra exe. If the API call to determine 64 bit fails, we play it safe 125 // one extra exe. If the API call to determine 64 bit fails, we play it safe
120 // and return true anyway so that the executable can be copied. 126 // and return true anyway so that the executable can be copied.
121 bool Is64bit() { 127 bool Is64bit() {
122 typedef BOOL (WINAPI *WOW_FUNC)(HANDLE, PBOOL); 128 typedef BOOL (WINAPI *WOW_FUNC)(HANDLE, PBOOL);
123 BOOL is64 = FALSE; 129 BOOL is64 = FALSE;
124 130
125 HANDLE handle = GetCurrentProcess(); 131 HANDLE handle = GetCurrentProcess();
(...skipping 17 matching lines...) Expand all
143 const HKEY reg_root, 149 const HKEY reg_root,
144 const Version& new_version) { 150 const Version& new_version) {
145 if (reg_root != HKEY_LOCAL_MACHINE && reg_root != HKEY_CURRENT_USER) 151 if (reg_root != HKEY_LOCAL_MACHINE && reg_root != HKEY_CURRENT_USER)
146 return false; 152 return false;
147 153
148 scoped_ptr<WorkItemList> install_list(WorkItem::CreateWorkItemList()); 154 scoped_ptr<WorkItemList> install_list(WorkItem::CreateWorkItemList());
149 // A temp directory that work items need and the actual install directory. 155 // A temp directory that work items need and the actual install directory.
150 install_list->AddCreateDirWorkItem(temp_dir); 156 install_list->AddCreateDirWorkItem(temp_dir);
151 install_list->AddCreateDirWorkItem(install_path); 157 install_list->AddCreateDirWorkItem(install_path);
152 158
153 // Move the version folder 159 // If it is system level install copy the version folder (since we want to
154 install_list->AddMoveTreeWorkItem( 160 // take the permissions of %ProgramFiles% folder) otherwise just move it.
155 AppendPath(src_path, new_version.GetString()), 161 if (reg_root == HKEY_LOCAL_MACHINE) {
156 AppendPath(install_path, new_version.GetString()), 162 install_list->AddCopyTreeWorkItem(
157 temp_dir); 163 AppendPath(src_path, new_version.GetString()),
164 AppendPath(install_path, new_version.GetString()),
165 temp_dir, WorkItem::ALWAYS);
166 } else {
167 install_list->AddMoveTreeWorkItem(
168 AppendPath(src_path, new_version.GetString()),
169 AppendPath(install_path, new_version.GetString()),
170 temp_dir);
171 }
158 172
159 // Delete any new_chrome.exe if present (we will end up create a new one 173 // Delete any new_chrome.exe if present (we will end up create a new one
160 // if required) and then copy chrome.exe 174 // if required) and then copy chrome.exe
161 std::wstring new_chrome_exe = AppendPath(install_path, 175 std::wstring new_chrome_exe = AppendPath(install_path,
162 installer_util::kChromeNewExe); 176 installer_util::kChromeNewExe);
163 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); 177 BrowserDistribution* dist = BrowserDistribution::GetDistribution();
164 RegKey chrome_key(reg_root, dist->GetVersionKey().c_str(), KEY_READ); 178 RegKey chrome_key(reg_root, dist->GetVersionKey().c_str(), KEY_READ);
165 std::wstring current_version; 179 std::wstring current_version;
166 if (file_util::PathExists(new_chrome_exe)) 180 if (file_util::PathExists(new_chrome_exe))
167 chrome_key.ReadValue(google_update::kRegOldVersionField, &current_version); 181 chrome_key.ReadValue(google_update::kRegOldVersionField, &current_version);
168 if (current_version.empty()) 182 if (current_version.empty())
169 chrome_key.ReadValue(google_update::kRegVersionField, &current_version); 183 chrome_key.ReadValue(google_update::kRegVersionField, &current_version);
170 chrome_key.Close(); 184 chrome_key.Close();
171 185
172 install_list->AddDeleteTreeWorkItem(new_chrome_exe, std::wstring()); 186 install_list->AddDeleteTreeWorkItem(new_chrome_exe, std::wstring());
173 install_list->AddCopyTreeWorkItem( 187 install_list->AddCopyTreeWorkItem(
174 AppendPath(src_path, installer_util::kChromeExe), 188 AppendPath(src_path, installer_util::kChromeExe),
175 AppendPath(install_path, installer_util::kChromeExe), 189 AppendPath(install_path, installer_util::kChromeExe),
176 temp_dir, WorkItem::NEW_NAME_IF_IN_USE, new_chrome_exe); 190 temp_dir, WorkItem::NEW_NAME_IF_IN_USE, new_chrome_exe);
177 191
178 // Extra executable for 64 bit systems. 192 // Extra executable for 64 bit systems.
179 if (Is64bit()) { 193 if (Is64bit()) {
180 install_list->AddMoveTreeWorkItem( 194 install_list->AddCopyTreeWorkItem(
181 AppendPath(src_path, installer::kWowHelperExe), 195 AppendPath(src_path, installer::kWowHelperExe),
182 AppendPath(install_path, installer::kWowHelperExe), 196 AppendPath(install_path, installer::kWowHelperExe),
183 temp_dir); 197 temp_dir, WorkItem::ALWAYS);
184 } 198 }
185 199
186 // Copy the default Dictionaries only if the folder doesnt exist already 200 // Copy the default Dictionaries only if the folder doesnt exist already
187 install_list->AddCopyTreeWorkItem( 201 install_list->AddCopyTreeWorkItem(
188 AppendPath(src_path, installer::kDictionaries), 202 AppendPath(src_path, installer::kDictionaries),
189 AppendPath(install_path, installer::kDictionaries), 203 AppendPath(install_path, installer::kDictionaries),
190 temp_dir, WorkItem::IF_NOT_PRESENT); 204 temp_dir, WorkItem::IF_NOT_PRESENT);
191 205
192 // Copy installer in install directory and 206 // Copy installer in install directory and
193 // add shortcut in Control Panel->Add/Remove Programs. 207 // add shortcut in Control Panel->Add/Remove Programs.
194 AddInstallerCopyTasks(exe_path, archive_path, temp_dir, install_path, 208 AddInstallerCopyTasks(exe_path, archive_path, temp_dir, install_path,
195 new_version.GetString(), install_list.get()); 209 new_version.GetString(), install_list.get(),
210 (reg_root == HKEY_LOCAL_MACHINE));
196 std::wstring product_name = dist->GetApplicationName(); 211 std::wstring product_name = dist->GetApplicationName();
197 AddUninstallShortcutWorkItems(reg_root, exe_path, install_path, 212 AddUninstallShortcutWorkItems(reg_root, exe_path, install_path,
198 product_name, new_version.GetString(), install_list.get()); 213 product_name, new_version.GetString(), install_list.get());
199 214
200 // Delete any old_chrome.exe if present. 215 // Delete any old_chrome.exe if present.
201 install_list->AddDeleteTreeWorkItem( 216 install_list->AddDeleteTreeWorkItem(
202 AppendPath(install_path, installer_util::kChromeOldExe), std::wstring()); 217 AppendPath(install_path, installer_util::kChromeOldExe), std::wstring());
203 218
204 // Create Version key (if not already present) and set the new Chrome 219 // Create Version key (if not already present) and set the new Chrome
205 // version as last step. 220 // version as last step.
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 } 312 }
298 } 313 }
299 314
300 if (!success) { 315 if (!success) {
301 LOG(ERROR) << "Install failed, rolling back... "; 316 LOG(ERROR) << "Install failed, rolling back... ";
302 install_list->Rollback(); 317 install_list->Rollback();
303 LOG(ERROR) << "Rollback complete. "; 318 LOG(ERROR) << "Rollback complete. ";
304 } 319 }
305 return success; 320 return success;
306 } 321 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698