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
3// found in the LICENSE file.
4//
5// This file contains the declarations of the installer functions that build
6// the WorkItemList used to install the application.
7
8#ifndef CHROME_INSTALLER_SETUP_INSTALL_WORKER_H_
9#define CHROME_INSTALLER_SETUP_INSTALL_WORKER_H_
10
11#include <windows.h>
12
13#include <vector>
14
15#include "base/strings/string16.h"
16
17class BrowserDistribution;
18class WorkItemList;
19
20namespace base {
21class CommandLine;
22class FilePath;
23class Version;
24}
25
26namespace installer {
27
28class InstallationState;
29class InstallerState;
30class Product;
31
32// This method adds work items to create (or update) Chrome uninstall entry in
33// either the Control Panel->Add/Remove Programs list or in the Omaha client
34// state key if running under an MSI installer.
35void AddUninstallShortcutWorkItems(const InstallerState& installer_state,
36                                   const base::FilePath& setup_path,
37                                   const base::Version& new_version,
38                                   const Product& product,
39                                   WorkItemList* install_list);
40
41// Creates Version key for a product (if not already present) and sets the new
42// product version as the last step.  If |add_language_identifier| is true, the
43// "lang" value is also set according to the currently selected translation.
44void AddVersionKeyWorkItems(HKEY root,
45                            const base::string16& version_key,
46                            const base::string16& product_name,
47                            const base::Version& new_version,
48                            bool add_language_identifier,
49                            WorkItemList* list);
50
51// Helper function for AddGoogleUpdateWorkItems that mirrors oeminstall.
52void AddOemInstallWorkItems(const InstallationState& original_state,
53                            const InstallerState& installer_state,
54                            WorkItemList* install_list);
55
56// Helper function for AddGoogleUpdateWorkItems that mirrors eulaaccepted.
57void AddEulaAcceptedWorkItems(const InstallationState& original_state,
58                              const InstallerState& installer_state,
59                              WorkItemList* install_list);
60
61// Adds work items that make registry adjustments for Google Update; namely,
62// copy brand, oeminstall, and eulaaccepted values; and move a usagestats value.
63void AddGoogleUpdateWorkItems(const InstallationState& original_state,
64                              const InstallerState& installer_state,
65                              WorkItemList* install_list);
66
67// Adds work items that make registry adjustments for stats and crash
68// collection.  When a product is installed, Google Update may write a
69// "usagestats" value to Chrome or Chrome Frame's ClientState key.  In the
70// multi-install case, both products will consult/modify stats for the binaries'
71// app guid.  Consequently, during install and update we will move a
72// product-specific value into the binaries' ClientState key.
73void AddUsageStatsWorkItems(const InstallationState& original_state,
74                            const InstallerState& installer_state,
75                            WorkItemList* install_list);
76
77// After a successful copying of all the files, this function is called to
78// do a few post install tasks:
79// - Handle the case of in-use-update by updating "opv" (old version) key or
80//   deleting it if not required.
81// - Register any new dlls and unregister old dlls.
82// - If this is an MSI install, ensures that the MSI marker is set, and sets
83//   it if not.
84// If these operations are successful, the function returns true, otherwise
85// false.
86// |current_version| can be NULL to indicate no Chrome is currently installed.
87bool AppendPostInstallTasks(const InstallerState& installer_state,
88                            const base::FilePath& setup_path,
89                            const base::Version* current_version,
90                            const base::Version& new_version,
91                            const base::FilePath& temp_path,
92                            WorkItemList* post_install_task_list);
93
94// Builds the complete WorkItemList used to build the set of installation steps
95// needed to lay down one or more installed products.
96//
97// setup_path: Path to the executable (setup.exe) as it will be copied
98//           to Chrome install folder after install is complete
99// archive_path: Path to the archive (chrome.7z) as it will be copied
100//               to Chrome install folder after install is complete
101// src_path: the path that contains a complete and unpacked Chrome package
102//           to be installed.
103// temp_path: the path of working directory used during installation. This path
104//            does not need to exist.
105// |current_version| can be NULL to indicate no Chrome is currently installed.
106void AddInstallWorkItems(const InstallationState& original_state,
107                         const InstallerState& installer_state,
108                         const base::FilePath& setup_path,
109                         const base::FilePath& archive_path,
110                         const base::FilePath& src_path,
111                         const base::FilePath& temp_path,
112                         const base::Version* current_version,
113                         const base::Version& new_version,
114                         WorkItemList* install_list);
115
116// Appends registration or unregistration work items to |work_item_list| for the
117// COM DLLs whose file names are given in |dll_files| and which reside in the
118// path |dll_folder|.
119// |system_level| specifies whether to call the system or user level DLL
120// registration entry points.
121// |do_register| says whether to register or unregister.
122// |may_fail| states whether this is best effort or not. If |may_fail| is true
123// then |work_item_list| will still succeed if the registration fails and
124// no registration rollback will be performed.
125void AddRegisterComDllWorkItems(const base::FilePath& dll_folder,
126                                const std::vector<base::FilePath>& dll_files,
127                                bool system_level,
128                                bool do_register,
129                                bool ignore_failures,
130                                WorkItemList* work_item_list);
131
132void AddSetMsiMarkerWorkItem(const InstallerState& installer_state,
133                             BrowserDistribution* dist,
134                             bool set,
135                             WorkItemList* work_item_list);
136
137// Called for either installation or uninstallation. This method adds or
138// removes COM registration for a product's DelegateExecute verb handler.
139// If |new_version| is empty, the registrations will point to
140// delegate_execute.exe directly in |target_path|.
141void AddDelegateExecuteWorkItems(const InstallerState& installer_state,
142                                 const base::FilePath& target_path,
143                                 const base::Version& new_version,
144                                 const Product& product,
145                                 WorkItemList* list);
146
147// Adds Active Setup registration for sytem-level setup to be called by Windows
148// on user-login post-install/update.
149// This method should be called for installation only.
150// |product|: The product being installed. This method is a no-op if this is
151// anything other than system-level Chrome/Chromium.
152void AddActiveSetupWorkItems(const InstallerState& installer_state,
153                             const base::FilePath& setup_path,
154                             const base::Version& new_version,
155                             const Product& product,
156                             WorkItemList* list);
157
158// Unregisters the "opv" version of ChromeLauncher from IE's low rights
159// elevation policy.
160void AddDeleteOldIELowRightsPolicyWorkItems(
161    const InstallerState& installer_state,
162    WorkItemList* install_list);
163
164// Utility method currently shared between install.cc and install_worker.cc
165void AppendUninstallCommandLineFlags(const InstallerState& installer_state,
166                                     const Product& product,
167                                     base::CommandLine* uninstall_cmd);
168
169// Refreshes the elevation policy on platforms where it is supported.
170void RefreshElevationPolicy();
171
172// Adds work items to add or remove the "on-os-upgrade" command to |product|'s
173// version key on the basis of the current operation (represented in
174// |installer_state|).  |new_version| is the version of the product(s)
175// currently being installed -- can be empty on uninstall.
176void AddOsUpgradeWorkItems(const InstallerState& installer_state,
177                           const base::FilePath& setup_path,
178                           const base::Version& new_version,
179                           const Product& product,
180                           WorkItemList* install_list);
181
182// Adds work items to add or remove the "query-eula-acceptance" command to
183// |product|'s version key on the basis of the current operation (represented
184// in |installer_state|).  |new_version| is the version of the product(s)
185// currently being installed -- can be empty on uninstall.
186void AddQueryEULAAcceptanceWorkItems(const InstallerState& installer_state,
187                                     const base::FilePath& setup_path,
188                                     const base::Version& new_version,
189                                     const Product& product,
190                                     WorkItemList* work_item_list);
191
192// Adds work items to remove "quick-enable-cf" from the multi-installer
193// binaries' version key.
194void AddQuickEnableChromeFrameWorkItems(const InstallerState& installer_state,
195                                        WorkItemList* work_item_list);
196
197}  // namespace installer
198
199#endif  // CHROME_INSTALLER_SETUP_INSTALL_WORKER_H_
200