OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_SERVICES_GCM_PUSH_MESSAGING_PERMISSION_CONTEXT_H_ | 5 #ifndef CHROME_BROWSER_SERVICES_GCM_PUSH_MESSAGING_PERMISSION_CONTEXT_H_ |
6 #define CHROME_BROWSER_SERVICES_GCM_PUSH_MESSAGING_PERMISSION_CONTEXT_H_ | 6 #define CHROME_BROWSER_SERVICES_GCM_PUSH_MESSAGING_PERMISSION_CONTEXT_H_ |
7 | 7 |
8 #include "chrome/browser/content_settings/permission_context_base.h" | 8 #include "chrome/browser/content_settings/permission_context_base.h" |
9 | 9 |
10 #include "components/content_settings/core/common/content_settings_types.h" | 10 #include "components/content_settings/core/common/content_settings_types.h" |
11 | 11 |
| 12 class PermissionRequestID; |
12 class Profile; | 13 class Profile; |
13 | 14 |
14 namespace gcm { | 15 namespace gcm { |
15 | 16 |
16 // Permission context for push messages. | 17 // Permission context for push messages. |
17 class PushMessagingPermissionContext : public PermissionContextBase { | 18 class PushMessagingPermissionContext : public PermissionContextBase { |
18 public: | 19 public: |
19 explicit PushMessagingPermissionContext(Profile* profile); | 20 explicit PushMessagingPermissionContext(Profile* profile); |
20 ~PushMessagingPermissionContext() override; | 21 ~PushMessagingPermissionContext() override; |
21 | 22 |
22 // PermissionContextBase: | 23 // PermissionContextBase: |
23 ContentSetting GetPermissionStatus( | 24 ContentSetting GetPermissionStatus( |
24 const GURL& requesting_origin, | 25 const GURL& requesting_origin, |
25 const GURL& embedding_origin) const override; | 26 const GURL& embedding_origin) const override; |
26 | 27 |
27 protected: | 28 protected: |
28 // PermissionContextBase: | 29 // PermissionContextBase: |
29 void DecidePermission(content::WebContents* web_contents, | 30 void DecidePermission(content::WebContents* web_contents, |
30 const PermissionRequestID& id, | 31 const PermissionRequestID& id, |
31 const GURL& requesting_origin, | 32 const GURL& requesting_origin, |
32 const GURL& embedding_origin, | 33 const GURL& embedding_origin, |
33 bool user_gesture, | 34 bool user_gesture, |
34 const BrowserPermissionCallback& callback) override; | 35 const BrowserPermissionCallback& callback) override; |
35 | 36 |
36 private: | 37 private: |
| 38 FRIEND_TEST_ALL_PREFIXES(PushMessagingPermissionContextTest, |
| 39 DecidePushPermission); |
| 40 |
| 41 // Used to decide the permission for push, once the permission for |
| 42 // Notification has been granted/denied. |
| 43 void DecidePushPermission(const PermissionRequestID& id, |
| 44 const GURL& requesting_origin, |
| 45 const GURL& embedding_origin, |
| 46 const BrowserPermissionCallback& callback, |
| 47 bool notifications_permission_granted); |
| 48 |
37 Profile* profile_; | 49 Profile* profile_; |
38 | 50 |
| 51 // Must be the last member, to ensure that it will be |
| 52 // destroyed first, which will invalidate weak pointers |
| 53 base::WeakPtrFactory<PushMessagingPermissionContext> weak_factory_ui_thread_; |
| 54 |
39 DISALLOW_COPY_AND_ASSIGN(PushMessagingPermissionContext); | 55 DISALLOW_COPY_AND_ASSIGN(PushMessagingPermissionContext); |
40 }; | 56 }; |
41 | 57 |
42 } // namespace gcm | 58 } // namespace gcm |
43 #endif // CHROME_BROWSER_SERVICES_GCM_PUSH_MESSAGING_PERMISSION_CONTEXT_H_ | 59 #endif // CHROME_BROWSER_SERVICES_GCM_PUSH_MESSAGING_PERMISSION_CONTEXT_H_ |
OLD | NEW |