| Index: third_party/WebKit/public/platform/WebStringMojoStringTraits.h
|
| diff --git a/third_party/WebKit/public/platform/WebStringMojoStringTraits.h b/third_party/WebKit/public/platform/WebStringMojoStringTraits.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..029ac7f52c0f1ca8f556af3526ed3b48a260c929
|
| --- /dev/null
|
| +++ b/third_party/WebKit/public/platform/WebStringMojoStringTraits.h
|
| @@ -0,0 +1,52 @@
|
| +// Copyright 2016 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef WebStringMojoStringTraits_h
|
| +#define WebStringMojoStringTraits_h
|
| +
|
| +#include "WebString.h"
|
| +#include "mojo/public/cpp/bindings/string_traits.h"
|
| +
|
| +#include <string>
|
| +
|
| +namespace mojo {
|
| +
|
| +template <>
|
| +struct StringTraits<::blink::WebString> {
|
| + static bool IsNull(const ::blink::WebString& input) { return input.isNull(); }
|
| +
|
| + static void SetToNull(::blink::WebString* output) { output->reset(); }
|
| +
|
| + static void* SetUpContext(const ::blink::WebString& input)
|
| + {
|
| + return new std::string(input.utf8());
|
| + }
|
| +
|
| + static void TearDownContext(const ::blink::WebString& input, void* context)
|
| + {
|
| + delete static_cast<std::string*>(context);
|
| + }
|
| +
|
| + static size_t GetSize(const ::blink::WebString& input, void* context)
|
| + {
|
| + std::string* utf8 = static_cast<std::string*>(context);
|
| + return utf8->size();
|
| + }
|
| +
|
| + static const char* GetData(const ::blink::WebString& input, void* context)
|
| + {
|
| + std::string* utf8 = static_cast<std::string*>(context);
|
| + return utf8->c_str();
|
| + }
|
| +
|
| + static bool Read(StringDataView input, ::blink::WebString* output)
|
| + {
|
| + output->assign(::blink::WebString::fromUTF8(input.storage(), input.size()));
|
| + return true;
|
| + }
|
| +};
|
| +
|
| +} // namespace mojo
|
| +
|
| +#endif
|
|
|