Convert WebPluginInfo from wstring to string16

BUG=None
TEST=No behavioral change; plugins should continue to work.

Review URL: http://codereview.chromium.org/2866014

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@50650 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc
index 8c4b5489..1630f14a 100644
--- a/chrome/browser/automation/automation_provider.cc
+++ b/chrome/browser/automation/automation_provider.cc
@@ -2105,10 +2105,10 @@
        it != plugins.end();
        ++it) {
     DictionaryValue* item = new DictionaryValue;
-    item->SetString(L"name", it->name);
+    item->SetStringFromUTF16(L"name", it->name);
     item->SetString(L"path", it->path.value());
-    item->SetString(L"version", it->version);
-    item->SetString(L"desc", it->desc);
+    item->SetStringFromUTF16(L"version", it->version);
+    item->SetStringFromUTF16(L"desc", it->desc);
     item->SetBoolean(L"enabled", it->enabled);
     // Add info about mime types.
     ListValue* mime_types = new ListValue();
@@ -2118,7 +2118,7 @@
          ++type_it) {
       DictionaryValue* mime_type = new DictionaryValue();
       mime_type->SetString(L"mimeType", type_it->mime_type);
-      mime_type->SetString(L"description", type_it->description);
+      mime_type->SetStringFromUTF16(L"description", type_it->description);
 
       ListValue* file_extensions = new ListValue();
       for (std::vector<std::string>::const_iterator ext_it =
diff --git a/chrome/browser/dom_ui/plugins_ui.cc b/chrome/browser/dom_ui/plugins_ui.cc
index b24a902..d14df5c 100644
--- a/chrome/browser/dom_ui/plugins_ui.cc
+++ b/chrome/browser/dom_ui/plugins_ui.cc
@@ -220,9 +220,9 @@
     const WebPluginInfo& plugin) {
   DictionaryValue* plugin_data = new DictionaryValue();
   plugin_data->SetString(L"path", plugin.path.value());
-  plugin_data->SetString(L"name", plugin.name);
-  plugin_data->SetString(L"version", plugin.version);
-  plugin_data->SetString(L"description", plugin.desc);
+  plugin_data->SetStringFromUTF16(L"name", plugin.name);
+  plugin_data->SetStringFromUTF16(L"version", plugin.version);
+  plugin_data->SetStringFromUTF16(L"description", plugin.desc);
   plugin_data->SetBoolean(L"enabled", plugin.enabled);
 
   ListValue* mime_types = new ListValue();
@@ -232,7 +232,7 @@
        ++type_it) {
     DictionaryValue* mime_type = new DictionaryValue();
     mime_type->SetString(L"mimeType", type_it->mime_type);
-    mime_type->SetString(L"description", type_it->description);
+    mime_type->SetStringFromUTF16(L"description", type_it->description);
 
     ListValue* file_extensions = new ListValue();
     for (std::vector<std::string>::const_iterator ext_it =
@@ -254,8 +254,8 @@
     const WebPluginInfo& plugin) {
   DictionaryValue* plugin_data = new DictionaryValue();
   plugin_data->SetString(L"path", plugin.path.value());
-  plugin_data->SetString(L"name", plugin.name);
-  plugin_data->SetString(L"version", plugin.version);
+  plugin_data->SetStringFromUTF16(L"name", plugin.name);
+  plugin_data->SetStringFromUTF16(L"version", plugin.version);
   plugin_data->SetBoolean(L"enabled", plugin.enabled);
   return plugin_data;
 }
diff --git a/chrome/browser/metrics/metrics_log.cc b/chrome/browser/metrics/metrics_log.cc
index f638857f..219d6864 100644
--- a/chrome/browser/metrics/metrics_log.cc
+++ b/chrome/browser/metrics/metrics_log.cc
@@ -244,10 +244,10 @@
 
     // Plugin name and filename are hashed for the privacy of those
     // testing unreleased new extensions.
-    WriteAttribute("name", CreateBase64Hash(WideToUTF8(iter->name)));
+    WriteAttribute("name", CreateBase64Hash(UTF16ToUTF8(iter->name)));
     WriteAttribute("filename",
         CreateBase64Hash(WideToUTF8(iter->path.BaseName().ToWStringHack())));
-    WriteAttribute("version", WideToUTF8(iter->version));
+    WriteAttribute("version", UTF16ToUTF8(iter->version));
   }
 }
 
