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/notifications/sync_notifier/image_holder.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 notifier::ImageHolderDelegate { |
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 // Set the URL for the low and high DPI bitmaps for the settings dialog. |
35 settings_icon_url_ = settings_icon; | 46 void SetSettingsURLs(const GURL& settings_low_dpi, |
| 47 const GURL& settings_high_dpi); |
| 48 |
| 49 // Set the URL for the low and high DPI bitmaps for indicating the sending |
| 50 // service. |
| 51 void SetMonochromeURLs(const GURL& monochrome_low_dpi, |
| 52 const GURL& monochrome_high_dpi); |
| 53 |
| 54 // Set the URL for the low and high DPI bitmaps for use by the welcome dialog. |
| 55 void SetWelcomeURLs(const GURL& welcome_low_dpi, |
| 56 const GURL& welcome_high_dpi); |
| 57 |
| 58 GURL settings_icon_url(); |
| 59 |
| 60 // If an app info is updated, keep track of the newly added app ids so we can |
| 61 // later inform the chrome_notifier_service to show any newly enabled |
| 62 // notifications. |
| 63 void set_added_app_ids(std::vector<std::string> added_app_ids) { |
| 64 added_app_ids_ = added_app_ids; |
36 } | 65 } |
37 | 66 |
38 GURL settings_icon_url() { return settings_icon_url_; } | 67 std::vector<std::string> added_app_ids() { return added_app_ids_; } |
| 68 |
| 69 // If an app info is updated removing app ids, keep track of the removed app |
| 70 // ids so we can later remove any affected notfications. |
| 71 void set_removed_app_ids(std::vector<std::string> removed_app_ids) { |
| 72 removed_app_ids_ = removed_app_ids; |
| 73 } |
| 74 |
| 75 std::vector<std::string> removed_app_ids() { return removed_app_ids_; } |
| 76 |
| 77 // TODO(petewil): Check resolution of system and return the right icon. |
| 78 gfx::Image icon(); |
39 | 79 |
40 // Build a vector of app_ids that this app_info contains. | 80 // Build a vector of app_ids that this app_info contains. |
41 void GetAppIdList(std::vector<std::string>* app_id_list); | 81 std::vector<std::string> GetAppIdList(); |
| 82 |
| 83 // Set up for fetching all the bitmaps in this AppInfo. |
| 84 void QueueBitmapFetchJobs(); |
| 85 |
| 86 // Start the bitmap fetching. When it is complete, the callback |
| 87 // will notify the ChromeNotifierService of the new app info availablity. |
| 88 void StartBitmapFetch(); |
| 89 |
| 90 // Method inherited from ImageHolderDelegate |
| 91 virtual void OnFetchComplete() OVERRIDE; |
| 92 |
| 93 // Check to see if we have responses for all the bitmaps we need. |
| 94 bool AreAllBitmapsFetched(); |
| 95 |
| 96 // Construct a Message Center NotifierId from this synced notification app |
| 97 // info object. |
| 98 message_center::NotifierId GetNotifierId(); |
42 | 99 |
43 private: | 100 private: |
44 // TODO(petewil): We need a unique id for a key. We will use the settings | 101 // 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. | 102 // display name, but it would be more robust with a unique id. |
| 103 Profile* profile_; |
46 std::vector<std::string> app_ids_; | 104 std::vector<std::string> app_ids_; |
47 std::string settings_display_name_; | 105 std::string settings_display_name_; |
48 // TODO(petewil): We should get 1x and 2x versions of all these images. | 106 // The 1x and 2x versions of the icon for settings, small. |
49 GURL settings_icon_url_; | 107 scoped_ptr<ImageHolder> settings_holder_; |
50 // TODO(petewil): Add monochrome icons for app badging and welcome icons. | 108 // Monochrome icons for app badging (1x and 2x), small. |
51 // TODO(petewil): Add a landing page link for settings/welcome toast. | 109 scoped_ptr<ImageHolder> monochrome_holder_; |
| 110 // Welcome dialog icon (1x and 2x), large. |
| 111 scoped_ptr<ImageHolder> welcome_holder_; |
| 112 // A landing page link for settings/welcome toast. |
| 113 GURL welcome_landing_page_url_; |
| 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 CreateBitmapFetcherTest); |
| 122 FRIEND_TEST_ALL_PREFIXES(SyncedNotificationAppInfoTest, OnFetchCompleteTest); |
| 123 FRIEND_TEST_ALL_PREFIXES(SyncedNotificationAppInfoTest, |
| 124 QueueBitmapFetchJobsTest); |
| 125 FRIEND_TEST_ALL_PREFIXES(SyncedNotificationAppInfoTest, |
| 126 AreAllBitmapsFetchedTest); |
52 | 127 |
53 DISALLOW_COPY_AND_ASSIGN(SyncedNotificationAppInfo); | 128 DISALLOW_COPY_AND_ASSIGN(SyncedNotificationAppInfo); |
54 }; | 129 }; |
55 | 130 |
56 } // namespace notifier | 131 } // namespace notifier |
57 | 132 |
58 #endif // CHROME_BROWSER_NOTIFICATIONS_SYNC_NOTIFIER_SYNCED_NOTIFICATION_APP_IN
FO_H_ | 133 #endif // CHROME_BROWSER_NOTIFICATIONS_SYNC_NOTIFIER_SYNCED_NOTIFICATION_APP_IN
FO_H_ |
OLD | NEW |