Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(180)

Side by Side Diff: chrome/installer/util/product.h

Issue 6288009: More installer refactoring in the interest of fixing some bugs and cleaning t... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/installer/util/package_unittest.cc ('k') | chrome/installer/util/product.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_INSTALLER_UTIL_PRODUCT_H_ 5 #ifndef CHROME_INSTALLER_UTIL_PRODUCT_H_
6 #define CHROME_INSTALLER_UTIL_PRODUCT_H_ 6 #define CHROME_INSTALLER_UTIL_PRODUCT_H_
7 #pragma once 7 #pragma once
8 8
9 #include <set>
10 #include <string>
9 #include <vector> 11 #include <vector>
10 12
11 #include "base/ref_counted.h"
12 #include "base/scoped_ptr.h" 13 #include "base/scoped_ptr.h"
13 #include "chrome/installer/util/browser_distribution.h" 14 #include "chrome/installer/util/browser_distribution.h"
14 #include "chrome/installer/util/package.h"
15 15
16 class CommandLine; 16 class CommandLine;
17 17
18 namespace installer { 18 namespace installer {
19
19 class MasterPreferences; 20 class MasterPreferences;
20 }
21
22 namespace installer {
23
24 class Product; 21 class Product;
25 class Package; 22 class ProductOperations;
26 class PackageProperties;
27
28 typedef std::vector<scoped_refptr<Package> > Packages;
29 typedef std::vector<scoped_refptr<const Product> > Products;
30
31 const Product* FindProduct(const Products& products,
32 BrowserDistribution::Type type);
33 23
34 // Represents an installation of a specific product which has a one-to-one 24 // Represents an installation of a specific product which has a one-to-one
35 // relation to a BrowserDistribution. A product has registry settings, related 25 // relation to a BrowserDistribution. A product has registry settings, related
36 // installation/uninstallation actions and exactly one Package that represents 26 // installation/uninstallation actions and exactly one Package that represents
37 // the files on disk. The Package may be shared with other Product instances, 27 // the files on disk. The Package may be shared with other Product instances,
38 // so only the last Product to be uninstalled should remove the package. 28 // so only the last Product to be uninstalled should remove the package.
39 // Right now there are no classes that derive from Product, but in 29 // Right now there are no classes that derive from Product, but in
40 // the future, as we move away from global functions and towards a data driven 30 // the future, as we move away from global functions and towards a data driven
41 // installation, each distribution could derive from this class and provide 31 // installation, each distribution could derive from this class and provide
42 // distribution specific functionality. 32 // distribution specific functionality.
43 class Product : public base::RefCounted<Product> { 33 class Product {
44 public: 34 public:
45 Product(BrowserDistribution* distribution, Package* installation_package); 35 explicit Product(BrowserDistribution* distribution);
36
37 ~Product();
38
39 void InitializeFromPreferences(const MasterPreferences& prefs);
40
41 void InitializeFromUninstallCommand(const CommandLine& uninstall_command);
46 42
47 BrowserDistribution* distribution() const { 43 BrowserDistribution* distribution() const {
48 return distribution_; 44 return distribution_;
49 } 45 }
50 46
51 // Returns the install package object for the installation of this product. 47 bool is_type(BrowserDistribution::Type type) const {
52 // If the product is installed at system level,the function returns a system 48 return distribution_->GetType() == type;
53 // wide location (ProgramFiles\Google). Otherwise it returns a package in a
54 // user specific location (Users\<user>\Local Settings...)
55 const Package& package() const;
56
57 // Convenience getter for package().system_level().
58 bool system_level() const {
59 return package().system_level();
60 } 49 }
61 50
62 bool is_chrome() const { 51 bool is_chrome() const {
63 return distribution_->GetType() == BrowserDistribution::CHROME_BROWSER; 52 return distribution_->GetType() == BrowserDistribution::CHROME_BROWSER;
64 } 53 }
65 54
66 bool is_chrome_frame() const { 55 bool is_chrome_frame() const {
67 return distribution_->GetType() == BrowserDistribution::CHROME_FRAME; 56 return distribution_->GetType() == BrowserDistribution::CHROME_FRAME;
68 } 57 }
69 58
59 bool HasOption(const std::wstring& option) const {
60 return options_.find(option) != options_.end();
61 }
62
63 // Returns true if the set of options is mutated by this operation.
64 bool SetOption(const std::wstring& option, bool set) {
65 if (set)
66 return options_.insert(option).second;
67 else
68 return options_.erase(option) != 0;
69 }
70
70 // Returns the path to the directory that holds the user data. This is always 71 // Returns the path to the directory that holds the user data. This is always
71 // inside "Users\<user>\Local Settings". Note that this is the default user 72 // inside "Users\<user>\Local Settings". Note that this is the default user
72 // data directory and does not take into account that it can be overriden with 73 // data directory and does not take into account that it can be overriden with
73 // a command line parameter. 74 // a command line parameter.
74 FilePath GetUserDataPath() const; 75 FilePath GetUserDataPath() const;
75 76
76 // Launches Chrome without waiting for it to exit. 77 // Launches Chrome without waiting for it to exit.
77 bool LaunchChrome() const; 78 bool LaunchChrome(const FilePath& application_path) const;
78 79
79 // Launches Chrome with given command line, waits for Chrome indefinitely 80 // Launches Chrome with given command line, waits for Chrome indefinitely
80 // (until it terminates), and gets the process exit code if available. 81 // (until it terminates), and gets the process exit code if available.
81 // The function returns true as long as Chrome is successfully launched. 82 // The function returns true as long as Chrome is successfully launched.
82 // The status of Chrome at the return of the function is given by exit_code. 83 // The status of Chrome at the return of the function is given by exit_code.
83 // NOTE: The 'options' CommandLine object should only contain parameters. 84 // NOTE: The 'options' CommandLine object should only contain parameters.
84 // The program part will be ignored. 85 // The program part will be ignored.
85 bool LaunchChromeAndWait(const CommandLine& options, int32* exit_code) const; 86 bool LaunchChromeAndWait(const FilePath& application_path,
86 87 const CommandLine& options,
87 // Returns true if this setup process is running as an install managed by an 88 int32* exit_code) const;
88 // MSI wrapper. There are three things that are checked:
89 // 1) the presence of --msi on the command line
90 // 2) the presence of "msi": true in the master preferences file
91 // 3) the presence of a DWORD value in the ClientState key called msi with
92 // value 1
93 bool IsMsi() const;
94 89
95 // Sets the boolean MSI marker for this installation if set is true or clears 90 // Sets the boolean MSI marker for this installation if set is true or clears
96 // it otherwise. The MSI marker is stored in the registry under the 91 // it otherwise. The MSI marker is stored in the registry under the
97 // ClientState key. 92 // ClientState key.
98 bool SetMsiMarker(bool set) const; 93 bool SetMsiMarker(bool system_install, bool set) const;
99 94
100 // Returns true if setup should create an entry in the Add/Remove list 95 // Returns true if setup should create an entry in the Add/Remove list
101 // of installed applications. 96 // of installed applications.
102 bool ShouldCreateUninstallEntry() const; 97 bool ShouldCreateUninstallEntry() const;
103 98
99 // See ProductOperations::AddKeyFiles.
100 void AddKeyFiles(std::vector<FilePath>* key_files) const;
101
102 // See ProductOperations::AddComDllList.
103 void AddComDllList(std::vector<FilePath>* com_dll_list) const;
104
105 // See ProductOperations::AppendProductFlags.
106 void AppendProductFlags(CommandLine* command_line) const;
107
108 // See Productoperations::SetChannelFlags.
109 bool SetChannelFlags(bool set, ChannelInfo* channel_info) const;
110
104 protected: 111 protected:
105 enum CacheStateFlags { 112 enum CacheStateFlags {
106 MSI_STATE = 0x01 113 MSI_STATE = 0x01
107 }; 114 };
108 115
109 BrowserDistribution* distribution_; 116 BrowserDistribution* distribution_;
110 scoped_refptr<Package> package_; 117 scoped_ptr<ProductOperations> operations_;
111 mutable bool msi_; 118 std::set<std::wstring> options_;
112 mutable uint8 cache_state_;
113 119
114 private: 120 private:
115 friend class base::RefCounted<Product>;
116 ~Product() {
117 }
118 DISALLOW_COPY_AND_ASSIGN(Product); 121 DISALLOW_COPY_AND_ASSIGN(Product);
119 }; 122 };
120 123
121 // A collection of Product objects and related physical installation
122 // packages. Each Product is associated with a single installation
123 // package object, and each package object is associated with one or more
124 // Product objects.
125 class ProductPackageMapping {
126 public:
127 explicit ProductPackageMapping(bool multi_install, bool system_level);
128
129 bool multi_install() const {
130 return multi_install_;
131 }
132
133 bool system_level() const {
134 return system_level_;
135 }
136
137 const Packages& packages() const;
138
139 const Products& products() const;
140
141 bool AddDistribution(BrowserDistribution::Type type,
142 const installer::MasterPreferences& prefs);
143 bool AddDistribution(BrowserDistribution* distribution);
144
145 protected:
146 bool multi_install_;
147 bool system_level_;
148 Packages packages_;
149 Products products_;
150 scoped_ptr<PackageProperties> package_properties_;
151
152 private:
153 DISALLOW_COPY_AND_ASSIGN(ProductPackageMapping);
154 };
155
156 } // namespace installer 124 } // namespace installer
157 125
158 #endif // CHROME_INSTALLER_UTIL_PRODUCT_H_ 126 #endif // CHROME_INSTALLER_UTIL_PRODUCT_H_
OLDNEW
« no previous file with comments | « chrome/installer/util/package_unittest.cc ('k') | chrome/installer/util/product.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698