| Index: Source/core/page/DOMWindowBase64.cpp
|
| diff --git a/Source/modules/webmidi/MIDIOutput.cpp b/Source/core/page/DOMWindowBase64.cpp
|
| similarity index 62%
|
| copy from Source/modules/webmidi/MIDIOutput.cpp
|
| copy to Source/core/page/DOMWindowBase64.cpp
|
| index e9066f0561fc600d24a8c1dd0fe59623522c6950..736668c68d29d8c5a344421d1aa205a5e68efdd2 100644
|
| --- a/Source/modules/webmidi/MIDIOutput.cpp
|
| +++ b/Source/core/page/DOMWindowBase64.cpp
|
| @@ -1,5 +1,7 @@
|
| /*
|
| - * Copyright (C) 2013 Google Inc. All rights reserved.
|
| + * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved.
|
| + * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
|
| + * Copyright (C) 2013 Samsung Electronics. All rights reserved.
|
| *
|
| * Redistribution and use in source and binary forms, with or without
|
| * modification, are permitted provided that the following conditions are
|
| @@ -29,32 +31,46 @@
|
| */
|
|
|
| #include "config.h"
|
| -#include "modules/webmidi/MIDIOutput.h"
|
| +#include "core/page/DOMWindowBase64.h"
|
| +
|
| +#include "wtf/text/Base64.h"
|
|
|
| namespace WebCore {
|
|
|
| -PassRefPtr<MIDIOutput> MIDIOutput::create(ScriptExecutionContext* context, const String& id, const String& manufacturer, const String& name, const String& version)
|
| -{
|
| - return adoptRef(new MIDIOutput(context, id, manufacturer, name, version));
|
| -}
|
| +namespace DOMWindowBase64 {
|
|
|
| -MIDIOutput::MIDIOutput(ScriptExecutionContext* context, const String& id, const String& manufacturer, const String& name, const String& version)
|
| - : MIDIPort(context, id, manufacturer, name, MIDIPortTypeOutput, version)
|
| +String btoa(void*, const String& stringToEncode, ExceptionCode& ec)
|
| {
|
| - ScriptWrappable::init(this);
|
| -}
|
| + if (stringToEncode.isNull())
|
| + return String();
|
|
|
| -void MIDIOutput::send(Uint8Array* data, double timestamp)
|
| -{
|
| - // FIXME: Implement MIDI protocol validation here. System exclusive
|
| - // messages must be checked at the same time.
|
| - // Actual sending operation will be implemented in core/platform/midi.
|
| + if (!stringToEncode.containsOnlyLatin1()) {
|
| + ec = InvalidCharacterError;
|
| + return String();
|
| + }
|
| +
|
| + return base64Encode(stringToEncode.latin1());
|
| }
|
|
|
| -void MIDIOutput::send(Vector<unsigned>, double timestamp)
|
| +String atob(void*, const String& encodedString, ExceptionCode& ec)
|
| {
|
| - // FIXME: Ditto. Implementation will be shared between these two send
|
| - // functions.
|
| + if (encodedString.isNull())
|
| + return String();
|
| +
|
| + if (!encodedString.containsOnlyLatin1()) {
|
| + ec = InvalidCharacterError;
|
| + return String();
|
| + }
|
| +
|
| + Vector<char> out;
|
| + if (!base64Decode(encodedString, out, Base64FailOnInvalidCharacter)) {
|
| + ec = InvalidCharacterError;
|
| + return String();
|
| + }
|
| +
|
| + return String(out.data(), out.size());
|
| }
|
|
|
| +} // namespace DOMWindowBase64
|
| +
|
| } // namespace WebCore
|
|
|