summaryrefslogtreecommitdiffstats
path: root/chrome_frame
diff options
context:
space:
mode:
authorananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-19 05:35:22 +0000
committerananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-19 05:35:22 +0000
commitb95f550fa7ef1723adf93f0292667979be66fa08 (patch)
tree56a6398774c2a24bb65ea7d30d6c6542309fa019 /chrome_frame
parent552e600db9f51ac1efb0438bd749227226dffa64 (diff)
downloadchromium_src-b95f550fa7ef1723adf93f0292667979be66fa08.zip
chromium_src-b95f550fa7ef1723adf93f0292667979be66fa08.tar.gz
chromium_src-b95f550fa7ef1723adf93f0292667979be66fa08.tar.bz2
Ensure that the renderer has focus when ChromeFrame navigates to a URL in IE full tab mode.
This fixes bug http://code.google.com/p/chromium/issues/detail?id=22745 Test=Covered by unit test. Bug=22745 Review URL: http://codereview.chromium.org/402079 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@32497 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame')
-rw-r--r--chrome_frame/chrome_active_document.cc5
-rw-r--r--chrome_frame/chrome_active_document.h3
-rw-r--r--chrome_frame/chrome_frame_plugin.h17
-rw-r--r--chrome_frame/test/chrome_frame_unittests.cc31
4 files changed, 48 insertions, 8 deletions
diff --git a/chrome_frame/chrome_active_document.cc b/chrome_frame/chrome_active_document.cc
index 56b13be..2406f6e 100644
--- a/chrome_frame/chrome_active_document.cc
+++ b/chrome_frame/chrome_active_document.cc
@@ -178,6 +178,11 @@ bool ChromeActiveDocument::is_frame_busting_enabled() {
return false;
}
+void ChromeActiveDocument::OnAutomationServerReady() {
+ Base::OnAutomationServerReady();
+ Base::GiveFocusToChrome();
+}
+
STDMETHODIMP ChromeActiveDocument::Load(BOOL fully_avalable,
IMoniker* moniker_name,
LPBC bind_context,
diff --git a/chrome_frame/chrome_active_document.h b/chrome_frame/chrome_active_document.h
index 103eb49..dbd430f 100644
--- a/chrome_frame/chrome_active_document.h
+++ b/chrome_frame/chrome_active_document.h
@@ -242,6 +242,9 @@ END_EXEC_COMMAND_MAP()
// responses served with the X-Frame-Options header?
bool is_frame_busting_enabled();
+ // ChromeFramePlugin overrides.
+ virtual void OnAutomationServerReady();
+
protected:
// ChromeFrameActivexBase overrides
virtual void OnOpenURL(int tab_handle, const GURL& url_to_open,
diff --git a/chrome_frame/chrome_frame_plugin.h b/chrome_frame/chrome_frame_plugin.h
index 01ee2e5..36f2fc2 100644
--- a/chrome_frame/chrome_frame_plugin.h
+++ b/chrome_frame/chrome_frame_plugin.h
@@ -122,14 +122,8 @@ END_MSG_MAP()
LRESULT OnSetFocus(UINT message, WPARAM wparam, LPARAM lparam,
BOOL& handled) { // NO_LINT
if (!ignore_setfocus_ && automation_client_ != NULL) {
- TabProxy* tab = automation_client_->tab();
- HWND chrome_window = automation_client_->tab_window();
- if (tab && ::IsWindow(chrome_window)) {
- DLOG(INFO) << "Setting initial focus";
- tab->SetInitialFocus(win_util::IsShiftPressed());
- }
+ GiveFocusToChrome();
}
-
return 0;
}
@@ -190,6 +184,15 @@ END_MSG_MAP()
return new ChromeFrameAutomationClient;
}
+ void GiveFocusToChrome() {
+ TabProxy* tab = automation_client_->tab();
+ HWND chrome_window = automation_client_->tab_window();
+ if (tab && ::IsWindow(chrome_window)) {
+ DLOG(INFO) << "Setting initial focus";
+ tab->SetInitialFocus(win_util::IsShiftPressed());
+ }
+ }
+
protected:
// Our gateway to chrome land
scoped_refptr<ChromeFrameAutomationClient> automation_client_;
diff --git a/chrome_frame/test/chrome_frame_unittests.cc b/chrome_frame/test/chrome_frame_unittests.cc
index 875695e..c9d081a 100644
--- a/chrome_frame/test/chrome_frame_unittests.cc
+++ b/chrome_frame/test/chrome_frame_unittests.cc
@@ -101,7 +101,10 @@ void ChromeFrameTestWithWebServer::TearDown() {
bool ChromeFrameTestWithWebServer::LaunchBrowser(BrowserKind browser,
const wchar_t* page) {
- std::wstring url = UTF8ToWide(server_.Resolve(page).spec());
+ std::wstring url = page;
+ if (url.find(L"files/") != std::wstring::npos)
+ url = UTF8ToWide(server_.Resolve(page).spec());
+
browser_ = browser;
if (browser == IE) {
browser_handle_.Set(chrome_frame_test::LaunchIE(url));
@@ -1741,3 +1744,29 @@ TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_BackForward) {
chrome_frame_test::CloseAllIEWindows();
}
+const wchar_t kChromeFrameAboutBlankUrl[] = L"cf:about:blank";
+
+TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_ChromeFrameFocusTest) {
+ TimedMsgLoop loop;
+
+ ASSERT_TRUE(LaunchBrowser(IE, kChromeFrameAboutBlankUrl));
+
+ // Allow some time for chrome to be launched.
+ loop.RunFor(kChromeFrameLaunchDelay);
+
+ HWND renderer_window = chrome_frame_test::GetChromeRendererWindow();
+ EXPECT_TRUE(IsWindow(renderer_window));
+
+ DWORD renderer_thread_id = 0;
+ DWORD renderer_process_id = 0;
+ renderer_thread_id = GetWindowThreadProcessId(renderer_window,
+ &renderer_process_id);
+
+ AttachThreadInput(GetCurrentThreadId(), renderer_thread_id, TRUE);
+ HWND focus_window = GetFocus();
+ EXPECT_TRUE(focus_window == renderer_window);
+ AttachThreadInput(GetCurrentThreadId(), renderer_thread_id, FALSE);
+
+ chrome_frame_test::CloseAllIEWindows();
+}
+