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