Index: content/browser/background_sync/background_sync_manager.cc |
diff --git a/content/browser/background_sync/background_sync_manager.cc b/content/browser/background_sync/background_sync_manager.cc |
index 018bbae5ab270ecfc3905a191a9fbb48dd63cb93..6ba38b57924d1e0dbe2ded9e8775ea56e176531d 100644 |
--- a/content/browser/background_sync/background_sync_manager.cc |
+++ b/content/browser/background_sync/background_sync_manager.cc |
@@ -73,6 +73,7 @@ BackgroundSyncManager::RegistrationKey::RegistrationKey( |
void BackgroundSyncManager::Register( |
int64 sw_registration_id, |
const BackgroundSyncRegistrationOptions& options, |
+ bool requested_from_service_worker, |
const StatusAndRegistrationCallback& callback) { |
DCHECK_CURRENTLY_ON(BrowserThread::IO); |
@@ -93,10 +94,10 @@ void BackgroundSyncManager::Register( |
return; |
} |
- op_scheduler_.ScheduleOperation( |
- base::Bind(&BackgroundSyncManager::RegisterImpl, |
- weak_ptr_factory_.GetWeakPtr(), sw_registration_id, options, |
- MakeStatusAndRegistrationCompletion(callback))); |
+ op_scheduler_.ScheduleOperation(base::Bind( |
+ &BackgroundSyncManager::RegisterImpl, weak_ptr_factory_.GetWeakPtr(), |
+ sw_registration_id, options, requested_from_service_worker, |
+ MakeStatusAndRegistrationCompletion(callback))); |
} |
void BackgroundSyncManager::Unregister( |
@@ -301,6 +302,7 @@ void BackgroundSyncManager::InitDidGetDataFromBackend( |
void BackgroundSyncManager::RegisterImpl( |
int64 sw_registration_id, |
const BackgroundSyncRegistrationOptions& options, |
+ bool requested_from_service_worker, |
const StatusAndRegistrationCallback& callback) { |
DCHECK_CURRENTLY_ON(BrowserThread::IO); |
@@ -335,7 +337,8 @@ void BackgroundSyncManager::RegisterImpl( |
return; |
} |
- if (!sw_registration->active_version()->HasWindowClients()) { |
+ if (requested_from_service_worker && |
+ !sw_registration->active_version()->HasWindowClients()) { |
base::ThreadTaskRunnerHandle::Get()->PostTask( |
FROM_HERE, base::Bind(callback, BACKGROUND_SYNC_STATUS_NOT_ALLOWED, |
BackgroundSyncRegistration())); |