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 "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" | 8 #include "bindings/core/v8/ExceptionState.h" |
9 #include "core/dom/ExceptionCode.h" | 9 #include "core/dom/ExceptionCode.h" |
10 | 10 |
11 namespace blink { | 11 namespace blink { |
12 | 12 |
13 Credential* Credential::create(const String& id, const String& name, const KURL&
avatar) | 13 Credential* Credential::create(const String& id, const String& name, const KURL&
icon) |
14 { | 14 { |
15 return new Credential(id, name, avatar); | 15 return new Credential(id, name, icon); |
16 } | 16 } |
17 | 17 |
18 Credential* Credential::create(const String& id, const String& name, const Strin
g& avatar, ExceptionState& exceptionState) | 18 Credential* Credential::create(const String& id, const String& name, const Strin
g& icon, ExceptionState& exceptionState) |
19 { | 19 { |
20 KURL avatarURL = parseStringAsURL(avatar, exceptionState); | 20 KURL iconURL = parseStringAsURL(icon, exceptionState); |
21 if (exceptionState.hadException()) | 21 if (exceptionState.hadException()) |
22 return nullptr; | 22 return nullptr; |
23 return new Credential(id, name, avatarURL); | 23 return new Credential(id, name, iconURL); |
24 } | 24 } |
25 | 25 |
26 Credential::Credential(PlatformCredential* credential) | 26 Credential::Credential(PlatformCredential* credential) |
27 : m_platformCredential(credential) | 27 : m_platformCredential(credential) |
28 { | 28 { |
29 } | 29 } |
30 | 30 |
31 Credential::Credential(const String& id, const String& name, const KURL& avatar) | 31 Credential::Credential(const String& id, const String& name, const KURL& icon) |
32 : m_platformCredential(PlatformCredential::create(id, name, avatar)) | 32 : m_platformCredential(PlatformCredential::create(id, name, icon)) |
33 { | 33 { |
34 } | 34 } |
35 | 35 |
36 KURL Credential::parseStringAsURL(const String& url, ExceptionState& exceptionSt
ate) | 36 KURL Credential::parseStringAsURL(const String& url, ExceptionState& exceptionSt
ate) |
37 { | 37 { |
38 if (url.isEmpty()) | 38 if (url.isEmpty()) |
39 return KURL(); | 39 return KURL(); |
40 KURL parsedURL = KURL(KURL(), url); | 40 KURL parsedURL = KURL(KURL(), url); |
41 if (!parsedURL.isValid()) | 41 if (!parsedURL.isValid()) |
42 exceptionState.throwDOMException(SyntaxError, "'" + url + "' is not a va
lid URL."); | 42 exceptionState.throwDOMException(SyntaxError, "'" + url + "' is not a va
lid URL."); |
43 return parsedURL; | 43 return parsedURL; |
44 } | 44 } |
45 | 45 |
46 DEFINE_TRACE(Credential) | 46 DEFINE_TRACE(Credential) |
47 { | 47 { |
48 visitor->trace(m_platformCredential); | 48 visitor->trace(m_platformCredential); |
49 } | 49 } |
50 | 50 |
51 } // namespace blink | 51 } // namespace blink |
OLD | NEW |