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#include "config.h" 6#include "modules/credentialmanager/LocalCredential.h" 7 8#include "bindings/core/v8/ExceptionState.h" 9#include "platform/credentialmanager/PlatformLocalCredential.h" 10#include "public/platform/WebCredential.h" 11#include "public/platform/WebLocalCredential.h" 12 13namespace blink { 14 15LocalCredential* LocalCredential::create(WebLocalCredential* webLocalCredential) 16{ 17 return new LocalCredential(webLocalCredential); 18} 19 20LocalCredential* LocalCredential::create(const String& id, const String& name, const String& avatar, const String& password, ExceptionState& exceptionState) 21{ 22 KURL avatarURL = parseStringAsURL(avatar, exceptionState); 23 if (exceptionState.hadException()) 24 return nullptr; 25 return new LocalCredential(id, name, avatarURL, password); 26} 27 28LocalCredential::LocalCredential(WebLocalCredential* webLocalCredential) 29 : Credential(webLocalCredential->platformCredential()) 30{ 31} 32 33LocalCredential::LocalCredential(const String& id, const String& name, const KURL& avatar, const String& password) 34 : Credential(PlatformLocalCredential::create(id, name, avatar, password)) 35{ 36} 37 38const String& LocalCredential::password() const 39{ 40 return static_cast<PlatformLocalCredential*>(m_platformCredential.get())->password(); 41} 42 43} // namespace blink 44