chromium/chrome/browser/extensions/api/runtime/chrome_runtime_api_delegate.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/extensions/api/runtime/chrome_runtime_api_delegate.h"

#include <memory>
#include <string>
#include <utility>
#include <vector>

#include "base/functional/bind.h"
#include "base/lazy_instance.h"
#include "base/location.h"
#include "base/metrics/histogram_macros.h"
#include "base/task/single_thread_task_runner.h"
#include "base/time/tick_clock.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_tab_util.h"
#include "chrome/browser/extensions/updater/extension_updater.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_navigator.h"
#include "chrome/browser/ui/browser_navigator_params.h"
#include "components/update_client/update_query_params.h"
#include "extensions/browser/extension_system.h"
#include "extensions/browser/warning_service.h"
#include "extensions/browser/warning_set.h"
#include "extensions/common/api/runtime.h"
#include "extensions/common/constants.h"
#include "extensions/common/extension_id.h"
#include "extensions/common/manifest.h"
#include "net/base/backoff_entry.h"

#if BUILDFLAG(IS_CHROMEOS)
#include "chromeos/components/kiosk/kiosk_utils.h"
#include "chromeos/dbus/power/power_manager_client.h"
#include "third_party/cros_system_api/dbus/service_constants.h"
#endif

Extension;
ExtensionSystem;
ExtensionUpdater;

PlatformInfo;

namespace {

// If an extension reloads itself within this many milliseconds of reloading
// itself, the reload is considered suspiciously fast.
const int kFastReloadTime =;

// Same as above, but we shorten the fast reload interval for unpacked
// extensions for ease of testing.
const int kUnpackedFastReloadTime =;

// A holder class for the policy we use for exponential backoff of update check
// requests.
class BackoffPolicy {};

// We use a LazyInstance since one of the the policy values references an
// extern symbol, which would cause a static initializer to be generated if we
// just declared the policy struct as a static variable.
base::LazyInstance<BackoffPolicy>::DestructorAtExit g_backoff_policy =;

BackoffPolicy::BackoffPolicy() {}

BackoffPolicy::~BackoffPolicy() = default;

// static
const net::BackoffEntry::Policy* BackoffPolicy::Get() {}

const base::TickClock* g_test_clock =;

}  // namespace

struct ChromeRuntimeAPIDelegate::UpdateCheckInfo {};

ChromeRuntimeAPIDelegate::ChromeRuntimeAPIDelegate(
    content::BrowserContext* context)
    :{}

ChromeRuntimeAPIDelegate::~ChromeRuntimeAPIDelegate() = default;

// static
void ChromeRuntimeAPIDelegate::set_tick_clock_for_tests(
    const base::TickClock* clock) {}

void ChromeRuntimeAPIDelegate::AddUpdateObserver(
    extensions::UpdateObserver* observer) {}

void ChromeRuntimeAPIDelegate::RemoveUpdateObserver(
    extensions::UpdateObserver* observer) {}

void ChromeRuntimeAPIDelegate::ReloadExtension(
    const extensions::ExtensionId& extension_id) {}

bool ChromeRuntimeAPIDelegate::CheckForUpdates(
    const extensions::ExtensionId& extension_id,
    UpdateCheckCallback callback) {}

void ChromeRuntimeAPIDelegate::OpenURL(const GURL& uninstall_url) {}

bool ChromeRuntimeAPIDelegate::GetPlatformInfo(PlatformInfo* info) {}

bool ChromeRuntimeAPIDelegate::RestartDevice(std::string* error_message) {}

bool ChromeRuntimeAPIDelegate::OpenOptionsPage(
    const Extension* extension,
    content::BrowserContext* browser_context) {}

void ChromeRuntimeAPIDelegate::OnExtensionUpdateFound(
    const extensions::ExtensionId& extension_id,
    const base::Version& version) {}

void ChromeRuntimeAPIDelegate::OnExtensionInstalled(
    content::BrowserContext* browser_context,
    const Extension* extension,
    bool is_update) {}

void ChromeRuntimeAPIDelegate::UpdateCheckComplete(
    const extensions::ExtensionId& extension_id) {}

void ChromeRuntimeAPIDelegate::CallUpdateCallbacks(
    const extensions::ExtensionId& extension_id,
    const UpdateCheckResult& result) {}