| Index: chrome/browser/extensions/active_tab_permission_granter.cc
|
| diff --git a/chrome/browser/extensions/active_tab_permission_granter.cc b/chrome/browser/extensions/active_tab_permission_granter.cc
|
| index 1732c6070d7d14ba03f78769f85c6b040245a123..650768af1e54d2cf7c74ad420284dc7fe4c8ce0b 100644
|
| --- a/chrome/browser/extensions/active_tab_permission_granter.cc
|
| +++ b/chrome/browser/extensions/active_tab_permission_granter.cc
|
| @@ -66,6 +66,8 @@ void SendMessageToProcesses(
|
| tab_process->Send(create_message.Run(false));
|
| }
|
|
|
| +ActiveTabPermissionGranter::Delegate* g_delegate = nullptr;
|
| +
|
| } // namespace
|
|
|
| ActiveTabPermissionGranter::ActiveTabPermissionGranter(
|
| @@ -80,6 +82,14 @@ ActiveTabPermissionGranter::ActiveTabPermissionGranter(
|
|
|
| ActiveTabPermissionGranter::~ActiveTabPermissionGranter() {}
|
|
|
| +// static
|
| +void ActiveTabPermissionGranter::SetPlatformDelegate(Delegate* delegate) {
|
| + // Disallow setting it twice (but allow resetting - don't forget to free in
|
| + // that case).
|
| + CHECK(!g_delegate || !delegate);
|
| + g_delegate = delegate;
|
| +}
|
| +
|
| void ActiveTabPermissionGranter::GrantIfRequested(const Extension* extension) {
|
| if (granted_extensions_.Contains(extension->id()))
|
| return;
|
| @@ -89,11 +99,14 @@ void ActiveTabPermissionGranter::GrantIfRequested(const Extension* extension) {
|
|
|
| const PermissionsData* permissions_data = extension->permissions_data();
|
|
|
| + bool active_tab_granted = !g_delegate ||
|
| + g_delegate->ActiveTabPermissionGranted(extension, web_contents());
|
| // If the extension requested all-hosts but has had it withheld, we grant it
|
| // active tab-style permissions, even if it doesn't have the activeTab
|
| // permission in the manifest.
|
| - if (permissions_data->HasAPIPermission(APIPermission::kActiveTab) ||
|
| - permissions_data->HasWithheldImpliedAllHosts()) {
|
| + if (active_tab_granted &&
|
| + (permissions_data->HasWithheldImpliedAllHosts() ||
|
| + permissions_data->HasAPIPermission(APIPermission::kActiveTab))) {
|
| new_hosts.AddOrigin(UserScript::ValidUserScriptSchemes(),
|
| web_contents()->GetVisibleURL().GetOrigin());
|
| new_apis.insert(APIPermission::kTab);
|
|
|