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

Unified Diff: chrome/browser/chromeos/extensions/public_session_permission_helper.h

Issue 2552203007: Public Sessions - prompt the user for pageCapture requests (Closed)
Patch Set: Devlin's comments, added other files 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..e5bb9a3547e8798db174e9542deb941ce83c3bbe
--- /dev/null
+++ b/chrome/browser/chromeos/extensions/public_session_permission_helper.h
@@ -0,0 +1,68 @@
+// 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;
+
+class PublicSessionPermissionHelperImpl;
+enum PermissionState {
Devlin 2017/01/25 16:00:32 Let's put this in the class.
Ivan Šandrk 2017/01/26 18:53:22 Removed completely.
+ NOT_PROMPTED = 0,
+ SHOWN_PROMPT,
+ ALLOWED,
+ DENIED
+};
+using PermissionHelperSet = std::set<APIPermission::ID>;
+
+class PublicSessionPermissionHelper {
+ public:
+ static PublicSessionPermissionHelper& Instance();
+
+ // 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. 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,
Devlin 2017/01/25 16:00:32 nit: it seems like we can have these two functions
Ivan Šandrk 2017/01/26 18:53:22 Done.
+ PermissionHelperSet requested_permissions,
+ content::WebContents* web_contents,
+ const base::Closure& success_callback,
+ const base::Closure& failure_callback);
+
+ PermissionState GetUserChoice(ExtensionId extension_id,
+ APIPermission::ID permission_id);
+
+ private:
+ PublicSessionPermissionHelper();
+ ~PublicSessionPermissionHelper();
+
+ std::map<ExtensionId, PublicSessionPermissionHelperImpl> impl_;
+
+ DISALLOW_COPY_AND_ASSIGN(PublicSessionPermissionHelper);
+};
+
+} // namespace extensions
+
+#endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_PUBLIC_SESSION_PERMISSION_HELPER_H_

Powered by Google App Engine
This is Rietveld 408576698