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

Side by Side Diff: chrome/browser/notifications/sync_notifier/chrome_notifier_service.cc

Issue 411463003: [Sync] Trigger refresh for synced notifications on context change (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Self review Created 6 years, 5 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
« no previous file with comments | « chrome/browser/notifications/sync_notifier/chrome_notifier_service.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // The ChromeNotifierService works together with sync to maintain the state of 5 // The ChromeNotifierService works together with sync to maintain the state of
6 // user notifications, which can then be presented in the notification center, 6 // user notifications, which can then be presented in the notification center,
7 // via the Notification UI Manager. 7 // via the Notification UI Manager.
8 8
9 #include "chrome/browser/notifications/sync_notifier/chrome_notifier_service.h" 9 #include "chrome/browser/notifications/sync_notifier/chrome_notifier_service.h"
10 10
11 #include "chrome/browser/chrome_notification_types.h"
11 #include "chrome/browser/extensions/api/synced_notifications_private/synced_noti fications_shim.h" 12 #include "chrome/browser/extensions/api/synced_notifications_private/synced_noti fications_shim.h"
12 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
14 #include "content/public/browser/notification_service.h"
13 #include "extensions/browser/event_router.h" 15 #include "extensions/browser/event_router.h"
14 16
15 namespace notifier { 17 namespace notifier {
16 18
17 ChromeNotifierService::ChromeNotifierService(Profile* profile) 19 ChromeNotifierService::ChromeNotifierService(Profile* profile)
18 : profile_(profile), 20 : profile_(profile),
19 weak_ptr_factory_(this) { 21 weak_ptr_factory_(this) {
20 synced_notifications_shim_.reset(new SyncedNotificationsShim( 22 synced_notifications_shim_.reset(new SyncedNotificationsShim(
21 base::Bind(&ChromeNotifierService::FireSyncJSEvent, 23 base::Bind(&ChromeNotifierService::FireSyncJSEvent,
24 weak_ptr_factory_.GetWeakPtr()),
25 base::Bind(&ChromeNotifierService::NotifyRefreshNeeded,
22 weak_ptr_factory_.GetWeakPtr()))); 26 weak_ptr_factory_.GetWeakPtr())));
23 } 27 }
24 28
25 ChromeNotifierService::~ChromeNotifierService() { 29 ChromeNotifierService::~ChromeNotifierService() {
26 } 30 }
27 31
28 // Methods from KeyedService. 32 // Methods from KeyedService.
29 void ChromeNotifierService::Shutdown() {} 33 void ChromeNotifierService::Shutdown() {}
30 34
31 SyncedNotificationsShim* ChromeNotifierService::GetSyncedNotificationsShim() { 35 SyncedNotificationsShim* ChromeNotifierService::GetSyncedNotificationsShim() {
32 return synced_notifications_shim_.get(); 36 return synced_notifications_shim_.get();
33 } 37 }
34 38
35 void ChromeNotifierService::FireSyncJSEvent( 39 void ChromeNotifierService::FireSyncJSEvent(
36 scoped_ptr<extensions::Event> event) { 40 scoped_ptr<extensions::Event> event) {
37 event->restrict_to_browser_context = profile_; 41 event->restrict_to_browser_context = profile_;
38 // TODO(synced notifications): consider broadcasting to a specific extension 42 // TODO(synced notifications): consider broadcasting to a specific extension
39 // id. 43 // id.
40 extensions::EventRouter::Get(profile_)->BroadcastEvent(event.Pass()); 44 extensions::EventRouter::Get(profile_)->BroadcastEvent(event.Pass());
41 } 45 }
42 46
47 void ChromeNotifierService::NotifyRefreshNeeded() {
48 const syncer::ModelTypeSet types(syncer::SYNCED_NOTIFICATIONS);
49 content::NotificationService::current()->Notify(
50 chrome::NOTIFICATION_SYNC_REFRESH_LOCAL,
51 content::Source<Profile>(profile_),
52 content::Details<const syncer::ModelTypeSet>(&types));
53 }
54
43 } // namespace notifier 55 } // namespace notifier
OLDNEW
« no previous file with comments | « chrome/browser/notifications/sync_notifier/chrome_notifier_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698