Browse Source

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

https://chromium-review.googlesource.com/c/chromium/src/+/2757472
John Kleinschmidt 4 years ago
parent
commit
2d3c65beca
31 changed files with 200 additions and 152 deletions
  1. 6 2
      shell/app/electron_crash_reporter_client.cc
  2. 1 1
      shell/app/node_main.cc
  3. 4 2
      shell/browser/api/electron_api_base_window.cc
  4. 1 1
      shell/browser/api/electron_api_crash_reporter.cc
  5. 1 1
      shell/browser/api/electron_api_web_contents.cc
  6. 8 8
      shell/browser/browser.h
  7. 58 56
      shell/browser/browser_win.cc
  8. 1 1
      shell/browser/electron_browser_client.cc
  9. 3 3
      shell/browser/notifications/win/notification_presenter_win.cc
  10. 1 1
      shell/browser/notifications/win/notification_presenter_win.h
  11. 5 2
      shell/browser/notifications/win/win32_notification.cc
  12. 9 6
      shell/browser/notifications/win/windows_toast_notification.cc
  13. 2 2
      shell/browser/ui/file_dialog_win.cc
  14. 15 14
      shell/browser/ui/message_box_win.cc
  15. 1 1
      shell/browser/ui/win/jump_list.cc
  16. 6 6
      shell/browser/ui/win/jump_list.h
  17. 5 3
      shell/browser/ui/win/notify_icon.cc
  18. 4 4
      shell/browser/ui/win/taskbar_host.cc
  19. 10 4
      shell/browser/web_contents_preferences.cc
  20. 1 1
      shell/browser/web_dialog_helper.cc
  21. 1 1
      shell/common/api/electron_api_native_image.cc
  22. 1 1
      shell/common/api/electron_api_native_image_win.cc
  23. 1 1
      shell/common/api/electron_api_shell.cc
  24. 5 4
      shell/common/application_info_win.cc
  25. 1 0
      shell/common/gin_converters/file_path_converter.h
  26. 28 0
      shell/common/gin_converters/std_converter.h
  27. 0 5
      shell/common/language_util.h
  28. 17 17
      shell/common/language_util_win.cc
  29. 1 1
      shell/common/node_bindings.cc
  30. 2 2
      shell/common/platform_util_win.cc
  31. 1 1
      shell/renderer/renderer_client_base.cc

+ 6 - 2
shell/app/electron_crash_reporter_client.cc

@@ -33,6 +33,10 @@
 #include "base/debug/dump_without_crashing.h"
 #endif
 
