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

Side by Side Diff: trunk/src/chrome/browser/extensions/api/push_messaging/push_messaging_api.cc

Issue 17610004: Revert 208315 "Make use of InvalidationService" (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 6 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 #include "chrome/browser/extensions/api/push_messaging/push_messaging_api.h" 5 #include "chrome/browser/extensions/api/push_messaging/push_messaging_api.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "chrome/browser/extensions/api/push_messaging/push_messaging_invalidati on_handler.h" 14 #include "chrome/browser/extensions/api/push_messaging/push_messaging_invalidati on_handler.h"
15 #include "chrome/browser/extensions/event_names.h" 15 #include "chrome/browser/extensions/event_names.h"
16 #include "chrome/browser/extensions/event_router.h" 16 #include "chrome/browser/extensions/event_router.h"
17 #include "chrome/browser/extensions/extension_service.h" 17 #include "chrome/browser/extensions/extension_service.h"
18 #include "chrome/browser/extensions/extension_system.h" 18 #include "chrome/browser/extensions/extension_system.h"
19 #include "chrome/browser/extensions/extension_system_factory.h" 19 #include "chrome/browser/extensions/extension_system_factory.h"
20 #include "chrome/browser/extensions/token_cache/token_cache_service.h" 20 #include "chrome/browser/extensions/token_cache/token_cache_service.h"
21 #include "chrome/browser/extensions/token_cache/token_cache_service_factory.h" 21 #include "chrome/browser/extensions/token_cache/token_cache_service_factory.h"
22 #include "chrome/browser/invalidation/invalidation_service.h"
23 #include "chrome/browser/invalidation/invalidation_service_factory.h"
24 #include "chrome/browser/profiles/profile.h" 22 #include "chrome/browser/profiles/profile.h"
25 #include "chrome/browser/signin/token_service.h" 23 #include "chrome/browser/signin/token_service.h"
26 #include "chrome/browser/signin/token_service_factory.h" 24 #include "chrome/browser/signin/token_service_factory.h"
25 #include "chrome/browser/sync/profile_sync_service.h"
26 #include "chrome/browser/sync/profile_sync_service_factory.h"
27 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" 27 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h"
28 #include "chrome/common/chrome_notification_types.h" 28 #include "chrome/common/chrome_notification_types.h"
29 #include "chrome/common/extensions/api/push_messaging.h" 29 #include "chrome/common/extensions/api/push_messaging.h"
30 #include "chrome/common/extensions/extension.h" 30 #include "chrome/common/extensions/extension.h"
31 #include "chrome/common/extensions/extension_set.h" 31 #include "chrome/common/extensions/extension_set.h"
32 #include "chrome/common/extensions/permissions/api_permission.h" 32 #include "chrome/common/extensions/permissions/api_permission.h"
33 #include "content/public/browser/browser_thread.h" 33 #include "content/public/browser/browser_thread.h"
34 #include "content/public/browser/notification_details.h" 34 #include "content/public/browser/notification_details.h"
35 #include "content/public/browser/notification_source.h" 35 #include "content/public/browser/notification_source.h"
36 #include "google_apis/gaia/gaia_constants.h" 36 #include "google_apis/gaia/gaia_constants.h"
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 295
296 // static 296 // static
297 ProfileKeyedAPIFactory<PushMessagingAPI>* 297 ProfileKeyedAPIFactory<PushMessagingAPI>*
298 PushMessagingAPI::GetFactoryInstance() { 298 PushMessagingAPI::GetFactoryInstance() {
299 return &g_factory.Get(); 299 return &g_factory.Get();
300 } 300 }
301 301
302 void PushMessagingAPI::Observe(int type, 302 void PushMessagingAPI::Observe(int type,
303 const content::NotificationSource& source, 303 const content::NotificationSource& source,
304 const content::NotificationDetails& details) { 304 const content::NotificationDetails& details) {
305 invalidation::InvalidationService* invalidation_service = 305 ProfileSyncService* pss = ProfileSyncServiceFactory::GetForProfile(profile_);
306 invalidation::InvalidationServiceFactory::GetForProfile(profile_);
307 // This may be NULL; for example, for the ChromeOS guest user. In these cases, 306 // This may be NULL; for example, for the ChromeOS guest user. In these cases,
308 // just return without setting up anything, since it won't work anyway. 307 // just return without setting up anything, since it won't work anyway.
309 if (!invalidation_service) 308 if (!pss)
310 return; 309 return;
311 310
312 if (!event_router_) 311 if (!event_router_)
313 event_router_.reset(new PushMessagingEventRouter(profile_)); 312 event_router_.reset(new PushMessagingEventRouter(profile_));
314 if (!handler_) { 313 if (!handler_) {
315 handler_.reset(new PushMessagingInvalidationHandler( 314 handler_.reset(new PushMessagingInvalidationHandler(
316 invalidation_service, event_router_.get())); 315 pss, event_router_.get()));
317 } 316 }
318 switch (type) { 317 switch (type) {
319 case chrome::NOTIFICATION_EXTENSION_INSTALLED: { 318 case chrome::NOTIFICATION_EXTENSION_INSTALLED: {
320 const Extension* extension = 319 const Extension* extension =
321 content::Details<const InstalledExtensionInfo>(details)->extension; 320 content::Details<const InstalledExtensionInfo>(details)->extension;
322 if (extension->HasAPIPermission(APIPermission::kPushMessaging)) { 321 if (extension->HasAPIPermission(APIPermission::kPushMessaging)) {
323 handler_->SuppressInitialInvalidationsForExtension(extension->id()); 322 handler_->SuppressInitialInvalidationsForExtension(extension->id());
324 } 323 }
325 break; 324 break;
326 } 325 }
(...skipping 18 matching lines...) Expand all
345 } 344 }
346 345
347 void PushMessagingAPI::SetMapperForTest( 346 void PushMessagingAPI::SetMapperForTest(
348 scoped_ptr<PushMessagingInvalidationMapper> mapper) { 347 scoped_ptr<PushMessagingInvalidationMapper> mapper) {
349 handler_ = mapper.Pass(); 348 handler_ = mapper.Pass();
350 } 349 }
351 350
352 template <> 351 template <>
353 void ProfileKeyedAPIFactory<PushMessagingAPI>::DeclareFactoryDependencies() { 352 void ProfileKeyedAPIFactory<PushMessagingAPI>::DeclareFactoryDependencies() {
354 DependsOn(ExtensionSystemFactory::GetInstance()); 353 DependsOn(ExtensionSystemFactory::GetInstance());
355 DependsOn(invalidation::InvalidationServiceFactory::GetInstance()); 354 DependsOn(ProfileSyncServiceFactory::GetInstance());
356 } 355 }
357 356
358 } // namespace extensions 357 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698