• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 CONTENT_SHELL_BROWSER_SHELL_NOTIFICATION_MANAGER_H_
6 #define CONTENT_SHELL_BROWSER_SHELL_NOTIFICATION_MANAGER_H_
7 
8 #include <map>
9 
10 #include "base/callback.h"
11 #include "third_party/WebKit/public/platform/WebNotificationPermission.h"
12 #include "url/gurl.h"
13 
14 namespace content {
15 
16 // Responsible for tracking active notifications and allowed origins for the
17 // Web Notification API when running layout tests. The methods in this class
18 // should only be used on the IO thread.
19 class ShellNotificationManager {
20  public:
21   ShellNotificationManager();
22   ~ShellNotificationManager();
23 
24   // Checks whether |origin| has permission to display notifications in tests.
25   blink::WebNotificationPermission CheckPermission(
26       const GURL& origin);
27 
28   // Requests permission for |origin| to display notifications in layout tests.
29   void RequestPermission(
30       const GURL& origin,
31       const base::Callback<void(blink::WebNotificationPermission)>& callback);
32 
33   // Sets the permission to display notifications for |origin| to |permission|.
34   void SetPermission(const GURL& origin,
35                      blink::WebNotificationPermission permission);
36 
37   // Clears the currently granted permissions.
38   void ClearPermissions();
39 
40  private:
41   typedef std::map<GURL, blink::WebNotificationPermission>
42       NotificationPermissionMap;
43   NotificationPermissionMap permission_map_;
44 
45   DISALLOW_COPY_AND_ASSIGN(ShellNotificationManager);
46 };
47 
48 }  // content
49 
50 #endif  // CONTENT_SHELL_BROWSER_SHELL_NOTIFICATION_MANAGER_H_
51