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