| 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 // 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> |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 | 28 |
| 29 void InstallationValidator::ChromeRules::AddUninstallSwitchExpectations( | 29 void InstallationValidator::ChromeRules::AddUninstallSwitchExpectations( |
| 30 const ProductContext& ctx, | 30 const ProductContext& ctx, |
| 31 SwitchExpectations* expectations) const { | 31 SwitchExpectations* expectations) const { |
| 32 const bool is_multi_install = | 32 const bool is_multi_install = |
| 33 ctx.state.uninstall_command().HasSwitch(switches::kMultiInstall); | 33 ctx.state.uninstall_command().HasSwitch(switches::kMultiInstall); |
| 34 | 34 |
| 35 // --chrome should be present for uninstall iff --multi-install. This wasn't | 35 // --chrome should be present for uninstall iff --multi-install. This wasn't |
| 36 // the case in Chrome 10 (between r68996 and r72497), though, so consider it | 36 // the case in Chrome 10 (between r68996 and r72497), though, so consider it |
| 37 // optional. | 37 // optional. |
| 38 | |
| 39 // --chrome-frame --ready-mode should be present for uninstall iff CF in ready | |
| 40 // mode. | |
| 41 const ProductState* cf_state = | |
| 42 ctx.machine_state.GetProductState(ctx.system_install, | |
| 43 BrowserDistribution::CHROME_FRAME); | |
| 44 const bool ready_mode = | |
| 45 cf_state != NULL && | |
| 46 cf_state->uninstall_command().HasSwitch(switches::kChromeFrameReadyMode); | |
| 47 expectations->push_back(std::make_pair(std::string(switches::kChromeFrame), | |
| 48 ready_mode)); | |
| 49 expectations->push_back( | |
| 50 std::make_pair(std::string(switches::kChromeFrameReadyMode), ready_mode)); | |
| 51 } | 38 } |
| 52 | 39 |
| 53 void InstallationValidator::ChromeRules::AddRenameSwitchExpectations( | 40 void InstallationValidator::ChromeRules::AddRenameSwitchExpectations( |
| 54 const ProductContext& ctx, | 41 const ProductContext& ctx, |
| 55 SwitchExpectations* expectations) const { | 42 SwitchExpectations* expectations) const { |
| 56 const bool is_multi_install = | 43 const bool is_multi_install = |
| 57 ctx.state.uninstall_command().HasSwitch(switches::kMultiInstall); | 44 ctx.state.uninstall_command().HasSwitch(switches::kMultiInstall); |
| 58 | 45 |
| 59 // --chrome should not be present for rename. It was for a time, so we'll be | 46 // --chrome should not be present for rename. It was for a time, so we'll be |
| 60 // lenient so that mini_installer tests pass. | 47 // lenient so that mini_installer tests pass. |
| 61 | 48 |
| 62 // --chrome-frame --ready-mode should never be present. | 49 // --chrome-frame should never be present. |
| 63 expectations->push_back( | 50 expectations->push_back( |
| 64 std::make_pair(std::string(switches::kChromeFrame), false)); | 51 std::make_pair(std::string(switches::kChromeFrame), false)); |
| 65 expectations->push_back( | |
| 66 std::make_pair(std::string(switches::kChromeFrameReadyMode), false)); | |
| 67 } | 52 } |
| 68 | 53 |
| 69 bool InstallationValidator::ChromeRules::UsageStatsAllowed( | 54 bool InstallationValidator::ChromeRules::UsageStatsAllowed( |
| 70 const ProductContext& ctx) const { | 55 const ProductContext& ctx) const { |
| 71 // Products must not have usagestats consent values when multi-install | 56 // Products must not have usagestats consent values when multi-install |
| 72 // (only the multi-install binaries may). | 57 // (only the multi-install binaries may). |
| 73 return !ctx.state.is_multi_install(); | 58 return !ctx.state.is_multi_install(); |
| 74 } | 59 } |
| 75 | 60 |
| 76 BrowserDistribution::Type | 61 BrowserDistribution::Type |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 const InstallationValidator::InstallationType | 151 const InstallationValidator::InstallationType |
| 167 InstallationValidator::kInstallationTypes[] = { | 152 InstallationValidator::kInstallationTypes[] = { |
| 168 NO_PRODUCTS, | 153 NO_PRODUCTS, |
| 169 CHROME_SINGLE, | 154 CHROME_SINGLE, |
| 170 CHROME_MULTI, | 155 CHROME_MULTI, |
| 171 CHROME_FRAME_SINGLE, | 156 CHROME_FRAME_SINGLE, |
| 172 CHROME_FRAME_SINGLE_CHROME_SINGLE, | 157 CHROME_FRAME_SINGLE_CHROME_SINGLE, |
| 173 CHROME_FRAME_SINGLE_CHROME_MULTI, | 158 CHROME_FRAME_SINGLE_CHROME_MULTI, |
| 174 CHROME_FRAME_MULTI, | 159 CHROME_FRAME_MULTI, |
| 175 CHROME_FRAME_MULTI_CHROME_MULTI, | 160 CHROME_FRAME_MULTI_CHROME_MULTI, |
| 176 CHROME_FRAME_READY_MODE_CHROME_MULTI, | |
| 177 CHROME_APP_HOST, | 161 CHROME_APP_HOST, |
| 178 CHROME_APP_HOST_CHROME_FRAME_SINGLE, | 162 CHROME_APP_HOST_CHROME_FRAME_SINGLE, |
| 179 CHROME_APP_HOST_CHROME_FRAME_SINGLE_CHROME_MULTI, | 163 CHROME_APP_HOST_CHROME_FRAME_SINGLE_CHROME_MULTI, |
| 180 CHROME_APP_HOST_CHROME_FRAME_MULTI, | 164 CHROME_APP_HOST_CHROME_FRAME_MULTI, |
| 181 CHROME_APP_HOST_CHROME_FRAME_MULTI_CHROME_MULTI, | 165 CHROME_APP_HOST_CHROME_FRAME_MULTI_CHROME_MULTI, |
| 182 CHROME_APP_HOST_CHROME_MULTI, | 166 CHROME_APP_HOST_CHROME_MULTI, |
| 183 CHROME_APP_HOST_CHROME_MULTI_CHROME_FRAME_READY_MODE, | |
| 184 }; | 167 }; |
| 185 | 168 |
| 186 void InstallationValidator::ValidateAppCommandFlags( | 169 void InstallationValidator::ValidateAppCommandFlags( |
| 187 const ProductContext& ctx, | 170 const ProductContext& ctx, |
| 188 const AppCommand& app_cmd, | 171 const AppCommand& app_cmd, |
| 189 const std::set<string16>& flags_exp, | 172 const std::set<string16>& flags_exp, |
| 190 const string16& name, | 173 const string16& name, |
| 191 bool* is_valid) { | 174 bool* is_valid) { |
| 192 const struct { | 175 const struct { |
| 193 const string16 exp_key; | 176 const string16 exp_key; |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 } | 415 } |
| 433 } | 416 } |
| 434 | 417 |
| 435 // Validates the multi-install binaries' Google Update commands. | 418 // Validates the multi-install binaries' Google Update commands. |
| 436 void InstallationValidator::ValidateBinariesCommands( | 419 void InstallationValidator::ValidateBinariesCommands( |
| 437 const ProductContext& ctx, | 420 const ProductContext& ctx, |
| 438 bool* is_valid) { | 421 bool* is_valid) { |
| 439 DCHECK(is_valid); | 422 DCHECK(is_valid); |
| 440 | 423 |
| 441 // The quick-enable-cf command must be present if Chrome Binaries are | 424 // The quick-enable-cf command must be present if Chrome Binaries are |
| 442 // installed and Chrome Frame is not installed (or installed in ready mode). | 425 // installed and Chrome Frame is not installed. |
| 443 const ChannelInfo& channel = ctx.state.channel(); | 426 const ChannelInfo& channel = ctx.state.channel(); |
| 444 const ProductState* binaries_state = ctx.machine_state.GetProductState( | 427 const ProductState* binaries_state = ctx.machine_state.GetProductState( |
| 445 ctx.system_install, BrowserDistribution::CHROME_BINARIES); | 428 ctx.system_install, BrowserDistribution::CHROME_BINARIES); |
| 446 const ProductState* cf_state = ctx.machine_state.GetProductState( | 429 const ProductState* cf_state = ctx.machine_state.GetProductState( |
| 447 ctx.system_install, BrowserDistribution::CHROME_FRAME); | 430 ctx.system_install, BrowserDistribution::CHROME_FRAME); |
| 448 | 431 |
| 449 CommandExpectations expectations; | 432 CommandExpectations expectations; |
| 450 | 433 |
| 451 if (binaries_state != NULL) { | 434 if (binaries_state != NULL) { |
| 452 if (cf_state == NULL || channel.IsReadyMode()) | 435 if (cf_state == NULL) |
| 453 expectations[kCmdQuickEnableCf] = &ValidateQuickEnableCfCommand; | 436 expectations[kCmdQuickEnableCf] = &ValidateQuickEnableCfCommand; |
| 454 | 437 |
| 455 expectations[kCmdQuickEnableApplicationHost] = | 438 expectations[kCmdQuickEnableApplicationHost] = |
| 456 &ValidateQuickEnableApplicationHostCommand; | 439 &ValidateQuickEnableApplicationHostCommand; |
| 457 | 440 |
| 458 expectations[kCmdQueryEULAAcceptance] = &ValidateQueryEULAAcceptanceCommand; | 441 expectations[kCmdQueryEULAAcceptance] = &ValidateQueryEULAAcceptanceCommand; |
| 459 } | 442 } |
| 460 | 443 |
| 461 ValidateAppCommandExpectations(ctx, expectations, is_valid); | 444 ValidateAppCommandExpectations(ctx, expectations, is_valid); |
| 462 } | 445 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 500 LOG(ERROR) << "Chrome Binaries are missing \"-chromeframe\" in channel" | 483 LOG(ERROR) << "Chrome Binaries are missing \"-chromeframe\" in channel" |
| 501 " name: \"" << channel.value() << "\""; | 484 " name: \"" << channel.value() << "\""; |
| 502 } | 485 } |
| 503 } else if (channel.IsChromeFrame()) { | 486 } else if (channel.IsChromeFrame()) { |
| 504 *is_valid = false; | 487 *is_valid = false; |
| 505 LOG(ERROR) << "Chrome Binaries have \"-chromeframe\" in channel name, yet " | 488 LOG(ERROR) << "Chrome Binaries have \"-chromeframe\" in channel name, yet " |
| 506 "Chrome Frame is not installed multi: \"" << channel.value() | 489 "Chrome Frame is not installed multi: \"" << channel.value() |
| 507 << "\""; | 490 << "\""; |
| 508 } | 491 } |
| 509 | 492 |
| 510 // ap must have -readymode iff Chrome Frame is installed in ready-mode | |
| 511 if (cf_state != NULL && | |
| 512 cf_state->uninstall_command().HasSwitch( | |
| 513 installer::switches::kChromeFrameReadyMode)) { | |
| 514 if (!channel.IsReadyMode()) { | |
| 515 *is_valid = false; | |
| 516 LOG(ERROR) << "Chrome Binaries are missing \"-readymode\" in channel" | |
| 517 " name: \"" << channel.value() << "\""; | |
| 518 } | |
| 519 } else if (channel.IsReadyMode()) { | |
| 520 *is_valid = false; | |
| 521 LOG(ERROR) << "Chrome Binaries have \"-readymode\" in channel name, yet " | |
| 522 "Chrome Frame is not in ready mode: \"" << channel.value() | |
| 523 << "\""; | |
| 524 } | |
| 525 | |
| 526 // ap must have -applauncher iff Chrome App Launcher is installed multi | 493 // ap must have -applauncher iff Chrome App Launcher is installed multi |
| 527 const ProductState* app_host_state = machine_state.GetProductState( | 494 const ProductState* app_host_state = machine_state.GetProductState( |
| 528 system_install, BrowserDistribution::CHROME_APP_HOST); | 495 system_install, BrowserDistribution::CHROME_APP_HOST); |
| 529 if (app_host_state != NULL) { | 496 if (app_host_state != NULL) { |
| 530 if (!app_host_state->is_multi_install()) { | 497 if (!app_host_state->is_multi_install()) { |
| 531 *is_valid = false; | 498 *is_valid = false; |
| 532 LOG(ERROR) << "Chrome App Launcher is installed in non-multi mode."; | 499 LOG(ERROR) << "Chrome App Launcher is installed in non-multi mode."; |
| 533 } | 500 } |
| 534 if (!channel.IsAppLauncher()) { | 501 if (!channel.IsAppLauncher()) { |
| 535 *is_valid = false; | 502 *is_valid = false; |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 842 // Is Chrome Frame installed? | 809 // Is Chrome Frame installed? |
| 843 product_state = | 810 product_state = |
| 844 machine_state.GetProductState(system_level, | 811 machine_state.GetProductState(system_level, |
| 845 BrowserDistribution::CHROME_FRAME); | 812 BrowserDistribution::CHROME_FRAME); |
| 846 if (product_state != NULL) { | 813 if (product_state != NULL) { |
| 847 ChromeFrameRules chrome_frame_rules; | 814 ChromeFrameRules chrome_frame_rules; |
| 848 ValidateProduct(machine_state, system_level, *product_state, | 815 ValidateProduct(machine_state, system_level, *product_state, |
| 849 chrome_frame_rules, &rock_on); | 816 chrome_frame_rules, &rock_on); |
| 850 int cf_bit = !product_state->is_multi_install() ? | 817 int cf_bit = !product_state->is_multi_install() ? |
| 851 ProductBits::CHROME_FRAME_SINGLE : | 818 ProductBits::CHROME_FRAME_SINGLE : |
| 852 (product_state->uninstall_command().HasSwitch( | 819 ProductBits::CHROME_FRAME_MULTI; |
| 853 switches::kChromeFrameReadyMode) ? | |
| 854 ProductBits::CHROME_FRAME_READY_MODE : | |
| 855 ProductBits::CHROME_FRAME_MULTI); | |
| 856 *type = static_cast<InstallationType>(*type | cf_bit); | 820 *type = static_cast<InstallationType>(*type | cf_bit); |
| 857 } | 821 } |
| 858 | 822 |
| 859 // Is Chrome App Host installed? | 823 // Is Chrome App Host installed? |
| 860 product_state = | 824 product_state = |
| 861 machine_state.GetProductState(system_level, | 825 machine_state.GetProductState(system_level, |
| 862 BrowserDistribution::CHROME_APP_HOST); | 826 BrowserDistribution::CHROME_APP_HOST); |
| 863 if (product_state != NULL) { | 827 if (product_state != NULL) { |
| 864 ChromeAppHostRules chrome_app_host_rules; | 828 ChromeAppHostRules chrome_app_host_rules; |
| 865 ValidateProduct(machine_state, system_level, *product_state, | 829 ValidateProduct(machine_state, system_level, *product_state, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 885 InstallationType* type) { | 849 InstallationType* type) { |
| 886 DCHECK(type); | 850 DCHECK(type); |
| 887 InstallationState machine_state; | 851 InstallationState machine_state; |
| 888 | 852 |
| 889 machine_state.Initialize(); | 853 machine_state.Initialize(); |
| 890 | 854 |
| 891 return ValidateInstallationTypeForState(machine_state, system_level, type); | 855 return ValidateInstallationTypeForState(machine_state, system_level, type); |
| 892 } | 856 } |
| 893 | 857 |
| 894 } // namespace installer | 858 } // namespace installer |
| OLD | NEW |