blob: ba5b3a818289ffc40f3862dc417b592ebefc92a9 [file] [log] [blame]
miguelg87e986d2016-07-08 18:04:441// Copyright 2016 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 CHROME_BROWSER_NOTIFICATIONS_NON_PERSISTENT_NOTIFICATION_HANDLER_H_
6#define CHROME_BROWSER_NOTIFICATIONS_NON_PERSISTENT_NOTIFICATION_HANDLER_H_
7
miguelg87e986d2016-07-08 18:04:448#include "base/macros.h"
Peter Beverloo71dba342018-05-26 11:10:299#include "base/memory/weak_ptr.h"
miguelg87e986d2016-07-08 18:04:4410#include "chrome/browser/notifications/notification_handler.h"
11
miguelg87e986d2016-07-08 18:04:4412// NotificationHandler implementation for non persistent notifications.
13class NonPersistentNotificationHandler : public NotificationHandler {
14 public:
15 NonPersistentNotificationHandler();
16 ~NonPersistentNotificationHandler() override;
17
18 // NotificationHandler implementation
miguelgabf610a2017-06-02 17:31:4319 void OnShow(Profile* profile, const std::string& notification_id) override;
miguelg87e986d2016-07-08 18:04:4420 void OnClose(Profile* profile,
Evan Stade7e48597c2017-11-03 22:04:4821 const GURL& origin,
miguelg87e986d2016-07-08 18:04:4422 const std::string& notification_id,
Peter Beverloo64337af2017-11-21 18:04:0223 bool by_user,
24 base::OnceClosure completed_closure) override;
miguelg87e986d2016-07-08 18:04:4425 void OnClick(Profile* profile,
Evan Stade7e48597c2017-11-03 22:04:4826 const GURL& origin,
miguelg87e986d2016-07-08 18:04:4427 const std::string& notification_id,
Peter Beverlooae64ba92017-09-08 21:02:4528 const base::Optional<int>& action_index,
Peter Beverloo64337af2017-11-21 18:04:0229 const base::Optional<base::string16>& reply,
30 base::OnceClosure completed_closure) override;
Peter Beverloo884488b2017-12-05 18:20:2831 void DisableNotifications(Profile* profile, const GURL& origin) override;
32 void OpenSettings(Profile* profile, const GURL& origin) override;
miguelg87e986d2016-07-08 18:04:4433
miguelg87e986d2016-07-08 18:04:4434 private:
Peter Beverloo71dba342018-05-26 11:10:2935 // Called when the "click" event for non-persistent notification has been
36 // dispatched. The |success| boolean indicates whether the click could be
37 // delivered to the originating document as a JavaScript event.
38 void DidDispatchClickEvent(Profile* profile,
39 const GURL& origin,
40 const std::string& notification_id,
41 base::OnceClosure completed_closure,
42 bool success);
43
44 base::WeakPtrFactory<NonPersistentNotificationHandler> weak_ptr_factory_{
45 this};
46
miguelg87e986d2016-07-08 18:04:4447 DISALLOW_COPY_AND_ASSIGN(NonPersistentNotificationHandler);
48};
49
50#endif // CHROME_BROWSER_NOTIFICATIONS_NON_PERSISTENT_NOTIFICATION_HANDLER_H_