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

Side by Side Diff: mojo/common/common_type_converters.cc

Issue 562483002: mojo: Create a basic clipboard. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes to the gn files. Created 6 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 unified diff | Download patch
« no previous file with comments | « mojo/common/common_type_converters.h ('k') | mojo/common/common_type_converters_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "mojo/common/common_type_converters.h" 5 #include "mojo/common/common_type_converters.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "url/gurl.h" 10 #include "url/gurl.h"
(...skipping 28 matching lines...) Expand all
39 } 39 }
40 40
41 String TypeConverter<String, GURL>::Convert(const GURL& input) { 41 String TypeConverter<String, GURL>::Convert(const GURL& input) {
42 return String(input.spec()); 42 return String(input.spec());
43 } 43 }
44 44
45 GURL TypeConverter<GURL, String>::Convert(const String& input) { 45 GURL TypeConverter<GURL, String>::Convert(const String& input) {
46 return GURL(input.get()); 46 return GURL(input.get());
47 } 47 }
48 48
49 std::string TypeConverter<std::string, Array<uint8_t> >::Convert(
50 const Array<uint8_t>& input) {
51 if (input.is_null())
52 return std::string();
53
54 return std::string(reinterpret_cast<const char*>(&input.front()),
55 input.size());
56 }
57
58 Array<uint8_t> TypeConverter<Array<uint8_t>, std::string>::Convert(
59 const std::string& input) {
60 Array<uint8_t> result(input.size());
61 memcpy(&result.front(), input.c_str(), input.size());
62 return result.Pass();
63 }
64
49 } // namespace mojo 65 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/common/common_type_converters.h ('k') | mojo/common/common_type_converters_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698