| 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 "modules/quota/StorageManager.h" | 5 #include "modules/quota/StorageManager.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ScriptPromiseResolver.h" | 7 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 8 #include "bindings/modules/v8/V8StorageEstimate.h" | 8 #include "bindings/modules/v8/V8StorageEstimate.h" |
| 9 #include "core/dom/DOMException.h" | 9 #include "core/dom/DOMException.h" |
| 10 #include "core/dom/Document.h" | 10 #include "core/dom/Document.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 ScriptPromise promise = resolver->Promise(); | 65 ScriptPromise promise = resolver->Promise(); |
| 66 ExecutionContext* execution_context = script_state->GetExecutionContext(); | 66 ExecutionContext* execution_context = script_state->GetExecutionContext(); |
| 67 DCHECK(execution_context->IsSecureContext()); // [SecureContext] in IDL | 67 DCHECK(execution_context->IsSecureContext()); // [SecureContext] in IDL |
| 68 SecurityOrigin* security_origin = execution_context->GetSecurityOrigin(); | 68 SecurityOrigin* security_origin = execution_context->GetSecurityOrigin(); |
| 69 if (security_origin->IsUnique()) { | 69 if (security_origin->IsUnique()) { |
| 70 resolver->Reject(V8ThrowException::CreateTypeError( | 70 resolver->Reject(V8ThrowException::CreateTypeError( |
| 71 script_state->GetIsolate(), kUniqueOriginErrorMessage)); | 71 script_state->GetIsolate(), kUniqueOriginErrorMessage)); |
| 72 return promise; | 72 return promise; |
| 73 } | 73 } |
| 74 | 74 |
| 75 ASSERT(execution_context->IsDocument()); | 75 DCHECK(execution_context->IsDocument()); |
| 76 PermissionService* permission_service = | 76 PermissionService* permission_service = |
| 77 GetPermissionService(script_state->GetExecutionContext()); | 77 GetPermissionService(script_state->GetExecutionContext()); |
| 78 if (!permission_service) { | 78 if (!permission_service) { |
| 79 resolver->Reject(DOMException::Create( | 79 resolver->Reject(DOMException::Create( |
| 80 kInvalidStateError, | 80 kInvalidStateError, |
| 81 "In its current state, the global scope can't request permissions.")); | 81 "In its current state, the global scope can't request permissions.")); |
| 82 return promise; | 82 return promise; |
| 83 } | 83 } |
| 84 permission_service->RequestPermission( | 84 permission_service->RequestPermission( |
| 85 CreatePermissionDescriptor(PermissionName::DURABLE_STORAGE), | 85 CreatePermissionDescriptor(PermissionName::DURABLE_STORAGE), |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 | 159 |
| 160 void StorageManager::PermissionRequestComplete(ScriptPromiseResolver* resolver, | 160 void StorageManager::PermissionRequestComplete(ScriptPromiseResolver* resolver, |
| 161 PermissionStatus status) { | 161 PermissionStatus status) { |
| 162 if (!resolver->GetExecutionContext() || | 162 if (!resolver->GetExecutionContext() || |
| 163 resolver->GetExecutionContext()->IsContextDestroyed()) | 163 resolver->GetExecutionContext()->IsContextDestroyed()) |
| 164 return; | 164 return; |
| 165 resolver->Resolve(status == PermissionStatus::GRANTED); | 165 resolver->Resolve(status == PermissionStatus::GRANTED); |
| 166 } | 166 } |
| 167 | 167 |
| 168 } // namespace blink | 168 } // namespace blink |
| OLD | NEW |