+#if defined(OS_WIN)
+#include "base/strings/string_util_win.h"
+#endif
+
 namespace {
 
 ElectronCrashReporterClient* Instance() {
@@ -130,8 +134,8 @@ void ElectronCrashReporterClient::GetProductNameAndVersion(
     std::wstring* version,
     std::wstring* special_build,
     std::wstring* channel_name) {
-  *product_name = base::UTF8ToUTF16(ELECTRON_PRODUCT_NAME);
-  *version = base::UTF8ToUTF16(ELECTRON_VERSION_STRING);
+  *product_name = base::UTF8ToWide(ELECTRON_PRODUCT_NAME);
+  *version = base::UTF8ToWide(ELECTRON_VERSION_STRING);
 }
 #endif
 

+ 1 - 1
shell/app/node_main.cc

@@ -66,7 +66,7 @@ void SetNodeCliFlags() {
 
   for (const auto& arg : argv) {
 #if defined(OS_WIN)
-    const auto& option = base::UTF16ToUTF8(arg);
+    const auto& option = base::WideToUTF8(arg);
 #else
     const auto& option = arg;
 #endif

+ 4 - 2
shell/browser/api/electron_api_base_window.cc

@@ -1101,8 +1101,10 @@ void BaseWindow::SetAppDetails(const gin_helper::Dictionary& options) {
   options.Get("relaunchCommand", &relaunch_command);
   options.Get("relaunchDisplayName", &relaunch_display_name);
 
-  ui::win::SetAppDetailsForWindow(app_id, app_icon_path, app_icon_index,
-                                  relaunch_command, relaunch_display_name,
+  ui::win::SetAppDetailsForWindow(base::UTF16ToWide(app_id), app_icon_path,
+                                  app_icon_index,
+                                  base::UTF16ToWide(relaunch_command),
+                                  base::UTF16ToWide(relaunch_display_name),
                                   window_->GetAcceleratedWidget());
 }
 #endif

+ 1 - 1
shell/browser/api/electron_api_crash_reporter.cc

@@ -175,7 +175,7 @@ void Start(const std::string& submit_url,
   base::PathService::Get(DIR_USER_DATA, &user_data_dir);
   ::crash_reporter::InitializeCrashpadWithEmbeddedHandler(
       process_type.empty(), process_type,
-      base::UTF16ToUTF8(user_data_dir.value()), base::FilePath());
+      base::WideToUTF8(user_data_dir.value()), base::FilePath());
 #endif
 #endif
 }

+ 1 - 1
shell/browser/api/electron_api_web_contents.cc

@@ -418,7 +418,7 @@ bool IsDeviceNameValid(const std::u16string& device_name) {
   return printer_exists;
 #elif defined(OS_WIN)
   printing::ScopedPrinterHandle printer;
-  return printer.OpenPrinterWithName(device_name.c_str());
+  return printer.OpenPrinterWithName(base::UTF16ToWide(device_name).c_str());
 #endif
   return true;
 }

+ 8 - 8
shell/browser/browser.h

@@ -112,10 +112,10 @@ class Browser : public WindowListObserver {
 
 #if defined(OS_WIN)
   struct LaunchItem {
-    std::u16string name;
-    std::u16string path;
-    std::u16string scope;
-    std::vector<std::u16string> args;
+    std::wstring name;
+    std::wstring path;
+    std::wstring scope;
+    std::vector<std::wstring> args;
     bool enabled = true;
 
     LaunchItem();
@@ -137,7 +137,7 @@ class Browser : public WindowListObserver {
 #if defined(OS_WIN)
     // used in browser::setLoginItemSettings
     bool enabled = true;
-    std::u16string name = std::u16string();
+    std::wstring name = std::wstring();
 
     // used in browser::getLoginItemSettings
     bool executable_will_launch_at_login = false;
@@ -237,9 +237,9 @@ class Browser : public WindowListObserver {
 #if defined(OS_WIN)
   struct UserTask {
     base::FilePath program;
-    std::u16string arguments;
-    std::u16string title;
-    std::u16string description;
+    std::wstring arguments;
+    std::wstring title;
+    std::wstring description;
     base::FilePath working_dir;
     base::FilePath icon_path;
     int icon_index;

+ 58 - 56
shell/browser/browser_win.cc

@@ -48,7 +48,7 @@ namespace electron {
 
 namespace {
 
-bool GetProcessExecPath(std::u16string* exe) {
+bool GetProcessExecPath(std::wstring* exe) {
   base::FilePath path;
   if (!base::PathService::Get(base::FILE_EXE, &path)) {
     return false;
@@ -57,13 +57,13 @@ bool GetProcessExecPath(std::u16string* exe) {
   return true;
 }
 
-bool GetProtocolLaunchPath(gin::Arguments* args, std::u16string* exe) {
+bool GetProtocolLaunchPath(gin::Arguments* args, std::wstring* exe) {
   if (!args->GetNext(exe) && !GetProcessExecPath(exe)) {
     return false;
   }
 
   // Read in optional args arg
-  std::vector<std::u16string> launch_args;
+  std::vector<std::wstring> launch_args;
   if (args->GetNext(&launch_args) && !launch_args.empty())
     *exe = base::StringPrintf(L"\"%ls\" %ls \"%%1\"", exe->c_str(),
                               base::JoinString(launch_args, L" ").c_str());
@@ -75,7 +75,7 @@ bool GetProtocolLaunchPath(gin::Arguments* args, std::u16string* exe) {
 // Windows treats a given scheme as an Internet scheme only if its registry
 // entry has a "URL Protocol" key. Check this, otherwise we allow ProgIDs to be
 // used as custom protocols which leads to security bugs.
-bool IsValidCustomProtocol(const std::u16string& scheme) {
+bool IsValidCustomProtocol(const std::wstring& scheme) {
   if (scheme.empty())
     return false;
   base::win::RegKey cmd_key(HKEY_CLASSES_ROOT, scheme.c_str(), KEY_QUERY_VALUE);
@@ -90,11 +90,10 @@ bool IsValidCustomProtocol(const std::u16string& scheme) {
 // Windows 8 introduced a new protocol->executable binding system which cannot
 // be retrieved in the HKCR registry subkey method implemented below. We call
 // AssocQueryString with the new Win8-only flag ASSOCF_IS_PROTOCOL instead.
-std::u16string GetAppInfoHelperForProtocol(ASSOCSTR assoc_str,
-                                           const GURL& url) {
-  const std::u16string url_scheme = base::ASCIIToUTF16(url.scheme());
+std::wstring GetAppInfoHelperForProtocol(ASSOCSTR assoc_str, const GURL& url) {
+  const std::wstring url_scheme = base::ASCIIToWide(url.scheme());
   if (!IsValidCustomProtocol(url_scheme))
-    return std::u16string();
+    return std::wstring();
 
   wchar_t out_buffer[1024];
   DWORD buffer_size = base::size(out_buffer);
@@ -103,13 +102,13 @@ std::u16string GetAppInfoHelperForProtocol(ASSOCSTR assoc_str,
                        out_buffer, &buffer_size);
   if (FAILED(hr)) {
     DLOG(WARNING) << "AssocQueryString failed!";
-    return std::u16string();
+    return std::wstring();
   }
-  return std::u16string(out_buffer);
+  return std::wstring(out_buffer);
 }
 
 void OnIconDataAvailable(const base::FilePath& app_path,
-                         const std::u16string& app_display_name,
+                         const std::wstring& app_display_name,
                          gin_helper::Promise<gin_helper::Dictionary> promise,
                          gfx::Image icon) {
   if (!icon.IsEmpty()) {
@@ -126,21 +125,21 @@ void OnIconDataAvailable(const base::FilePath& app_path,
   }
 }
 
-std::u16string GetAppDisplayNameForProtocol(const GURL& url) {
+std::wstring GetAppDisplayNameForProtocol(const GURL& url) {
   return GetAppInfoHelperForProtocol(ASSOCSTR_FRIENDLYAPPNAME, url);
 }
 
-std::u16string GetAppPathForProtocol(const GURL& url) {
+std::wstring GetAppPathForProtocol(const GURL& url) {
   return GetAppInfoHelperForProtocol(ASSOCSTR_EXECUTABLE, url);
 }
 
-std::u16string GetAppForProtocolUsingRegistry(const GURL& url) {
-  const std::u16string url_scheme = base::ASCIIToUTF16(url.scheme());
+std::wstring GetAppForProtocolUsingRegistry(const GURL& url) {
+  const std::wstring url_scheme = base::ASCIIToWide(url.scheme());
   if (!IsValidCustomProtocol(url_scheme))
-    return std::u16string();
+    return std::wstring();
 
   // First, try and extract the application's display name.
-  std::u16string command_to_launch;
+  std::wstring command_to_launch;
   base::win::RegKey cmd_key_name(HKEY_CLASSES_ROOT, url_scheme.c_str(),
                                  KEY_READ);
   if (cmd_key_name.ReadValue(NULL, &command_to_launch) == ERROR_SUCCESS &&
@@ -150,7 +149,7 @@ std::u16string GetAppForProtocolUsingRegistry(const GURL& url) {
 
   // Otherwise, parse the command line in the registry, and return the basename
   // of the program path if it exists.
-  const std::u16string cmd_key_path = url_scheme + L"\\shell\\open\\command";
+  const std::wstring cmd_key_path = url_scheme + L"\\shell\\open\\command";
   base::win::RegKey cmd_key_exe(HKEY_CLASSES_ROOT, cmd_key_path.c_str(),
                                 KEY_READ);
   if (cmd_key_exe.ReadValue(NULL, &command_to_launch) == ERROR_SUCCESS) {
@@ -159,18 +158,20 @@ std::u16string GetAppForProtocolUsingRegistry(const GURL& url) {
     return command_line.GetProgram().BaseName().value();
   }
 
-  return std::u16string();
+  return std::wstring();
 }
 
-bool FormatCommandLineString(std::u16string* exe,
+bool FormatCommandLineString(std::wstring* exe,
                              const std::vector<std::u16string>& launch_args) {
   if (exe->empty() && !GetProcessExecPath(exe)) {
     return false;
   }
 
   if (!launch_args.empty()) {
+    std::u16string joined_launch_args =
+        base::JoinString(launch_args, base::UTF8ToUTF16(" "));
     *exe = base::StringPrintf(L"%ls %ls", exe->c_str(),
-                              base::JoinString(launch_args, L" ").c_str());
+                              base::UTF16ToWide(joined_launch_args).c_str());
   }
 
   return true;
@@ -184,18 +185,20 @@ bool FormatCommandLineString(std::u16string* exe,
 std::vector<Browser::LaunchItem> GetLoginItemSettingsHelper(
     base::win::RegistryValueIterator* it,
     boolean* executable_will_launch_at_login,
-    std::u16string scope,
+    std::wstring scope,
     const Browser::LoginItemSettings& options) {
   std::vector<Browser::LaunchItem> launch_items;
 
   base::FilePath lookup_exe_path;
   if (options.path.empty()) {
-    std::u16string process_exe_path;
+    std::wstring process_exe_path;
     GetProcessExecPath(&process_exe_path);
     lookup_exe_path =
         base::CommandLine::FromString(process_exe_path).GetProgram();
   } else {
-    lookup_exe_path = base::CommandLine::FromString(options.path).GetProgram();
+    lookup_exe_path =
+        base::CommandLine::FromString(base::UTF16ToWide(options.path))
+            .GetProgram();
   }
 
   if (!lookup_exe_path.empty()) {
@@ -287,7 +290,7 @@ Browser::UserTask::~UserTask() = default;
 void GetFileIcon(const base::FilePath& path,
                  v8::Isolate* isolate,
                  base::CancelableTaskTracker* cancelable_task_tracker_,
-                 const std::u16string app_display_name,
+                 const std::wstring app_display_name,
                  gin_helper::Promise<gin_helper::Dictionary> promise) {
   base::FilePath normalized_path = path.NormalizePathSeparators();
   IconLoader::IconSize icon_size = IconLoader::IconSize::LARGE;
@@ -316,13 +319,13 @@ void GetApplicationInfoForProtocolUsingRegistry(
     base::CancelableTaskTracker* cancelable_task_tracker_) {
   base::FilePath app_path;
 
-  const std::u16string url_scheme = base::ASCIIToUTF16(url.scheme());
+  const std::wstring url_scheme = base::ASCIIToWide(url.scheme());
   if (!IsValidCustomProtocol(url_scheme)) {
     promise.RejectWithErrorMessage("invalid url_scheme");
     return;
   }
-  std::u16string command_to_launch;
-  const std::u16string cmd_key_path = url_scheme + L"\\shell\\open\\command";
+  std::wstring command_to_launch;
+  const std::wstring cmd_key_path = url_scheme + L"\\shell\\open\\command";
   base::win::RegKey cmd_key_exe(HKEY_CLASSES_ROOT, cmd_key_path.c_str(),
                                 KEY_READ);
   if (cmd_key_exe.ReadValue(NULL, &command_to_launch) == ERROR_SUCCESS) {
@@ -334,7 +337,7 @@ void GetApplicationInfoForProtocolUsingRegistry(
         "Unable to retrieve installation path to app");
     return;
   }
-  const std::u16string app_display_name = GetAppForProtocolUsingRegistry(url);
+  const std::wstring app_display_name = GetAppForProtocolUsingRegistry(url);
 
   if (app_display_name.empty()) {
     promise.RejectWithErrorMessage(
@@ -354,7 +357,7 @@ void GetApplicationInfoForProtocolUsingAssocQuery(
     const GURL& url,
     gin_helper::Promise<gin_helper::Dictionary> promise,
     base::CancelableTaskTracker* cancelable_task_tracker_) {
-  std::u16string app_path = GetAppPathForProtocol(url);
+  std::wstring app_path = GetAppPathForProtocol(url);
 
   if (app_path.empty()) {
     promise.RejectWithErrorMessage(
@@ -362,7 +365,7 @@ void GetApplicationInfoForProtocolUsingAssocQuery(
     return;
   }
 
-  std::u16string app_display_name = GetAppDisplayNameForProtocol(url);
+  std::wstring app_display_name = GetAppDisplayNameForProtocol(url);
 
   if (app_display_name.empty()) {
     promise.RejectWithErrorMessage("Unable to retrieve display name of app");
@@ -426,12 +429,12 @@ bool Browser::RemoveAsDefaultProtocolClient(const std::string& protocol,
 
   // Main Registry Key
   HKEY root = HKEY_CURRENT_USER;
-  std::u16string keyPath = L"Software\\Classes\\";
+  std::wstring keyPath = L"Software\\Classes\\";
 
   // Command Key
-  std::u16string wprotocol = base::UTF8ToUTF16(protocol);
-  std::u16string shellPath = wprotocol + L"\\shell";
-  std::u16string cmdPath = keyPath + shellPath + L"\\open\\command";
+  std::wstring wprotocol = base::UTF8ToWide(protocol);
+  std::wstring shellPath = wprotocol + L"\\shell";
+  std::wstring cmdPath = keyPath + shellPath + L"\\open\\command";
 
   base::win::RegKey classesKey;
   base::win::RegKey commandKey;
@@ -445,12 +448,12 @@ bool Browser::RemoveAsDefaultProtocolClient(const std::string& protocol,
     // Key doesn't even exist, we can confirm that it is not set
     return true;
 
-  std::u16string keyVal;
+  std::wstring keyVal;
   if (FAILED(commandKey.ReadValue(L"", &keyVal)))
     // Default value not set, we can confirm that it is not set
     return true;
 
-  std::u16string exe;
+  std::wstring exe;
   if (!GetProtocolLaunchPath(args, &exe))
     return false;
 
@@ -461,7 +464,7 @@ bool Browser::RemoveAsDefaultProtocolClient(const std::string& protocol,
 
     // Let's clean up after ourselves
     base::win::RegKey protocolKey;
-    std::u16string protocolPath = keyPath + wprotocol;
+    std::wstring protocolPath = keyPath + wprotocol;
 
     if (SUCCEEDED(
             protocolKey.Open(root, protocolPath.c_str(), KEY_ALL_ACCESS))) {
@@ -500,17 +503,17 @@ bool Browser::SetAsDefaultProtocolClient(const std::string& protocol,
   if (protocol.empty())
     return false;
 
-  std::u16string exe;
+  std::wstring exe;
   if (!GetProtocolLaunchPath(args, &exe))
     return false;
 
   // Main Registry Key
   HKEY root = HKEY_CURRENT_USER;
-  std::u16string keyPath = base::UTF8ToUTF16("Software\\Classes\\" + protocol);
-  std::u16string urlDecl = base::UTF8ToUTF16("URL:" + protocol);
+  std::wstring keyPath = base::UTF8ToWide("Software\\Classes\\" + protocol);
+  std::wstring urlDecl = base::UTF8ToWide("URL:" + protocol);
 
   // Command Key
-  std::u16string cmdPath = keyPath + L"\\shell\\open\\command";
+  std::wstring cmdPath = keyPath + L"\\shell\\open\\command";
 
   // Write information to registry
   base::win::RegKey key(root, keyPath.c_str(), KEY_ALL_ACCESS);
@@ -530,16 +533,16 @@ bool Browser::IsDefaultProtocolClient(const std::string& protocol,
   if (protocol.empty())
     return false;
 
-  std::u16string exe;
+  std::wstring exe;
   if (!GetProtocolLaunchPath(args, &exe))
     return false;
 
   // Main Registry Key
   HKEY root = HKEY_CURRENT_USER;
-  std::u16string keyPath = base::UTF8ToUTF16("Software\\Classes\\" + protocol);
+  std::wstring keyPath = base::UTF8ToWide("Software\\Classes\\" + protocol);
 
   // Command Key
-  std::u16string cmdPath = keyPath + L"\\shell\\open\\command";
+  std::wstring cmdPath = keyPath + L"\\shell\\open\\command";
 
   base::win::RegKey key;
   base::win::RegKey commandKey;
@@ -551,7 +554,7 @@ bool Browser::IsDefaultProtocolClient(const std::string& protocol,
     // Key doesn't exist, we can confirm that it is not set
     return false;
 
-  std::u16string keyVal;
+  std::wstring keyVal;
   if (FAILED(commandKey.ReadValue(L"", &keyVal)))
     // Default value not set, we can confirm that it is not set
     return false;
@@ -563,12 +566,12 @@ bool Browser::IsDefaultProtocolClient(const std::string& protocol,
 std::u16string Browser::GetApplicationNameForProtocol(const GURL& url) {
   // Windows 8 or above has a new protocol association query.
   if (base::win::GetVersion() >= base::win::Version::WIN8) {
-    std::u16string application_name = GetAppDisplayNameForProtocol(url);
+    std::wstring application_name = GetAppDisplayNameForProtocol(url);
     if (!application_name.empty())
-      return application_name;
+      return base::WideToUTF16(application_name);
   }
 
-  return GetAppForProtocolUsingRegistry(url);
+  return base::WideToUTF16(GetAppForProtocolUsingRegistry(url));
 }
 
 v8::Local<v8::Promise> Browser::GetApplicationInfoForProtocol(
@@ -686,11 +689,10 @@ void Browser::UpdateBadgeContents(
 }
 
 void Browser::SetLoginItemSettings(LoginItemSettings settings) {
-  std::u16string key_path =
-      L"Software\\Microsoft\\Windows\\CurrentVersion\\Run";
+  std::wstring key_path = L"Software\\Microsoft\\Windows\\CurrentVersion\\Run";
   base::win::RegKey key(HKEY_CURRENT_USER, key_path.c_str(), KEY_ALL_ACCESS);
 
-  std::u16string startup_approved_key_path =
+  std::wstring startup_approved_key_path =
       L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\StartupApproved"
       L"\\Run";
   base::win::RegKey startup_approved_key(
@@ -699,7 +701,7 @@ void Browser::SetLoginItemSettings(LoginItemSettings settings) {
       !settings.name.empty() ? settings.name.c_str() : GetAppUserModelID();
 
   if (settings.open_at_login) {
-    std::u16string exe = settings.path;
+    std::wstring exe = base::UTF16ToWide(settings.path);
     if (FormatCommandLineString(&exe, settings.args)) {
       key.WriteValue(key_name, exe.c_str());
 
@@ -732,13 +734,13 @@ void Browser::SetLoginItemSettings(LoginItemSettings settings) {
 Browser::LoginItemSettings Browser::GetLoginItemSettings(
     const LoginItemSettings& options) {
   LoginItemSettings settings;
-  std::u16string keyPath = L"Software\\Microsoft\\Windows\\CurrentVersion\\Run";
+  std::wstring keyPath = L"Software\\Microsoft\\Windows\\CurrentVersion\\Run";
   base::win::RegKey key(HKEY_CURRENT_USER, keyPath.c_str(), KEY_ALL_ACCESS);
-  std::u16string keyVal;
+  std::wstring keyVal;
 
   // keep old openAtLogin behaviour
   if (!FAILED(key.ReadValue(GetAppUserModelID(), &keyVal))) {
-    std::u16string exe = options.path;
+    std::wstring exe = base::UTF16ToWide(options.path);
     if (FormatCommandLineString(&exe, options.args)) {
       settings.open_at_login = keyVal == exe;
     }

+ 1 - 1
shell/browser/electron_browser_client.cc

@@ -920,7 +920,7 @@ ElectronBrowserClient::CreateWindowForPictureInPicture(
     content::PictureInPictureWindowController* controller) {
   auto overlay_window = content::OverlayWindow::Create(controller);
 #if defined(OS_WIN)
-  std::u16string app_user_model_id = Browser::Get()->GetAppUserModelID();
+  std::wstring app_user_model_id = Browser::Get()->GetAppUserModelID();
   if (!app_user_model_id.empty()) {
     auto* overlay_window_view =
         static_cast<OverlayWindowViews*>(overlay_window.get());

+ 3 - 3
shell/browser/notifications/win/notification_presenter_win.cc

@@ -72,7 +72,7 @@ bool NotificationPresenterWin::Init() {
   return temp_dir_.CreateUniqueTempDir();
 }
 
-std::u16string NotificationPresenterWin::SaveIconToFilesystem(
+std::wstring NotificationPresenterWin::SaveIconToFilesystem(
     const SkBitmap& icon,
     const GURL& origin) {
   std::string filename;
@@ -85,12 +85,12 @@ std::u16string NotificationPresenterWin::SaveIconToFilesystem(
   }
 
   base::ThreadRestrictions::ScopedAllowIO allow_io;
-  base::FilePath path = temp_dir_.GetPath().Append(base::UTF8ToUTF16(filename));
+  base::FilePath path = temp_dir_.GetPath().Append(base::UTF8ToWide(filename));
   if (base::PathExists(path))
     return path.value();
   if (SaveIconToPath(icon, path))
     return path.value();
-  return base::UTF8ToUTF16(origin.spec());
+  return base::UTF8ToWide(origin.spec());
 }
 
 Notification* NotificationPresenterWin::CreateNotificationObject(

+ 1 - 1
shell/browser/notifications/win/notification_presenter_win.h

@@ -38,7 +38,7 @@ class NotificationPresenterWin : public NotificationPresenter {
 
   bool Init();
 
-  std::u16string SaveIconToFilesystem(const SkBitmap& icon, const GURL& origin);
+  std::wstring SaveIconToFilesystem(const SkBitmap& icon, const GURL& origin);
 
  private:
   Notification* CreateNotificationObject(

+ 5 - 2
shell/browser/notifications/win/win32_notification.cc

@@ -13,6 +13,7 @@
 #include <utility>
 #include <vector>
 
+#include "base/strings/utf_string_conversions.h"
 #include "third_party/skia/include/core/SkBitmap.h"
 
 namespace electron {
@@ -49,13 +50,15 @@ void Win32Notification::Show(const NotificationOptions& options) {
     existing->tag_.clear();
 
     this->notification_ref_ = std::move(existing->notification_ref_);
-    this->notification_ref_.Set(options.title, options.msg, image);
+    this->notification_ref_.Set(base::UTF16ToWide(options.title),
+                                base::UTF16ToWide(options.msg), image);
     // Need to remove the entry in the notifications set that
     // NotificationPresenter is holding
     existing->Destroy();
   } else {
     this->notification_ref_ =
-        presenter->AddNotification(options.title, options.msg, image);
+        presenter->AddNotification(base::UTF16ToWide(options.title),
+                                   base::UTF16ToWide(options.msg), image);
   }
 
   this->tag_ = options.tag;

+ 9 - 6
shell/browser/notifications/win/windows_toast_notification.cc

@@ -21,7 +21,7 @@
 #include "shell/browser/notifications/win/notification_presenter_win.h"
 #include "shell/browser/win/scoped_hstring.h"
 #include "shell/common/application_info.h"
-#include "ui/base/l10n/l10n_util.h"
+#include "ui/base/l10n/l10n_util_win.h"
 #include "ui/strings/grit/ui_strings.h"
 
 using ABI::Windows::Data::Xml::Dom::IXmlAttribute;
@@ -132,15 +132,18 @@ HRESULT WindowsToastNotification::ShowInternal(
   // The custom xml takes priority over the preset template.
   if (!options.toast_xml.empty()) {
     REPORT_AND_RETURN_IF_FAILED(
-        XmlDocumentFromString(options.toast_xml.c_str(), &toast_xml),
+        XmlDocumentFromString(base::UTF16ToWide(options.toast_xml).c_str(),
+                              &toast_xml),
         "XML: Invalid XML");
   } else {
     auto* presenter_win = static_cast<NotificationPresenterWin*>(presenter());
     std::wstring icon_path =
         presenter_win->SaveIconToFilesystem(options.icon, options.icon_url);
     REPORT_AND_RETURN_IF_FAILED(
-        GetToastXml(toast_manager_.Get(), options.title, options.msg, icon_path,
-                    options.timeout_type, options.silent, &toast_xml),
+        GetToastXml(toast_manager_.Get(), base::UTF16ToWide(options.title),
+                    base::UTF16ToWide(options.msg), icon_path,
+                    base::UTF16ToWide(options.timeout_type), options.silent,
+                    &toast_xml),
         "XML: Failed to create XML document");
   }
 
@@ -211,7 +214,7 @@ HRESULT WindowsToastNotification::GetToastXml(
   }
 
   // Configure the toast's timeout settings
-  if (timeout_type == base::ASCIIToUTF16("never")) {
+  if (timeout_type == base::ASCIIToWide("never")) {
     REPORT_AND_RETURN_IF_FAILED(
         (SetXmlScenarioReminder(*toast_xml)),
         "XML: Setting \"scenario\" option on notification failed");
@@ -379,7 +382,7 @@ HRESULT WindowsToastNotification::SetXmlScenarioReminder(IXmlDocument* doc) {
   RETURN_IF_FAILED(content_attribute.As(&content_attribute_node));
 
   // Set content attribute to Dismiss
-  ScopedHString content_value(l10n_util::GetStringUTF16(IDS_APP_CLOSE));
+  ScopedHString content_value(l10n_util::GetWideString(IDS_APP_CLOSE));
   if (!content_value.success())
     return E_FAIL;
 

+ 2 - 2
shell/browser/ui/file_dialog_win.cc

@@ -118,10 +118,10 @@ static void ApplySettings(IFileDialog* dialog, const DialogSettings& settings) {
   dialog->SetFileName(file_part.c_str());
 
   if (!settings.title.empty())
-    dialog->SetTitle(base::UTF8ToUTF16(settings.title).c_str());
+    dialog->SetTitle(base::UTF8ToWide(settings.title).c_str());
 
   if (!settings.button_label.empty())
-    dialog->SetOkButtonLabel(base::UTF8ToUTF16(settings.button_label).c_str());
+    dialog->SetOkButtonLabel(base::UTF8ToWide(settings.button_label).c_str());
 
   std::vector<std::wstring> buffer;
   std::vector<COMDLG_FILTERSPEC> filterspec;

+ 15 - 14
shell/browser/ui/message_box_win.cc

@@ -39,8 +39,8 @@ struct CommonButtonID {
   int button;
   int id;
 };
-CommonButtonID GetCommonID(const std::u16string& button) {
-  std::u16string lower = base::ToLowerASCII(button);
+CommonButtonID GetCommonID(const std::wstring& button) {
+  std::wstring lower = base::ToLowerASCII(button);
   if (lower == L"ok")
     return {TDCBF_OK_BUTTON, IDOK};
   else if (lower == L"yes")
@@ -63,15 +63,15 @@ void MapToCommonID(const std::vector<std::u16string>& buttons,
                    TASKDIALOG_COMMON_BUTTON_FLAGS* button_flags,
                    std::vector<TASKDIALOG_BUTTON>* dialog_buttons) {
   for (size_t i = 0; i < buttons.size(); ++i) {
-    auto common = GetCommonID(buttons[i]);
+    auto common = GetCommonID(base::UTF16ToWide(buttons[i]));
     if (common.button != -1) {
       // It is a common button.
       (*id_map)[common.id] = i;
       (*button_flags) |= common.button;
     } else {
       // It is a custom button.
-      dialog_buttons->push_back(
-          {static_cast<int>(i + kIDStart), buttons[i].c_str()});
+      dialog_buttons->push_back({static_cast<int>(i + kIDStart),
+                                 base::UTF16ToWide(buttons[i]).c_str()});
     }
   }
 }
@@ -107,11 +107,11 @@ DialogResult ShowTaskDialogUTF16(NativeWindow* parent,
 
   // TaskDialogIndirect doesn't allow empty name, if we set empty title it
   // will show "electron.exe" in title.
-  std::u16string app_name = base::UTF8ToUTF16(Browser::Get()->GetName());
+  std::wstring app_name = base::UTF8ToWide(Browser::Get()->GetName());
   if (title.empty())
     config.pszWindowTitle = app_name.c_str();
   else
-    config.pszWindowTitle = title.c_str();
+    config.pszWindowTitle = base::UTF16ToWide(title).c_str();
 
   base::win::ScopedHICON hicon;
   if (!icon.isNull()) {
@@ -138,14 +138,14 @@ DialogResult ShowTaskDialogUTF16(NativeWindow* parent,
 
   // If "detail" is empty then don't make message highlighted.
   if (detail.empty()) {
-    config.pszContent = message.c_str();
+    config.pszContent = base::UTF16ToWide(message).c_str();
   } else {
-    config.pszMainInstruction = message.c_str();
-    config.pszContent = detail.c_str();
+    config.pszMainInstruction = base::UTF16ToWide(message).c_str();
+    config.pszContent = base::UTF16ToWide(detail).c_str();
   }
 
   if (!checkbox_label.empty()) {
-    config.pszVerificationText = checkbox_label.c_str();
+    config.pszVerificationText = base::UTF16ToWide(checkbox_label).c_str();
     if (checkbox_checked)
       config.dwFlags |= TDF_VERIFICATION_FLAG_CHECKED;
   }
@@ -156,8 +156,8 @@ DialogResult ShowTaskDialogUTF16(NativeWindow* parent,
   std::vector<TASKDIALOG_BUTTON> dialog_buttons;
   if (no_link) {
     for (size_t i = 0; i < buttons.size(); ++i)
-      dialog_buttons.push_back(
-          {static_cast<int>(i + kIDStart), buttons[i].c_str()});
+      dialog_buttons.push_back({static_cast<int>(i + kIDStart),
+                                base::UTF16ToWide(buttons[i]).c_str()});
   } else {
     MapToCommonID(buttons, &id_map, &config.dwCommonButtons, &dialog_buttons);
   }
@@ -222,7 +222,8 @@ void ShowMessageBox(const MessageBoxSettings& settings,
 void ShowErrorBox(const std::u16string& title, const std::u16string& content) {
   electron::UnresponsiveSuppressor suppressor;
   ShowTaskDialogUTF16(nullptr, MessageBoxType::kError, {}, -1, 0, false,
-                      L"Error", title, content, L"", false, gfx::ImageSkia());
+                      base::UTF8ToUTF16("Error"), title, content,
+                      base::UTF8ToUTF16(""), false, gfx::ImageSkia());
 }
 
 }  // namespace electron

+ 1 - 1
shell/browser/ui/win/jump_list.cc

@@ -158,7 +158,7 @@ JumpListCategory::JumpListCategory() = default;
 JumpListCategory::JumpListCategory(const JumpListCategory&) = default;
 JumpListCategory::~JumpListCategory() = default;
 
-JumpList::JumpList(const std::u16string& app_id) : app_id_(app_id) {
+JumpList::JumpList(const std::wstring& app_id) : app_id_(app_id) {
   destinations_.CoCreateInstance(CLSID_DestinationList);
 }
 

+ 6 - 6
shell/browser/ui/win/jump_list.h

@@ -46,9 +46,9 @@ struct JumpListItem {
   // For tasks this is the path to the program executable, for file links this
   // is the full filename.
   base::FilePath path;
-  std::u16string arguments;
-  std::u16string title;
-  std::u16string description;
+  std::wstring arguments;
+  std::wstring title;
+  std::wstring description;
   base::FilePath working_dir;
   base::FilePath icon_path;
   int icon_index = 0;
@@ -73,7 +73,7 @@ struct JumpListCategory {
   };
 
   Type type = Type::kTasks;
-  std::u16string name;
+  std::wstring name;
   std::vector<JumpListItem> items;
 
   JumpListCategory();
@@ -88,7 +88,7 @@ class JumpList {
   // |app_id| must be the Application User Model ID of the app for which the
   // custom Jump List should be created/removed, it's usually obtained by
   // calling GetCurrentProcessExplicitAppUserModelID().
-  explicit JumpList(const std::u16string& app_id);
+  explicit JumpList(const std::wstring& app_id);
   ~JumpList();
 
   // Starts a new transaction, must be called before appending any categories,
@@ -111,7 +111,7 @@ class JumpList {
       const std::vector<JumpListCategory>& categories);
 
  private:
-  std::u16string app_id_;
+  std::wstring app_id_;
   CComPtr<ICustomDestinationList> destinations_;
 
   DISALLOW_COPY_AND_ASSIGN(JumpList);

+ 5 - 3
shell/browser/ui/win/notify_icon.cc

@@ -141,7 +141,7 @@ void NotifyIcon::SetToolTip(const std::string& tool_tip) {
   NOTIFYICONDATA icon_data;
   InitIconData(&icon_data);
   icon_data.uFlags |= NIF_TIP;
-  wcsncpy_s(icon_data.szTip, base::UTF8ToUTF16(tool_tip).c_str(), _TRUNCATE);
+  wcsncpy_s(icon_data.szTip, base::UTF8ToWide(tool_tip).c_str(), _TRUNCATE);
   BOOL result = Shell_NotifyIcon(NIM_MODIFY, &icon_data);
   if (!result)
     LOG(WARNING) << "Unable to set tooltip for status tray icon";
@@ -151,8 +151,10 @@ void NotifyIcon::DisplayBalloon(const BalloonOptions& options) {
   NOTIFYICONDATA icon_data;
   InitIconData(&icon_data);
   icon_data.uFlags |= NIF_INFO;
-  wcsncpy_s(icon_data.szInfoTitle, options.title.c_str(), _TRUNCATE);
-  wcsncpy_s(icon_data.szInfo, options.content.c_str(), _TRUNCATE);
+  wcsncpy_s(icon_data.szInfoTitle, base::UTF16ToWide(options.title).c_str(),
+            _TRUNCATE);
+  wcsncpy_s(icon_data.szInfo, base::UTF16ToWide(options.content).c_str(),
+            _TRUNCATE);
   icon_data.uTimeout = 0;
   icon_data.hBalloonIcon = options.icon;
   icon_data.dwInfoFlags = ConvertIconType(options.icon_type);

+ 4 - 4
shell/browser/ui/win/taskbar_host.cc

@@ -104,7 +104,7 @@ bool TaskbarHost::SetThumbarButtons(HWND window,
     // Set tooltip.
     if (!button.tooltip.empty()) {
       thumb_button.dwMask |= THB_TOOLTIP;
-      wcsncpy_s(thumb_button.szTip, base::UTF8ToUTF16(button.tooltip).c_str(),
+      wcsncpy_s(thumb_button.szTip, base::UTF8ToWide(button.tooltip).c_str(),
                 _TRUNCATE);
     }
 
@@ -173,7 +173,7 @@ bool TaskbarHost::SetOverlayIcon(HWND window,
 
   base::win::ScopedHICON icon(IconUtil::CreateHICONFromSkBitmap(overlay));
   return SUCCEEDED(taskbar_->SetOverlayIcon(window, icon.get(),
-                                            base::UTF8ToUTF16(text).c_str()));
+                                            base::UTF8ToWide(text).c_str()));
 }
 
 bool TaskbarHost::SetThumbnailClip(HWND window, const gfx::Rect& region) {
@@ -193,8 +193,8 @@ bool TaskbarHost::SetThumbnailToolTip(HWND window, const std::string& tooltip) {
   if (!InitializeTaskbar())
     return false;
 
-  return SUCCEEDED(taskbar_->SetThumbnailTooltip(
-      window, base::UTF8ToUTF16(tooltip).c_str()));
+  return SUCCEEDED(
+      taskbar_->SetThumbnailTooltip(window, base::UTF8ToWide(tooltip).c_str()));
 }
 
 bool TaskbarHost::HandleThumbarButtonEvent(int button_id) {

+ 10 - 4
shell/browser/web_contents_preferences.cc

@@ -235,18 +235,24 @@ bool WebContentsPreferences::GetPreference(base::StringPiece name,
 bool WebContentsPreferences::GetPreloadPath(base::FilePath* path) const {
   DCHECK(path);
   base::FilePath::StringType preload_path;
-  if (GetAsString(&preference_, options::kPreloadScript, &preload_path)) {
-    base::FilePath preload(preload_path);
+  std::u16string preload_path_str;
+  if (GetAsString(&preference_, options::kPreloadScript, &preload_path_str)) {
+#if defined(OS_WIN)
+    base::FilePath preload(base::UTF16ToWide(preload_path_str));
+#else
+    base::FilePath preload(preload_path_str);
+#endif
     if (preload.IsAbsolute()) {
       *path = std::move(preload);
       return true;
     } else {
       LOG(ERROR) << "preload script must have absolute path.";
     }
-  } else if (GetAsString(&preference_, options::kPreloadURL, &preload_path)) {
+  } else if (GetAsString(&preference_, options::kPreloadURL,
+                         &preload_path_str)) {
     // Translate to file path if there is "preload-url" option.
     base::FilePath preload;
-    if (net::FileURLToFilePath(GURL(preload_path), &preload)) {
+    if (net::FileURLToFilePath(GURL(preload_path_str), &preload)) {
       *path = std::move(preload);
       return true;
     } else {

+ 1 - 1
shell/browser/web_dialog_helper.cc

@@ -86,7 +86,7 @@ file_dialog::Filters GetFileTypesFromAcceptType(
 
   for (const auto& extension : extensions) {
 #if defined(OS_WIN)
-    filters[0].second.push_back(base::UTF16ToASCII(extension));
+    filters[0].second.push_back(base::WideToASCII(extension));
 #else
     filters[0].second.push_back(extension);
 #endif

+ 1 - 1
shell/common/api/electron_api_native_image.cc

@@ -156,7 +156,7 @@ bool NativeImage::TryConvertNativeImage(v8::Isolate* isolate,
     *native_image = NativeImage::CreateFromPath(isolate, icon_path).get();
     if ((*native_image)->image().IsEmpty()) {
 #if defined(OS_WIN)
-      const auto img_path = base::UTF16ToUTF8(icon_path.value());
+      const auto img_path = base::WideToUTF8(icon_path.value());
 #else
       const auto img_path = icon_path.value();
 #endif

+ 1 - 1
shell/common/api/electron_api_native_image_win.cc

@@ -37,7 +37,7 @@ v8::Local<v8::Promise> NativeImage::CreateThumbnailFromPath(
 
   // create an IShellItem
   Microsoft::WRL::ComPtr<IShellItem> pItem;
-  std::wstring image_path = path.AsUTF16Unsafe();
+  std::wstring image_path = path.value();
   hr = SHCreateItemFromParsingName(image_path.c_str(), nullptr,
                                    IID_PPV_ARGS(&pItem));
 

+ 1 - 1
shell/common/api/electron_api_shell.cc

@@ -117,7 +117,7 @@ bool WriteShortcutLink(const base::FilePath& shortcut_path,
 
   base::win::ShortcutProperties properties;
   base::FilePath path;
-  std::u16string str;
+  std::wstring str;
   UUID toastActivatorClsid;
   int index;
   if (options.Get("target", &path))

+ 5 - 4
shell/common/application_info_win.cc

@@ -15,6 +15,7 @@
 #include "base/file_version_info.h"
 #include "base/notreached.h"
 #include "base/strings/string_util.h"
+#include "base/strings/string_util_win.h"
 #include "base/strings/stringprintf.h"
 #include "base/strings/utf_string_conversions.h"
 #include "shell/browser/win/scoped_hstring.h"
@@ -23,7 +24,7 @@ namespace electron {
 
 namespace {
 
-std::u16string g_app_user_model_id;
+std::wstring g_app_user_model_id;
 }
 
 const wchar_t kAppUserModelIDFormat[] = L"electron.app.$1";
@@ -42,7 +43,7 @@ std::string GetApplicationVersion() {
   return base::UTF16ToUTF8(info->product_version());
 }
 
-void SetAppUserModelID(const std::u16string& name) {
+void SetAppUserModelID(const std::wstring& name) {
   g_app_user_model_id = name;
   SetCurrentProcessExplicitAppUserModelID(g_app_user_model_id.c_str());
 }
@@ -54,8 +55,8 @@ PCWSTR GetRawAppUserModelID() {
       g_app_user_model_id = current_app_id;
     } else {
       std::string name = GetApplicationName();
-      std::u16string generated_app_id = base::ReplaceStringPlaceholders(
-          kAppUserModelIDFormat, base::UTF8ToUTF16(name), nullptr);
+      std::wstring generated_app_id = base::ReplaceStringPlaceholders(
+          kAppUserModelIDFormat, {base::UTF8ToWide(name)}, nullptr);
       SetAppUserModelID(generated_app_id);
     }
     CoTaskMemFree(current_app_id);

+ 1 - 0
shell/common/gin_converters/file_path_converter.h

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

+ 28 - 0
shell/common/gin_converters/std_converter.h

@@ -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_

+ 0 - 5
shell/common/language_util.h

@@ -14,11 +14,6 @@ namespace electron {
 // overrides from command line arguments.
 std::vector<std::string> GetPreferredLanguages();
 
-#if defined(OS_WIN)
-bool GetPreferredLanguagesUsingGlobalization(
-    std::vector<std::u16string>* languages);
-#endif
-
 }  // namespace electron
 
 #endif  // SHELL_COMMON_LANGUAGE_UTIL_H_

+ 17 - 17
shell/common/language_util_win.cc

@@ -16,24 +16,8 @@
 
 namespace electron {
 
-std::vector<std::string> GetPreferredLanguages() {
-  std::vector<std::u16string> languages16;
-
-  // Attempt to use API available on Windows 10 or later, which
-  // returns the full list of language preferences.
-  if (!GetPreferredLanguagesUsingGlobalization(&languages16)) {
-    base::win::i18n::GetThreadPreferredUILanguageList(&languages16);
-  }
-
-  std::vector<std::string> languages;
-  for (const auto& language : languages16) {
-    languages.push_back(base::SysWideToUTF8(language));
-  }
-  return languages;
-}
-
 bool GetPreferredLanguagesUsingGlobalization(
-    std::vector<std::u16string>* languages) {
+    std::vector<std::wstring>* languages) {
   if (base::win::GetVersion() < base::win::Version::WIN10)
     return false;
   if (!base::win::ResolveCoreWinRTDelayload() ||
@@ -73,4 +57,20 @@ bool GetPreferredLanguagesUsingGlobalization(
   return true;
 }
 
+std::vector<std::string> GetPreferredLanguages() {
+  std::vector<std::wstring> languages16;
+
+  // Attempt to use API available on Windows 10 or later, which
+  // returns the full list of language preferences.
+  if (!GetPreferredLanguagesUsingGlobalization(&languages16)) {
+    base::win::i18n::GetThreadPreferredUILanguageList(&languages16);
+  }
+
+  std::vector<std::string> languages;
+  for (const auto& language : languages16) {
+    languages.push_back(base::SysWideToUTF8(language));
+  }
+  return languages;
+}
+
 }  // namespace electron

+ 1 - 1
shell/common/node_bindings.cc

@@ -214,7 +214,7 @@ void SetNodeCliFlags() {
 
   for (const auto& arg : argv) {
 #if defined(OS_WIN)
-    const auto& option = base::UTF16ToUTF8(arg);
+    const auto& option = base::WideToUTF8(arg);
 #else
     const auto& option = arg;
 #endif

+ 2 - 2
shell/common/platform_util_win.cc

@@ -241,8 +241,8 @@ std::string OpenExternalOnWorkerThread(
   // Quote the input scheme to be sure that the command does not have
   // parameters unexpected by the external program. This url should already
   // have been escaped.
-  std::u16string escaped_url = L"\"" + base::UTF8ToUTF16(url.spec()) + L"\"";
-  std::u16string working_dir = options.working_dir.value();
+  std::wstring escaped_url = L"\"" + base::UTF8ToWide(url.spec()) + L"\"";
+  std::wstring working_dir = options.working_dir.value();
 
   if (reinterpret_cast<ULONG_PTR>(
           ShellExecuteW(nullptr, L"open", escaped_url.c_str(), nullptr,

+ 1 - 1
shell/renderer/renderer_client_base.cc

@@ -218,7 +218,7 @@ void RendererClientBase::RenderThreadStarted() {
 
 #if defined(OS_WIN)
   // Set ApplicationUserModelID in renderer process.
-  std::u16string app_id =
+  std::wstring app_id =
       command_line->GetSwitchValueNative(switches::kAppUserModelId);
   if (!app_id.empty()) {
     SetCurrentProcessExplicitAppUserModelID(app_id.c_str());