#include "chrome/browser/extensions/extension_action_runner.h"
#include <memory>
#include <tuple>
#include <vector>
#include "base/auto_reset.h"
#include "base/containers/contains.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/location.h"
#include "base/metrics/histogram_macros.h"
#include "base/ranges/algorithm.h"
#include "base/task/single_thread_task_runner.h"
#include "chrome/browser/extensions/api/extension_action/extension_action_api.h"
#include "chrome/browser/extensions/api/side_panel/side_panel_service.h"
#include "chrome/browser/extensions/extension_tab_util.h"
#include "chrome/browser/extensions/permissions/active_tab_permission_granter.h"
#include "chrome/browser/extensions/permissions/permissions_updater.h"
#include "chrome/browser/extensions/permissions/scripting_permissions_modifier.h"
#include "chrome/browser/extensions/permissions/site_permissions_helper.h"
#include "chrome/browser/extensions/tab_helper.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/extensions/extensions_dialogs.h"
#include "chrome/browser/ui/toolbar/toolbar_actions_model.h"
#include "components/crx_file/id_util.h"
#include "components/sessions/content/session_tab_helper.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h"
#include "extensions/browser/api/declarative_net_request/action_tracker.h"
#include "extensions/browser/api/declarative_net_request/rules_monitor_service.h"
#include "extensions/browser/extension_action.h"
#include "extensions/browser/extension_action_manager.h"
#include "extensions/browser/permissions_manager.h"
#include "extensions/common/api/extension_action/action_info.h"
#include "extensions/common/extension.h"
#include "extensions/common/extension_features.h"
#include "extensions/common/extension_id.h"
#include "extensions/common/extension_set.h"
#include "extensions/common/manifest.h"
#include "extensions/common/permissions/permission_set.h"
#include "extensions/common/permissions/permissions_data.h"
#include "url/origin.h"
namespace {
std::vector<extensions::ExtensionId> GetExtensionIds(
std::vector<const extensions::Extension*> extensions) { … }
}
namespace extensions {
ExtensionActionRunner::PendingScript::PendingScript(
mojom::RunLocation run_location,
ScriptInjectionCallback permit_script)
: … { … }
ExtensionActionRunner::PendingScript::~PendingScript() = default;
ExtensionActionRunner::ExtensionActionRunner(content::WebContents* web_contents)
: … { … }
ExtensionActionRunner::~ExtensionActionRunner() { … }
ExtensionActionRunner* ExtensionActionRunner::GetForWebContents(
content::WebContents* web_contents) { … }
ExtensionAction::ShowAction ExtensionActionRunner::RunAction(
const Extension* extension,
bool grant_tab_permissions) { … }
void ExtensionActionRunner::GrantTabPermissions(
const std::vector<const Extension*>& extensions) { … }
void ExtensionActionRunner::OnActiveTabPermissionGranted(
const Extension* extension) { … }
void ExtensionActionRunner::OnWebRequestBlocked(const Extension* extension) { … }
int ExtensionActionRunner::GetBlockedActions(
const ExtensionId& extension_id) const { … }
bool ExtensionActionRunner::WantsToRun(const Extension* extension) { … }
void ExtensionActionRunner::RunForTesting(const Extension* extension) { … }
PermissionsData::PageAccess
ExtensionActionRunner::RequiresUserConsentForScriptInjection(
const Extension* extension,
mojom::InjectionType type) { … }
void ExtensionActionRunner::RequestScriptInjection(
const Extension* extension,
mojom::RunLocation run_location,
ScriptInjectionCallback callback) { … }
void ExtensionActionRunner::RunPendingScriptsForExtension(
const Extension* extension) { … }
void ExtensionActionRunner::OnRequestScriptInjectionPermission(
const ExtensionId& extension_id,
mojom::InjectionType script_type,
mojom::RunLocation run_location,
mojom::LocalFrameHost::RequestScriptInjectionPermissionCallback callback) { … }
void ExtensionActionRunner::NotifyChange(const Extension* extension) { … }
void ExtensionActionRunner::LogUMA() const { … }
void ExtensionActionRunner::ShowReloadPageBubble(
const std::vector<ExtensionId>& extension_ids) { … }
void ExtensionActionRunner::OnReloadPageBubbleAccepted() { … }
void ExtensionActionRunner::RunBlockedActions(const Extension* extension) { … }
void ExtensionActionRunner::DidFinishNavigation(
content::NavigationHandle* navigation_handle) { … }
void ExtensionActionRunner::WebContentsDestroyed() { … }
void ExtensionActionRunner::OnExtensionUnloaded(
content::BrowserContext* browser_context,
const Extension* extension,
UnloadedExtensionReason reason) { … }
void ExtensionActionRunner::RunCallbackOnPendingScript(
const PendingScriptList& list,
bool granted) { … }
}