OLD | NEW |
1 // Copyright (c) 2011 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 // Implementation of the installation validator. | 5 // Implementation of the installation validator. |
6 | 6 |
7 #include "chrome/installer/util/installation_validator.h" | 7 #include "chrome/installer/util/installation_validator.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <set> | 10 #include <set> |
11 | 11 |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/version.h" | 13 #include "base/version.h" |
| 14 #include "chrome/common/chrome_switches.h" |
14 #include "chrome/installer/util/browser_distribution.h" | 15 #include "chrome/installer/util/browser_distribution.h" |
15 #include "chrome/installer/util/helper.h" | 16 #include "chrome/installer/util/helper.h" |
16 #include "chrome/installer/util/installation_state.h" | 17 #include "chrome/installer/util/installation_state.h" |
17 | 18 |
18 namespace installer { | 19 namespace installer { |
19 | 20 |
20 BrowserDistribution::Type | 21 BrowserDistribution::Type |
21 InstallationValidator::ChromeRules::distribution_type() const { | 22 InstallationValidator::ChromeRules::distribution_type() const { |
22 return BrowserDistribution::CHROME_BROWSER; | 23 return BrowserDistribution::CHROME_BROWSER; |
23 } | 24 } |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 } | 106 } |
106 | 107 |
107 bool InstallationValidator::ChromeFrameRules::UsageStatsAllowed( | 108 bool InstallationValidator::ChromeFrameRules::UsageStatsAllowed( |
108 const ProductState& product_state) const { | 109 const ProductState& product_state) const { |
109 // Products must not have usagestats consent values when multi-install | 110 // Products must not have usagestats consent values when multi-install |
110 // (only the multi-install binaries may). | 111 // (only the multi-install binaries may). |
111 return !product_state.is_multi_install(); | 112 return !product_state.is_multi_install(); |
112 } | 113 } |
113 | 114 |
114 BrowserDistribution::Type | 115 BrowserDistribution::Type |
| 116 InstallationValidator::ChromeAppHostRules::distribution_type() const { |
| 117 return BrowserDistribution::CHROME_APP_HOST; |
| 118 } |
| 119 |
| 120 void InstallationValidator::ChromeAppHostRules::AddUninstallSwitchExpectations( |
| 121 const InstallationState& machine_state, |
| 122 bool system_install, |
| 123 const ProductState& product_state, |
| 124 SwitchExpectations* expectations) const { |
| 125 DCHECK(!system_install); |
| 126 |
| 127 // --chrome-app-host must be present. |
| 128 expectations->push_back(std::make_pair(std::string(switches::kChromeAppHost), |
| 129 true)); |
| 130 // --chrome must not be present. |
| 131 expectations->push_back(std::make_pair(std::string(switches::kChrome), |
| 132 false)); |
| 133 |
| 134 // --chrome-frame must not be present. |
| 135 expectations->push_back(std::make_pair(std::string(switches::kChromeFrame), |
| 136 false)); |
| 137 } |
| 138 |
| 139 void InstallationValidator::ChromeAppHostRules::AddRenameSwitchExpectations( |
| 140 const InstallationState& machine_state, |
| 141 bool system_install, |
| 142 const ProductState& product_state, |
| 143 SwitchExpectations* expectations) const { |
| 144 // TODO(erikwright): I guess there will be none? |
| 145 } |
| 146 |
| 147 bool InstallationValidator::ChromeAppHostRules::UsageStatsAllowed( |
| 148 const ProductState& product_state) const { |
| 149 // App Host doesn't manage usage stats. The Chrome Binaries will. |
| 150 return false; |
| 151 } |
| 152 |
| 153 BrowserDistribution::Type |
115 InstallationValidator::ChromeBinariesRules::distribution_type() const { | 154 InstallationValidator::ChromeBinariesRules::distribution_type() const { |
116 return BrowserDistribution::CHROME_BINARIES; | 155 return BrowserDistribution::CHROME_BINARIES; |
117 } | 156 } |
118 | 157 |
119 void InstallationValidator::ChromeBinariesRules::AddUninstallSwitchExpectations( | 158 void InstallationValidator::ChromeBinariesRules::AddUninstallSwitchExpectations( |
120 const InstallationState& machine_state, | 159 const InstallationState& machine_state, |
121 bool system_install, | 160 bool system_install, |
122 const ProductState& product_state, | 161 const ProductState& product_state, |
123 SwitchExpectations* expectations) const { | 162 SwitchExpectations* expectations) const { |
124 NOTREACHED(); | 163 NOTREACHED(); |
(...skipping 17 matching lines...) Expand all Loading... |
142 const InstallationValidator::InstallationType | 181 const InstallationValidator::InstallationType |
143 InstallationValidator::kInstallationTypes[] = { | 182 InstallationValidator::kInstallationTypes[] = { |
144 NO_PRODUCTS, | 183 NO_PRODUCTS, |
145 CHROME_SINGLE, | 184 CHROME_SINGLE, |
146 CHROME_MULTI, | 185 CHROME_MULTI, |
147 CHROME_FRAME_SINGLE, | 186 CHROME_FRAME_SINGLE, |
148 CHROME_FRAME_SINGLE_CHROME_SINGLE, | 187 CHROME_FRAME_SINGLE_CHROME_SINGLE, |
149 CHROME_FRAME_SINGLE_CHROME_MULTI, | 188 CHROME_FRAME_SINGLE_CHROME_MULTI, |
150 CHROME_FRAME_MULTI, | 189 CHROME_FRAME_MULTI, |
151 CHROME_FRAME_MULTI_CHROME_MULTI, | 190 CHROME_FRAME_MULTI_CHROME_MULTI, |
152 CHROME_FRAME_READY_MODE_CHROME_MULTI | 191 CHROME_FRAME_READY_MODE_CHROME_MULTI, |
| 192 CHROME_APP_HOST, |
| 193 CHROME_APP_HOST_CHROME_FRAME_SINGLE, |
| 194 CHROME_APP_HOST_CHROME_FRAME_SINGLE_CHROME_MULTI, |
| 195 CHROME_APP_HOST_CHROME_FRAME_MULTI, |
| 196 CHROME_APP_HOST_CHROME_FRAME_MULTI_CHROME_MULTI, |
| 197 CHROME_APP_HOST_CHROME_MULTI, |
| 198 CHROME_APP_HOST_CHROME_MULTI_CHROME_FRAME_READY_MODE, |
153 }; | 199 }; |
154 | 200 |
| 201 // Validates the "install-application" Google Update product command. |
| 202 void InstallationValidator::ValidateInstallAppCommand( |
| 203 const ProductContext& ctx, |
| 204 const AppCommand& command, |
| 205 bool* is_valid) { |
| 206 DCHECK(is_valid); |
| 207 |
| 208 CommandLine the_command(CommandLine::FromString(command.command_line())); |
| 209 |
| 210 FilePath expected_path( |
| 211 installer::GetChromeInstallPath(ctx.system_install, ctx.dist) |
| 212 .Append(installer::kChromeAppHostExe)); |
| 213 |
| 214 if (!FilePath::CompareEqualIgnoreCase(expected_path.value(), |
| 215 the_command.GetProgram().value())) { |
| 216 *is_valid = false; |
| 217 LOG(ERROR) << "install-application command's path is not " |
| 218 << expected_path.value() << ": " |
| 219 << the_command.GetProgram().value(); |
| 220 } |
| 221 |
| 222 |
| 223 SwitchExpectations expected; |
| 224 |
| 225 expected.push_back( |
| 226 std::make_pair(std::string(::switches::kAppsInstallFromManifestURL), |
| 227 true)); |
| 228 |
| 229 ValidateCommandExpectations(ctx, the_command, expected, "install application", |
| 230 is_valid); |
| 231 |
| 232 if (!command.sends_pings()) { |
| 233 *is_valid = false; |
| 234 LOG(ERROR) << "install-application command is not configured to send " |
| 235 << "pings."; |
| 236 } |
| 237 |
| 238 if (!command.is_web_accessible()) { |
| 239 *is_valid = false; |
| 240 LOG(ERROR) << "install-application command is not web accessible."; |
| 241 } |
| 242 } |
| 243 |
155 // Validates the "quick-enable-cf" Google Update product command. | 244 // Validates the "quick-enable-cf" Google Update product command. |
156 void InstallationValidator::ValidateQuickEnableCfCommand( | 245 void InstallationValidator::ValidateQuickEnableCfCommand( |
157 const ProductContext& ctx, | 246 const ProductContext& ctx, |
158 const AppCommand& command, | 247 const AppCommand& command, |
159 bool* is_valid) { | 248 bool* is_valid) { |
160 DCHECK(is_valid); | 249 DCHECK(is_valid); |
161 | 250 |
162 CommandLine the_command(CommandLine::FromString(command.command_line())); | 251 CommandLine the_command(CommandLine::FromString(command.command_line())); |
163 | 252 |
164 ValidateSetupPath(ctx, the_command.GetProgram(), "quick enable cf", is_valid); | 253 ValidateSetupPath(ctx, the_command.GetProgram(), "quick enable cf", is_valid); |
(...skipping 14 matching lines...) Expand all Loading... |
179 *is_valid = false; | 268 *is_valid = false; |
180 LOG(ERROR) << "Quick-enable-cf command is not configured to send pings."; | 269 LOG(ERROR) << "Quick-enable-cf command is not configured to send pings."; |
181 } | 270 } |
182 | 271 |
183 if (!command.is_web_accessible()) { | 272 if (!command.is_web_accessible()) { |
184 *is_valid = false; | 273 *is_valid = false; |
185 LOG(ERROR) << "Quick-enable-cf command is not web accessible."; | 274 LOG(ERROR) << "Quick-enable-cf command is not web accessible."; |
186 } | 275 } |
187 } | 276 } |
188 | 277 |
| 278 // Validates the "quick-enable-application-host" Google Update product command. |
| 279 void InstallationValidator::ValidateQuickEnableApplicationHostCommand( |
| 280 const ProductContext& ctx, |
| 281 const AppCommand& command, |
| 282 bool* is_valid) { |
| 283 DCHECK(is_valid); |
| 284 |
| 285 CommandLine the_command(CommandLine::FromString(command.command_line())); |
| 286 |
| 287 ValidateSetupPath(ctx, |
| 288 the_command.GetProgram(), |
| 289 "quick enable application host", |
| 290 is_valid); |
| 291 |
| 292 SwitchExpectations expected; |
| 293 |
| 294 expected.push_back( |
| 295 std::make_pair(std::string(switches::kChromeAppHost), true)); |
| 296 expected.push_back(std::make_pair(std::string(switches::kSystemLevel), |
| 297 false)); |
| 298 expected.push_back(std::make_pair(std::string(switches::kMultiInstall), |
| 299 true)); |
| 300 |
| 301 ValidateCommandExpectations(ctx, |
| 302 the_command, |
| 303 expected, |
| 304 "quick enable application host", |
| 305 is_valid); |
| 306 |
| 307 if (!command.sends_pings()) { |
| 308 *is_valid = false; |
| 309 LOG(ERROR) << "Quick-enable-application-host command is not configured to " |
| 310 << "send pings."; |
| 311 } |
| 312 |
| 313 if (!command.is_web_accessible()) { |
| 314 *is_valid = false; |
| 315 LOG(ERROR) << "Quick-enable-application-host command is not web " |
| 316 << "accessible."; |
| 317 } |
| 318 } |
| 319 |
189 // Validates a product's set of Google Update product commands against a | 320 // Validates a product's set of Google Update product commands against a |
190 // collection of expectations. | 321 // collection of expectations. |
191 void InstallationValidator::ValidateAppCommandExpectations( | 322 void InstallationValidator::ValidateAppCommandExpectations( |
192 const ProductContext& ctx, | 323 const ProductContext& ctx, |
193 const CommandExpectations& expectations, | 324 const CommandExpectations& expectations, |
194 bool* is_valid) { | 325 bool* is_valid) { |
195 DCHECK(is_valid); | 326 DCHECK(is_valid); |
196 | 327 |
197 CommandExpectations the_expectations(expectations); | 328 CommandExpectations the_expectations(expectations); |
198 | 329 |
(...skipping 26 matching lines...) Expand all Loading... |
225 << scan->first << "\"."; | 356 << scan->first << "\"."; |
226 } | 357 } |
227 } | 358 } |
228 | 359 |
229 // Validates the multi-install binaries' Google Update commands. | 360 // Validates the multi-install binaries' Google Update commands. |
230 void InstallationValidator::ValidateBinariesCommands( | 361 void InstallationValidator::ValidateBinariesCommands( |
231 const ProductContext& ctx, | 362 const ProductContext& ctx, |
232 bool* is_valid) { | 363 bool* is_valid) { |
233 DCHECK(is_valid); | 364 DCHECK(is_valid); |
234 | 365 |
235 // The quick-enable-cf command must be present if Chrome is installed either | 366 // The quick-enable-cf command must be present if Chrome Binaries are |
236 // alone or with CF in ready-mode. | 367 // installed and Chrome Frame is not installed (or installed in ready mode). |
237 const ChannelInfo& channel = ctx.state.channel(); | 368 const ChannelInfo& channel = ctx.state.channel(); |
238 const ProductState* chrome_state = ctx.machine_state.GetProductState( | 369 const ProductState* binaries_state = ctx.machine_state.GetProductState( |
239 ctx.system_install, BrowserDistribution::CHROME_BROWSER); | 370 ctx.system_install, BrowserDistribution::CHROME_BINARIES); |
240 const ProductState* cf_state = ctx.machine_state.GetProductState( | 371 const ProductState* cf_state = ctx.machine_state.GetProductState( |
241 ctx.system_install, BrowserDistribution::CHROME_FRAME); | 372 ctx.system_install, BrowserDistribution::CHROME_FRAME); |
242 | 373 |
243 CommandExpectations expectations; | 374 CommandExpectations expectations; |
244 | 375 |
245 if (chrome_state != NULL && (cf_state == NULL || channel.IsReadyMode())) | 376 if (binaries_state != NULL) { |
246 expectations[kCmdQuickEnableCf] = &ValidateQuickEnableCfCommand; | 377 if (cf_state == NULL || channel.IsReadyMode()) |
| 378 expectations[kCmdQuickEnableCf] = &ValidateQuickEnableCfCommand; |
| 379 |
| 380 expectations[kCmdQuickEnableApplicationHost] = |
| 381 &ValidateQuickEnableApplicationHostCommand; |
| 382 } |
247 | 383 |
248 ValidateAppCommandExpectations(ctx, expectations, is_valid); | 384 ValidateAppCommandExpectations(ctx, expectations, is_valid); |
249 } | 385 } |
250 | 386 |
251 // Validates the multi-install binaries at level |system_level|. | 387 // Validates the multi-install binaries at level |system_level|. |
252 void InstallationValidator::ValidateBinaries( | 388 void InstallationValidator::ValidateBinaries( |
253 const InstallationState& machine_state, | 389 const InstallationState& machine_state, |
254 bool system_install, | 390 bool system_install, |
255 const ProductState& binaries_state, | 391 const ProductState& binaries_state, |
256 bool* is_valid) { | 392 bool* is_valid) { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 LOG(ERROR) << "Chrome Binaries are missing \"-readymode\" in channel" | 439 LOG(ERROR) << "Chrome Binaries are missing \"-readymode\" in channel" |
304 " name: \"" << channel.value() << "\""; | 440 " name: \"" << channel.value() << "\""; |
305 } | 441 } |
306 } else if (channel.IsReadyMode()) { | 442 } else if (channel.IsReadyMode()) { |
307 *is_valid = false; | 443 *is_valid = false; |
308 LOG(ERROR) << "Chrome Binaries have \"-readymode\" in channel name, yet " | 444 LOG(ERROR) << "Chrome Binaries have \"-readymode\" in channel name, yet " |
309 "Chrome Frame is not in ready mode: \"" << channel.value() | 445 "Chrome Frame is not in ready mode: \"" << channel.value() |
310 << "\""; | 446 << "\""; |
311 } | 447 } |
312 | 448 |
313 // Chrome or Chrome Frame must be present | 449 // ap must have -apphost iff Chrome Frame is installed multi |
314 if (chrome_state == NULL && cf_state == NULL) { | 450 const ProductState* app_host_state = machine_state.GetProductState( |
| 451 system_install, BrowserDistribution::CHROME_APP_HOST); |
| 452 if (app_host_state != NULL) { |
| 453 if (!app_host_state->is_multi_install()) { |
| 454 *is_valid = false; |
| 455 LOG(ERROR) << "Chrome App Host is installed in non-multi mode."; |
| 456 } |
| 457 if (!channel.IsAppHost()) { |
| 458 *is_valid = false; |
| 459 LOG(ERROR) << "Chrome Binaries are missing \"-apphost\" in channel" |
| 460 " name: \"" << channel.value() << "\""; |
| 461 } |
| 462 } else if (channel.IsAppHost()) { |
| 463 *is_valid = false; |
| 464 LOG(ERROR) << "Chrome Binaries have \"-apphost\" in channel name, yet " |
| 465 "Chrome App Host is not installed: \"" << channel.value() |
| 466 << "\""; |
| 467 } |
| 468 |
| 469 // Chrome, Chrome Frame, or App Host must be present |
| 470 if (chrome_state == NULL && cf_state == NULL && app_host_state == NULL) { |
315 *is_valid = false; | 471 *is_valid = false; |
316 LOG(ERROR) << "Chrome Binaries are present with no other products."; | 472 LOG(ERROR) << "Chrome Binaries are present with no other products."; |
317 } | 473 } |
318 | 474 |
319 // Chrome must be multi-install if present. | 475 // Chrome must be multi-install if present. |
320 if (chrome_state != NULL && !chrome_state->is_multi_install()) { | 476 if (chrome_state != NULL && !chrome_state->is_multi_install()) { |
321 *is_valid = false; | 477 *is_valid = false; |
322 LOG(ERROR) | 478 LOG(ERROR) |
323 << "Chrome Binaries are present yet Chrome is not multi-install."; | 479 << "Chrome Binaries are present yet Chrome is not multi-install."; |
324 } | 480 } |
325 | 481 |
326 // Chrome Frame must be multi-install if Chrome is not present. | 482 // Chrome Frame must be multi-install if Chrome & App Host are not present. |
327 if (cf_state != NULL && chrome_state == NULL && | 483 if (cf_state != NULL && app_host_state == NULL && chrome_state == NULL && |
328 !cf_state->is_multi_install()) { | 484 !cf_state->is_multi_install()) { |
329 *is_valid = false; | 485 *is_valid = false; |
330 LOG(ERROR) << "Chrome Binaries are present without Chrome yet Chrome Frame " | 486 LOG(ERROR) << "Chrome Binaries are present without Chrome nor App Host " |
331 "is not multi-install."; | 487 << "yet Chrome Frame is not multi-install."; |
332 } | 488 } |
333 | 489 |
334 ChromeBinariesRules binaries_rules; | 490 ChromeBinariesRules binaries_rules; |
335 ProductContext ctx = { | 491 ProductContext ctx = { |
336 machine_state, | 492 machine_state, |
337 system_install, | 493 system_install, |
338 BrowserDistribution::GetSpecificDistribution( | 494 BrowserDistribution::GetSpecificDistribution( |
339 BrowserDistribution::CHROME_BINARIES), | 495 BrowserDistribution::CHROME_BINARIES), |
340 binaries_state, | 496 binaries_state, |
341 binaries_rules | 497 binaries_rules |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
476 | 632 |
477 // Validates the multi-install state of the product described in |ctx|. | 633 // Validates the multi-install state of the product described in |ctx|. |
478 void InstallationValidator::ValidateMultiInstallProduct( | 634 void InstallationValidator::ValidateMultiInstallProduct( |
479 const ProductContext& ctx, | 635 const ProductContext& ctx, |
480 bool* is_valid) { | 636 bool* is_valid) { |
481 DCHECK(is_valid); | 637 DCHECK(is_valid); |
482 | 638 |
483 const ProductState* binaries = | 639 const ProductState* binaries = |
484 ctx.machine_state.GetProductState(ctx.system_install, | 640 ctx.machine_state.GetProductState(ctx.system_install, |
485 BrowserDistribution::CHROME_BINARIES); | 641 BrowserDistribution::CHROME_BINARIES); |
486 DCHECK(binaries); | 642 if (!binaries) { |
| 643 if (ctx.dist->GetType() == BrowserDistribution::CHROME_APP_HOST) { |
| 644 if (!ctx.machine_state.GetProductState( |
| 645 true, // system-level |
| 646 BrowserDistribution::CHROME_BINARIES) && |
| 647 !ctx.machine_state.GetProductState( |
| 648 true, // system-level |
| 649 BrowserDistribution::CHROME_BROWSER)) { |
| 650 *is_valid = false; |
| 651 LOG(ERROR) << ctx.dist->GetAppShortCutName() |
| 652 << " (" << ctx.state.version().GetString() << ") is " |
| 653 << "installed without Chrome Binaries or a system-level " |
| 654 << "Chrome."; |
| 655 } |
| 656 } else { |
| 657 *is_valid = false; |
| 658 LOG(ERROR) << ctx.dist->GetAppShortCutName() |
| 659 << " (" << ctx.state.version().GetString() << ") is installed " |
| 660 << "without Chrome Binaries."; |
| 661 } |
| 662 } else { |
| 663 // Version must match that of binaries. |
| 664 if (ctx.state.version().CompareTo(binaries->version()) != 0) { |
| 665 *is_valid = false; |
| 666 LOG(ERROR) << "Version of " << ctx.dist->GetAppShortCutName() |
| 667 << " (" << ctx.state.version().GetString() << ") does not " |
| 668 "match that of Chrome Binaries (" |
| 669 << binaries->version().GetString() << ")."; |
| 670 } |
487 | 671 |
488 // Version must match that of binaries. | 672 // Channel value must match that of binaries. |
489 if (ctx.state.version().CompareTo(binaries->version()) != 0) { | 673 if (!ctx.state.channel().Equals(binaries->channel())) { |
490 *is_valid = false; | 674 *is_valid = false; |
491 LOG(ERROR) << "Version of " << ctx.dist->GetAppShortCutName() | 675 LOG(ERROR) << "Channel name of " << ctx.dist->GetAppShortCutName() |
492 << " (" << ctx.state.version().GetString() << ") does not " | 676 << " (" << ctx.state.channel().value() |
493 "match that of Chrome Binaries (" | 677 << ") does not match that of Chrome Binaries (" |
494 << binaries->version().GetString() << ")."; | 678 << binaries->channel().value() << ")."; |
495 } | 679 } |
496 | |
497 // Channel value must match that of binaries. | |
498 if (!ctx.state.channel().Equals(binaries->channel())) { | |
499 *is_valid = false; | |
500 LOG(ERROR) << "Channel name of " << ctx.dist->GetAppShortCutName() | |
501 << " (" << ctx.state.channel().value() | |
502 << ") does not match that of Chrome Binaries (" | |
503 << binaries->channel().value() << ")."; | |
504 } | 680 } |
505 } | 681 } |
506 | 682 |
507 // Validates the Google Update commands for the product described in |ctx|. | 683 // Validates the Google Update commands for the product described in |ctx|. |
508 void InstallationValidator::ValidateAppCommands( | 684 void InstallationValidator::ValidateAppCommands( |
509 const ProductContext& ctx, | 685 const ProductContext& ctx, |
510 bool* is_valid) { | 686 bool* is_valid) { |
511 DCHECK(is_valid); | 687 DCHECK(is_valid); |
512 | 688 |
513 // Products are not expected to have any commands. | 689 CommandExpectations expectations; |
514 ValidateAppCommandExpectations(ctx, CommandExpectations(), is_valid); | 690 |
| 691 if (ctx.dist->GetType() == BrowserDistribution::CHROME_APP_HOST) { |
| 692 expectations[kCmdInstallApp] = &ValidateInstallAppCommand; |
| 693 } |
| 694 |
| 695 ValidateAppCommandExpectations(ctx, expectations, is_valid); |
515 } | 696 } |
516 | 697 |
517 // Validates usagestats for the product or binaries in |ctx|. | 698 // Validates usagestats for the product or binaries in |ctx|. |
518 void InstallationValidator::ValidateUsageStats(const ProductContext& ctx, | 699 void InstallationValidator::ValidateUsageStats(const ProductContext& ctx, |
519 bool* is_valid) { | 700 bool* is_valid) { |
520 DWORD usagestats = 0; | 701 DWORD usagestats = 0; |
521 if (ctx.state.GetUsageStats(&usagestats)) { | 702 if (ctx.state.GetUsageStats(&usagestats)) { |
522 if (!ctx.rules.UsageStatsAllowed(ctx.state)) { | 703 if (!ctx.rules.UsageStatsAllowed(ctx.state)) { |
523 *is_valid = false; | 704 *is_valid = false; |
524 LOG(ERROR) << ctx.dist->GetAppShortCutName() | 705 LOG(ERROR) << ctx.dist->GetAppShortCutName() |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
602 chrome_frame_rules, &rock_on); | 783 chrome_frame_rules, &rock_on); |
603 int cf_bit = !product_state->is_multi_install() ? | 784 int cf_bit = !product_state->is_multi_install() ? |
604 ProductBits::CHROME_FRAME_SINGLE : | 785 ProductBits::CHROME_FRAME_SINGLE : |
605 (product_state->uninstall_command().HasSwitch( | 786 (product_state->uninstall_command().HasSwitch( |
606 switches::kChromeFrameReadyMode) ? | 787 switches::kChromeFrameReadyMode) ? |
607 ProductBits::CHROME_FRAME_READY_MODE : | 788 ProductBits::CHROME_FRAME_READY_MODE : |
608 ProductBits::CHROME_FRAME_MULTI); | 789 ProductBits::CHROME_FRAME_MULTI); |
609 *type = static_cast<InstallationType>(*type | cf_bit); | 790 *type = static_cast<InstallationType>(*type | cf_bit); |
610 } | 791 } |
611 | 792 |
| 793 // Is Chrome App Host installed? |
| 794 product_state = |
| 795 machine_state.GetProductState(system_level, |
| 796 BrowserDistribution::CHROME_APP_HOST); |
| 797 if (product_state != NULL) { |
| 798 ChromeAppHostRules chrome_app_host_rules; |
| 799 ValidateProduct(machine_state, system_level, *product_state, |
| 800 chrome_app_host_rules, &rock_on); |
| 801 *type = static_cast<InstallationType>(*type | ProductBits::CHROME_APP_HOST); |
| 802 if (system_level) { |
| 803 LOG(ERROR) << "Chrome App Host must not be installed at system level."; |
| 804 rock_on = false; |
| 805 } |
| 806 if (!product_state->is_multi_install()) { |
| 807 LOG(ERROR) << "Chrome App Host must always be multi-install."; |
| 808 rock_on = false; |
| 809 } |
| 810 } |
| 811 |
612 DCHECK_NE(std::find(&kInstallationTypes[0], | 812 DCHECK_NE(std::find(&kInstallationTypes[0], |
613 &kInstallationTypes[arraysize(kInstallationTypes)], | 813 &kInstallationTypes[arraysize(kInstallationTypes)], |
614 *type), | 814 *type), |
615 &kInstallationTypes[arraysize(kInstallationTypes)]) | 815 &kInstallationTypes[arraysize(kInstallationTypes)]) |
616 << "Invalid combination of products found on system (" << *type << ")"; | 816 << "Invalid combination of products found on system (" << *type << ")"; |
617 | 817 |
618 return rock_on; | 818 return rock_on; |
619 } | 819 } |
620 | 820 |
621 // static | 821 // static |
622 bool InstallationValidator::ValidateInstallationType(bool system_level, | 822 bool InstallationValidator::ValidateInstallationType(bool system_level, |
623 InstallationType* type) { | 823 InstallationType* type) { |
624 DCHECK(type); | 824 DCHECK(type); |
625 InstallationState machine_state; | 825 InstallationState machine_state; |
626 | 826 |
627 machine_state.Initialize(); | 827 machine_state.Initialize(); |
628 | 828 |
629 return ValidateInstallationTypeForState(machine_state, system_level, type); | 829 return ValidateInstallationTypeForState(machine_state, system_level, type); |
630 } | 830 } |
631 | 831 |
632 } // namespace installer | 832 } // namespace installer |
OLD | NEW |