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

Side by Side Diff: chrome/installer/util/installation_validator.cc

Issue 869153004: Support migrating multi-install Chrome to single-install. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
OLDNEW
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 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 LOG(ERROR) << "Chrome Binaries are missing \"-chromeframe\" in channel" 385 LOG(ERROR) << "Chrome Binaries are missing \"-chromeframe\" in channel"
386 " name: \"" << channel.value() << "\""; 386 " name: \"" << channel.value() << "\"";
387 } 387 }
388 } else if (channel.IsChromeFrame()) { 388 } else if (channel.IsChromeFrame()) {
389 *is_valid = false; 389 *is_valid = false;
390 LOG(ERROR) << "Chrome Binaries have \"-chromeframe\" in channel name, yet " 390 LOG(ERROR) << "Chrome Binaries have \"-chromeframe\" in channel name, yet "
391 "Chrome Frame is not installed multi: \"" << channel.value() 391 "Chrome Frame is not installed multi: \"" << channel.value()
392 << "\""; 392 << "\"";
393 } 393 }
394 394
395 // ap must have -applauncher iff Chrome App Launcher is installed multi 395 // ap must not have -applauncher.
396 const ProductState* app_host_state = machine_state.GetProductState( 396 if (channel.IsAppLauncher()) {
robertshield 2015/01/23 22:45:30 isn't applauncher dead again?
grt (UTC plus 2) 2015/01/24 02:25:16 huangs@ is removing heroic swaths of code in https
397 system_install, BrowserDistribution::CHROME_APP_HOST);
398 if (app_host_state != NULL) {
399 if (!app_host_state->is_multi_install()) {
400 *is_valid = false;
401 LOG(ERROR) << "Chrome App Launcher is installed in non-multi mode.";
402 }
403 if (!channel.IsAppLauncher()) {
404 *is_valid = false;
405 LOG(ERROR) << "Chrome Binaries are missing \"-applauncher\" in channel"
406 " name: \"" << channel.value() << "\"";
407 }
408 } else if (channel.IsAppLauncher()) {
409 *is_valid = false; 397 *is_valid = false;
410 LOG(ERROR) << "Chrome Binaries have \"-applauncher\" in channel name, yet " 398 LOG(ERROR) << "Chrome Binaries have \"-applauncher\" in channel name: \""
411 "Chrome App Launcher is not installed: \"" << channel.value() 399 << channel.value() << "\"";
412 << "\"";
413 } 400 }
414 401
415 // Chrome, Chrome Frame, or App Host must be present 402 // Chrome or Chrome Frame must be present
416 if (chrome_state == NULL && cf_state == NULL && app_host_state == NULL) { 403 if (chrome_state == NULL && cf_state == NULL) {
417 *is_valid = false; 404 *is_valid = false;
418 LOG(ERROR) << "Chrome Binaries are present with no other products."; 405 LOG(ERROR) << "Chrome Binaries are present with no other products.";
419 } 406 }
420 407
421 // Chrome must be multi-install if present. 408 // Chrome must be multi-install if present.
422 if (chrome_state != NULL && !chrome_state->is_multi_install()) { 409 if (chrome_state != NULL && !chrome_state->is_multi_install()) {
423 *is_valid = false; 410 *is_valid = false;
424 LOG(ERROR) 411 LOG(ERROR)
425 << "Chrome Binaries are present yet Chrome is not multi-install."; 412 << "Chrome Binaries are present yet Chrome is not multi-install.";
426 } 413 }
427 414
428 // Chrome Frame must be multi-install if Chrome & App Host are not present. 415 // Chrome Frame must be multi-install if Chrome is not present.
429 if (cf_state != NULL && app_host_state == NULL && chrome_state == NULL && 416 if (cf_state != NULL && chrome_state == NULL &&
430 !cf_state->is_multi_install()) { 417 !cf_state->is_multi_install()) {
431 *is_valid = false; 418 *is_valid = false;
432 LOG(ERROR) << "Chrome Binaries are present without Chrome nor App Launcher " 419 LOG(ERROR) << "Chrome Binaries are present without Chrome yet Chrome Frame "
433 << "yet Chrome Frame is not multi-install."; 420 "is not multi-install.";
434 } 421 }
435 422
436 ChromeBinariesRules binaries_rules; 423 ChromeBinariesRules binaries_rules;
437 ProductContext ctx(machine_state, system_install, binaries_state, 424 ProductContext ctx(machine_state, system_install, binaries_state,
438 binaries_rules); 425 binaries_rules);
439 426
440 ValidateBinariesCommands(ctx, is_valid); 427 ValidateBinariesCommands(ctx, is_valid);
441 428
442 ValidateUsageStats(ctx, is_valid); 429 ValidateUsageStats(ctx, is_valid);
443 } 430 }
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 BrowserDistribution::CHROME_BROWSER); 686 BrowserDistribution::CHROME_BROWSER);
700 if (product_state != NULL) { 687 if (product_state != NULL) {
701 ChromeRules chrome_rules; 688 ChromeRules chrome_rules;
702 ValidateProduct(machine_state, system_level, *product_state, 689 ValidateProduct(machine_state, system_level, *product_state,
703 chrome_rules, &rock_on); 690 chrome_rules, &rock_on);
704 *type = static_cast<InstallationType>( 691 *type = static_cast<InstallationType>(
705 *type | (product_state->is_multi_install() ? 692 *type | (product_state->is_multi_install() ?
706 ProductBits::CHROME_MULTI : 693 ProductBits::CHROME_MULTI :
707 ProductBits::CHROME_SINGLE)); 694 ProductBits::CHROME_SINGLE));
708 } 695 }
696 // Usage of the app launcher is tracked alongside Chrome.
697 const ProductState* launcher_state =
698 machine_state.GetProductState(system_level,
699 BrowserDistribution::CHROME_APP_HOST);
700 BrowserDistribution* chrome_dist =
701 BrowserDistribution::GetSpecificDistribution(
702 BrowserDistribution::CHROME_BROWSER);
703 if (!launcher_state) {
704 LOG_IF(ERROR, product_state)
705 << "App launcher is not installed with "
706 << chrome_dist->GetDisplayName();
707 } else {
708 LOG_IF(ERROR, !product_state)
709 << "App launcher is installed without "
710 << chrome_dist->GetDisplayName();
711 }
709 712
710 // Is Chrome Frame installed? 713 // Is Chrome Frame installed?
711 product_state = 714 product_state =
712 machine_state.GetProductState(system_level, 715 machine_state.GetProductState(system_level,
713 BrowserDistribution::CHROME_FRAME); 716 BrowserDistribution::CHROME_FRAME);
714 if (product_state != NULL) { 717 if (product_state != NULL) {
715 ChromeFrameRules chrome_frame_rules; 718 ChromeFrameRules chrome_frame_rules;
716 ValidateProduct(machine_state, system_level, *product_state, 719 ValidateProduct(machine_state, system_level, *product_state,
717 chrome_frame_rules, &rock_on); 720 chrome_frame_rules, &rock_on);
718 int cf_bit = !product_state->is_multi_install() ? 721 int cf_bit = !product_state->is_multi_install() ?
719 ProductBits::CHROME_FRAME_SINGLE : 722 ProductBits::CHROME_FRAME_SINGLE :
720 ProductBits::CHROME_FRAME_MULTI; 723 ProductBits::CHROME_FRAME_MULTI;
721 *type = static_cast<InstallationType>(*type | cf_bit); 724 *type = static_cast<InstallationType>(*type | cf_bit);
722 } 725 }
723 726
724 // Is Chrome App Host installed?
725 product_state =
726 machine_state.GetProductState(system_level,
727 BrowserDistribution::CHROME_APP_HOST);
728 if (product_state != NULL) {
729 ChromeAppHostRules chrome_app_host_rules;
730 ValidateProduct(machine_state, system_level, *product_state,
731 chrome_app_host_rules, &rock_on);
732 *type = static_cast<InstallationType>(*type | ProductBits::CHROME_APP_HOST);
733 if (!product_state->is_multi_install()) {
734 LOG(ERROR) << "Chrome App Launcher must always be multi-install.";
735 rock_on = false;
736 }
737 }
738
739 DCHECK_NE(std::find(&kInstallationTypes[0], 727 DCHECK_NE(std::find(&kInstallationTypes[0],
740 &kInstallationTypes[arraysize(kInstallationTypes)], 728 &kInstallationTypes[arraysize(kInstallationTypes)],
741 *type), 729 *type),
742 &kInstallationTypes[arraysize(kInstallationTypes)]) 730 &kInstallationTypes[arraysize(kInstallationTypes)])
743 << "Invalid combination of products found on system (" << *type << ")"; 731 << "Invalid combination of products found on system (" << *type << ")";
744 732
745 return rock_on; 733 return rock_on;
746 } 734 }
747 735
748 // static 736 // static
749 bool InstallationValidator::ValidateInstallationType(bool system_level, 737 bool InstallationValidator::ValidateInstallationType(bool system_level,
750 InstallationType* type) { 738 InstallationType* type) {
751 DCHECK(type); 739 DCHECK(type);
752 InstallationState machine_state; 740 InstallationState machine_state;
753 741
754 machine_state.Initialize(); 742 machine_state.Initialize();
755 743
756 return ValidateInstallationTypeForState(machine_state, system_level, type); 744 return ValidateInstallationTypeForState(machine_state, system_level, type);
757 } 745 }
758 746
759 } // namespace installer 747 } // namespace installer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698