#include "extensions/common/manifest_handlers/permissions_parser.h"
#include <memory>
#include <utility>
#include "base/command_line.h"
#include "base/containers/contains.h"
#include "base/memory/ptr_util.h"
#include "base/memory/ref_counted.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "content/public/common/url_constants.h"
#include "extensions/common/error_utils.h"
#include "extensions/common/extension.h"
#include "extensions/common/extensions_client.h"
#include "extensions/common/features/feature.h"
#include "extensions/common/features/feature_provider.h"
#include "extensions/common/manifest.h"
#include "extensions/common/manifest_constants.h"
#include "extensions/common/manifest_handler.h"
#include "extensions/common/permissions/api_permission.h"
#include "extensions/common/permissions/api_permission_set.h"
#include "extensions/common/permissions/permission_set.h"
#include "extensions/common/permissions/permissions_data.h"
#include "extensions/common/switches.h"
#include "extensions/common/url_pattern_set.h"
#include "url/url_constants.h"
APIPermissionID;
namespace extensions {
keys;
errors;
namespace {
struct ManifestPermissions : public Extension::ManifestData { … };
ManifestPermissions::ManifestPermissions(
std::unique_ptr<const PermissionSet> permissions)
: … { … }
ManifestPermissions::~ManifestPermissions() { … }
bool CanSpecifyHostPermission(const Extension* extension,
const URLPattern& pattern,
const APIPermissionSet& permissions) { … }
bool ParseHostsFromJSON(Extension* extension,
const char* key,
std::vector<std::string>* hosts,
std::u16string* error) { … }
void ParseHostPermissions(Extension* extension,
const char* key,
const std::vector<std::string>& host_data,
const APIPermissionSet& api_permissions,
URLPatternSet* host_permissions) { … }
bool ParseHelper(Extension* extension,
const char* key,
APIPermissionSet* api_permissions,
URLPatternSet* host_permissions,
std::u16string* error) { … }
void RemoveNonAllowedOptionalPermissions(
Extension* extension,
APIPermissionSet* optional_api_permissions) { … }
void RemoveOverlappingAPIPermissions(
Extension* extension,
const APIPermissionSet& required_api_permissions,
APIPermissionSet* optional_api_permissions) { … }
void RemoveOverlappingHostPermissions(
Extension* extension,
const URLPatternSet& required_host_permissions,
URLPatternSet* optional_host_permissions) { … }
}
struct PermissionsParser::InitialPermissions { … };
PermissionsParser::PermissionsParser() { … }
PermissionsParser::~PermissionsParser() { … }
bool PermissionsParser::Parse(Extension* extension, std::u16string* error) { … }
void PermissionsParser::Finalize(Extension* extension) { … }
void PermissionsParser::AddAPIPermission(Extension* extension,
APIPermissionID permission) { … }
void PermissionsParser::AddAPIPermission(Extension* extension,
APIPermission* permission) { … }
bool PermissionsParser::HasAPIPermission(const Extension* extension,
APIPermissionID permission) { … }
void PermissionsParser::SetScriptableHosts(
Extension* extension,
const URLPatternSet& scriptable_hosts) { … }
const PermissionSet& PermissionsParser::GetRequiredPermissions(
const Extension* extension) { … }
const PermissionSet& PermissionsParser::GetOptionalPermissions(
const Extension* extension) { … }
}