OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 <shlobj.h> | 5 #include <shlobj.h> |
6 #include <time.h> | 6 #include <time.h> |
7 | 7 |
8 #include "chrome/installer/setup/install.h" | 8 #include "chrome/installer/setup/install.h" |
9 | 9 |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 L"InstallDate", | 150 L"InstallDate", |
151 buffer, false); | 151 buffer, false); |
152 } | 152 } |
153 } | 153 } |
154 | 154 |
155 // Copy master preferences file provided to installer, in the same folder | 155 // Copy master preferences file provided to installer, in the same folder |
156 // as chrome.exe so Chrome first run can find it. This function will be called | 156 // as chrome.exe so Chrome first run can find it. This function will be called |
157 // only on the first install of Chrome. | 157 // only on the first install of Chrome. |
158 void CopyPreferenceFileForFirstRun(bool system_level, | 158 void CopyPreferenceFileForFirstRun(bool system_level, |
159 const std::wstring& prefs_source_path) { | 159 const std::wstring& prefs_source_path) { |
160 FilePath prefs_dest_path = FilePath::FromWStringHack( | 160 std::wstring prefs_dest_path( |
161 installer::GetChromeInstallPath(system_level)); | 161 installer::GetChromeInstallPath(system_level)); |
162 prefs_dest_path = prefs_dest_path.Append(installer_util::kDefaultMasterPrefs); | 162 file_util::AppendToPath(&prefs_dest_path, |
163 if (!file_util::CopyFile(FilePath::FromWStringHack(prefs_source_path), | 163 installer_util::kDefaultMasterPrefs); |
164 prefs_dest_path)) { | 164 if (!file_util::CopyFile(prefs_source_path, prefs_dest_path)) |
165 LOG(INFO) << "Failed to copy master preferences."; | 165 LOG(INFO) << "Failed to copy master preferences."; |
166 } | |
167 } | 166 } |
168 | 167 |
169 // This method creates Chrome shortcuts in Start->Programs for all users or | 168 // This method creates Chrome shortcuts in Start->Programs for all users or |
170 // only for current user depending on whether it is system wide install or | 169 // only for current user depending on whether it is system wide install or |
171 // user only install. | 170 // user only install. |
172 // | 171 // |
173 // If first_install is true, it creates shortcuts for launching and | 172 // If first_install is true, it creates shortcuts for launching and |
174 // uninstalling chrome. | 173 // uninstalling chrome. |
175 // If first_install is false, the function only updates the shortcut for | 174 // If first_install is false, the function only updates the shortcut for |
176 // uninstalling chrome. According to | 175 // uninstalling chrome. According to |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 // false. | 297 // false. |
299 bool DoPostInstallTasks(HKEY reg_root, | 298 bool DoPostInstallTasks(HKEY reg_root, |
300 const std::wstring& exe_path, | 299 const std::wstring& exe_path, |
301 const std::wstring& install_path, | 300 const std::wstring& install_path, |
302 const std::wstring& new_chrome_exe, | 301 const std::wstring& new_chrome_exe, |
303 const std::wstring& current_version, | 302 const std::wstring& current_version, |
304 const installer::Version& new_version) { | 303 const installer::Version& new_version) { |
305 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | 304 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
306 std::wstring version_key = dist->GetVersionKey(); | 305 std::wstring version_key = dist->GetVersionKey(); |
307 | 306 |
308 if (file_util::PathExists(FilePath::FromWStringHack(new_chrome_exe))) { | 307 if (file_util::PathExists(new_chrome_exe)) { |
309 // Looks like this was in use update. So make sure we update the 'opv' key | 308 // Looks like this was in use update. So make sure we update the 'opv' key |
310 // with the current version that is active and 'cmd' key with the rename | 309 // with the current version that is active and 'cmd' key with the rename |
311 // command to run. | 310 // command to run. |
312 if (current_version.empty()) { | 311 if (current_version.empty()) { |
313 LOG(ERROR) << "New chrome.exe exists but current version is empty!"; | 312 LOG(ERROR) << "New chrome.exe exists but current version is empty!"; |
314 return false; | 313 return false; |
315 } | 314 } |
316 scoped_ptr<WorkItemList> inuse_list(WorkItem::CreateWorkItemList()); | 315 scoped_ptr<WorkItemList> inuse_list(WorkItem::CreateWorkItemList()); |
317 inuse_list->AddSetRegValueWorkItem(reg_root, | 316 inuse_list->AddSetRegValueWorkItem(reg_root, |
318 version_key, | 317 version_key, |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 AppendPath(install_path, new_version.GetString()), | 485 AppendPath(install_path, new_version.GetString()), |
487 temp_dir); | 486 temp_dir); |
488 } | 487 } |
489 | 488 |
490 // Delete any new_chrome.exe if present (we will end up creating a new one | 489 // Delete any new_chrome.exe if present (we will end up creating a new one |
491 // if required) and then copy chrome.exe | 490 // if required) and then copy chrome.exe |
492 std::wstring new_chrome_exe = AppendPath(install_path, | 491 std::wstring new_chrome_exe = AppendPath(install_path, |
493 installer_util::kChromeNewExe); | 492 installer_util::kChromeNewExe); |
494 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | 493 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
495 RegKey chrome_key(reg_root, dist->GetVersionKey().c_str(), KEY_READ); | 494 RegKey chrome_key(reg_root, dist->GetVersionKey().c_str(), KEY_READ); |
496 if (file_util::PathExists(FilePath::FromWStringHack(new_chrome_exe))) | 495 if (file_util::PathExists(new_chrome_exe)) |
497 chrome_key.ReadValue(google_update::kRegOldVersionField, current_version); | 496 chrome_key.ReadValue(google_update::kRegOldVersionField, current_version); |
498 if (current_version->empty()) | 497 if (current_version->empty()) |
499 chrome_key.ReadValue(google_update::kRegVersionField, current_version); | 498 chrome_key.ReadValue(google_update::kRegVersionField, current_version); |
500 chrome_key.Close(); | 499 chrome_key.Close(); |
501 | 500 |
502 install_list->AddDeleteTreeWorkItem(new_chrome_exe, std::wstring()); | 501 install_list->AddDeleteTreeWorkItem(new_chrome_exe, std::wstring()); |
503 install_list->AddCopyTreeWorkItem( | 502 install_list->AddCopyTreeWorkItem( |
504 AppendPath(src_path, installer_util::kChromeExe), | 503 AppendPath(src_path, installer_util::kChromeExe), |
505 AppendPath(install_path, installer_util::kChromeExe), | 504 AppendPath(install_path, installer_util::kChromeExe), |
506 temp_dir, WorkItem::NEW_NAME_IF_IN_USE, new_chrome_exe); | 505 temp_dir, WorkItem::NEW_NAME_IF_IN_USE, new_chrome_exe); |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
635 } | 634 } |
636 | 635 |
637 std::wstring latest_version_to_keep(new_version.GetString()); | 636 std::wstring latest_version_to_keep(new_version.GetString()); |
638 if (!current_version.empty()) | 637 if (!current_version.empty()) |
639 latest_version_to_keep.assign(current_version); | 638 latest_version_to_keep.assign(current_version); |
640 RemoveOldVersionDirs(install_path, latest_version_to_keep); | 639 RemoveOldVersionDirs(install_path, latest_version_to_keep); |
641 } | 640 } |
642 | 641 |
643 return result; | 642 return result; |
644 } | 643 } |
OLD | NEW |