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

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: fix windows build 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.
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);
dewittj 2014/03/17 21:43:43 nit: rename to OnAppIdsAdded
dewittj 2014/03/25 22:31:13 This comment was not addressed.
Pete Williamson 2014/03/26 18:12:55 Oops, missed that, done now. I think that my meth
106 void SetRemovedAppIds(std::vector<std::string> removed_app_ids);
dewittj 2014/03/17 21:43:43 nit: rename to OnAppIdsRemoved
dewittj 2014/03/25 22:31:13 This comment was not addressed.
Pete Williamson 2014/03/26 18:12:55 Done.
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
113 // If we allow the tests to do bitmap fetching, they will attempt to fetch 120 // 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 121 // 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 122 // of what we want without also trying to fetch bitmaps. Other tests will
116 // cover bitmap fetching. 123 // cover bitmap fetching.
117 static void set_avoid_bitmap_fetching_for_test(bool avoid) { 124 static void set_avoid_bitmap_fetching_for_test(bool avoid) {
118 avoid_bitmap_fetching_for_test_ = avoid; 125 avoid_bitmap_fetching_for_test_ = avoid;
119 } 126 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 std::set<std::string>* ids_field); 166 std::set<std::string>* ids_field);
160 167
161 // Called when our "first run" boolean pref has been changed. 168 // Called when our "first run" boolean pref has been changed.
162 void OnSyncedNotificationFirstRunBooleanPrefChanged(bool* new_value); 169 void OnSyncedNotificationFirstRunBooleanPrefChanged(bool* new_value);
163 170
164 // Convert our internal set of strings to a list value. 171 // Convert our internal set of strings to a list value.
165 // The second param is an outparam which the function fills in. 172 // The second param is an outparam which the function fills in.
166 void BuildServiceListValueInplace( 173 void BuildServiceListValueInplace(
167 std::set<std::string> services, base::ListValue* list_value); 174 std::set<std::string> services, base::ListValue* list_value);
168 175
169 SyncedNotificationAppInfoTemp* FindAppInfo(const std::string& app_id) const; 176 notifier::SyncedNotificationAppInfo* FindAppInfoByAppId(
177 const std::string& app_id) const;
170 178
171 const Notification CreateWelcomeNotificationForService( 179 const Notification CreateWelcomeNotificationForService(
172 SyncedNotificationAppInfoTemp* app_info); 180 SyncedNotificationAppInfo* app_info);
173 181
174 // Preferences for storing which SyncedNotificationServices are enabled 182 // Preferences for storing which SyncedNotificationServices are enabled
175 StringListPrefMember enabled_sending_services_prefs_; 183 StringListPrefMember enabled_sending_services_prefs_;
176 StringListPrefMember initialized_sending_services_prefs_; 184 StringListPrefMember initialized_sending_services_prefs_;
177 185
178 // Preferences to avoid toasting on SyncedNotification first run. 186 // Preferences to avoid toasting on SyncedNotification first run.
179 BooleanPrefMember synced_notification_first_run_prefs_; 187 BooleanPrefMember synced_notification_first_run_prefs_;
180 188
181 // Back pointer to the owning profile. 189 // Back pointer to the owning profile.
182 Profile* const profile_; 190 Profile* const profile_;
183 NotificationUIManager* const notification_manager_; 191 NotificationUIManager* const notification_manager_;
184 scoped_ptr<syncer::SyncChangeProcessor> sync_processor_; 192 scoped_ptr<syncer::SyncChangeProcessor> sync_processor_;
185 std::set<std::string> enabled_sending_services_; 193 std::set<std::string> enabled_sending_services_;
186 std::set<std::string> initialized_sending_services_; 194 std::set<std::string> initialized_sending_services_;
187 bool synced_notification_first_run_; 195 bool synced_notification_first_run_;
188 static bool avoid_bitmap_fetching_for_test_; 196 static bool avoid_bitmap_fetching_for_test_;
189 base::ThreadChecker thread_checker_; 197 base::ThreadChecker thread_checker_;
198 // Unowned pointer to the App Info service. The lifetime is managed by the
199 // profile service, this service depends on the App Info service, so it should
200 // always be in scope whenever our service is active.
201 SyncedNotificationAppInfoService* synced_notification_app_info_service_;
190 202
191 ScopedVector<SyncedNotificationAppInfoTemp> app_info_data_;
192 // TODO(petewil): Consider whether a map would better suit our data. 203 // TODO(petewil): Consider whether a map would better suit our data.
193 // If there are many entries, lookup time may trump locality of reference. 204 // If there are many entries, lookup time may trump locality of reference.
194 ScopedVector<SyncedNotification> notification_data_; 205 ScopedVector<SyncedNotification> notification_data_;
195 206
196 friend class ChromeNotifierServiceTest; 207 friend class ChromeNotifierServiceTest;
197 FRIEND_TEST_ALL_PREFIXES(ChromeNotifierServiceTest, ServiceEnabledTest); 208 FRIEND_TEST_ALL_PREFIXES(ChromeNotifierServiceTest, ServiceEnabledTest);
198 FRIEND_TEST_ALL_PREFIXES(ChromeNotifierServiceTest, 209 FRIEND_TEST_ALL_PREFIXES(ChromeNotifierServiceTest,
199 AddNewSendingServicesTest); 210 AddNewSendingServicesTest);
200 FRIEND_TEST_ALL_PREFIXES(ChromeNotifierServiceTest, 211 FRIEND_TEST_ALL_PREFIXES(ChromeNotifierServiceTest,
201 CheckInitializedServicesTest); 212 CheckInitializedServicesTest);
202 FRIEND_TEST_ALL_PREFIXES(ChromeNotifierServiceTest, 213 FRIEND_TEST_ALL_PREFIXES(ChromeNotifierServiceTest,
203 GetEnabledSendingServicesFromPreferencesTest); 214 GetEnabledSendingServicesFromPreferencesTest);
204 FRIEND_TEST_ALL_PREFIXES(ChromeNotifierServiceTest, CheckFindAppInfo); 215 FRIEND_TEST_ALL_PREFIXES(ChromeNotifierServiceTest, CheckFindAppInfo);
216 FRIEND_TEST_ALL_PREFIXES(ChromeNotifierServiceTest, SetAddedAppIdsTest);
217 FRIEND_TEST_ALL_PREFIXES(ChromeNotifierServiceTest, SetRemovedAppIdsTest);
205 218
206 DISALLOW_COPY_AND_ASSIGN(ChromeNotifierService); 219 DISALLOW_COPY_AND_ASSIGN(ChromeNotifierService);
207 }; 220 };
208 221
209 } // namespace notifier 222 } // namespace notifier
210 223
211 #endif // CHROME_BROWSER_NOTIFICATIONS_SYNC_NOTIFIER_CHROME_NOTIFIER_SERVICE_H_ 224 #endif // CHROME_BROWSER_NOTIFICATIONS_SYNC_NOTIFIER_CHROME_NOTIFIER_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698