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

Side by Side Diff: third_party/WebKit/Source/platform/exported/WebString.cpp

Issue 2571863003: Add explicit conversions methods for WebString <-> string16 (Closed)
Patch Set: Created 4 years 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 | « content/child/blink_platform_impl.cc ('k') | third_party/WebKit/public/platform/DEPS » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 } 74 }
75 75
76 WebString WebString::fromUTF8(const char* data, size_t length) { 76 WebString WebString::fromUTF8(const char* data, size_t length) {
77 return String::fromUTF8(data, length); 77 return String::fromUTF8(data, length);
78 } 78 }
79 79
80 WebString WebString::fromUTF8(const char* data) { 80 WebString WebString::fromUTF8(const char* data) {
81 return String::fromUTF8(data); 81 return String::fromUTF8(data);
82 } 82 }
83 83
84 WebString WebString::fromUTF16(const base::string16& s) {
85 WebString string;
86 string.assign(s.data(), s.length());
87 return string;
88 }
89
90 WebString WebString::fromUTF16(const base::NullableString16& s) {
91 WebString string;
92 if (s.is_null())
93 string.reset();
94 else
95 string.assign(s.string().data(), s.string().length());
96 return string;
97 }
98
84 std::string WebString::latin1() const { 99 std::string WebString::latin1() const {
85 String string(m_private.get()); 100 String string(m_private.get());
86 101
87 if (string.isEmpty()) 102 if (string.isEmpty())
88 return std::string(); 103 return std::string();
89 104
90 if (string.is8Bit()) 105 if (string.is8Bit())
91 return std::string(reinterpret_cast<const char*>(string.characters8()), 106 return std::string(reinterpret_cast<const char*>(string.characters8()),
92 string.length()); 107 string.length());
93 108
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 172
158 WebString::operator WTF::AtomicString() const { 173 WebString::operator WTF::AtomicString() const {
159 return WTF::AtomicString(m_private.get()); 174 return WTF::AtomicString(m_private.get());
160 } 175 }
161 176
162 void WebString::assign(WTF::StringImpl* p) { 177 void WebString::assign(WTF::StringImpl* p) {
163 m_private = p; 178 m_private = p;
164 } 179 }
165 180
166 } // namespace blink 181 } // namespace blink
OLDNEW
« no previous file with comments | « content/child/blink_platform_impl.cc ('k') | third_party/WebKit/public/platform/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698