Index: chrome/browser/notifications/sync_notifier/synced_notification_app_info.h |
diff --git a/chrome/browser/notifications/sync_notifier/synced_notification_app_info.h b/chrome/browser/notifications/sync_notifier/synced_notification_app_info.h |
index e35d692e0f85bfb56e0847f762e6e1c15e565b4b..50661b34f0a448f091a21f1d1f296be1def3dbae 100644 |
--- a/chrome/browser/notifications/sync_notifier/synced_notification_app_info.h |
+++ b/chrome/browser/notifications/sync_notifier/synced_notification_app_info.h |
@@ -11,14 +11,25 @@ |
#include <string> |
#include <vector> |
+#include "base/memory/scoped_vector.h" |
+#include "chrome/browser/bitmap_fetcher.h" |
+#include "ui/gfx/image/image.h" |
+#include "ui/message_center/notifier_settings.h" |
#include "url/gurl.h" |
+class Profile; |
+ |
namespace notifier { |
-class SyncedNotificationAppInfo { |
+class SyncedNotificationAppInfoService; |
+ |
+class SyncedNotificationAppInfo : public chrome::BitmapFetcherDelegate { |
public: |
- explicit SyncedNotificationAppInfo(const std::string& settings_display_name); |
- ~SyncedNotificationAppInfo(); |
+ SyncedNotificationAppInfo( |
+ Profile* const profile, |
+ const std::string& settings_display_name, |
+ SyncedNotificationAppInfoService* synced_notification_app_info_service); |
+ virtual ~SyncedNotificationAppInfo(); |
// Return true if the app id is present in this AppInfo protobuf. |
bool HasAppId(const std::string& app_id); |
@@ -32,23 +43,98 @@ class SyncedNotificationAppInfo { |
std::string settings_display_name() const { return settings_display_name_; } |
void SetSettingsIcon(const GURL& settings_icon) { |
- settings_icon_url_ = settings_icon; |
+ settings_low_dpi_icon_url_ = settings_icon; |
+ } |
+ |
+ GURL settings_icon_url() { return settings_low_dpi_icon_url_; } |
+ |
+ // If an app info is updated, keep track of the newly added app ids so we can |
+ // later inform the chrome_notifier_service to show any newly enabled |
+ // notifications. |
+ void SetAddedAppIds(std::vector<std::string> added_app_ids) { |
+ added_app_ids_ = added_app_ids; |
+ } |
+ |
+ std::vector<std::string> added_app_ids() { return added_app_ids_; } |
+ |
+ // If an app info is updated removing app ids, keep track of the removed app |
+ // ids so we can later remove any affected notfications. |
dewittj
2014/03/20 18:00:28
Shouldn't remove be instant? We don't have to wai
Pete Williamson
2014/03/25 00:08:37
I chose to wait until the bitmap fetch is done for
|
+ void SetRemovedAppIds(std::vector<std::string> removed_app_ids) { |
+ removed_app_ids_ = removed_app_ids; |
} |
- GURL settings_icon_url() { return settings_icon_url_; } |
+ std::vector<std::string> removed_app_ids() { return removed_app_ids_; } |
+ |
+ // TODO(petewil): Check resolution of system and return the right icon. |
+ gfx::Image icon() { return settings_low_dpi_icon_; } |
// Build a vector of app_ids that this app_info contains. |
- void GetAppIdList(std::vector<std::string>* app_id_list); |
+ std::vector<std::string> GetAppIdList(); |
+ |
+ // Set up for fetching all the bitmaps in this AppInfo. |
+ void QueueBitmapFetchJobs(); |
+ |
+ // If this bitmap has a valid GURL, create a fetcher for it. |
+ void CreateBitmapFetcher(const GURL& url); |
+ |
+ // Start the bitmap fetching. When it is complete, the callback |
+ // will notify the ChromeNotifierService of the new app info availablity. |
+ void StartBitmapFetch(); |
+ |
+ // Method inherited from BitmapFetcher delegate. |
+ virtual void OnFetchComplete(const GURL url, const SkBitmap* bitmap) OVERRIDE; |
+ |
+ // Check to see if we have responses for all the bitmaps we need. |
+ bool AreAllBitmapsFetched(); |
+ |
+ // Construct a Message Center NotifierId from this synced notification app |
+ // info object. |
+ message_center::NotifierId GetNotifierId(); |
private: |
// TODO(petewil): We need a unique id for a key. We will use the settings |
- // display name for now, but it would be more robust with a unique id. |
+ // display name, but it would be more robust with a unique id. |
+ Profile* profile_; |
std::vector<std::string> app_ids_; |
std::string settings_display_name_; |
- // TODO(petewil): We should get 1x and 2x versions of all these images. |
- GURL settings_icon_url_; |
- // TODO(petewil): Add monochrome icons for app badging and welcome icons. |
- // TODO(petewil): Add a landing page link for settings/welcome toast. |
+ // The 1x and 2x versions of the icon for settings, small. |
+ GURL settings_low_dpi_icon_url_; |
+ GURL settings_high_dpi_icon_url_; |
+ gfx::Image settings_low_dpi_icon_; |
dewittj
2014/03/20 18:00:28
There is no need for settings_low_dpi_icon_ and se
Pete Williamson
2014/03/25 00:08:37
already fixed by my most recent patch.
|
+ gfx::Image settings_high_dpi_icon_; |
+ bool settings_low_dpi_icon_fetched_; |
+ bool settings_high_dpi_icon_fetched_; |
+ // Monochrome icons for app badging (1x and 2x), small. |
+ GURL monochrome_low_dpi_icon_url_; |
+ GURL monochrome_high_dpi_icon_url_; |
+ gfx::Image monochrome_low_dpi_icon_; |
+ gfx::Image monochrome_high_dpi_icon_; |
+ bool monochrome_low_dpi_icon_fetched_; |
+ bool monochrome_high_dpi_icon_fetched_; |
+ // Welcome dialog icon (1x and 2x), large. |
+ GURL welcome_low_dpi_icon_url_; |
+ GURL welcome_high_dpi_icon_url_; |
+ gfx::Image welcome_low_dpi_icon_; |
+ gfx::Image welcome_high_dpi_icon_; |
+ bool welcome_low_dpi_icon_fetched_; |
+ bool welcome_high_dpi_icon_fetched_; |
+ // A landing page link for settings/welcome toast. |
+ GURL welcome_landing_page_url_; |
+ ScopedVector<chrome::BitmapFetcher> fetchers_; |
+ std::vector<std::string> added_app_ids_; |
+ std::vector<std::string> removed_app_ids_; |
+ SyncedNotificationAppInfoService* synced_notification_app_info_service_; |
+ |
+ FRIEND_TEST_ALL_PREFIXES(SyncedNotificationAppInfoTest, AddRemoveTest); |
+ FRIEND_TEST_ALL_PREFIXES(SyncedNotificationAppInfoTest, GetAppIdListTest); |
+ FRIEND_TEST_ALL_PREFIXES(SyncedNotificationAppInfoTest, |
+ CreateBitmapFetcherTest); |
+ FRIEND_TEST_ALL_PREFIXES(SyncedNotificationAppInfoTest, OnFetchCompleteTest); |
+ FRIEND_TEST_ALL_PREFIXES(SyncedNotificationAppInfoTest, |
+ QueueBitmapFetchJobsTest); |
+ FRIEND_TEST_ALL_PREFIXES(SyncedNotificationAppInfoTest, EmptyBitmapTest); |
+ FRIEND_TEST_ALL_PREFIXES(SyncedNotificationAppInfoTest, |
+ AreAllBitmapsFetchedTest); |
DISALLOW_COPY_AND_ASSIGN(SyncedNotificationAppInfo); |
}; |