chromium/chrome/browser/google/google_brand.cc

// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/google/google_brand.h"

#include <optional>
#include <string>
#include <string_view>

#include "base/containers/contains.h"
#include "base/containers/fixed_flat_set.h"
#include "base/no_destructor.h"
#include "base/ranges/algorithm.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/installer/util/google_update_settings.h"

#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chrome/browser/google/google_brand_chromeos.h"
#endif

namespace google_brand {

const char* g_brand_for_testing =;

// Global functions -----------------------------------------------------------

#if BUILDFLAG(IS_WIN)

bool GetBrand(std::string* brand) {
  if (g_brand_for_testing) {
    brand->assign(g_brand_for_testing);
    return true;
  }

  // Cache brand code value, since it is queried a lot and registry queries are
  // slow enough to actually affect top-level metrics like
  // Omnibox.CharTypedToRepaintLatency.
  static const base::NoDestructor<std::optional<std::string>> brand_code(
      []() -> std::optional<std::string> {
        std::wstring brandw;
        if (!GoogleUpdateSettings::GetBrand(&brandw))
          return std::nullopt;
        return base::WideToASCII(brandw);
      }());
  if (!brand_code->has_value())
    return false;
  brand->assign(**brand_code);
  return true;
}

bool GetReactivationBrand(std::string* brand) {
  std::wstring brandw;
  bool ret = GoogleUpdateSettings::GetReactivationBrand(&brandw);
  if (ret)
    brand->assign(base::WideToASCII(brandw));
  return ret;
}

#elif !BUILDFLAG(IS_MAC)

bool GetBrand(std::string* brand) {}

bool GetReactivationBrand(std::string* brand) {}

#endif

bool GetRlzBrand(std::string* brand) {}

bool IsOrganic(const std::string& brand) {}

bool IsOrganicFirstRun(const std::string& brand) {}

bool IsInternetCafeBrandCode(const std::string& brand) {}

bool IsEnterprise(const std::string& brand) {}

// BrandForTesting ------------------------------------------------------------

BrandForTesting::BrandForTesting(const std::string& brand) :{}

BrandForTesting::~BrandForTesting() {}

}  // namespace google_brand