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 #ifndef CHROME_INSTALLER_UTIL_PRODUCT_OPERATIONS_H_ 6 #define CHROME_INSTALLER_UTIL_PRODUCT_OPERATIONS_H_ 7 8 #include <set> 9 #include <string> 10 #include <vector> 11 12 #include "base/files/file_path.h" 13 #include "base/strings/string16.h" 14 #include "chrome/installer/util/shell_util.h" 15 #include "chrome/installer/util/util_constants.h" 16 17 class BrowserDistribution; 18 19 namespace base { 20 class CommandLine; 21 } 22 23 namespace installer { 24 25 class ChannelInfo; 26 class MasterPreferences; 27 28 // An interface to product-specific operations that depend on product 29 // configuration. Implementations are expected to be stateless. Configuration 30 // can be read from a MasterPreferences instance or from a product's uninstall 31 // command. 32 class ProductOperations { 33 public: ~ProductOperations()34 virtual ~ProductOperations() {} 35 36 // Reads product-specific options from |prefs|, adding them to |options|. 37 virtual void ReadOptions(const MasterPreferences& prefs, 38 std::set<base::string16>* options) const = 0; 39 40 // Reads product-specific options from |command|, adding them to |options|. 41 virtual void ReadOptions(const base::CommandLine& command, 42 std::set<base::string16>* options) const = 0; 43 44 // A key-file is a file such as a DLL on Windows that is expected to be in use 45 // when the product is being used. For example "chrome.dll" for Chrome. 46 // Before attempting to delete an installation directory during an 47 // uninstallation, the uninstaller will check if any one of a potential set of 48 // key files is in use and if they are, abort the delete operation. Only if 49 // none of the key files are in use, can the folder be deleted. Note that 50 // this function does not return a full path to the key file(s), only (a) file 51 // name(s). 52 virtual void AddKeyFiles(const std::set<base::string16>& options, 53 std::vector<base::FilePath>* key_files) const = 0; 54 55 // Adds to |com_dll_list| the list of COM DLLs that are to be registered 56 // and/or unregistered. The list may be empty. 57 virtual void AddComDllList( 58 const std::set<base::string16>& options, 59 std::vector<base::FilePath>* com_dll_list) const = 0; 60 61 // Given a command line, appends the set of product-specific flags. These are 62 // required for product-specific uninstall commands, but are of use for any 63 // invocation of setup.exe for the product. 64 virtual void AppendProductFlags(const std::set<base::string16>& options, 65 base::CommandLine* cmd_line) const = 0; 66 67 // Given a command line, appends the set of product-specific rename flags. 68 virtual void AppendRenameFlags(const std::set<base::string16>& options, 69 base::CommandLine* cmd_line) const = 0; 70 71 // Adds or removes product-specific flags in |channel_info|. Returns true if 72 // |channel_info| is modified. 73 virtual bool SetChannelFlags(const std::set<base::string16>& options, 74 bool set, 75 ChannelInfo* channel_info) const = 0; 76 77 // Returns true if setup should create an entry in the Add/Remove list 78 // of installed applications for this product. This does not test for use of 79 // MSI; see InstallerState::is_msi. 80 virtual bool ShouldCreateUninstallEntry( 81 const std::set<base::string16>& options) const = 0; 82 83 // Modifies a ShellUtil::ShortcutProperties object by assigning default values 84 // to unintialized members. 85 virtual void AddDefaultShortcutProperties( 86 BrowserDistribution* dist, 87 const base::FilePath& target_exe, 88 ShellUtil::ShortcutProperties* properties) const = 0; 89 90 // After an install or upgrade the user might qualify to participate in an 91 // experiment. This function determines if the user qualifies and if so it 92 // sets the wheels in motion or in simple cases does the experiment itself. 93 virtual void LaunchUserExperiment(const base::FilePath& setup_path, 94 const std::set<base::string16>& options, 95 InstallStatus status, 96 bool system_level) const = 0; 97 }; 98 99 } // namespace installer 100 101 #endif // CHROME_INSTALLER_UTIL_PRODUCT_OPERATIONS_H_ 102