diff options
Diffstat (limited to 'chrome')
32 files changed, 138 insertions, 240 deletions
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc index f6c0328..4d71b37 100644 --- a/chrome/browser/browser.cc +++ b/chrome/browser/browser.cc @@ -515,8 +515,7 @@ void Browser::ProcessPendingUIUpdates() { void Browser::OpenURLFromTab(TabContents* source, const GURL& url, WindowOpenDisposition disposition, - PageTransition::Type transition, - const std::string& override_encoding) { + PageTransition::Type transition) { // No code for these yet DCHECK((disposition != NEW_POPUP) && (disposition != SAVE_TO_DISK)); @@ -631,14 +630,6 @@ void Browser::OpenURLFromTab(TabContents* source, // front-most. new_contents->Focus(); } - - if (!override_encoding.empty()) { - // The new tab needs a special encoding, such as a view source page - // which should use the same encoding as the original page. - WebContents* web_contents = new_contents->AsWebContents(); - if (web_contents) - web_contents->set_override_encoding(override_encoding); - } } void Browser::NavigationStateChanged(const TabContents* source, diff --git a/chrome/browser/browser.h b/chrome/browser/browser.h index f500972..184496a 100644 --- a/chrome/browser/browser.h +++ b/chrome/browser/browser.h @@ -267,10 +267,9 @@ class Browser : public TabStripModelDelegate, // Overridden from TabContentsDelegate: virtual void OpenURLFromTab(TabContents* source, - const GURL& url, - WindowOpenDisposition disposition, - PageTransition::Type transition, - const std::string& override_encoding); + const GURL& url, + WindowOpenDisposition disposition, + PageTransition::Type transition); 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 5594f0e..363c6bd 100644 --- a/chrome/browser/browser_commands.cc +++ b/chrome/browser/browser_commands.cc @@ -625,7 +625,7 @@ void Browser::ExecuteCommand(int id) { case IDC_ENCODING_WINDOWS1255: case IDC_ENCODING_WINDOWS1258: { UserMetrics::RecordAction(L"OverrideEncoding", profile_); - const std::string cur_encoding_name = + const std::wstring 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 b6659ea..c40895b 100644 --- a/chrome/browser/character_encoding.cc +++ b/chrome/browser/character_encoding.cc @@ -24,56 +24,56 @@ const int kUserSelectedEncodingsMaxLength = 3; typedef struct { int resource_id; - const char* name; + const wchar_t* name; int category_string_id; } CanonicalEncodingData; // An array of all supported canonical encoding names. static CanonicalEncodingData canonical_encoding_names[] = { - { 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 }, + { 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 }, }; static const int canonical_encoding_names_length = arraysize(canonical_encoding_names); -typedef std::map<int, std::pair<const char*, int> > IdToCanonicalEncodingNameMapType; -typedef std::map<const std::string, int> CanonicalEncodingNameToIdMapType; +typedef std::map<int, std::pair<const wchar_t*, int> > IdToCanonicalEncodingNameMapType; +typedef std::map<const std::wstring, int> CanonicalEncodingNameToIdMapType; class CanonicalEncodingMap { public: @@ -134,7 +134,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::string& encoding_name) { + const std::wstring& encoding_name) { const CanonicalEncodingNameToIdMapType* map = canonical_encoding_name_map_singleton. GetCanonicalEncodingNameToIdMapData(); @@ -206,8 +206,7 @@ static void ParseEncodingListSeparatedWithComma( size_t maximum_size) { WStringTokenizer tokenizer(encoding_list, L","); while (tokenizer.GetNext()) { - std::string valid_encoding = WideToUTF8(tokenizer.token()); - int id = GetCommandIdByCanonicalEncodingName(valid_encoding); + int id = GetCommandIdByCanonicalEncodingName(tokenizer.token()); // Ignore invalid encoding. if (!id) continue; @@ -217,14 +216,14 @@ static void ParseEncodingListSeparatedWithComma( } } -std::wstring GetEncodingDisplayName(std::string encoding_name, +std::wstring GetEncodingDisplayName(std::wstring 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, - UTF8ToWide(encoding_name)); + encoding_name); } return category_name; } @@ -232,7 +231,7 @@ std::wstring GetEncodingDisplayName(std::string encoding_name, } // namespace // Static. -std::string CharacterEncoding::GetCanonicalEncodingNameByCommandId(int id) { +std::wstring CharacterEncoding::GetCanonicalEncodingNameByCommandId(int id) { const IdToCanonicalEncodingNameMapType* map = canonical_encoding_name_map_singleton. GetIdToCanonicalEncodingNameMapData(); @@ -241,7 +240,7 @@ std::string CharacterEncoding::GetCanonicalEncodingNameByCommandId(int id) { IdToCanonicalEncodingNameMapType::const_iterator found_name = map->find(id); if (found_name != map->end()) return found_name->second.first; - return std::string(); + return std::wstring(); } // Static. @@ -266,10 +265,10 @@ int CharacterEncoding::GetSupportCanonicalEncodingCount() { } // Static. -std::string CharacterEncoding::GetCanonicalEncodingNameByIndex(int index) { +std::wstring CharacterEncoding::GetCanonicalEncodingNameByIndex(int index) { if (index < canonical_encoding_names_length) return canonical_encoding_names[index].name; - return std::string(); + return std::wstring(); } // Static. @@ -282,8 +281,8 @@ std::wstring CharacterEncoding::GetCanonicalEncodingDisplayNameByIndex( } // Static. -std::string CharacterEncoding::GetCanonicalEncodingNameByAliasName( - const std::string& alias_name) { +std::wstring CharacterEncoding::GetCanonicalEncodingNameByAliasName( + const std::wstring& alias_name) { // If the input alias_name is already canonical encoding name, just return it. const CanonicalEncodingNameToIdMapType* map = canonical_encoding_name_map_singleton. @@ -297,18 +296,19 @@ std::string CharacterEncoding::GetCanonicalEncodingNameByAliasName( UErrorCode error_code = U_ZERO_ERROR; - const char* canonical_name = ucnv_getCanonicalName(alias_name.c_str(), - "MIME", - &error_code); + const char* canonical_name = ucnv_getCanonicalName( + WideToASCII(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(alias_name.c_str(), - "IANA", - &error_code); + canonical_name = ucnv_getCanonicalName( + WideToASCII(alias_name).c_str(), "IANA", &error_code); } - return std::string(canonical_name); + if (canonical_name) + return ASCIIToWide(canonical_name); + else + return std::wstring(); } // Static @@ -395,7 +395,7 @@ bool CharacterEncoding::UpdateRecentlySelectdEncoding( int new_selected_encoding_id, std::wstring* selected_encodings) { // Get encoding name. - std::string encoding_name = + std::wstring encoding_name = GetCanonicalEncodingNameByCommandId(new_selected_encoding_id); DCHECK(!encoding_name.empty()); // Check whether the new encoding is in local dependent encodings or original @@ -424,13 +424,12 @@ 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->append(UTF8ToWide(encoding_name)); + *selected_encodings = 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( - UTF8ToWide(GetCanonicalEncodingNameByCommandId(*it))); + selected_encodings->append(GetCanonicalEncodingNameByCommandId(*it)); } return true; } diff --git a/chrome/browser/character_encoding.h b/chrome/browser/character_encoding.h index 7d4bb34..1830edc 100644 --- a/chrome/browser/character_encoding.h +++ b/chrome/browser/character_encoding.h @@ -20,7 +20,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::string GetCanonicalEncodingNameByCommandId(int id); + static std::wstring GetCanonicalEncodingNameByCommandId(int id); // Return display name of canonical encoding according to the command // ID. THIS FUNCTION IS NOT THREADSAFE. You must run this function @@ -33,7 +33,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::string GetCanonicalEncodingNameByIndex(int index); + static std::wstring GetCanonicalEncodingNameByIndex(int index); // Return display name of canonical encoding according to the index, // which starts from zero to GetSupportCanonicalEncodingCount() - 1. @@ -43,8 +43,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::string GetCanonicalEncodingNameByAliasName( - const std::string& alias_name); + static std::wstring GetCanonicalEncodingNameByAliasName( + const std::wstring& 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 57f7ecf..a3092f2 100644 --- a/chrome/browser/debugger/debugger_view.cc +++ b/chrome/browser/debugger/debugger_view.cc @@ -128,10 +128,9 @@ void DebuggerView::SetDebuggerBreak(bool is_broken) { } void DebuggerView::OpenURLFromTab(TabContents* source, - const GURL& url, - WindowOpenDisposition disposition, - PageTransition::Type transition, - const std::string& override_encoding) { + const GURL& url, + WindowOpenDisposition disposition, + PageTransition::Type transition) { BrowserList::GetLastActive()->OpenURL(url, disposition, transition); } diff --git a/chrome/browser/debugger/debugger_view.h b/chrome/browser/debugger/debugger_view.h index 2da9408..78931b8 100644 --- a/chrome/browser/debugger/debugger_view.h +++ b/chrome/browser/debugger/debugger_view.h @@ -59,8 +59,7 @@ class DebuggerView : public ChromeViews::View, virtual void OpenURLFromTab(TabContents* source, const GURL& url, WindowOpenDisposition disposition, - PageTransition::Type transition, - const std::string& override_encoding); + PageTransition::Type transition); // 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 c15b00c..d7a7bc8 100644 --- a/chrome/browser/encoding_menu_controller_delegate.cc +++ b/chrome/browser/encoding_menu_controller_delegate.cc @@ -28,11 +28,9 @@ bool EncodingMenuControllerDelegate::IsItemChecked(int id) const { TabContents* current_tab = browser_->GetSelectedTabContents(); if (!current_tab) return false; - std::string encoding_name = current_tab->GetEncoding(); - if (encoding_name.empty()) { - encoding_name = WideToUTF8( - profile->GetPrefs()->GetString(prefs::kDefaultCharset)); - } + std::wstring encoding_name = current_tab->GetEncoding(); + if (encoding_name.empty()) + encoding_name = 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 fe9b842..82253dc 100644 --- a/chrome/browser/external_tab_container.cc +++ b/chrome/browser/external_tab_container.cc @@ -130,12 +130,10 @@ LRESULT ExternalTabContainer::OnSize(UINT, WPARAM, LPARAM, BOOL& handled) { // needs to be fully fleshed out based on the requirements of the // "Chrome tab in external browser" feature. -void ExternalTabContainer::OpenURLFromTab( - TabContents* source, - const GURL& url, - WindowOpenDisposition disposition, - PageTransition::Type transition, - const std::string& override_encoding) { +void ExternalTabContainer::OpenURLFromTab(TabContents* source, + const GURL& url, + WindowOpenDisposition disposition, + PageTransition::Type transition) { 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 27f62c8..6cc1160 100644 --- a/chrome/browser/external_tab_container.h +++ b/chrome/browser/external_tab_container.h @@ -55,8 +55,7 @@ class ExternalTabContainer : public TabContentsDelegate, virtual void OpenURLFromTab(TabContents* source, const GURL& url, WindowOpenDisposition disposition, - PageTransition::Type transition, - const std::string& override_encoding); + PageTransition::Type transition); 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 0a2527f..035c2ad 100644 --- a/chrome/browser/navigation_controller_unittest.cc +++ b/chrome/browser/navigation_controller_unittest.cc @@ -136,8 +136,7 @@ class NavigationControllerTest : public testing::Test, virtual void OpenURLFromTab(TabContents*, const GURL&, WindowOpenDisposition, - PageTransition::Type, - const std::string& override_encoding) {} + PageTransition::Type) {} 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 d84834b..1a97ec3 100644 --- a/chrome/browser/render_view_context_menu_controller.cc +++ b/chrome/browser/render_view_context_menu_controller.cc @@ -42,15 +42,6 @@ RenderViewContextMenuController::~RenderViewContextMenuController() { /////////////////////////////////////////////////////////////////////////////// // Controller methods -void RenderViewContextMenuController::OpenURLWithOverrideEncoding( - const GURL& url, - WindowOpenDisposition disposition, - PageTransition::Type transition, - const std::string& override_encoding) { - source_web_contents_->OpenURLWithOverrideEncoding(url, disposition, - transition, override_encoding); -} - void RenderViewContextMenuController::OpenURL( const GURL& url, WindowOpenDisposition disposition, @@ -282,10 +273,8 @@ void RenderViewContextMenuController::ExecuteCommand(int id) { break; case IDS_CONTENT_CONTEXT_VIEWPAGESOURCE: - OpenURLWithOverrideEncoding( - GURL("view-source:" + params_.page_url.spec()), - NEW_FOREGROUND_TAB, PageTransition::GENERATED, - source_web_contents_->GetEncoding()); + OpenURL(GURL("view-source:" + params_.page_url.spec()), + NEW_FOREGROUND_TAB, PageTransition::GENERATED); break; case IDS_CONTENT_CONTEXT_INSPECTELEMENT: @@ -320,10 +309,8 @@ void RenderViewContextMenuController::ExecuteCommand(int id) { break; case IDS_CONTENT_CONTEXT_VIEWFRAMESOURCE: - OpenURLWithOverrideEncoding( - GURL("view-source:" + params_.frame_url.spec()), - NEW_FOREGROUND_TAB, PageTransition::GENERATED, - params_.frame_encoding); + OpenURL(GURL("view-source:" + params_.frame_url.spec()), + NEW_FOREGROUND_TAB, PageTransition::GENERATED); break; case IDS_CONTENT_CONTEXT_VIEWFRAMEINFO: diff --git a/chrome/browser/render_view_context_menu_controller.h b/chrome/browser/render_view_context_menu_controller.h index dbca5eb..59f44c0 100644 --- a/chrome/browser/render_view_context_menu_controller.h +++ b/chrome/browser/render_view_context_menu_controller.h @@ -23,19 +23,12 @@ class RenderViewContextMenuController : public Menu::Delegate { virtual bool GetAcceleratorInfo(int id, ChromeViews::Accelerator* accel); private: - // Opens the specified URL string with a disposition specified by parameter - // |disposition|. + // Opens the specified URL string in a new tab. If |in_current_window| is + // false, a new window is created to hold the new tab. void OpenURL(const GURL& url, WindowOpenDisposition disposition, PageTransition::Type transition); - // Opens the specified URL string with a disposition specified by parameter - // |disposition| and forces the new page on using |override_encoding|. - void OpenURLWithOverrideEncoding(const GURL& url, - WindowOpenDisposition disposition, - PageTransition::Type transition, - 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 f4fc34b..4f02aaca 100644 --- a/chrome/browser/render_view_host.cc +++ b/chrome/browser/render_view_host.cc @@ -327,7 +327,7 @@ void RenderViewHost::AlterTextSize(text_zoom::TextSize size) { Send(new ViewMsg_AlterTextSize(routing_id_, size)); } -void RenderViewHost::SetPageEncoding(const std::string& encoding_name) { +void RenderViewHost::SetPageEncoding(const std::wstring& encoding_name) { Send(new ViewMsg_SetPageEncoding(routing_id_, encoding_name)); } @@ -830,7 +830,7 @@ void RenderViewHost::OnMsgUpdateTitle(int32 page_id, delegate_->UpdateTitle(this, page_id, title); } -void RenderViewHost::OnMsgUpdateEncoding(const std::string& encoding_name) { +void RenderViewHost::OnMsgUpdateEncoding(const std::wstring& encoding_name) { delegate_->UpdateEncoding(this, encoding_name); } diff --git a/chrome/browser/render_view_host.h b/chrome/browser/render_view_host.h index 325ab81..5e0543d 100644 --- a/chrome/browser/render_view_host.h +++ b/chrome/browser/render_view_host.h @@ -192,7 +192,7 @@ class RenderViewHost : public RenderWidgetHost { void AlterTextSize(text_zoom::TextSize size); // Change the encoding of the page. - void SetPageEncoding(const std::string& encoding_name); + void SetPageEncoding(const std::wstring& encoding_name); // Change the alternate error page URL. An empty GURL disables the use of // alternate error pages. @@ -413,7 +413,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::string& encoding_name); + void OnMsgUpdateEncoding(const std::wstring& 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 124ed11..8e541348 100644 --- a/chrome/browser/render_view_host_delegate.h +++ b/chrome/browser/render_view_host_delegate.h @@ -107,7 +107,7 @@ class RenderViewHostDelegate { // The page's encoding was changed and should be updated. virtual void UpdateEncoding(RenderViewHost* render_view_host, - const std::string& encoding_name) { } + const std::wstring& 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 503c99e..d0606d6 100644 --- a/chrome/browser/tab_contents.cc +++ b/chrome/browser/tab_contents.cc @@ -408,24 +408,11 @@ void TabContents::DidMoveOrResize(ConstrainedWindow* window) { /////////////////////////////////////////////////////////////////////////////// // PageNavigator methods -void TabContents::OpenURLWithOverrideEncoding( - const GURL& url, - WindowOpenDisposition disposition, - PageTransition::Type transition, - const std::string& override_encoding) { - if (delegate_) { - delegate_->OpenURLFromTab(this, url, disposition, transition, - override_encoding); - } -} - void TabContents::OpenURL(const GURL& url, WindowOpenDisposition disposition, PageTransition::Type transition) { - if (delegate_) { - delegate_->OpenURLFromTab(this, url, disposition, transition, - std::string()); - } + if (delegate_) + delegate_->OpenURLFromTab(this, url, disposition, transition); } /////////////////////////////////////////////////////////////////////////////// diff --git a/chrome/browser/tab_contents.h b/chrome/browser/tab_contents.h index b079eeb..a8eaec3 100644 --- a/chrome/browser/tab_contents.h +++ b/chrome/browser/tab_contents.h @@ -258,7 +258,7 @@ class TabContents : public PageNavigator, virtual void SetEncodingAutoDetector(bool encoding_auto_detector) { } // Asynchronous call to change page encoding. - virtual void SetPageEncoding(const std::string& encoding_name) { } + virtual void SetPageEncoding(const std::wstring& encoding_name) { } // Return whether this tab contents is loading a resource. bool is_loading() const { return is_loading_; } @@ -347,12 +347,6 @@ class TabContents : public PageNavigator, WindowOpenDisposition disposition, PageTransition::Type transition); - virtual void OpenURLWithOverrideEncoding( - const GURL& url, - WindowOpenDisposition disposition, - PageTransition::Type transition, - const std::string& override_encoding); - // NotificationObserver implementation. virtual void Observe(NotificationType type, const NotificationSource& source, @@ -411,8 +405,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::string& GetEncoding() { return encoding_name_; } - void SetEncoding(const std::string& encoding_name) { + const std::wstring& GetEncoding() { return encoding_name_; } + void SetEncoding(const std::wstring& encoding_name) { encoding_name_ = encoding_name; } @@ -540,7 +534,7 @@ class TabContents : public PageNavigator, // The id used in the ViewStorage to store the last focused view. int last_focused_view_storage_id_; - std::string encoding_name_; + std::wstring 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 29acb72..63cbcde 100644 --- a/chrome/browser/tab_contents_delegate.h +++ b/chrome/browser/tab_contents_delegate.h @@ -28,13 +28,13 @@ class TabContentsDelegate : public PageNavigator { virtual void OpenURLFromTab(TabContents* source, const GURL& url, WindowOpenDisposition disposition, - PageTransition::Type transition, - const std::string& override_encoding) = 0; + PageTransition::Type transition) = 0; virtual void OpenURL(const GURL& url, WindowOpenDisposition disposition, - PageTransition::Type transition) { - OpenURLFromTab(NULL, url, disposition, transition, std::string()); + PageTransition::Type transition) + { + OpenURLFromTab(NULL, url, disposition, transition); } // Called to inform the delegate that the tab content's navigation state diff --git a/chrome/browser/views/constrained_window_impl.cc b/chrome/browser/views/constrained_window_impl.cc index 77b1854..de02b41 100644 --- a/chrome/browser/views/constrained_window_impl.cc +++ b/chrome/browser/views/constrained_window_impl.cc @@ -985,12 +985,10 @@ void ConstrainedWindowImpl::ActivateContents(TabContents* contents) { ActivateConstrainedWindow(); } -void ConstrainedWindowImpl::OpenURLFromTab( - TabContents* source, - const GURL& url, - WindowOpenDisposition disposition, - PageTransition::Type transition, - const std::string& override_encoding) { +void ConstrainedWindowImpl::OpenURLFromTab(TabContents* source, + const GURL& url, + WindowOpenDisposition disposition, + PageTransition::Type transition) { // 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 64456ae..90c2db3 100644 --- a/chrome/browser/views/constrained_window_impl.h +++ b/chrome/browser/views/constrained_window_impl.h @@ -55,8 +55,7 @@ class ConstrainedWindowImpl : public ConstrainedWindow, virtual void OpenURLFromTab(TabContents* source, const GURL& url, WindowOpenDisposition disposition, - PageTransition::Type transition, - const std::string& override_encoding); + PageTransition::Type transition); // 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 6b413d3..1d985d2 100644 --- a/chrome/browser/views/html_dialog_view.cc +++ b/chrome/browser/views/html_dialog_view.cc @@ -85,13 +85,11 @@ void HtmlDialogView::OnDialogClosed(const std::string& json_retval) { void HtmlDialogView::OpenURLFromTab(TabContents* source, const GURL& url, WindowOpenDisposition disposition, - PageTransition::Type transition, - const std::string& override_encoding) { + PageTransition::Type transition) { // 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. - parent_browser_->OpenURLFromTab(source, url, NEW_WINDOW, transition, - override_encoding); + parent_browser_->OpenURLFromTab(source, url, NEW_WINDOW, transition); } //////////////////////////////////////////////////////////////////////////////// diff --git a/chrome/browser/views/html_dialog_view.h b/chrome/browser/views/html_dialog_view.h index 0c4dc59..82a42f6 100644 --- a/chrome/browser/views/html_dialog_view.h +++ b/chrome/browser/views/html_dialog_view.h @@ -57,8 +57,7 @@ class HtmlDialogView virtual void OpenURLFromTab(TabContents* source, const GURL& url, WindowOpenDisposition disposition, - PageTransition::Type transition, - const std::string& override_encoding); + PageTransition::Type transition); 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 797dc35..09a82cf 100644 --- a/chrome/browser/views/options/fonts_page_view.cc +++ b/chrome/browser/views/options/fonts_page_view.cc @@ -55,8 +55,7 @@ class DefaultEncodingComboboxModel : public ChromeViews::ComboBox::Model { std::wstring GetEncodingCharsetByIndex(int index) { DCHECK(index >= 0 && canonical_encoding_names_length_ > index); - return UTF8ToWide( - CharacterEncoding::GetCanonicalEncodingNameByIndex(index)); + return CharacterEncoding::GetCanonicalEncodingNameByIndex(index); } int GetSelectedEncodingIndex(Profile* profile) { @@ -64,8 +63,7 @@ class DefaultEncodingComboboxModel : public ChromeViews::ComboBox::Model { current_encoding_string.Init(prefs::kDefaultCharset, profile->GetPrefs(), NULL); - const std::string current_encoding = - WideToUTF8(current_encoding_string.GetValue()); + const std::wstring current_encoding = 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/views/tabs/dragged_tab_controller.cc b/chrome/browser/views/tabs/dragged_tab_controller.cc index 81b5386..82c002e 100644 --- a/chrome/browser/views/tabs/dragged_tab_controller.cc +++ b/chrome/browser/views/tabs/dragged_tab_controller.cc @@ -141,18 +141,15 @@ bool DraggedTabController::IsDragSourceTab(Tab* tab) const { /////////////////////////////////////////////////////////////////////////////// // DraggedTabController, PageNavigator implementation: -void DraggedTabController::OpenURLFromTab( - TabContents* source, - const GURL& url, - WindowOpenDisposition disposition, - PageTransition::Type transition, - const std::string& override_encoding) { +void DraggedTabController::OpenURLFromTab(TabContents* source, + const GURL& url, + WindowOpenDisposition disposition, + PageTransition::Type transition) { if (original_delegate_) { if (disposition == CURRENT_TAB) disposition = NEW_WINDOW; - original_delegate_->OpenURLFromTab(source, url, disposition, transition, - override_encoding); + original_delegate_->OpenURLFromTab(source, url, disposition, transition); } } diff --git a/chrome/browser/views/tabs/dragged_tab_controller.h b/chrome/browser/views/tabs/dragged_tab_controller.h index 6c6aed6..5874661 100644 --- a/chrome/browser/views/tabs/dragged_tab_controller.h +++ b/chrome/browser/views/tabs/dragged_tab_controller.h @@ -81,8 +81,7 @@ class DraggedTabController : public TabContentsDelegate, virtual void OpenURLFromTab(TabContents* source, const GURL& url, WindowOpenDisposition disposition, - PageTransition::Type transition, - const std::string& override_encoding); + PageTransition::Type transition); virtual void NavigationStateChanged(const TabContents* source, unsigned changed_flags); virtual void ReplaceContents(TabContents* source, diff --git a/chrome/browser/web_contents.cc b/chrome/browser/web_contents.cc index 0893681..fd061b3 100644 --- a/chrome/browser/web_contents.cc +++ b/chrome/browser/web_contents.cc @@ -711,7 +711,7 @@ void WebContents::AlterTextSize(text_zoom::TextSize size) { // TODO(creis): should this be propagated to other and future RVHs? } -void WebContents::SetPageEncoding(const std::string& encoding_name) { +void WebContents::SetPageEncoding(const std::wstring& encoding_name) { render_view_host()->SetPageEncoding(encoding_name); // TODO(creis): should this be propagated to other and future RVHs? } @@ -1609,7 +1609,7 @@ void WebContents::UpdateTitle(RenderViewHost* rvh, void WebContents::UpdateEncoding(RenderViewHost* render_view_host, - const std::string& encoding_name) { + const std::wstring& encoding_name) { SetEncoding(encoding_name); } @@ -1644,15 +1644,6 @@ void WebContents::DidStartLoading(RenderViewHost* rvh, int32 page_id) { if (plugin_installer_ != NULL) plugin_installer_->OnStartLoading(); SetIsLoading(true, NULL); - - // Overrides the page's encoding if we need to open this page with specified - // encoding. - if (!override_encoding_.empty()) { - SetPageEncoding(override_encoding_); - // Once we override the new encoding, we need to clear the encoding value - // for avoiding overriding it again. - override_encoding_.clear(); - } } void WebContents::DidStopLoading(RenderViewHost* rvh, int32 page_id) { @@ -2046,9 +2037,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 = UTF8ToWide( + web_prefs.default_encoding = CharacterEncoding::GetCanonicalEncodingNameByAliasName( - WideToUTF8(web_prefs.default_encoding))); + 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 054c57e..fd12b9b 100644 --- a/chrome/browser/web_contents.h +++ b/chrome/browser/web_contents.h @@ -93,7 +93,7 @@ class WebContents : public TabContents, virtual void AlterTextSize(text_zoom::TextSize size); // Change encoding of page. - virtual void SetPageEncoding(const std::string& encoding_name); + virtual void SetPageEncoding(const std::wstring& encoding_name); bool is_starred() const { return is_starred_; } @@ -323,10 +323,6 @@ 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::string& override_encoding) { - override_encoding_ = override_encoding; - } - protected: FRIEND_TEST(WebContentsTest, OnMessageReceived); @@ -358,7 +354,7 @@ class WebContents : public TabContents, int32 page_id, const std::wstring& title); virtual void UpdateEncoding(RenderViewHost* render_view_host, - const std::string& encoding_name); + const std::wstring& encoding_name); virtual void UpdateTargetURL(int32 page_id, const GURL& url); virtual void UpdateThumbnail(const GURL& url, const SkBitmap& bitmap, @@ -757,9 +753,6 @@ class WebContents : public TabContents, // Non-null if we're displaying content for a web app. scoped_refptr<WebApp> web_app_; - // Specified encoding which is used to override current tab's 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 a47b05b..e39b392e 100644 --- a/chrome/common/render_messages.h +++ b/chrome/common/render_messages.h @@ -150,9 +150,6 @@ struct ViewHostMsg_ContextMenu_Params { // These flags indicate to the browser whether the renderer believes it is // able to perform the corresponding action. int edit_flags; - - // |frame_encoding|indicates the encoding of current focused sub frame. - std::string frame_encoding; }; // Values that may be OR'd together to form the 'flags' parameter of a @@ -769,7 +766,6 @@ struct ParamTraits<ViewHostMsg_ContextMenu_Params> { WriteParam(m, p.misspelled_word); WriteParam(m, p.dictionary_suggestions); WriteParam(m, p.edit_flags); - WriteParam(m, p.frame_encoding); } static bool Read(const Message* m, void** iter, param_type* p) { return @@ -783,8 +779,7 @@ struct ParamTraits<ViewHostMsg_ContextMenu_Params> { ReadParam(m, iter, &p->selection_text) && ReadParam(m, iter, &p->misspelled_word) && ReadParam(m, iter, &p->dictionary_suggestions) && - ReadParam(m, iter, &p->edit_flags) && - ReadParam(m, iter, &p->frame_encoding); + ReadParam(m, iter, &p->edit_flags); } static void Log(const param_type& p, std::wstring* l) { l->append(L"<ViewHostMsg_ContextMenu_Params>"); diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h index f6c595d..66941ef 100644 --- a/chrome/common/render_messages_internal.h +++ b/chrome/common/render_messages_internal.h @@ -229,7 +229,7 @@ IPC_BEGIN_MESSAGES(View, 1) // Change encoding of page in the renderer. IPC_MESSAGE_ROUTED1(ViewMsg_SetPageEncoding, - std::string /*new encoding name*/) + std::wstring /*new encoding name*/) // Inspect the element at the specified coordinates IPC_MESSAGE_ROUTED2(ViewMsg_InspectElement, @@ -529,7 +529,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::string /* new encoding name */) + std::wstring /* 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 9755fa8..f978178 100644 --- a/chrome/renderer/render_view.cc +++ b/chrome/renderer/render_view.cc @@ -1060,15 +1060,14 @@ void RenderView::UpdateTitle(WebFrame* frame, const std::wstring& title) { } void RenderView::UpdateEncoding(WebFrame* frame, - const std::string& encoding_name) { + const std::wstring& encoding_name) { // Only update main frame's encoding_name. if (webview()->GetMainFrame() == frame && last_encoding_name_ != encoding_name) { - // save the encoding name for later comparing. + // Save the encoding name for later comparing. last_encoding_name_ = encoding_name; - Send(new ViewHostMsg_UpdateEncoding(routing_id_, - last_encoding_name_)); + Send(new ViewHostMsg_UpdateEncoding(routing_id_, last_encoding_name_)); } } @@ -1422,13 +1421,6 @@ WindowOpenDisposition RenderView::DispositionForNavigationAction( // Webkit is asking whether to navigate to a new URL. // This is fine normally, except if we're showing UI from one security // context and they're trying to navigate to a different context. - // - // Reload allowing stale data is used for encoding changes which will never - // appear in a new tab. So we should return disposition as CURRENT_TAB when - // encountering this situation. - if (frame->IsReloadAllowingStaleData()) - return CURRENT_TAB; - const GURL& url = request->GetURL(); // We only care about navigations that are within the current tab (as opposed // to, for example, opening a new window). @@ -1798,8 +1790,7 @@ void RenderView::ShowContextMenu(WebView* webview, const GURL& frame_url, const std::wstring& selection_text, const std::wstring& misspelled_word, - int edit_flags, - const std::string& frame_encoding) { + int edit_flags) { ViewHostMsg_ContextMenu_Params params; params.type = type; params.x = x; @@ -1811,7 +1802,6 @@ void RenderView::ShowContextMenu(WebView* webview, params.selection_text = selection_text; params.misspelled_word = misspelled_word; params.edit_flags = edit_flags; - params.frame_encoding = frame_encoding; Send(new ViewHostMsg_ContextMenu(routing_id_, params)); } @@ -2169,7 +2159,7 @@ void RenderView::OnAlterTextSize(int size) { } } -void RenderView::OnSetPageEncoding(const std::string& encoding_name) { +void RenderView::OnSetPageEncoding(const std::wstring& encoding_name) { webview()->SetPageEncoding(encoding_name); } diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h index bc3a052..85c74fc 100644 --- a/chrome/renderer/render_view.h +++ b/chrome/renderer/render_view.h @@ -205,8 +205,7 @@ class RenderView : public RenderWidget, public WebViewDelegate, const GURL& frame_url, const std::wstring& selection_text, const std::wstring& misspelled_word, - int edit_flags, - const std::string& frame_encoding); + int edit_flags); virtual void StartDragging(WebView* webview, const WebDropData& drag_data); @@ -310,7 +309,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::string& encoding_name); + void UpdateEncoding(WebFrame* frame, const std::wstring& 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 @@ -372,7 +371,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::string& encoding_name); + void OnSetPageEncoding(const std::wstring& encoding_name); void OnGetAllSavableResourceLinksForCurrentPage(const GURL& page_url); void OnGetSerializedHtmlDataForCurrentPageWithLocalLinks( const std::vector<std::wstring>& links, @@ -506,7 +505,7 @@ class RenderView : public RenderWidget, public WebViewDelegate, ExternalHostBindings external_host_bindings_; // The last gotten main frame's encoding. - std::string last_encoding_name_; + std::wstring 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 |