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

Side by Side Diff: third_party/WebKit/public/platform/WebStringMojoStringTraits.h

Issue 2353003004: Move ViewHostMsg_CreateWindow to mojom (Closed)
Patch Set: . Created 4 years, 2 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 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 WebStringMojoStringTraits_h
6 #define WebStringMojoStringTraits_h
7
8 #include "WebString.h"
9 #include "mojo/public/cpp/bindings/string_traits.h"
10
11 #include <string>
12
13 namespace mojo {
14
15 template <>
16 struct StringTraits<::blink::WebString> {
17 static bool IsNull(const ::blink::WebString& input) { return input.isNull(); }
18
19 static void SetToNull(::blink::WebString* output) { output->reset(); }
20
21 static void* SetUpContext(const ::blink::WebString& input)
22 {
23 return new std::string(input.utf8());
24 }
25
26 static void TearDownContext(const ::blink::WebString& input, void* context)
27 {
28 delete static_cast<std::string*>(context);
29 }
30
31 static size_t GetSize(const ::blink::WebString& input, void* context)
32 {
33 std::string* utf8 = static_cast<std::string*>(context);
34 return utf8->size();
35 }
36
37 static const char* GetData(const ::blink::WebString& input, void* context)
38 {
39 std::string* utf8 = static_cast<std::string*>(context);
40 return utf8->c_str();
41 }
42
43 static bool Read(StringDataView input, ::blink::WebString* output)
44 {
45 output->assign(::blink::WebString::fromUTF8(input.storage(), input.size( )));
46 return true;
47 }
48 };
49
50 } // namespace mojo
51
52 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698