Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(162)

Side by Side Diff: chrome/browser/chromeos/extensions/public_session_permission_helper.h

Issue 2552203007: Public Sessions - prompt the user for pageCapture requests (Closed)
Patch Set: Using factory callback for prompts Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 <memory>
9 #include <set>
10
11 #include "base/callback_forward.h"
12 #include "extensions/common/permissions/api_permission.h"
13 #include "extensions/common/permissions/api_permission_set.h"
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 using PromptFactory = base::Callback<std::unique_ptr<ExtensionInstallPrompt>()>;
Andrew T Wilson (Slow) 2017/02/10 17:17:21 This should take a WebContents I think - since tha
Ivan Šandrk 2017/02/10 18:46:25 Done.
29
30 // In Public Sessions, extensions (and apps) are force-installed by admin policy
31 // so the user does not get a chance to review the permissions for these
32 // extensions. This is not acceptable from a security/privacy standpoint, so
33 // when an extension uses one of the sensitive APIs for the first time, we show
34 // the user a dialog where they can choose whether to allow the extension access
35 // to the API.
36 //
37 // This function sets up the prompt asking the user for additional
38 // permission(s), handles the result, caches it, and then runs the callback with
39 // the allowed permissions as the argument.
40 //
41 // The user will be prompted about a certain permission only once, and that
42 // choice will be cached and used in any subsequent requests that use the same
43 // permission. If a request comes for a permission that is currently being
44 // prompted, its callback will be queued up to be invoked when the prompt is
45 // resolved.
46 //
47 // Caller must ensure that web_contents is valid. Must be called on UI thread.
48 void HandlePermissionRequest(const Extension& extension,
49 const PermissionIDSet& requested_permissions,
50 content::WebContents* web_contents,
51 const RequestResolvedCallback& callback,
52 PromptFactory* prompt_factory = nullptr);
Andrew T Wilson (Slow) 2017/02/10 17:17:21 Don't pass PromptFactory as a pointer - pass it as
Ivan Šandrk 2017/02/10 18:46:25 I see. Done.
53
54 // Used to completely reset state in between tests.
55 void ResetPermissionsForTesting();
56
57 // Sets the ExtensionInstallPrompt to be used in HandlePermissionRequest, useful
58 // in testing to mock out the ExtensionInstallPrompt.
59 void SetExtensionInstallPromptForTesting(
60 ExtensionInstallPrompt* extension_install_prompt);
61
62 } // namespace permission_helper
63 } // namespace extensions
64
65 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_PUBLIC_SESSION_PERMISSION_HELPER_H _
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698