| Index: chrome/browser/chromeos/extensions/public_session_permission_helper.cc
|
| diff --git a/chrome/browser/chromeos/extensions/public_session_permission_helper.cc b/chrome/browser/chromeos/extensions/public_session_permission_helper.cc
|
| index c54a1978e2c49881c182012eacea7dd495e322a2..41fd99fca4d94931dacc55c1df62483828e57460 100644
|
| --- a/chrome/browser/chromeos/extensions/public_session_permission_helper.cc
|
| +++ b/chrome/browser/chromeos/extensions/public_session_permission_helper.cc
|
| @@ -43,12 +43,14 @@ class PublicSessionPermissionHelper {
|
| PublicSessionPermissionHelper(PublicSessionPermissionHelper&& other);
|
| ~PublicSessionPermissionHelper();
|
|
|
| - void HandlePermissionRequestImpl(const Extension& extension,
|
| + bool HandlePermissionRequestImpl(const Extension& extension,
|
| const PermissionIDSet& requested_permissions,
|
| content::WebContents* web_contents,
|
| const RequestResolvedCallback& callback,
|
| const PromptFactory& prompt_factory);
|
|
|
| + bool PermissionAllowedImpl(APIPermission::ID permission);
|
| +
|
| private:
|
| void ResolvePermissionPrompt(const ExtensionInstallPrompt* prompt,
|
| const PermissionIDSet& unprompted_permissions,
|
| @@ -82,7 +84,7 @@ PublicSessionPermissionHelper::PublicSessionPermissionHelper(
|
|
|
| PublicSessionPermissionHelper::~PublicSessionPermissionHelper() {}
|
|
|
| -void PublicSessionPermissionHelper::HandlePermissionRequestImpl(
|
| +bool PublicSessionPermissionHelper::HandlePermissionRequestImpl(
|
| const Extension& extension,
|
| const PermissionIDSet& requested_permissions,
|
| content::WebContents* web_contents,
|
| @@ -96,20 +98,22 @@ void PublicSessionPermissionHelper::HandlePermissionRequestImpl(
|
| unresolved_permissions, denied_permission_set_);
|
| if (unresolved_permissions.empty()) {
|
| // All requested permissions are already resolved.
|
| - callback.Run(FilterAllowedPermissions(requested_permissions));
|
| - return;
|
| + if (!callback.is_null())
|
| + callback.Run(FilterAllowedPermissions(requested_permissions));
|
| + return true;
|
| }
|
|
|
| // Since not all permissions are resolved yet, queue the callback to be called
|
| // when all of them are resolved.
|
| - callbacks_.push_back(RequestCallback(callback, requested_permissions));
|
| + if (!callback.is_null())
|
| + callbacks_.push_back(RequestCallback(callback, requested_permissions));
|
|
|
| PermissionIDSet unprompted_permissions = PermissionIDSet::Difference(
|
| unresolved_permissions, prompted_permission_set_);
|
| if (unprompted_permissions.empty()) {
|
| // Some permissions aren't resolved yet, but they are currently being
|
| // prompted for, so no need to show a prompt.
|
| - return;
|
| + return false;
|
| }
|
|
|
| // Some permissions need prompting, setup the prompt and show it.
|
| @@ -134,6 +138,13 @@ void PublicSessionPermissionHelper::HandlePermissionRequestImpl(
|
| std::move(permission_set),
|
| ExtensionInstallPrompt::GetDefaultShowDialogCallback());
|
| prompts_.insert(std::move(prompt));
|
| +
|
| + return false;
|
| +}
|
| +
|
| +bool PublicSessionPermissionHelper::PermissionAllowedImpl(
|
| + APIPermission::ID permission) {
|
| + return allowed_permission_set_.ContainsID(permission);
|
| }
|
|
|
| void PublicSessionPermissionHelper::ResolvePermissionPrompt(
|
| @@ -203,7 +214,7 @@ base::LazyInstance<std::map<ExtensionId, PublicSessionPermissionHelper>>::Leaky
|
|
|
| } // namespace
|
|
|
| -void HandlePermissionRequest(const Extension& extension,
|
| +bool HandlePermissionRequest(const Extension& extension,
|
| const PermissionIDSet& requested_permissions,
|
| content::WebContents* web_contents,
|
| const RequestResolvedCallback& callback,
|
| @@ -216,6 +227,12 @@ void HandlePermissionRequest(const Extension& extension,
|
| extension, requested_permissions, web_contents, callback, factory);
|
| }
|
|
|
| +bool PermissionAllowed(const Extension* extension,
|
| + APIPermission::ID permission) {
|
| + DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
| + return g_helpers.Get()[extension->id()].PermissionAllowedImpl(permission);
|
| +}
|
| +
|
| void ResetPermissionsForTesting() {
|
| // Clear out the std::map between tests. Just setting g_helpers to
|
| // LAZY_INSTANCE_INITIALIZER again causes a memory leak (because of the
|
|
|