Move StartsWith[ASCII] to base namespace.
[chromium-blink-merge.git] / chrome / browser / push_messaging / push_messaging_permission_context.h
blob22926c0e1d20dcaafecc9b0fa13a04e37c914a18
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;
13 class Profile;
15 // Permission context for push messages.
16 class PushMessagingPermissionContext : public PermissionContextBase {
17 public:
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;
29 protected:
30 // PermissionContextBase:
31 void DecidePermission(content::WebContents* web_contents,
32 const PermissionRequestID& id,
33 const GURL& requesting_origin,
34 const GURL& embedding_origin,
35 bool user_gesture,
36 const BrowserPermissionCallback& callback) override;
37 bool IsRestrictedToSecureOrigins() const override;
39 private:
40 FRIEND_TEST_ALL_PREFIXES(PushMessagingPermissionContextTest,
41 DecidePushPermission);
43 // Used to decide the permission for push, once the permission for
44 // Notification has been granted/denied.
45 void DecidePushPermission(const PermissionRequestID& id,
46 const GURL& requesting_origin,
47 const GURL& embedding_origin,
48 const BrowserPermissionCallback& callback,
49 ContentSetting notifications_content_setting);
51 Profile* profile_;
53 // Must be the last member, to ensure that it will be
54 // destroyed first, which will invalidate weak pointers
55 base::WeakPtrFactory<PushMessagingPermissionContext> weak_factory_ui_thread_;
57 DISALLOW_COPY_AND_ASSIGN(PushMessagingPermissionContext);
60 #endif // CHROME_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_PERMISSION_CONTEXT_H_