Chromium Code Reviews| 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..43ec5a812bb9fde8bfd1aeddde4ac916e298f550 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 (permissions_data->HasWithheldImpliedAllHosts() || |
|
Andrew T Wilson (Slow)
2017/05/09 13:29:29
Why isn't HasWithheldImpliedAllHosts() subject to
Ivan Šandrk
2017/05/10 10:01:28
It's unrelated to activeTab functionality. Afaict
|
| + (active_tab_granted && |
| + permissions_data->HasAPIPermission(APIPermission::kActiveTab))) { |
| new_hosts.AddOrigin(UserScript::ValidUserScriptSchemes(), |
| web_contents()->GetVisibleURL().GetOrigin()); |
| new_apis.insert(APIPermission::kTab); |