1 // Copyright 2015 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.
5 #ifndef CHROME_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_PERMISSION_CONTEXT_H_
6 #define CHROME_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_PERMISSION_CONTEXT_H_
8 #include "chrome/browser/content_settings/permission_context_base.h"
10 #include "components/content_settings/core/common/content_settings_types.h"
12 class PermissionRequestID
;
15 // Permission context for push messages.
16 class PushMessagingPermissionContext
: public PermissionContextBase
{
18 explicit PushMessagingPermissionContext(Profile
* profile
);
19 ~PushMessagingPermissionContext() override
;
21 // PermissionContextBase:
22 ContentSetting
GetPermissionStatus(
23 const GURL
& requesting_origin
,
24 const GURL
& embedding_origin
) const override
;
26 void CancelPermissionRequest(content::WebContents
* web_contents
,
27 const PermissionRequestID
& id
) override
;
30 // PermissionContextBase:
31 void DecidePermission(content::WebContents
* web_contents
,
32 const PermissionRequestID
& id
,
33 const GURL
& requesting_origin
,
34 const GURL
& embedding_origin
,
36 const BrowserPermissionCallback
& callback
) override
;
39 FRIEND_TEST_ALL_PREFIXES(PushMessagingPermissionContextTest
,
40 DecidePushPermission
);
42 // Used to decide the permission for push, once the permission for
43 // Notification has been granted/denied.
44 void DecidePushPermission(const PermissionRequestID
& id
,
45 const GURL
& requesting_origin
,
46 const GURL
& embedding_origin
,
47 const BrowserPermissionCallback
& callback
,
48 ContentSetting notifications_content_setting
);
52 // Must be the last member, to ensure that it will be
53 // destroyed first, which will invalidate weak pointers
54 base::WeakPtrFactory
<PushMessagingPermissionContext
> weak_factory_ui_thread_
;
56 DISALLOW_COPY_AND_ASSIGN(PushMessagingPermissionContext
);
59 #endif // CHROME_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_PERMISSION_CONTEXT_H_