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

Side by Side Diff: chrome/browser/notifications/sync_notifier/chrome_notifier_service.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: Refactoring the image holders 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_NOTIFICATIONS_SYNC_NOTIFIER_CHROME_NOTIFIER_SERVICE_H_ 5 #ifndef CHROME_BROWSER_NOTIFICATIONS_SYNC_NOTIFIER_CHROME_NOTIFIER_SERVICE_H_
6 #define CHROME_BROWSER_NOTIFICATIONS_SYNC_NOTIFIER_CHROME_NOTIFIER_SERVICE_H_ 6 #define CHROME_BROWSER_NOTIFICATIONS_SYNC_NOTIFIER_CHROME_NOTIFIER_SERVICE_H_
7 7
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 10
(...skipping 12 matching lines...) Expand all
23 23
24 namespace user_prefs { 24 namespace user_prefs {
25 class PrefRegistrySyncable; 25 class PrefRegistrySyncable;
26 } 26 }
27 27
28 namespace message_center { 28 namespace message_center {
29 struct Notifier; 29 struct Notifier;
30 } 30 }
31 31
32 namespace notifier { 32 namespace notifier {
33 class SyncedNotificationAppInfoTemp; 33 class SyncedNotificationAppInfo;
34 class SyncedNotificationAppInfoService;
34 35
35 // The name of our first synced notification service. 36 // The name of our first synced notification service.
36 // TODO(petewil): remove this hardcoding once we have the synced notification 37 // TODO(petewil): Remove this once we figure out how to do UMA per name.
dewittj 2014/03/24 17:35:50 per name of what?
Pete Williamson 2014/03/25 00:08:37 Comment improved.
37 // signalling sync data type set up to provide this.
38 // crbug.com/248337
39 extern const char kFirstSyncedNotificationServiceId[]; 38 extern const char kFirstSyncedNotificationServiceId[];
40 extern const char kServiceEnabledOnce[]; 39 extern const char kServiceEnabledOnce[];
41 extern const char kSyncedNotificationFirstRun[]; 40 extern const char kSyncedNotificationFirstRun[];
42 extern const char kSyncedNotificationsWelcomeOrigin[]; 41 extern const char kSyncedNotificationsWelcomeOrigin[];
43 42
44 enum ChromeNotifierServiceActionType { 43 enum ChromeNotifierServiceActionType {
45 CHROME_NOTIFIER_SERVICE_ACTION_UNKNOWN, 44 CHROME_NOTIFIER_SERVICE_ACTION_UNKNOWN,
46 CHROME_NOTIFIER_SERVICE_ACTION_FIRST_SERVICE_ENABLED, 45 CHROME_NOTIFIER_SERVICE_ACTION_FIRST_SERVICE_ENABLED,
47 CHROME_NOTIFIER_SERVICE_ACTION_FIRST_SERVICE_DISABLED, 46 CHROME_NOTIFIER_SERVICE_ACTION_FIRST_SERVICE_DISABLED,
48 // NOTE: Add new action types only immediately above this line. Also, 47 // NOTE: Add new action types only immediately above this line. Also,
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 94
96 // Called when we dismiss a notification. This is virtual so that test 95 // Called when we dismiss a notification. This is virtual so that test
97 // subclasses can override it. 96 // subclasses can override it.
98 virtual void MarkNotificationAsRead(const std::string& id); 97 virtual void MarkNotificationAsRead(const std::string& id);
99 98
100 // Called when a notier is enabled or disabled. 99 // Called when a notier is enabled or disabled.
101 void OnSyncedNotificationServiceEnabled( 100 void OnSyncedNotificationServiceEnabled(
102 const std::string& notifier_id, 101 const std::string& notifier_id,
103 bool enabled); 102 bool enabled);
104 103
104 // When app ids are added or removed, unblock or remove associated messages.
105 void SetAddedAppIds(std::vector<std::string> added_app_ids);
106 void SetRemovedAppIds(std::vector<std::string> removed_app_ids);
107
105 // Register the preferences we use to save state. 108 // Register the preferences we use to save state.
106 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); 109 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
107 110
108 Profile* profile() const { return profile_; } 111 Profile* profile() const { return profile_; }
109 112
113 // Find and retun the sending service Id for this notification.
114 std::string GetSendingServiceId(
115 const SyncedNotification* synced_notification);
116
110 // Functions for test. 117 // Functions for test.
111 void AddForTest(scoped_ptr<notifier::SyncedNotification> notification); 118 void AddForTest(scoped_ptr<notifier::SyncedNotification> notification);
112 119
120 void SetSyncedNotificationAppInfoServiceForTest(
121 SyncedNotificationAppInfoService* synced_notification_app_info_service);
122
113 // If we allow the tests to do bitmap fetching, they will attempt to fetch 123 // If we allow the tests to do bitmap fetching, they will attempt to fetch
114 // a URL from the web, which will fail. We can already test the majority 124 // a URL from the web, which will fail. We can already test the majority
115 // of what we want without also trying to fetch bitmaps. Other tests will 125 // of what we want without also trying to fetch bitmaps. Other tests will
116 // cover bitmap fetching. 126 // cover bitmap fetching.
117 static void set_avoid_bitmap_fetching_for_test(bool avoid) { 127 static void set_avoid_bitmap_fetching_for_test(bool avoid) {
118 avoid_bitmap_fetching_for_test_ = avoid; 128 avoid_bitmap_fetching_for_test_ = avoid;
119 } 129 }
120 130
121 // Initialize the preferences we use for the ChromeNotificationService. 131 // Initialize the preferences we use for the ChromeNotificationService.
122 void InitializePrefs(); 132 void InitializePrefs();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 std::set<std::string>* ids_field); 169 std::set<std::string>* ids_field);
160 170
161 // Called when our "first run" boolean pref has been changed. 171 // Called when our "first run" boolean pref has been changed.
162 void OnSyncedNotificationFirstRunBooleanPrefChanged(bool* new_value); 172 void OnSyncedNotificationFirstRunBooleanPrefChanged(bool* new_value);
163 173
164 // Convert our internal set of strings to a list value. 174 // Convert our internal set of strings to a list value.
165 // The second param is an outparam which the function fills in. 175 // The second param is an outparam which the function fills in.
166 void BuildServiceListValueInplace( 176 void BuildServiceListValueInplace(
167 std::set<std::string> services, base::ListValue* list_value); 177 std::set<std::string> services, base::ListValue* list_value);
168 178
169 SyncedNotificationAppInfoTemp* FindAppInfo(const std::string& app_id) const; 179 notifier::SyncedNotificationAppInfo* FindAppInfoByAppId(
180 const std::string& app_id) const;
170 181
171 const Notification CreateWelcomeNotificationForService( 182 const Notification CreateWelcomeNotificationForService(
172 SyncedNotificationAppInfoTemp* app_info); 183 SyncedNotificationAppInfo* app_info);
173 184
174 // Preferences for storing which SyncedNotificationServices are enabled 185 // Preferences for storing which SyncedNotificationServices are enabled
175 StringListPrefMember enabled_sending_services_prefs_; 186 StringListPrefMember enabled_sending_services_prefs_;
176 StringListPrefMember initialized_sending_services_prefs_; 187 StringListPrefMember initialized_sending_services_prefs_;
177 188
178 // Preferences to avoid toasting on SyncedNotification first run. 189 // Preferences to avoid toasting on SyncedNotification first run.
179 BooleanPrefMember synced_notification_first_run_prefs_; 190 BooleanPrefMember synced_notification_first_run_prefs_;
180 191
181 // Back pointer to the owning profile. 192 // Back pointer to the owning profile.
182 Profile* const profile_; 193 Profile* const profile_;
183 NotificationUIManager* const notification_manager_; 194 NotificationUIManager* const notification_manager_;
184 scoped_ptr<syncer::SyncChangeProcessor> sync_processor_; 195 scoped_ptr<syncer::SyncChangeProcessor> sync_processor_;
185 std::set<std::string> enabled_sending_services_; 196 std::set<std::string> enabled_sending_services_;
186 std::set<std::string> initialized_sending_services_; 197 std::set<std::string> initialized_sending_services_;
187 bool synced_notification_first_run_; 198 bool synced_notification_first_run_;
188 static bool avoid_bitmap_fetching_for_test_; 199 static bool avoid_bitmap_fetching_for_test_;
189 base::ThreadChecker thread_checker_; 200 base::ThreadChecker thread_checker_;
201 // Unowned pointer to the App Info service. The lifetime is managed by the
202 // profile service, this service depends on the App Info service, so it should
203 // always be in scope whenever our service is active.
204 SyncedNotificationAppInfoService* synced_notification_app_info_service_;
190 205
191 ScopedVector<SyncedNotificationAppInfoTemp> app_info_data_;
192 // TODO(petewil): Consider whether a map would better suit our data. 206 // TODO(petewil): Consider whether a map would better suit our data.
193 // If there are many entries, lookup time may trump locality of reference. 207 // If there are many entries, lookup time may trump locality of reference.
194 ScopedVector<SyncedNotification> notification_data_; 208 ScopedVector<SyncedNotification> notification_data_;
195 209
196 friend class ChromeNotifierServiceTest; 210 friend class ChromeNotifierServiceTest;
197 FRIEND_TEST_ALL_PREFIXES(ChromeNotifierServiceTest, ServiceEnabledTest); 211 FRIEND_TEST_ALL_PREFIXES(ChromeNotifierServiceTest, ServiceEnabledTest);
198 FRIEND_TEST_ALL_PREFIXES(ChromeNotifierServiceTest, 212 FRIEND_TEST_ALL_PREFIXES(ChromeNotifierServiceTest,
199 AddNewSendingServicesTest); 213 AddNewSendingServicesTest);
200 FRIEND_TEST_ALL_PREFIXES(ChromeNotifierServiceTest, 214 FRIEND_TEST_ALL_PREFIXES(ChromeNotifierServiceTest,
201 CheckInitializedServicesTest); 215 CheckInitializedServicesTest);
202 FRIEND_TEST_ALL_PREFIXES(ChromeNotifierServiceTest, 216 FRIEND_TEST_ALL_PREFIXES(ChromeNotifierServiceTest,
203 GetEnabledSendingServicesFromPreferencesTest); 217 GetEnabledSendingServicesFromPreferencesTest);
204 FRIEND_TEST_ALL_PREFIXES(ChromeNotifierServiceTest, CheckFindAppInfo); 218 FRIEND_TEST_ALL_PREFIXES(ChromeNotifierServiceTest, CheckFindAppInfo);
219 FRIEND_TEST_ALL_PREFIXES(ChromeNotifierServiceTest, SetAddedAppIdsTest);
220 FRIEND_TEST_ALL_PREFIXES(ChromeNotifierServiceTest, SetRemovedAppIdsTest);
205 221
206 DISALLOW_COPY_AND_ASSIGN(ChromeNotifierService); 222 DISALLOW_COPY_AND_ASSIGN(ChromeNotifierService);
207 }; 223 };
208 224
209 } // namespace notifier 225 } // namespace notifier
210 226
211 #endif // CHROME_BROWSER_NOTIFICATIONS_SYNC_NOTIFIER_CHROME_NOTIFIER_SERVICE_H_ 227 #endif // CHROME_BROWSER_NOTIFICATIONS_SYNC_NOTIFIER_CHROME_NOTIFIER_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698