Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(422)

Side by Side Diff: third_party/WebKit/Source/modules/credentialmanager/FederatedCredential.cpp

Issue 1745963002: CREDENTIAL: Do type checks for credential constructors. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/FederatedCredential.h" 5 #include "modules/credentialmanager/FederatedCredential.h"
6 6
7 #include "bindings/core/v8/ExceptionState.h" 7 #include "bindings/core/v8/ExceptionState.h"
8 #include "modules/credentialmanager/FederatedCredentialData.h" 8 #include "modules/credentialmanager/FederatedCredentialData.h"
9 #include "platform/credentialmanager/PlatformFederatedCredential.h" 9 #include "platform/credentialmanager/PlatformFederatedCredential.h"
10 #include "platform/weborigin/SecurityOrigin.h" 10 #include "platform/weborigin/SecurityOrigin.h"
11 #include "public/platform/WebFederatedCredential.h" 11 #include "public/platform/WebFederatedCredential.h"
12 12
13 namespace blink { 13 namespace blink {
14 14
15 FederatedCredential* FederatedCredential::create(WebFederatedCredential* webFede ratedCredential) 15 FederatedCredential* FederatedCredential::create(WebFederatedCredential* webFede ratedCredential)
16 { 16 {
17 return new FederatedCredential(webFederatedCredential); 17 return new FederatedCredential(webFederatedCredential);
18 } 18 }
19 19
20 FederatedCredential* FederatedCredential::create(const FederatedCredentialData& data, ExceptionState& exceptionState) 20 FederatedCredential* FederatedCredential::create(const FederatedCredentialData& data, ExceptionState& exceptionState)
21 { 21 {
22 if (data.id().isEmpty()) {
23 exceptionState.throwTypeError("'id' must not be empty.");
24 return nullptr;
25 }
26 if (data.provider().isEmpty()) {
27 exceptionState.throwTypeError("'provider' must not be empty.");
28 return nullptr;
29 }
30
22 KURL iconURL = parseStringAsURL(data.iconURL(), exceptionState); 31 KURL iconURL = parseStringAsURL(data.iconURL(), exceptionState);
23 KURL providerURL = parseStringAsURL(data.provider(), exceptionState); 32 KURL providerURL = parseStringAsURL(data.provider(), exceptionState);
24 if (exceptionState.hadException()) 33 if (exceptionState.hadException())
25 return nullptr; 34 return nullptr;
26 return new FederatedCredential(data.id(), providerURL, data.name(), iconURL) ; 35 return new FederatedCredential(data.id(), providerURL, data.name(), iconURL) ;
27 } 36 }
28 37
29 FederatedCredential::FederatedCredential(WebFederatedCredential* webFederatedCre dential) 38 FederatedCredential::FederatedCredential(WebFederatedCredential* webFederatedCre dential)
30 : Credential(webFederatedCredential->platformCredential()) 39 : Credential(webFederatedCredential->platformCredential())
31 { 40 {
32 } 41 }
33 42
34 FederatedCredential::FederatedCredential(const String& id, const KURL& provider, const String& name, const KURL& icon) 43 FederatedCredential::FederatedCredential(const String& id, const KURL& provider, const String& name, const KURL& icon)
35 : Credential(PlatformFederatedCredential::create(id, SecurityOrigin::create( provider), name, icon)) 44 : Credential(PlatformFederatedCredential::create(id, SecurityOrigin::create( provider), name, icon))
36 { 45 {
37 } 46 }
38 47
39 const String FederatedCredential::provider() const 48 const String FederatedCredential::provider() const
40 { 49 {
41 return static_cast<PlatformFederatedCredential*>(m_platformCredential.get()) ->provider()->toString(); 50 return static_cast<PlatformFederatedCredential*>(m_platformCredential.get()) ->provider()->toString();
42 } 51 }
43 52
44 } // namespace blink 53 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698