| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "content/child/background_sync/background_sync_provider.h" | 5 #include "content/child/background_sync/background_sync_provider.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "components/permission/public/interfaces/permission_status.mojom.h" |
| 9 #include "content/child/background_sync/background_sync_type_converters.h" | 10 #include "content/child/background_sync/background_sync_type_converters.h" |
| 10 #include "content/child/service_worker/web_service_worker_registration_impl.h" | 11 #include "content/child/service_worker/web_service_worker_registration_impl.h" |
| 11 #include "content/child/worker_task_runner.h" | 12 #include "content/child/worker_task_runner.h" |
| 12 #include "content/public/common/background_sync.mojom.h" | 13 #include "content/public/common/background_sync.mojom.h" |
| 13 #include "content/public/common/permission_status.mojom.h" | |
| 14 #include "content/public/common/service_registry.h" | 14 #include "content/public/common/service_registry.h" |
| 15 #include "third_party/WebKit/public/platform/modules/background_sync/WebSyncErro
r.h" | 15 #include "third_party/WebKit/public/platform/modules/background_sync/WebSyncErro
r.h" |
| 16 #include "third_party/WebKit/public/platform/modules/background_sync/WebSyncRegi
stration.h" | 16 #include "third_party/WebKit/public/platform/modules/background_sync/WebSyncRegi
stration.h" |
| 17 | 17 |
| 18 namespace content { | 18 namespace content { |
| 19 namespace { | 19 namespace { |
| 20 | 20 |
| 21 // Returns the id of the given |service_worker_registration|, which | 21 // Returns the id of the given |service_worker_registration|, which |
| 22 // is only available on the implementation of the interface. | 22 // is only available on the implementation of the interface. |
| 23 int64 GetServiceWorkerRegistrationId( | 23 int64 GetServiceWorkerRegistrationId( |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 callbacks->onError( | 293 callbacks->onError( |
| 294 blink::WebSyncError(blink::WebSyncError::ErrorTypeUnknown, | 294 blink::WebSyncError(blink::WebSyncError::ErrorTypeUnknown, |
| 295 "No service worker is active.")); | 295 "No service worker is active.")); |
| 296 break; | 296 break; |
| 297 } | 297 } |
| 298 } | 298 } |
| 299 | 299 |
| 300 void BackgroundSyncProvider::GetPermissionStatusCallback( | 300 void BackgroundSyncProvider::GetPermissionStatusCallback( |
| 301 scoped_ptr<blink::WebSyncGetPermissionStatusCallbacks> callbacks, | 301 scoped_ptr<blink::WebSyncGetPermissionStatusCallbacks> callbacks, |
| 302 BackgroundSyncError error, | 302 BackgroundSyncError error, |
| 303 PermissionStatus status) { | 303 permission::Status status) { |
| 304 // TODO(iclelland): Determine the correct error message to return in each case | 304 // TODO(iclelland): Determine the correct error message to return in each case |
| 305 switch (error) { | 305 switch (error) { |
| 306 case BACKGROUND_SYNC_ERROR_NONE: | 306 case BACKGROUND_SYNC_ERROR_NONE: |
| 307 switch (status) { | 307 switch (status) { |
| 308 case PERMISSION_STATUS_GRANTED: | 308 case permission::STATUS_GRANTED: |
| 309 callbacks->onSuccess(blink::WebSyncPermissionStatusGranted); | 309 callbacks->onSuccess(blink::WebSyncPermissionStatusGranted); |
| 310 break; | 310 break; |
| 311 case PERMISSION_STATUS_DENIED: | 311 case permission::STATUS_DENIED: |
| 312 callbacks->onSuccess(blink::WebSyncPermissionStatusDenied); | 312 callbacks->onSuccess(blink::WebSyncPermissionStatusDenied); |
| 313 break; | 313 break; |
| 314 case PERMISSION_STATUS_ASK: | 314 case permission::STATUS_ASK: |
| 315 callbacks->onSuccess(blink::WebSyncPermissionStatusPrompt); | 315 callbacks->onSuccess(blink::WebSyncPermissionStatusPrompt); |
| 316 break; | 316 break; |
| 317 } | 317 } |
| 318 break; | 318 break; |
| 319 case BACKGROUND_SYNC_ERROR_NOT_FOUND: | 319 case BACKGROUND_SYNC_ERROR_NOT_FOUND: |
| 320 case BACKGROUND_SYNC_ERROR_NOT_ALLOWED: | 320 case BACKGROUND_SYNC_ERROR_NOT_ALLOWED: |
| 321 // These errors should never be returned from | 321 // These errors should never be returned from |
| 322 // BackgroundSyncManager::GetPermissionStatus | 322 // BackgroundSyncManager::GetPermissionStatus |
| 323 NOTREACHED(); | 323 NOTREACHED(); |
| 324 break; | 324 break; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 BackgroundSyncServicePtr& | 376 BackgroundSyncServicePtr& |
| 377 BackgroundSyncProvider::GetBackgroundSyncServicePtr() { | 377 BackgroundSyncProvider::GetBackgroundSyncServicePtr() { |
| 378 if (!background_sync_service_.get()) { | 378 if (!background_sync_service_.get()) { |
| 379 service_registry_->ConnectToRemoteService( | 379 service_registry_->ConnectToRemoteService( |
| 380 mojo::GetProxy(&background_sync_service_)); | 380 mojo::GetProxy(&background_sync_service_)); |
| 381 } | 381 } |
| 382 return background_sync_service_; | 382 return background_sync_service_; |
| 383 } | 383 } |
| 384 | 384 |
| 385 } // namespace content | 385 } // namespace content |
| OLD | NEW |