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

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: Added PermissionHelper which handles permission requests and caches user choices Created 3 years, 11 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 <map>
9 #include <set>
10 #include <vector>
11
12 #include "base/callback_forward.h"
13 #include "base/macros.h"
14 #include "extensions/common/extension_id.h"
15 #include "extensions/common/permissions/api_permission.h"
16
17 namespace content {
18 class WebContents;
19 }
20
21 namespace extensions {
22
23 class Extension;
24
25 namespace permission_helper {
Devlin 2017/01/23 22:59:48 we probably don't need a namespace just for these
Ivan Šandrk 2017/01/24 19:57:22 Done.
26
27 class PublicSessionPermissionHelperImpl;
28 enum PermissionState {
Devlin 2017/01/23 22:59:48 It looks like this might not be used at all?
Ivan Šandrk 2017/01/24 19:57:22 Used in public_session_media_access_handler.cc
Devlin 2017/01/25 16:00:31 Ah, that file didn't used to exist. :)
29 NOT_PROMPTED = 0,
30 SHOWN_PROMPT,
31 ALLOWED,
32 DENIED
33 };
34 using PermissionHelperSet = std::set<APIPermission::ID>;
Devlin 2017/01/23 22:59:48 We have an APIPermissionSet; is there a reason we
Ivan Šandrk 2017/01/24 19:57:22 ContainsAnyID accepts a set<APIPermission::ID> but
Devlin 2017/01/25 16:00:31 Grr... these weird sets are annoying (totally not
Ivan Šandrk 2017/01/26 18:53:21 Done.
35
36 class PublicSessionPermissionHelper {
37 public:
38 static PublicSessionPermissionHelper& Instance();
Devlin 2017/01/23 22:59:48 style forbids non-const refs being returned.
Ivan Šandrk 2017/01/24 19:57:22 Can you link this? I wasn't able to find it in the
Devlin 2017/01/25 16:00:31 Hmm... I've found https://google.github.io/stylegu
Ivan Šandrk 2017/01/26 18:53:21 I think people have misunderstood that rule to mea
39
40 // Sets up the prompt asking the user for additional permission(s), handles
41 // the result, caches it, and then runs either success_callback or
42 // failure_callback depending on all permissions being allowed.
43 // Supports handling multiple requests for the same permission(s). Only the
44 // first request causes the prompt to be shown, subsequent ones are just
45 // enqueued to be called when the permission(s) is resolved.
46 // Caller must ensure that web_contents is valid. requested_permissions may
47 // contain at most 2 elements. Must be called on UI thread.
48 // If finer resolving is needed, pass the same function in both callbacks and
49 // check the individual permissions by calling GetUserChoice inside your
50 // function.
51 void HandlePermissionRequest(const Extension* extension,
52 PermissionHelperSet requested_permissions,
53 content::WebContents* web_contents,
54 const base::Closure& success_callback,
55 const base::Closure& failure_callback);
56
57 PermissionState GetUserChoice(ExtensionId extension_id,
Devlin 2017/01/23 22:59:48 Needed?
Ivan Šandrk 2017/01/24 19:57:22 I'll upload also the changes to the other files so
58 APIPermission::ID permission_id);
59
60 private:
61 PublicSessionPermissionHelper();
62 ~PublicSessionPermissionHelper();
63
64 std::map<ExtensionId, PublicSessionPermissionHelperImpl> impl_;
65
66 DISALLOW_COPY_AND_ASSIGN(PublicSessionPermissionHelper);
67 };
68
69 } // namespace permission_helper
70 } // namespace extensions
71
72 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_PUBLIC_SESSION_PERMISSION_HELPER_H _
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698