| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/permissions/Permissions.h" | 5 #include "modules/permissions/Permissions.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/Dictionary.h" | 7 #include "bindings/core/v8/Dictionary.h" |
| 8 #include "bindings/core/v8/Nullable.h" | 8 #include "bindings/core/v8/Nullable.h" |
| 9 #include "bindings/core/v8/ScriptPromise.h" | 9 #include "bindings/core/v8/ScriptPromise.h" |
| 10 #include "bindings/core/v8/ScriptPromiseResolver.h" | 10 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 "In its current state, the global " | 149 "In its current state, the global " |
| 150 "scope can't request permissions.")); | 150 "scope can't request permissions.")); |
| 151 | 151 |
| 152 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); | 152 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); |
| 153 ScriptPromise promise = resolver->promise(); | 153 ScriptPromise promise = resolver->promise(); |
| 154 | 154 |
| 155 PermissionDescriptorPtr descriptorCopy = descriptor->Clone(); | 155 PermissionDescriptorPtr descriptorCopy = descriptor->Clone(); |
| 156 service->RequestPermission( | 156 service->RequestPermission( |
| 157 std::move(descriptor), | 157 std::move(descriptor), |
| 158 scriptState->getExecutionContext()->getSecurityOrigin(), | 158 scriptState->getExecutionContext()->getSecurityOrigin(), |
| 159 UserGestureIndicator::processingUserGesture(), | 159 UserGestureIndicator::processingUserGestureThreadSafe(), |
| 160 convertToBaseCallback(WTF::bind( | 160 convertToBaseCallback(WTF::bind( |
| 161 &Permissions::taskComplete, wrapPersistent(this), | 161 &Permissions::taskComplete, wrapPersistent(this), |
| 162 wrapPersistent(resolver), WTF::passed(std::move(descriptorCopy))))); | 162 wrapPersistent(resolver), WTF::passed(std::move(descriptorCopy))))); |
| 163 return promise; | 163 return promise; |
| 164 } | 164 } |
| 165 | 165 |
| 166 ScriptPromise Permissions::revoke(ScriptState* scriptState, | 166 ScriptPromise Permissions::revoke(ScriptState* scriptState, |
| 167 const Dictionary& rawPermission) { | 167 const Dictionary& rawPermission) { |
| 168 ExceptionState exceptionState(scriptState->isolate(), | 168 ExceptionState exceptionState(scriptState->isolate(), |
| 169 ExceptionState::GetterContext, "Permissions", | 169 ExceptionState::GetterContext, "Permissions", |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 ScriptPromise promise = resolver->promise(); | 240 ScriptPromise promise = resolver->promise(); |
| 241 | 241 |
| 242 Vector<PermissionDescriptorPtr> internalPermissionsCopy; | 242 Vector<PermissionDescriptorPtr> internalPermissionsCopy; |
| 243 internalPermissionsCopy.reserveCapacity(internalPermissions.size()); | 243 internalPermissionsCopy.reserveCapacity(internalPermissions.size()); |
| 244 for (const auto& descriptor : internalPermissions) | 244 for (const auto& descriptor : internalPermissions) |
| 245 internalPermissionsCopy.append(descriptor->Clone()); | 245 internalPermissionsCopy.append(descriptor->Clone()); |
| 246 | 246 |
| 247 service->RequestPermissions( | 247 service->RequestPermissions( |
| 248 std::move(internalPermissions), | 248 std::move(internalPermissions), |
| 249 scriptState->getExecutionContext()->getSecurityOrigin(), | 249 scriptState->getExecutionContext()->getSecurityOrigin(), |
| 250 UserGestureIndicator::processingUserGesture(), | 250 UserGestureIndicator::processingUserGestureThreadSafe(), |
| 251 convertToBaseCallback( | 251 convertToBaseCallback( |
| 252 WTF::bind(&Permissions::batchTaskComplete, wrapPersistent(this), | 252 WTF::bind(&Permissions::batchTaskComplete, wrapPersistent(this), |
| 253 wrapPersistent(resolver), | 253 wrapPersistent(resolver), |
| 254 WTF::passed(std::move(internalPermissionsCopy)), | 254 WTF::passed(std::move(internalPermissionsCopy)), |
| 255 WTF::passed(std::move(callerIndexToInternalIndex))))); | 255 WTF::passed(std::move(callerIndexToInternalIndex))))); |
| 256 return promise; | 256 return promise; |
| 257 } | 257 } |
| 258 | 258 |
| 259 PermissionService* Permissions::getService(ExecutionContext* executionContext) { | 259 PermissionService* Permissions::getService(ExecutionContext* executionContext) { |
| 260 if (!m_service && | 260 if (!m_service && |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 result.reserveInitialCapacity(callerIndexToInternalIndex.size()); | 301 result.reserveInitialCapacity(callerIndexToInternalIndex.size()); |
| 302 for (int internalIndex : callerIndexToInternalIndex) { | 302 for (int internalIndex : callerIndexToInternalIndex) { |
| 303 result.append(PermissionStatus::createAndListen( | 303 result.append(PermissionStatus::createAndListen( |
| 304 resolver->getExecutionContext(), results[internalIndex], | 304 resolver->getExecutionContext(), results[internalIndex], |
| 305 descriptors[internalIndex]->Clone())); | 305 descriptors[internalIndex]->Clone())); |
| 306 } | 306 } |
| 307 resolver->resolve(result); | 307 resolver->resolve(result); |
| 308 } | 308 } |
| 309 | 309 |
| 310 } // namespace blink | 310 } // namespace blink |
| OLD | NEW |