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 #include "chrome/installer/setup/install.h" | 5 #include "chrome/installer/setup/install.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 #include <shlobj.h> | 8 #include <shlobj.h> |
9 #include <time.h> | 9 #include <time.h> |
10 | 10 |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 // package. If package does not exist before calling the function | 176 // package. If package does not exist before calling the function |
177 // (typical new install), the function creates package during install | 177 // (typical new install), the function creates package during install |
178 // and removes the whole directory during rollback. | 178 // and removes the whole directory during rollback. |
179 installer::InstallStatus InstallNewVersion( | 179 installer::InstallStatus InstallNewVersion( |
180 const installer::InstallationState& original_state, | 180 const installer::InstallationState& original_state, |
181 const installer::InstallerState& installer_state, | 181 const installer::InstallerState& installer_state, |
182 const base::FilePath& setup_path, | 182 const base::FilePath& setup_path, |
183 const base::FilePath& archive_path, | 183 const base::FilePath& archive_path, |
184 const base::FilePath& src_path, | 184 const base::FilePath& src_path, |
185 const base::FilePath& temp_path, | 185 const base::FilePath& temp_path, |
186 const Version& new_version, | 186 const base::Version& new_version, |
187 scoped_ptr<Version>* current_version) { | 187 scoped_ptr<base::Version>* current_version) { |
188 DCHECK(current_version); | 188 DCHECK(current_version); |
189 | 189 |
190 installer_state.UpdateStage(installer::BUILDING); | 190 installer_state.UpdateStage(installer::BUILDING); |
191 | 191 |
192 current_version->reset(installer_state.GetCurrentVersion(original_state)); | 192 current_version->reset(installer_state.GetCurrentVersion(original_state)); |
193 scoped_ptr<WorkItemList> install_list(WorkItem::CreateWorkItemList()); | 193 scoped_ptr<WorkItemList> install_list(WorkItem::CreateWorkItemList()); |
194 | 194 |
195 AddInstallWorkItems(original_state, | 195 AddInstallWorkItems(original_state, |
196 installer_state, | 196 installer_state, |
197 setup_path, | 197 setup_path, |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 void EscapeXmlAttributeValueInSingleQuotes(base::string16* att_value) { | 273 void EscapeXmlAttributeValueInSingleQuotes(base::string16* att_value) { |
274 base::ReplaceChars(*att_value, base::ASCIIToUTF16("&"), | 274 base::ReplaceChars(*att_value, base::ASCIIToUTF16("&"), |
275 base::ASCIIToUTF16("&"), att_value); | 275 base::ASCIIToUTF16("&"), att_value); |
276 base::ReplaceChars(*att_value, base::ASCIIToUTF16("'"), | 276 base::ReplaceChars(*att_value, base::ASCIIToUTF16("'"), |
277 base::ASCIIToUTF16("'"), att_value); | 277 base::ASCIIToUTF16("'"), att_value); |
278 base::ReplaceChars(*att_value, base::ASCIIToUTF16("<"), | 278 base::ReplaceChars(*att_value, base::ASCIIToUTF16("<"), |
279 base::ASCIIToUTF16("<"), att_value); | 279 base::ASCIIToUTF16("<"), att_value); |
280 } | 280 } |
281 | 281 |
282 bool CreateVisualElementsManifest(const base::FilePath& src_path, | 282 bool CreateVisualElementsManifest(const base::FilePath& src_path, |
283 const Version& version) { | 283 const base::Version& version) { |
284 // Construct the relative path to the versioned VisualElements directory. | 284 // Construct the relative path to the versioned VisualElements directory. |
285 base::string16 elements_dir(base::ASCIIToUTF16(version.GetString())); | 285 base::string16 elements_dir(base::ASCIIToUTF16(version.GetString())); |
286 elements_dir.push_back(base::FilePath::kSeparators[0]); | 286 elements_dir.push_back(base::FilePath::kSeparators[0]); |
287 elements_dir.append(installer::kVisualElements); | 287 elements_dir.append(installer::kVisualElements); |
288 | 288 |
289 // Some distributions of Chromium may not include visual elements. Only | 289 // Some distributions of Chromium may not include visual elements. Only |
290 // proceed if this distribution does. | 290 // proceed if this distribution does. |
291 if (!base::PathExists(src_path.Append(elements_dir))) { | 291 if (!base::PathExists(src_path.Append(elements_dir))) { |
292 VLOG(1) << "No visual elements found, not writing " | 292 VLOG(1) << "No visual elements found, not writing " |
293 << installer::kVisualElementsManifest << " to " << src_path.value(); | 293 << installer::kVisualElementsManifest << " to " << src_path.value(); |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 | 482 |
483 InstallStatus InstallOrUpdateProduct( | 483 InstallStatus InstallOrUpdateProduct( |
484 const installer::InstallationState& original_state, | 484 const installer::InstallationState& original_state, |
485 const installer::InstallerState& installer_state, | 485 const installer::InstallerState& installer_state, |
486 const base::FilePath& setup_path, | 486 const base::FilePath& setup_path, |
487 const base::FilePath& archive_path, | 487 const base::FilePath& archive_path, |
488 const base::FilePath& install_temp_path, | 488 const base::FilePath& install_temp_path, |
489 const base::FilePath& src_path, | 489 const base::FilePath& src_path, |
490 const base::FilePath& prefs_path, | 490 const base::FilePath& prefs_path, |
491 const MasterPreferences& prefs, | 491 const MasterPreferences& prefs, |
492 const Version& new_version) { | 492 const base::Version& new_version) { |
493 DCHECK(!installer_state.products().empty()); | 493 DCHECK(!installer_state.products().empty()); |
494 | 494 |
495 // TODO(robertshield): Removing the pending on-reboot moves should be done | 495 // TODO(robertshield): Removing the pending on-reboot moves should be done |
496 // elsewhere. | 496 // elsewhere. |
497 // Remove any scheduled MOVEFILE_DELAY_UNTIL_REBOOT entries in the target of | 497 // Remove any scheduled MOVEFILE_DELAY_UNTIL_REBOOT entries in the target of |
498 // this installation. These may have been added during a previous uninstall of | 498 // this installation. These may have been added during a previous uninstall of |
499 // the same version. | 499 // the same version. |
500 LOG_IF(ERROR, !RemoveFromMovesPendingReboot(installer_state.target_path())) | 500 LOG_IF(ERROR, !RemoveFromMovesPendingReboot(installer_state.target_path())) |
501 << "Error accessing pending moves value."; | 501 << "Error accessing pending moves value."; |
502 | 502 |
503 // Create VisualElementManifest.xml in |src_path| (if required) so that it | 503 // Create VisualElementManifest.xml in |src_path| (if required) so that it |
504 // looks as if it had been extracted from the archive when calling | 504 // looks as if it had been extracted from the archive when calling |
505 // InstallNewVersion() below. | 505 // InstallNewVersion() below. |
506 installer_state.UpdateStage(installer::CREATING_VISUAL_MANIFEST); | 506 installer_state.UpdateStage(installer::CREATING_VISUAL_MANIFEST); |
507 CreateVisualElementsManifest(src_path, new_version); | 507 CreateVisualElementsManifest(src_path, new_version); |
508 | 508 |
509 scoped_ptr<Version> existing_version; | 509 scoped_ptr<base::Version> existing_version; |
510 InstallStatus result = InstallNewVersion(original_state, installer_state, | 510 InstallStatus result = InstallNewVersion(original_state, installer_state, |
511 setup_path, archive_path, src_path, install_temp_path, new_version, | 511 setup_path, archive_path, src_path, install_temp_path, new_version, |
512 &existing_version); | 512 &existing_version); |
513 | 513 |
514 // TODO(robertshield): Everything below this line should instead be captured | 514 // TODO(robertshield): Everything below this line should instead be captured |
515 // by WorkItems. | 515 // by WorkItems. |
516 if (!InstallUtil::GetInstallReturnCode(result)) { | 516 if (!InstallUtil::GetInstallReturnCode(result)) { |
517 installer_state.UpdateStage(installer::UPDATING_CHANNELS); | 517 installer_state.UpdateStage(installer::UPDATING_CHANNELS); |
518 | 518 |
519 // Update the modifiers on the channel values for the product(s) being | 519 // Update the modifiers on the channel values for the product(s) being |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
699 // Read master_preferences copied beside chrome.exe at install. | 699 // Read master_preferences copied beside chrome.exe at install. |
700 MasterPreferences prefs(installation_root.AppendASCII(kDefaultMasterPrefs)); | 700 MasterPreferences prefs(installation_root.AppendASCII(kDefaultMasterPrefs)); |
701 base::FilePath chrome_exe(installation_root.Append(kChromeExe)); | 701 base::FilePath chrome_exe(installation_root.Append(kChromeExe)); |
702 CreateOrUpdateShortcuts( | 702 CreateOrUpdateShortcuts( |
703 chrome_exe, chrome, prefs, CURRENT_USER, install_operation); | 703 chrome_exe, chrome, prefs, CURRENT_USER, install_operation); |
704 | 704 |
705 UpdateDefaultBrowserBeaconForPath(chrome_exe); | 705 UpdateDefaultBrowserBeaconForPath(chrome_exe); |
706 } | 706 } |
707 | 707 |
708 } // namespace installer | 708 } // namespace installer |
OLD | NEW |