| 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..462192a802176cc87dc3a2ad79f21f19578d3f75 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/notifications/sync_notifier/image_holder.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 notifier::ImageHolderDelegate {
|
| 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);
|
| @@ -31,24 +42,90 @@ class SyncedNotificationAppInfo {
|
|
|
| std::string settings_display_name() const { return settings_display_name_; }
|
|
|
| - void SetSettingsIcon(const GURL& settings_icon) {
|
| - settings_icon_url_ = settings_icon;
|
| + void SetSettingsURLs(const GURL& settings_low_dpi,
|
| + const GURL& settings_high_dpi);
|
| +
|
| + void SetMonochromeURLs(const GURL& monochrome_low_dpi,
|
| + const GURL& monochrome_high_dpi);
|
| +
|
| + void SetWelcomeURLs(const GURL& welcome_low_dpi,
|
| + const GURL& welcome_high_dpi);
|
| +
|
| + GURL settings_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.
|
| + 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: move to .cc file
|
| + // TODO(petewil): Check resolution of system and return the right icon.
|
| + gfx::Image icon() {
|
| + if (settings_holder_ != NULL)
|
| + return settings_holder_->low_dpi_image();
|
| + else
|
| + return gfx::Image();
|
| + }
|
|
|
| // 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();
|
| +
|
| + // 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 ImageHolderDelegate
|
| + virtual void OnFetchComplete() 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.
|
| + scoped_ptr<ImageHolder> settings_holder_;
|
| + // Monochrome icons for app badging (1x and 2x), small.
|
| + scoped_ptr<ImageHolder> monochrome_holder_;
|
| + // Welcome dialog icon (1x and 2x), large.
|
| + scoped_ptr<ImageHolder> welcome_holder_;
|
| + // A landing page link for settings/welcome toast.
|
| + GURL welcome_landing_page_url_;
|
| + 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,
|
| + AreAllBitmapsFetchedTest);
|
|
|
| DISALLOW_COPY_AND_ASSIGN(SyncedNotificationAppInfo);
|
| };
|
|
|