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

Unified Diff: chrome/browser/content_settings/permission_context_base.h

Issue 365123003: Implement midi permissions on top of the new common permission classes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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/content_settings/permission_context_base.h
diff --git a/chrome/browser/services/gcm/permission_context_base.h b/chrome/browser/content_settings/permission_context_base.h
similarity index 63%
rename from chrome/browser/services/gcm/permission_context_base.h
rename to chrome/browser/content_settings/permission_context_base.h
index 73ca8af4c38e8a4d8ada17e404301002a1e36c17..dc679f2360870f7911c6bc92567ea6cc93fefbf9 100644
--- a/chrome/browser/services/gcm/permission_context_base.h
+++ b/chrome/browser/content_settings/permission_context_base.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_SERVICES_GCM_PERMISSION_CONTEXT_BASE_H_
-#define CHROME_BROWSER_SERVICES_GCM_PERMISSION_CONTEXT_BASE_H_
+#ifndef CHROME_BROWSER_CONTENT_SETTINGS_PERMISSION_CONTEXT_BASE_H_
+#define CHROME_BROWSER_CONTENT_SETTINGS_PERMISSION_CONTEXT_BASE_H_
#include "base/callback.h"
#include "base/containers/scoped_ptr_hash_map.h"
@@ -24,19 +24,30 @@ class WebContents;
typedef base::Callback<void(bool)> BrowserPermissionCallback;
-// TODO(miguelg): Move this out of gcm into a generic place and make
-// Midi permissions and others use it.
-namespace gcm {
-
// This base class contains common operations for granting permissions.
-// It is spit out of Midi and Push and will be moved to a common place
-// so it can be used by both classes (and eventually others) in a separate
-// patch.
-// It supports both infobars and bubbles, but it handles them differently.
-// For bubbles, it manages the life cycle of permission request and persists the
-// permission choices when stated by the user.
-// For infobars however all that logic is managed by the internal
-// PermissionQueueController object.
+// It offers the following functionality:
+// - Creates a bubble or infobar when a permission is needed
+// - If accepted/denied the permission is saved in content settings for
+// future uses (for the domain that requested it).
Bernhard Bauer 2014/07/04 10:24:13 Mini-nit: the alignment for continuing indented pa
Miguel Garcia 2014/07/04 12:09:52 Done.
+// - If dismissed the permission is not saved but it's considered denied for
+// - this one request
Bernhard Bauer 2014/07/04 10:24:13 No dash
Miguel Garcia 2014/07/04 12:09:52 Done.
+// - In any case the BrowserPermissionCallback is executed once a decision
+// about the permission is made by the user.
+// The bare minimum you need to create a new permission request is
+// - Define your new permission in the ContentSettingsType enum.
+// - Create a class that inherits from PermissionContextBase and passes the
+// new permission.
+// - Inherit from PermissionInfobarDelegate and implement
+// |GetMessageText|
+// - Edit the PermissionBubbleRequestImpl methods to add the new text for
+// the bubble.
+// - Hit several asserts for the missing plumbing and fix them :)
+// After this you can override several other methods to customize behavior,
+// in particular it is advised to override UpdateTabContext in order to manage
+// the permission from the omnibox.
+// See midi_permission_context.h/cc or push_permission_context.cc/h for some
+// examples.
+
class PermissionContextBase : public KeyedService {
public:
PermissionContextBase(Profile* profile,
@@ -58,21 +69,21 @@ class PermissionContextBase : public KeyedService {
// or NotifyPermissionSet if permission decided by presenting an infobar.
void DecidePermission(content::WebContents* web_contents,
const PermissionRequestID& id,
- const GURL& requesting_frame,
- const GURL& embedder,
+ const GURL& requesting_origin,
+ const GURL& embedder_origin,
bool user_gesture,
const BrowserPermissionCallback& callback);
// Called when permission is granted without interactively asking the user.
void PermissionDecided(const PermissionRequestID& id,
- const GURL& requesting_frame,
- const GURL& embedder,
+ const GURL& requesting_origin,
+ const GURL& embedder_origin,
const BrowserPermissionCallback& callback,
bool allowed);
void NotifyPermissionSet(const PermissionRequestID& id,
- const GURL& requesting_frame,
- const GURL& embedder,
+ const GURL& requesting_origin,
+ const GURL& embedder_origin,
const BrowserPermissionCallback& callback,
bool persist,
bool allowed);
@@ -80,7 +91,7 @@ class PermissionContextBase : public KeyedService {
// Implementors can override this method to update the icons on the
// url bar with the result of the new permission.
virtual void UpdateTabContext(const PermissionRequestID& id,
- const GURL& requesting_frame,
+ const GURL& requesting_origin,
bool allowed) {}
// Return an instance of the infobar queue controller, creating it if needed.
@@ -88,8 +99,8 @@ class PermissionContextBase : public KeyedService {
private:
void UpdateContentSetting(
- const GURL& requesting_frame,
- const GURL& embedder,
+ const GURL& requesting_origin,
+ const GURL& embedder_origin,
bool allowed);
// Called when a bubble is no longer used so it can be cleaned up.
@@ -103,6 +114,4 @@ class PermissionContextBase : public KeyedService {
pending_bubbles_;
};
-} // namespace gcm
-
-#endif // CHROME_BROWSER_SERVICES_GCM_PERMISSION_CONTEXT_BASE_H_
+#endif // CHROME_BROWSER_CONTENT_SETTINGS_PERMISSION_CONTEXT_BASE_H_

Powered by Google App Engine
This is Rietveld 408576698