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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/extensions/public_session_permission_helper.h
diff --git a/chrome/browser/chromeos/extensions/public_session_permission_helper.h b/chrome/browser/chromeos/extensions/public_session_permission_helper.h
new file mode 100644
index 0000000000000000000000000000000000000000..0da9203f6a640d22c66ac7ad8e4a78e4c37851d1
--- /dev/null
+++ b/chrome/browser/chromeos/extensions/public_session_permission_helper.h
@@ -0,0 +1,72 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_PUBLIC_SESSION_PERMISSION_HELPER_H_
+#define CHROME_BROWSER_CHROMEOS_EXTENSIONS_PUBLIC_SESSION_PERMISSION_HELPER_H_
+
+#include <map>
+#include <set>
+#include <vector>
+
+#include "base/callback_forward.h"
+#include "base/macros.h"
+#include "extensions/common/extension_id.h"
+#include "extensions/common/permissions/api_permission.h"
+
+namespace content {
+class WebContents;
+}
+
+namespace extensions {
+
+class Extension;
+
+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.
+
+class PublicSessionPermissionHelperImpl;
+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. :)
+ NOT_PROMPTED = 0,
+ SHOWN_PROMPT,
+ ALLOWED,
+ DENIED
+};
+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.
+
+class PublicSessionPermissionHelper {
+ public:
+ 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
+
+ // Sets up the prompt asking the user for additional permission(s), handles
+ // the result, caches it, and then runs either success_callback or
+ // failure_callback depending on all permissions being allowed.
+ // Supports handling multiple requests for the same permission(s). Only the
+ // first request causes the prompt to be shown, subsequent ones are just
+ // enqueued to be called when the permission(s) is resolved.
+ // Caller must ensure that web_contents is valid. requested_permissions may
+ // contain at most 2 elements. Must be called on UI thread.
+ // If finer resolving is needed, pass the same function in both callbacks and
+ // check the individual permissions by calling GetUserChoice inside your
+ // function.
+ void HandlePermissionRequest(const Extension* extension,
+ PermissionHelperSet requested_permissions,
+ content::WebContents* web_contents,
+ const base::Closure& success_callback,
+ const base::Closure& failure_callback);
+
+ 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
+ APIPermission::ID permission_id);
+
+ private:
+ PublicSessionPermissionHelper();
+ ~PublicSessionPermissionHelper();
+
+ std::map<ExtensionId, PublicSessionPermissionHelperImpl> impl_;
+
+ DISALLOW_COPY_AND_ASSIGN(PublicSessionPermissionHelper);
+};
+
+} // namespace permission_helper
+} // namespace extensions
+
+#endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_PUBLIC_SESSION_PERMISSION_HELPER_H_

Powered by Google App Engine
This is Rietveld 408576698