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

Unified Diff: chrome/browser/services/gcm/permission_context_base.h

Issue 343743004: Implement a permission check for push. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased and addressed Michael's comments Created 6 years, 6 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/services/gcm/permission_context_base.h
diff --git a/chrome/browser/services/gcm/permission_context_base.h b/chrome/browser/services/gcm/permission_context_base.h
new file mode 100644
index 0000000000000000000000000000000000000000..92ad8dc13e8244e0f45f116aa0b6863eb7de13a4
--- /dev/null
+++ b/chrome/browser/services/gcm/permission_context_base.h
@@ -0,0 +1,86 @@
+// Copyright 2014 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_SERVICES_GCM_PERMISSION_CONTEXT_BASE_H_
+#define CHROME_BROWSER_SERVICES_GCM_PERMISSION_CONTEXT_BASE_H_
+
+#include "base/callback.h"
+#include "base/memory/ref_counted.h"
+#include "chrome/common/content_settings_types.h"
+#include "components/keyed_service/core/keyed_service.h"
+
+class GURL;
+class PermissionQueueController;
+class PermissionRequestID;
+class Profile;
+
+namespace content {
+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 grating 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.
+class PermissionContextBase : public KeyedService {
+ public:
+ PermissionContextBase(Profile* profile,
+ const ContentSettingsType permission_type);
+ virtual ~PermissionContextBase();
+
+ // The renderer is requesting permission to push messages.
+ // When the answer to a permission request has been determined, |callback|
+ // should be called with the result.
+ virtual void RequestPermission(content::WebContents* web_contents,
+ const PermissionRequestID& id,
+ const GURL& requesting_frame,
+ bool user_gesture,
+ const BrowserPermissionCallback& callback);
+
+ protected:
+ // Decide whether the permission should be granted.
+ // Calls PermissionDecided if permission can be decided non-interactively,
+ // 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,
+ 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 BrowserPermissionCallback& callback,
+ bool allowed);
+
+ void NotifyPermissionSet(const PermissionRequestID& id,
+ const GURL& requesting_frame,
+ const BrowserPermissionCallback& callback,
+ bool allowed);
+
+ // 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,
+ bool allowed) {}
+
+ // Return an instance of the infobar queue controller, creating it if needed.
+ PermissionQueueController* GetQueueController();
+
+ private:
+ Profile* profile_;
+ const ContentSettingsType permission_type_;
+ scoped_ptr<PermissionQueueController> permission_queue_controller_;
+};
+} // namespace gcm
+
+#endif // CHROME_BROWSER_SERVICES_GCM_PERMISSION_CONTEXT_BASE_H_

Powered by Google App Engine
This is Rietveld 408576698