Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / installer / util / product.h
blob9ff763b9b0e6f383d834a3915b6325816e4f4d0e
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 class CommandLine;
19 namespace installer {
21 class ChannelInfo;
22 class MasterPreferences;
23 class Product;
24 class ProductOperations;
26 // Represents an installation of a specific product which has a one-to-one
27 // relation to a BrowserDistribution. A product has registry settings, related
28 // installation/uninstallation actions and exactly one Package that represents
29 // the files on disk. The Package may be shared with other Product instances,
30 // so only the last Product to be uninstalled should remove the package.
31 // Right now there are no classes that derive from Product, but in
32 // the future, as we move away from global functions and towards a data driven
33 // installation, each distribution could derive from this class and provide
34 // distribution specific functionality.
35 class Product {
36 public:
37 explicit Product(BrowserDistribution* distribution);
39 ~Product();
41 void InitializeFromPreferences(const MasterPreferences& prefs);
43 void InitializeFromUninstallCommand(const CommandLine& uninstall_command);
45 BrowserDistribution* distribution() const {
46 return distribution_;
49 bool is_type(BrowserDistribution::Type type) const {
50 return distribution_->GetType() == type;
53 bool is_chrome() const {
54 return distribution_->GetType() == BrowserDistribution::CHROME_BROWSER;
57 bool is_chrome_frame() const {
58 return distribution_->GetType() == BrowserDistribution::CHROME_FRAME;
61 bool is_chrome_app_host() const {
62 return distribution_->GetType() == BrowserDistribution::CHROME_APP_HOST;
65 bool is_chrome_binaries() const {
66 return distribution_->GetType() == BrowserDistribution::CHROME_BINARIES;
69 bool HasOption(const std::wstring& option) const {
70 return options_.find(option) != options_.end();
73 // Returns true if the set of options is mutated by this operation.
74 bool SetOption(const std::wstring& option, bool set) {
75 if (set)
76 return options_.insert(option).second;
77 else
78 return options_.erase(option) != 0;
81 // Returns the path(s) to the directory that holds the user data (primary
82 // and, if applicable to |dist|, alternate). This is always inside a user's
83 // local application data folder (e.g., "AppData\Local or "Local
84 // Settings\Application Data" in %USERPROFILE%). Note that these are the
85 // defaults and do not take into account that they can be overriden with a
86 // command line parameter. |paths| may be empty on return, but is guaranteed
87 // not to contain empty paths otherwise. If more than one path is returned,
88 // they are guaranteed to be siblings.
89 void GetUserDataPaths(std::vector<base::FilePath>* paths) const;
91 // Launches Chrome without waiting for it to exit.
92 bool LaunchChrome(const base::FilePath& application_path) const;
94 // Launches Chrome with given command line, waits for Chrome indefinitely
95 // (until it terminates), and gets the process exit code if available.
96 // The function returns true as long as Chrome is successfully launched.
97 // The status of Chrome at the return of the function is given by exit_code.
98 // NOTE: The 'options' CommandLine object should only contain parameters.
99 // The program part will be ignored.
100 bool LaunchChromeAndWait(const base::FilePath& application_path,
101 const CommandLine& options,
102 int32* exit_code) const;
104 // Sets the boolean MSI marker for this installation if set is true or clears
105 // it otherwise. The MSI marker is stored in the registry under the
106 // ClientState key.
107 bool SetMsiMarker(bool system_install, bool set) const;
109 // Returns true if setup should create an entry in the Add/Remove list
110 // of installed applications.
111 bool ShouldCreateUninstallEntry() const;
113 // See ProductOperations::AddKeyFiles.
114 void AddKeyFiles(std::vector<base::FilePath>* key_files) const;
116 // See ProductOperations::AddComDllList.
117 void AddComDllList(std::vector<base::FilePath>* com_dll_list) const;
119 // See ProductOperations::AppendProductFlags.
120 void AppendProductFlags(CommandLine* command_line) const;
122 // See ProductOperations::AppendRenameFlags.
123 void AppendRenameFlags(CommandLine* command_line) const;
125 // See Productoperations::SetChannelFlags.
126 bool SetChannelFlags(bool set, ChannelInfo* channel_info) const;
128 // See ProductOperations::AddDefaultShortcutProperties.
129 void AddDefaultShortcutProperties(
130 const base::FilePath& target_exe,
131 ShellUtil::ShortcutProperties* properties) const;
133 void LaunchUserExperiment(const base::FilePath& setup_path,
134 InstallStatus status,
135 bool system_level) const;
137 protected:
138 enum CacheStateFlags {
139 MSI_STATE = 0x01
142 BrowserDistribution* distribution_;
143 scoped_ptr<ProductOperations> operations_;
144 std::set<std::wstring> options_;
146 private:
147 DISALLOW_COPY_AND_ASSIGN(Product);
150 } // namespace installer
152 #endif // CHROME_INSTALLER_UTIL_PRODUCT_H_