• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4 
5 #ifndef CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_UI_MANAGER_H_
6 #define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_UI_MANAGER_H_
7 
8 #include <set>
9 #include <string>
10 #include <vector>
11 
12 #include "base/basictypes.h"
13 
14 class GURL;
15 class Notification;
16 class PrefService;
17 class Profile;
18 
19 // This virtual interface is used to manage the UI surfaces for desktop
20 // notifications. There is one instance per profile.
21 class NotificationUIManager {
22  public:
~NotificationUIManager()23   virtual ~NotificationUIManager() {}
24 
25   // Creates an initialized UI manager.
26   static NotificationUIManager* Create(PrefService* local_state);
27 
28   // Adds a notification to be displayed. Virtual for unit test override.
29   virtual void Add(const Notification& notification, Profile* profile) = 0;
30 
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;
34 
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;
39 
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;
43 
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(
47       Profile* profile,
48       const GURL& source) = 0;
49 
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;
53 
54   // Removes notifications matching |profile|. Returns true if any were removed.
55   virtual bool CancelAllByProfile(Profile* profile) = 0;
56 
57   // Cancels all pending notifications and closes anything currently showing.
58   // Used when the app is terminating.
59   virtual void CancelAll() = 0;
60 
61  protected:
NotificationUIManager()62   NotificationUIManager() {}
63 
64  private:
65   DISALLOW_COPY_AND_ASSIGN(NotificationUIManager);
66 };
67 
68 #endif  // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_UI_MANAGER_H_
69