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

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

Issue 1878313003: Convert //chrome/installer from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert decompress.cc in mini_installer. Created 4 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
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 "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
11 #include <memory>
11 #include <string> 12 #include <string>
12 13
13 #include "base/files/file_enumerator.h" 14 #include "base/files/file_enumerator.h"
14 #include "base/files/file_path.h" 15 #include "base/files/file_path.h"
15 #include "base/files/file_util.h" 16 #include "base/files/file_util.h"
16 #include "base/logging.h" 17 #include "base/logging.h"
17 #include "base/memory/scoped_ptr.h"
18 #include "base/numerics/safe_conversions.h" 18 #include "base/numerics/safe_conversions.h"
19 #include "base/strings/string_util.h" 19 #include "base/strings/string_util.h"
20 #include "base/strings/stringprintf.h" 20 #include "base/strings/stringprintf.h"
21 #include "base/strings/utf_string_conversions.h" 21 #include "base/strings/utf_string_conversions.h"
22 #include "base/win/shortcut.h" 22 #include "base/win/shortcut.h"
23 #include "base/win/windows_version.h" 23 #include "base/win/windows_version.h"
24 #include "chrome/common/chrome_constants.h" 24 #include "chrome/common/chrome_constants.h"
25 #include "chrome/common/chrome_switches.h" 25 #include "chrome/common/chrome_switches.h"
26 #include "chrome/installer/setup/install_worker.h" 26 #include "chrome/installer/setup/install_worker.h"
27 #include "chrome/installer/setup/installer_crash_reporting.h" 27 #include "chrome/installer/setup/installer_crash_reporting.h"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 LogShortcutOperation(location, dist, properties, operation, true); 127 LogShortcutOperation(location, dist, properties, operation, true);
128 } 128 }
129 } 129 }
130 130
131 void AddChromeToMediaPlayerList() { 131 void AddChromeToMediaPlayerList() {
132 base::string16 reg_path(installer::kMediaPlayerRegPath); 132 base::string16 reg_path(installer::kMediaPlayerRegPath);
133 // registry paths can also be appended like file system path 133 // registry paths can also be appended like file system path
134 reg_path.push_back(base::FilePath::kSeparators[0]); 134 reg_path.push_back(base::FilePath::kSeparators[0]);
135 reg_path.append(installer::kChromeExe); 135 reg_path.append(installer::kChromeExe);
136 VLOG(1) << "Adding Chrome to Media player list at " << reg_path; 136 VLOG(1) << "Adding Chrome to Media player list at " << reg_path;
137 scoped_ptr<WorkItem> work_item(WorkItem::CreateCreateRegKeyWorkItem( 137 std::unique_ptr<WorkItem> work_item(WorkItem::CreateCreateRegKeyWorkItem(
138 HKEY_LOCAL_MACHINE, reg_path, WorkItem::kWow64Default)); 138 HKEY_LOCAL_MACHINE, reg_path, WorkItem::kWow64Default));
139 139
140 // if the operation fails we log the error but still continue 140 // if the operation fails we log the error but still continue
141 if (!work_item.get()->Do()) 141 if (!work_item.get()->Do())
142 LOG(ERROR) << "Could not add Chrome to media player inclusion list."; 142 LOG(ERROR) << "Could not add Chrome to media player inclusion list.";
143 } 143 }
144 144
145 // Copy master_preferences file provided to installer, in the same folder 145 // Copy master_preferences file provided to installer, in the same folder
146 // as chrome.exe so Chrome first run can find it. This function will be called 146 // as chrome.exe so Chrome first run can find it. This function will be called
147 // only on the first install of Chrome. 147 // only on the first install of Chrome.
(...skipping 29 matching lines...) Expand all
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 Version& new_version,
187 scoped_ptr<Version>* current_version) { 187 std::unique_ptr<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 installer::SetCurrentVersionCrashKey(current_version->get()); 193 installer::SetCurrentVersionCrashKey(current_version->get());
194 194
195 scoped_ptr<WorkItemList> install_list(WorkItem::CreateWorkItemList()); 195 std::unique_ptr<WorkItemList> install_list(WorkItem::CreateWorkItemList());
196 196
197 AddInstallWorkItems(original_state, 197 AddInstallWorkItems(original_state,
198 installer_state, 198 installer_state,
199 setup_path, 199 setup_path,
200 archive_path, 200 archive_path,
201 src_path, 201 src_path,
202 temp_path, 202 temp_path,
203 current_version->get(), 203 current_version->get(),
204 new_version, 204 new_version,
205 install_list.get()); 205 install_list.get());
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 // the same version. 574 // the same version.
575 LOG_IF(ERROR, !RemoveFromMovesPendingReboot(installer_state.target_path())) 575 LOG_IF(ERROR, !RemoveFromMovesPendingReboot(installer_state.target_path()))
576 << "Error accessing pending moves value."; 576 << "Error accessing pending moves value.";
577 577
578 // Create VisualElementManifest.xml in |src_path| (if required) so that it 578 // Create VisualElementManifest.xml in |src_path| (if required) so that it
579 // looks as if it had been extracted from the archive when calling 579 // looks as if it had been extracted from the archive when calling
580 // InstallNewVersion() below. 580 // InstallNewVersion() below.
581 installer_state.UpdateStage(installer::CREATING_VISUAL_MANIFEST); 581 installer_state.UpdateStage(installer::CREATING_VISUAL_MANIFEST);
582 CreateVisualElementsManifest(src_path, new_version); 582 CreateVisualElementsManifest(src_path, new_version);
583 583
584 scoped_ptr<Version> existing_version; 584 std::unique_ptr<Version> existing_version;
585 InstallStatus result = InstallNewVersion(original_state, installer_state, 585 InstallStatus result = InstallNewVersion(original_state, installer_state,
586 setup_path, archive_path, src_path, install_temp_path, new_version, 586 setup_path, archive_path, src_path, install_temp_path, new_version,
587 &existing_version); 587 &existing_version);
588 588
589 // TODO(robertshield): Everything below this line should instead be captured 589 // TODO(robertshield): Everything below this line should instead be captured
590 // by WorkItems. 590 // by WorkItems.
591 if (!InstallUtil::GetInstallReturnCode(result)) { 591 if (!InstallUtil::GetInstallReturnCode(result)) {
592 installer_state.UpdateStage(installer::UPDATING_CHANNELS); 592 installer_state.UpdateStage(installer::UPDATING_CHANNELS);
593 593
594 // Update the modifiers on the channel values for the product(s) being 594 // Update the modifiers on the channel values for the product(s) being
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 RegisterChromeOnMachine(installer_state, chrome, false); 698 RegisterChromeOnMachine(installer_state, chrome, false);
699 699
700 // Active Setup registrations are sometimes lost across OS update, make sure 700 // Active Setup registrations are sometimes lost across OS update, make sure
701 // they're back in place. Note: when Active Setup registrations in HKLM are 701 // they're back in place. Note: when Active Setup registrations in HKLM are
702 // lost, the per-user values of performed Active Setups in HKCU are also lost, 702 // lost, the per-user values of performed Active Setups in HKCU are also lost,
703 // so it is fine to restart the dynamic components of the Active Setup version 703 // so it is fine to restart the dynamic components of the Active Setup version
704 // (ref. UpdateActiveSetupVersionWorkItem) from scratch. 704 // (ref. UpdateActiveSetupVersionWorkItem) from scratch.
705 // TODO(gab): This should really perform all registry only update steps (i.e., 705 // TODO(gab): This should really perform all registry only update steps (i.e.,
706 // something between InstallOrUpdateProduct and AddActiveSetupWorkItems, but 706 // something between InstallOrUpdateProduct and AddActiveSetupWorkItems, but
707 // this takes care of what is most required for now). 707 // this takes care of what is most required for now).
708 scoped_ptr<WorkItemList> work_item_list(WorkItem::CreateWorkItemList()); 708 std::unique_ptr<WorkItemList> work_item_list(WorkItem::CreateWorkItemList());
709 AddActiveSetupWorkItems(installer_state, installed_version, chrome, 709 AddActiveSetupWorkItems(installer_state, installed_version, chrome,
710 work_item_list.get()); 710 work_item_list.get());
711 if (!work_item_list->Do()) { 711 if (!work_item_list->Do()) {
712 LOG(WARNING) << "Failed to reinstall Active Setup keys."; 712 LOG(WARNING) << "Failed to reinstall Active Setup keys.";
713 work_item_list->Rollback(); 713 work_item_list->Rollback();
714 } 714 }
715 715
716 UpdateOsUpgradeBeacon(installer_state.system_install(), 716 UpdateOsUpgradeBeacon(installer_state.system_install(),
717 BrowserDistribution::GetDistribution()); 717 BrowserDistribution::GetDistribution());
718 718
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 // Read master_preferences copied beside chrome.exe at install. 762 // Read master_preferences copied beside chrome.exe at install.
763 MasterPreferences prefs(installation_root.AppendASCII(kDefaultMasterPrefs)); 763 MasterPreferences prefs(installation_root.AppendASCII(kDefaultMasterPrefs));
764 base::FilePath chrome_exe(installation_root.Append(kChromeExe)); 764 base::FilePath chrome_exe(installation_root.Append(kChromeExe));
765 CreateOrUpdateShortcuts( 765 CreateOrUpdateShortcuts(
766 chrome_exe, chrome, prefs, CURRENT_USER, install_operation); 766 chrome_exe, chrome, prefs, CURRENT_USER, install_operation);
767 767
768 UpdateDefaultBrowserBeaconForPath(chrome_exe); 768 UpdateDefaultBrowserBeaconForPath(chrome_exe);
769 } 769 }
770 770
771 } // namespace installer 771 } // namespace installer
OLDNEW
« no previous file with comments | « chrome/browser/google/google_update_settings_posix.cc ('k') | chrome/installer/setup/install_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698