#include "extensions/browser/extensions_browser_client.h"
#include <memory>
#include <optional>
#include "base/files/file_path.h"
#include "base/functional/callback.h"
#include "base/logging.h"
#include "base/memory/ref_counted_memory.h"
#include "components/update_client/update_client.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/site_instance.h"
#include "content/public/browser/storage_partition_config.h"
#include "extensions/browser/extension_api_frame_id_map.h"
#include "extensions/browser/extension_error.h"
#include "extensions/browser/updater/scoped_extension_updater_keep_alive.h"
#include "extensions/common/constants.h"
#include "extensions/common/extension_id.h"
#include "extensions/common/permissions/permission_set.h"
#include "url/gurl.h"
namespace extensions {
namespace {
ExtensionsBrowserClient* g_extension_browser_client = …;
}
ExtensionsBrowserClient::ExtensionsBrowserClient() = default;
ExtensionsBrowserClient::~ExtensionsBrowserClient() = default;
ExtensionsBrowserClient* ExtensionsBrowserClient::Get() { … }
void ExtensionsBrowserClient::Set(ExtensionsBrowserClient* client) { … }
void ExtensionsBrowserClient::RegisterExtensionFunctions(
ExtensionFunctionRegistry* registry) { … }
void ExtensionsBrowserClient::AddAPIProvider(
std::unique_ptr<ExtensionsBrowserAPIProvider> provider) { … }
void ExtensionsBrowserClient::StartTearDown() { … }
scoped_refptr<update_client::UpdateClient>
ExtensionsBrowserClient::CreateUpdateClient(content::BrowserContext* context) { … }
std::unique_ptr<ScopedExtensionUpdaterKeepAlive>
ExtensionsBrowserClient::CreateUpdaterKeepAlive(
content::BrowserContext* context) { … }
void ExtensionsBrowserClient::ReportError(
content::BrowserContext* context,
std::unique_ptr<ExtensionError> error) { … }
bool ExtensionsBrowserClient::IsActivityLoggingEnabled(
content::BrowserContext* context) { … }
void ExtensionsBrowserClient::GetTabAndWindowIdForWebContents(
content::WebContents* web_contents,
int* tab_id,
int* window_id) { … }
bool ExtensionsBrowserClient::IsExtensionEnabled(
const ExtensionId& extension_id,
content::BrowserContext* context) const { … }
bool ExtensionsBrowserClient::IsWebUIAllowedToMakeNetworkRequests(
const url::Origin& origin) { … }
network::mojom::NetworkContext*
ExtensionsBrowserClient::GetSystemNetworkContext() { … }
UserScriptListener* ExtensionsBrowserClient::GetUserScriptListener() { … }
void ExtensionsBrowserClient::SignalContentScriptsLoaded(
content::BrowserContext* context) { … }
std::string ExtensionsBrowserClient::GetUserAgent() const { … }
bool ExtensionsBrowserClient::ShouldSchemeBypassNavigationChecks(
const std::string& scheme) const { … }
base::FilePath ExtensionsBrowserClient::GetSaveFilePath(
content::BrowserContext* context) { … }
void ExtensionsBrowserClient::SetLastSaveFilePath(
content::BrowserContext* context,
const base::FilePath& path) { … }
bool ExtensionsBrowserClient::HasIsolatedStorage(
const ExtensionId& extension_id,
content::BrowserContext* context) { … }
bool ExtensionsBrowserClient::IsScreenshotRestricted(
content::WebContents* web_contents) const { … }
bool ExtensionsBrowserClient::IsValidTabId(content::BrowserContext* context,
int tab_id) const { … }
void ExtensionsBrowserClient::NotifyExtensionApiTabExecuteScript(
content::BrowserContext* context,
const ExtensionId& extension_id,
const std::string& code) const { … }
bool ExtensionsBrowserClient::IsExtensionTelemetryServiceEnabled(
content::BrowserContext* context) const { … }
void ExtensionsBrowserClient::NotifyExtensionApiDeclarativeNetRequest(
content::BrowserContext* context,
const ExtensionId& extension_id,
const std::vector<api::declarative_net_request::Rule>& rules) const { … }
void ExtensionsBrowserClient::
NotifyExtensionDeclarativeNetRequestRedirectAction(
content::BrowserContext* context,
const ExtensionId& extension_id,
const GURL& request_url,
const GURL& redirect_url) const { … }
void ExtensionsBrowserClient::NotifyExtensionRemoteHostContacted(
content::BrowserContext* context,
const ExtensionId& extension_id,
const GURL& url) const { … }
bool ExtensionsBrowserClient::IsUsbDeviceAllowedByPolicy(
content::BrowserContext* context,
const ExtensionId& extension_id,
int vendor_id,
int product_id) const { … }
void ExtensionsBrowserClient::GetFavicon(
content::BrowserContext* browser_context,
const Extension* extension,
const GURL& url,
base::CancelableTaskTracker* tracker,
base::OnceCallback<void(scoped_refptr<base::RefCountedMemory> bitmap_data)>
callback) const { … }
std::vector<content::BrowserContext*>
ExtensionsBrowserClient::GetRelatedContextsForExtension(
content::BrowserContext* browser_context,
const Extension& extension) const { … }
void ExtensionsBrowserClient::AddAdditionalAllowedHosts(
const PermissionSet& desired_permissions,
PermissionSet* granted_permissions) const { … }
void ExtensionsBrowserClient::AddAPIActionToActivityLog(
content::BrowserContext* browser_context,
const ExtensionId& extension_id,
const std::string& call_name,
base::Value::List args,
const std::string& extra) { … }
void ExtensionsBrowserClient::AddEventToActivityLog(
content::BrowserContext* context,
const ExtensionId& extension_id,
const std::string& call_name,
base::Value::List args,
const std::string& extra) { … }
void ExtensionsBrowserClient::AddDOMActionToActivityLog(
content::BrowserContext* browser_context,
const ExtensionId& extension_id,
const std::string& call_name,
base::Value::List args,
const GURL& url,
const std::u16string& url_title,
int call_type) { … }
void ExtensionsBrowserClient::GetWebViewStoragePartitionConfig(
content::BrowserContext* browser_context,
content::SiteInstance* owner_site_instance,
const std::string& partition_name,
bool in_memory,
base::OnceCallback<void(std::optional<content::StoragePartitionConfig>)>
callback) { … }
void ExtensionsBrowserClient::CreatePasswordReuseDetectionManager(
content::WebContents* web_contents) const { … }
media_device_salt::MediaDeviceSaltService*
ExtensionsBrowserClient::GetMediaDeviceSaltService(
content::BrowserContext* context) { … }
}