| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_PUBLIC_SESSION_PERMISSION_HELPER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_PUBLIC_SESSION_PERMISSION_HELPER_H_ |
| 7 |
| 8 #include <set> |
| 9 |
| 10 #include "base/callback_forward.h" |
| 11 #include "extensions/common/permissions/api_permission.h" |
| 12 #include "extensions/common/permissions/api_permission_set.h" |
| 13 |
| 14 |
| 15 class ExtensionInstallPrompt; |
| 16 |
| 17 namespace content { |
| 18 class WebContents; |
| 19 } |
| 20 |
| 21 namespace extensions { |
| 22 |
| 23 class Extension; |
| 24 |
| 25 namespace permission_helper { |
| 26 |
| 27 using RequestResolvedCallback = base::Callback<void(const PermissionIDSet&)>; |
| 28 |
| 29 // In Public Sessions, extensions (and apps) are force-installed by admin policy |
| 30 // so the user does not get a chance to review the permissions for these |
| 31 // extensions. This is not acceptable from a security/privacy standpoint, so |
| 32 // when an extension uses one of the sensitive APIs for the first time, we show |
| 33 // the user a dialog where they can choose whether to allow the extension access |
| 34 // to the API. |
| 35 // |
| 36 // This function sets up the prompt asking the user for additional |
| 37 // permission(s), handles the result, caches it, and then runs the callback with |
| 38 // the allowed permissions as the argument. |
| 39 // |
| 40 // The user will be prompted about a certain permission only once, and that |
| 41 // choice will be cached and used in any subsequent requests that use the same |
| 42 // permission. If a request comes for a permission that is currently being |
| 43 // prompted, its callback will be queued up to be invoked when the prompt is |
| 44 // resolved. |
| 45 // |
| 46 // Caller must ensure that web_contents is valid. Must be called on UI thread. |
| 47 void HandlePermissionRequest(const Extension& extension, |
| 48 const PermissionIDSet& requested_permissions, |
| 49 content::WebContents* web_contents, |
| 50 const RequestResolvedCallback& callback); |
| 51 |
| 52 // Used to completely reset state in between tests. |
| 53 void ResetPermissionsForTesting(); |
| 54 |
| 55 // Sets the ExtensionInstallPrompt to be used in HandlePermissionRequest, useful |
| 56 // in testing to mock out the ExtensionInstallPrompt. |
| 57 void SetExtensionInstallPromptForTesting( |
| 58 ExtensionInstallPrompt* extension_install_prompt); |
| 59 |
| 60 } // namespace permission_helper |
| 61 } // namespace extensions |
| 62 |
| 63 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_PUBLIC_SESSION_PERMISSION_HELPER_H
_ |
| OLD | NEW |