blob: 6e6959073544413c35a6a207b8dd51560e773261 [file] [log] [blame]
Avi Drissman4a8573c2022-09-09 19:35:541// Copyright 2016 The Chromium Authors
miguelg87e986d2016-07-08 18:04:442// 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
Peter Beverloo71dba342018-05-26 11:10:298#include "base/memory/weak_ptr.h"
miguelg87e986d2016-07-08 18:04:449#include "chrome/browser/notifications/notification_handler.h"
10
miguelg87e986d2016-07-08 18:04:4411// NotificationHandler implementation for non persistent notifications.
12class NonPersistentNotificationHandler : public NotificationHandler {
13 public:
14 NonPersistentNotificationHandler();
Sundoo Kimdd91d952020-08-26 17:11:2015 NonPersistentNotificationHandler(const NonPersistentNotificationHandler&) =
16 delete;
17 NonPersistentNotificationHandler& operator=(
18 const NonPersistentNotificationHandler&) = delete;
miguelg87e986d2016-07-08 18:04:4419 ~NonPersistentNotificationHandler() override;
20
21 // NotificationHandler implementation
miguelgabf610a2017-06-02 17:31:4322 void OnShow(Profile* profile, const std::string& notification_id) override;
miguelg87e986d2016-07-08 18:04:4423 void OnClose(Profile* profile,
Evan Stade7e48597c2017-11-03 22:04:4824 const GURL& origin,
miguelg87e986d2016-07-08 18:04:4425 const std::string& notification_id,
Peter Beverloo64337af2017-11-21 18:04:0226 bool by_user,
27 base::OnceClosure completed_closure) override;
miguelg87e986d2016-07-08 18:04:4428 void OnClick(Profile* profile,
Evan Stade7e48597c2017-11-03 22:04:4829 const GURL& origin,
miguelg87e986d2016-07-08 18:04:4430 const std::string& notification_id,
Arthur Sonzognife132ee2024-01-15 11:01:0431 const std::optional<int>& action_index,
32 const std::optional<std::u16string>& reply,
Peter Beverloo64337af2017-11-21 18:04:0233 base::OnceClosure completed_closure) override;
Peter Beverloo884488b2017-12-05 18:20:2834 void DisableNotifications(Profile* profile, const GURL& origin) override;
35 void OpenSettings(Profile* profile, const GURL& origin) override;
miguelg87e986d2016-07-08 18:04:4436
miguelg87e986d2016-07-08 18:04:4437 private:
Peter Beverloo71dba342018-05-26 11:10:2938 // Called when the "click" event for non-persistent notification has been
39 // dispatched. The |success| boolean indicates whether the click could be
40 // delivered to the originating document as a JavaScript event.
41 void DidDispatchClickEvent(Profile* profile,
42 const GURL& origin,
43 const std::string& notification_id,
44 base::OnceClosure completed_closure,
45 bool success);
46
47 base::WeakPtrFactory<NonPersistentNotificationHandler> weak_ptr_factory_{
48 this};
miguelg87e986d2016-07-08 18:04:4449};
50
51#endif // CHROME_BROWSER_NOTIFICATIONS_NON_PERSISTENT_NOTIFICATION_HANDLER_H_