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
3 // found in the LICENSE file.
5 // This class represents the metadata for a service sending synced
8 #ifndef CHROME_BROWSER_NOTIFICATIONS_SYNC_NOTIFIER_SYNCED_NOTIFICATION_APP_INFO_H_
9 #define CHROME_BROWSER_NOTIFICATIONS_SYNC_NOTIFIER_SYNCED_NOTIFICATION_APP_INFO_H_
14 #include "base/memory/scoped_vector.h"
15 #include "chrome/browser/image_holder.h"
16 #include "ui/gfx/image/image.h"
17 #include "ui/message_center/notifier_settings.h"
24 class SyncedNotificationAppInfoService;
26 class SyncedNotificationAppInfo : public chrome::ImageHolderDelegate {
28 SyncedNotificationAppInfo(
29 Profile* const profile,
30 const std::string& settings_display_name,
31 SyncedNotificationAppInfoService* synced_notification_app_info_service);
32 virtual ~SyncedNotificationAppInfo();
34 // Return true if the app id is present in this AppInfo protobuf.
35 bool HasAppId(const std::string& app_id);
37 // Add an app id to the supported set for this AppInfo protobuf.
38 void AddAppId(const std::string& app_id);
40 // Remove an app id from the set for this AppInfo protobuf.
41 void RemoveAppId(const std::string& app_id);
43 std::string settings_display_name() const { return settings_display_name_; }
45 // Sets/gets the link to navigate to when the user clicks on the body of the
46 // app's welcome notification.
47 void SetWelcomeLinkUrl(const GURL& settings_link_url);
48 GURL welcome_link_url() const { return welcome_link_url_; }
50 // Set the URL for the low and high DPI bitmaps for the settings dialog.
51 void SetSettingsURLs(const GURL& settings_low_dpi,
52 const GURL& settings_high_dpi);
54 // Set the URL for the low and high DPI bitmaps for indicating the sending
56 void SetMonochromeURLs(const GURL& monochrome_low_dpi,
57 const GURL& monochrome_high_dpi);
59 // Set the URL for the low and high DPI bitmaps for use by the welcome dialog.
60 void SetWelcomeURLs(const GURL& welcome_low_dpi,
61 const GURL& welcome_high_dpi);
63 GURL settings_icon_url();
65 // If an app info is updated, keep track of the newly added app ids so we can
66 // later inform the chrome_notifier_service to show any newly enabled
68 void set_added_app_ids(std::vector<std::string> added_app_ids) {
69 added_app_ids_ = added_app_ids;
72 std::vector<std::string> added_app_ids() { return added_app_ids_; }
74 // If an app info is updated removing app ids, keep track of the removed app
75 // ids so we can later remove any affected notifications.
76 void set_removed_app_ids(std::vector<std::string> removed_app_ids) {
77 removed_app_ids_ = removed_app_ids;
80 std::vector<std::string> removed_app_ids() { return removed_app_ids_; }
82 // TODO(petewil): Check resolution of system and return the right icon.
85 // Build a vector of app_ids that this app_info contains.
86 std::vector<std::string> GetAppIdList();
88 // Set up for fetching all the bitmaps in this AppInfo.
89 void QueueBitmapFetchJobs();
91 // Start the bitmap fetching. When it is complete, the callback
92 // will notify the ChromeNotifierService of the new app info availablity.
93 void StartBitmapFetch();
95 // Method inherited from ImageHolderDelegate
96 virtual void OnFetchComplete() OVERRIDE;
98 // Check to see if we have responses for all the bitmaps we need.
99 bool AreAllBitmapsFetched();
101 // Construct a Message Center NotifierId from this synced notification app
103 message_center::NotifierId GetNotifierId();
106 // TODO(petewil): We need a unique id for a key. We will use the settings
107 // display name, but it would be more robust with a unique id.
109 std::vector<std::string> app_ids_;
110 std::string settings_display_name_;
111 GURL welcome_link_url_;
113 // The 1x and 2x versions of the icon for settings, small.
114 scoped_ptr<chrome::ImageHolder> settings_holder_;
115 // Monochrome icons for app badging (1x and 2x), small.
116 scoped_ptr<chrome::ImageHolder> monochrome_holder_;
117 // Welcome dialog icon (1x and 2x), large.
118 scoped_ptr<chrome::ImageHolder> welcome_holder_;
119 // A landing page link for settings/welcome toast.
120 GURL welcome_landing_page_url_;
121 std::vector<std::string> added_app_ids_;
122 std::vector<std::string> removed_app_ids_;
123 SyncedNotificationAppInfoService* synced_notification_app_info_service_;
125 FRIEND_TEST_ALL_PREFIXES(SyncedNotificationAppInfoTest, AddRemoveTest);
126 FRIEND_TEST_ALL_PREFIXES(SyncedNotificationAppInfoTest, GetAppIdListTest);
127 FRIEND_TEST_ALL_PREFIXES(SyncedNotificationAppInfoTest,
128 CreateBitmapFetcherTest);
129 FRIEND_TEST_ALL_PREFIXES(SyncedNotificationAppInfoTest, OnFetchCompleteTest);
130 FRIEND_TEST_ALL_PREFIXES(SyncedNotificationAppInfoTest,
131 QueueBitmapFetchJobsTest);
132 FRIEND_TEST_ALL_PREFIXES(SyncedNotificationAppInfoTest,
133 AreAllBitmapsFetchedTest);
135 DISALLOW_COPY_AND_ASSIGN(SyncedNotificationAppInfo);
138 } // namespace notifier
140 #endif // CHROME_BROWSER_NOTIFICATIONS_SYNC_NOTIFIER_SYNCED_NOTIFICATION_APP_INFO_H_