| Index: components/html_viewer/blink_basic_type_converters.cc
|
| diff --git a/components/html_viewer/blink_basic_type_converters.cc b/components/html_viewer/blink_basic_type_converters.cc
|
| index f7a5ff470b36c1f311cc43c502fc9cd27cd360e5..70a9b8a04bac21a61d5eaf39b2afc005574e4191 100644
|
| --- a/components/html_viewer/blink_basic_type_converters.cc
|
| +++ b/components/html_viewer/blink_basic_type_converters.cc
|
| @@ -24,6 +24,17 @@ WebString TypeConverter<WebString, String>::Convert(const String& str) {
|
| }
|
|
|
| // static
|
| +WebString TypeConverter<WebString, Array<uint8_t>>::Convert(
|
| + const Array<uint8_t>& input) {
|
| + COMPILE_ASSERT(sizeof(uint8_t) == sizeof(char),
|
| + uint8_t_same_size_as_unsigned_char);
|
| + return input.is_null()
|
| + ? WebString()
|
| + : WebString::fromUTF8(
|
| + reinterpret_cast<const char*>(&input.front()), input.size());
|
| +}
|
| +
|
| +// static
|
| RectPtr TypeConverter<RectPtr, WebRect>::Convert(const WebRect& input) {
|
| RectPtr result(Rect::New());
|
| result->x = input.x;
|
| @@ -34,12 +45,15 @@ RectPtr TypeConverter<RectPtr, WebRect>::Convert(const WebRect& input) {
|
| };
|
|
|
| // static
|
| -Array<uint8_t> TypeConverter<Array<uint8_t>, blink::WebString>::Convert(
|
| - const blink::WebString& input) {
|
| - std::string utf8 = input.utf8();
|
| +Array<uint8_t> TypeConverter<Array<uint8_t>, WebString>::Convert(
|
| + const WebString& input) {
|
| + if (input.isNull())
|
| + return Array<uint8_t>();
|
| + const std::string utf8 = input.utf8();
|
| Array<uint8_t> result(utf8.size());
|
| - for (size_t i = 0; i < utf8.size(); ++i)
|
| - result[i] = utf8[i];
|
| + COMPILE_ASSERT(sizeof(uint8_t) == sizeof(char),
|
| + uint8_t_same_size_as_unsigned_char);
|
| + memcpy(&result.front(), utf8.data(), utf8.size());
|
| return result.Pass();
|
| }
|
|
|
|
|