Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(294)

Side by Side Diff: chrome/browser/notifications/sync_notifier/synced_notification.h

Issue 193773003: Turn on and use the AppInfo data. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Turn on app info: LGTM nits Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This class represents the data for a single Synced Notification. 5 // This class represents the data for a single Synced Notification.
6 // It should map 1-1 to all the data in synced_notification_sepcifics.proto, 6 // It should map 1-1 to all the data in synced_notification_sepcifics.proto,
7 // and the data and render protobufs that the specifics protobuf contains. 7 // and the data and render protobufs that the specifics protobuf contains.
8 8
9 #ifndef CHROME_BROWSER_NOTIFICATIONS_SYNC_NOTIFIER_SYNCED_NOTIFICATION_H_ 9 #ifndef CHROME_BROWSER_NOTIFICATIONS_SYNC_NOTIFIER_SYNCED_NOTIFICATION_H_
10 #define CHROME_BROWSER_NOTIFICATIONS_SYNC_NOTIFIER_SYNCED_NOTIFICATION_H_ 10 #define CHROME_BROWSER_NOTIFICATIONS_SYNC_NOTIFIER_SYNCED_NOTIFICATION_H_
(...skipping 15 matching lines...) Expand all
26 26
27 class NotificationUIManager; 27 class NotificationUIManager;
28 class Profile; 28 class Profile;
29 29
30 namespace notifier { 30 namespace notifier {
31 31
32 class ChromeNotifierService; 32 class ChromeNotifierService;
33 33
34 class SyncedNotification : public chrome::BitmapFetcherDelegate { 34 class SyncedNotification : public chrome::BitmapFetcherDelegate {
35 public: 35 public:
36 explicit SyncedNotification(const syncer::SyncData& sync_data); 36 SyncedNotification(const syncer::SyncData& sync_data,
37 ChromeNotifierService* notifier,
38 NotificationUIManager* notification_manager);
37 39
38 virtual ~SyncedNotification(); 40 virtual ~SyncedNotification();
39 41
40 enum ReadState { 42 enum ReadState {
41 kUnread = 1, 43 kUnread = 1,
42 kRead = 2, 44 kRead = 2,
43 kDismissed = 3, 45 kDismissed = 3,
44 }; 46 };
45 47
46 static const int kUndefinedPriority = 65535; 48 static const int kUndefinedPriority = 65535;
47 49
48 void Update(const syncer::SyncData& sync_data); 50 void Update(const syncer::SyncData& sync_data);
49 51
52 // Display the notification in the notification center
53 void Show(Profile* profile);
54
55 // This gets a pointer to the SyncedNotificationSpecifics part
56 // of the sync data.
57 sync_pb::EntitySpecifics GetEntitySpecifics() const;
58
59 // Display the notification if it has the specified app_id_name.
60 void ShowAllForAppId(Profile* profile,
61 std::string app_id_name);
62
63 // Remove the notification if it has the specified app_id_name.
64 void HideAllForAppId(std::string app_id_name);
65
66 // Fill up the queue of bitmaps to fetch.
67 void QueueBitmapFetchJobs(ChromeNotifierService* notifier_service,
68 Profile* profile);
69
70 // Start the bitmap fetching. When it is complete, the callback
71 // will call Show().
72 void StartBitmapFetch();
73
74 // Check against an incoming notification, see if only the read state is
75 // different.
76 bool EqualsIgnoringReadState(const SyncedNotification& other) const;
77
78 // Mark the notification as Read.
79 void NotificationHasBeenRead();
80
81 // Mark a notification as Dismissed (deleted).
82 void NotificationHasBeenDismissed();
83
50 // Here are some helper functions to get individual data parts out of a 84 // Here are some helper functions to get individual data parts out of a
51 // SyncedNotification. 85 // SyncedNotification.
52 std::string GetTitle() const; 86 std::string GetTitle() const;
53 std::string GetHeading() const; 87 std::string GetHeading() const;
54 std::string GetDescription() const; 88 std::string GetDescription() const;
55 std::string GetAnnotation() const; 89 std::string GetAnnotation() const;
56 std::string GetAppId() const; 90 std::string GetAppId() const;
57 std::string GetKey() const; 91 std::string GetKey() const;
58 GURL GetOriginUrl() const; 92 GURL GetOriginUrl() const;
59 GURL GetAppIconUrl() const; 93 GURL GetAppIconUrl() const;
60 GURL GetImageUrl() const; 94 GURL GetImageUrl() const;
61 std::string GetText() const; 95 std::string GetText() const;
62 ReadState GetReadState() const; 96 ReadState GetReadState() const;
63 uint64 GetCreationTime() const; 97 uint64 GetCreationTime() const;
64 int GetPriority() const; 98 int GetPriority() const;
65 std::string GetDefaultDestinationTitle() const; 99 std::string GetDefaultDestinationTitle() const;
66 GURL GetDefaultDestinationIconUrl() const; 100 GURL GetDefaultDestinationIconUrl() const;
67 GURL GetDefaultDestinationUrl() const; 101 GURL GetDefaultDestinationUrl() const;
68 std::string GetButtonTitle(unsigned int which_button) const; 102 std::string GetButtonTitle(unsigned int which_button) const;
69 GURL GetButtonIconUrl(unsigned int which_button) const; 103 GURL GetButtonIconUrl(unsigned int which_button) const;
70 GURL GetButtonUrl(unsigned int which_button) const; 104 GURL GetButtonUrl(unsigned int which_button) const;
71 GURL GetProfilePictureUrl(unsigned int which_url) const; 105 GURL GetProfilePictureUrl(unsigned int which_url) const;
72 size_t GetProfilePictureCount() const; 106 size_t GetProfilePictureCount() const;
73 size_t GetNotificationCount() const; 107 size_t GetNotificationCount() const;
74 size_t GetButtonCount() const; 108 size_t GetButtonCount() const;
75 std::string GetContainedNotificationTitle(int index) const; 109 std::string GetContainedNotificationTitle(int index) const;
76 std::string GetContainedNotificationMessage(int index) const; 110 std::string GetContainedNotificationMessage(int index) const;
77 std::string GetSendingServiceId() const;
78 const gfx::Image& GetAppIcon() const; 111 const gfx::Image& GetAppIcon() const;
79 112
80 // Use this to prevent toasting a notification. 113 // Use this to prevent toasting a notification.
81 void SetToastState(bool toast_state); 114 void set_toast_state(bool toast_state);
82
83 bool EqualsIgnoringReadState(const SyncedNotification& other) const;
84
85 void NotificationHasBeenRead();
86 void NotificationHasBeenDismissed();
87
88 // Fill up the queue of bitmaps to fetch.
89 void QueueBitmapFetchJobs(NotificationUIManager* notification_manager,
90 ChromeNotifierService* notifier_service,
91 Profile* profile);
92
93 // Start the bitmap fetching. When it is complete, the callback
94 // will call Show().
95 void StartBitmapFetch();
96
97 // Display the notification in the notification center
98 void Show(NotificationUIManager* notification_manager,
99 ChromeNotifierService* notifier_service,
100 Profile* profile);
101
102 // This gets a pointer to the SyncedNotificationSpecifics part
103 // of the sync data.
104 sync_pb::EntitySpecifics GetEntitySpecifics() const;
105 115
106 // Write a notification to the console log. 116 // Write a notification to the console log.
107 void LogNotification(); 117 void LogNotification();
108 118
109 private: 119 private:
110 // Helper function to mark a notification as read or dismissed.
111 void SetReadState(const ReadState& read_state);
112
113 // Method inherited from BitmapFetcher delegate. 120 // Method inherited from BitmapFetcher delegate.
114 virtual void OnFetchComplete(const GURL url, const SkBitmap* bitmap) OVERRIDE; 121 virtual void OnFetchComplete(const GURL url, const SkBitmap* bitmap) OVERRIDE;
115 122
116 // If this bitmap has a valid GURL, create a fetcher for it. 123 // If this bitmap has a valid GURL, create a fetcher for it.
117 void AddBitmapToFetchQueue(const GURL& gurl); 124 void CreateBitmapFetcher(const GURL& gurl);
118 125
119 // Check to see if we have responses for all the bitmaps we need. 126 // Check to see if we have responses for all the bitmaps we need.
120 bool AreAllBitmapsFetched(); 127 bool AreAllBitmapsFetched();
121 128
129 // Helper function to mark a notification as read or dismissed.
130 void SetReadState(const ReadState& read_state);
131
132 void SetNotifierServiceForTest(ChromeNotifierService* notifier) {
133 notifier_service_ = notifier;
134 }
135
122 sync_pb::SyncedNotificationSpecifics specifics_; 136 sync_pb::SyncedNotificationSpecifics specifics_;
123 NotificationUIManager* notification_manager_; 137 NotificationUIManager* notification_manager_;
124 ChromeNotifierService* notifier_service_; 138 ChromeNotifierService* notifier_service_;
125 Profile* profile_; 139 Profile* profile_;
126 bool toast_state_; 140 bool toast_state_;
127 ScopedVector<chrome::BitmapFetcher> fetchers_; 141 ScopedVector<chrome::BitmapFetcher> fetchers_;
128 gfx::Image app_icon_bitmap_; 142 gfx::Image app_icon_bitmap_;
129 gfx::Image sender_bitmap_; 143 gfx::Image sender_bitmap_;
130 gfx::Image image_bitmap_; 144 gfx::Image image_bitmap_;
131 std::vector<gfx::Image> button_bitmaps_; 145 std::vector<gfx::Image> button_bitmaps_;
132 bool app_icon_bitmap_fetch_pending_; 146 bool app_icon_bitmap_fetch_pending_;
133 bool sender_bitmap_fetch_pending_; 147 bool sender_bitmap_fetch_pending_;
134 bool image_bitmap_fetch_pending_; 148 bool image_bitmap_fetch_pending_;
135 std::vector<bool> button_bitmaps_fetch_pending_; 149 std::vector<bool> button_bitmaps_fetch_pending_;
136 150
137
138 friend class SyncedNotificationTest; 151 friend class SyncedNotificationTest;
139 152
140 FRIEND_TEST_ALL_PREFIXES(SyncedNotificationTest, AddBitmapToFetchQueueTest); 153 FRIEND_TEST_ALL_PREFIXES(SyncedNotificationTest, CreateBitmapFetcherTest);
141 FRIEND_TEST_ALL_PREFIXES(SyncedNotificationTest, OnFetchCompleteTest); 154 FRIEND_TEST_ALL_PREFIXES(SyncedNotificationTest, OnFetchCompleteTest);
142 FRIEND_TEST_ALL_PREFIXES(SyncedNotificationTest, QueueBitmapFetchJobsTest); 155 FRIEND_TEST_ALL_PREFIXES(SyncedNotificationTest, QueueBitmapFetchJobsTest);
143 FRIEND_TEST_ALL_PREFIXES(SyncedNotificationTest, EmptyBitmapTest); 156 FRIEND_TEST_ALL_PREFIXES(SyncedNotificationTest, EmptyBitmapTest);
157 FRIEND_TEST_ALL_PREFIXES(SyncedNotificationTest, ShowIfNewlyEnabledTest);
158 FRIEND_TEST_ALL_PREFIXES(SyncedNotificationTest, HideIfNewlyRemovedTest);
159 FRIEND_TEST_ALL_PREFIXES(ChromeNotifierServiceTest, SetAddedAppIdsTest);
144 160
145 DISALLOW_COPY_AND_ASSIGN(SyncedNotification); 161 DISALLOW_COPY_AND_ASSIGN(SyncedNotification);
146 }; 162 };
147 163
148 } // namespace notifier 164 } // namespace notifier
149 165
150 #endif // CHROME_BROWSER_NOTIFICATIONS_SYNC_NOTIFIER_SYNCED_NOTIFICATION_H_ 166 #endif // CHROME_BROWSER_NOTIFICATIONS_SYNC_NOTIFIER_SYNCED_NOTIFICATION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698