diff --git a/chrome/browser/plugin_process_host.cc b/chrome/browser/plugin_process_host.cc
index e12a575..409d6c0 100644
--- a/chrome/browser/plugin_process_host.cc
+++ b/chrome/browser/plugin_process_host.cc
@@ -342,8 +342,8 @@
 bool PluginProcessHost::Init(const WebPluginInfo& info,
                              const std::wstring& locale) {
   info_ = info;
-  set_name(info_.name);
-  set_version(info_.version);
+  set_name(UTF16ToWideHack(info_.name));
+  set_version(UTF16ToWideHack(info_.version));
 
   if (!CreateChannel())
     return false;
diff --git a/chrome/plugin/plugin_thread.cc b/chrome/plugin/plugin_thread.cc
index 774780c..1ae410e 100644
--- a/chrome/plugin/plugin_thread.cc
+++ b/chrome/plugin/plugin_thread.cc
@@ -102,7 +102,7 @@
     plugin->NP_Initialize();
 
 #if defined(OS_MACOSX)
-    scoped_cftyperef<CFStringRef> plugin_name(base::SysWideToCFStringRef(
+    scoped_cftyperef<CFStringRef> plugin_name(base::SysUTF16ToCFStringRef(
         plugin->plugin_info().name));
     scoped_cftyperef<CFStringRef> app_name(base::SysUTF16ToCFStringRef(
         l10n_util::GetStringUTF16(IDS_SHORT_PLUGIN_APP_NAME)));
diff --git a/chrome/renderer/webplugin_delegate_proxy.cc b/chrome/renderer/webplugin_delegate_proxy.cc
index ab21bbe9..8b4068c7 100644
--- a/chrome/renderer/webplugin_delegate_proxy.cc
+++ b/chrome/renderer/webplugin_delegate_proxy.cc
@@ -342,8 +342,8 @@
   // expensive extra copy for us).
   if (!transparent_ && mime_type_ == "application/x-shockwave-flash") {
     bool force_opaque_mode = false;
-    if (StartsWith(info_.version, L"10.0", false) ||
-        StartsWith(info_.version, L"9.", false)) {
+    if (StartsWith(info_.version, ASCIIToUTF16("10.0"), false) ||
+        StartsWith(info_.version, ASCIIToUTF16("9."), false)) {
       // Older versions of Flash don't support CA (and they assume QuickDraw
       // support, so we can't rely on negotiation to do the right thing).
       force_opaque_mode = true;
@@ -1542,7 +1542,7 @@
   // Need to update geometry synchronously with WMP, otherwise if a site
   // scripts the plugin to start playing while it's in the middle of handling
   // an update geometry message, videos don't play.  See urls in bug 20260.
-  if (info_.name.find(L"Windows Media Player") != std::wstring::npos)
+  if (info_.name.find(ASCIIToUTF16("Windows Media Player")) != string16::npos)
     return true;
 
   // The move networks plugin needs to be informed of geometry updates
diff --git a/webkit/glue/plugins/plugin_host.cc b/webkit/glue/plugins/plugin_host.cc
index f1041994..87503a9f 100644
--- a/webkit/glue/plugins/plugin_host.cc
+++ b/webkit/glue/plugins/plugin_host.cc
@@ -577,8 +577,8 @@
     plugin = FindInstance(id);
   if (plugin.get()) {
     WebPluginInfo plugin_info = plugin->plugin_lib()->plugin_info();
-    if (plugin_info.name == L"Silverlight Plug-In" &&
-        StartsWith(plugin_info.version, L"4.", false)) {
+    if (plugin_info.name == ASCIIToUTF16("Silverlight Plug-In") &&
+        StartsWith(plugin_info.version, ASCIIToUTF16("4."), false)) {
       return "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; en-us) "
           "AppleWebKit/534.1+ (KHTML, like Gecko) Version/5.0 Safari/533.16";
     }
diff --git a/webkit/glue/plugins/plugin_lib_mac.mm b/webkit/glue/plugins/plugin_lib_mac.mm
index da9910d..263b3b48 100644
--- a/webkit/glue/plugins/plugin_lib_mac.mm
+++ b/webkit/glue/plugins/plugin_lib_mac.mm
@@ -97,7 +97,7 @@
     }
 
     if (mime_desc)
-      mime.description = base::SysNSStringToWide(mime_desc);
+      mime.description = base::SysNSStringToUTF16(mime_desc);
     for (NSString* ext in mime_exts)
       mime.file_extensions.push_back(
           base::SysNSStringToUTF8([ext lowercaseString]));
@@ -116,16 +116,16 @@
       CFSTR("WebPluginDescription"));
 
   if (plugin_name)
-    info->name = base::SysNSStringToWide(plugin_name);
+    info->name = base::SysNSStringToUTF16(plugin_name);
   else
-    info->name = UTF8ToWide(filename.BaseName().value());
+    info->name = UTF8ToUTF16(filename.BaseName().value());
   info->path = filename;
   if (plugin_vers)
-    info->version = base::SysNSStringToWide(plugin_vers);
+    info->version = base::SysNSStringToUTF16(plugin_vers);
   if (plugin_desc)
-    info->desc = base::SysNSStringToWide(plugin_desc);
+    info->desc = base::SysNSStringToUTF16(plugin_desc);
   else
-    info->desc = UTF8ToWide(filename.BaseName().value());
+    info->desc = UTF8ToUTF16(filename.BaseName().value());
   info->enabled = true;
 
   return true;
@@ -198,7 +198,7 @@
     WebPluginMimeType mime;
     mime.mime_type = StringToLowerASCII(type_strings[2*i]);
     if (have_type_descs && i < type_descs.size())
-      mime.description = UTF8ToWide(type_descs[i]);
+      mime.description = UTF8ToUTF16(type_descs[i]);
     SplitString(StringToLowerASCII(type_strings[2*i+1]), ',',
                 &mime.file_extensions);
 
@@ -210,16 +210,16 @@
       CFSTR("CFBundleShortVersionString"));
 
   if (have_plugin_descs && plugin_descs.size() > 1)
-    info->name = UTF8ToWide(plugin_descs[1]);
+    info->name = UTF8ToUTF16(plugin_descs[1]);
   else
-    info->name = UTF8ToWide(filename.BaseName().value());
+    info->name = UTF8ToUTF16(filename.BaseName().value());
   info->path = filename;
   if (plugin_vers)
-    info->version = base::SysNSStringToWide(plugin_vers);
+    info->version = base::SysNSStringToUTF16(plugin_vers);
   if (have_plugin_descs && plugin_descs.size() > 0)
-    info->desc = UTF8ToWide(plugin_descs[0]);
+    info->desc = UTF8ToUTF16(plugin_descs[0]);
   else
-    info->desc = UTF8ToWide(filename.BaseName().value());
+    info->desc = UTF8ToUTF16(filename.BaseName().value());
   info->enabled = true;
 
   return true;
diff --git a/webkit/glue/plugins/plugin_lib_posix.cc b/webkit/glue/plugins/plugin_lib_posix.cc
index 00e85e49..0bf7786 100644
--- a/webkit/glue/plugins/plugin_lib_posix.cc
+++ b/webkit/glue/plugins/plugin_lib_posix.cc
@@ -170,12 +170,12 @@
     const char* name = NULL;
     NP_GetValue(NULL, nsPluginVariable_NameString, &name);
     if (name)
-      info->name = UTF8ToWide(name);
+      info->name = UTF8ToUTF16(name);
 
     const char* description = NULL;
     NP_GetValue(NULL, nsPluginVariable_DescriptionString, &description);
     if (description)
-      info->desc = UTF8ToWide(description);
+      info->desc = UTF8ToUTF16(description);
   }
 
   // Intentionally not unloading the plugin here, it can lead to crashes.
@@ -216,9 +216,9 @@
     // It's ok for end to run off the string here.  If there's no
     // trailing semicolon we consume the remainder of the string.
     if (end != std::string::npos) {
-      mime_type.description = UTF8ToWide(description.substr(ofs, end - ofs));
+      mime_type.description = UTF8ToUTF16(description.substr(ofs, end - ofs));
     } else {
-      mime_type.description = UTF8ToWide(description.substr(ofs));
+      mime_type.description = UTF8ToUTF16(description.substr(ofs));
     }
     mime_types->push_back(mime_type);
     if (end == std::string::npos)
diff --git a/webkit/glue/plugins/plugin_lib_unittest.cc b/webkit/glue/plugins/plugin_lib_unittest.cc
index 720462936..a52510ba 100644
--- a/webkit/glue/plugins/plugin_lib_unittest.cc
+++ b/webkit/glue/plugins/plugin_lib_unittest.cc
@@ -4,6 +4,7 @@
 
 #include "webkit/glue/plugins/plugin_lib.h"
 
+#include "base/string_util.h"
 #include "build/build_config.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
@@ -68,7 +69,7 @@
   EXPECT_EQ("audio/x-pn-realaudio-plugin", type.mime_type);
   ASSERT_EQ(1U, type.file_extensions.size());
   EXPECT_EQ("rpm", type.file_extensions[0]);
-  EXPECT_EQ(L"RealAudio document", type.description);
+  EXPECT_EQ(ASCIIToUTF16("RealAudio document"), type.description);
 }
 
 // Test parsing a multi-entry description: QuickTime as provided by Totem.
@@ -89,7 +90,7 @@
   EXPECT_EQ("image/x-quicktime", type.mime_type);
   ASSERT_EQ(3U, type.file_extensions.size());
   EXPECT_EQ("pict2", type.file_extensions[2]);
-  EXPECT_EQ(L"QuickTime image", type.description);
+  EXPECT_EQ(ASCIIToUTF16("QuickTime image"), type.description);
 }
 
 // Test parsing a Japanese description, since we got this wrong in the past.
@@ -118,7 +119,7 @@
   EXPECT_EQ("mime/type", types[0].mime_type);
   EXPECT_EQ(1U, types[0].file_extensions.size());
   EXPECT_EQ("ext1", types[0].file_extensions[0]);
-  EXPECT_EQ(L"", types[0].description);
+  EXPECT_EQ(string16(), types[0].description);
 }
 
 // This Java plugin has embedded semicolons in the mime type.
@@ -141,7 +142,7 @@
 
   ASSERT_EQ(12U, types.size());
   for (size_t i = 0; i < types.size(); ++i)
-    EXPECT_EQ(L"IcedTea", types[i].description);
+    EXPECT_EQ(ASCIIToUTF16("IcedTea"), types[i].description);
 
   // Verify that the mime types with semis are coming through ok.
   EXPECT_TRUE(types[4].mime_type.find(';') != std::string::npos);
diff --git a/webkit/glue/plugins/plugin_list.cc b/webkit/glue/plugins/plugin_list.cc
index 487420ff..1d164ea 100644
--- a/webkit/glue/plugins/plugin_list.cc
+++ b/webkit/glue/plugins/plugin_list.cc
@@ -93,19 +93,19 @@
 bool PluginList::CreateWebPluginInfo(const PluginVersionInfo& pvi,
                                      WebPluginInfo* info) {
   std::vector<std::string> mime_types, file_extensions;
-  std::vector<std::wstring> descriptions;
+  std::vector<string16> descriptions;
   SplitString(WideToUTF8(pvi.mime_types), '|', &mime_types);
   SplitString(WideToUTF8(pvi.file_extensions), '|', &file_extensions);
-  SplitString(pvi.type_descriptions, '|', &descriptions);
+  SplitString(WideToUTF16(pvi.type_descriptions), '|', &descriptions);
 
   info->mime_types.clear();
 
   if (mime_types.empty())
     return false;
 
-  info->name = pvi.product_name;
-  info->desc = pvi.file_description;
-  info->version = pvi.file_version;
+  info->name = WideToUTF16(pvi.product_name);
+  info->desc = WideToUTF16(pvi.file_description);
+  info->version = WideToUTF16(pvi.file_version);
   info->path = pvi.path;
   info->enabled = true;
 
@@ -121,8 +121,8 @@
       // On Windows, the description likely has a list of file extensions
       // embedded in it (e.g. "SurfWriter file (*.swr)"). Remove an extension
       // list from the description if it is present.
-      size_t ext = mime_type.description.find(L"(*");
-      if (ext != std::wstring::npos) {
+      size_t ext = mime_type.description.find(ASCIIToUTF16("(*"));
+      if (ext != string16::npos) {
         if (ext > 1 && mime_type.description[ext -1] == ' ')
           ext--;
 
diff --git a/webkit/glue/plugins/webplugin_delegate_impl_mac.mm b/webkit/glue/plugins/webplugin_delegate_impl_mac.mm
index 23eefda..3bcff4c 100644
--- a/webkit/glue/plugins/webplugin_delegate_impl_mac.mm
+++ b/webkit/glue/plugins/webplugin_delegate_impl_mac.mm
@@ -317,7 +317,7 @@
     // TODO(stuartmorgan): Test other QuickDraw plugins that we support and
     // see if any others can use the fast path.
     const WebPluginInfo& plugin_info = instance_->plugin_lib()->plugin_info();
-    if (plugin_info.name.find(L"QuickTime") != std::wstring::npos)
+    if (plugin_info.name.find(ASCIIToUTF16("QuickTime")) != string16::npos)
       quirks_ |= PLUGIN_QUIRK_ALLOW_FASTER_QUICKDRAW_PATH;
   }
 #endif
@@ -410,7 +410,7 @@
 #ifndef NP_NO_QUICKDRAW
   if (instance()->drawing_model() == NPDrawingModelQuickDraw) {
     const WebPluginInfo& plugin_info = instance_->plugin_lib()->plugin_info();
-    if (plugin_info.name.find(L"QuickTime") != std::wstring::npos)
+    if (plugin_info.name.find(ASCIIToUTF16("QuickTime")) != string16::npos)
       WindowlessSetWindow();
   }
 #endif
diff --git a/webkit/glue/plugins/webplugininfo.h b/webkit/glue/plugins/webplugininfo.h
index 21f34df..9d2ab6e 100644
--- a/webkit/glue/plugins/webplugininfo.h
+++ b/webkit/glue/plugins/webplugininfo.h
@@ -20,22 +20,22 @@
   std::vector<std::string> file_extensions;
 
   // Description of the mime type.
-  std::wstring description;
+  string16 description;
 };
 
 // Describes an available NPAPI plugin.
 struct WebPluginInfo {
   // The name of the plugin (i.e. Flash).
-  std::wstring name;
+  string16 name;
 
   // The path to the plugin file (DLL/bundle/library).
   FilePath path;
 
   // The version number of the plugin file (may be OS-specific)
-  std::wstring version;
+  string16 version;
 
   // A description of the plugin that we get from its version info.
-  std::wstring desc;
+  string16 desc;
 
   // A list of all the mime types that this plugin supports.
   std::vector<WebPluginMimeType> mime_types;
diff --git a/webkit/glue/webkitclient_impl.cc b/webkit/glue/webkitclient_impl.cc
index ff0d93bc2..9808339 100644
--- a/webkit/glue/webkitclient_impl.cc
+++ b/webkit/glue/webkitclient_impl.cc
@@ -194,16 +194,14 @@
     const WebPluginInfo& plugin = plugins[i];
 
     builder->addPlugin(
-        WideToUTF16Hack(plugin.name),
-        WideToUTF16Hack(plugin.desc),
+        plugin.name, plugin.desc,
         FilePathStringToWebString(plugin.path.BaseName().value()));
 
     for (size_t j = 0; j < plugin.mime_types.size(); ++j) {
       const WebPluginMimeType& mime_type = plugin.mime_types[j];
 
       builder->addMediaTypeToLastPlugin(
-          WebString::fromUTF8(mime_type.mime_type),
-          WideToUTF16Hack(mime_type.description));
+          WebString::fromUTF8(mime_type.mime_type), mime_type.description);
 
       for (size_t k = 0; k < mime_type.file_extensions.size(); ++k) {
         builder->addFileExtensionToLastMediaType(