diff options
| author | jnd@google.com <jnd@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-21 02:58:09 +0000 | 
|---|---|---|
| committer | jnd@google.com <jnd@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-21 02:58:09 +0000 | 
| commit | 1a3ebe10ead2ca99d2beb45b9ec65a2863406184 (patch) | |
| tree | b1c8b11cc0a32e1f561362ecee1b488bf7d91b15 /chrome | |
| parent | aef050626d6412bffa292cbfcee23107cadc4b5d (diff) | |
| download | chromium_src-1a3ebe10ead2ca99d2beb45b9ec65a2863406184.zip chromium_src-1a3ebe10ead2ca99d2beb45b9ec65a2863406184.tar.gz chromium_src-1a3ebe10ead2ca99d2beb45b9ec65a2863406184.tar.bz2 | |
As Brett pointed it out, We normally use 8-bit for encoding names since they're always ASCII. Plus, wstrings will also be 32-bit characters on Linux and Mac, which is expensive. So I make this CL by using std::string instead of std::wstring every time you have an encoding name.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1144 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
32 files changed, 123 insertions, 118 deletions
| diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc index 2b2ee56..5bef039 100644 --- a/chrome/browser/browser.cc +++ b/chrome/browser/browser.cc @@ -536,7 +536,7 @@ void Browser::OpenURLFromTab(TabContents* source,                               const GURL& url,                               WindowOpenDisposition disposition,                               PageTransition::Type transition, -                             const std::wstring& override_encoding) { +                             const std::string& override_encoding) {    // No code for these yet    DCHECK((disposition != NEW_POPUP) && (disposition != SAVE_TO_DISK)); diff --git a/chrome/browser/browser.h b/chrome/browser/browser.h index 49d5518..de370e4 100644 --- a/chrome/browser/browser.h +++ b/chrome/browser/browser.h @@ -295,7 +295,7 @@ class Browser : public TabStripModelDelegate,                                const GURL& url,                                WindowOpenDisposition disposition,                                PageTransition::Type transition, -                              const std::wstring& override_encoding); +                              const std::string& override_encoding);    virtual void NavigationStateChanged(const TabContents* source,                                        unsigned changed_flags);    virtual void ReplaceContents(TabContents* source, TabContents* new_contents); diff --git a/chrome/browser/browser_commands.cc b/chrome/browser/browser_commands.cc index 0514dfb..8539cf2 100644 --- a/chrome/browser/browser_commands.cc +++ b/chrome/browser/browser_commands.cc @@ -650,7 +650,7 @@ void Browser::ExecuteCommand(int id) {      case IDC_ENCODING_WINDOWS1255:      case IDC_ENCODING_WINDOWS1258: {        UserMetrics::RecordAction(L"OverrideEncoding", profile_); -      const std::wstring cur_encoding_name = +      const std::string cur_encoding_name =            CharacterEncoding::GetCanonicalEncodingNameByCommandId(id);        TabContents* current_tab = GetSelectedTabContents();        if (!cur_encoding_name.empty() && current_tab) diff --git a/chrome/browser/character_encoding.cc b/chrome/browser/character_encoding.cc index 9e4404c..79cbc28 100644 --- a/chrome/browser/character_encoding.cc +++ b/chrome/browser/character_encoding.cc @@ -49,56 +49,56 @@ const int kUserSelectedEncodingsMaxLength = 3;  typedef struct {    int resource_id; -  const wchar_t* name; +  const char* name;    int category_string_id;  } CanonicalEncodingData;  // An array of all supported canonical encoding names.  static CanonicalEncodingData canonical_encoding_names[] = { -  { IDC_ENCODING_UTF8, L"UTF-8", IDS_ENCODING_UNICODE }, -  { IDC_ENCODING_UTF16LE, L"UTF-16LE", IDS_ENCODING_UNICODE }, -  { IDC_ENCODING_ISO88591, L"ISO-8859-1", IDS_ENCODING_WESTERN }, -  { IDC_ENCODING_WINDOWS1252, L"windows-1252", IDS_ENCODING_WESTERN }, -  { IDC_ENCODING_GB2312, L"GB2312", IDS_ENCODING_SIMP_CHINESE }, -  { IDC_ENCODING_GB18030, L"gb18030", IDS_ENCODING_SIMP_CHINESE }, -  { IDC_ENCODING_BIG5, L"Big5", IDS_ENCODING_TRAD_CHINESE }, -  { IDC_ENCODING_BIG5HKSCS, L"Big5-HKSCS", IDS_ENCODING_TRAD_CHINESE }, -  { IDC_ENCODING_KOREAN, L"EUC-KR", IDS_ENCODING_KOREAN }, -  { IDC_ENCODING_SHIFTJIS, L"Shift_JIS", IDS_ENCODING_JAPANESE }, -  { IDC_ENCODING_ISO2022JP, L"ISO-2022-JP", IDS_ENCODING_JAPANESE }, -  { IDC_ENCODING_EUCJP, L"EUC-JP", IDS_ENCODING_JAPANESE }, -  { IDC_ENCODING_THAI, L"TIS-620", IDS_ENCODING_THAI }, -  { IDC_ENCODING_ISO885915, L"ISO-8859-15", IDS_ENCODING_WESTERN }, -  { IDC_ENCODING_MACINTOSH, L"macintosh", IDS_ENCODING_WESTERN }, -  { IDC_ENCODING_ISO88592, L"ISO-8859-2", IDS_ENCODING_CENTRAL_EUROPEAN }, -  { IDC_ENCODING_WINDOWS1250, L"windows-1250", IDS_ENCODING_CENTRAL_EUROPEAN }, -  { IDC_ENCODING_ISO88595, L"ISO-8859-5", IDS_ENCODING_CYRILLIC }, -  { IDC_ENCODING_WINDOWS1251, L"windows-1251", IDS_ENCODING_CYRILLIC }, -  { IDC_ENCODING_KOI8R, L"KOI8-R", IDS_ENCODING_CYRILLIC }, -  { IDC_ENCODING_KOI8U, L"KOI8-U", IDS_ENCODING_CYRILLIC }, -  { IDC_ENCODING_ISO88597, L"ISO-8859-7", IDS_ENCODING_GREEK }, -  { IDC_ENCODING_WINDOWS1253, L"windows-1253", IDS_ENCODING_GREEK }, -  { IDC_ENCODING_ISO88599, L"ISO-8859-9", IDS_ENCODING_TURKISH }, -  { IDC_ENCODING_WINDOWS1254, L"windows-1254", IDS_ENCODING_TURKISH }, -  { IDC_ENCODING_ISO88596, L"ISO-8859-6", IDS_ENCODING_ARABIC }, -  { IDC_ENCODING_WINDOWS1256, L"windows-1256", IDS_ENCODING_ARABIC }, -  { IDC_ENCODING_ISO88598, L"ISO-8859-8", IDS_ENCODING_HEBREW }, -  { IDC_ENCODING_WINDOWS1255, L"windows-1255", IDS_ENCODING_HEBREW }, -  { IDC_ENCODING_WINDOWS1258, L"windows-1258", IDS_ENCODING_VIETNAMESE }, -  { IDC_ENCODING_ISO88594, L"ISO-8859-4", IDS_ENCODING_BALTIC }, -  { IDC_ENCODING_ISO885913, L"ISO-8859-13", IDS_ENCODING_BALTIC }, -  { IDC_ENCODING_WINDOWS1257, L"windows-1257", IDS_ENCODING_BALTIC }, -  { IDC_ENCODING_ISO88593, L"ISO-8859-3", IDS_ENCODING_SOUTH_EUROPEAN }, -  { IDC_ENCODING_ISO885910, L"ISO-8859-10", IDS_ENCODING_NORDIC }, -  { IDC_ENCODING_ISO885914, L"ISO-8859-14", IDS_ENCODING_CELTIC }, -  { IDC_ENCODING_ISO885916, L"ISO-8859-16", IDS_ENCODING_ROMANIAN }, +  { IDC_ENCODING_UTF8, "UTF-8", IDS_ENCODING_UNICODE }, +  { IDC_ENCODING_UTF16LE, "UTF-16LE", IDS_ENCODING_UNICODE }, +  { IDC_ENCODING_ISO88591, "ISO-8859-1", IDS_ENCODING_WESTERN }, +  { IDC_ENCODING_WINDOWS1252, "windows-1252", IDS_ENCODING_WESTERN }, +  { IDC_ENCODING_GB2312, "GB2312", IDS_ENCODING_SIMP_CHINESE }, +  { IDC_ENCODING_GB18030, "gb18030", IDS_ENCODING_SIMP_CHINESE }, +  { IDC_ENCODING_BIG5, "Big5", IDS_ENCODING_TRAD_CHINESE }, +  { IDC_ENCODING_BIG5HKSCS, "Big5-HKSCS", IDS_ENCODING_TRAD_CHINESE }, +  { IDC_ENCODING_KOREAN, "EUC-KR", IDS_ENCODING_KOREAN }, +  { IDC_ENCODING_SHIFTJIS, "Shift_JIS", IDS_ENCODING_JAPANESE }, +  { IDC_ENCODING_ISO2022JP, "ISO-2022-JP", IDS_ENCODING_JAPANESE }, +  { IDC_ENCODING_EUCJP, "EUC-JP", IDS_ENCODING_JAPANESE }, +  { IDC_ENCODING_THAI, "TIS-620", IDS_ENCODING_THAI }, +  { IDC_ENCODING_ISO885915, "ISO-8859-15", IDS_ENCODING_WESTERN }, +  { IDC_ENCODING_MACINTOSH, "macintosh", IDS_ENCODING_WESTERN }, +  { IDC_ENCODING_ISO88592, "ISO-8859-2", IDS_ENCODING_CENTRAL_EUROPEAN }, +  { IDC_ENCODING_WINDOWS1250, "windows-1250", IDS_ENCODING_CENTRAL_EUROPEAN }, +  { IDC_ENCODING_ISO88595, "ISO-8859-5", IDS_ENCODING_CYRILLIC }, +  { IDC_ENCODING_WINDOWS1251, "windows-1251", IDS_ENCODING_CYRILLIC }, +  { IDC_ENCODING_KOI8R, "KOI8-R", IDS_ENCODING_CYRILLIC }, +  { IDC_ENCODING_KOI8U, "KOI8-U", IDS_ENCODING_CYRILLIC }, +  { IDC_ENCODING_ISO88597, "ISO-8859-7", IDS_ENCODING_GREEK }, +  { IDC_ENCODING_WINDOWS1253, "windows-1253", IDS_ENCODING_GREEK }, +  { IDC_ENCODING_ISO88599, "ISO-8859-9", IDS_ENCODING_TURKISH }, +  { IDC_ENCODING_WINDOWS1254, "windows-1254", IDS_ENCODING_TURKISH }, +  { IDC_ENCODING_ISO88596, "ISO-8859-6", IDS_ENCODING_ARABIC }, +  { IDC_ENCODING_WINDOWS1256, "windows-1256", IDS_ENCODING_ARABIC }, +  { IDC_ENCODING_ISO88598, "ISO-8859-8", IDS_ENCODING_HEBREW }, +  { IDC_ENCODING_WINDOWS1255, "windows-1255", IDS_ENCODING_HEBREW }, +  { IDC_ENCODING_WINDOWS1258, "windows-1258", IDS_ENCODING_VIETNAMESE }, +  { IDC_ENCODING_ISO88594, "ISO-8859-4", IDS_ENCODING_BALTIC }, +  { IDC_ENCODING_ISO885913, "ISO-8859-13", IDS_ENCODING_BALTIC }, +  { IDC_ENCODING_WINDOWS1257, "windows-1257", IDS_ENCODING_BALTIC }, +  { IDC_ENCODING_ISO88593, "ISO-8859-3", IDS_ENCODING_SOUTH_EUROPEAN }, +  { IDC_ENCODING_ISO885910, "ISO-8859-10", IDS_ENCODING_NORDIC }, +  { IDC_ENCODING_ISO885914, "ISO-8859-14", IDS_ENCODING_CELTIC }, +  { IDC_ENCODING_ISO885916, "ISO-8859-16", IDS_ENCODING_ROMANIAN },  };  static const int canonical_encoding_names_length =      arraysize(canonical_encoding_names); -typedef std::map<int, std::pair<const wchar_t*, int> > IdToCanonicalEncodingNameMapType; -typedef std::map<const std::wstring, int> CanonicalEncodingNameToIdMapType; +typedef std::map<int, std::pair<const char*, int> > IdToCanonicalEncodingNameMapType; +typedef std::map<const std::string, int> CanonicalEncodingNameToIdMapType;  class CanonicalEncodingMap {   public: @@ -159,7 +159,7 @@ static CanonicalEncodingMap canonical_encoding_name_map_singleton;  // Get encoding command id according to input encoding name. If the name is  // valid, return corresponding encoding command id. Otherwise return 0;  static int GetCommandIdByCanonicalEncodingName( -    const std::wstring& encoding_name) { +    const std::string& encoding_name) {    const CanonicalEncodingNameToIdMapType* map =        canonical_encoding_name_map_singleton.            GetCanonicalEncodingNameToIdMapData(); @@ -231,7 +231,8 @@ static void ParseEncodingListSeparatedWithComma(      size_t maximum_size) {    WStringTokenizer tokenizer(encoding_list, L",");    while (tokenizer.GetNext()) { -    int id = GetCommandIdByCanonicalEncodingName(tokenizer.token()); +    std::string valid_encoding = WideToUTF8(tokenizer.token()); +    int id = GetCommandIdByCanonicalEncodingName(valid_encoding);      // Ignore invalid encoding.      if (!id)        continue; @@ -241,14 +242,14 @@ static void ParseEncodingListSeparatedWithComma(    }  } -std::wstring GetEncodingDisplayName(std::wstring encoding_name, +std::wstring GetEncodingDisplayName(std::string encoding_name,                                      int category_string_id) {    std::wstring category_name = l10n_util::GetString(category_string_id);    if (category_string_id != IDS_ENCODING_KOREAN &&        category_string_id != IDS_ENCODING_THAI) {      return l10n_util::GetStringF(IDS_ENCODING_DISPLAY_TEMPLATE,                                   category_name, -                                 encoding_name); +                                 UTF8ToWide(encoding_name));    }    return category_name;  } @@ -256,7 +257,7 @@ std::wstring GetEncodingDisplayName(std::wstring encoding_name,  }  // namespace  // Static. -std::wstring CharacterEncoding::GetCanonicalEncodingNameByCommandId(int id) { +std::string CharacterEncoding::GetCanonicalEncodingNameByCommandId(int id) {    const IdToCanonicalEncodingNameMapType* map =        canonical_encoding_name_map_singleton.            GetIdToCanonicalEncodingNameMapData(); @@ -265,7 +266,7 @@ std::wstring CharacterEncoding::GetCanonicalEncodingNameByCommandId(int id) {    IdToCanonicalEncodingNameMapType::const_iterator found_name = map->find(id);    if (found_name != map->end())      return found_name->second.first; -  return std::wstring(); +  return std::string();  }  // Static. @@ -290,10 +291,10 @@ int CharacterEncoding::GetSupportCanonicalEncodingCount() {  }  // Static. -std::wstring CharacterEncoding::GetCanonicalEncodingNameByIndex(int index) { +std::string CharacterEncoding::GetCanonicalEncodingNameByIndex(int index) {    if (index < canonical_encoding_names_length)      return canonical_encoding_names[index].name; -  return std::wstring(); +  return std::string();  }  // Static. @@ -306,8 +307,8 @@ std::wstring CharacterEncoding::GetCanonicalEncodingDisplayNameByIndex(  }  // Static. -std::wstring CharacterEncoding::GetCanonicalEncodingNameByAliasName( -    const std::wstring& alias_name) { +std::string CharacterEncoding::GetCanonicalEncodingNameByAliasName( +    const std::string& alias_name) {    // If the input alias_name is already canonical encoding name, just return it.    const CanonicalEncodingNameToIdMapType* map =        canonical_encoding_name_map_singleton. @@ -321,19 +322,18 @@ std::wstring CharacterEncoding::GetCanonicalEncodingNameByAliasName(    UErrorCode error_code = U_ZERO_ERROR; -  const char* canonical_name = ucnv_getCanonicalName( -      WideToASCII(alias_name).c_str(), "MIME", &error_code); +  const char* canonical_name = ucnv_getCanonicalName(alias_name.c_str(), +                                                     "MIME", +                                                     &error_code);    // If failed,  then try IANA next.    if (U_FAILURE(error_code) || !canonical_name) {      error_code = U_ZERO_ERROR; -    canonical_name = ucnv_getCanonicalName( -      WideToASCII(alias_name).c_str(), "IANA", &error_code); +    canonical_name = ucnv_getCanonicalName(alias_name.c_str(), +                                           "IANA", +                                           &error_code);    } -  if (canonical_name) -    return ASCIIToWide(canonical_name); -  else -    return std::wstring(); +  return std::string(canonical_name);  }  // Static @@ -420,7 +420,7 @@ bool CharacterEncoding::UpdateRecentlySelectdEncoding(      int new_selected_encoding_id,      std::wstring* selected_encodings) {    // Get encoding name. -  std::wstring encoding_name = +  std::string encoding_name =        GetCanonicalEncodingNameByCommandId(new_selected_encoding_id);    DCHECK(!encoding_name.empty());    // Check whether the new encoding is in local dependent encodings or original @@ -449,12 +449,13 @@ bool CharacterEncoding::UpdateRecentlySelectdEncoding(    if (selected_encoding_list.size() == kUserSelectedEncodingsMaxLength)      selected_encoding_list.pop_back();    // Insert new encoding to head of selected encoding list. -  *selected_encodings = encoding_name; +  selected_encodings->append(UTF8ToWide(encoding_name));    // Generate the string for rest selected encoding list.    for (std::vector<int>::const_iterator it = selected_encoding_list.begin();         it != selected_encoding_list.end(); ++it) {      selected_encodings->append(1, L','); -    selected_encodings->append(GetCanonicalEncodingNameByCommandId(*it)); +    selected_encodings->append( +        UTF8ToWide(GetCanonicalEncodingNameByCommandId(*it)));    }    return true;  } diff --git a/chrome/browser/character_encoding.h b/chrome/browser/character_encoding.h index 29120d6..8ff13d8 100644 --- a/chrome/browser/character_encoding.h +++ b/chrome/browser/character_encoding.h @@ -45,7 +45,7 @@ class CharacterEncoding {    // Return canonical encoding name according to the command ID.    // THIS FUNCTION IS NOT THREADSAFE. You must run this function    // only in UI thread. -  static std::wstring GetCanonicalEncodingNameByCommandId(int id); +  static std::string GetCanonicalEncodingNameByCommandId(int id);    // Return display name of canonical encoding according to the command    // ID. THIS FUNCTION IS NOT THREADSAFE. You must run this function @@ -58,7 +58,7 @@ class CharacterEncoding {    // Return canonical encoding name according to the index, which starts    // from zero to GetSupportCanonicalEncodingCount() - 1. THIS FUNCTION    // IS NOT THREADSAFE. You must run this function only in UI thread. -  static std::wstring GetCanonicalEncodingNameByIndex(int index); +  static std::string GetCanonicalEncodingNameByIndex(int index);    // Return display name of canonical encoding according to the index,    // which starts from zero to GetSupportCanonicalEncodingCount() - 1. @@ -68,8 +68,8 @@ class CharacterEncoding {    // Return canonical encoding name according to the encoding alias name. THIS    // FUNCTION IS NOT THREADSAFE. You must run this function only in UI thread. -  static std::wstring GetCanonicalEncodingNameByAliasName( -      const std::wstring& alias_name); +  static std::string GetCanonicalEncodingNameByAliasName( +      const std::string& alias_name);    // Returns the pointer of a vector of command ids corresponding to    // encodings to display in the encoding menu. The list begins with diff --git a/chrome/browser/debugger/debugger_view.cc b/chrome/browser/debugger/debugger_view.cc index 46bdbdb..dcf390e 100644 --- a/chrome/browser/debugger/debugger_view.cc +++ b/chrome/browser/debugger/debugger_view.cc @@ -156,7 +156,7 @@ void DebuggerView::OpenURLFromTab(TabContents* source,                                    const GURL& url,                                    WindowOpenDisposition disposition,                                    PageTransition::Type transition, -                                  const std::wstring& override_encoding) { +                                  const std::string& override_encoding) {    BrowserList::GetLastActive()->OpenURL(url, disposition, transition);  } diff --git a/chrome/browser/debugger/debugger_view.h b/chrome/browser/debugger/debugger_view.h index 16213ed..0b04261 100644 --- a/chrome/browser/debugger/debugger_view.h +++ b/chrome/browser/debugger/debugger_view.h @@ -85,7 +85,7 @@ class DebuggerView : public ChromeViews::View,                                const GURL& url,                                WindowOpenDisposition disposition,                                PageTransition::Type transition, -                              const std::wstring& override_encoding); +                              const std::string& override_encoding);    // Overridden from TabContentsDelegate:    virtual void NavigationStateChanged(const TabContents* source, diff --git a/chrome/browser/encoding_menu_controller_delegate.cc b/chrome/browser/encoding_menu_controller_delegate.cc index 8ebd8d8..7892920 100644 --- a/chrome/browser/encoding_menu_controller_delegate.cc +++ b/chrome/browser/encoding_menu_controller_delegate.cc @@ -53,9 +53,11 @@ bool EncodingMenuControllerDelegate::IsItemChecked(int id) const {    TabContents* current_tab = browser_->GetSelectedTabContents();    if (!current_tab)      return false; -  std::wstring encoding_name = current_tab->GetEncoding(); -  if (encoding_name.empty()) -    encoding_name = profile->GetPrefs()->GetString(prefs::kDefaultCharset); +  std::string encoding_name = current_tab->GetEncoding(); +  if (encoding_name.empty()) { +    encoding_name = WideToUTF8( +        profile->GetPrefs()->GetString(prefs::kDefaultCharset)); +  }    switch (id) {      case IDC_ENCODING_AUTO_DETECT:        return profile->GetPrefs()->GetBoolean( diff --git a/chrome/browser/external_tab_container.cc b/chrome/browser/external_tab_container.cc index bb56384..bc25861 100644 --- a/chrome/browser/external_tab_container.cc +++ b/chrome/browser/external_tab_container.cc @@ -154,7 +154,7 @@ void ExternalTabContainer::OpenURLFromTab(      const GURL& url,      WindowOpenDisposition disposition,      PageTransition::Type transition, -    const std::wstring& override_encoding) { +    const std::string& override_encoding) {    switch (disposition) {      case CURRENT_TAB:      case NEW_FOREGROUND_TAB: diff --git a/chrome/browser/external_tab_container.h b/chrome/browser/external_tab_container.h index 7bfb213..304d179 100644 --- a/chrome/browser/external_tab_container.h +++ b/chrome/browser/external_tab_container.h @@ -81,7 +81,7 @@ class ExternalTabContainer : public TabContentsDelegate,                                const GURL& url,                                WindowOpenDisposition disposition,                                PageTransition::Type transition, -                              const std::wstring& override_encoding); +                              const std::string& override_encoding);    virtual void NavigationStateChanged(const TabContents* source,                                        unsigned changed_flags);    virtual void ReplaceContents(TabContents* source, TabContents* new_contents); diff --git a/chrome/browser/navigation_controller_unittest.cc b/chrome/browser/navigation_controller_unittest.cc index d815a54..53733be 100644 --- a/chrome/browser/navigation_controller_unittest.cc +++ b/chrome/browser/navigation_controller_unittest.cc @@ -157,7 +157,7 @@ class NavigationControllerTest : public testing::Test,                                const GURL&,                                WindowOpenDisposition,                                PageTransition::Type, -                              const std::wstring& override_encoding) {} +                              const std::string& override_encoding) {}    virtual void NavigationStateChanged(const TabContents*,                                        unsigned flags) {}    virtual void ReplaceContents(TabContents* source, diff --git a/chrome/browser/render_view_context_menu_controller.cc b/chrome/browser/render_view_context_menu_controller.cc index c4ec6ad..d5121f32 100644 --- a/chrome/browser/render_view_context_menu_controller.cc +++ b/chrome/browser/render_view_context_menu_controller.cc @@ -71,7 +71,7 @@ void RenderViewContextMenuController::OpenURLWithOverrideEncoding(      const GURL& url,      WindowOpenDisposition disposition,      PageTransition::Type transition, -    const std::wstring& override_encoding) { +    const std::string& override_encoding) {    source_web_contents_->OpenURLWithOverrideEncoding(url, disposition,        transition, override_encoding);  } diff --git a/chrome/browser/render_view_context_menu_controller.h b/chrome/browser/render_view_context_menu_controller.h index 3817dd6..bdb7ecd 100644 --- a/chrome/browser/render_view_context_menu_controller.h +++ b/chrome/browser/render_view_context_menu_controller.h @@ -59,7 +59,7 @@ class RenderViewContextMenuController : public Menu::Delegate {    void OpenURLWithOverrideEncoding(const GURL& url,                                     WindowOpenDisposition disposition,                                     PageTransition::Type transition, -                                   const std::wstring& override_encoding); +                                   const std::string& override_encoding);    // Copy to the clipboard an image located at a point in the RenderView    void CopyImageAt(int x, int y); diff --git a/chrome/browser/render_view_host.cc b/chrome/browser/render_view_host.cc index 4db7793..0a6912b 100644 --- a/chrome/browser/render_view_host.cc +++ b/chrome/browser/render_view_host.cc @@ -351,7 +351,7 @@ void RenderViewHost::AlterTextSize(text_zoom::TextSize size) {    Send(new ViewMsg_AlterTextSize(routing_id_, size));  } -void RenderViewHost::SetPageEncoding(const std::wstring& encoding_name) { +void RenderViewHost::SetPageEncoding(const std::string& encoding_name) {    Send(new ViewMsg_SetPageEncoding(routing_id_, encoding_name));  } @@ -850,7 +850,7 @@ void RenderViewHost::OnMsgUpdateTitle(int32 page_id,    delegate_->UpdateTitle(this, page_id, title);  } -void RenderViewHost::OnMsgUpdateEncoding(const std::wstring& encoding_name) { +void RenderViewHost::OnMsgUpdateEncoding(const std::string& encoding_name) {    delegate_->UpdateEncoding(this, encoding_name);  } diff --git a/chrome/browser/render_view_host.h b/chrome/browser/render_view_host.h index 7b9f593..dcba399 100644 --- a/chrome/browser/render_view_host.h +++ b/chrome/browser/render_view_host.h @@ -217,7 +217,7 @@ class RenderViewHost : public RenderWidgetHost {    void AlterTextSize(text_zoom::TextSize size);    // Change the encoding of the page. -  void SetPageEncoding(const std::wstring& encoding_name); +  void SetPageEncoding(const std::string& encoding_name);    // Change the alternate error page URL.  An empty GURL disables the use of    // alternate error pages. @@ -429,7 +429,7 @@ class RenderViewHost : public RenderWidgetHost {                          const std::wstring& title,                          const std::string& state);    void OnMsgUpdateTitle(int32 page_id, const std::wstring& title); -  void OnMsgUpdateEncoding(const std::wstring& encoding_name); +  void OnMsgUpdateEncoding(const std::string& encoding_name);    void OnMsgUpdateTargetURL(int32 page_id, const GURL& url);    void OnMsgThumbnail(const IPC::Message& msg);    void OnMsgClose(); diff --git a/chrome/browser/render_view_host_delegate.h b/chrome/browser/render_view_host_delegate.h index c6cc9a2..7a1b2fb 100644 --- a/chrome/browser/render_view_host_delegate.h +++ b/chrome/browser/render_view_host_delegate.h @@ -132,7 +132,7 @@ class RenderViewHostDelegate {    // The page's encoding was changed and should be updated.    virtual void UpdateEncoding(RenderViewHost* render_view_host, -                              const std::wstring& encoding_name) { } +                              const std::string& encoding_name) { }    // The destination URL has changed should be updated    virtual void UpdateTargetURL(int32 page_id, const GURL& url) { } diff --git a/chrome/browser/tab_contents.cc b/chrome/browser/tab_contents.cc index 3edd315..abb23a0 100644 --- a/chrome/browser/tab_contents.cc +++ b/chrome/browser/tab_contents.cc @@ -428,7 +428,7 @@ void TabContents::OpenURLWithOverrideEncoding(      const GURL& url,      WindowOpenDisposition disposition,      PageTransition::Type transition, -    const std::wstring& override_encoding) { +    const std::string& override_encoding) {    if (delegate_) {      delegate_->OpenURLFromTab(this, url, disposition, transition,                                override_encoding); @@ -440,7 +440,7 @@ void TabContents::OpenURL(const GURL& url,                            PageTransition::Type transition) {    if (delegate_) {      delegate_->OpenURLFromTab(this, url, disposition, transition, -                              std::wstring()); +                              std::string());    }  } diff --git a/chrome/browser/tab_contents.h b/chrome/browser/tab_contents.h index 2b3338a..d97756b 100644 --- a/chrome/browser/tab_contents.h +++ b/chrome/browser/tab_contents.h @@ -284,7 +284,7 @@ class TabContents : public PageNavigator,    virtual void SetEncodingAutoDetector(bool encoding_auto_detector) { }    // Asynchronous call to change page encoding. -  virtual void SetPageEncoding(const std::wstring& encoding_name) { } +  virtual void SetPageEncoding(const std::string& encoding_name) { }    // Return whether this tab contents is loading a resource.    bool is_loading() const { return is_loading_; } @@ -377,7 +377,7 @@ class TabContents : public PageNavigator,        const GURL& url,        WindowOpenDisposition disposition,        PageTransition::Type transition, -      const std::wstring& override_encoding); +      const std::string& override_encoding);    // NotificationObserver implementation.    virtual void Observe(NotificationType type, @@ -437,8 +437,8 @@ class TabContents : public PageNavigator,    // Returns a human-readable description the tab's loading state.    virtual std::wstring GetStatusText() const { return std::wstring(); } -  const std::wstring& GetEncoding() { return encoding_name_; } -  void SetEncoding(const std::wstring& encoding_name) { +  const std::string& GetEncoding() { return encoding_name_; } +  void SetEncoding(const std::string& encoding_name) {      encoding_name_ = encoding_name;    } @@ -563,7 +563,7 @@ class TabContents : public PageNavigator,    // The id used in the ViewStorage to store the last focused view.    int last_focused_view_storage_id_; -  std::wstring encoding_name_; +  std::string encoding_name_;  };  #endif  // CHROME_BROWSER_TAB_CONTENTS_H_ diff --git a/chrome/browser/tab_contents_delegate.h b/chrome/browser/tab_contents_delegate.h index 2b94e34..2b8b6cf 100644 --- a/chrome/browser/tab_contents_delegate.h +++ b/chrome/browser/tab_contents_delegate.h @@ -54,12 +54,12 @@ class TabContentsDelegate : public PageNavigator {                                const GURL& url,                                WindowOpenDisposition disposition,                                PageTransition::Type transition, -                              const std::wstring& override_encoding) = 0; +                              const std::string& override_encoding) = 0;    virtual void OpenURL(const GURL& url,                         WindowOpenDisposition disposition,                         PageTransition::Type transition) { -    OpenURLFromTab(NULL, url, disposition, transition, std::wstring()); +    OpenURLFromTab(NULL, url, disposition, transition, std::string());    }    // Called to inform the delegate that the tab content's navigation state diff --git a/chrome/browser/tabs/dragged_tab_controller.cc b/chrome/browser/tabs/dragged_tab_controller.cc index cdfb8df..eca0438 100644 --- a/chrome/browser/tabs/dragged_tab_controller.cc +++ b/chrome/browser/tabs/dragged_tab_controller.cc @@ -171,7 +171,7 @@ void DraggedTabController::OpenURLFromTab(      const GURL& url,      WindowOpenDisposition disposition,      PageTransition::Type transition, -    const std::wstring& override_encoding) { +    const std::string& override_encoding) {    if (original_delegate_) {      if (disposition == CURRENT_TAB)        disposition = NEW_WINDOW; diff --git a/chrome/browser/tabs/dragged_tab_controller.h b/chrome/browser/tabs/dragged_tab_controller.h index e95776d..bc961f2 100644 --- a/chrome/browser/tabs/dragged_tab_controller.h +++ b/chrome/browser/tabs/dragged_tab_controller.h @@ -107,7 +107,7 @@ class DraggedTabController : public TabContentsDelegate,                                const GURL& url,                                WindowOpenDisposition disposition,                                PageTransition::Type transition, -                              const std::wstring& override_encoding); +                              const std::string& override_encoding);    virtual void NavigationStateChanged(const TabContents* source,                                        unsigned changed_flags);    virtual void ReplaceContents(TabContents* source, diff --git a/chrome/browser/views/constrained_window_impl.cc b/chrome/browser/views/constrained_window_impl.cc index cfcdee0..44dc92f 100644 --- a/chrome/browser/views/constrained_window_impl.cc +++ b/chrome/browser/views/constrained_window_impl.cc @@ -1046,7 +1046,7 @@ void ConstrainedWindowImpl::OpenURLFromTab(      const GURL& url,      WindowOpenDisposition disposition,      PageTransition::Type transition, -    const std::wstring& override_encoding) { +    const std::string& override_encoding) {    // We ignore source right now.    owner_->OpenURL(this, url, disposition, transition);  } diff --git a/chrome/browser/views/constrained_window_impl.h b/chrome/browser/views/constrained_window_impl.h index a91586b..987c970 100644 --- a/chrome/browser/views/constrained_window_impl.h +++ b/chrome/browser/views/constrained_window_impl.h @@ -81,7 +81,7 @@ class ConstrainedWindowImpl : public ConstrainedWindow,                                const GURL& url,                                WindowOpenDisposition disposition,                                PageTransition::Type transition, -                              const std::wstring& override_encoding); +                              const std::string& override_encoding);    // Overridden from TabContentsDelegate:    virtual void NavigationStateChanged(const TabContents* source, diff --git a/chrome/browser/views/html_dialog_view.cc b/chrome/browser/views/html_dialog_view.cc index 07f89c4..99f9748 100644 --- a/chrome/browser/views/html_dialog_view.cc +++ b/chrome/browser/views/html_dialog_view.cc @@ -111,7 +111,7 @@ void HtmlDialogView::OpenURLFromTab(TabContents* source,                                      const GURL& url,                                      WindowOpenDisposition disposition,                                      PageTransition::Type transition, -                                    const std::wstring& override_encoding) { +                                    const std::string& override_encoding) {    // Force all links to open in a new window, ignoring the incoming    // disposition. This is a tabless, modal dialog so we can't just    // open it in the current frame. diff --git a/chrome/browser/views/html_dialog_view.h b/chrome/browser/views/html_dialog_view.h index 51e9abb..b96b79d 100644 --- a/chrome/browser/views/html_dialog_view.h +++ b/chrome/browser/views/html_dialog_view.h @@ -83,7 +83,7 @@ class HtmlDialogView                                const GURL& url,                                WindowOpenDisposition disposition,                                PageTransition::Type transition, -                              const std::wstring& override_encoding); +                              const std::string& override_encoding);    virtual void NavigationStateChanged(const TabContents* source,                                        unsigned changed_flags);    virtual void ReplaceContents(TabContents* source, diff --git a/chrome/browser/views/options/fonts_page_view.cc b/chrome/browser/views/options/fonts_page_view.cc index 0241cc0..8307933 100644 --- a/chrome/browser/views/options/fonts_page_view.cc +++ b/chrome/browser/views/options/fonts_page_view.cc @@ -80,7 +80,8 @@ class DefaultEncodingComboboxModel : public ChromeViews::ComboBox::Model {    std::wstring GetEncodingCharsetByIndex(int index) {      DCHECK(index >= 0 && canonical_encoding_names_length_ > index); -    return CharacterEncoding::GetCanonicalEncodingNameByIndex(index); +    return UTF8ToWide( +        CharacterEncoding::GetCanonicalEncodingNameByIndex(index));    }    int GetSelectedEncodingIndex(Profile* profile) { @@ -88,7 +89,8 @@ class DefaultEncodingComboboxModel : public ChromeViews::ComboBox::Model {      current_encoding_string.Init(prefs::kDefaultCharset,                                   profile->GetPrefs(),                                   NULL); -    const std::wstring current_encoding = current_encoding_string.GetValue(); +    const std::string current_encoding = +        WideToUTF8(current_encoding_string.GetValue());      for (int i = 0; i < canonical_encoding_names_length_; i++) {        if (CharacterEncoding::GetCanonicalEncodingNameByIndex(i) ==            current_encoding) diff --git a/chrome/browser/web_contents.cc b/chrome/browser/web_contents.cc index 79593c9..ccaf94d 100644 --- a/chrome/browser/web_contents.cc +++ b/chrome/browser/web_contents.cc @@ -757,7 +757,7 @@ void WebContents::AlterTextSize(text_zoom::TextSize size) {    // TODO(creis): should this be propagated to other and future RVHs?  } -void WebContents::SetPageEncoding(const std::wstring& encoding_name) { +void WebContents::SetPageEncoding(const std::string& encoding_name) {    render_view_host()->SetPageEncoding(encoding_name);    // TODO(creis): should this be propagated to other and future RVHs?  } @@ -1729,7 +1729,7 @@ void WebContents::UpdateTitle(RenderViewHost* rvh,  void WebContents::UpdateEncoding(RenderViewHost* render_view_host, -                                 const std::wstring& encoding_name) { +                                 const std::string& encoding_name) {    SetEncoding(encoding_name);  } @@ -2170,9 +2170,9 @@ WebPreferences WebContents::GetWebkitPrefs() {    // webkit/glue/webpreferences.h for more details.    // Make sure we will set the default_encoding with canonical encoding name. -  web_prefs.default_encoding = +  web_prefs.default_encoding = UTF8ToWide(        CharacterEncoding::GetCanonicalEncodingNameByAliasName( -          web_prefs.default_encoding); +          WideToUTF8(web_prefs.default_encoding)));    if (web_prefs.default_encoding.empty()) {      prefs->ClearPref(prefs::kDefaultCharset);      web_prefs.default_encoding = prefs->GetString( diff --git a/chrome/browser/web_contents.h b/chrome/browser/web_contents.h index 865cfab..d6bc129 100644 --- a/chrome/browser/web_contents.h +++ b/chrome/browser/web_contents.h @@ -118,7 +118,7 @@ class WebContents : public TabContents,    virtual void AlterTextSize(text_zoom::TextSize size);    // Change encoding of page. -  virtual void SetPageEncoding(const std::wstring& encoding_name); +  virtual void SetPageEncoding(const std::string& encoding_name);    bool is_starred() const { return is_starred_; } @@ -359,7 +359,7 @@ class WebContents : public TabContents,    // Returns true if this WebContents will notify about disconnection.    bool notify_disconnection() const { return notify_disconnection_; } -  void set_override_encoding(const std::wstring& override_encoding) { +  void set_override_encoding(const std::string& override_encoding) {      override_encoding_ = override_encoding;    } @@ -394,7 +394,7 @@ class WebContents : public TabContents,                             int32 page_id,                             const std::wstring& title);    virtual void UpdateEncoding(RenderViewHost* render_view_host, -                              const std::wstring& encoding_name); +                              const std::string& encoding_name);    virtual void UpdateTargetURL(int32 page_id, const GURL& url);    virtual void UpdateThumbnail(const GURL& url,                                 const SkBitmap& bitmap, @@ -827,7 +827,7 @@ class WebContents : public TabContents,    scoped_refptr<WebApp> web_app_;    // Specified encoding which is used to override current tab's encoding. -  std::wstring override_encoding_; +  std::string override_encoding_;    DISALLOW_COPY_AND_ASSIGN(WebContents);  }; diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h index 5ef5cd0..3e72ea7 100644 --- a/chrome/common/render_messages.h +++ b/chrome/common/render_messages.h @@ -177,7 +177,7 @@ struct ViewHostMsg_ContextMenu_Params {    int edit_flags;    // |frame_encoding|indicates the encoding of current focused sub frame. -  std::wstring frame_encoding; +  std::string frame_encoding;  };  // Values that may be OR'd together to form the 'flags' parameter of a diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h index a8251a0..7ce3daf 100644 --- a/chrome/common/render_messages_internal.h +++ b/chrome/common/render_messages_internal.h @@ -248,7 +248,7 @@ IPC_BEGIN_MESSAGES(View, 1)    // Change encoding of page in the renderer.    IPC_MESSAGE_ROUTED1(ViewMsg_SetPageEncoding, -                      std::wstring /*new encoding name*/) +                      std::string /*new encoding name*/)    // Inspect the element at the specified coordinates    IPC_MESSAGE_ROUTED2(ViewMsg_InspectElement, @@ -541,7 +541,7 @@ IPC_BEGIN_MESSAGES(ViewHost, 2)    // Change the encoding name of the page in UI when the page has detected proper    // encoding name.    IPC_MESSAGE_ROUTED1(ViewHostMsg_UpdateEncoding, -                      std::wstring /* new encoding name */) +                      std::string /* new encoding name */)    // Notifies the browser that we want to show a destination url for a potential    // action (e.g. when the user is hovering over a link). diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc index 7153ed2..41b6ab0 100644 --- a/chrome/renderer/render_view.cc +++ b/chrome/renderer/render_view.cc @@ -1074,7 +1074,7 @@ void RenderView::UpdateTitle(WebFrame* frame, const std::wstring& title) {  }  void RenderView::UpdateEncoding(WebFrame* frame, -                                const std::wstring& encoding_name) { +                                const std::string& encoding_name) {    // Only update main frame's encoding_name.    if (webview()->GetMainFrame() == frame &&        last_encoding_name_ != encoding_name) { @@ -1816,7 +1816,7 @@ void RenderView::ShowContextMenu(WebView* webview,                                   const std::wstring& selection_text,                                   const std::wstring& misspelled_word,                                   int edit_flags, -                                 const std::wstring& frame_encoding) { +                                 const std::string& frame_encoding) {    ViewHostMsg_ContextMenu_Params params;    params.type = type;    params.x = x; @@ -2186,7 +2186,7 @@ void RenderView::OnAlterTextSize(int size) {    }  } -void RenderView::OnSetPageEncoding(const std::wstring& encoding_name) { +void RenderView::OnSetPageEncoding(const std::string& encoding_name) {    webview()->SetPageEncoding(encoding_name);  } diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h index b94f849..cecebaa 100644 --- a/chrome/renderer/render_view.h +++ b/chrome/renderer/render_view.h @@ -232,7 +232,7 @@ class RenderView : public RenderWidget, public WebViewDelegate,                                 const std::wstring& selection_text,                                 const std::wstring& misspelled_word,                                 int edit_flags, -                               const std::wstring& frame_encoding); +                               const std::string& frame_encoding);    virtual void StartDragging(WebView* webview,                               const WebDropData& drag_data); @@ -336,7 +336,7 @@ class RenderView : public RenderWidget, public WebViewDelegate,    // c) function:DidFinishDocumentLoadForFrame. When this function is    // called, that means we have got whole html page. In here we should    // finally get right encoding of page. -  void UpdateEncoding(WebFrame* frame, const std::wstring& encoding_name); +  void UpdateEncoding(WebFrame* frame, const std::string& encoding_name);    // Captures the thumbnail and text contents for indexing for the given load    // ID. If the view's load ID is different than the parameter, this call is @@ -398,7 +398,7 @@ class RenderView : public RenderWidget, public WebViewDelegate,    void OnCancelDownload(int32 download_id);    void OnFind(const FindInPageRequest& request);    void OnAlterTextSize(int size); -  void OnSetPageEncoding(const std::wstring& encoding_name); +  void OnSetPageEncoding(const std::string& encoding_name);    void OnGetAllSavableResourceLinksForCurrentPage(const GURL& page_url);    void OnGetSerializedHtmlDataForCurrentPageWithLocalLinks(        const std::vector<std::wstring>& links, @@ -524,7 +524,7 @@ class RenderView : public RenderWidget, public WebViewDelegate,    ExternalHostBindings external_host_bindings_;    // The last gotten main frame's encoding. -  std::wstring last_encoding_name_; +  std::string last_encoding_name_;    // The URL we think the user's mouse is hovering over. We use this to    // determine if we want to send a new one (we do not need to send | 
