#include "extensions/common/permissions/permissions_data.h"
#include <memory>
#include <utility>
#include "base/command_line.h"
#include "base/containers/contains.h"
#include "base/feature_list.h"
#include "base/memory/stack_allocated.h"
#include "base/no_destructor.h"
#include "content/public/common/url_constants.h"
#include "extensions/common/constants.h"
#include "extensions/common/error_utils.h"
#include "extensions/common/extension_features.h"
#include "extensions/common/extension_id.h"
#include "extensions/common/extension_urls.h"
#include "extensions/common/extensions_client.h"
#include "extensions/common/manifest.h"
#include "extensions/common/manifest_constants.h"
#include "extensions/common/permissions/permission_message_provider.h"
#include "extensions/common/switches.h"
#include "extensions/common/url_pattern_set.h"
#include "url/gurl.h"
#include "url/origin.h"
#include "url/url_constants.h"
APIPermissionID;
namespace extensions {
namespace {
PermissionsData::PolicyDelegate* g_policy_delegate = …;
struct URLPatternAccessSet { … };
struct ContextPermissions { … };
ContextPermissionsMap;
base::Lock& GetContextPermissionsLock() { … }
ContextPermissions& GetContextPermissions(int context_id) { … }
class AutoLockOnValidThread { … };
}
PermissionsData::PermissionsData(
const ExtensionId& extension_id,
Manifest::Type manifest_type,
mojom::ManifestLocation location,
std::unique_ptr<const PermissionSet> initial_permissions)
: … { … }
PermissionsData::~PermissionsData() { … }
void PermissionsData::SetPolicyDelegate(PolicyDelegate* delegate) { … }
bool PermissionsData::CanExecuteScriptEverywhere(
const ExtensionId& extension_id,
mojom::ManifestLocation location) { … }
bool PermissionsData::IsRestrictedUrl(const GURL& document_url,
std::string* error) const { … }
bool PermissionsData::AllUrlsIncludesChromeUrls(
const ExtensionId& extension_id) { … }
bool PermissionsData::UsesDefaultPolicyHostRestrictions() const { … }
URLPatternSet PermissionsData::GetDefaultPolicyBlockedHosts(int context_id) { … }
URLPatternSet PermissionsData::GetDefaultPolicyAllowedHosts(int context_id) { … }
URLPatternSet PermissionsData::policy_blocked_hosts() const { … }
URLPatternSet PermissionsData::policy_allowed_hosts() const { … }
void PermissionsData::BindToCurrentThread() const { … }
void PermissionsData::SetContextId(int context_id) const { … }
void PermissionsData::SetPermissions(
std::unique_ptr<const PermissionSet> active,
std::unique_ptr<const PermissionSet> withheld) const { … }
void PermissionsData::SetPolicyHostRestrictions(
const URLPatternSet& policy_blocked_hosts,
const URLPatternSet& policy_allowed_hosts) const { … }
void PermissionsData::SetUsesDefaultHostRestrictions() const { … }
void PermissionsData::SetDefaultPolicyHostRestrictions(
int context_id,
const URLPatternSet& default_policy_blocked_hosts,
const URLPatternSet& default_policy_allowed_hosts) { … }
void PermissionsData::SetUserHostRestrictions(
int context_id,
URLPatternSet user_blocked_hosts,
URLPatternSet user_allowed_hosts) { … }
URLPatternSet PermissionsData::GetUserAllowedHosts(int context_id) { … }
URLPatternSet PermissionsData::GetUserBlockedHosts(int context_id) { … }
URLPatternSet PermissionsData::GetUserBlockedHosts() const { … }
void PermissionsData::UpdateTabSpecificPermissions(
int tab_id,
const PermissionSet& permissions) const { … }
void PermissionsData::ClearTabSpecificPermissions(int tab_id) const { … }
bool PermissionsData::HasTabPermissionsForSecurityOrigin(
int tab_id,
const GURL& url) const { … }
bool PermissionsData::HasAPIPermission(APIPermissionID permission) const { … }
bool PermissionsData::HasAPIPermission(
const std::string& permission_name) const { … }
bool PermissionsData::HasAPIPermissionForTab(int tab_id,
APIPermissionID permission) const { … }
bool PermissionsData::CheckAPIPermissionWithParam(
APIPermissionID permission,
const APIPermission::CheckParam* param) const { … }
URLPatternSet PermissionsData::GetEffectiveHostPermissions() const { … }
bool PermissionsData::HasHostPermission(const GURL& url) const { … }
PermissionMessages PermissionsData::GetPermissionMessages() const { … }
PermissionMessages PermissionsData::GetNewPermissionMessages(
const PermissionSet& granted_permissions) const { … }
bool PermissionsData::CanAccessPage(const GURL& document_url,
int tab_id,
std::string* error) const { … }
PermissionsData::PageAccess PermissionsData::GetPageAccess(
const GURL& document_url,
int tab_id,
std::string* error) const { … }
bool PermissionsData::CanRunContentScriptOnPage(const GURL& document_url,
int tab_id,
std::string* error) const { … }
PermissionsData::PageAccess PermissionsData::GetContentScriptAccess(
const GURL& document_url,
int tab_id,
std::string* error) const { … }
bool PermissionsData::CanCaptureVisiblePage(
const GURL& document_url,
int tab_id,
std::string* error,
CaptureRequirement capture_requirement) const { … }
const PermissionSet* PermissionsData::GetTabSpecificPermissions(
int tab_id) const { … }
bool PermissionsData::IsPolicyBlockedHostUnsafe(const GURL& url) const { … }
PermissionsData::PageAccess PermissionsData::CanRunOnPage(
const GURL& document_url,
const URLPatternSet& permitted_url_patterns,
const URLPatternSet& withheld_url_patterns,
const URLPatternSet* tab_url_patterns,
std::string* error) const { … }
}