| 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/credentialmanager/CredentialsContainer.h" | 5 #include "modules/credentialmanager/CredentialsContainer.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> |
| 8 #include "bindings/core/v8/Dictionary.h" | 9 #include "bindings/core/v8/Dictionary.h" |
| 9 #include "bindings/core/v8/ScriptPromise.h" | 10 #include "bindings/core/v8/ScriptPromise.h" |
| 10 #include "bindings/core/v8/ScriptPromiseResolver.h" | 11 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 11 #include "core/dom/DOMException.h" | 12 #include "core/dom/DOMException.h" |
| 12 #include "core/dom/Document.h" | 13 #include "core/dom/Document.h" |
| 13 #include "core/dom/ExceptionCode.h" | 14 #include "core/dom/ExceptionCode.h" |
| 14 #include "core/dom/ExecutionContext.h" | 15 #include "core/dom/ExecutionContext.h" |
| 15 #include "core/frame/Frame.h" | 16 #include "core/frame/Frame.h" |
| 16 #include "core/frame/UseCounter.h" | 17 #include "core/frame/UseCounter.h" |
| 17 #include "core/page/FrameTree.h" | 18 #include "core/page/FrameTree.h" |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 ScriptPromise CredentialsContainer::get( | 161 ScriptPromise CredentialsContainer::get( |
| 161 ScriptState* script_state, | 162 ScriptState* script_state, |
| 162 const CredentialRequestOptions& options) { | 163 const CredentialRequestOptions& options) { |
| 163 ScriptPromiseResolver* resolver = ScriptPromiseResolver::Create(script_state); | 164 ScriptPromiseResolver* resolver = ScriptPromiseResolver::Create(script_state); |
| 164 ScriptPromise promise = resolver->Promise(); | 165 ScriptPromise promise = resolver->Promise(); |
| 165 if (!CheckBoilerplate(resolver)) | 166 if (!CheckBoilerplate(resolver)) |
| 166 return promise; | 167 return promise; |
| 167 | 168 |
| 168 Vector<KURL> providers; | 169 Vector<KURL> providers; |
| 169 if (options.hasFederated() && options.federated().hasProviders()) { | 170 if (options.hasFederated() && options.federated().hasProviders()) { |
| 170 // TODO(mkwst): CredentialRequestOptions::federated() needs to return a | 171 for (const auto& string : options.federated().providers()) { |
| 171 // reference, not a value. Because it returns a temporary value now, a for | |
| 172 // loop that directly references the value generates code that holds a | |
| 173 // reference to a value that no longer exists by the time the loop starts | |
| 174 // looping. In order to avoid this crazyness for the moment, we're making a | |
| 175 // copy of the vector. https://crbug.com/587088 | |
| 176 const Vector<String> provider_strings = options.federated().providers(); | |
| 177 for (const auto& string : provider_strings) { | |
| 178 KURL url = KURL(KURL(), string); | 172 KURL url = KURL(KURL(), string); |
| 179 if (url.IsValid()) | 173 if (url.IsValid()) |
| 180 providers.push_back(url); | 174 providers.push_back(std::move(url)); |
| 181 } | 175 } |
| 182 } | 176 } |
| 183 | 177 |
| 184 UseCounter::Count(ExecutionContext::From(script_state), | 178 UseCounter::Count(ExecutionContext::From(script_state), |
| 185 options.unmediated() | 179 options.unmediated() |
| 186 ? UseCounter::kCredentialManagerGetWithoutUI | 180 ? UseCounter::kCredentialManagerGetWithoutUI |
| 187 : UseCounter::kCredentialManagerGetWithUI); | 181 : UseCounter::kCredentialManagerGetWithUI); |
| 188 | 182 |
| 189 CredentialManagerClient::From(ExecutionContext::From(script_state)) | 183 CredentialManagerClient::From(ExecutionContext::From(script_state)) |
| 190 ->DispatchGet(options.unmediated(), options.password(), providers, | 184 ->DispatchGet(options.unmediated(), options.password(), providers, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 212 ScriptPromise promise = resolver->Promise(); | 206 ScriptPromise promise = resolver->Promise(); |
| 213 if (!CheckBoilerplate(resolver)) | 207 if (!CheckBoilerplate(resolver)) |
| 214 return promise; | 208 return promise; |
| 215 | 209 |
| 216 CredentialManagerClient::From(ExecutionContext::From(script_state)) | 210 CredentialManagerClient::From(ExecutionContext::From(script_state)) |
| 217 ->DispatchRequireUserMediation(new NotificationCallbacks(resolver)); | 211 ->DispatchRequireUserMediation(new NotificationCallbacks(resolver)); |
| 218 return promise; | 212 return promise; |
| 219 } | 213 } |
| 220 | 214 |
| 221 } // namespace blink | 215 } // namespace blink |
| OLD | NEW |