OLD | NEW |
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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 GURL GetDefaultDestinationUrl() const; | 67 GURL GetDefaultDestinationUrl() const; |
68 std::string GetButtonTitle(unsigned int which_button) const; | 68 std::string GetButtonTitle(unsigned int which_button) const; |
69 GURL GetButtonIconUrl(unsigned int which_button) const; | 69 GURL GetButtonIconUrl(unsigned int which_button) const; |
70 GURL GetButtonUrl(unsigned int which_button) const; | 70 GURL GetButtonUrl(unsigned int which_button) const; |
71 GURL GetProfilePictureUrl(unsigned int which_url) const; | 71 GURL GetProfilePictureUrl(unsigned int which_url) const; |
72 size_t GetProfilePictureCount() const; | 72 size_t GetProfilePictureCount() const; |
73 size_t GetNotificationCount() const; | 73 size_t GetNotificationCount() const; |
74 size_t GetButtonCount() const; | 74 size_t GetButtonCount() const; |
75 std::string GetContainedNotificationTitle(int index) const; | 75 std::string GetContainedNotificationTitle(int index) const; |
76 std::string GetContainedNotificationMessage(int index) const; | 76 std::string GetContainedNotificationMessage(int index) const; |
77 std::string GetSendingServiceId() const; | |
78 const gfx::Image& GetAppIcon() const; | 77 const gfx::Image& GetAppIcon() const; |
79 | 78 |
80 // Use this to prevent toasting a notification. | 79 // Use this to prevent toasting a notification. |
81 void SetToastState(bool toast_state); | 80 void SetToastState(bool toast_state); |
82 | 81 |
83 bool EqualsIgnoringReadState(const SyncedNotification& other) const; | 82 bool EqualsIgnoringReadState(const SyncedNotification& other) const; |
84 | 83 |
85 void NotificationHasBeenRead(); | 84 void NotificationHasBeenRead(); |
86 void NotificationHasBeenDismissed(); | 85 void NotificationHasBeenDismissed(); |
87 | 86 |
88 // Fill up the queue of bitmaps to fetch. | 87 // Fill up the queue of bitmaps to fetch. |
89 void QueueBitmapFetchJobs(NotificationUIManager* notification_manager, | 88 void QueueBitmapFetchJobs(ChromeNotifierService* notifier_service, |
90 ChromeNotifierService* notifier_service, | |
91 Profile* profile); | 89 Profile* profile); |
92 | 90 |
| 91 void set_notification_manager(NotificationUIManager* notification_manager) { |
| 92 notification_manager_ = notification_manager; |
| 93 } |
| 94 |
| 95 void set_notifier_service(ChromeNotifierService* notifier) { |
| 96 notifier_service_ = notifier; |
| 97 } |
| 98 |
93 // Start the bitmap fetching. When it is complete, the callback | 99 // Start the bitmap fetching. When it is complete, the callback |
94 // will call Show(). | 100 // will call Show(). |
95 void StartBitmapFetch(); | 101 void StartBitmapFetch(); |
96 | 102 |
97 // Display the notification in the notification center | 103 // Display the notification in the notification center |
98 void Show(NotificationUIManager* notification_manager, | 104 void Show(Profile* profile); |
99 ChromeNotifierService* notifier_service, | 105 |
100 Profile* profile); | 106 // Display the notification if it has the specified app_id_name. |
| 107 void ShowAllForAppId(Profile* profile, |
| 108 std::string app_id_name); |
| 109 |
| 110 // Remove the notification if it has the specified app_id_name. |
| 111 void HideAllForAppId(std::string app_id_name); |
101 | 112 |
102 // This gets a pointer to the SyncedNotificationSpecifics part | 113 // This gets a pointer to the SyncedNotificationSpecifics part |
103 // of the sync data. | 114 // of the sync data. |
104 sync_pb::EntitySpecifics GetEntitySpecifics() const; | 115 sync_pb::EntitySpecifics GetEntitySpecifics() const; |
105 | 116 |
106 // Write a notification to the console log. | 117 // Write a notification to the console log. |
107 void LogNotification(); | 118 void LogNotification(); |
108 | 119 |
109 private: | 120 private: |
110 // Helper function to mark a notification as read or dismissed. | 121 // Helper function to mark a notification as read or dismissed. |
111 void SetReadState(const ReadState& read_state); | 122 void SetReadState(const ReadState& read_state); |
112 | 123 |
113 // Method inherited from BitmapFetcher delegate. | 124 // Method inherited from BitmapFetcher delegate. |
114 virtual void OnFetchComplete(const GURL url, const SkBitmap* bitmap) OVERRIDE; | 125 virtual void OnFetchComplete(const GURL url, const SkBitmap* bitmap) OVERRIDE; |
115 | 126 |
116 // If this bitmap has a valid GURL, create a fetcher for it. | 127 // If this bitmap has a valid GURL, create a fetcher for it. |
117 void AddBitmapToFetchQueue(const GURL& gurl); | 128 void CreateBitmapFetcher(const GURL& gurl); |
118 | 129 |
119 // Check to see if we have responses for all the bitmaps we need. | 130 // Check to see if we have responses for all the bitmaps we need. |
120 bool AreAllBitmapsFetched(); | 131 bool AreAllBitmapsFetched(); |
121 | 132 |
122 sync_pb::SyncedNotificationSpecifics specifics_; | 133 sync_pb::SyncedNotificationSpecifics specifics_; |
123 NotificationUIManager* notification_manager_; | 134 NotificationUIManager* notification_manager_; |
124 ChromeNotifierService* notifier_service_; | 135 ChromeNotifierService* notifier_service_; |
125 Profile* profile_; | 136 Profile* profile_; |
126 bool toast_state_; | 137 bool toast_state_; |
127 ScopedVector<chrome::BitmapFetcher> fetchers_; | 138 ScopedVector<chrome::BitmapFetcher> fetchers_; |
128 gfx::Image app_icon_bitmap_; | 139 gfx::Image app_icon_bitmap_; |
129 gfx::Image sender_bitmap_; | 140 gfx::Image sender_bitmap_; |
130 gfx::Image image_bitmap_; | 141 gfx::Image image_bitmap_; |
131 std::vector<gfx::Image> button_bitmaps_; | 142 std::vector<gfx::Image> button_bitmaps_; |
132 bool app_icon_bitmap_fetch_pending_; | 143 bool app_icon_bitmap_fetch_pending_; |
133 bool sender_bitmap_fetch_pending_; | 144 bool sender_bitmap_fetch_pending_; |
134 bool image_bitmap_fetch_pending_; | 145 bool image_bitmap_fetch_pending_; |
135 std::vector<bool> button_bitmaps_fetch_pending_; | 146 std::vector<bool> button_bitmaps_fetch_pending_; |
136 | 147 |
137 | |
138 friend class SyncedNotificationTest; | 148 friend class SyncedNotificationTest; |
139 | 149 |
140 FRIEND_TEST_ALL_PREFIXES(SyncedNotificationTest, AddBitmapToFetchQueueTest); | 150 FRIEND_TEST_ALL_PREFIXES(SyncedNotificationTest, CreateBitmapFetcherTest); |
141 FRIEND_TEST_ALL_PREFIXES(SyncedNotificationTest, OnFetchCompleteTest); | 151 FRIEND_TEST_ALL_PREFIXES(SyncedNotificationTest, OnFetchCompleteTest); |
142 FRIEND_TEST_ALL_PREFIXES(SyncedNotificationTest, QueueBitmapFetchJobsTest); | 152 FRIEND_TEST_ALL_PREFIXES(SyncedNotificationTest, QueueBitmapFetchJobsTest); |
143 FRIEND_TEST_ALL_PREFIXES(SyncedNotificationTest, EmptyBitmapTest); | 153 FRIEND_TEST_ALL_PREFIXES(SyncedNotificationTest, EmptyBitmapTest); |
| 154 FRIEND_TEST_ALL_PREFIXES(SyncedNotificationTest, ShowIfNewlyEnabledTest); |
| 155 FRIEND_TEST_ALL_PREFIXES(SyncedNotificationTest, HideIfNewlyRemovedTest); |
144 | 156 |
145 DISALLOW_COPY_AND_ASSIGN(SyncedNotification); | 157 DISALLOW_COPY_AND_ASSIGN(SyncedNotification); |
146 }; | 158 }; |
147 | 159 |
148 } // namespace notifier | 160 } // namespace notifier |
149 | 161 |
150 #endif // CHROME_BROWSER_NOTIFICATIONS_SYNC_NOTIFIER_SYNCED_NOTIFICATION_H_ | 162 #endif // CHROME_BROWSER_NOTIFICATIONS_SYNC_NOTIFIER_SYNCED_NOTIFICATION_H_ |
OLD | NEW |