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

Side by Side Diff: chrome/browser/extensions/app_notification_manager.cc

Issue 10830036: Moved the AppNotification system into extensions namespace (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Latest master for cq Created 8 years, 4 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
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 #include "chrome/browser/extensions/app_notification_manager.h" 5 #include "chrome/browser/extensions/app_notification_manager.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/location.h" 10 #include "base/location.h"
11 #include "base/metrics/histogram.h" 11 #include "base/metrics/histogram.h"
12 #include "base/perftimer.h" 12 #include "base/perftimer.h"
13 #include "base/stl_util.h" 13 #include "base/stl_util.h"
14 #include "base/time.h" 14 #include "base/time.h"
15 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/common/chrome_notification_types.h" 16 #include "chrome/common/chrome_notification_types.h"
17 #include "chrome/common/extensions/extension.h" 17 #include "chrome/common/extensions/extension.h"
18 #include "content/public/browser/notification_service.h" 18 #include "content/public/browser/notification_service.h"
19 #include "sync/api/sync_error_factory.h" 19 #include "sync/api/sync_error_factory.h"
20 #include "sync/protocol/app_notification_specifics.pb.h" 20 #include "sync/protocol/app_notification_specifics.pb.h"
21 #include "sync/protocol/sync.pb.h" 21 #include "sync/protocol/sync.pb.h"
22 22
23 using content::BrowserThread; 23 using content::BrowserThread;
24 24
25 typedef std::map<std::string, syncer::SyncData> SyncDataMap; 25 typedef std::map<std::string, syncer::SyncData> SyncDataMap;
26 26
27 namespace extensions {
28
27 namespace { 29 namespace {
28 30
29 class GuidComparator 31 class GuidComparator
30 : public std::binary_function<linked_ptr<AppNotification>, 32 : public std::binary_function<linked_ptr<AppNotification>,
31 std::string, 33 std::string,
32 bool> { 34 bool> {
33 public: 35 public:
34 bool operator() (linked_ptr<AppNotification> notif, 36 bool operator() (linked_ptr<AppNotification> notif,
35 const std::string& guid) const { 37 const std::string& guid) const {
36 return notif->guid() == guid; 38 return notif->guid() == guid;
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 chrome::NOTIFICATION_APP_NOTIFICATION_STATE_CHANGED, 170 chrome::NOTIFICATION_APP_NOTIFICATION_STATE_CHANGED,
169 content::Source<Profile>(profile_), 171 content::Source<Profile>(profile_),
170 content::Details<const std::string>(&extension_id)); 172 content::Details<const std::string>(&extension_id));
171 } 173 }
172 174
173 void AppNotificationManager::Observe( 175 void AppNotificationManager::Observe(
174 int type, 176 int type,
175 const content::NotificationSource& source, 177 const content::NotificationSource& source,
176 const content::NotificationDetails& details) { 178 const content::NotificationDetails& details) {
177 CHECK(type == chrome::NOTIFICATION_EXTENSION_UNINSTALLED); 179 CHECK(type == chrome::NOTIFICATION_EXTENSION_UNINSTALLED);
178 ClearAll(content::Details<const extensions::Extension>(details).ptr()->id()); 180 ClearAll(content::Details<const Extension>(details).ptr()->id());
179 } 181 }
180 182
181 syncer::SyncDataList AppNotificationManager::GetAllSyncData( 183 syncer::SyncDataList AppNotificationManager::GetAllSyncData(
182 syncer::ModelType type) const { 184 syncer::ModelType type) const {
183 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 185 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
184 DCHECK(loaded()); 186 DCHECK(loaded());
185 DCHECK_EQ(syncer::APP_NOTIFICATIONS, type); 187 DCHECK_EQ(syncer::APP_NOTIFICATIONS, type);
186 syncer::SyncDataList data; 188 syncer::SyncDataList data;
187 for (NotificationMap::const_iterator iter = notifications_->begin(); 189 for (NotificationMap::const_iterator iter = notifications_->begin();
188 iter != notifications_->end(); ++iter) { 190 iter != notifications_->end(); ++iter) {
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 AppNotification* notification = new AppNotification( 579 AppNotification* notification = new AppNotification(
578 false, base::Time::FromInternalValue(specifics.creation_timestamp_ms()), 580 false, base::Time::FromInternalValue(specifics.creation_timestamp_ms()),
579 specifics.guid(), specifics.app_id(), 581 specifics.guid(), specifics.app_id(),
580 specifics.title(), specifics.body_text()); 582 specifics.title(), specifics.body_text());
581 if (specifics.has_link_text()) 583 if (specifics.has_link_text())
582 notification->set_link_text(specifics.link_text()); 584 notification->set_link_text(specifics.link_text());
583 if (specifics.has_link_url()) 585 if (specifics.has_link_url())
584 notification->set_link_url(GURL(specifics.link_url())); 586 notification->set_link_url(GURL(specifics.link_url()));
585 return notification; 587 return notification;
586 } 588 }
589
590 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698