0

Work toward getting components_unittests building with u16string.

Bug: 911896
Change-Id: I08a9c5d20ca82094da0297f80388651c9643afb2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2653738
Commit-Queue: Maxim Kolosovskiy  <kolos@chromium.org>
Reviewed-by: Maxim Kolosovskiy  <kolos@chromium.org>
Reviewed-by: Jeremy Roman <jbroman@chromium.org>
Reviewed-by: Alan Screen <awscreen@chromium.org>
Reviewed-by: Rebekah Potter <rbpotter@chromium.org>
Reviewed-by: Marijn Kruisselbrink <mek@chromium.org>
Reviewed-by: Ken Rockot <rockot@google.com>
Reviewed-by: Alex Gough <ajgo@chromium.org>
Reviewed-by: Yutaka Hirano <yhirano@chromium.org>
Reviewed-by: Roger Tawa <rogerta@chromium.org>
Auto-Submit: Peter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#849564}
This commit is contained in:
Peter Kasting
2021-02-02 13:01:34 +00:00
committed by Chromium LUCI CQ
parent 9a43dec462
commit 3c73bbc147
25 changed files with 104 additions and 96 deletions

@ -290,7 +290,7 @@ class FormAutofillTest : public ChromeRenderViewTest {
// Autofill uses the system font to render suggestion previews. On Windows // Autofill uses the system font to render suggestion previews. On Windows
// an extra step is required to ensure that the system font is configured. // an extra step is required to ensure that the system font is configured.
blink::WebFontRendering::SetMenuFontMetrics( blink::WebFontRendering::SetMenuFontMetrics(
base::ASCIIToUTF16("Arial").c_str(), 12); blink::WebString::FromASCII("Arial"), 12);
} }
#endif #endif

