summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorjnd@chromium.org <jnd@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-02 14:51:10 +0000
committerjnd@chromium.org <jnd@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-02 14:51:10 +0000
commitaacd7cc1c7283ec41fa47334a20e3ffd1f8e4d51 (patch)
tree20fed6384f84ba0a3231bae16742f486c2836fac /chrome
parent725c98edd346e39782305a833372c2be9a854eba (diff)
downloadchromium_src-aacd7cc1c7283ec41fa47334a20e3ffd1f8e4d51.zip
chromium_src-aacd7cc1c7283ec41fa47334a20e3ffd1f8e4d51.tar.gz
chromium_src-aacd7cc1c7283ec41fa47334a20e3ffd1f8e4d51.tar.bz2
Alias 'US-ASCII' to 'ISO-8859-1' in our UI without touching webkit.BUG=15801
TEST=Add US-ASCII encoding to browser encoding test Review URL: http://codereview.chromium.org/178017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25168 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/browser_encoding_uitest.cc1
-rw-r--r--chrome/browser/character_encoding.cc12
-rw-r--r--chrome/browser/tab_contents/tab_contents.cc6
-rw-r--r--chrome/browser/tab_contents/tab_contents.h4
-rw-r--r--chrome/test/data/encoding_tests/alias_mapping/US-ASCII.html11
5 files changed, 29 insertions, 5 deletions
diff --git a/chrome/browser/browser_encoding_uitest.cc b/chrome/browser/browser_encoding_uitest.cc
index b961705..80ed566 100644
--- a/chrome/browser/browser_encoding_uitest.cc
+++ b/chrome/browser/browser_encoding_uitest.cc
@@ -75,6 +75,7 @@ TEST_F(BrowserEncodingTest, TestEncodingAliasMapping) {
{ "KOI8-U.html", L"KOI8-U" },
{ "macintosh.html", L"macintosh" },
{ "Shift-JIS.html", L"Shift_JIS" },
+ { "US-ASCII.html", L"ISO-8859-1" }, // http://crbug.com/15801
{ "UTF-8.html", L"UTF-8" },
{ "UTF-16LE.html", L"UTF-16LE" },
{ "windows-874.html", L"windows-874" },
diff --git a/chrome/browser/character_encoding.cc b/chrome/browser/character_encoding.cc
index 841b48b..dd15587 100644
--- a/chrome/browser/character_encoding.cc
+++ b/chrome/browser/character_encoding.cc
@@ -331,10 +331,18 @@ std::wstring CharacterEncoding::GetCanonicalEncodingNameByAliasName(
WideToASCII(alias_name).c_str(), "IANA", &error_code);
}
- if (canonical_name)
+ if (canonical_name) {
+ // TODO(jnd) use a map to handle all customized {alias, canonical}
+ // encoding mappings if we have more than one pair.
+ // We don't want to add an unnecessary charset to the encoding menu, so we
+ // alias 'US-ASCII' to 'ISO-8859-1' in our UI without touching WebKit.
+ // http://crbug.com/15801.
+ if (alias_name == L"US-ASCII")
+ return GetCanonicalEncodingNameByCommandId(IDC_ENCODING_ISO88591);
return ASCIIToWide(canonical_name);
- else
+ } else {
return std::wstring();
+ }
}
// Static
diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc
index cfdde6c..d86a9bf 100644
--- a/chrome/browser/tab_contents/tab_contents.cc
+++ b/chrome/browser/tab_contents/tab_contents.cc
@@ -15,6 +15,7 @@
#include "chrome/browser/bookmarks/bookmark_model.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/cert_store.h"
+#include "chrome/browser/character_encoding.h"
#include "chrome/browser/debugger/devtools_manager.h"
#include "chrome/browser/dom_operation_notification_details.h"
#include "chrome/browser/dom_ui/dom_ui.h"
@@ -2471,3 +2472,8 @@ void TabContents::Observe(NotificationType type,
NOTREACHED();
}
}
+
+void TabContents::set_encoding(const std::wstring& encoding) {
+ encoding_ = CharacterEncoding::GetCanonicalEncodingNameByAliasName(encoding);
+}
+
diff --git a/chrome/browser/tab_contents/tab_contents.h b/chrome/browser/tab_contents/tab_contents.h
index 3b53b52..2935273 100644
--- a/chrome/browser/tab_contents/tab_contents.h
+++ b/chrome/browser/tab_contents/tab_contents.h
@@ -232,9 +232,7 @@ class TabContents : public PageNavigator,
bool is_starred() const { return is_starred_; }
const std::wstring& encoding() const { return encoding_; }
- void set_encoding(const std::wstring& encoding) {
- encoding_ = encoding;
- }
+ void set_encoding(const std::wstring& encoding);
// Internal state ------------------------------------------------------------
diff --git a/chrome/test/data/encoding_tests/alias_mapping/US-ASCII.html b/chrome/test/data/encoding_tests/alias_mapping/US-ASCII.html
new file mode 100644
index 0000000..e9ae278
--- /dev/null
+++ b/chrome/test/data/encoding_tests/alias_mapping/US-ASCII.html
@@ -0,0 +1,11 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.o rg/TR/1999/REC-html401-19991224/loose.dtd">
+<HTML lang=en-US xml:lang="en-US" xmlns="http://www.w3.org/1999/xhtml">
+<HEAD profile=http://www.w3.org/2000/08/w3c-synd/#>
+<TITLE>World Wide Web Consortium - Web Standards</TITLE>
+<META http-equiv=Content-Type content="text/html; charset=us-ascii">
+</HEAD>
+<BODY>
+<H1><IMG height=48 alt="The World Wide Web Consortium (W3C)" src="" width=315></H1>
+<H2>The encoding of the contents are US-ASCII</H2>
+</BODY>
+</HTML> \ No newline at end of file