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

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

Issue 619203002: [Installer] Make recent install_worker.cc changes use AppRegistrationData (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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) 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 13 matching lines...) Expand all
24 #include "base/strings/utf_string_conversions.h" 24 #include "base/strings/utf_string_conversions.h"
25 #include "base/version.h" 25 #include "base/version.h"
26 #include "base/win/registry.h" 26 #include "base/win/registry.h"
27 #include "base/win/scoped_comptr.h" 27 #include "base/win/scoped_comptr.h"
28 #include "base/win/windows_version.h" 28 #include "base/win/windows_version.h"
29 #include "chrome/common/chrome_constants.h" 29 #include "chrome/common/chrome_constants.h"
30 #include "chrome/common/chrome_switches.h" 30 #include "chrome/common/chrome_switches.h"
31 #include "chrome/installer/setup/install.h" 31 #include "chrome/installer/setup/install.h"
32 #include "chrome/installer/setup/setup_constants.h" 32 #include "chrome/installer/setup/setup_constants.h"
33 #include "chrome/installer/setup/setup_util.h" 33 #include "chrome/installer/setup/setup_util.h"
34 #include "chrome/installer/util/app_registration_data.h"
34 #include "chrome/installer/util/browser_distribution.h" 35 #include "chrome/installer/util/browser_distribution.h"
35 #include "chrome/installer/util/callback_work_item.h" 36 #include "chrome/installer/util/callback_work_item.h"
36 #include "chrome/installer/util/conditional_work_item_list.h" 37 #include "chrome/installer/util/conditional_work_item_list.h"
37 #include "chrome/installer/util/create_reg_key_work_item.h" 38 #include "chrome/installer/util/create_reg_key_work_item.h"
38 #include "chrome/installer/util/firewall_manager_win.h" 39 #include "chrome/installer/util/firewall_manager_win.h"
39 #include "chrome/installer/util/google_update_constants.h" 40 #include "chrome/installer/util/google_update_constants.h"
40 #include "chrome/installer/util/helper.h" 41 #include "chrome/installer/util/helper.h"
41 #include "chrome/installer/util/install_util.h" 42 #include "chrome/installer/util/install_util.h"
42 #include "chrome/installer/util/installation_state.h" 43 #include "chrome/installer/util/installation_state.h"
43 #include "chrome/installer/util/installer_state.h" 44 #include "chrome/installer/util/installer_state.h"
44 #include "chrome/installer/util/l10n_string_util.h" 45 #include "chrome/installer/util/l10n_string_util.h"
45 #include "chrome/installer/util/product.h" 46 #include "chrome/installer/util/product.h"
46 #include "chrome/installer/util/set_reg_value_work_item.h" 47 #include "chrome/installer/util/set_reg_value_work_item.h"
47 #include "chrome/installer/util/shell_util.h" 48 #include "chrome/installer/util/shell_util.h"
49 #include "chrome/installer/util/updating_app_registration_data.h"
48 #include "chrome/installer/util/util_constants.h" 50 #include "chrome/installer/util/util_constants.h"
49 #include "chrome/installer/util/work_item_list.h" 51 #include "chrome/installer/util/work_item_list.h"
50 52
51 using base::ASCIIToWide; 53 using base::ASCIIToWide;
52 using base::win::RegKey; 54 using base::win::RegKey;
53 55
54 namespace installer { 56 namespace installer {
55 57
56 namespace { 58 namespace {
57 59
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 // system-level archive. 180 // system-level archive.
179 install_list->AddCopyTreeWorkItem(archive_path.value(), 181 install_list->AddCopyTreeWorkItem(archive_path.value(),
180 archive_dst.value(), 182 archive_dst.value(),
181 temp_path.value(), 183 temp_path.value(),
182 WorkItem::ALWAYS); 184 WorkItem::ALWAYS);
183 } 185 }
184 } 186 }
185 } 187 }
186 } 188 }
187 189
188 base::string16 GetRegCommandKey(BrowserDistribution* dist, 190 base::string16 GetRegCommandKey(const AppRegistrationData& reg_data,
grt (UTC plus 2) 2014/10/01 20:14:26 this makes all callers' lives a bit more difficult
huangs 2014/10/01 22:39:20 Done.
189 const wchar_t* name) { 191 const wchar_t* name) {
190 base::string16 cmd_key(dist->GetVersionKey()); 192 base::string16 cmd_key(reg_data.GetVersionKey());
191 cmd_key.append(1, base::FilePath::kSeparators[0]) 193 cmd_key.append(1, base::FilePath::kSeparators[0])
192 .append(google_update::kRegCommandsKey) 194 .append(google_update::kRegCommandsKey)
193 .append(1, base::FilePath::kSeparators[0]) 195 .append(1, base::FilePath::kSeparators[0])
194 .append(name); 196 .append(name);
195 return cmd_key; 197 return cmd_key;
196 } 198 }
197 199
198 // Adds work items to create (or delete if uninstalling) app commands to launch 200 // Adds work items to create (or delete if uninstalling) app commands to launch
199 // the app with a switch. The following criteria should be true: 201 // the app with a switch. The following criteria should be true:
200 // 1. The switch takes one parameter. 202 // 1. The switch takes one parameter.
201 // 2. The command send pings. 203 // 2. The command send pings.
202 // 3. The command is web accessible. 204 // 3. The command is web accessible.
203 // 4. The command is run as the user. 205 // 4. The command is run as the user.
204 void AddCommandWithParameterWorkItems(const InstallerState& installer_state, 206 void AddCommandWithParameterWorkItems(const InstallerState& installer_state,
205 const InstallationState& machine_state, 207 const InstallationState& machine_state,
206 const Version& new_version, 208 const Version& new_version,
207 const Product& product, 209 const Product& product,
208 const wchar_t* command_key, 210 const wchar_t* command_key,
209 const wchar_t* app, 211 const wchar_t* app,
210 const char* command_with_parameter, 212 const char* command_with_parameter,
211 WorkItemList* work_item_list) { 213 WorkItemList* work_item_list) {
212 DCHECK(command_key); 214 DCHECK(command_key);
213 DCHECK(app); 215 DCHECK(app);
214 DCHECK(command_with_parameter); 216 DCHECK(command_with_parameter);
215 DCHECK(work_item_list); 217 DCHECK(work_item_list);
216 218
217 base::string16 full_cmd_key( 219 base::string16 full_cmd_key(
218 GetRegCommandKey(product.distribution(), command_key)); 220 GetRegCommandKey(product.distribution()->GetAppRegistrationData(),
221 command_key));
219 222
220 if (installer_state.operation() == InstallerState::UNINSTALL) { 223 if (installer_state.operation() == InstallerState::UNINSTALL) {
221 work_item_list->AddDeleteRegKeyWorkItem(installer_state.root_key(), 224 work_item_list->AddDeleteRegKeyWorkItem(installer_state.root_key(),
222 full_cmd_key, 225 full_cmd_key,
223 KEY_WOW64_32KEY) 226 KEY_WOW64_32KEY)
224 ->set_log_message("removing " + base::UTF16ToASCII(command_key) + 227 ->set_log_message("removing " + base::UTF16ToASCII(command_key) +
225 " command"); 228 " command");
226 } else { 229 } else {
227 CommandLine cmd_line(installer_state.target_path().Append(app)); 230 CommandLine cmd_line(installer_state.target_path().Append(app));
228 cmd_line.AppendSwitchASCII(command_with_parameter, "%1"); 231 cmd_line.AppendSwitchASCII(command_with_parameter, "%1");
229 232
230 AppCommand cmd(cmd_line.GetCommandLineString()); 233 AppCommand cmd(cmd_line.GetCommandLineString());
231 cmd.set_sends_pings(true); 234 cmd.set_sends_pings(true);
232 cmd.set_is_web_accessible(true); 235 cmd.set_is_web_accessible(true);
233 cmd.set_is_run_as_user(true); 236 cmd.set_is_run_as_user(true);
234 cmd.AddWorkItems(installer_state.root_key(), full_cmd_key, work_item_list); 237 cmd.AddWorkItems(installer_state.root_key(), full_cmd_key, work_item_list);
235 } 238 }
236 } 239 }
237 240
238 void AddLegacyAppCommandRemovalItem(const InstallerState& installer_state, 241 void AddLegacyAppCommandRemovalItem(const InstallerState& installer_state,
239 BrowserDistribution* distribution, 242 const AppRegistrationData& reg_data,
240 const wchar_t* name, 243 const wchar_t* name,
241 WorkItemList* work_item_list) { 244 WorkItemList* work_item_list) {
242 // These failures are ignored because this is a clean-up operation that 245 // These failures are ignored because this is a clean-up operation that
243 // shouldn't block an install or update on failing. 246 // shouldn't block an install or update on failing.
244 work_item_list->AddDeleteRegKeyWorkItem( 247 work_item_list->AddDeleteRegKeyWorkItem(
245 installer_state.root_key(), 248 installer_state.root_key(),
246 GetRegCommandKey(distribution, name), 249 GetRegCommandKey(reg_data, name),
247 KEY_WOW64_32KEY)->set_ignore_failure(true); 250 KEY_WOW64_32KEY)->set_ignore_failure(true);
248 } 251 }
249 252
250 // A callback invoked by |work_item| that adds firewall rules for Chrome. Rules 253 // A callback invoked by |work_item| that adds firewall rules for Chrome. Rules
251 // are left in-place on rollback unless |remove_on_rollback| is true. This is 254 // are left in-place on rollback unless |remove_on_rollback| is true. This is
252 // the case for new installs only. Updates and overinstalls leave the rule 255 // the case for new installs only. Updates and overinstalls leave the rule
253 // in-place on rollback since a previous install of Chrome will be used in that 256 // in-place on rollback since a previous install of Chrome will be used in that
254 // case. 257 // case.
255 bool AddFirewallRulesCallback(bool system_level, 258 bool AddFirewallRulesCallback(bool system_level,
256 BrowserDistribution* dist, 259 BrowserDistribution* dist,
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 358
356 bool will_have_chrome_binaries = 359 bool will_have_chrome_binaries =
357 WillProductBePresentAfterSetup(installer_state, machine_state, 360 WillProductBePresentAfterSetup(installer_state, machine_state,
358 BrowserDistribution::CHROME_BINARIES); 361 BrowserDistribution::CHROME_BINARIES);
359 362
360 // For system-level binaries there is no way to keep the command state in sync 363 // For system-level binaries there is no way to keep the command state in sync
361 // with the installation/uninstallation of the Application Launcher (which is 364 // with the installation/uninstallation of the Application Launcher (which is
362 // always at user-level). So we do not try to remove the command, i.e., it 365 // always at user-level). So we do not try to remove the command, i.e., it
363 // will always be installed if the Chrome Binaries are installed. 366 // will always be installed if the Chrome Binaries are installed.
364 if (will_have_chrome_binaries) { 367 if (will_have_chrome_binaries) {
368 BrowserDistribution* binaries_dist =
369 BrowserDistribution::GetSpecificDistribution(
370 BrowserDistribution::CHROME_BINARIES);
365 base::string16 cmd_key( 371 base::string16 cmd_key(
366 GetRegCommandKey(BrowserDistribution::GetSpecificDistribution( 372 GetRegCommandKey(binaries_dist->GetAppRegistrationData(),
367 BrowserDistribution::CHROME_BINARIES),
368 kCmdQuickEnableApplicationHost)); 373 kCmdQuickEnableApplicationHost));
369 CommandLine cmd_line(GetGenericQuickEnableCommand(installer_state, 374 CommandLine cmd_line(GetGenericQuickEnableCommand(installer_state,
370 machine_state, 375 machine_state,
371 setup_path, 376 setup_path,
372 new_version)); 377 new_version));
373 // kMultiInstall and kVerboseLogging were processed above. 378 // kMultiInstall and kVerboseLogging were processed above.
374 cmd_line.AppendSwitch(switches::kChromeAppLauncher); 379 cmd_line.AppendSwitch(switches::kChromeAppLauncher);
375 cmd_line.AppendSwitch(switches::kEnsureGoogleUpdatePresent); 380 cmd_line.AppendSwitch(switches::kEnsureGoogleUpdatePresent);
376 AppCommand cmd(cmd_line.GetCommandLineString()); 381 AppCommand cmd(cmd_line.GetCommandLineString());
377 cmd.set_sends_pings(true); 382 cmd.set_sends_pings(true);
(...skipping 12 matching lines...) Expand all
390 const Products& products = installer_state.products(); 395 const Products& products = installer_state.products();
391 for (Products::const_iterator it = products.begin(); it < products.end(); 396 for (Products::const_iterator it = products.begin(); it < products.end();
392 ++it) { 397 ++it) {
393 const Product& p = **it; 398 const Product& p = **it;
394 if (p.is_chrome()) { 399 if (p.is_chrome()) {
395 AddOsUpgradeWorkItems(installer_state, setup_path, new_version, p, 400 AddOsUpgradeWorkItems(installer_state, setup_path, new_version, p,
396 list); 401 list);
397 AddFirewallRulesWorkItems( 402 AddFirewallRulesWorkItems(
398 installer_state, p.distribution(), is_new_install, list); 403 installer_state, p.distribution(), is_new_install, list);
399 AddLegacyAppCommandRemovalItem( 404 AddLegacyAppCommandRemovalItem(
400 installer_state, p.distribution(), kLegacyCmdInstallExtension, list); 405 installer_state,
406 p.distribution()->GetAppRegistrationData(),
407 kLegacyCmdInstallExtension,
408 list);
401 409
402 if (p.distribution()->AppHostIsSupported()) { 410 if (p.distribution()->AppHostIsSupported()) {
403 // Unconditionally remove the "install-application" command from the app 411 // Unconditionally remove the "install-application" command from the app
404 // hosts's key. 412 // hosts's key.
405 AddLegacyAppCommandRemovalItem( 413 UpdatingAppRegistrationData app_launcher_reg_data(
406 installer_state, 414 installer::kAppLauncherGuid);
407 BrowserDistribution::GetSpecificDistribution( 415 AddLegacyAppCommandRemovalItem(installer_state, app_launcher_reg_data,
408 BrowserDistribution::CHROME_APP_HOST), 416 kLegacyCmdInstallApp, list);
409 kLegacyCmdInstallApp,
410 list);
411 } 417 }
412 } 418 }
413 if (p.is_chrome_binaries()) { 419 if (p.is_chrome_binaries()) {
414 AddQueryEULAAcceptanceWorkItems( 420 AddQueryEULAAcceptanceWorkItems(
415 installer_state, setup_path, new_version, p, list); 421 installer_state, setup_path, new_version, p, list);
416 AddQuickEnableChromeFrameWorkItems(installer_state, list); 422 AddQuickEnableChromeFrameWorkItems(installer_state, list);
417 AddQuickEnableApplicationLauncherWorkItems( 423 AddQuickEnableApplicationLauncherWorkItems(
418 installer_state, original_state, setup_path, new_version, list); 424 installer_state, original_state, setup_path, new_version, list);
419 } 425 }
420 } 426 }
(...skipping 1162 matching lines...) Expand 10 before | Expand all | Expand 10 after
1583 } 1589 }
1584 } 1590 }
1585 1591
1586 void AddOsUpgradeWorkItems(const InstallerState& installer_state, 1592 void AddOsUpgradeWorkItems(const InstallerState& installer_state,
1587 const base::FilePath& setup_path, 1593 const base::FilePath& setup_path,
1588 const Version& new_version, 1594 const Version& new_version,
1589 const Product& product, 1595 const Product& product,
1590 WorkItemList* install_list) { 1596 WorkItemList* install_list) {
1591 const HKEY root_key = installer_state.root_key(); 1597 const HKEY root_key = installer_state.root_key();
1592 base::string16 cmd_key( 1598 base::string16 cmd_key(
1593 GetRegCommandKey(product.distribution(), kCmdOnOsUpgrade)); 1599 GetRegCommandKey(product.distribution()->GetAppRegistrationData(),
1600 kCmdOnOsUpgrade));
1594 1601
1595 if (installer_state.operation() == InstallerState::UNINSTALL) { 1602 if (installer_state.operation() == InstallerState::UNINSTALL) {
1596 install_list->AddDeleteRegKeyWorkItem(root_key, cmd_key, KEY_WOW64_32KEY) 1603 install_list->AddDeleteRegKeyWorkItem(root_key, cmd_key, KEY_WOW64_32KEY)
1597 ->set_log_message("Removing OS upgrade command"); 1604 ->set_log_message("Removing OS upgrade command");
1598 } else { 1605 } else {
1599 // Register with Google Update to have setup.exe --on-os-upgrade called on 1606 // Register with Google Update to have setup.exe --on-os-upgrade called on
1600 // OS upgrade. 1607 // OS upgrade.
1601 CommandLine cmd_line(installer_state 1608 CommandLine cmd_line(installer_state
1602 .GetInstallerDirectory(new_version) 1609 .GetInstallerDirectory(new_version)
1603 .Append(setup_path.BaseName())); 1610 .Append(setup_path.BaseName()));
(...skipping 12 matching lines...) Expand all
1616 } 1623 }
1617 } 1624 }
1618 1625
1619 void AddQueryEULAAcceptanceWorkItems(const InstallerState& installer_state, 1626 void AddQueryEULAAcceptanceWorkItems(const InstallerState& installer_state,
1620 const base::FilePath& setup_path, 1627 const base::FilePath& setup_path,
1621 const Version& new_version, 1628 const Version& new_version,
1622 const Product& product, 1629 const Product& product,
1623 WorkItemList* work_item_list) { 1630 WorkItemList* work_item_list) {
1624 const HKEY root_key = installer_state.root_key(); 1631 const HKEY root_key = installer_state.root_key();
1625 base::string16 cmd_key( 1632 base::string16 cmd_key(
1626 GetRegCommandKey(product.distribution(), kCmdQueryEULAAcceptance)); 1633 GetRegCommandKey(product.distribution()->GetAppRegistrationData(),
1634 kCmdQueryEULAAcceptance));
1627 if (installer_state.operation() == InstallerState::UNINSTALL) { 1635 if (installer_state.operation() == InstallerState::UNINSTALL) {
1628 work_item_list->AddDeleteRegKeyWorkItem(root_key, cmd_key, KEY_WOW64_32KEY) 1636 work_item_list->AddDeleteRegKeyWorkItem(root_key, cmd_key, KEY_WOW64_32KEY)
1629 ->set_log_message("Removing query EULA acceptance command"); 1637 ->set_log_message("Removing query EULA acceptance command");
1630 } else { 1638 } else {
1631 CommandLine cmd_line(installer_state 1639 CommandLine cmd_line(installer_state
1632 .GetInstallerDirectory(new_version) 1640 .GetInstallerDirectory(new_version)
1633 .Append(setup_path.BaseName())); 1641 .Append(setup_path.BaseName()));
1634 cmd_line.AppendSwitch(switches::kQueryEULAAcceptance); 1642 cmd_line.AppendSwitch(switches::kQueryEULAAcceptance);
1635 if (installer_state.system_install()) 1643 if (installer_state.system_install())
1636 cmd_line.AppendSwitch(installer::switches::kSystemLevel); 1644 cmd_line.AppendSwitch(installer::switches::kSystemLevel);
1637 if (installer_state.verbose_logging()) 1645 if (installer_state.verbose_logging())
1638 cmd_line.AppendSwitch(installer::switches::kVerboseLogging); 1646 cmd_line.AppendSwitch(installer::switches::kVerboseLogging);
1639 AppCommand cmd(cmd_line.GetCommandLineString()); 1647 AppCommand cmd(cmd_line.GetCommandLineString());
1640 cmd.set_is_web_accessible(true); 1648 cmd.set_is_web_accessible(true);
1641 cmd.set_is_run_as_user(true); 1649 cmd.set_is_run_as_user(true);
1642 cmd.AddWorkItems(installer_state.root_key(), cmd_key, work_item_list); 1650 cmd.AddWorkItems(installer_state.root_key(), cmd_key, work_item_list);
1643 } 1651 }
1644 } 1652 }
1645 1653
1646 void AddQuickEnableChromeFrameWorkItems(const InstallerState& installer_state, 1654 void AddQuickEnableChromeFrameWorkItems(const InstallerState& installer_state,
1647 WorkItemList* work_item_list) { 1655 WorkItemList* work_item_list) {
1648 DCHECK(work_item_list); 1656 DCHECK(work_item_list);
1649 1657 BrowserDistribution* binaries_dist =
1658 BrowserDistribution::GetSpecificDistribution(
1659 BrowserDistribution::CHROME_BINARIES);
1650 base::string16 cmd_key( 1660 base::string16 cmd_key(
1651 GetRegCommandKey(BrowserDistribution::GetSpecificDistribution( 1661 GetRegCommandKey(binaries_dist->GetAppRegistrationData(),
1652 BrowserDistribution::CHROME_BINARIES),
1653 kCmdQuickEnableCf)); 1662 kCmdQuickEnableCf));
1654 1663
1655 // Unconditionally remove the legacy Quick Enable command from the binaries. 1664 // Unconditionally remove the legacy Quick Enable command from the binaries.
1656 // Do this even if multi-install Chrome isn't installed to ensure that it is 1665 // Do this even if multi-install Chrome isn't installed to ensure that it is
1657 // not left behind in any case. 1666 // not left behind in any case.
1658 work_item_list->AddDeleteRegKeyWorkItem( 1667 work_item_list->AddDeleteRegKeyWorkItem(
1659 installer_state.root_key(), cmd_key, KEY_WOW64_32KEY) 1668 installer_state.root_key(), cmd_key, KEY_WOW64_32KEY)
1660 ->set_log_message("removing " + base::UTF16ToASCII(kCmdQuickEnableCf) + 1669 ->set_log_message("removing " + base::UTF16ToASCII(kCmdQuickEnableCf) +
1661 " command"); 1670 " command");
1662 } 1671 }
1663 1672
1664 } // namespace installer 1673 } // namespace installer
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