Don't show supervised user as "already on this device" while they're being imported.
[chromium-blink-merge.git] / chrome / browser / notifications / notification_ui_manager.h
blob49d0ed91f95cfd81e10ff236d31815c6eaaddeb8
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_
8 #include <set>
9 #include <string>
10 #include <vector>
12 #include "base/basictypes.h"
14 typedef void* ProfileID;
16 class GURL;
17 class Notification;
18 class PrefService;
19 class Profile;
21 // This virtual interface is used to manage the UI surfaces for desktop
22 // notifications. There is just one instance for all profiles.
23 // This represents the middle layer of notification and it's aware of profile.
24 // It identifies a notification by the id string and a profile, hence two
25 // notifications from two different profiles, even though they may have
26 // identical ids, will not be considered the same notification.
27 // This interface will generate a new id behind the scene based on the id string
28 // and the profile's characteristics for each notification and use this new id
29 // to call lower layer MessageCenter interface which is profile agnostic.
30 // Therefore the ids passed into this interface are not the same as those passed
31 // into the MessageCenter interface.
32 class NotificationUIManager {
33 public:
34 // Convert a profile pointer into an opaque profile id, which can be safely
35 // used by FindById() and CancelById() even after a profile may have been
36 // destroyed.
37 static ProfileID GetProfileID(Profile* profile) {
38 return static_cast<ProfileID>(profile);
41 virtual ~NotificationUIManager() {}
43 // Creates an initialized UI manager.
44 static NotificationUIManager* Create(PrefService* local_state);
46 // Adds a notification to be displayed. Virtual for unit test override.
47 virtual void Add(const Notification& notification, Profile* profile) = 0;
49 // Updates an existing notification. If |update_progress_only|, assume
50 // only message and progress properties are updated.
51 virtual bool Update(const Notification& notification, Profile* profile) = 0;
53 // Returns the pointer to a notification if it match the supplied ID, either
54 // currently displayed or in the queue.
55 // This function can be bound for delayed execution, where a profile pointer
56 // may not be valid. Hence caller needs to call the static GetProfileID(...)
57 // function to turn a profile pointer into a profile id and pass that in.
58 virtual const Notification* FindById(const std::string& delegate_id,
59 ProfileID profile_id) const = 0;
61 // Removes any notifications matching the supplied ID, either currently
62 // displayed or in the queue. Returns true if anything was removed.
63 // This function can be bound for delayed execution, where a profile pointer
64 // may not be valid. Hence caller needs to call the static GetProfileID(...)
65 // function to turn a profile pointer into a profile id and pass that in.
66 virtual bool CancelById(const std::string& delegate_id,
67 ProfileID profile_id) = 0;
69 // Returns the set of all delegate IDs for notifications from the passed
70 // |profile| and |source|.
71 // TODO(peter): Change Profile* to ProfileID to clarify that the profile
72 // should not be used for making any calls, as it might be dead.
73 virtual std::set<std::string> GetAllIdsByProfileAndSourceOrigin(
74 Profile* profile,
75 const GURL& source) = 0;
77 // Returns the set of all delegate IDs for notifications from |profile|.
78 // TODO(peter): Change Profile* to ProfileID to clarify that the profile
79 // should not be used for making any calls, as it might be dead.
80 virtual std::set<std::string> GetAllIdsByProfile(Profile* profile) = 0;
82 // Removes notifications matching the |source_origin| (which could be an
83 // extension ID). Returns true if anything was removed.
84 virtual bool CancelAllBySourceOrigin(const GURL& source_origin) = 0;
86 // Removes notifications matching |profile_id|. Returns true if any were
87 // removed.
88 virtual bool CancelAllByProfile(ProfileID profile_id) = 0;
90 // Cancels all pending notifications and closes anything currently showing.
91 // Used when the app is terminating.
92 virtual void CancelAll() = 0;
94 protected:
95 NotificationUIManager() {}
97 private:
98 DISALLOW_COPY_AND_ASSIGN(NotificationUIManager);
101 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_UI_MANAGER_H_