| 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::processingUserGesture( |
| 160 UserGestureIndicator::CheckThreadState), |
| 160 convertToBaseCallback(WTF::bind( | 161 convertToBaseCallback(WTF::bind( |
| 161 &Permissions::taskComplete, wrapPersistent(this), | 162 &Permissions::taskComplete, wrapPersistent(this), |
| 162 wrapPersistent(resolver), passed(std::move(descriptorCopy))))); | 163 wrapPersistent(resolver), passed(std::move(descriptorCopy))))); |
| 163 return promise; | 164 return promise; |
| 164 } | 165 } |
| 165 | 166 |
| 166 ScriptPromise Permissions::revoke(ScriptState* scriptState, | 167 ScriptPromise Permissions::revoke(ScriptState* scriptState, |
| 167 const Dictionary& rawPermission) { | 168 const Dictionary& rawPermission) { |
| 168 ExceptionState exceptionState(ExceptionState::GetterContext, "revoke", | 169 ExceptionState exceptionState(ExceptionState::GetterContext, "revoke", |
| 169 "Permissions", scriptState->context()->Global(), | 170 "Permissions", scriptState->context()->Global(), |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 ScriptPromise promise = resolver->promise(); | 241 ScriptPromise promise = resolver->promise(); |
| 241 | 242 |
| 242 Vector<PermissionDescriptorPtr> internalPermissionsCopy; | 243 Vector<PermissionDescriptorPtr> internalPermissionsCopy; |
| 243 internalPermissionsCopy.reserveCapacity(internalPermissions.size()); | 244 internalPermissionsCopy.reserveCapacity(internalPermissions.size()); |
| 244 for (const auto& descriptor : internalPermissions) | 245 for (const auto& descriptor : internalPermissions) |
| 245 internalPermissionsCopy.append(descriptor->Clone()); | 246 internalPermissionsCopy.append(descriptor->Clone()); |
| 246 | 247 |
| 247 service->RequestPermissions( | 248 service->RequestPermissions( |
| 248 std::move(internalPermissions), | 249 std::move(internalPermissions), |
| 249 scriptState->getExecutionContext()->getSecurityOrigin(), | 250 scriptState->getExecutionContext()->getSecurityOrigin(), |
| 250 UserGestureIndicator::processingUserGesture(), | 251 UserGestureIndicator::processingUserGesture( |
| 252 UserGestureIndicator::CheckThreadState), |
| 251 convertToBaseCallback(WTF::bind( | 253 convertToBaseCallback(WTF::bind( |
| 252 &Permissions::batchTaskComplete, wrapPersistent(this), | 254 &Permissions::batchTaskComplete, wrapPersistent(this), |
| 253 wrapPersistent(resolver), passed(std::move(internalPermissionsCopy)), | 255 wrapPersistent(resolver), passed(std::move(internalPermissionsCopy)), |
| 254 passed(std::move(callerIndexToInternalIndex))))); | 256 passed(std::move(callerIndexToInternalIndex))))); |
| 255 return promise; | 257 return promise; |
| 256 } | 258 } |
| 257 | 259 |
| 258 PermissionService* Permissions::getService(ExecutionContext* executionContext) { | 260 PermissionService* Permissions::getService(ExecutionContext* executionContext) { |
| 259 if (!m_service && | 261 if (!m_service && |
| 260 connectToPermissionService(executionContext, mojo::GetProxy(&m_service))) | 262 connectToPermissionService(executionContext, mojo::GetProxy(&m_service))) |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 result.reserveInitialCapacity(callerIndexToInternalIndex.size()); | 302 result.reserveInitialCapacity(callerIndexToInternalIndex.size()); |
| 301 for (int internalIndex : callerIndexToInternalIndex) { | 303 for (int internalIndex : callerIndexToInternalIndex) { |
| 302 result.append(PermissionStatus::createAndListen( | 304 result.append(PermissionStatus::createAndListen( |
| 303 resolver->getExecutionContext(), results[internalIndex], | 305 resolver->getExecutionContext(), results[internalIndex], |
| 304 descriptors[internalIndex]->Clone())); | 306 descriptors[internalIndex]->Clone())); |
| 305 } | 307 } |
| 306 resolver->resolve(result); | 308 resolver->resolve(result); |
| 307 } | 309 } |
| 308 | 310 |
| 309 } // namespace blink | 311 } // namespace blink |
| OLD | NEW |