Chromium Code Reviews| Index: chrome/browser/chrome_to_mobile_service.cc |
| diff --git a/chrome/browser/chrome_to_mobile_service.cc b/chrome/browser/chrome_to_mobile_service.cc |
| index dfb42f79ea008b10a5c2674fcbefe47a081ffabc..c111c300cdfa87f9d6d6adb4c09f9765c785bd81 100644 |
| --- a/chrome/browser/chrome_to_mobile_service.cc |
| +++ b/chrome/browser/chrome_to_mobile_service.cc |
| @@ -15,12 +15,12 @@ |
| #include "base/utf_string_conversions.h" |
| #include "chrome/app/chrome_command_ids.h" |
| #include "chrome/browser/chrome_to_mobile_service_factory.h" |
| +#include "chrome/browser/invalidation/invalidation_service.h" |
| +#include "chrome/browser/invalidation/invalidation_service_factory.h" |
| #include "chrome/browser/printing/cloud_print/cloud_print_url.h" |
| #include "chrome/browser/profiles/profile.h" |
| #include "chrome/browser/signin/token_service.h" |
| #include "chrome/browser/signin/token_service_factory.h" |
| -#include "chrome/browser/sync/profile_sync_service.h" |
| -#include "chrome/browser/sync/profile_sync_service_factory.h" |
| #include "chrome/browser/ui/browser.h" |
| #include "chrome/browser/ui/browser_command_controller.h" |
| #include "chrome/browser/ui/browser_finder.h" |
| @@ -261,23 +261,27 @@ void ChromeToMobileService::RegisterUserPrefs( |
| ChromeToMobileService::ChromeToMobileService(Profile* profile) |
| : weak_ptr_factory_(this), |
| profile_(profile), |
| - sync_invalidation_enabled_(false) { |
| + invalidation_enabled_(false) { |
| // TODO(msw): Unit tests do not provide profiles; see http://crbug.com/122183 |
| - ProfileSyncService* profile_sync_service = |
| - profile_ ? ProfileSyncServiceFactory::GetForProfile(profile_) : NULL; |
| - if (profile_sync_service) { |
| + |
| + invalidation::InvalidationService* invalidation_service = NULL; |
| + if (profile_) { |
|
msw
2013/05/23 00:00:02
Side note: Too bad ProfileKeyedBaseFactory::GetBro
|
| + invalidation_service = |
| + invalidation::InvalidationServiceFactory::GetForProfile(profile_); |
| + } |
| + if (invalidation_service) { |
| CloudPrintURL cloud_print_url(profile_); |
| cloud_print_url_ = cloud_print_url.GetCloudPrintServiceURL(); |
| - sync_invalidation_enabled_ = |
| - (profile_sync_service->GetInvalidatorState() == |
| + invalidation_enabled_ = |
| + (invalidation_service->GetInvalidatorState() == |
| syncer::INVALIDATIONS_ENABLED); |
| // Register for cloud print device list invalidation notifications. |
| - profile_sync_service->RegisterInvalidationHandler(this); |
| + invalidation_service->RegisterInvalidationHandler(this); |
| syncer::ObjectIdSet ids; |
| ids.insert(invalidation::ObjectId( |
| ipc::invalidation::ObjectSource::CHROME_COMPONENTS, |
| kSyncInvalidationObjectIdChromeToMobileDeviceList)); |
| - profile_sync_service->UpdateRegisteredInvalidationIds(this, ids); |
| + invalidation_service->UpdateRegisteredInvalidationIds(this, ids); |
| } |
| } |
| @@ -292,7 +296,7 @@ bool ChromeToMobileService::HasMobiles() const { |
| } |
| const base::ListValue* ChromeToMobileService::GetMobiles() const { |
| - return sync_invalidation_enabled_ ? |
| + return invalidation_enabled_ ? |
| profile_->GetPrefs()->GetList(prefs::kChromeToMobileDeviceList) : NULL; |
| } |
| @@ -384,10 +388,12 @@ void ChromeToMobileService::LearnMore(Browser* browser) const { |
| void ChromeToMobileService::Shutdown() { |
| // TODO(msw): Unit tests do not provide profiles; see http://crbug.com/122183 |
| // Unregister for cloud print device list invalidation notifications. |
| - ProfileSyncService* profile_sync_service = |
| - profile_ ? ProfileSyncServiceFactory::GetForProfile(profile_) : NULL; |
| - if (profile_sync_service) |
| - profile_sync_service->UnregisterInvalidationHandler(this); |
| + invalidation::InvalidationService* invalidation_service = |
| + profile_ ? |
|
msw
2013/05/23 00:00:02
nit: move "profile_ ?" to the line above, outdent
rlarocque
2013/05/23 21:43:27
Done.
|
| + invalidation::InvalidationServiceFactory::GetForProfile(profile_) |
| + : NULL; |
| + if (invalidation_service) |
| + invalidation_service->UnregisterInvalidationHandler(this); |
| } |
| void ChromeToMobileService::OnURLFetchComplete(const net::URLFetcher* source) { |
| @@ -472,7 +478,7 @@ void ChromeToMobileService::OnGetTokenFailure( |
| void ChromeToMobileService::OnInvalidatorStateChange( |
| syncer::InvalidatorState state) { |
| - sync_invalidation_enabled_ = (state == syncer::INVALIDATIONS_ENABLED); |
| + invalidation_enabled_ = (state == syncer::INVALIDATIONS_ENABLED); |
| } |
| void ChromeToMobileService::OnIncomingInvalidation( |
| @@ -482,12 +488,14 @@ void ChromeToMobileService::OnIncomingInvalidation( |
| ipc::invalidation::ObjectSource::CHROME_COMPONENTS, |
| kSyncInvalidationObjectIdChromeToMobileDeviceList))); |
| // TODO(msw): Unit tests do not provide profiles; see http://crbug.com/122183 |
| - ProfileSyncService* profile_sync_service = |
| - profile_ ? ProfileSyncServiceFactory::GetForProfile(profile_) : NULL; |
| - if (profile_sync_service) { |
| + invalidation::InvalidationService* invalidation_service = |
| + profile_ ? |
| + invalidation::InvalidationServiceFactory::GetForProfile(profile_) |
| + : NULL; |
| + if (invalidation_service) { |
| // TODO(dcheng): Only acknowledge the invalidation once the device search |
| // has finished. http://crbug.com/156843. |
| - profile_sync_service->AcknowledgeInvalidation( |
| + invalidation_service->AcknowledgeInvalidation( |
| invalidation_map.begin()->first, |
| invalidation_map.begin()->second.ack_handle); |
| } |