#include "extensions/browser/renderer_startup_helper.h"
#include <string>
#include <utility>
#include <vector>
#include "base/containers/adapters.h"
#include "base/containers/contains.h"
#include "base/debug/dump_without_crashing.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/ptr_util.h"
#include "base/memory/raw_ptr.h"
#include "base/strings/string_util.h"
#include "base/task/thread_pool.h"
#include "base/unguessable_token.h"
#include "base/values.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/render_process_host.h"
#include "extensions/browser/bad_message.h"
#include "extensions/browser/extension_function_dispatcher.h"
#include "extensions/browser/extension_prefs.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_util.h"
#include "extensions/browser/extensions_browser_client.h"
#include "extensions/browser/l10n_file_util.h"
#include "extensions/browser/network_permissions_updater.h"
#include "extensions/browser/service_worker/service_worker_task_queue.h"
#include "extensions/browser/user_script_world_configuration_manager.h"
#include "extensions/common/extension_id.h"
#include "extensions/common/extension_l10n_util.h"
#include "extensions/common/extension_set.h"
#include "extensions/common/extensions_client.h"
#include "extensions/common/features/feature_channel.h"
#include "extensions/common/features/feature_developer_mode_only.h"
#include "extensions/common/features/feature_session_type.h"
#include "extensions/common/manifest_handlers/background_info.h"
#include "extensions/common/manifest_handlers/default_locale_handler.h"
#include "extensions/common/manifest_handlers/incognito_info.h"
#include "extensions/common/manifest_handlers/shared_module_info.h"
#include "extensions/common/message_bundle.h"
#include "extensions/common/permissions/permissions_data.h"
#include "ipc/ipc_channel_proxy.h"
#include "ui/base/webui/web_ui_util.h"
#include "url/origin.h"
#if BUILDFLAG(ENABLE_GUEST_VIEW)
#include "extensions/browser/guest_view/web_view/web_view_guest.h"
#include "extensions/browser/guest_view/web_view/web_view_renderer_state.h"
#endif
namespace extensions {
namespace {
std::optional<base::UnguessableToken> GetActivationTokenForWorkerBasedExtension(
content::BrowserContext* browser_context,
const Extension& extension) { … }
BrowserContext;
std::optional<base::UnguessableToken> GetWorkerActivationToken(
BrowserContext* browser_context,
const Extension& extension) { … }
PermissionSet CreatePermissionSet(const PermissionSet& set) { … }
mojom::ExtensionLoadedParamsPtr CreateExtensionLoadedParams(
const Extension& extension,
bool include_tab_permissions,
BrowserContext* browser_context) { … }
base::flat_map<std::string, std::string> ToFlatMap(
const std::map<std::string, std::string>& map) { … }
}
RendererStartupHelper::RendererStartupHelper(BrowserContext* browser_context)
: … { … }
RendererStartupHelper::~RendererStartupHelper() { … }
void RendererStartupHelper::OnRenderProcessHostCreated(
content::RenderProcessHost* host) { … }
void RendererStartupHelper::RenderProcessExited(
content::RenderProcessHost* host,
const content::ChildProcessTerminationInfo& info) { … }
void RendererStartupHelper::RenderProcessHostDestroyed(
content::RenderProcessHost* host) { … }
void RendererStartupHelper::InitializeProcess(
content::RenderProcessHost* process) { … }
void RendererStartupHelper::UntrackProcess(
content::RenderProcessHost* process) { … }
void RendererStartupHelper::ActivateExtensionInProcess(
const Extension& extension,
content::RenderProcessHost* process) { … }
void RendererStartupHelper::OnExtensionLoaded(const Extension& extension) { … }
void RendererStartupHelper::OnExtensionUnloaded(const Extension& extension) { … }
void RendererStartupHelper::OnDeveloperModeChanged(bool in_developer_mode) { … }
void RendererStartupHelper::SetUserScriptWorldProperties(
const Extension& extension,
std::optional<std::string> world_id,
std::optional<std::string> csp,
bool enable_messaging) { … }
void RendererStartupHelper::ClearUserScriptWorldProperties(
const Extension& extension,
const std::optional<std::string>& world_id) { … }
mojo::PendingAssociatedRemote<mojom::Renderer>
RendererStartupHelper::BindNewRendererRemote(
content::RenderProcessHost* process) { … }
mojom::Renderer* RendererStartupHelper::GetRenderer(
content::RenderProcessHost* process) { … }
BrowserContext* RendererStartupHelper::GetRendererBrowserContext() { … }
void RendererStartupHelper::AddAPIActionToActivityLog(
const ExtensionId& extension_id,
const std::string& call_name,
base::Value::List args,
const std::string& extra) { … }
void RendererStartupHelper::AddEventToActivityLog(
const ExtensionId& extension_id,
const std::string& call_name,
base::Value::List args,
const std::string& extra) { … }
void RendererStartupHelper::AddDOMActionToActivityLog(
const ExtensionId& extension_id,
const std::string& call_name,
base::Value::List args,
const GURL& url,
const std::u16string& url_title,
int32_t call_type) { … }
void RendererStartupHelper::BindForRenderer(
int process_id,
mojo::PendingAssociatedReceiver<mojom::RendererHost> receiver) { … }
void RendererStartupHelper::GetMessageBundle(
const ExtensionId& extension_id,
GetMessageBundleCallback callback) { … }
RendererStartupHelper* RendererStartupHelperFactory::GetForBrowserContext(
BrowserContext* context) { … }
RendererStartupHelperFactory* RendererStartupHelperFactory::GetInstance() { … }
RendererStartupHelperFactory::RendererStartupHelperFactory()
: … { … }
RendererStartupHelperFactory::~RendererStartupHelperFactory() = default;
std::unique_ptr<KeyedService>
RendererStartupHelperFactory::BuildServiceInstanceForBrowserContext(
BrowserContext* context) const { … }
BrowserContext* RendererStartupHelperFactory::GetBrowserContextToUse(
BrowserContext* context) const { … }
bool RendererStartupHelperFactory::ServiceIsCreatedWithBrowserContext() const { … }
}