Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / installer / util / product.h
blobe8101391989fe60cb93659dc643fbd126bfded91
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.
5 #ifndef CHROME_INSTALLER_UTIL_PRODUCT_H_
6 #define CHROME_INSTALLER_UTIL_PRODUCT_H_
8 #include <set>
9 #include <string>
10 #include <vector>
12 #include "base/memory/scoped_ptr.h"
13 #include "chrome/installer/util/browser_distribution.h"
14 #include "chrome/installer/util/shell_util.h"
15 #include "chrome/installer/util/util_constants.h"
17 namespace base {
18 class CommandLine;
21 namespace installer {
23 class ChannelInfo;
24 class MasterPreferences;
25 class Product;
26 class ProductOperations;
28 // Represents an installation of a specific product which has a one-to-one
29 // relation to a BrowserDistribution. A product has registry settings, related
30 // installation/uninstallation actions and exactly one Package that represents
31 // the files on disk. The Package may be shared with other Product instances,
32 // so only the last Product to be uninstalled should remove the package.
33 // Right now there are no classes that derive from Product, but in
34 // the future, as we move away from global functions and towards a data driven
35 // installation, each distribution could derive from this class and provide
36 // distribution specific functionality.
37 class Product {
38 public:
39 explicit Product(BrowserDistribution* distribution);
41 ~Product();
43 void InitializeFromPreferences(const MasterPreferences& prefs);
45 void InitializeFromUninstallCommand(
46 const base::CommandLine& uninstall_command);
48 BrowserDistribution* distribution() const {
49 return distribution_;
52 bool is_type(BrowserDistribution::Type type) const {
53 return distribution_->GetType() == type;
56 bool is_chrome() const {
57 return distribution_->GetType() == BrowserDistribution::CHROME_BROWSER;
60 bool is_chrome_frame() const {
61 return distribution_->GetType() == BrowserDistribution::CHROME_FRAME;
64 bool is_chrome_binaries() const {
65 return distribution_->GetType() == BrowserDistribution::CHROME_BINARIES;
68 bool HasOption(const std::wstring& option) const {
69 return options_.find(option) != options_.end();
72 // Returns true if the set of options is mutated by this operation.
73 bool SetOption(const std::wstring& option, bool set) {
74 if (set)
75 return options_.insert(option).second;
76 else
77 return options_.erase(option) != 0;
80 // Launches Chrome without waiting for it to exit.
81 bool LaunchChrome(const base::FilePath& application_path) const;
83 // Launches Chrome with given command line, waits for Chrome indefinitely
84 // (until it terminates), and gets the process exit code if available.
85 // The function returns true as long as Chrome is successfully launched.
86 // The status of Chrome at the return of the function is given by exit_code.
87 // NOTE: The 'options' CommandLine object should only contain parameters.
88 // The program part will be ignored.
89 bool LaunchChromeAndWait(const base::FilePath& application_path,
90 const base::CommandLine& options,
91 int32* exit_code) const;
93 // Sets the boolean MSI marker for this installation if set is true or clears
94 // it otherwise. The MSI marker is stored in the registry under the
95 // ClientState key.
96 bool SetMsiMarker(bool system_install, bool set) const;
98 // Returns true if setup should create an entry in the Add/Remove list
99 // of installed applications.
100 bool ShouldCreateUninstallEntry() const;
102 // See ProductOperations::AddKeyFiles.
103 void AddKeyFiles(std::vector<base::FilePath>* key_files) const;
105 // See ProductOperations::AddComDllList.
106 void AddComDllList(std::vector<base::FilePath>* com_dll_list) const;
108 // See ProductOperations::AppendProductFlags.
109 void AppendProductFlags(base::CommandLine* command_line) const;
111 // See ProductOperations::AppendRenameFlags.
112 void AppendRenameFlags(base::CommandLine* command_line) const;
114 // See Productoperations::SetChannelFlags.
115 bool SetChannelFlags(bool set, ChannelInfo* channel_info) const;
117 // See ProductOperations::AddDefaultShortcutProperties.
118 void AddDefaultShortcutProperties(
119 const base::FilePath& target_exe,
120 ShellUtil::ShortcutProperties* properties) const;
122 void LaunchUserExperiment(const base::FilePath& setup_path,
123 InstallStatus status,
124 bool system_level) const;
126 protected:
127 enum CacheStateFlags {
128 MSI_STATE = 0x01
131 BrowserDistribution* distribution_;
132 scoped_ptr<ProductOperations> operations_;
133 std::set<std::wstring> options_;
135 private:
136 DISALLOW_COPY_AND_ASSIGN(Product);
139 } // namespace installer
141 #endif // CHROME_INSTALLER_UTIL_PRODUCT_H_