| 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_ |
| 11 | 11 |
| 12 #include <string> | 12 #include <string> |
| 13 | 13 |
| 14 #include "base/gtest_prod_util.h" | 14 #include "base/gtest_prod_util.h" |
| 15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 16 #include "base/memory/scoped_vector.h" | 16 #include "base/memory/scoped_vector.h" |
| 17 #include "chrome/browser/notifications/sync_notifier/notification_bitmap_fetcher
.h" | 17 #include "chrome/browser/bitmap_fetcher.h" |
| 18 #include "sync/api/sync_data.h" | 18 #include "sync/api/sync_data.h" |
| 19 #include "sync/protocol/sync.pb.h" | 19 #include "sync/protocol/sync.pb.h" |
| 20 #include "ui/gfx/image/image.h" | 20 #include "ui/gfx/image/image.h" |
| 21 #include "url/gurl.h" | 21 #include "url/gurl.h" |
| 22 | 22 |
| 23 namespace sync_pb { | 23 namespace sync_pb { |
| 24 class SyncedNotificationSpecifics; | 24 class SyncedNotificationSpecifics; |
| 25 } | 25 } |
| 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 NotificationBitmapFetcherDelegate { | 34 class SyncedNotification : public chrome::BitmapFetcherDelegate { |
| 35 public: | 35 public: |
| 36 explicit SyncedNotification(const syncer::SyncData& sync_data); | 36 explicit SyncedNotification(const syncer::SyncData& sync_data); |
| 37 | 37 |
| 38 virtual ~SyncedNotification(); | 38 virtual ~SyncedNotification(); |
| 39 | 39 |
| 40 enum ReadState { | 40 enum ReadState { |
| 41 kUnread = 1, | 41 kUnread = 1, |
| 42 kRead = 2, | 42 kRead = 2, |
| 43 kDismissed = 3, | 43 kDismissed = 3, |
| 44 }; | 44 }; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 // of the sync data. | 103 // of the sync data. |
| 104 sync_pb::EntitySpecifics GetEntitySpecifics() const; | 104 sync_pb::EntitySpecifics GetEntitySpecifics() const; |
| 105 | 105 |
| 106 // Write a notification to the console log. | 106 // Write a notification to the console log. |
| 107 void LogNotification(); | 107 void LogNotification(); |
| 108 | 108 |
| 109 private: | 109 private: |
| 110 // Helper function to mark a notification as read or dismissed. | 110 // Helper function to mark a notification as read or dismissed. |
| 111 void SetReadState(const ReadState& read_state); | 111 void SetReadState(const ReadState& read_state); |
| 112 | 112 |
| 113 // Method inherited from NotificationBitmapFetcher delegate. | 113 // Method inherited from BitmapFetcher delegate. |
| 114 virtual void OnFetchComplete(const GURL url, const SkBitmap* bitmap) OVERRIDE; | 114 virtual void OnFetchComplete(const GURL url, const SkBitmap* bitmap) OVERRIDE; |
| 115 | 115 |
| 116 // If this bitmap has a valid GURL, create a fetcher for it. | 116 // If this bitmap has a valid GURL, create a fetcher for it. |
| 117 void AddBitmapToFetchQueue(const GURL& gurl); | 117 void AddBitmapToFetchQueue(const GURL& gurl); |
| 118 | 118 |
| 119 // Check to see if we have responses for all the bitmaps we need. | 119 // Check to see if we have responses for all the bitmaps we need. |
| 120 bool AreAllBitmapsFetched(); | 120 bool AreAllBitmapsFetched(); |
| 121 | 121 |
| 122 sync_pb::SyncedNotificationSpecifics specifics_; | 122 sync_pb::SyncedNotificationSpecifics specifics_; |
| 123 NotificationUIManager* notification_manager_; | 123 NotificationUIManager* notification_manager_; |
| 124 ChromeNotifierService* notifier_service_; | 124 ChromeNotifierService* notifier_service_; |
| 125 Profile* profile_; | 125 Profile* profile_; |
| 126 bool toast_state_; | 126 bool toast_state_; |
| 127 ScopedVector<NotificationBitmapFetcher> fetchers_; | 127 ScopedVector<chrome::BitmapFetcher> fetchers_; |
| 128 gfx::Image app_icon_bitmap_; | 128 gfx::Image app_icon_bitmap_; |
| 129 gfx::Image sender_bitmap_; | 129 gfx::Image sender_bitmap_; |
| 130 gfx::Image image_bitmap_; | 130 gfx::Image image_bitmap_; |
| 131 std::vector<gfx::Image> button_bitmaps_; | 131 std::vector<gfx::Image> button_bitmaps_; |
| 132 bool app_icon_bitmap_fetch_pending_; | 132 bool app_icon_bitmap_fetch_pending_; |
| 133 bool sender_bitmap_fetch_pending_; | 133 bool sender_bitmap_fetch_pending_; |
| 134 bool image_bitmap_fetch_pending_; | 134 bool image_bitmap_fetch_pending_; |
| 135 std::vector<bool> button_bitmaps_fetch_pending_; | 135 std::vector<bool> button_bitmaps_fetch_pending_; |
| 136 | 136 |
| 137 | 137 |
| 138 friend class SyncedNotificationTest; | 138 friend class SyncedNotificationTest; |
| 139 | 139 |
| 140 FRIEND_TEST_ALL_PREFIXES(SyncedNotificationTest, AddBitmapToFetchQueueTest); | 140 FRIEND_TEST_ALL_PREFIXES(SyncedNotificationTest, AddBitmapToFetchQueueTest); |
| 141 FRIEND_TEST_ALL_PREFIXES(SyncedNotificationTest, OnFetchCompleteTest); | 141 FRIEND_TEST_ALL_PREFIXES(SyncedNotificationTest, OnFetchCompleteTest); |
| 142 FRIEND_TEST_ALL_PREFIXES(SyncedNotificationTest, QueueBitmapFetchJobsTest); | 142 FRIEND_TEST_ALL_PREFIXES(SyncedNotificationTest, QueueBitmapFetchJobsTest); |
| 143 FRIEND_TEST_ALL_PREFIXES(SyncedNotificationTest, EmptyBitmapTest); | 143 FRIEND_TEST_ALL_PREFIXES(SyncedNotificationTest, EmptyBitmapTest); |
| 144 | 144 |
| 145 DISALLOW_COPY_AND_ASSIGN(SyncedNotification); | 145 DISALLOW_COPY_AND_ASSIGN(SyncedNotification); |
| 146 }; | 146 }; |
| 147 | 147 |
| 148 } // namespace notifier | 148 } // namespace notifier |
| 149 | 149 |
| 150 #endif // CHROME_BROWSER_NOTIFICATIONS_SYNC_NOTIFIER_SYNCED_NOTIFICATION_H_ | 150 #endif // CHROME_BROWSER_NOTIFICATIONS_SYNC_NOTIFIER_SYNCED_NOTIFICATION_H_ |
| OLD | NEW |