#include <utility>
#include "base/functional/callback_helpers.h"
#include "base/strings/stringprintf.h"
#include "base/test/values_test_util.h"
#include "chrome/browser/extensions/chrome_test_extension_loader.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_service_test_with_install.h"
#include "chrome/browser/extensions/permissions/permissions_test_util.h"
#include "chrome/browser/extensions/permissions/permissions_updater.h"
#include "chrome/browser/extensions/permissions/scripting_permissions_modifier.h"
#include "chrome/test/base/testing_profile.h"
#include "components/crx_file/id_util.h"
#include "extensions/browser/extension_prefs.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_util.h"
#include "extensions/browser/permissions_manager.h"
#include "extensions/browser/test_extension_registry_observer.h"
#include "extensions/common/extension.h"
#include "extensions/common/extension_builder.h"
#include "extensions/common/extensions_client.h"
#include "extensions/common/manifest_handlers/permissions_parser.h"
#include "extensions/common/permissions/permission_set.h"
#include "extensions/common/permissions/permissions_data.h"
#include "extensions/common/url_pattern.h"
#include "extensions/common/url_pattern_set.h"
#include "extensions/common/user_script.h"
#include "extensions/test/test_extension_dir.h"
#include "testing/gmock/include/gmock/gmock.h"
ManifestLocation;
namespace extensions {
namespace {
GetPatternsAsStrings;
std::vector<std::string> GetEffectivePatternsAsStrings(
const Extension& extension) { … }
std::vector<std::string> GetScriptablePatternsAsStrings(
const Extension& extension) { … }
std::vector<std::string> GetExplicitPatternsAsStrings(
const Extension& extension) { … }
void InitializeExtensionPermissions(Profile* profile,
const Extension& extension) { … }
void CheckActiveHostPermissions(
const Extension& extension,
const std::vector<std::string>& explicit_hosts,
const std::vector<std::string>& scriptable_hosts) { … }
void CheckWithheldHostPermissions(
const Extension& extension,
const std::vector<std::string>& explicit_hosts,
const std::vector<std::string>& scriptable_hosts) { … }
ScriptingPermissionsModifierUnitTest;
}
TEST_F(ScriptingPermissionsModifierUnitTest, GrantAndWithholdHostPermissions) { … }
TEST_F(ScriptingPermissionsModifierUnitTest, WithholdHostPermissionsOnInstall) { … }
TEST_F(ScriptingPermissionsModifierUnitTest,
WithholdOnInstallPreservedOnReload) { … }
TEST_F(ScriptingPermissionsModifierUnitTest,
WithholdOnInstallPreservedOnUpdate) { … }
TEST_F(ScriptingPermissionsModifierUnitTest, SwitchBehavior) { … }
TEST_F(ScriptingPermissionsModifierUnitTest, GrantHostPermission) { … }
TEST_F(ScriptingPermissionsModifierUnitTest,
ExtensionsInitializedWithSavedRuntimeGrantedHostPermissionsAcrossLoad) { … }
TEST_F(ScriptingPermissionsModifierUnitTest,
RemoveAllGrantedHostPermissions_GrantedHosts) { … }
TEST_F(ScriptingPermissionsModifierUnitTest,
RemoveAllGrantedHostPermissions_GrantedHostsForNonAllUrlsExtension) { … }
TEST_F(ScriptingPermissionsModifierUnitTest,
RemoveAllGrantedHostPermissions_GrantedOptionalPermissions) { … }
TEST_F(ScriptingPermissionsModifierUnitTest, HasBroadGrantedHostPermissions) { … }
TEST_F(ScriptingPermissionsModifierUnitTest,
RemoveBroadGrantedHostPermissions) { … }
TEST_F(ScriptingPermissionsModifierUnitTest,
GrantingHostPermissionsBeyondRequested) { … }
TEST_F(ScriptingPermissionsModifierUnitTest, ChangeHostPermissions_AllHosts) { … }
TEST_F(ScriptingPermissionsModifierUnitTest,
ChangeHostPermissions_AllHostsLike) { … }
TEST_F(ScriptingPermissionsModifierUnitTest,
ChangeHostPermissions_SpecificSite) { … }
TEST_F(ScriptingPermissionsModifierUnitTest, AddRuntimeGrantedHostPermission) { … }
TEST_F(ScriptingPermissionsModifierUnitTest,
ChangeHostPermissions_IgnorePaths) { … }
TEST_F(ScriptingPermissionsModifierUnitTest,
RemoveHostAccess_RemovesOverlappingPatterns) { … }
TEST_F(ScriptingPermissionsModifierUnitTest,
RemoveAllURLsGrantedOptionalPermission) { … }
}