#include "chrome/browser/extensions/updater/chrome_update_client_config.h"
#include <algorithm>
#include <set>
#include <string>
#include <utility>
#include <vector>
#include "base/command_line.h"
#include "base/containers/flat_map.h"
#include "base/files/file_path.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/scoped_refptr.h"
#include "base/no_destructor.h"
#include "base/path_service.h"
#include "base/scoped_observation.h"
#include "base/task/sequenced_task_runner.h"
#include "base/time/time.h"
#include "base/version.h"
#include "chrome/browser/component_updater/component_updater_utils.h"
#include "chrome/browser/extensions/updater/extension_update_client_command_line_config_policy.h"
#include "chrome/browser/extensions/updater/extension_updater_switches.h"
#include "chrome/browser/google/google_brand.h"
#include "chrome/browser/update_client/chrome_update_query_params_delegate.h"
#include "chrome/common/channel_info.h"
#include "chrome/common/chrome_paths.h"
#include "components/prefs/pref_service.h"
#include "components/services/patch/content/patch_service.h"
#include "components/services/unzip/content/unzip_service.h"
#include "components/update_client/activity_data_service.h"
#include "components/update_client/crx_downloader_factory.h"
#include "components/update_client/net/network_chromium.h"
#include "components/update_client/patch/patch_impl.h"
#include "components/update_client/patcher.h"
#include "components/update_client/persisted_data.h"
#include "components/update_client/protocol_handler.h"
#include "components/update_client/unzip/unzip_impl.h"
#include "components/update_client/unzipper.h"
#include "components/update_client/update_query_params.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/storage_partition.h"
#include "extensions/browser/extension_prefs.h"
#include "extensions/browser/extension_prefs_observer.h"
namespace extensions {
namespace {
FactoryCallback;
static FactoryCallback& GetFactoryCallback() { … }
class ExtensionActivityDataService final
: public update_client::ActivityDataService,
public ExtensionPrefsObserver { … };
int CalculatePingDays(const base::Time& last_ping_day) { … }
ExtensionActivityDataService::ExtensionActivityDataService(
ExtensionPrefs* extension_prefs)
: … { … }
void ExtensionActivityDataService::GetActiveBits(
const std::vector<std::string>& ids,
base::OnceCallback<void(const std::set<std::string>&)> callback) const { … }
int ExtensionActivityDataService::GetDaysSinceLastActive(
const std::string& id) const { … }
int ExtensionActivityDataService::GetDaysSinceLastRollCall(
const std::string& id) const { … }
void ExtensionActivityDataService::GetAndClearActiveBits(
const std::vector<std::string>& ids,
base::OnceCallback<void(const std::set<std::string>&)> callback) { … }
void ExtensionActivityDataService::OnExtensionPrefsWillBeDestroyed(
ExtensionPrefs* prefs) { … }
}
ChromeUpdateClientConfig::ChromeUpdateClientConfig(
content::BrowserContext* context,
std::optional<GURL> url_override)
: … { … }
ChromeUpdateClientConfig::~ChromeUpdateClientConfig() = default;
base::TimeDelta ChromeUpdateClientConfig::InitialDelay() const { … }
base::TimeDelta ChromeUpdateClientConfig::NextCheckDelay() const { … }
base::TimeDelta ChromeUpdateClientConfig::OnDemandDelay() const { … }
base::TimeDelta ChromeUpdateClientConfig::UpdateDelay() const { … }
std::vector<GURL> ChromeUpdateClientConfig::UpdateUrl() const { … }
std::vector<GURL> ChromeUpdateClientConfig::PingUrl() const { … }
std::string ChromeUpdateClientConfig::GetProdId() const { … }
base::Version ChromeUpdateClientConfig::GetBrowserVersion() const { … }
std::string ChromeUpdateClientConfig::GetChannel() const { … }
std::string ChromeUpdateClientConfig::GetLang() const { … }
std::string ChromeUpdateClientConfig::GetOSLongName() const { … }
base::flat_map<std::string, std::string>
ChromeUpdateClientConfig::ExtraRequestParams() const { … }
std::string ChromeUpdateClientConfig::GetDownloadPreference() const { … }
scoped_refptr<update_client::NetworkFetcherFactory>
ChromeUpdateClientConfig::GetNetworkFetcherFactory() { … }
scoped_refptr<update_client::CrxDownloaderFactory>
ChromeUpdateClientConfig::GetCrxDownloaderFactory() { … }
scoped_refptr<update_client::UnzipperFactory>
ChromeUpdateClientConfig::GetUnzipperFactory() { … }
scoped_refptr<update_client::PatcherFactory>
ChromeUpdateClientConfig::GetPatcherFactory() { … }
bool ChromeUpdateClientConfig::EnabledDeltas() const { … }
bool ChromeUpdateClientConfig::EnabledBackgroundDownloader() const { … }
bool ChromeUpdateClientConfig::EnabledCupSigning() const { … }
PrefService* ChromeUpdateClientConfig::GetPrefService() const { … }
update_client::PersistedData* ChromeUpdateClientConfig::GetPersistedData()
const { … }
bool ChromeUpdateClientConfig::IsPerUserInstall() const { … }
std::unique_ptr<update_client::ProtocolHandlerFactory>
ChromeUpdateClientConfig::GetProtocolHandlerFactory() const { … }
std::optional<bool> ChromeUpdateClientConfig::IsMachineExternallyManaged()
const { … }
update_client::UpdaterStateProvider
ChromeUpdateClientConfig::GetUpdaterStateProvider() const { … }
scoped_refptr<ChromeUpdateClientConfig> ChromeUpdateClientConfig::Create(
content::BrowserContext* context,
std::optional<GURL> update_url_override) { … }
void ChromeUpdateClientConfig::SetChromeUpdateClientConfigFactoryForTesting(
FactoryCallback factory) { … }
std::optional<base::FilePath> ChromeUpdateClientConfig::GetCrxCachePath()
const { … }
bool ChromeUpdateClientConfig::IsConnectionMetered() const { … }
}