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

Side by Side 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: add content settings html sections 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2014 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_SERVICES_GCM_PERMISSION_CONTEXT_BASE_H_
6 #define CHROME_BROWSER_SERVICES_GCM_PERMISSION_CONTEXT_BASE_H_
7
8 #include "base/callback.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/memory/weak_ptr.h"
11 #include "chrome/common/content_settings_types.h"
12 #include "components/keyed_service/core/keyed_service.h"
13 #include "url/gurl.h"
14
15 class PermissionQueueController;
16 class PermissionRequestID;
17 class Profile;
18
19 namespace content {
20 class WebContents;
21 }
22
23 typedef base::Callback<void(bool)> BrowserPermissionCallback;
24
25 // TODO(miguelg) Move this out of gcm into a generic place and make
26 // Midi permissions and others use it.
27 namespace gcm {
28
29 // This base class contains common operations for grating permissions.
30 // It is spit out of Midi and Push and will be moved to a common place
31 // so it can be used by both classes (and eventually others) in a separate
32 // patch.
33 class PermissionContextBase : public KeyedService {
34 public:
35 PermissionContextBase(Profile* profile,
36 const ContentSettingsType permission_type);
37 virtual ~PermissionContextBase();
38
39 // The renderer is requesting permission to push messages.
40 // When the answer to a permission request has been determined, |callback|
41 // should be called with the result.
42 virtual void RequestPermission(content::WebContents* web_contents,
43 const PermissionRequestID& id,
44 const GURL& requesting_frame,
45 bool user_gesture,
46 const BrowserPermissionCallback& callback);
47
48 protected:
49 // Decide whether the permission should be granted.
50 // Calls PermissionDecided if permission can be decided non-interactively,
51 // or NotifyPermissionSet if permission decided by presenting an infobar.
52 void DecidePermission(content::WebContents* web_contents,
53 const PermissionRequestID& id,
54 const GURL& requesting_frame,
55 const GURL& embedder,
56 bool user_gesture,
57 const BrowserPermissionCallback& callback);
58
59 // Called when permission is granted without interactively asking the user.
60 void PermissionDecided(const PermissionRequestID& id,
61 const GURL& requesting_frame,
62 const GURL& embedder,
63 const BrowserPermissionCallback& callback,
64 bool allowed);
65
66 void NotifyPermissionSet(const PermissionRequestID& id,
67 const GURL& requesting_frame,
68 const BrowserPermissionCallback& callback,
69 bool allowed);
70
71 // Implementors can override this method to update the icons on the
72 // url bar with the result of the new permission.
73 virtual void UpdateTabContext(const PermissionRequestID& id,
74 const GURL& requesting_frame,
75 bool allowed) {}
76
77 // Return an instance of the infobar queue controller, creating it if needed.
78 PermissionQueueController* GetQueueController();
79
80 private:
81 Profile* profile_;
82 const ContentSettingsType permission_type_;
83 base::WeakPtrFactory<PermissionContextBase> weak_factory_;
84 scoped_ptr<PermissionQueueController> permission_queue_controller_;
85 };
86
87 } // namespace gcm
88
89 #endif // CHROME_BROWSER_SERVICES_GCM_PERMISSION_CONTEXT_BASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698