<commit_before>// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Implementation of the installation validator.

#include "chrome/installer/util/installation_validator.h"

#include <algorithm>

#include "base/logging.h"
#include "base/version.h"
#include "chrome/installer/util/browser_distribution.h"
#include "chrome/installer/util/helper.h"
#include "chrome/installer/util/installation_state.h"

namespace installer {

BrowserDistribution::Type
    InstallationValidator::ChromeRules::distribution_type() const {
  return BrowserDistribution::CHROME_BROWSER;
}

void InstallationValidator::ChromeRules::AddProductSwitchExpectations(
    const InstallationState& machine_state,
    bool system_install,
    const ProductState& product_state,
    SwitchExpectations* expectations) const {
  const bool is_multi_install =
      product_state.uninstall_command().HasSwitch(switches::kMultiInstall);

  // --chrome should be present iff --multi-install.
  expectations->push_back(std::make_pair(std::string(switches::kChrome),
                                         is_multi_install));
  // --chrome-frame --ready-mode should be present iff CF in ready mode.
  const ProductState* cf_state =
      machine_state.GetProductState(system_install,
                                    BrowserDistribution::CHROME_FRAME);
  const bool ready_mode =
      cf_state != NULL &&
      cf_state->uninstall_command().HasSwitch(switches::kChromeFrameReadyMode);
  expectations->push_back(std::make_pair(std::string(switches::kChromeFrame),
                                         ready_mode));
  expectations->push_back(
      std::make_pair(std::string(switches::kChromeFrameReadyMode), ready_mode));
}

BrowserDistribution::Type
    InstallationValidator::ChromeFrameRules::distribution_type() const {
  return BrowserDistribution::CHROME_FRAME;
}

void InstallationValidator::ChromeFrameRules::AddProductSwitchExpectations(
    const InstallationState& machine_state,
    bool system_install,
    const ProductState& product_state,
    SwitchExpectations* expectations) const {
  // --chrome-frame must be present.<commit_msg>Allow --chrome in a single-install's uninstall and rename commands so that mini installer tests don't cry when they evaluate M10 builds.<commit_after>// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Implementation of the installation validator.

#include "chrome/installer/util/installation_validator.h"

#include <algorithm>

#include "base/logging.h"
#include "base/version.h"
#include "chrome/installer/util/browser_distribution.h"
#include "chrome/installer/util/helper.h"
#include "chrome/installer/util/installation_state.h"

namespace installer {

BrowserDistribution::Type
    InstallationValidator::ChromeRules::distribution_type() const {
  return BrowserDistribution::CHROME_BROWSER;
}

void InstallationValidator::ChromeRules::AddProductSwitchExpectations(
    const InstallationState& machine_state,
    bool system_install,
    const ProductState& product_state,
    SwitchExpectations* expectations) const {
  const bool is_multi_install =
      product_state.uninstall_command().HasSwitch(switches::kMultiInstall);

  // --chrome should be present iff --multi-install.  This wasn't the case in
  // Chrome 10 (between r68996 and r72497), though, so consider it optional.

  // --chrome-frame --ready-mode should be present iff CF in ready mode.
  const ProductState* cf_state =
      machine_state.GetProductState(system_install,
                                    BrowserDistribution::CHROME_FRAME);
  const bool ready_mode =
      cf_state != NULL &&
      cf_state->uninstall_command().HasSwitch(switches::kChromeFrameReadyMode);
  expectations->push_back(std::make_pair(std::string(switches::kChromeFrame),
                                         ready_mode));
  expectations->push_back(
      std::make_pair(std::string(switches::kChromeFrameReadyMode), ready_mode));
}

BrowserDistribution::Type
    InstallationValidator::ChromeFrameRules::distribution_type() const {
  return BrowserDistribution::CHROME_FRAME;
}

void InstallationValidator::ChromeFrameRules::AddProductSwitchExpectations(
    const InstallationState& machine_state,
    bool system_install,
    const ProductState& product_state,
    SwitchExpectations* expectations) const {
  // --chrome-frame must be present.
{'fraction_non_alphanumeric': 0.09500875656742556, 'fraction_numerical': 0.004816112084063047, 'mean_word_length': 4.294322132097335, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6880594', 'n_tokens_mistral': 1281, 'n_tokens_neox': 1227, 'n_words': 289}