1 // Copyright (c) 2012 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.
5 #ifndef CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_UI_MANAGER_H_
6 #define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_UI_MANAGER_H_
12 #include "base/basictypes.h"
19 // This virtual interface is used to manage the UI surfaces for desktop
20 // notifications. There is one instance per profile.
21 class NotificationUIManager
{
23 virtual ~NotificationUIManager() {}
25 // Creates an initialized UI manager.
26 static NotificationUIManager
* Create(PrefService
* local_state
);
28 // Adds a notification to be displayed. Virtual for unit test override.
29 virtual void Add(const Notification
& notification
, Profile
* profile
) = 0;
31 // Updates an existing notification. If |update_progress_only|, assume
32 // only message and progress properties are updated.
33 virtual bool Update(const Notification
& notification
, Profile
* profile
) = 0;
35 // Returns the pointer to a notification if it match the supplied ID, either
36 // currently displayed or in the queue.
37 virtual const Notification
* FindById(
38 const std::string
& notification_id
) const = 0;
40 // Removes any notifications matching the supplied ID, either currently
41 // displayed or in the queue. Returns true if anything was removed.
42 virtual bool CancelById(const std::string
& notification_id
) = 0;
44 // Adds the notification_id for each outstanding notification to the set
45 // |notification_ids| (must not be NULL).
46 virtual std::set
<std::string
> GetAllIdsByProfileAndSourceOrigin(
48 const GURL
& source
) = 0;
50 // Removes notifications matching the |source_origin| (which could be an
51 // extension ID). Returns true if anything was removed.
52 virtual bool CancelAllBySourceOrigin(const GURL
& source_origin
) = 0;
54 // Removes notifications matching |profile|. Returns true if any were removed.
55 virtual bool CancelAllByProfile(Profile
* profile
) = 0;
57 // Cancels all pending notifications and closes anything currently showing.
58 // Used when the app is terminating.
59 virtual void CancelAll() = 0;
62 NotificationUIManager() {}
65 DISALLOW_COPY_AND_ASSIGN(NotificationUIManager
);
68 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_UI_MANAGER_H_