2757472: Reland "Reland "[LSC] Remove base::string16 alias""

2757472
This commit is contained in:
John Kleinschmidt 2021-03-18 15:55:51 -04:00
parent 3b183854ff
commit 2d3c65beca
31 changed files with 200 additions and 152 deletions

View file

@ -7,6 +7,7 @@
#include "base/files/file_path.h"
#include "gin/converter.h"
#include "shell/common/gin_converters/std_converter.h"
namespace gin {

View file

@ -11,6 +11,10 @@
#include "gin/converter.h"
#if defined(OS_WIN)
#include "base/strings/string_util_win.h"
#endif
namespace gin {
// Make it possible to convert move-only types.
@ -182,6 +186,30 @@ struct Converter<std::map<K, V>> {
}
};
#if defined(OS_WIN)
template <>
struct Converter<std::wstring> {
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
const std::wstring& val) {
return Converter<std::u16string>::ToV8(isolate, base::AsString16(val));
}
static bool FromV8(v8::Isolate* isolate,
v8::Local<v8::Value> val,
std::wstring* out) {
if (!val->IsString())
return false;
std::u16string str;
if (Converter<std::u16string>::FromV8(isolate, val, &str)) {
*out = base::AsWString(str);
return true;
} else {
return false;
}
}
};
#endif
} // namespace gin
#endif // SHELL_COMMON_GIN_CONVERTERS_STD_CONVERTER_H_