#include "chrome/browser/extensions/permissions/permissions_updater.h"
#include <set>
#include <utility>
#include <vector>
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/ref_counted.h"
#include "base/no_destructor.h"
#include "base/values.h"
#include "chrome/browser/extensions/extension_management.h"
#include "chrome/browser/extensions/extension_system_factory.h"
#include "chrome/browser/extensions/permissions/permissions_helpers.h"
#include "chrome/browser/extensions/permissions/scripting_permissions_modifier.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/extensions/api/permissions.h"
#include "chrome/common/webui_url_constants.h"
#include "components/keyed_service/content/browser_context_keyed_service_shutdown_notifier_factory.h"
#include "components/keyed_service/core/keyed_service_shutdown_notifier.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/common/url_constants.h"
#include "extensions/browser/event_router.h"
#include "extensions/browser/event_router_factory.h"
#include "extensions/browser/extension_prefs.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_util.h"
#include "extensions/browser/network_permissions_updater.h"
#include "extensions/browser/permissions_manager.h"
#include "extensions/browser/renderer_startup_helper.h"
#include "extensions/browser/script_injection_tracker.h"
#include "extensions/common/cors_util.h"
#include "extensions/common/extension.h"
#include "extensions/common/extension_features.h"
#include "extensions/common/manifest_handlers/permissions_parser.h"
#include "extensions/common/mojom/permission_set.mojom.h"
#include "extensions/common/mojom/renderer.mojom.h"
#include "extensions/common/permissions/permission_set.h"
#include "extensions/common/permissions/permissions_data.h"
RenderProcessHost;
PackPermissionSet;
namespace extensions {
permissions;
namespace {
class PermissionsUpdaterShutdownNotifierFactory
: public BrowserContextKeyedServiceShutdownNotifierFactory { … };
URLPatternSet GetUserPermittedPatternSet(
content::BrowserContext& browser_context) { … }
}
class PermissionsUpdater::NetworkPermissionsUpdateHelper { … };
void PermissionsUpdater::NetworkPermissionsUpdateHelper::UpdatePermissions(
content::BrowserContext* browser_context,
EventType event_type,
scoped_refptr<const Extension> extension,
const PermissionSet& changed,
base::OnceClosure completion_callback) { … }
void PermissionsUpdater::NetworkPermissionsUpdateHelper::
UpdateDefaultPolicyHostRestrictions(
content::BrowserContext* browser_context,
const URLPatternSet& default_runtime_blocked_hosts,
const URLPatternSet& default_runtime_allowed_hosts) { … }
PermissionsUpdater::NetworkPermissionsUpdateHelper::
NetworkPermissionsUpdateHelper(content::BrowserContext* browser_context,
base::OnceClosure dispatch_event)
: … { … }
PermissionsUpdater::NetworkPermissionsUpdateHelper::
~NetworkPermissionsUpdateHelper() { … }
void PermissionsUpdater::NetworkPermissionsUpdateHelper::OnShutdown() { … }
void PermissionsUpdater::NetworkPermissionsUpdateHelper::
OnOriginAccessUpdated() { … }
PermissionsUpdater::PermissionsUpdater(content::BrowserContext* browser_context)
: … { … }
PermissionsUpdater::PermissionsUpdater(content::BrowserContext* browser_context,
InitFlag init_flag)
: … { … }
PermissionsUpdater::~PermissionsUpdater() { … }
void PermissionsUpdater::GrantOptionalPermissions(
const Extension& extension,
const PermissionSet& permissions,
base::OnceClosure completion_callback) { … }
void PermissionsUpdater::GrantRuntimePermissions(
const Extension& extension,
const PermissionSet& permissions,
base::OnceClosure completion_callback) { … }
void PermissionsUpdater::RevokeOptionalPermissions(
const Extension& extension,
const PermissionSet& permissions,
RemoveType remove_type,
base::OnceClosure completion_callback) { … }
void PermissionsUpdater::RevokeRuntimePermissions(
const Extension& extension,
const PermissionSet& permissions,
base::OnceClosure completion_callback) { … }
void PermissionsUpdater::ApplyPolicyHostRestrictions(
const Extension& extension) { … }
void PermissionsUpdater::SetPolicyHostRestrictions(
const Extension* extension,
const URLPatternSet& runtime_blocked_hosts,
const URLPatternSet& runtime_allowed_hosts) { … }
void PermissionsUpdater::SetUsesDefaultHostRestrictions(
const Extension* extension) { … }
void PermissionsUpdater::SetDefaultPolicyHostRestrictions(
const URLPatternSet& default_runtime_blocked_hosts,
const URLPatternSet& default_runtime_allowed_hosts) { … }
void PermissionsUpdater::RemovePermissionsUnsafe(
const Extension* extension,
const PermissionSet& to_remove) { … }
std::unique_ptr<const PermissionSet>
PermissionsUpdater::GetRevokablePermissions(const Extension* extension) const { … }
void PermissionsUpdater::GrantActivePermissions(const Extension* extension) { … }
void PermissionsUpdater::InitializePermissions(const Extension* extension) { … }
void PermissionsUpdater::AddPermissionsForTesting(
const Extension& extension,
const PermissionSet& permissions) { … }
void PermissionsUpdater::SetPermissions(
const Extension* extension,
std::unique_ptr<const PermissionSet> new_active) { … }
void PermissionsUpdater::NotifyPermissionsUpdated(
content::BrowserContext* browser_context,
EventType event_type,
scoped_refptr<const Extension> extension,
std::unique_ptr<const PermissionSet> changed,
base::OnceClosure completion_callback) { … }
void PermissionsUpdater::NotifyDefaultPolicyHostRestrictionsUpdated(
content::BrowserContext* browser_context,
const URLPatternSet default_runtime_blocked_hosts,
const URLPatternSet default_runtime_allowed_hosts) { … }
void PermissionsUpdater::AddPermissionsImpl(
const Extension& extension,
const PermissionSet& active_permissions_to_add,
int prefs_permissions_store_mask,
const PermissionSet& permissions_to_add_to_prefs,
base::OnceClosure completion_callback) { … }
void PermissionsUpdater::RemovePermissionsImpl(
const Extension& extension,
std::unique_ptr<const PermissionSet> new_active_permissions,
const PermissionSet& permissions_to_remove_from_prefs,
int prefs_permissions_store_mask,
base::OnceClosure completion_callback) { … }
void PermissionsUpdater::EnsureAssociatedFactoryBuilt() { … }
}