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

Side by Side 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: CR fixes per DewittJ 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 metadata for a service sending synced 5 // This class represents the metadata for a service sending synced
6 // notifications. 6 // notifications.
7 7
8 #ifndef CHROME_BROWSER_NOTIFICATIONS_SYNC_NOTIFIER_SYNCED_NOTIFICATION_APP_INFO_ H_ 8 #ifndef CHROME_BROWSER_NOTIFICATIONS_SYNC_NOTIFIER_SYNCED_NOTIFICATION_APP_INFO_ H_
9 #define CHROME_BROWSER_NOTIFICATIONS_SYNC_NOTIFIER_SYNCED_NOTIFICATION_APP_INFO_ H_ 9 #define CHROME_BROWSER_NOTIFICATIONS_SYNC_NOTIFIER_SYNCED_NOTIFICATION_APP_INFO_ H_
10 10
11 #include <string> 11 #include <string>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/memory/scoped_vector.h"
15 #include "chrome/browser/bitmap_fetcher.h"
16 #include "ui/gfx/image/image.h"
17 #include "ui/message_center/notifier_settings.h"
14 #include "url/gurl.h" 18 #include "url/gurl.h"
15 19
20 class Profile;
21
16 namespace notifier { 22 namespace notifier {
17 23
18 class SyncedNotificationAppInfo { 24 class SyncedNotificationAppInfoService;
25
26 class SyncedNotificationAppInfo : public chrome::BitmapFetcherDelegate {
19 public: 27 public:
20 explicit SyncedNotificationAppInfo(const std::string& settings_display_name); 28 SyncedNotificationAppInfo(
21 ~SyncedNotificationAppInfo(); 29 Profile* const profile,
30 const std::string& settings_display_name,
31 SyncedNotificationAppInfoService* synced_notification_app_info_service);
32 virtual ~SyncedNotificationAppInfo();
22 33
23 // Return true if the app id is present in this AppInfo protobuf. 34 // Return true if the app id is present in this AppInfo protobuf.
24 bool HasAppId(const std::string& app_id); 35 bool HasAppId(const std::string& app_id);
25 36
26 // Add an app id to the supported set for this AppInfo protobuf. 37 // Add an app id to the supported set for this AppInfo protobuf.
27 void AddAppId(const std::string& app_id); 38 void AddAppId(const std::string& app_id);
28 39
29 // Remove an app id from the set for this AppInfo protobuf. 40 // Remove an app id from the set for this AppInfo protobuf.
30 void RemoveAppId(const std::string& app_id); 41 void RemoveAppId(const std::string& app_id);
31 42
32 std::string settings_display_name() const { return settings_display_name_; } 43 std::string settings_display_name() const { return settings_display_name_; }
33 44
34 void SetSettingsIcon(const GURL& settings_icon) { 45 void SetSettingsIcon(const GURL& settings_icon) {
35 settings_icon_url_ = settings_icon; 46 settings_low_dpi_icon_url_ = settings_icon;
36 } 47 }
37 48
38 GURL settings_icon_url() { return settings_icon_url_; } 49 GURL settings_icon_url() { return settings_low_dpi_icon_url_; }
50
51 // If an app info is updated, keep track of the newly added app ids so we can
52 // later inform the chrome_notifier_service to show any newly enabled
53 // notifications.
54 void SetAddedAppIds(std::vector<std::string> added_app_ids) {
55 added_app_ids_ = added_app_ids;
56 }
57
58 std::vector<std::string> added_app_ids() { return added_app_ids_; }
59
60 // If an app info is updated removing app ids, keep track of the removed app
61 // 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
62 void SetRemovedAppIds(std::vector<std::string> removed_app_ids) {
63 removed_app_ids_ = removed_app_ids;
64 }
65
66 std::vector<std::string> removed_app_ids() { return removed_app_ids_; }
67
68 // TODO(petewil): Check resolution of system and return the right icon.
69 gfx::Image icon() { return settings_low_dpi_icon_; }
39 70
40 // Build a vector of app_ids that this app_info contains. 71 // Build a vector of app_ids that this app_info contains.
41 void GetAppIdList(std::vector<std::string>* app_id_list); 72 std::vector<std::string> GetAppIdList();
73
74 // Set up for fetching all the bitmaps in this AppInfo.
75 void QueueBitmapFetchJobs();
76
77 // If this bitmap has a valid GURL, create a fetcher for it.
78 void CreateBitmapFetcher(const GURL& url);
79
80 // Start the bitmap fetching. When it is complete, the callback
81 // will notify the ChromeNotifierService of the new app info availablity.
82 void StartBitmapFetch();
83
84 // Method inherited from BitmapFetcher delegate.
85 virtual void OnFetchComplete(const GURL url, const SkBitmap* bitmap) OVERRIDE;
86
87 // Check to see if we have responses for all the bitmaps we need.
88 bool AreAllBitmapsFetched();
89
90 // Construct a Message Center NotifierId from this synced notification app
91 // info object.
92 message_center::NotifierId GetNotifierId();
42 93
43 private: 94 private:
44 // TODO(petewil): We need a unique id for a key. We will use the settings 95 // TODO(petewil): We need a unique id for a key. We will use the settings
45 // display name for now, but it would be more robust with a unique id. 96 // display name, but it would be more robust with a unique id.
97 Profile* profile_;
46 std::vector<std::string> app_ids_; 98 std::vector<std::string> app_ids_;
47 std::string settings_display_name_; 99 std::string settings_display_name_;
48 // TODO(petewil): We should get 1x and 2x versions of all these images. 100 // The 1x and 2x versions of the icon for settings, small.
49 GURL settings_icon_url_; 101 GURL settings_low_dpi_icon_url_;
50 // TODO(petewil): Add monochrome icons for app badging and welcome icons. 102 GURL settings_high_dpi_icon_url_;
51 // TODO(petewil): Add a landing page link for settings/welcome toast. 103 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.
104 gfx::Image settings_high_dpi_icon_;
105 bool settings_low_dpi_icon_fetched_;
106 bool settings_high_dpi_icon_fetched_;
107 // Monochrome icons for app badging (1x and 2x), small.
108 GURL monochrome_low_dpi_icon_url_;
109 GURL monochrome_high_dpi_icon_url_;
110 gfx::Image monochrome_low_dpi_icon_;
111 gfx::Image monochrome_high_dpi_icon_;
112 bool monochrome_low_dpi_icon_fetched_;
113 bool monochrome_high_dpi_icon_fetched_;
114 // Welcome dialog icon (1x and 2x), large.
115 GURL welcome_low_dpi_icon_url_;
116 GURL welcome_high_dpi_icon_url_;
117 gfx::Image welcome_low_dpi_icon_;
118 gfx::Image welcome_high_dpi_icon_;
119 bool welcome_low_dpi_icon_fetched_;
120 bool welcome_high_dpi_icon_fetched_;
121 // A landing page link for settings/welcome toast.
122 GURL welcome_landing_page_url_;
123 ScopedVector<chrome::BitmapFetcher> fetchers_;
124 std::vector<std::string> added_app_ids_;
125 std::vector<std::string> removed_app_ids_;
126 SyncedNotificationAppInfoService* synced_notification_app_info_service_;
127
128 FRIEND_TEST_ALL_PREFIXES(SyncedNotificationAppInfoTest, AddRemoveTest);
129 FRIEND_TEST_ALL_PREFIXES(SyncedNotificationAppInfoTest, GetAppIdListTest);
130 FRIEND_TEST_ALL_PREFIXES(SyncedNotificationAppInfoTest,
131 CreateBitmapFetcherTest);
132 FRIEND_TEST_ALL_PREFIXES(SyncedNotificationAppInfoTest, OnFetchCompleteTest);
133 FRIEND_TEST_ALL_PREFIXES(SyncedNotificationAppInfoTest,
134 QueueBitmapFetchJobsTest);
135 FRIEND_TEST_ALL_PREFIXES(SyncedNotificationAppInfoTest, EmptyBitmapTest);
136 FRIEND_TEST_ALL_PREFIXES(SyncedNotificationAppInfoTest,
137 AreAllBitmapsFetchedTest);
52 138
53 DISALLOW_COPY_AND_ASSIGN(SyncedNotificationAppInfo); 139 DISALLOW_COPY_AND_ASSIGN(SyncedNotificationAppInfo);
54 }; 140 };
55 141
56 } // namespace notifier 142 } // namespace notifier
57 143
58 #endif // CHROME_BROWSER_NOTIFICATIONS_SYNC_NOTIFIER_SYNCED_NOTIFICATION_APP_IN FO_H_ 144 #endif // CHROME_BROWSER_NOTIFICATIONS_SYNC_NOTIFIER_SYNCED_NOTIFICATION_APP_IN FO_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698