OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 #include "chrome/installer/util/installer_state.h" | 5 #include "chrome/installer/util/installer_state.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <functional> | 8 #include <functional> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "chrome/installer/util/install_util.h" | 23 #include "chrome/installer/util/install_util.h" |
24 #include "chrome/installer/util/installation_state.h" | 24 #include "chrome/installer/util/installation_state.h" |
25 #include "chrome/installer/util/master_preferences.h" | 25 #include "chrome/installer/util/master_preferences.h" |
26 #include "chrome/installer/util/master_preferences_constants.h" | 26 #include "chrome/installer/util/master_preferences_constants.h" |
27 #include "chrome/installer/util/product.h" | 27 #include "chrome/installer/util/product.h" |
28 #include "chrome/installer/util/work_item.h" | 28 #include "chrome/installer/util/work_item.h" |
29 #include "chrome/installer/util/work_item_list.h" | 29 #include "chrome/installer/util/work_item_list.h" |
30 | 30 |
31 namespace installer { | 31 namespace installer { |
32 | 32 |
33 bool InstallerState::IsMultiInstallUpdate(const MasterPreferences& prefs, | 33 bool InstallerState::IsMultiInstallUpdate( |
| 34 const MasterPreferences& prefs, |
34 const InstallationState& machine_state) { | 35 const InstallationState& machine_state) { |
35 // First, is the package present? | 36 // First, are the binaries present? |
36 const ProductState* package = | 37 const ProductState* binaries = |
37 machine_state.GetProductState(level_ == SYSTEM_LEVEL, | 38 machine_state.GetProductState(level_ == SYSTEM_LEVEL, |
38 BrowserDistribution::CHROME_BINARIES); | 39 BrowserDistribution::CHROME_BINARIES); |
39 if (package == NULL) { | 40 if (binaries == NULL) { |
40 // The multi-install package has not been installed, so it certainly isn't | 41 // The multi-install binaries have not been installed, so they certainly |
41 // being updated. | 42 // aren't being updated. |
42 return false; | 43 return false; |
43 } | 44 } |
44 | 45 |
45 BrowserDistribution::Type types[2]; | 46 if (prefs.install_chrome()) { |
46 size_t num_types = 0; | |
47 if (prefs.install_chrome()) | |
48 types[num_types++] = BrowserDistribution::CHROME_BROWSER; | |
49 if (prefs.install_chrome_frame()) | |
50 types[num_types++] = BrowserDistribution::CHROME_FRAME; | |
51 | |
52 for (const BrowserDistribution::Type* scan = &types[0], | |
53 *end = &types[num_types]; scan != end; ++scan) { | |
54 const ProductState* product = | 47 const ProductState* product = |
55 machine_state.GetProductState(level_ == SYSTEM_LEVEL, *scan); | 48 machine_state.GetProductState(level_ == SYSTEM_LEVEL, |
| 49 BrowserDistribution::CHROME_BROWSER); |
56 if (product == NULL) { | 50 if (product == NULL) { |
57 VLOG(2) << "It seems that distribution type " << *scan | 51 VLOG(2) << "It seems that chrome is being installed for the first time."; |
58 << " is being installed for the first time."; | |
59 return false; | 52 return false; |
60 } | 53 } |
61 if (!product->channel().Equals(package->channel())) { | 54 if (!product->channel().Equals(binaries->channel())) { |
62 VLOG(2) << "It seems that distribution type " << *scan | 55 VLOG(2) << "It seems that chrome is being over installed."; |
63 << " is being over installed."; | |
64 return false; | 56 return false; |
65 } | 57 } |
66 } | 58 } |
67 | 59 |
68 VLOG(2) << "It seems that the package is being updated."; | 60 VLOG(2) << "It seems that the binaries are being updated."; |
69 | 61 |
70 return true; | 62 return true; |
71 } | 63 } |
72 | 64 |
73 InstallerState::InstallerState() | 65 InstallerState::InstallerState() |
74 : operation_(UNINITIALIZED), | 66 : operation_(UNINITIALIZED), |
75 state_type_(BrowserDistribution::CHROME_BROWSER), | 67 state_type_(BrowserDistribution::CHROME_BROWSER), |
76 multi_package_distribution_(NULL), | 68 multi_package_distribution_(NULL), |
77 level_(UNKNOWN_LEVEL), | 69 level_(UNKNOWN_LEVEL), |
78 package_type_(UNKNOWN_PACKAGE_TYPE), | 70 package_type_(UNKNOWN_PACKAGE_TYPE), |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 command_line.HasSwitch(installer::switches::kEnsureGoogleUpdatePresent); | 112 command_line.HasSwitch(installer::switches::kEnsureGoogleUpdatePresent); |
121 | 113 |
122 const bool is_uninstall = command_line.HasSwitch(switches::kUninstall); | 114 const bool is_uninstall = command_line.HasSwitch(switches::kUninstall); |
123 | 115 |
124 if (prefs.install_chrome()) { | 116 if (prefs.install_chrome()) { |
125 Product* p = AddProductFromPreferences( | 117 Product* p = AddProductFromPreferences( |
126 BrowserDistribution::CHROME_BROWSER, prefs, machine_state); | 118 BrowserDistribution::CHROME_BROWSER, prefs, machine_state); |
127 VLOG(1) << (is_uninstall ? "Uninstall" : "Install") | 119 VLOG(1) << (is_uninstall ? "Uninstall" : "Install") |
128 << " distribution: " << p->distribution()->GetDisplayName(); | 120 << " distribution: " << p->distribution()->GetDisplayName(); |
129 } | 121 } |
130 if (prefs.install_chrome_frame()) { | |
131 Product* p = AddProductFromPreferences( | |
132 BrowserDistribution::CHROME_FRAME, prefs, machine_state); | |
133 VLOG(1) << (is_uninstall ? "Uninstall" : "Install") | |
134 << " distribution: " << p->distribution()->GetDisplayName(); | |
135 } | |
136 | 122 |
137 if (prefs.install_chrome_app_launcher()) { | 123 if (prefs.install_chrome_app_launcher()) { |
138 Product* p = AddProductFromPreferences( | 124 Product* p = AddProductFromPreferences( |
139 BrowserDistribution::CHROME_APP_HOST, prefs, machine_state); | 125 BrowserDistribution::CHROME_APP_HOST, prefs, machine_state); |
140 VLOG(1) << (is_uninstall ? "Uninstall" : "Install") | 126 VLOG(1) << (is_uninstall ? "Uninstall" : "Install") |
141 << " distribution: " << p->distribution()->GetDisplayName(); | 127 << " distribution: " << p->distribution()->GetDisplayName(); |
142 } | 128 } |
143 | 129 |
144 if (!is_uninstall && is_multi_install()) { | 130 if (!is_uninstall && is_multi_install()) { |
145 bool need_binaries = false; | 131 bool need_binaries = false; |
146 if (FindProduct(BrowserDistribution::CHROME_APP_HOST)) { | 132 if (FindProduct(BrowserDistribution::CHROME_APP_HOST)) { |
147 // App Host will happily use Chrome at system level, or binaries at system | 133 // App Host will happily use Chrome at system level, or binaries at system |
148 // level, even if app host is user level. | 134 // level, even if app host is user level. |
149 const ProductState* chrome_state = machine_state.GetProductState( | 135 const ProductState* chrome_state = machine_state.GetProductState( |
150 true, // system level | 136 true, // system level |
151 BrowserDistribution::CHROME_BROWSER); | 137 BrowserDistribution::CHROME_BROWSER); |
152 // If Chrome is at system-level, multi- or otherwise. We'll use it. | 138 // If Chrome is at system-level, multi- or otherwise. We'll use it. |
153 if (!chrome_state) { | 139 if (!chrome_state) { |
154 const ProductState* binaries_state = machine_state.GetProductState( | 140 const ProductState* binaries_state = machine_state.GetProductState( |
155 true, // system level | 141 true, // system level |
156 BrowserDistribution::CHROME_BINARIES); | 142 BrowserDistribution::CHROME_BINARIES); |
157 if (!binaries_state) | 143 if (!binaries_state) |
158 need_binaries = true; | 144 need_binaries = true; |
159 } | 145 } |
160 } | 146 } |
161 | 147 |
162 // Chrome/Chrome Frame multi need Binaries at their own level. | 148 // Chrome multi needs Binaries at its own level. |
163 if (FindProduct(BrowserDistribution::CHROME_BROWSER)) | 149 if (FindProduct(BrowserDistribution::CHROME_BROWSER)) |
164 need_binaries = true; | 150 need_binaries = true; |
165 | 151 |
166 if (FindProduct(BrowserDistribution::CHROME_FRAME)) | |
167 need_binaries = true; | |
168 | |
169 if (need_binaries && !FindProduct(BrowserDistribution::CHROME_BINARIES)) { | 152 if (need_binaries && !FindProduct(BrowserDistribution::CHROME_BINARIES)) { |
170 // Force binaries to be installed/updated. | 153 // Force binaries to be installed/updated. |
171 Product* p = AddProductFromPreferences( | 154 Product* p = AddProductFromPreferences( |
172 BrowserDistribution::CHROME_BINARIES, prefs, machine_state); | 155 BrowserDistribution::CHROME_BINARIES, prefs, machine_state); |
173 VLOG(1) << "Install distribution: " | 156 VLOG(1) << "Install distribution: " |
174 << p->distribution()->GetDisplayName(); | 157 << p->distribution()->GetDisplayName(); |
175 } | 158 } |
176 } | 159 } |
177 | 160 |
178 if (is_uninstall && prefs.is_multi_install()) { | 161 if (is_uninstall && prefs.is_multi_install()) { |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 operation_ = SINGLE_INSTALL_OR_UPDATE; | 266 operation_ = SINGLE_INSTALL_OR_UPDATE; |
284 } else if (IsMultiInstallUpdate(prefs, machine_state)) { | 267 } else if (IsMultiInstallUpdate(prefs, machine_state)) { |
285 // Updates driven by Google Update take place under the multi-installer's | 268 // Updates driven by Google Update take place under the multi-installer's |
286 // app guid. | 269 // app guid. |
287 operand = multi_package_distribution_; | 270 operand = multi_package_distribution_; |
288 operation_ = MULTI_UPDATE; | 271 operation_ = MULTI_UPDATE; |
289 } else { | 272 } else { |
290 operation_ = MULTI_INSTALL; | 273 operation_ = MULTI_INSTALL; |
291 } | 274 } |
292 | 275 |
293 // Initial, over, and un-installs will take place under one of the | 276 // Initial, over, and un-installs will take place under one of the product app |
294 // product app guids (Chrome, Chrome Frame, App Host, or Binaries, in order of | 277 // guids (Chrome, App Host, or Binaries, in order of preference). |
295 // preference). | |
296 if (operand == NULL) { | 278 if (operand == NULL) { |
297 BrowserDistribution::Type operand_distribution_type = | 279 BrowserDistribution::Type operand_distribution_type = |
298 BrowserDistribution::CHROME_BINARIES; | 280 BrowserDistribution::CHROME_BINARIES; |
299 if (prefs.install_chrome()) | 281 if (prefs.install_chrome()) |
300 operand_distribution_type = BrowserDistribution::CHROME_BROWSER; | 282 operand_distribution_type = BrowserDistribution::CHROME_BROWSER; |
301 else if (prefs.install_chrome_frame()) | |
302 operand_distribution_type = BrowserDistribution::CHROME_FRAME; | |
303 else if (prefs.install_chrome_app_launcher()) | 283 else if (prefs.install_chrome_app_launcher()) |
304 operand_distribution_type = BrowserDistribution::CHROME_APP_HOST; | 284 operand_distribution_type = BrowserDistribution::CHROME_APP_HOST; |
305 | 285 |
306 operand = BrowserDistribution::GetSpecificDistribution( | 286 operand = BrowserDistribution::GetSpecificDistribution( |
307 operand_distribution_type); | 287 operand_distribution_type); |
308 } | 288 } |
309 | 289 |
310 state_key_ = operand->GetStateKey(); | 290 state_key_ = operand->GetStateKey(); |
311 state_type_ = operand->GetType(); | 291 state_type_ = operand->GetType(); |
312 | 292 |
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
843 } | 823 } |
844 if (!install_list->Do()) | 824 if (!install_list->Do()) |
845 LOG(ERROR) << "Failed to record installer error information in registry."; | 825 LOG(ERROR) << "Failed to record installer error information in registry."; |
846 } | 826 } |
847 | 827 |
848 bool InstallerState::RequiresActiveSetup() const { | 828 bool InstallerState::RequiresActiveSetup() const { |
849 return system_install() && FindProduct(BrowserDistribution::CHROME_BROWSER); | 829 return system_install() && FindProduct(BrowserDistribution::CHROME_BROWSER); |
850 } | 830 } |
851 | 831 |
852 } // namespace installer | 832 } // namespace installer |
OLD | NEW |