OLD | NEW |
---|---|
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" | |
14 #include "url/gurl.h" | 17 #include "url/gurl.h" |
15 | 18 |
19 class Profile; | |
20 | |
16 namespace notifier { | 21 namespace notifier { |
17 | 22 |
18 class SyncedNotificationAppInfo { | 23 class SyncedNotificationAppInfoService; |
24 | |
25 class SyncedNotificationAppInfo : public chrome::BitmapFetcherDelegate { | |
19 public: | 26 public: |
20 explicit SyncedNotificationAppInfo(const std::string& settings_display_name); | 27 SyncedNotificationAppInfo( |
21 ~SyncedNotificationAppInfo(); | 28 Profile* const profile, |
29 const std::string& settings_display_name, | |
30 SyncedNotificationAppInfoService* synced_notification_app_info_service); | |
31 virtual ~SyncedNotificationAppInfo(); | |
22 | 32 |
23 // Return true if the app id is present in this AppInfo protobuf. | 33 // Return true if the app id is present in this AppInfo protobuf. |
24 bool HasAppId(const std::string& app_id); | 34 bool HasAppId(const std::string& app_id); |
25 | 35 |
26 // Add an app id to the supported set for this AppInfo protobuf. | 36 // Add an app id to the supported set for this AppInfo protobuf. |
27 void AddAppId(const std::string& app_id); | 37 void AddAppId(const std::string& app_id); |
28 | 38 |
29 // Remove an app id from the set for this AppInfo protobuf. | 39 // Remove an app id from the set for this AppInfo protobuf. |
30 void RemoveAppId(const std::string& app_id); | 40 void RemoveAppId(const std::string& app_id); |
31 | 41 |
32 std::string settings_display_name() const { return settings_display_name_; } | 42 std::string settings_display_name() const { return settings_display_name_; } |
33 | 43 |
34 void SetSettingsIcon(const GURL& settings_icon) { | 44 void SetSettingsIcon(const GURL& settings_icon) { |
35 settings_icon_url_ = settings_icon; | 45 settings_low_dpi_icon_url_ = settings_icon; |
36 } | 46 } |
37 | 47 |
38 GURL settings_icon_url() { return settings_icon_url_; } | 48 GURL settings_icon_url() { return settings_low_dpi_icon_url_; } |
49 | |
50 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
| |
51 added_app_ids_ = added_app_ids; | |
52 } | |
53 | |
54 std::vector<std::string> added_app_ids() { return added_app_ids_; } | |
55 | |
56 void SetRemovedAppIds(std::vector<std::string> removed_app_ids) { | |
57 removed_app_ids_ = removed_app_ids; | |
58 } | |
59 | |
60 std::vector<std::string> removed_app_ids() { return removed_app_ids_; } | |
61 | |
62 // TODO(petewil): Check resolution of system and return the right icon. | |
63 gfx::Image icon() { return settings_low_dpi_icon_; } | |
39 | 64 |
40 // Build a vector of app_ids that this app_info contains. | 65 // Build a vector of app_ids that this app_info contains. |
41 void GetAppIdList(std::vector<std::string>* app_id_list); | 66 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
| |
42 | 67 |
68 // Set up for fetching all the bitmaps in this AppInfo. | |
69 void QueueBitmapFetchJobs(); | |
70 | |
71 // If this bitmap has a valid GURL, create a fetcher for it. | |
72 void AddBitmapToFetchQueue(const GURL& url); | |
73 | |
74 // Start the bitmap fetching. When it is complete, the callback | |
75 // will notify the ChromeNotifierService of the new app info availablity. | |
76 void StartBitmapFetch(); | |
77 | |
78 // Method inherited from BitmapFetcher delegate. | |
79 virtual void OnFetchComplete(const GURL url, const SkBitmap* bitmap) OVERRIDE; | |
80 | |
81 // Check to see if we have responses for all the bitmaps we need. | |
82 bool AreAllBitmapsFetched(); | |
83 | |
43 private: | 84 private: |
44 // TODO(petewil): We need a unique id for a key. We will use the settings | 85 // 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. | 86 // display name, but it would be more robust with a unique id. |
87 Profile* profile_; | |
46 std::vector<std::string> app_ids_; | 88 std::vector<std::string> app_ids_; |
47 std::string settings_display_name_; | 89 std::string settings_display_name_; |
48 // TODO(petewil): We should get 1x and 2x versions of all these images. | 90 // The 1x and 2x versions of the icon for settings, small. |
49 GURL settings_icon_url_; | 91 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.
| |
50 // TODO(petewil): Add monochrome icons for app badging and welcome icons. | 92 GURL settings_high_dpi_icon_url_; |
51 // TODO(petewil): Add a landing page link for settings/welcome toast. | 93 gfx::Image settings_low_dpi_icon_; |
94 gfx::Image settings_high_dpi_icon_; | |
95 bool settings_low_dpi_icon_fetched_; | |
96 bool settings_high_dpi_icon_fetched_; | |
97 // Monochrome icons for app badging (1x and 2x), small. | |
98 GURL monochrome_low_dpi_icon_url_; | |
99 GURL monochrome_high_dpi_icon_url_; | |
100 gfx::Image monochrome_low_dpi_icon_; | |
101 gfx::Image monochrome_high_dpi_icon_; | |
102 bool monochrome_low_dpi_icon_fetched_; | |
103 bool monochrome_high_dpi_icon_fetched_; | |
104 // Welcome dialog icon (1x and 2x), large. | |
105 GURL welcome_low_dpi_icon_url_; | |
106 GURL welcome_high_dpi_icon_url_; | |
107 gfx::Image welcome_low_dpi_icon_; | |
108 gfx::Image welcome_high_dpi_icon_; | |
109 bool welcome_low_dpi_icon_fetched_; | |
110 bool welcome_high_dpi_icon_fetched_; | |
111 // A landing page link for settings/welcome toast. | |
112 GURL welcome_landing_page_url_; | |
113 ScopedVector<chrome::BitmapFetcher> fetchers_; | |
114 std::vector<std::string> added_app_ids_; | |
115 std::vector<std::string> removed_app_ids_; | |
116 SyncedNotificationAppInfoService* synced_notification_app_info_service_; | |
117 | |
118 FRIEND_TEST_ALL_PREFIXES(SyncedNotificationAppInfoTest, AddRemoveTest); | |
119 FRIEND_TEST_ALL_PREFIXES(SyncedNotificationAppInfoTest, GetAppIdListTest); | |
120 FRIEND_TEST_ALL_PREFIXES(SyncedNotificationAppInfoTest, | |
121 AddBitmapToFetchQueueTest); | |
122 FRIEND_TEST_ALL_PREFIXES(SyncedNotificationAppInfoTest, OnFetchCompleteTest); | |
123 FRIEND_TEST_ALL_PREFIXES(SyncedNotificationAppInfoTest, | |
124 QueueBitmapFetchJobsTest); | |
125 FRIEND_TEST_ALL_PREFIXES(SyncedNotificationAppInfoTest, EmptyBitmapTest); | |
126 FRIEND_TEST_ALL_PREFIXES(SyncedNotificationAppInfoTest, | |
127 AreAllBitmapsFetchedTest); | |
52 | 128 |
53 DISALLOW_COPY_AND_ASSIGN(SyncedNotificationAppInfo); | 129 DISALLOW_COPY_AND_ASSIGN(SyncedNotificationAppInfo); |
54 }; | 130 }; |
55 | 131 |
56 } // namespace notifier | 132 } // namespace notifier |
57 | 133 |
58 #endif // CHROME_BROWSER_NOTIFICATIONS_SYNC_NOTIFIER_SYNCED_NOTIFICATION_APP_IN FO_H_ | 134 #endif // CHROME_BROWSER_NOTIFICATIONS_SYNC_NOTIFIER_SYNCED_NOTIFICATION_APP_IN FO_H_ |
OLD | NEW |