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

Unified Diff: chrome/browser/notifications/sync_notifier/synced_notification_app_info.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: fix windows build Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
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..da3ce5d752ab73cf32839cf0ad87223995137b35 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,24 @@
#include <string>
#include <vector>
+#include "base/memory/scoped_vector.h"
+#include "chrome/browser/bitmap_fetcher.h"
+#include "ui/gfx/image/image.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 +42,89 @@ 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_; }
+
+ void SetAddedAppIds(std::vector<std::string> added_app_ids) {
dewittj 2014/03/17 21:43:43 I don't like this added_app_ids_ and removed_app_i
Pete Williamson 2014/03/21 01:22:31 Are you objecting to the name, the existence of th
+ added_app_ids_ = added_app_ids;
+ }
+
+ std::vector<std::string> added_app_ids() { return added_app_ids_; }
+
+ 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);
dewittj 2014/03/17 21:43:43 Can this just return the vector? It's more readab
Pete Williamson 2014/03/21 01:22:31 Done. (I was trying to avoid copying the STL stru
+ // 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 AddBitmapToFetchQueue(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();
+
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_;
dewittj 2014/03/17 21:43:43 Let's make these into objects, something like: sc
Pete Williamson 2014/03/21 01:22:31 Done.
+ GURL settings_high_dpi_icon_url_;
+ gfx::Image settings_low_dpi_icon_;
+ 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,
+ AddBitmapToFetchQueueTest);
+ 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);
};

Powered by Google App Engine
This is Rietveld 408576698