| Index: content/shell/browser/layout_test/layout_test_notification_manager.h
|
| diff --git a/content/shell/browser/layout_test/layout_test_notification_manager.h b/content/shell/browser/layout_test/layout_test_notification_manager.h
|
| index b97efa44166ac46b7953797c3c393bed41eeb0d1..258f84a7414eb95c5ff66ca1e2a5613fdc0e93c6 100644
|
| --- a/content/shell/browser/layout_test/layout_test_notification_manager.h
|
| +++ b/content/shell/browser/layout_test/layout_test_notification_manager.h
|
| @@ -6,42 +6,68 @@
|
| #define CONTENT_SHELL_BROWSER_LAYOUT_TEST_LAYOUT_TEST_NOTIFICATION_MANAGER_H_
|
|
|
| #include <map>
|
| +#include <string>
|
|
|
| #include "base/callback.h"
|
| +#include "base/memory/weak_ptr.h"
|
| #include "third_party/WebKit/public/platform/WebNotificationPermission.h"
|
| #include "url/gurl.h"
|
|
|
| namespace content {
|
|
|
| +struct ShowDesktopNotificationHostMsgParams;
|
| +class DesktopNotificationDelegate;
|
| +
|
| // Responsible for tracking active notifications and allowed origins for the
|
| -// Web Notification API when running layout tests. The methods in this class
|
| -// should only be used on the IO thread.
|
| +// Web Notification API when running layout tests.
|
| class LayoutTestNotificationManager {
|
| public:
|
| LayoutTestNotificationManager();
|
| ~LayoutTestNotificationManager();
|
|
|
| // Checks whether |origin| has permission to display notifications in tests.
|
| + // Must be called on the IO thread.
|
| blink::WebNotificationPermission CheckPermission(
|
| const GURL& origin);
|
|
|
| // Requests permission for |origin| to display notifications in layout tests.
|
| + // Must be called on the IO thread.
|
| void RequestPermission(
|
| const GURL& origin,
|
| const base::Callback<void(blink::WebNotificationPermission)>& callback);
|
|
|
| // Sets the permission to display notifications for |origin| to |permission|.
|
| + // Must be called on the IO thread.
|
| void SetPermission(const GURL& origin,
|
| blink::WebNotificationPermission permission);
|
|
|
| - // Clears the currently granted permissions.
|
| + // Clears the currently granted permissions. Must be called on the IO thread.
|
| void ClearPermissions();
|
|
|
| + // Pretends to show the given notification for testing, storing a delegate so
|
| + // that interaction with the notification can be simulated later on. Must
|
| + // be called on the UI thread.
|
| + void Show(const ShowDesktopNotificationHostMsgParams& params,
|
| + scoped_ptr<DesktopNotificationDelegate> delegate,
|
| + base::Closure* cancel_callback);
|
| +
|
| + // Simulates a click on the notification titled |title|. Must be called on the
|
| + // UI thread.
|
| + void SimulateClick(const std::string& title);
|
| +
|
| private:
|
| + // Closes the notification titled |title|. Must be called on the UI thread.
|
| + void Close(const std::string& title);
|
| +
|
| typedef std::map<GURL, blink::WebNotificationPermission>
|
| NotificationPermissionMap;
|
| NotificationPermissionMap permission_map_;
|
|
|
| + std::map<std::string, DesktopNotificationDelegate*> notifications_;
|
| + std::map<std::string, std::string> replacements_;
|
| +
|
| + base::WeakPtrFactory<LayoutTestNotificationManager> weak_factory_;
|
| +
|
| DISALLOW_COPY_AND_ASSIGN(LayoutTestNotificationManager);
|
| };
|
|
|
|
|