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

Side by Side Diff: Source/modules/credentialmanager/Credential.cpp

Issue 464783003: Credential manager: Convert strings to URLs early. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Feedback. Created 6 years, 4 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 | Annotate | Revision Log
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 "config.h" 5 #include "config.h"
6 #include "modules/credentialmanager/Credential.h" 6 #include "modules/credentialmanager/Credential.h"
7 7
8 #include "bindings/core/v8/ExceptionState.h"
9 #include "core/dom/ExceptionCode.h"
10
8 namespace blink { 11 namespace blink {
9 12
10 Credential* Credential::create(const String& id, const String& name, const Strin g& avatarURL) 13 Credential* Credential::create(const String& id, const String& name, const KURL& avatar)
11 { 14 {
15 return new Credential(id, name, avatar);
16 }
17
18 Credential* Credential::create(const String& id, const String& name, const Strin g& avatar, ExceptionState& exceptionState)
19 {
20 KURL avatarURL = parseStringAsURL(avatar, exceptionState);
21 if (exceptionState.hadException())
22 return nullptr;
12 return new Credential(id, name, avatarURL); 23 return new Credential(id, name, avatarURL);
13 } 24 }
14 25
15 Credential::Credential(PlatformCredential* credential) 26 Credential::Credential(PlatformCredential* credential)
16 : m_platformCredential(credential) 27 : m_platformCredential(credential)
17 { 28 {
18 } 29 }
19 30
20 Credential::Credential(const String& id, const String& name, const String& avata rURL) 31 Credential::Credential(const String& id, const String& name, const KURL& avatar)
21 : m_platformCredential(PlatformCredential::create(id, name, avatarURL)) 32 : m_platformCredential(PlatformCredential::create(id, name, avatar))
22 { 33 {
23 ScriptWrappable::init(this); 34 ScriptWrappable::init(this);
24 } 35 }
25 36
37 KURL Credential::parseStringAsURL(const String& url, ExceptionState& exceptionSt ate)
38 {
39 KURL parsedURL = KURL(KURL(), url);
40 if (!parsedURL.isValid())
41 exceptionState.throwDOMException(SyntaxError, "'" + url + "' is not a va lid URL.");
42 return parsedURL;
43 }
44
26 void Credential::trace(Visitor* visitor) 45 void Credential::trace(Visitor* visitor)
27 { 46 {
28 visitor->trace(m_platformCredential); 47 visitor->trace(m_platformCredential);
29 } 48 }
30 49
31 } // namespace blink 50 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/credentialmanager/Credential.h ('k') | Source/modules/credentialmanager/CredentialsContainer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698