| 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 CONTENT_SHELL_BROWSER_LAYOUT_TEST_LAYOUT_TEST_NOTIFICATION_MANAGER_H_ | 5 #ifndef CONTENT_SHELL_BROWSER_LAYOUT_TEST_LAYOUT_TEST_NOTIFICATION_MANAGER_H_ |
| 6 #define CONTENT_SHELL_BROWSER_LAYOUT_TEST_LAYOUT_TEST_NOTIFICATION_MANAGER_H_ | 6 #define CONTENT_SHELL_BROWSER_LAYOUT_TEST_LAYOUT_TEST_NOTIFICATION_MANAGER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "third_party/WebKit/public/platform/WebNotificationPermission.h" | 13 #include "third_party/WebKit/public/platform/WebNotificationPermission.h" |
| 14 #include "url/gurl.h" | 14 #include "url/gurl.h" |
| 15 | 15 |
| 16 namespace content { | 16 namespace content { |
| 17 | 17 |
| 18 struct ShowDesktopNotificationHostMsgParams; | 18 struct ShowDesktopNotificationHostMsgParams; |
| 19 class DesktopNotificationDelegate; | 19 class DesktopNotificationDelegate; |
| 20 | 20 |
| 21 // Responsible for tracking active notifications and allowed origins for the | 21 // Responsible for tracking active notifications and allowed origins for the |
| 22 // Web Notification API when running layout tests. | 22 // Web Notification API when running layout tests. |
| 23 class LayoutTestNotificationManager { | 23 class LayoutTestNotificationManager { |
| 24 public: | 24 public: |
| 25 LayoutTestNotificationManager(); | 25 LayoutTestNotificationManager(); |
| 26 ~LayoutTestNotificationManager(); | 26 ~LayoutTestNotificationManager(); |
| 27 | 27 |
| 28 // Checks whether |origin| has permission to display notifications in tests. | 28 // Checks whether |origin| has permission to display notifications in tests. |
| 29 // Must be called on the IO thread. | 29 // Must be called on the IO thread. |
| 30 blink::WebNotificationPermission CheckPermission( | 30 blink::WebNotificationPermission CheckPermission(const GURL& origin); |
| 31 const GURL& origin); | |
| 32 | 31 |
| 33 // Requests permission for |origin| to display notifications in layout tests. | 32 // Requests permission for |origin| to display notifications in layout tests. |
| 34 // Must be called on the IO thread. | 33 // Must be called on the IO thread. |
| 35 void RequestPermission( | 34 // Returns whether the permission is granted. |
| 36 const GURL& origin, | 35 bool RequestPermission(const GURL& origin); |
| 37 const base::Callback<void(bool)>& callback); | |
| 38 | 36 |
| 39 // Sets the permission to display notifications for |origin| to |permission|. | 37 // Sets the permission to display notifications for |origin| to |permission|. |
| 40 // Must be called on the IO thread. | 38 // Must be called on the IO thread. |
| 41 void SetPermission(const GURL& origin, | 39 void SetPermission(const GURL& origin, |
| 42 blink::WebNotificationPermission permission); | 40 blink::WebNotificationPermission permission); |
| 43 | 41 |
| 44 // Clears the currently granted permissions. Must be called on the IO thread. | 42 // Clears the currently granted permissions. Must be called on the IO thread. |
| 45 void ClearPermissions(); | 43 void ClearPermissions(); |
| 46 | 44 |
| 47 // Pretends to show the given notification for testing, storing a delegate so | 45 // Pretends to show the given notification for testing, storing a delegate so |
| (...skipping 19 matching lines...) Expand all Loading... |
| 67 std::map<std::string, std::string> replacements_; | 65 std::map<std::string, std::string> replacements_; |
| 68 | 66 |
| 69 base::WeakPtrFactory<LayoutTestNotificationManager> weak_factory_; | 67 base::WeakPtrFactory<LayoutTestNotificationManager> weak_factory_; |
| 70 | 68 |
| 71 DISALLOW_COPY_AND_ASSIGN(LayoutTestNotificationManager); | 69 DISALLOW_COPY_AND_ASSIGN(LayoutTestNotificationManager); |
| 72 }; | 70 }; |
| 73 | 71 |
| 74 } // content | 72 } // content |
| 75 | 73 |
| 76 #endif // CONTENT_SHELL_BROWSER_LAYOUT_TEST_LAYOUT_TEST_NOTIFICATION_MANAGER_H_ | 74 #endif // CONTENT_SHELL_BROWSER_LAYOUT_TEST_LAYOUT_TEST_NOTIFICATION_MANAGER_H_ |
| OLD | NEW |