#include "extensions/browser/test_extensions_browser_client.h"
#include "base/values.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "content/public/browser/browser_context.h"
#include "extensions/browser/extension_host_delegate.h"
#include "extensions/browser/updater/null_extension_cache.h"
#include "extensions/buildflags/buildflags.h"
#include "extensions/common/extension_id.h"
#include "services/network/public/mojom/url_loader.mojom.h"
#include "ui/base/l10n/l10n_util.h"
#if BUILDFLAG(ENABLE_EXTENSIONS)
#include "extensions/browser/test_runtime_api_delegate.h"
#endif
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chromeos/ash/components/login/login_state/login_state.h"
#endif
BrowserContext;
namespace extensions {
TestExtensionsBrowserClient::TestExtensionsBrowserClient(
BrowserContext* main_context)
: … { … }
TestExtensionsBrowserClient::TestExtensionsBrowserClient()
: … { … }
TestExtensionsBrowserClient::~TestExtensionsBrowserClient() = default;
void TestExtensionsBrowserClient::SetUpdateClientFactory(
base::RepeatingCallback<update_client::UpdateClient*(void)> factory) { … }
void TestExtensionsBrowserClient::SetMainContext(
content::BrowserContext* main_context) { … }
void TestExtensionsBrowserClient::SetIncognitoContext(BrowserContext* context) { … }
bool TestExtensionsBrowserClient::IsShuttingDown() { … }
bool TestExtensionsBrowserClient::AreExtensionsDisabled(
const base::CommandLine& command_line,
BrowserContext* context) { … }
bool TestExtensionsBrowserClient::IsValidContext(void* context) { … }
bool TestExtensionsBrowserClient::IsSameContext(BrowserContext* first,
BrowserContext* second) { … }
bool TestExtensionsBrowserClient::HasOffTheRecordContext(
BrowserContext* context) { … }
BrowserContext* TestExtensionsBrowserClient::GetOffTheRecordContext(
BrowserContext* context) { … }
BrowserContext* TestExtensionsBrowserClient::GetOriginalContext(
BrowserContext* context) { … }
content::BrowserContext*
TestExtensionsBrowserClient::GetContextRedirectedToOriginal(
content::BrowserContext* context,
bool force_guest_profile) { … }
content::BrowserContext* TestExtensionsBrowserClient::GetContextOwnInstance(
content::BrowserContext* context,
bool force_guest_profile) { … }
content::BrowserContext* TestExtensionsBrowserClient::GetContextForOriginalOnly(
content::BrowserContext* context,
bool force_guest_profile) { … }
bool TestExtensionsBrowserClient::AreExtensionsDisabledForContext(
content::BrowserContext* context) { … }
#if BUILDFLAG(IS_CHROMEOS_ASH)
std::string TestExtensionsBrowserClient::GetUserIdHashFromContext(
content::BrowserContext* context) {
if (context != main_context_ || !ash::LoginState::IsInitialized())
return "";
return ash::LoginState::Get()->primary_user_hash();
}
#endif
#if BUILDFLAG(IS_CHROMEOS_LACROS)
bool TestExtensionsBrowserClient::IsFromMainProfile(
content::BrowserContext* context) {
return context == main_context_;
}
#endif
bool TestExtensionsBrowserClient::IsGuestSession(
BrowserContext* context) const { … }
bool TestExtensionsBrowserClient::IsExtensionIncognitoEnabled(
const ExtensionId& extension_id,
content::BrowserContext* context) const { … }
bool TestExtensionsBrowserClient::CanExtensionCrossIncognito(
const extensions::Extension* extension,
content::BrowserContext* context) const { … }
base::FilePath TestExtensionsBrowserClient::GetBundleResourcePath(
const network::ResourceRequest& request,
const base::FilePath& extension_resources_path,
int* resource_id) const { … }
void TestExtensionsBrowserClient::LoadResourceFromResourceBundle(
const network::ResourceRequest& request,
mojo::PendingReceiver<network::mojom::URLLoader> loader,
const base::FilePath& resource_relative_path,
int resource_id,
scoped_refptr<net::HttpResponseHeaders> headers,
mojo::PendingRemote<network::mojom::URLLoaderClient> client) { … }
bool TestExtensionsBrowserClient::AllowCrossRendererResourceLoad(
const network::ResourceRequest& request,
network::mojom::RequestDestination destination,
ui::PageTransition page_transition,
int child_id,
bool is_incognito,
const Extension* extension,
const ExtensionSet& extensions,
const ProcessMap& process_map,
const GURL& upstream_url) { … }
PrefService* TestExtensionsBrowserClient::GetPrefServiceForContext(
BrowserContext* context) { … }
void TestExtensionsBrowserClient::GetEarlyExtensionPrefsObservers(
content::BrowserContext* context,
std::vector<EarlyExtensionPrefsObserver*>* observers) const { … }
ProcessManagerDelegate* TestExtensionsBrowserClient::GetProcessManagerDelegate()
const { … }
mojo::PendingRemote<network::mojom::URLLoaderFactory>
TestExtensionsBrowserClient::GetControlledFrameEmbedderURLLoader(
const url::Origin& app_origin,
int frame_tree_node_id,
content::BrowserContext* browser_context) { … }
std::unique_ptr<ExtensionHostDelegate>
TestExtensionsBrowserClient::CreateExtensionHostDelegate() { … }
bool TestExtensionsBrowserClient::DidVersionUpdate(BrowserContext* context) { … }
void TestExtensionsBrowserClient::PermitExternalProtocolHandler() { … }
bool TestExtensionsBrowserClient::IsInDemoMode() { … }
bool TestExtensionsBrowserClient::IsScreensaverInDemoMode(
const std::string& app_id) { … }
bool TestExtensionsBrowserClient::IsRunningInForcedAppMode() { … }
bool TestExtensionsBrowserClient::IsAppModeForcedForApp(
const ExtensionId& extension_id) { … }
bool TestExtensionsBrowserClient::IsLoggedInAsPublicAccount() { … }
ExtensionSystemProvider*
TestExtensionsBrowserClient::GetExtensionSystemFactory() { … }
void TestExtensionsBrowserClient::RegisterBrowserInterfaceBindersForFrame(
mojo::BinderMapWithContext<content::RenderFrameHost*>* binder_map,
content::RenderFrameHost* render_frame_host,
const Extension* extension) const { … }
std::unique_ptr<RuntimeAPIDelegate>
TestExtensionsBrowserClient::CreateRuntimeAPIDelegate(
content::BrowserContext* context) const { … }
const ComponentExtensionResourceManager*
TestExtensionsBrowserClient::GetComponentExtensionResourceManager() { … }
void TestExtensionsBrowserClient::BroadcastEventToRenderers(
events::HistogramValue histogram_value,
const std::string& event_name,
base::Value::List args,
bool dispatch_to_off_the_record_profiles) { … }
ExtensionCache* TestExtensionsBrowserClient::GetExtensionCache() { … }
bool TestExtensionsBrowserClient::IsBackgroundUpdateAllowed() { … }
bool TestExtensionsBrowserClient::IsMinBrowserVersionSupported(
const std::string& min_version) { … }
ExtensionWebContentsObserver*
TestExtensionsBrowserClient::GetExtensionWebContentsObserver(
content::WebContents* web_contents) { … }
KioskDelegate* TestExtensionsBrowserClient::GetKioskDelegate() { … }
scoped_refptr<update_client::UpdateClient>
TestExtensionsBrowserClient::CreateUpdateClient(
content::BrowserContext* context) { … }
bool TestExtensionsBrowserClient::IsLockScreenContext(
content::BrowserContext* context) { … }
std::string TestExtensionsBrowserClient::GetApplicationLocale() { … }
}