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