Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(344)

Unified Diff: third_party/WebKit/public/platform/WebStringMojoStringTraits.h

Issue 2353003004: Move ViewHostMsg_CreateWindow to mojom (Closed)
Patch Set: . Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698