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
3// found in the LICENSE file.
4
5#ifndef Credential_h
6#define Credential_h
7
8#include "bindings/core/v8/ScriptWrappable.h"
9#include "bindings/core/v8/SerializedScriptValue.h"
10#include "platform/credentialmanager/PlatformCredential.h"
11#include "platform/heap/Handle.h"
12#include "platform/weborigin/KURL.h"
13
14namespace blink {
15
16class WebCredential;
17class ExceptionState;
18
19class Credential : public GarbageCollected<Credential>, public ScriptWrappable {
20    DEFINE_WRAPPERTYPEINFO();
21public:
22    static Credential* create(const String& id, const String& name, const KURL& avatar);
23    static Credential* create(const String& id, const String& name, const String& avatar, ExceptionState&);
24
25    // Credential.idl
26    const String& id() const { return m_platformCredential->id(); }
27    const String& name() const { return m_platformCredential->name(); }
28    const KURL& avatarURL() const { return m_platformCredential->avatarURL(); }
29
30    virtual void trace(Visitor*);
31
32    PlatformCredential* platformCredential() const { return m_platformCredential; }
33
34protected:
35    Credential(PlatformCredential*);
36    Credential(const String& id, const String& name, const KURL& avatar);
37
38    // Parses a string as a KURL. Throws an exception via |exceptionState| if an invalid URL is produced.
39    static KURL parseStringAsURL(const String&, ExceptionState&);
40
41    Member<PlatformCredential> m_platformCredential;
42};
43
44} // namespace blink
45
46#endif // Credential_h
47