summaryrefslogtreecommitdiffstats
path: root/chrome_frame/chrome_active_document.cc
diff options
context:
space:
mode:
authorjnd@chromium.org <jnd@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-01 01:53:19 +0000
committerjnd@chromium.org <jnd@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-01 01:53:19 +0000
commit2f2afba1c5f04e5f83d7c62873bef8a0d166f291 (patch)
treeb40f104b3b8d90268d27a53751ff29c7d68c413e /chrome_frame/chrome_active_document.cc
parent565a83eb237b0f746f1924901352ae4c8e75f1a4 (diff)
downloadchromium_src-2f2afba1c5f04e5f83d7c62873bef8a0d166f291.zip
chromium_src-2f2afba1c5f04e5f83d7c62873bef8a0d166f291.tar.gz
chromium_src-2f2afba1c5f04e5f83d7c62873bef8a0d166f291.tar.bz2
Add encoding override support for Chrome frame. With this change, users can override current page encoding in Chrome Frame via clicking IE's encoding menu.
Unfortunately this change does not work on IE8 since the encoding menu is off on IE8. This change was from http://codereview.chromium.org/460036/show, which was on a temporary machine which I can not access from China now. I will re-create the patch, make some modifications according to previous reviewers' comments. now I send to you for review. BUG=24040 TEST=none Review URL: http://codereview.chromium.org/1530012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43306 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame/chrome_active_document.cc')
-rw-r--r--chrome_frame/chrome_active_document.cc58
1 files changed, 58 insertions, 0 deletions
diff --git a/chrome_frame/chrome_active_document.cc b/chrome_frame/chrome_active_document.cc
index 4f92e70..80ccd23 100644
--- a/chrome_frame/chrome_active_document.cc
+++ b/chrome_frame/chrome_active_document.cc
@@ -50,6 +50,13 @@ base::ThreadLocalPointer<ChromeActiveDocument> g_active_doc_cache;
bool g_first_launch_by_process_ = true;
+const DWORD kIEEncodingIdArray[] = {
+#define DEFINE_ENCODING_ID_ARRAY(encoding_name, id, chrome_name) encoding_name,
+ INTERNAL_IE_ENCODINGMENU_IDS(DEFINE_ENCODING_ID_ARRAY)
+#undef DEFINE_ENCODING_ID_ARRAY
+ 0 // The Last data must be 0 to indicate the end of the encoding id array.
+};
+
ChromeActiveDocument::ChromeActiveDocument()
: first_navigation_(true),
is_automation_client_reused_(false),
@@ -1083,6 +1090,57 @@ HRESULT ChromeActiveDocument::SetPageFontSize(const GUID* cmd_group_guid,
return S_OK;
}
+HRESULT ChromeActiveDocument::OnEncodingChange(const GUID* cmd_group_guid,
+ DWORD command_id,
+ DWORD cmd_exec_opt,
+ VARIANT* in_args,
+ VARIANT* out_args) {
+ const struct EncodingMapData {
+ DWORD ie_encoding_id;
+ const char* chrome_encoding_name;
+ } kEncodingTestDatas[] = {
+#define DEFINE_ENCODING_MAP(encoding_name, id, chrome_name) \
+ { encoding_name, chrome_name },
+ INTERNAL_IE_ENCODINGMENU_IDS(DEFINE_ENCODING_MAP)
+#undef DEFINE_ENCODING_MAP
+ };
+
+ if (!automation_client_.get()) {
+ NOTREACHED() << "Invalid automtion client";
+ return E_FAIL;
+ }
+
+ // Using ARRAYSIZE_UNSAFE in here is because we define the struct
+ // EncodingMapData inside function.
+ const char* chrome_encoding_name = NULL;
+ for (int i = 0; i < ARRAYSIZE_UNSAFE(kEncodingTestDatas); ++i) {
+ const struct EncodingMapData* encoding_data = &kEncodingTestDatas[i];
+ if (command_id == encoding_data->ie_encoding_id) {
+ chrome_encoding_name = encoding_data->chrome_encoding_name;
+ break;
+ }
+ }
+ // Return E_FAIL when encountering invalid encoding id.
+ if (!chrome_encoding_name)
+ return E_FAIL;
+
+ TabProxy* tab = GetTabProxy();
+ if (!tab) {
+ NOTREACHED() << "Can not get TabProxy";
+ return E_FAIL;
+ }
+
+ if (chrome_encoding_name)
+ tab->OverrideEncoding(chrome_encoding_name);
+
+ // Like we did on SetPageFontSize, we may forward the command back to IEFrame
+ // to update the menu state to indicate that which encoding was set.
+ // TODO(iyengar)
+ // Do some investigation into why this Exec call fails.
+ IEExec(&CGID_ExplorerBarDoc, command_id, cmd_exec_opt, NULL, NULL);
+ return S_OK;
+}
+
void ChromeActiveDocument::OnGoToHistoryEntryOffset(int tab_handle,
int offset) {
DLOG(INFO) << __FUNCTION__ << " - offset:" << offset;