@ -323,7 +323,7 @@ class PasswordAutofillAgentTest : public ChromeRenderViewTest {
// Autofill uses the system font to render suggestion previews. On Windows // Autofill uses the system font to render suggestion previews. On Windows
// an extra step is required to ensure that the system font is configured. // an extra step is required to ensure that the system font is configured.
blink::WebFontRendering::SetMenuFontMetrics( blink::WebFontRendering::SetMenuFontMetrics(
base::ASCIIToUTF16("Arial").c_str(), 12); blink::WebString::FromASCII("Arial"), 12);
#endif #endif
// TODO(crbug/862989): Remove workaround preventing non-test classes to bind // TODO(crbug/862989): Remove workaround preventing non-test classes to bind

@ -71,11 +71,11 @@ class PrintSystemWatcherWin : public base::win::ObjectWatcher::Delegate {
delegate_ = delegate; delegate_ = delegate;
// An empty printer name means watch the current server, we need to pass // An empty printer name means watch the current server, we need to pass
// nullptr to OpenPrinterWithName(). // nullptr to OpenPrinterWithName().
LPTSTR printer_name_to_use = nullptr; base::char16* printer_name_to_use = nullptr;
std::wstring printer_name_wide; base::string16 printer_name_16;
if (!printer_name.empty()) { if (!printer_name.empty()) {
printer_name_wide = base::UTF8ToWide(printer_name); printer_name_16 = base::UTF8ToUTF16(printer_name);
printer_name_to_use = const_cast<LPTSTR>(printer_name_wide.c_str()); printer_name_to_use = const_cast<base::char16*>(printer_name_16.c_str());
} }
bool ret = false; bool ret = false;
if (printer_.OpenPrinterWithName(printer_name_to_use)) { if (printer_.OpenPrinterWithName(printer_name_to_use)) {
@ -688,8 +688,8 @@ bool PrintSystemWin::GetJobDetails(const std::string& printer_name,
print_backend_->GetPrinterDriverInfo(printer_name)); print_backend_->GetPrinterDriverInfo(printer_name));
DCHECK(job_details); DCHECK(job_details);
printing::ScopedPrinterHandle printer_handle; printing::ScopedPrinterHandle printer_handle;
std::wstring printer_name_wide = base::UTF8ToWide(printer_name); base::string16 printer_name_16 = base::UTF8ToUTF16(printer_name);
printer_handle.OpenPrinterWithName(printer_name_wide.c_str()); printer_handle.OpenPrinterWithName(printer_name_16.c_str());
DCHECK(printer_handle.IsValid()); DCHECK(printer_handle.IsValid());
bool ret = false; bool ret = false;
if (printer_handle.IsValid()) { if (printer_handle.IsValid()) {

@ -352,8 +352,7 @@ class MidiManagerWin::InPort final : public Port {
caps.wMid, caps.wMid,
caps.wPid, caps.wPid,
caps.vDriverVersion, caps.vDriverVersion,
base::WideToUTF8( base::WideToUTF8(std::wstring(caps.szPname, wcslen(caps.szPname))),
base::string16(caps.szPname, wcslen(caps.szPname))),
caps.ManufacturerGuid), caps.ManufacturerGuid),
manager_(manager), manager_(manager),
in_handle_(kInvalidInHandle), in_handle_(kInvalidInHandle),
@ -471,8 +470,7 @@ class MidiManagerWin::OutPort final : public Port {
caps.wMid, caps.wMid,
caps.wPid, caps.wPid,
caps.vDriverVersion, caps.vDriverVersion,
base::WideToUTF8( base::WideToUTF8(std::wstring(caps.szPname, wcslen(caps.szPname))),
base::string16(caps.szPname, wcslen(caps.szPname))),
caps.ManufacturerGuid), caps.ManufacturerGuid),
software_(caps.wTechnology == MOD_SWSYNTH), software_(caps.wTechnology == MOD_SWSYNTH),
out_handle_(kInvalidOutHandle) {} out_handle_(kInvalidOutHandle) {}

@ -143,7 +143,7 @@ void GetDevPropString(DEVINST handle,
if (cr != CR_SUCCESS) if (cr != CR_SUCCESS)
VLOG(1) << "CM_Get_DevNode_Property failed: CONFIGRET 0x" << std::hex << cr; VLOG(1) << "CM_Get_DevNode_Property failed: CONFIGRET 0x" << std::hex << cr;
else else
*out = base::WideToUTF8(reinterpret_cast<base::char16*>(buffer.get())); *out = base::WideToUTF8(reinterpret_cast<wchar_t*>(buffer.get()));
} }
// Retrieves manufacturer (provider) and version information of underlying // Retrieves manufacturer (provider) and version information of underlying
@ -163,7 +163,7 @@ void GetDevPropString(DEVINST handle,
void GetDriverInfoFromDeviceId(const std::string& dev_id, void GetDriverInfoFromDeviceId(const std::string& dev_id,
std::string* out_manufacturer, std::string* out_manufacturer,
std::string* out_driver_version) { std::string* out_driver_version) {
base::string16 dev_instance_id = std::wstring dev_instance_id =
base::UTF8ToWide(dev_id.substr(4, dev_id.size() - 43)); base::UTF8ToWide(dev_id.substr(4, dev_id.size() - 43));
base::ReplaceChars(dev_instance_id, L"#", L"\\", &dev_instance_id); base::ReplaceChars(dev_instance_id, L"#", L"\\", &dev_instance_id);
@ -208,7 +208,7 @@ struct MidiPort {
template <typename InterfaceType, template <typename InterfaceType,
typename RuntimeType, typename RuntimeType,
typename StaticsInterfaceType, typename StaticsInterfaceType,
base::char16 const* runtime_class_id> wchar_t const* runtime_class_id>
class MidiManagerWinrt::MidiPortManager { class MidiManagerWinrt::MidiPortManager {
public: public:
// MidiPortManager instances should be constructed on the kComTaskRunner. // MidiPortManager instances should be constructed on the kComTaskRunner.

@ -15,6 +15,7 @@
#include "base/numerics/safe_conversions.h" #include "base/numerics/safe_conversions.h"
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "base/strings/string_piece.h" #include "base/strings/string_piece.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/threading/scoped_blocking_call.h" #include "base/threading/scoped_blocking_call.h"
#include "base/win/scoped_bstr.h" #include "base/win/scoped_bstr.h"
@ -30,7 +31,7 @@ namespace {
ScopedPrinterHandle GetPrinterHandle(const std::string& printer_name) { ScopedPrinterHandle GetPrinterHandle(const std::string& printer_name) {
ScopedPrinterHandle handle; ScopedPrinterHandle handle;
handle.OpenPrinterWithName(base::UTF8ToWide(printer_name).c_str()); handle.OpenPrinterWithName(base::UTF8ToUTF16(printer_name).c_str());
return handle; return handle;
} }
@ -104,7 +105,7 @@ void LoadPaper(const wchar_t* printer,
paper.size_um.SetSize(sizes[i].x * kToUm, sizes[i].y * kToUm); paper.size_um.SetSize(sizes[i].x * kToUm, sizes[i].y * kToUm);
if (!names.empty()) { if (!names.empty()) {
const wchar_t* name_start = names[i].chars; const wchar_t* name_start = names[i].chars;
base::string16 tmp_name(name_start, kMaxPaperName); std::wstring tmp_name(name_start, kMaxPaperName);
// Trim trailing zeros. // Trim trailing zeros.
tmp_name = tmp_name.c_str(); tmp_name = tmp_name.c_str();
paper.display_name = base::WideToUTF8(tmp_name); paper.display_name = base::WideToUTF8(tmp_name);
@ -211,7 +212,8 @@ bool PrintBackendWin::EnumeratePrinters(PrinterList* printer_list) {
for (DWORD index = 0; index < count_returned; index++) { for (DWORD index = 0; index < count_returned; index++) {
ScopedPrinterHandle printer; ScopedPrinterHandle printer;
PrinterBasicInfo info; PrinterBasicInfo info;
if (printer.OpenPrinterWithName(printer_info[index].pPrinterName) && if (printer.OpenPrinterWithName(
base::as_u16cstr(printer_info[index].pPrinterName)) &&
InitBasicPrinterInfo(printer.Get(), &info)) { InitBasicPrinterInfo(printer.Get(), &info)) {
info.is_default = (info.printer_name == default_printer); info.is_default = (info.printer_name == default_printer);
printer_list->push_back(info); printer_list->push_back(info);
@ -330,8 +332,8 @@ bool PrintBackendWin::GetPrinterCapsAndDefaults(
return false; return false;
HPTPROVIDER provider = nullptr; HPTPROVIDER provider = nullptr;
std::wstring printer_name_wide = base::UTF8ToWide(printer_name); base::string16 printer_name_16 = base::UTF8ToUTF16(printer_name);
HRESULT hr = XPSModule::OpenProvider(printer_name_wide, 1, &provider); HRESULT hr = XPSModule::OpenProvider(printer_name_16, 1, &provider);
if (!provider) if (!provider)
return true; return true;
@ -353,7 +355,7 @@ bool PrintBackendWin::GetPrinterCapsAndDefaults(
printer_info->caps_mime_type = "text/xml"; printer_info->caps_mime_type = "text/xml";
} }
ScopedPrinterHandle printer_handle; ScopedPrinterHandle printer_handle;
if (printer_handle.OpenPrinterWithName(printer_name_wide.c_str())) { if (printer_handle.OpenPrinterWithName(printer_name_16.c_str())) {
std::unique_ptr<DEVMODE, base::FreeDeleter> devmode_out( std::unique_ptr<DEVMODE, base::FreeDeleter> devmode_out(
CreateDevMode(printer_handle.Get(), nullptr)); CreateDevMode(printer_handle.Get(), nullptr));
if (!devmode_out) if (!devmode_out)

@ -145,10 +145,11 @@ bool PrinterChangeHandleTraits::CloseHandle(HANDLE handle) {
return true; return true;
} }
bool ScopedPrinterHandle::OpenPrinterWithName(const wchar_t* printer) { bool ScopedPrinterHandle::OpenPrinterWithName(const base::char16* printer) {
HANDLE temp_handle; HANDLE temp_handle;
// ::OpenPrinter may return error but assign some value into handle. // ::OpenPrinter may return error but assign some value into handle.
if (::OpenPrinter(const_cast<LPTSTR>(printer), &temp_handle, nullptr)) { if (::OpenPrinter(const_cast<LPTSTR>(base::as_wcstr(printer)), &temp_handle,
nullptr)) {
Set(temp_handle); Set(temp_handle);
} }
return IsValid(); return IsValid();
@ -216,7 +217,7 @@ HRESULT XPSModule::OpenProvider(const base::string16& printer_name,
HPTPROVIDER* provider) { HPTPROVIDER* provider) {
base::ScopedBlockingCall scoped_blocking_call(FROM_HERE, base::ScopedBlockingCall scoped_blocking_call(FROM_HERE,
base::BlockingType::MAY_BLOCK); base::BlockingType::MAY_BLOCK);
return g_open_provider_proc(printer_name.c_str(), version, provider); return g_open_provider_proc(base::as_wcstr(printer_name), version, provider);
} }
HRESULT XPSModule::GetPrintCapabilities(HPTPROVIDER provider, HRESULT XPSModule::GetPrintCapabilities(HPTPROVIDER provider,
@ -409,9 +410,9 @@ std::string GetDriverInfo(HANDLE printer) {
FileVersionInfo::CreateFileVersionInfo( FileVersionInfo::CreateFileVersionInfo(
base::FilePath(info_6.get()->pDriverPath))); base::FilePath(info_6.get()->pDriverPath)));
if (version_info.get()) { if (version_info.get()) {
info[1] = base::WideToUTF8(version_info->file_version()); info[1] = base::UTF16ToUTF8(version_info->file_version());
info[2] = base::WideToUTF8(version_info->product_name()); info[2] = base::UTF16ToUTF8(version_info->product_name());
info[3] = base::WideToUTF8(version_info->product_version()); info[3] = base::UTF16ToUTF8(version_info->product_version());
} }
} }
@ -573,7 +574,8 @@ std::unique_ptr<DEVMODE, base::FreeDeleter> PromptDevMode(
DEVMODE* in, DEVMODE* in,
HWND window, HWND window,
bool* canceled) { bool* canceled) {
wchar_t* printer_name_ptr = const_cast<wchar_t*>(printer_name.c_str()); wchar_t* printer_name_ptr =
const_cast<wchar_t*>(base::as_wcstr(printer_name));
LONG buffer_size = DocumentProperties(window, printer, printer_name_ptr, LONG buffer_size = DocumentProperties(window, printer, printer_name_ptr,
nullptr, nullptr, 0); nullptr, nullptr, 0);
if (buffer_size < static_cast<int>(sizeof(DEVMODE))) if (buffer_size < static_cast<int>(sizeof(DEVMODE)))

@ -48,7 +48,7 @@ class PRINTING_EXPORT ScopedPrinterHandle
: public base::win::GenericScopedHandle<PrinterHandleTraits, : public base::win::GenericScopedHandle<PrinterHandleTraits,
base::win::DummyVerifierTraits> { base::win::DummyVerifierTraits> {
public: public:
bool OpenPrinterWithName(const wchar_t* printer); bool OpenPrinterWithName(const base::char16* printer);
}; };
class PRINTING_EXPORT PrinterChangeHandleTraits { class PRINTING_EXPORT PrinterChangeHandleTraits {

@ -258,7 +258,7 @@ base::FilePath PrintedDocument::CreateDebugDumpPath(
filename += document_name; filename += document_name;
base::FilePath::StringType system_filename; base::FilePath::StringType system_filename;
#if defined(OS_WIN) #if defined(OS_WIN)
system_filename = filename; system_filename = base::UTF16ToWide(filename);
#else // OS_WIN #else // OS_WIN
system_filename = base::UTF16ToUTF8(filename); system_filename = base::UTF16ToUTF8(filename);
#endif // OS_WIN #endif // OS_WIN

@ -8,6 +8,7 @@
#include "base/auto_reset.h" #include "base/auto_reset.h"
#include "base/stl_util.h" #include "base/stl_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/current_thread.h" #include "base/task/current_thread.h"
#include "printing/backend/win_helper.h" #include "printing/backend/win_helper.h"
#include "printing/print_settings_initializer_win.h" #include "printing/print_settings_initializer_win.h"
@ -133,7 +134,7 @@ bool PrintingContextSystemDialogWin::InitializeSettingsWithRanges(
} }
settings_->set_ranges(ranges_vector); settings_->set_ranges(ranges_vector);
settings_->set_device_name(new_device_name); settings_->set_device_name(base::WideToUTF16(new_device_name));
settings_->set_selection_only(selection_only); settings_->set_selection_only(selection_only);
PrintSettingsInitializerWin::InitPrintSettings(context(), dev_mode, PrintSettingsInitializerWin::InitPrintSettings(context(), dev_mode,
settings_.get()); settings_.get());

@ -79,7 +79,7 @@ PrintingContext::Result PrintingContextWin::UseDefaultSettings() {
scoped_refptr<PrintBackend> backend = scoped_refptr<PrintBackend> backend =
PrintBackend::CreateInstance(delegate_->GetAppLocale()); PrintBackend::CreateInstance(delegate_->GetAppLocale());
base::string16 default_printer = base::string16 default_printer =
base::UTF8ToWide(backend->GetDefaultPrinterName()); base::UTF8ToUTF16(backend->GetDefaultPrinterName());
if (!default_printer.empty()) { if (!default_printer.empty()) {
ScopedPrinterHandle printer; ScopedPrinterHandle printer;
if (printer.OpenPrinterWithName(default_printer.c_str())) { if (printer.OpenPrinterWithName(default_printer.c_str())) {
@ -110,11 +110,13 @@ PrintingContext::Result PrintingContextWin::UseDefaultSettings() {
const PRINTER_INFO_2* info_2_end = info_2 + count_returned; const PRINTER_INFO_2* info_2_end = info_2 + count_returned;
for (; info_2 < info_2_end; ++info_2) { for (; info_2 < info_2_end; ++info_2) {
ScopedPrinterHandle printer; ScopedPrinterHandle printer;
if (!printer.OpenPrinterWithName(info_2->pPrinterName)) if (!printer.OpenPrinterWithName(
base::as_u16cstr(info_2->pPrinterName)))
continue; continue;
std::unique_ptr<DEVMODE, base::FreeDeleter> dev_mode = std::unique_ptr<DEVMODE, base::FreeDeleter> dev_mode =
CreateDevMode(printer.Get(), nullptr); CreateDevMode(printer.Get(), nullptr);
if (InitializeSettings(info_2->pPrinterName, dev_mode.get()) == OK) if (InitializeSettings(base::as_u16cstr(info_2->pPrinterName),
dev_mode.get()) == OK)
return OK; return OK;
} }
if (context_) if (context_)
@ -289,7 +291,7 @@ PrintingContext::Result PrintingContextWin::NewDocument(
DCHECK(SimplifyDocumentTitle(document_name) == document_name); DCHECK(SimplifyDocumentTitle(document_name) == document_name);
DOCINFO di = {sizeof(DOCINFO)}; DOCINFO di = {sizeof(DOCINFO)};
di.lpszDocName = document_name.c_str(); di.lpszDocName = base::as_wcstr(document_name);
// Is there a debug dump directory specified? If so, force to print to a file. // Is there a debug dump directory specified? If so, force to print to a file.
if (PrintedDocument::HasDebugDumpPath()) { if (PrintedDocument::HasDebugDumpPath()) {
@ -378,7 +380,7 @@ BOOL PrintingContextWin::AbortProc(HDC hdc, int nCode) {
} }
PrintingContext::Result PrintingContextWin::InitializeSettings( PrintingContext::Result PrintingContextWin::InitializeSettings(
const std::wstring& device_name, const base::string16& device_name,
DEVMODE* dev_mode) { DEVMODE* dev_mode) {
if (!dev_mode) if (!dev_mode)
return OnError(); return OnError();

@ -39,14 +39,14 @@ const wchar_t kHKLMAccessProviders[] =
L"System\\CurrentControlSet\\Control\\Lsa\\AccessProviders"; L"System\\CurrentControlSet\\Control\\Lsa\\AccessProviders";
struct RegistryValue { struct RegistryValue {
base::string16 name; std::wstring name;
DWORD type; DWORD type;
std::vector<uint8_t> data; std::vector<uint8_t> data;
}; };
struct RegistryKeyData { struct RegistryKeyData {
std::vector<RegistryValue> values; std::vector<RegistryValue> values;
std::map<base::string16, RegistryKeyData> keys; std::map<std::wstring, RegistryKeyData> keys;
}; };
void ReadRegistryTree(const base::win::RegKey& src, RegistryKeyData* data) { void ReadRegistryTree(const base::win::RegKey& src, RegistryKeyData* data) {
@ -69,7 +69,7 @@ void ReadRegistryTree(const base::win::RegKey& src, RegistryKeyData* data) {
for (base::win::RegistryKeyIterator i(src.Handle(), L""); for (base::win::RegistryKeyIterator i(src.Handle(), L"");
i.Valid(); ++i) { i.Valid(); ++i) {
ReadRegistryTree(base::win::RegKey(src.Handle(), i.Name(), KEY_READ), ReadRegistryTree(base::win::RegKey(src.Handle(), i.Name(), KEY_READ),
&data->keys[base::string16(i.Name())]); &data->keys[std::wstring(i.Name())]);
} }
} }

@ -10,6 +10,7 @@
#include "base/stl_util.h" #include "base/stl_util.h"
#include "base/strings/string16.h" #include "base/strings/string16.h"
#include "base/strings/utf_string_conversions.h"
#include "rlz/lib/assert.h" #include "rlz/lib/assert.h"
namespace rlz_lib { namespace rlz_lib {
@ -69,14 +70,14 @@ bool GetComputerSid(const wchar_t* account_name, SID* sid, DWORD sid_size) {
return success != FALSE; return success != FALSE;
} }
std::wstring ConvertSidToString(SID* sid) { base::string16 ConvertSidToString(SID* sid) {
std::wstring sid_string; std::wstring sid_string;
wchar_t* sid_buffer = NULL; wchar_t* sid_buffer = NULL;
if (ConvertSidToStringSidW(sid, &sid_buffer)) { if (ConvertSidToStringSidW(sid, &sid_buffer)) {
sid_string = sid_buffer; sid_string = sid_buffer;
LocalFree(sid_buffer); LocalFree(sid_buffer);
} }
return sid_string; return base::WideToUTF16(sid_string);
} }
} // namespace } // namespace

@ -48,7 +48,7 @@ HRESULT GetElevationType(PTOKEN_ELEVATION_TYPE elevation) {
namespace rlz_lib { namespace rlz_lib {
bool ProcessInfo::IsRunningAsSystem() { bool ProcessInfo::IsRunningAsSystem() {
static base::string16 user_sid; static std::wstring user_sid;
if (user_sid.empty()) { if (user_sid.empty()) {
if (!base::win::GetUserSidString(&user_sid)) if (!base::win::GetUserSidString(&user_sid))
return false; return false;

@ -40,7 +40,7 @@ bool RegKeyReadValue(const base::win::RegKey& key, const wchar_t* name,
bool RegKeyWriteValue(base::win::RegKey* key, const wchar_t* name, bool RegKeyWriteValue(base::win::RegKey* key, const wchar_t* name,
const char* value) { const char* value) {
base::string16 value_string(base::ASCIIToUTF16(value)); std::wstring value_string(base::ASCIIToWide(value));
return key->WriteValue(name, value_string.c_str()) == ERROR_SUCCESS; return key->WriteValue(name, value_string.c_str()) == ERROR_SUCCESS;
} }

@ -14,8 +14,6 @@
#include "rlz/lib/supplementary_branding.h" #include "rlz/lib/supplementary_branding.h"
#include "rlz/win/lib/registry_util.h" #include "rlz/win/lib/registry_util.h"
using base::ASCIIToUTF16;
namespace rlz_lib { namespace rlz_lib {
namespace { namespace {
@ -48,7 +46,7 @@ const char kStatefulEventsSubkeyName[] = "StatefulEvents";
const char kPingTimesSubkeyName[] = "PTimes"; const char kPingTimesSubkeyName[] = "PTimes";
std::wstring GetWideProductName(Product product) { std::wstring GetWideProductName(Product product) {
return ASCIIToUTF16(GetProductName(product)); return base::ASCIIToWide(GetProductName(product));
} }
void AppendBrandToString(std::string* str) { void AppendBrandToString(std::string* str) {
@ -62,13 +60,13 @@ bool GetRegKey(const char* name, REGSAM access, base::win::RegKey* key) {
std::string key_location; std::string key_location;
base::StringAppendF(&key_location, "%s\\%s", kLibKeyName, name); base::StringAppendF(&key_location, "%s\\%s", kLibKeyName, name);
AppendBrandToString(&key_location); AppendBrandToString(&key_location);
base::string16 key_location16 = ASCIIToUTF16(key_location); std::wstring key_locationw = base::ASCIIToWide(key_location);
LONG ret; LONG ret;
if (access & (KEY_SET_VALUE | KEY_CREATE_SUB_KEY | KEY_CREATE_LINK)) if (access & (KEY_SET_VALUE | KEY_CREATE_SUB_KEY | KEY_CREATE_LINK))
ret = key->Create(HKEY_CURRENT_USER, key_location16.c_str(), access); ret = key->Create(HKEY_CURRENT_USER, key_locationw.c_str(), access);
else else
ret = key->Open(HKEY_CURRENT_USER, key_location16.c_str(), access); ret = key->Open(HKEY_CURRENT_USER, key_locationw.c_str(), access);
return ret == ERROR_SUCCESS; return ret == ERROR_SUCCESS;
} }
@ -92,13 +90,13 @@ bool GetEventsRegKey(const char* event_type,
base::StringAppendF(&key_location, "\\%s", product_name.c_str()); base::StringAppendF(&key_location, "\\%s", product_name.c_str());
} }
base::string16 key_location16 = ASCIIToUTF16(key_location); std::wstring key_locationw = base::ASCIIToWide(key_location);
LONG ret; LONG ret;
if (access & (KEY_SET_VALUE | KEY_CREATE_SUB_KEY | KEY_CREATE_LINK)) if (access & (KEY_SET_VALUE | KEY_CREATE_SUB_KEY | KEY_CREATE_LINK))
ret = key->Create(HKEY_CURRENT_USER, key_location16.c_str(), access); ret = key->Create(HKEY_CURRENT_USER, key_locationw.c_str(), access);
else else
ret = key->Open(HKEY_CURRENT_USER, key_location16.c_str(), access); ret = key->Open(HKEY_CURRENT_USER, key_locationw.c_str(), access);
return ret == ERROR_SUCCESS; return ret == ERROR_SUCCESS;
} }
@ -155,7 +153,7 @@ bool DeleteKeyIfEmpty(HKEY root_key, const wchar_t* key_name) {
// static // static
std::wstring RlzValueStoreRegistry::GetWideLibKeyName() { std::wstring RlzValueStoreRegistry::GetWideLibKeyName() {
return ASCIIToUTF16(kLibKeyName); return base::ASCIIToWide(kLibKeyName);
} }
bool RlzValueStoreRegistry::HasAccess(AccessType type) { bool RlzValueStoreRegistry::HasAccess(AccessType type) {
@ -202,11 +200,11 @@ bool RlzValueStoreRegistry::WriteAccessPointRlz(AccessPoint access_point,
if (!access_point_name) if (!access_point_name)
return false; return false;
base::string16 access_point_name16(ASCIIToUTF16(access_point_name)); std::wstring access_point_namew(base::ASCIIToWide(access_point_name));
base::win::RegKey key; base::win::RegKey key;
GetAccessPointRlzsRegKey(KEY_WRITE, &key); GetAccessPointRlzsRegKey(KEY_WRITE, &key);
if (!RegKeyWriteValue(&key, access_point_name16.c_str(), new_rlz)) { if (!RegKeyWriteValue(&key, access_point_namew.c_str(), new_rlz)) {
ASSERT_STRING("SetAccessPointRlz: Could not write the new RLZ value"); ASSERT_STRING("SetAccessPointRlz: Could not write the new RLZ value");
return false; return false;
} }
@ -223,8 +221,8 @@ bool RlzValueStoreRegistry::ReadAccessPointRlz(AccessPoint access_point,
size_t size = rlz_size; size_t size = rlz_size;
base::win::RegKey key; base::win::RegKey key;
GetAccessPointRlzsRegKey(KEY_READ, &key); GetAccessPointRlzsRegKey(KEY_READ, &key);
base::string16 access_point_name16 = ASCIIToUTF16(access_point_name); std::wstring access_point_namew = base::ASCIIToWide(access_point_name);
if (!RegKeyReadValue(key, access_point_name16.c_str(), rlz, &size)) { if (!RegKeyReadValue(key, access_point_namew.c_str(), rlz, &size)) {
rlz[0] = 0; rlz[0] = 0;
if (size > rlz_size) { if (size > rlz_size) {
ASSERT_STRING("GetAccessPointRlz: Insufficient buffer size"); ASSERT_STRING("GetAccessPointRlz: Insufficient buffer size");
@ -239,15 +237,15 @@ bool RlzValueStoreRegistry::ClearAccessPointRlz(AccessPoint access_point) {
if (!access_point_name) if (!access_point_name)
return false; return false;
base::string16 access_point_name16(ASCIIToUTF16(access_point_name)); std::wstring access_point_namew(base::ASCIIToWide(access_point_name));
base::win::RegKey key; base::win::RegKey key;
GetAccessPointRlzsRegKey(KEY_WRITE, &key); GetAccessPointRlzsRegKey(KEY_WRITE, &key);
key.DeleteValue(access_point_name16.c_str()); key.DeleteValue(access_point_namew.c_str());
// Verify deletion. // Verify deletion.
DWORD value; DWORD value;
if (key.ReadValueDW(access_point_name16.c_str(), &value) == ERROR_SUCCESS) { if (key.ReadValueDW(access_point_namew.c_str(), &value) == ERROR_SUCCESS) {
ASSERT_STRING("SetAccessPointRlz: Could not clear the RLZ value."); ASSERT_STRING("SetAccessPointRlz: Could not clear the RLZ value.");
return false; return false;
} }
@ -261,10 +259,10 @@ bool RlzValueStoreRegistry::UpdateExistingAccessPointRlz(
bool RlzValueStoreRegistry::AddProductEvent(Product product, bool RlzValueStoreRegistry::AddProductEvent(Product product,
const char* event_rlz) { const char* event_rlz) {
base::string16 event_rlz16(ASCIIToUTF16(event_rlz)); std::wstring event_rlzw(base::ASCIIToWide(event_rlz));
base::win::RegKey reg_key; base::win::RegKey reg_key;
GetEventsRegKey(kEventsSubkeyName, &product, KEY_WRITE, &reg_key); GetEventsRegKey(kEventsSubkeyName, &product, KEY_WRITE, &reg_key);
if (reg_key.WriteValue(event_rlz16.c_str(), 1) != ERROR_SUCCESS) { if (reg_key.WriteValue(event_rlzw.c_str(), 1) != ERROR_SUCCESS) {
ASSERT_STRING("AddProductEvent: Could not write the new event value"); ASSERT_STRING("AddProductEvent: Could not write the new event value");
return false; return false;
} }
@ -300,14 +298,14 @@ bool RlzValueStoreRegistry::ReadProductEvents(Product product,
bool RlzValueStoreRegistry::ClearProductEvent(Product product, bool RlzValueStoreRegistry::ClearProductEvent(Product product,
const char* event_rlz) { const char* event_rlz) {
base::string16 event_rlz16(ASCIIToUTF16(event_rlz)); std::wstring event_rlzw(base::ASCIIToWide(event_rlz));
base::win::RegKey key; base::win::RegKey key;
GetEventsRegKey(kEventsSubkeyName, &product, KEY_WRITE, &key); GetEventsRegKey(kEventsSubkeyName, &product, KEY_WRITE, &key);
key.DeleteValue(event_rlz16.c_str()); key.DeleteValue(event_rlzw.c_str());
// Verify deletion. // Verify deletion.
DWORD value; DWORD value;
if (key.ReadValueDW(event_rlz16.c_str(), &value) == ERROR_SUCCESS) { if (key.ReadValueDW(event_rlzw.c_str(), &value) == ERROR_SUCCESS) {
ASSERT_STRING("ClearProductEvent: Could not delete the event value."); ASSERT_STRING("ClearProductEvent: Could not delete the event value.");
return false; return false;
} }
@ -322,9 +320,9 @@ bool RlzValueStoreRegistry::ClearAllProductEvents(Product product) {
bool RlzValueStoreRegistry::AddStatefulEvent(Product product, bool RlzValueStoreRegistry::AddStatefulEvent(Product product,
const char* event_rlz) { const char* event_rlz) {
base::win::RegKey key; base::win::RegKey key;
base::string16 event_rlz16(ASCIIToUTF16(event_rlz)); std::wstring event_rlzw(base::ASCIIToWide(event_rlz));
if (!GetEventsRegKey(kStatefulEventsSubkeyName, &product, KEY_WRITE, &key) || if (!GetEventsRegKey(kStatefulEventsSubkeyName, &product, KEY_WRITE, &key) ||
key.WriteValue(event_rlz16.c_str(), 1) != ERROR_SUCCESS) { key.WriteValue(event_rlzw.c_str(), 1) != ERROR_SUCCESS) {
ASSERT_STRING( ASSERT_STRING(
"AddStatefulEvent: Could not write the new stateful event"); "AddStatefulEvent: Could not write the new stateful event");
return false; return false;
@ -338,8 +336,8 @@ bool RlzValueStoreRegistry::IsStatefulEvent(Product product,
DWORD value; DWORD value;
base::win::RegKey key; base::win::RegKey key;
GetEventsRegKey(kStatefulEventsSubkeyName, &product, KEY_READ, &key); GetEventsRegKey(kStatefulEventsSubkeyName, &product, KEY_READ, &key);
base::string16 event_rlz16(ASCIIToUTF16(event_rlz)); std::wstring event_rlzw(base::ASCIIToWide(event_rlz));
return key.ReadValueDW(event_rlz16.c_str(), &value) == ERROR_SUCCESS; return key.ReadValueDW(event_rlzw.c_str(), &value) == ERROR_SUCCESS;
} }
bool RlzValueStoreRegistry::ClearAllStatefulEvents(Product product) { bool RlzValueStoreRegistry::ClearAllStatefulEvents(Product product) {
@ -359,9 +357,9 @@ void RlzValueStoreRegistry::CollectGarbage() {
std::string subkey_name; std::string subkey_name;
base::StringAppendF(&subkey_name, "%s\\%s", kLibKeyName, subkeys[i]); base::StringAppendF(&subkey_name, "%s\\%s", kLibKeyName, subkeys[i]);
AppendBrandToString(&subkey_name); AppendBrandToString(&subkey_name);
base::string16 subkey_name16 = ASCIIToUTF16(subkey_name); std::wstring subkey_namew = base::ASCIIToWide(subkey_name);
VERIFY(DeleteKeyIfEmpty(HKEY_CURRENT_USER, subkey_name16.c_str())); VERIFY(DeleteKeyIfEmpty(HKEY_CURRENT_USER, subkey_namew.c_str()));
} }
// Delete the library key and its parents too now if empty. // Delete the library key and its parents too now if empty.

@ -289,7 +289,7 @@ void AddGenericDllEvictionPolicy(TargetPolicy* policy) {
} }
// Returns the object path prepended with the current logon session. // Returns the object path prepended with the current logon session.
base::string16 PrependWindowsSessionPath(const base::char16* object) { std::wstring PrependWindowsSessionPath(const wchar_t* object) {
// Cache this because it can't change after process creation. // Cache this because it can't change after process creation.
static DWORD s_session_id = 0; static DWORD s_session_id = 0;
if (s_session_id == 0) { if (s_session_id == 0) {
@ -626,8 +626,8 @@ ResultCode SetJobMemoryLimit(const base::CommandLine& cmd_line,
// Generate a unique sandbox AC profile for the appcontainer based on the SHA1 // Generate a unique sandbox AC profile for the appcontainer based on the SHA1
// hash of the appcontainer_id. This does not need to be secure so using SHA1 // hash of the appcontainer_id. This does not need to be secure so using SHA1
// isn't a security concern. // isn't a security concern.
base::string16 GetAppContainerProfileName(const std::string& appcontainer_id, std::wstring GetAppContainerProfileName(const std::string& appcontainer_id,
SandboxType sandbox_type) { SandboxType sandbox_type) {
std::string sandbox_base_name; std::string sandbox_base_name;
switch (sandbox_type) { switch (sandbox_type) {
case SandboxType::kXrCompositing: case SandboxType::kXrCompositing:
@ -714,7 +714,7 @@ ResultCode SetupAppContainerProfile(AppContainerProfile* profile,
} }
} }
std::vector<base::string16> base_caps = { std::vector<std::wstring> base_caps = {
L"lpacChromeInstallFiles", L"lpacChromeInstallFiles",
L"registryRead", L"registryRead",
}; };
@ -782,7 +782,7 @@ ResultCode SandboxWin::AddBaseHandleClosePolicy(TargetPolicy* policy) {
} }
// TODO(cpu): Add back the BaseNamedObjects policy. // TODO(cpu): Add back the BaseNamedObjects policy.
base::string16 object_path = PrependWindowsSessionPath( std::wstring object_path = PrependWindowsSessionPath(
L"\\BaseNamedObjects\\windows_shell_global_counters"); L"\\BaseNamedObjects\\windows_shell_global_counters");
return policy->AddKernelObjectToClose(L"Section", object_path.data()); return policy->AddKernelObjectToClose(L"Section", object_path.data());
} }
@ -826,7 +826,7 @@ ResultCode SandboxWin::AddAppContainerProfileToPolicy(
TargetPolicy* policy) { TargetPolicy* policy) {
if (base::win::GetVersion() < base::win::Version::WIN10_RS1) if (base::win::GetVersion() < base::win::Version::WIN10_RS1)
return SBOX_ALL_OK; return SBOX_ALL_OK;
base::string16 profile_name = std::wstring profile_name =
GetAppContainerProfileName(appcontainer_id, sandbox_type); GetAppContainerProfileName(appcontainer_id, sandbox_type);
ResultCode result = ResultCode result =
policy->AddAppContainerProfile(profile_name.c_str(), true); policy->AddAppContainerProfile(profile_name.c_str(), true);

@ -18,7 +18,7 @@ namespace audio {
namespace { namespace {
#if defined(OS_WIN) #if defined(OS_WIN)
#define NumberToStringType base::NumberToString16 #define NumberToStringType base::NumberToWString
#else #else
#define NumberToStringType base::NumberToString #define NumberToStringType base::NumberToString
#endif #endif

@ -327,16 +327,18 @@ std::string GetFileSystemTypeString(FileSystemType type) {
} }
std::string FilePathToString(const base::FilePath& file_path) { std::string FilePathToString(const base::FilePath& file_path) {
// TODO(pkasting): Probably this should use AsUTF8Unsafe() across platforms.
#if defined(OS_WIN) #if defined(OS_WIN)
return base::UTF16ToUTF8(file_path.value()); return file_path.AsUTF8Unsafe();
#elif defined(OS_POSIX) || defined(OS_FUCHSIA) #elif defined(OS_POSIX) || defined(OS_FUCHSIA)
return file_path.value(); return file_path.value();
#endif #endif
} }
base::FilePath StringToFilePath(const std::string& file_path_string) { base::FilePath StringToFilePath(const std::string& file_path_string) {
// TODO(pkasting): Probably this should use FromUTF8Unsafe() across platforms.
#if defined(OS_WIN) #if defined(OS_WIN)
return base::FilePath(base::UTF8ToUTF16(file_path_string)); return base::FilePath::FromUTF8Unsafe(file_path_string);
#elif defined(OS_POSIX) || defined(OS_FUCHSIA) #elif defined(OS_POSIX) || defined(OS_FUCHSIA)
return base::FilePath(file_path_string); return base::FilePath(file_path_string);
#endif #endif

@ -6,6 +6,7 @@
#define THIRD_PARTY_BLINK_PUBLIC_WEB_WIN_WEB_FONT_RENDERING_H_ #define THIRD_PARTY_BLINK_PUBLIC_WEB_WIN_WEB_FONT_RENDERING_H_
#include "third_party/blink/public/platform/web_common.h" #include "third_party/blink/public/platform/web_common.h"
#include "third_party/blink/public/platform/web_string.h"
#include "third_party/skia/include/core/SkRefCnt.h" #include "third_party/skia/include/core/SkRefCnt.h"
class SkFontMgr; class SkFontMgr;
@ -17,12 +18,12 @@ class WebFontRendering {
public: public:
BLINK_EXPORT static void SetSkiaFontManager(sk_sp<SkFontMgr>); BLINK_EXPORT static void SetSkiaFontManager(sk_sp<SkFontMgr>);
BLINK_EXPORT static void AddSideloadedFontForTesting(sk_sp<SkTypeface>); BLINK_EXPORT static void AddSideloadedFontForTesting(sk_sp<SkTypeface>);
BLINK_EXPORT static void SetMenuFontMetrics(const wchar_t* family_name, BLINK_EXPORT static void SetMenuFontMetrics(const WebString& family_name,
int32_t font_height); int32_t font_height);
BLINK_EXPORT static void SetSmallCaptionFontMetrics( BLINK_EXPORT static void SetSmallCaptionFontMetrics(
const wchar_t* family_name, const WebString& family_name,
int32_t font_height); int32_t font_height);
BLINK_EXPORT static void SetStatusFontMetrics(const wchar_t* family_name, BLINK_EXPORT static void SetStatusFontMetrics(const WebString& family_name,
int32_t font_height); int32_t font_height);
BLINK_EXPORT static void SetAntialiasedTextEnabled(bool); BLINK_EXPORT static void SetAntialiasedTextEnabled(bool);
BLINK_EXPORT static void SetLCDTextEnabled(bool); BLINK_EXPORT static void SetLCDTextEnabled(bool);

@ -3049,13 +3049,14 @@ void WebViewImpl::UpdateFontRenderingFromRendererPrefs() {
#if defined(OS_WIN) #if defined(OS_WIN)
// Cache the system font metrics in blink. // Cache the system font metrics in blink.
WebFontRendering::SetMenuFontMetrics( WebFontRendering::SetMenuFontMetrics(
renderer_preferences_.menu_font_family_name.c_str(), WebString::FromUTF16(renderer_preferences_.menu_font_family_name),
renderer_preferences_.menu_font_height); renderer_preferences_.menu_font_height);
WebFontRendering::SetSmallCaptionFontMetrics( WebFontRendering::SetSmallCaptionFontMetrics(
renderer_preferences_.small_caption_font_family_name.c_str(), WebString::FromUTF16(
renderer_preferences_.small_caption_font_family_name),
renderer_preferences_.small_caption_font_height); renderer_preferences_.small_caption_font_height);
WebFontRendering::SetStatusFontMetrics( WebFontRendering::SetStatusFontMetrics(
renderer_preferences_.status_font_family_name.c_str(), WebString::FromUTF16(renderer_preferences_.status_font_family_name),
renderer_preferences_.status_font_height); renderer_preferences_.status_font_height);
WebFontRendering::SetAntialiasedTextEnabled( WebFontRendering::SetAntialiasedTextEnabled(
renderer_preferences_.should_antialias_text); renderer_preferences_.should_antialias_text);

@ -19,19 +19,19 @@ void WebFontRendering::AddSideloadedFontForTesting(sk_sp<SkTypeface> typeface) {
} }
// static // static
void WebFontRendering::SetMenuFontMetrics(const wchar_t* family_name, void WebFontRendering::SetMenuFontMetrics(const WebString& family_name,
int32_t font_height) { int32_t font_height) {
FontCache::SetMenuFontMetrics(family_name, font_height); FontCache::SetMenuFontMetrics(family_name, font_height);
} }
// static // static
void WebFontRendering::SetSmallCaptionFontMetrics(const wchar_t* family_name, void WebFontRendering::SetSmallCaptionFontMetrics(const WebString& family_name,
int32_t font_height) { int32_t font_height) {
FontCache::SetSmallCaptionFontMetrics(family_name, font_height); FontCache::SetSmallCaptionFontMetrics(family_name, font_height);
} }
// static // static
void WebFontRendering::SetStatusFontMetrics(const wchar_t* family_name, void WebFontRendering::SetStatusFontMetrics(const WebString& family_name,
int32_t font_height) { int32_t font_height) {
FontCache::SetStatusFontMetrics(family_name, font_height); FontCache::SetStatusFontMetrics(family_name, font_height);
} }

@ -34,7 +34,7 @@ class ValidationMessageOverlayDelegateTest : public PaintTestConfigurations,
// an extra step is required to ensure that the system font is configured. // an extra step is required to ensure that the system font is configured.
// See https://crbug.com/969622 // See https://crbug.com/969622
blink::WebFontRendering::SetMenuFontMetrics( blink::WebFontRendering::SetMenuFontMetrics(
base::ASCIIToUTF16("Arial").c_str(), 12); blink::WebString::FromASCII("Arial"), 12);
} }
#endif #endif
}; };

@ -203,11 +203,11 @@ class PLATFORM_EXPORT FontCache {
static void SetLCDTextEnabled(bool enabled) { lcd_text_enabled_ = enabled; } static void SetLCDTextEnabled(bool enabled) { lcd_text_enabled_ = enabled; }
static void AddSideloadedFontForTesting(sk_sp<SkTypeface>); static void AddSideloadedFontForTesting(sk_sp<SkTypeface>);
// Functions to cache and retrieve the system font metrics. // Functions to cache and retrieve the system font metrics.
static void SetMenuFontMetrics(const wchar_t* family_name, static void SetMenuFontMetrics(const AtomicString& family_name,
int32_t font_height); int32_t font_height);
static void SetSmallCaptionFontMetrics(const wchar_t* family_name, static void SetSmallCaptionFontMetrics(const AtomicString& family_name,
int32_t font_height); int32_t font_height);
static void SetStatusFontMetrics(const wchar_t* family_name, static void SetStatusFontMetrics(const AtomicString& family_name,
int32_t font_height); int32_t font_height);
static int32_t MenuFontHeight() { return menu_font_height_; } static int32_t MenuFontHeight() { return menu_font_height_; }
static const AtomicString& MenuFontFamily() { static const AtomicString& MenuFontFamily() {

@ -207,21 +207,21 @@ const AtomicString& FontCache::SystemFontFamily() {
} }
// static // static
void FontCache::SetMenuFontMetrics(const wchar_t* family_name, void FontCache::SetMenuFontMetrics(const AtomicString& family_name,
int32_t font_height) { int32_t font_height) {
menu_font_family_name_ = new AtomicString(family_name); menu_font_family_name_ = new AtomicString(family_name);
menu_font_height_ = EnsureMinimumFontHeightIfNeeded(font_height); menu_font_height_ = EnsureMinimumFontHeightIfNeeded(font_height);
} }
// static // static
void FontCache::SetSmallCaptionFontMetrics(const wchar_t* family_name, void FontCache::SetSmallCaptionFontMetrics(const AtomicString& family_name,
int32_t font_height) { int32_t font_height) {
small_caption_font_family_name_ = new AtomicString(family_name); small_caption_font_family_name_ = new AtomicString(family_name);
small_caption_font_height_ = EnsureMinimumFontHeightIfNeeded(font_height); small_caption_font_height_ = EnsureMinimumFontHeightIfNeeded(font_height);
} }
// static // static
void FontCache::SetStatusFontMetrics(const wchar_t* family_name, void FontCache::SetStatusFontMetrics(const AtomicString& family_name,
int32_t font_height) { int32_t font_height) {
status_font_family_name_ = new AtomicString(family_name); status_font_family_name_ = new AtomicString(family_name);
status_font_height_ = EnsureMinimumFontHeightIfNeeded(font_height); status_font_height_ = EnsureMinimumFontHeightIfNeeded(font_height);