| 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 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 flags_exp.insert(google_update::kRegRunAsUserField); | 257 flags_exp.insert(google_update::kRegRunAsUserField); |
| 258 ValidateAppCommandFlags(ctx, app_cmd, flags_exp, name, is_valid); | 258 ValidateAppCommandFlags(ctx, app_cmd, flags_exp, name, is_valid); |
| 259 } | 259 } |
| 260 | 260 |
| 261 // Validates the "install-application" Google Update product command. | 261 // Validates the "install-application" Google Update product command. |
| 262 void InstallationValidator::ValidateInstallAppCommand( | 262 void InstallationValidator::ValidateInstallAppCommand( |
| 263 const ProductContext& ctx, | 263 const ProductContext& ctx, |
| 264 const AppCommand& app_cmd, | 264 const AppCommand& app_cmd, |
| 265 bool* is_valid) { | 265 bool* is_valid) { |
| 266 ValidateInstallCommand(ctx, app_cmd, kCmdInstallApp, | 266 ValidateInstallCommand(ctx, app_cmd, kCmdInstallApp, |
| 267 installer::kChromeAppHostExe, | 267 installer::kChromeExe, |
| 268 ::switches::kInstallFromWebstore, is_valid); | 268 ::switches::kInstallFromWebstore, is_valid); |
| 269 } | 269 } |
| 270 | 270 |
| 271 // Validates the "install-extension" Google Update product command. | 271 // Validates the "install-extension" Google Update product command. |
| 272 void InstallationValidator::ValidateInstallExtensionCommand( | 272 void InstallationValidator::ValidateInstallExtensionCommand( |
| 273 const ProductContext& ctx, | 273 const ProductContext& ctx, |
| 274 const AppCommand& app_cmd, | 274 const AppCommand& app_cmd, |
| 275 bool* is_valid) { | 275 bool* is_valid) { |
| 276 ValidateInstallCommand(ctx, app_cmd, kCmdInstallExtension, | 276 ValidateInstallCommand(ctx, app_cmd, kCmdInstallExtension, |
| 277 installer::kChromeExe, | 277 installer::kChromeExe, |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 ValidateSetupPath(ctx, cmd_line.GetProgram(), name, is_valid); | 375 ValidateSetupPath(ctx, cmd_line.GetProgram(), name, is_valid); |
| 376 | 376 |
| 377 SwitchExpectations expected; | 377 SwitchExpectations expected; |
| 378 | 378 |
| 379 expected.push_back(std::make_pair( | 379 expected.push_back(std::make_pair( |
| 380 std::string(switches::kChromeAppLauncher), true)); | 380 std::string(switches::kChromeAppLauncher), true)); |
| 381 expected.push_back(std::make_pair( | 381 expected.push_back(std::make_pair( |
| 382 std::string(switches::kSystemLevel), false)); | 382 std::string(switches::kSystemLevel), false)); |
| 383 expected.push_back(std::make_pair( | 383 expected.push_back(std::make_pair( |
| 384 std::string(switches::kMultiInstall), true)); | 384 std::string(switches::kMultiInstall), true)); |
| 385 expected.push_back(std::make_pair( | |
| 386 std::string(switches::kEnsureGoogleUpdatePresent), true)); | |
| 387 | 385 |
| 388 ValidateCommandExpectations(ctx, cmd_line, expected, name, is_valid); | 386 ValidateCommandExpectations(ctx, cmd_line, expected, name, is_valid); |
| 389 | 387 |
| 390 std::set<string16> flags_exp; | 388 std::set<string16> flags_exp; |
| 391 flags_exp.insert(google_update::kRegSendsPingsField); | 389 flags_exp.insert(google_update::kRegSendsPingsField); |
| 392 flags_exp.insert(google_update::kRegWebAccessibleField); | 390 flags_exp.insert(google_update::kRegWebAccessibleField); |
| 393 flags_exp.insert(google_update::kRegRunAsUserField); | 391 flags_exp.insert(google_update::kRegRunAsUserField); |
| 394 ValidateAppCommandFlags(ctx, app_cmd, flags_exp, name, is_valid); | 392 ValidateAppCommandFlags(ctx, app_cmd, flags_exp, name, is_valid); |
| 395 } | 393 } |
| 396 | 394 |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 526 } | 524 } |
| 527 | 525 |
| 528 // ap must have -applauncher iff Chrome App Launcher is installed multi | 526 // ap must have -applauncher iff Chrome App Launcher is installed multi |
| 529 const ProductState* app_host_state = machine_state.GetProductState( | 527 const ProductState* app_host_state = machine_state.GetProductState( |
| 530 system_install, BrowserDistribution::CHROME_APP_HOST); | 528 system_install, BrowserDistribution::CHROME_APP_HOST); |
| 531 if (app_host_state != NULL) { | 529 if (app_host_state != NULL) { |
| 532 if (!app_host_state->is_multi_install()) { | 530 if (!app_host_state->is_multi_install()) { |
| 533 *is_valid = false; | 531 *is_valid = false; |
| 534 LOG(ERROR) << "Chrome App Launcher is installed in non-multi mode."; | 532 LOG(ERROR) << "Chrome App Launcher is installed in non-multi mode."; |
| 535 } | 533 } |
| 536 if (!channel.IsAppLauncher()) { | 534 } |
| 537 *is_valid = false; | 535 if (channel.IsAppLauncher()) { |
| 538 LOG(ERROR) << "Chrome Binaries are missing \"-applauncher\" in channel" | |
| 539 " name: \"" << channel.value() << "\""; | |
| 540 } | |
| 541 } else if (channel.IsAppLauncher()) { | |
| 542 *is_valid = false; | 536 *is_valid = false; |
| 543 LOG(ERROR) << "Chrome Binaries have \"-applauncher\" in channel name, yet " | 537 LOG(ERROR) << "Chrome Binaries have deprecated \"-applauncher\" in channel " |
| 544 "Chrome App Launcher is not installed: \"" << channel.value() | 538 "name: \"" << channel.value() << "\""; |
| 545 << "\""; | |
| 546 } | 539 } |
| 547 | 540 |
| 548 // Chrome, Chrome Frame, or App Host must be present | 541 // Chrome, Chrome Frame, or App Host must be present |
| 549 if (chrome_state == NULL && cf_state == NULL && app_host_state == NULL) { | 542 if (chrome_state == NULL && cf_state == NULL && app_host_state == NULL) { |
| 550 *is_valid = false; | 543 *is_valid = false; |
| 551 LOG(ERROR) << "Chrome Binaries are present with no other products."; | 544 LOG(ERROR) << "Chrome Binaries are present with no other products."; |
| 552 } | 545 } |
| 553 | 546 |
| 554 // Chrome must be multi-install if present. | 547 // Chrome must be multi-install if present. |
| 555 if (chrome_state != NULL && !chrome_state->is_multi_install()) { | 548 if (chrome_state != NULL && !chrome_state->is_multi_install()) { |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 860 | 853 |
| 861 // Is Chrome App Host installed? | 854 // Is Chrome App Host installed? |
| 862 product_state = | 855 product_state = |
| 863 machine_state.GetProductState(system_level, | 856 machine_state.GetProductState(system_level, |
| 864 BrowserDistribution::CHROME_APP_HOST); | 857 BrowserDistribution::CHROME_APP_HOST); |
| 865 if (product_state != NULL) { | 858 if (product_state != NULL) { |
| 866 ChromeAppHostRules chrome_app_host_rules; | 859 ChromeAppHostRules chrome_app_host_rules; |
| 867 ValidateProduct(machine_state, system_level, *product_state, | 860 ValidateProduct(machine_state, system_level, *product_state, |
| 868 chrome_app_host_rules, &rock_on); | 861 chrome_app_host_rules, &rock_on); |
| 869 *type = static_cast<InstallationType>(*type | ProductBits::CHROME_APP_HOST); | 862 *type = static_cast<InstallationType>(*type | ProductBits::CHROME_APP_HOST); |
| 870 if (system_level) { | |
| 871 LOG(ERROR) << | |
| 872 "Chrome App Launcher must not be installed at system level."; | |
| 873 rock_on = false; | |
| 874 } | |
| 875 if (!product_state->is_multi_install()) { | 863 if (!product_state->is_multi_install()) { |
| 876 LOG(ERROR) << "Chrome App Launcher must always be multi-install."; | 864 LOG(ERROR) << "Chrome App Launcher must always be multi-install."; |
| 877 rock_on = false; | 865 rock_on = false; |
| 878 } | 866 } |
| 879 } | 867 } |
| 880 | 868 |
| 881 DCHECK_NE(std::find(&kInstallationTypes[0], | 869 DCHECK_NE(std::find(&kInstallationTypes[0], |
| 882 &kInstallationTypes[arraysize(kInstallationTypes)], | 870 &kInstallationTypes[arraysize(kInstallationTypes)], |
| 883 *type), | 871 *type), |
| 884 &kInstallationTypes[arraysize(kInstallationTypes)]) | 872 &kInstallationTypes[arraysize(kInstallationTypes)]) |
| 885 << "Invalid combination of products found on system (" << *type << ")"; | 873 << "Invalid combination of products found on system (" << *type << ")"; |
| 886 | 874 |
| 887 return rock_on; | 875 return rock_on; |
| 888 } | 876 } |
| 889 | 877 |
| 890 // static | 878 // static |
| 891 bool InstallationValidator::ValidateInstallationType(bool system_level, | 879 bool InstallationValidator::ValidateInstallationType(bool system_level, |
| 892 InstallationType* type) { | 880 InstallationType* type) { |
| 893 DCHECK(type); | 881 DCHECK(type); |
| 894 InstallationState machine_state; | 882 InstallationState machine_state; |
| 895 | 883 |
| 896 machine_state.Initialize(); | 884 machine_state.Initialize(); |
| 897 | 885 |
| 898 return ValidateInstallationTypeForState(machine_state, system_level, type); | 886 return ValidateInstallationTypeForState(machine_state, system_level, type); |
| 899 } | 887 } |
| 900 | 888 |
| 901 } // namespace installer | 889 } // namespace installer |
| OLD | NEW |