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

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

Issue 2258243002: Consistently use namespaced base::Version in chrome/installer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 // This file contains the definitions of the installer functions that build 5 // This file contains the definitions of the installer functions that build
6 // the WorkItemList used to install the application. 6 // the WorkItemList used to install the application.
7 7
8 #include "chrome/installer/setup/install_worker.h" 8 #include "chrome/installer/setup/install_worker.h"
9 9
10 #include <oaidl.h> 10 #include <oaidl.h>
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 key_path->assign(kElevationPolicyKeyPath, 75 key_path->assign(kElevationPolicyKeyPath,
76 arraysize(kElevationPolicyKeyPath) - 1); 76 arraysize(kElevationPolicyKeyPath) - 1);
77 key_path->append(kIELowRightsPolicyOldGuid, 77 key_path->append(kIELowRightsPolicyOldGuid,
78 arraysize(kIELowRightsPolicyOldGuid)- 1); 78 arraysize(kIELowRightsPolicyOldGuid)- 1);
79 } 79 }
80 80
81 // Local helper to call AddRegisterComDllWorkItems for all DLLs in a set of 81 // Local helper to call AddRegisterComDllWorkItems for all DLLs in a set of
82 // products managed by a given package. 82 // products managed by a given package.
83 // |old_version| can be NULL to indicate no Chrome is currently installed. 83 // |old_version| can be NULL to indicate no Chrome is currently installed.
84 void AddRegisterComDllWorkItemsForPackage(const InstallerState& installer_state, 84 void AddRegisterComDllWorkItemsForPackage(const InstallerState& installer_state,
85 const Version* old_version, 85 const base::Version* old_version,
86 const Version& new_version, 86 const base::Version& new_version,
87 WorkItemList* work_item_list) { 87 WorkItemList* work_item_list) {
88 // First collect the list of DLLs to be registered from each product. 88 // First collect the list of DLLs to be registered from each product.
89 std::vector<base::FilePath> com_dll_list; 89 std::vector<base::FilePath> com_dll_list;
90 installer_state.AddComDllList(&com_dll_list); 90 installer_state.AddComDllList(&com_dll_list);
91 91
92 // Then, if we got some, attempt to unregister the DLLs from the old 92 // Then, if we got some, attempt to unregister the DLLs from the old
93 // version directory and then re-register them in the new one. 93 // version directory and then re-register them in the new one.
94 // Note that if we are migrating the install directory then we will not 94 // Note that if we are migrating the install directory then we will not
95 // successfully unregister the old DLLs. 95 // successfully unregister the old DLLs.
96 // TODO(robertshield): See whether we need to fix the migration case. 96 // TODO(robertshield): See whether we need to fix the migration case.
(...skipping 21 matching lines...) Expand all
118 true, // Register 118 true, // Register
119 false, // Must succeed. 119 false, // Must succeed.
120 work_item_list); 120 work_item_list);
121 } 121 }
122 } 122 }
123 123
124 void AddInstallerCopyTasks(const InstallerState& installer_state, 124 void AddInstallerCopyTasks(const InstallerState& installer_state,
125 const base::FilePath& setup_path, 125 const base::FilePath& setup_path,
126 const base::FilePath& archive_path, 126 const base::FilePath& archive_path,
127 const base::FilePath& temp_path, 127 const base::FilePath& temp_path,
128 const Version& new_version, 128 const base::Version& new_version,
129 WorkItemList* install_list) { 129 WorkItemList* install_list) {
130 DCHECK(install_list); 130 DCHECK(install_list);
131 base::FilePath installer_dir( 131 base::FilePath installer_dir(
132 installer_state.GetInstallerDirectory(new_version)); 132 installer_state.GetInstallerDirectory(new_version));
133 install_list->AddCreateDirWorkItem(installer_dir); 133 install_list->AddCreateDirWorkItem(installer_dir);
134 134
135 base::FilePath exe_dst(installer_dir.Append(setup_path.BaseName())); 135 base::FilePath exe_dst(installer_dir.Append(setup_path.BaseName()));
136 136
137 if (exe_dst != setup_path) { 137 if (exe_dst != setup_path) {
138 install_list->AddCopyTreeWorkItem(setup_path.value(), exe_dst.value(), 138 install_list->AddCopyTreeWorkItem(setup_path.value(), exe_dst.value(),
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 base::Bind(&AddFirewallRulesCallback, 221 base::Bind(&AddFirewallRulesCallback,
222 installer_state.system_install(), 222 installer_state.system_install(),
223 dist, 223 dist,
224 installer_state.target_path().Append(kChromeExe), 224 installer_state.target_path().Append(kChromeExe),
225 is_new_install)); 225 is_new_install));
226 } 226 }
227 227
228 void AddProductSpecificWorkItems(const InstallationState& original_state, 228 void AddProductSpecificWorkItems(const InstallationState& original_state,
229 const InstallerState& installer_state, 229 const InstallerState& installer_state,
230 const base::FilePath& setup_path, 230 const base::FilePath& setup_path,
231 const Version& new_version, 231 const base::Version& new_version,
232 const Version* current_version, 232 const base::Version* current_version,
233 bool add_language_identifier, 233 bool add_language_identifier,
234 WorkItemList* list) { 234 WorkItemList* list) {
235 const Products& products = installer_state.products(); 235 const Products& products = installer_state.products();
236 for (Products::const_iterator it = products.begin(); it < products.end(); 236 for (Products::const_iterator it = products.begin(); it < products.end();
237 ++it) { 237 ++it) {
238 const Product& p = **it; 238 const Product& p = **it;
239 if (p.is_chrome()) { 239 if (p.is_chrome()) {
240 AddOsUpgradeWorkItems(installer_state, setup_path, new_version, p, 240 AddOsUpgradeWorkItems(installer_state, setup_path, new_version, p,
241 list); 241 list);
242 AddFirewallRulesWorkItems(installer_state, p.distribution(), 242 AddFirewallRulesWorkItems(installer_state, p.distribution(),
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 } 278 }
279 279
280 // Adds Chrome specific install work items to |install_list|. 280 // Adds Chrome specific install work items to |install_list|.
281 // |current_version| can be NULL to indicate no Chrome is currently installed. 281 // |current_version| can be NULL to indicate no Chrome is currently installed.
282 void AddChromeWorkItems(const InstallationState& original_state, 282 void AddChromeWorkItems(const InstallationState& original_state,
283 const InstallerState& installer_state, 283 const InstallerState& installer_state,
284 const base::FilePath& setup_path, 284 const base::FilePath& setup_path,
285 const base::FilePath& archive_path, 285 const base::FilePath& archive_path,
286 const base::FilePath& src_path, 286 const base::FilePath& src_path,
287 const base::FilePath& temp_path, 287 const base::FilePath& temp_path,
288 const Version* current_version, 288 const base::Version* current_version,
289 const Version& new_version, 289 const base::Version& new_version,
290 WorkItemList* install_list) { 290 WorkItemList* install_list) {
291 const base::FilePath& target_path = installer_state.target_path(); 291 const base::FilePath& target_path = installer_state.target_path();
292 292
293 if (current_version) { 293 if (current_version) {
294 // Delete the archive from an existing install to save some disk space. 294 // Delete the archive from an existing install to save some disk space.
295 base::FilePath old_installer_dir( 295 base::FilePath old_installer_dir(
296 installer_state.GetInstallerDirectory(*current_version)); 296 installer_state.GetInstallerDirectory(*current_version));
297 base::FilePath old_archive( 297 base::FilePath old_archive(
298 old_installer_dir.Append(installer::kChromeArchive)); 298 old_installer_dir.Append(installer::kChromeArchive));
299 // Don't delete the archive that we are actually installing from. 299 // Don't delete the archive that we are actually installing from.
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 } 405 }
406 } 406 }
407 407
408 } // namespace 408 } // namespace
409 409
410 // This method adds work items to create (or update) Chrome uninstall entry in 410 // This method adds work items to create (or update) Chrome uninstall entry in
411 // either the Control Panel->Add/Remove Programs list or in the Omaha client 411 // either the Control Panel->Add/Remove Programs list or in the Omaha client
412 // state key if running under an MSI installer. 412 // state key if running under an MSI installer.
413 void AddUninstallShortcutWorkItems(const InstallerState& installer_state, 413 void AddUninstallShortcutWorkItems(const InstallerState& installer_state,
414 const base::FilePath& setup_path, 414 const base::FilePath& setup_path,
415 const Version& new_version, 415 const base::Version& new_version,
416 const Product& product, 416 const Product& product,
417 WorkItemList* install_list) { 417 WorkItemList* install_list) {
418 HKEY reg_root = installer_state.root_key(); 418 HKEY reg_root = installer_state.root_key();
419 BrowserDistribution* browser_dist = product.distribution(); 419 BrowserDistribution* browser_dist = product.distribution();
420 DCHECK(browser_dist); 420 DCHECK(browser_dist);
421 421
422 // When we are installed via an MSI, we need to store our uninstall strings 422 // When we are installed via an MSI, we need to store our uninstall strings
423 // in the Google Update client state key. We do this even for non-MSI 423 // in the Google Update client state key. We do this even for non-MSI
424 // managed installs to avoid breaking the edge case whereby an MSI-managed 424 // managed installs to avoid breaking the edge case whereby an MSI-managed
425 // install is updated by a non-msi installer (which would confuse the MSI 425 // install is updated by a non-msi installer (which would confuse the MSI
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 true); 551 true);
552 } 552 }
553 } 553 }
554 } 554 }
555 555
556 // Create Version key for a product (if not already present) and sets the new 556 // Create Version key for a product (if not already present) and sets the new
557 // product version as the last step. 557 // product version as the last step.
558 void AddVersionKeyWorkItems(HKEY root, 558 void AddVersionKeyWorkItems(HKEY root,
559 const base::string16& version_key, 559 const base::string16& version_key,
560 const base::string16& product_name, 560 const base::string16& product_name,
561 const Version& new_version, 561 const base::Version& new_version,
562 bool add_language_identifier, 562 bool add_language_identifier,
563 WorkItemList* list) { 563 WorkItemList* list) {
564 list->AddCreateRegKeyWorkItem(root, version_key, KEY_WOW64_32KEY); 564 list->AddCreateRegKeyWorkItem(root, version_key, KEY_WOW64_32KEY);
565 565
566 list->AddSetRegValueWorkItem(root, 566 list->AddSetRegValueWorkItem(root,
567 version_key, 567 version_key,
568 KEY_WOW64_32KEY, 568 KEY_WOW64_32KEY,
569 google_update::kRegNameField, 569 google_update::kRegNameField,
570 product_name, 570 product_name,
571 true); // overwrite name also 571 true); // overwrite name also
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
888 installer_state.root_key(), 888 installer_state.root_key(),
889 chrome_product->distribution()->GetStateKey(), 889 chrome_product->distribution()->GetStateKey(),
890 KEY_WOW64_32KEY, 890 KEY_WOW64_32KEY,
891 google_update::kRegUsageStatsField, 891 google_update::kRegUsageStatsField,
892 usagestats, 892 usagestats,
893 true); 893 true);
894 } 894 }
895 895
896 bool AppendPostInstallTasks(const InstallerState& installer_state, 896 bool AppendPostInstallTasks(const InstallerState& installer_state,
897 const base::FilePath& setup_path, 897 const base::FilePath& setup_path,
898 const Version* current_version, 898 const base::Version* current_version,
899 const Version& new_version, 899 const base::Version& new_version,
900 WorkItemList* post_install_task_list) { 900 WorkItemList* post_install_task_list) {
901 DCHECK(post_install_task_list); 901 DCHECK(post_install_task_list);
902 902
903 HKEY root = installer_state.root_key(); 903 HKEY root = installer_state.root_key();
904 const Products& products = installer_state.products(); 904 const Products& products = installer_state.products();
905 base::FilePath new_chrome_exe( 905 base::FilePath new_chrome_exe(
906 installer_state.target_path().Append(installer::kChromeNewExe)); 906 installer_state.target_path().Append(installer::kChromeNewExe));
907 907
908 // Append work items that will only be executed if this was an update. 908 // Append work items that will only be executed if this was an update.
909 // We update the 'opv' value with the current version that is active, 909 // We update the 'opv' value with the current version that is active,
910 // the 'cpv' value with the critical update version (if present), and the 910 // the 'cpv' value with the critical update version (if present), and the
911 // 'cmd' value with the rename command to run. 911 // 'cmd' value with the rename command to run.
912 { 912 {
913 std::unique_ptr<WorkItemList> in_use_update_work_items( 913 std::unique_ptr<WorkItemList> in_use_update_work_items(
914 WorkItem::CreateConditionalWorkItemList( 914 WorkItem::CreateConditionalWorkItemList(
915 new ConditionRunIfFileExists(new_chrome_exe))); 915 new ConditionRunIfFileExists(new_chrome_exe)));
916 in_use_update_work_items->set_log_message("InUseUpdateWorkItemList"); 916 in_use_update_work_items->set_log_message("InUseUpdateWorkItemList");
917 917
918 // |critical_version| will be valid only if this in-use update includes a 918 // |critical_version| will be valid only if this in-use update includes a
919 // version considered critical relative to the version being updated. 919 // version considered critical relative to the version being updated.
920 Version critical_version(installer_state.DetermineCriticalVersion( 920 base::Version critical_version(installer_state.DetermineCriticalVersion(
921 current_version, new_version)); 921 current_version, new_version));
922 base::FilePath installer_path( 922 base::FilePath installer_path(
923 installer_state.GetInstallerDirectory(new_version).Append( 923 installer_state.GetInstallerDirectory(new_version).Append(
924 setup_path.BaseName())); 924 setup_path.BaseName()));
925 925
926 base::CommandLine rename(installer_path); 926 base::CommandLine rename(installer_path);
927 rename.AppendSwitch(switches::kRenameChromeExe); 927 rename.AppendSwitch(switches::kRenameChromeExe);
928 if (installer_state.system_install()) 928 if (installer_state.system_install())
929 rename.AppendSwitch(switches::kSystemLevel); 929 rename.AppendSwitch(switches::kSystemLevel);
930 930
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
1036 1036
1037 return true; 1037 return true;
1038 } 1038 }
1039 1039
1040 void AddInstallWorkItems(const InstallationState& original_state, 1040 void AddInstallWorkItems(const InstallationState& original_state,
1041 const InstallerState& installer_state, 1041 const InstallerState& installer_state,
1042 const base::FilePath& setup_path, 1042 const base::FilePath& setup_path,
1043 const base::FilePath& archive_path, 1043 const base::FilePath& archive_path,
1044 const base::FilePath& src_path, 1044 const base::FilePath& src_path,
1045 const base::FilePath& temp_path, 1045 const base::FilePath& temp_path,
1046 const Version* current_version, 1046 const base::Version* current_version,
1047 const Version& new_version, 1047 const base::Version& new_version,
1048 WorkItemList* install_list) { 1048 WorkItemList* install_list) {
1049 DCHECK(install_list); 1049 DCHECK(install_list);
1050 1050
1051 const base::FilePath& target_path = installer_state.target_path(); 1051 const base::FilePath& target_path = installer_state.target_path();
1052 1052
1053 // A temp directory that work items need and the actual install directory. 1053 // A temp directory that work items need and the actual install directory.
1054 install_list->AddCreateDirWorkItem(temp_path); 1054 install_list->AddCreateDirWorkItem(temp_path);
1055 install_list->AddCreateDirWorkItem(target_path); 1055 install_list->AddCreateDirWorkItem(target_path);
1056 1056
1057 // Create the directory in which persistent metrics will be stored. 1057 // Create the directory in which persistent metrics will be stored.
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
1195 list->AddDeleteRegKeyWorkItem(HKEY_CURRENT_USER, 1195 list->AddDeleteRegKeyWorkItem(HKEY_CURRENT_USER,
1196 dist->GetRegistryPath() + L"\\Metro", 1196 dist->GetRegistryPath() + L"\\Metro",
1197 KEY_WOW64_32KEY); 1197 KEY_WOW64_32KEY);
1198 list->AddDeleteRegKeyWorkItem(HKEY_CURRENT_USER, 1198 list->AddDeleteRegKeyWorkItem(HKEY_CURRENT_USER,
1199 dist->GetRegistryPath() + L"\\Metro", 1199 dist->GetRegistryPath() + L"\\Metro",
1200 KEY_WOW64_64KEY); 1200 KEY_WOW64_64KEY);
1201 } 1201 }
1202 } 1202 }
1203 1203
1204 void AddActiveSetupWorkItems(const InstallerState& installer_state, 1204 void AddActiveSetupWorkItems(const InstallerState& installer_state,
1205 const Version& new_version, 1205 const base::Version& new_version,
1206 const Product& product, 1206 const Product& product,
1207 WorkItemList* list) { 1207 WorkItemList* list) {
1208 DCHECK(installer_state.operation() != InstallerState::UNINSTALL); 1208 DCHECK(installer_state.operation() != InstallerState::UNINSTALL);
1209 BrowserDistribution* dist = product.distribution(); 1209 BrowserDistribution* dist = product.distribution();
1210 1210
1211 if (!product.is_chrome() || !installer_state.system_install()) { 1211 if (!product.is_chrome() || !installer_state.system_install()) {
1212 const char* install_level = 1212 const char* install_level =
1213 installer_state.system_install() ? "system" : "user"; 1213 installer_state.system_install() ? "system" : "user";
1214 VLOG(1) << "No Active Setup processing to do for " << install_level 1214 VLOG(1) << "No Active Setup processing to do for " << install_level
1215 << "-level " << dist->GetDisplayName(); 1215 << "-level " << dist->GetDisplayName();
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
1309 } 1309 }
1310 1310
1311 FreeLibrary(ieframe); 1311 FreeLibrary(ieframe);
1312 } else { 1312 } else {
1313 VLOG(1) << "Cannot load " << kIEFrameDll; 1313 VLOG(1) << "Cannot load " << kIEFrameDll;
1314 } 1314 }
1315 } 1315 }
1316 1316
1317 void AddOsUpgradeWorkItems(const InstallerState& installer_state, 1317 void AddOsUpgradeWorkItems(const InstallerState& installer_state,
1318 const base::FilePath& setup_path, 1318 const base::FilePath& setup_path,
1319 const Version& new_version, 1319 const base::Version& new_version,
1320 const Product& product, 1320 const Product& product,
1321 WorkItemList* install_list) { 1321 WorkItemList* install_list) {
1322 const HKEY root_key = installer_state.root_key(); 1322 const HKEY root_key = installer_state.root_key();
1323 base::string16 cmd_key( 1323 base::string16 cmd_key(
1324 GetRegCommandKey(product.distribution(), kCmdOnOsUpgrade)); 1324 GetRegCommandKey(product.distribution(), kCmdOnOsUpgrade));
1325 1325
1326 if (installer_state.operation() == InstallerState::UNINSTALL) { 1326 if (installer_state.operation() == InstallerState::UNINSTALL) {
1327 install_list->AddDeleteRegKeyWorkItem(root_key, cmd_key, KEY_WOW64_32KEY) 1327 install_list->AddDeleteRegKeyWorkItem(root_key, cmd_key, KEY_WOW64_32KEY)
1328 ->set_log_message("Removing OS upgrade command"); 1328 ->set_log_message("Removing OS upgrade command");
1329 } else { 1329 } else {
(...skipping 29 matching lines...) Expand all
1359 // Unconditionally remove the legacy Quick Enable command from the binaries. 1359 // Unconditionally remove the legacy Quick Enable command from the binaries.
1360 // Do this even if multi-install Chrome isn't installed to ensure that it is 1360 // Do this even if multi-install Chrome isn't installed to ensure that it is
1361 // not left behind in any case. 1361 // not left behind in any case.
1362 work_item_list->AddDeleteRegKeyWorkItem( 1362 work_item_list->AddDeleteRegKeyWorkItem(
1363 installer_state.root_key(), cmd_key, KEY_WOW64_32KEY) 1363 installer_state.root_key(), cmd_key, KEY_WOW64_32KEY)
1364 ->set_log_message("removing " + base::UTF16ToASCII(kCmdQuickEnableCf) + 1364 ->set_log_message("removing " + base::UTF16ToASCII(kCmdQuickEnableCf) +
1365 " command"); 1365 " command");
1366 } 1366 }
1367 1367
1368 } // namespace installer 1368 } // namespace installer
OLDNEW
« no previous file with comments | « chrome/installer/setup/install_unittest.cc ('k') | chrome/installer/setup/install_worker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698