diff options
author | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-30 21:38:50 +0000 |
---|---|---|
committer | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-30 21:38:50 +0000 |
commit | 9eeb35e21e43c6a91fe45b03feb9cf1d42b88b65 (patch) | |
tree | 06d0ad7b09dd3fa48a20565a622f8a5f0c6552da /chrome_frame | |
parent | f1cde5f421b507601fd23a7ec25962e5a1dbc3ba (diff) | |
download | chromium_src-9eeb35e21e43c6a91fe45b03feb9cf1d42b88b65.zip chromium_src-9eeb35e21e43c6a91fe45b03feb9cf1d42b88b65.tar.gz chromium_src-9eeb35e21e43c6a91fe45b03feb9cf1d42b88b65.tar.bz2 |
Top level navigations are not sent to the host browser in the ChromeFrame NPAPI implementation.
These include window.open requests, hrefs with target _blank, etc.
The ChromeFrame NPAPI plugin needs to set the renderer pref which indicates that the host browser
can handle top level requests.
We also pass an additional flag in the CreateExternal tab IPC which indicates whether the host
browser supports full tab mode browsing or not. This defaults to true for IE, as the activex
implementation relies on being able to launch a new window with the attach external tab prefix.
which assumes support for full tab mode for IE being available. If the host browser does not
support full tab browsing the window.open request which comes into the ExternalTabContainer
instance creates a dummy ExternalTabContainer instance which is destroyed when the top level
navigation info is sent back to the host browser.
This CL is a short term fix for the issues with the NPAPI ChromeFrame plugin. Will do some
investigation into a better approach.
Fixes bug http://code.google.com/p/chromium/issues/detail?id=57319
Test=Covered by existing ChromeFrame widget mode tests WidgetModeIE_SrcProperty and
WidgetModeFF_SrcProperty
Fixed incorrect assumptions in the test files used by these tests.
Bug=57319
Review URL: http://codereview.chromium.org/3549006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@61117 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame')
-rw-r--r-- | chrome_frame/chrome_active_document.cc | 3 | ||||
-rw-r--r-- | chrome_frame/chrome_frame_activex.cc | 8 | ||||
-rw-r--r-- | chrome_frame/chrome_frame_automation.cc | 10 | ||||
-rw-r--r-- | chrome_frame/chrome_frame_automation.h | 26 | ||||
-rw-r--r-- | chrome_frame/chrome_frame_npapi.cc | 11 | ||||
-rw-r--r-- | chrome_frame/chrome_frame_npapi.h | 3 | ||||
-rw-r--r-- | chrome_frame/chrome_frame_npapi_unittest.cc | 2 | ||||
-rw-r--r-- | chrome_frame/chrome_frame_plugin.h | 5 | ||||
-rw-r--r-- | chrome_frame/delete_chrome_history.cc | 2 | ||||
-rw-r--r-- | chrome_frame/test/automation_client_mock.cc | 16 | ||||
-rw-r--r-- | chrome_frame/test/chrome_frame_automation_mock.h | 2 | ||||
-rw-r--r-- | chrome_frame/test/data/src_property_frame1.html | 9 | ||||
-rw-r--r-- | chrome_frame/test/data/src_property_frame2.html | 15 | ||||
-rw-r--r-- | chrome_frame/test/data/src_property_host.html | 40 | ||||
-rw-r--r-- | chrome_frame/test/proxy_factory_mock.cc | 10 |
15 files changed, 95 insertions, 67 deletions
diff --git a/chrome_frame/chrome_active_document.cc b/chrome_frame/chrome_active_document.cc index 78f85f2..9b24507 100644 --- a/chrome_frame/chrome_active_document.cc +++ b/chrome_frame/chrome_active_document.cc @@ -1042,7 +1042,8 @@ bool ChromeActiveDocument::LaunchUrl(const ChromeFrameUrl& cf_url, if (profile.empty()) profile = GetHostProcessName(false); return InitializeAutomation(profile, L"", IsIEInPrivate(), - false, cf_url.gurl(), GURL(referrer)); + false, cf_url.gurl(), GURL(referrer), + false); } } diff --git a/chrome_frame/chrome_frame_activex.cc b/chrome_frame/chrome_frame_activex.cc index 705be34..5da61f5 100644 --- a/chrome_frame/chrome_frame_activex.cc +++ b/chrome_frame/chrome_frame_activex.cc @@ -460,17 +460,13 @@ HRESULT ChromeFrameActivex::IOleObject_SetClientSite( WideToUTF8(url_, url_.Length(), &utf8_url); } - // Only privileged instances of ActiveX Chrome Frame controls may read - // the chrome-network, and top-level-navigation settings from the registry. - // See issue: 54920 - if (is_privileged_) - InitializeAutomationSettings(); + InitializeAutomationSettings(); url_fetcher_->set_frame_busting(!is_privileged_); automation_client_->SetUrlFetcher(url_fetcher_.get()); if (!InitializeAutomation(profile_name, chrome_extra_arguments, IsIEInPrivate(), true, GURL(utf8_url), - GURL())) { + GURL(), false)) { DLOG(ERROR) << "Failed to navigate to url:" << utf8_url; return E_FAIL; } diff --git a/chrome_frame/chrome_frame_automation.cc b/chrome_frame/chrome_frame_automation.cc index a97e6d0..d49c8fb 100644 --- a/chrome_frame/chrome_frame_automation.cc +++ b/chrome_frame/chrome_frame_automation.cc @@ -565,7 +565,8 @@ ChromeFrameAutomationClient::ChromeFrameAutomationClient() external_tab_cookie_(0), url_fetcher_(NULL), url_fetcher_flags_(PluginUrlRequestManager::NOT_THREADSAFE), - navigate_after_initialization_(false) { + navigate_after_initialization_(false), + route_all_top_level_navigations_(false) { } ChromeFrameAutomationClient::~ChromeFrameAutomationClient() { @@ -719,7 +720,8 @@ bool ChromeFrameAutomationClient::InitiateNavigation(const std::string& url, if (!chrome_launch_params_) { FilePath profile_path; chrome_launch_params_ = new ChromeFrameLaunchParams(parsed_url, - referrer_gurl, profile_path, L"", L"", false, false); + referrer_gurl, profile_path, L"", L"", false, false, + route_all_top_level_navigations_); } else { chrome_launch_params_->set_referrer(referrer_gurl); chrome_launch_params_->set_url(parsed_url); @@ -937,7 +939,9 @@ void ChromeFrameAutomationClient::CreateExternalTab() { handle_top_level_requests_, chrome_launch_params_->url(), chrome_launch_params_->referrer(), - !chrome_launch_params_->widget_mode() // Infobars disabled in widget mode. + // Infobars disabled in widget mode. + !chrome_launch_params_->widget_mode(), + chrome_launch_params_->route_all_top_level_navigations(), }; THREAD_SAFE_UMA_HISTOGRAM_CUSTOM_COUNTS( diff --git a/chrome_frame/chrome_frame_automation.h b/chrome_frame/chrome_frame_automation.h index 0890fb7..8500ee7 100644 --- a/chrome_frame/chrome_frame_automation.h +++ b/chrome_frame/chrome_frame_automation.h @@ -110,12 +110,14 @@ class ChromeFrameLaunchParams : // NOLINT const FilePath& profile_path, const std::wstring& profile_name, const std::wstring& extra_arguments, - bool incognito, bool widget_mode) + bool incognito, bool widget_mode, + bool route_all_top_level_navigations) : launch_timeout_(kCommandExecutionTimeout), url_(url), referrer_(referrer), profile_path_(profile_path), profile_name_(profile_name), extra_arguments_(extra_arguments), version_check_(true), incognito_mode_(incognito), - is_widget_mode_(widget_mode) { + is_widget_mode_(widget_mode), + route_all_top_level_navigations_(route_all_top_level_navigations) { } ~ChromeFrameLaunchParams() { @@ -173,6 +175,15 @@ class ChromeFrameLaunchParams : // NOLINT return is_widget_mode_; } + void set_route_all_top_level_navigations( + bool route_all_top_level_navigations) { + route_all_top_level_navigations_ = route_all_top_level_navigations; + } + + bool route_all_top_level_navigations() const { + return route_all_top_level_navigations_; + } + protected: int launch_timeout_; GURL url_; @@ -183,6 +194,7 @@ class ChromeFrameLaunchParams : // NOLINT bool version_check_; bool incognito_mode_; bool is_widget_mode_; + bool route_all_top_level_navigations_; private: DISALLOW_COPY_AND_ASSIGN(ChromeFrameLaunchParams); @@ -422,6 +434,11 @@ class ChromeFrameAutomationClient // the website to put up a confirmation dialog on unload. void OnUnload(bool* should_unload); + void set_route_all_top_level_navigations( + bool route_all_top_level_navigations) { + route_all_top_level_navigations_ = route_all_top_level_navigations; + } + protected: // ChromeFrameAutomationProxy::LaunchDelegate implementation. virtual void LaunchComplete(ChromeFrameAutomationProxy* proxy, @@ -523,6 +540,11 @@ class ChromeFrameAutomationClient PluginUrlRequestManager* url_fetcher_; PluginUrlRequestManager::ThreadSafeFlags url_fetcher_flags_; + // set to true if the host needs to get notified of all top level navigations + // in this page. This typically applies to hosts which would render the new + // page without chrome frame. Defaults to false. + bool route_all_top_level_navigations_; + friend class BeginNavigateContext; friend class CreateExternalTabContext; }; diff --git a/chrome_frame/chrome_frame_npapi.cc b/chrome_frame/chrome_frame_npapi.cc index 4cd889be..f0874e2 100644 --- a/chrome_frame/chrome_frame_npapi.cc +++ b/chrome_frame/chrome_frame_npapi.cc @@ -246,6 +246,11 @@ bool ChromeFrameNPAPI::Initialize(NPMIMEType mime_type, NPP instance, automation_client_->set_use_chrome_network(chrome_network_arg); } + static const wchar_t kHandleTopLevelRequests[] = L"HandleTopLevelRequests"; + bool top_level_requests = GetConfigBool(true, kHandleTopLevelRequests); + automation_client_->set_handle_top_level_requests(top_level_requests); + automation_client_->set_route_all_top_level_navigations(true); + // Setup Url fetcher. url_fetcher_.set_NPPInstance(instance_); url_fetcher_.set_frame_busting(!is_privileged_); @@ -275,7 +280,7 @@ bool ChromeFrameNPAPI::Initialize(NPMIMEType mime_type, NPP instance, // host's in-private mode. return InitializeAutomation(profile_name, extra_arguments, GetBrowserIncognitoMode(), true, - GURL(src_), GURL()); + GURL(src_), GURL(), true); } void ChromeFrameNPAPI::Uninitialize() { @@ -466,7 +471,9 @@ void ChromeFrameNPAPI::OnTabbedOut(int tab_handle, bool reverse) { } void ChromeFrameNPAPI::OnOpenURL(int tab_handle, - const GURL& url, int open_disposition) { + const GURL& url, + const GURL& referrer, + int open_disposition) { std::string target; switch (open_disposition) { case NEW_FOREGROUND_TAB: diff --git a/chrome_frame/chrome_frame_npapi.h b/chrome_frame/chrome_frame_npapi.h index 8fd0c6f7..994b178 100644 --- a/chrome_frame/chrome_frame_npapi.h +++ b/chrome_frame/chrome_frame_npapi.h @@ -132,7 +132,8 @@ END_MSG_MAP() // instance. virtual void OnAcceleratorPressed(int tab_handle, const MSG& accel_message); virtual void OnTabbedOut(int tab_handle, bool reverse); - virtual void OnOpenURL(int tab_handle, const GURL& url, int open_disposition); + virtual void OnOpenURL(int tab_handle, const GURL& url, + const GURL& referrer, int open_disposition); virtual void OnLoad(int tab_handle, const GURL& url); virtual void OnMessageFromChromeFrame(int tab_handle, const std::string& message, diff --git a/chrome_frame/chrome_frame_npapi_unittest.cc b/chrome_frame/chrome_frame_npapi_unittest.cc index 324fad1..c0a0208 100644 --- a/chrome_frame/chrome_frame_npapi_unittest.cc +++ b/chrome_frame/chrome_frame_npapi_unittest.cc @@ -137,7 +137,7 @@ class TestNPAPIPrivilegedApi: public ::testing::Test { scoped_refptr<ChromeFrameLaunchParams> launch_params( new ChromeFrameLaunchParams(GURL(), GURL(), FilePath(), profile_name, - extra_args, is_incognito, true)); + extra_args, is_incognito, true, false)); EXPECT_CALL(*mock_automation, Initialize(_, LaunchParamEq(true, extra_args, is_incognito, true))) diff --git a/chrome_frame/chrome_frame_plugin.h b/chrome_frame/chrome_frame_plugin.h index de63b3c..6fa795e 100644 --- a/chrome_frame/chrome_frame_plugin.h +++ b/chrome_frame/chrome_frame_plugin.h @@ -61,7 +61,8 @@ END_MSG_MAP() bool InitializeAutomation(const std::wstring& profile_name, const std::wstring& extra_chrome_arguments, bool incognito, bool is_widget_mode, - const GURL& url, const GURL& referrer) { + const GURL& url, const GURL& referrer, + bool route_all_top_level_navigations) { DCHECK(IsValid()); DCHECK(launch_params_ == NULL); // We don't want to do incognito when privileged, since we're @@ -75,7 +76,7 @@ END_MSG_MAP() FilePath actual_profile_name = profile_path.BaseName(); launch_params_ = new ChromeFrameLaunchParams(url, referrer, profile_path, actual_profile_name.value(), extra_chrome_arguments, incognito_mode, - is_widget_mode); + is_widget_mode, route_all_top_level_navigations); return automation_client_->Initialize(this, launch_params_); } diff --git a/chrome_frame/delete_chrome_history.cc b/chrome_frame/delete_chrome_history.cc index 19eccf3..1d58df9 100644 --- a/chrome_frame/delete_chrome_history.cc +++ b/chrome_frame/delete_chrome_history.cc @@ -74,7 +74,7 @@ STDMETHODIMP DeleteChromeHistory::DeleteBrowsingHistory(DWORD flags) { return S_OK; } if (!InitializeAutomation(GetHostProcessName(false), L"", false, false, - GURL(), GURL())) { + GURL(), GURL(), true)) { return E_UNEXPECTED; } diff --git a/chrome_frame/test/automation_client_mock.cc b/chrome_frame/test/automation_client_mock.cc index 8ea09b6..7626c0b 100644 --- a/chrome_frame/test/automation_client_mock.cc +++ b/chrome_frame/test/automation_client_mock.cc @@ -105,7 +105,7 @@ TEST(CFACWithChrome, CreateTooFast) { GURL empty; scoped_refptr<ChromeFrameLaunchParams> clp(new ChromeFrameLaunchParams( empty, empty, profile_path, profile_path.BaseName().value(), L"", - false, false)); + false, false, false)); clp->set_launch_timeout(timeout); clp->set_version_check(false); EXPECT_TRUE(client->Initialize(&cfd, clp)); @@ -137,7 +137,7 @@ TEST(CFACWithChrome, CreateNotSoFast) { GURL empty; scoped_refptr<ChromeFrameLaunchParams> clp(new ChromeFrameLaunchParams( empty, empty, profile_path, profile_path.BaseName().value(), L"", - false, false)); + false, false, false)); clp->set_launch_timeout(timeout); clp->set_version_check(false); EXPECT_TRUE(client->Initialize(&cfd, clp)); @@ -183,7 +183,7 @@ TEST(CFACWithChrome, NavigateOk) { GURL empty; scoped_refptr<ChromeFrameLaunchParams> clp(new ChromeFrameLaunchParams( empty, empty, profile_path, profile_path.BaseName().value(), L"", - false, false)); + false, false, false)); clp->set_launch_timeout(timeout); clp->set_version_check(false); EXPECT_TRUE(client->Initialize(&cfd, clp)); @@ -229,7 +229,7 @@ TEST(CFACWithChrome, NavigateFailed) { GURL empty; scoped_refptr<ChromeFrameLaunchParams> clp(new ChromeFrameLaunchParams( empty, empty, profile_path, profile_path.BaseName().value(), L"", - false, false)); + false, false, false)); clp->set_launch_timeout(10000); clp->set_version_check(false); EXPECT_TRUE(client->Initialize(&cfd, clp)); @@ -267,7 +267,7 @@ TEST_F(CFACMockTest, MockedCreateTabOk) { GURL empty; scoped_refptr<ChromeFrameLaunchParams> clp(new ChromeFrameLaunchParams( empty, empty, profile_path_, profile_path_.BaseName().value(), L"", - false, false)); + false, false, false)); clp->set_launch_timeout(timeout); clp->set_version_check(false); EXPECT_TRUE(client_->Initialize(&cfd_, clp)); @@ -299,7 +299,7 @@ TEST_F(CFACMockTest, MockedCreateTabFailed) { GURL empty; scoped_refptr<ChromeFrameLaunchParams> clp(new ChromeFrameLaunchParams( empty, empty, profile_path_, profile_path_.BaseName().value(), L"", - false, false)); + false, false, false)); clp->set_launch_timeout(timeout_); clp->set_version_check(false); EXPECT_TRUE(client_->Initialize(&cfd_, clp)); @@ -339,7 +339,7 @@ TEST_F(CFACMockTest, OnChannelError) { GURL empty; scoped_refptr<ChromeFrameLaunchParams> clp(new ChromeFrameLaunchParams( empty, empty, profile_path_, profile_path_.BaseName().value(), L"", - false, false)); + false, false, false)); clp->set_launch_timeout(1); // Unneeded timeout, but can't be 0. clp->set_version_check(false); @@ -457,7 +457,7 @@ TEST_F(CFACMockTest, NavigateTwiceAfterInitToSameUrl) { scoped_refptr<ChromeFrameLaunchParams> launch_params( new ChromeFrameLaunchParams( GURL("http://www.nonexistent.com"), empty, profile_path_, - profile_path_.BaseName().value(), L"", false, false)); + profile_path_.BaseName().value(), L"", false, false, false)); launch_params->set_launch_timeout(timeout); launch_params->set_version_check(false); EXPECT_TRUE(client_->Initialize(&cfd_, launch_params)); diff --git a/chrome_frame/test/chrome_frame_automation_mock.h b/chrome_frame/test/chrome_frame_automation_mock.h index b080bea..2d7a76e 100644 --- a/chrome_frame/test/chrome_frame_automation_mock.h +++ b/chrome_frame/test/chrome_frame_automation_mock.h @@ -40,7 +40,7 @@ class AutomationMockDelegate GURL empty; scoped_refptr<ChromeFrameLaunchParams> clp( new ChromeFrameLaunchParams(empty, empty, profile_path, profile_name, - extra_chrome_arguments, incognito, is_widget_mode)); + extra_chrome_arguments, incognito, is_widget_mode, false)); clp->set_launch_timeout(launch_timeout); clp->set_version_check(perform_version_check); automation_client_->Initialize(this, clp); diff --git a/chrome_frame/test/data/src_property_frame1.html b/chrome_frame/test/data/src_property_frame1.html index 1eaa3cf..784a4c8 100644 --- a/chrome_frame/test/data/src_property_frame1.html +++ b/chrome_frame/test/data/src_property_frame1.html @@ -1,7 +1,14 @@ <html>
<head><title>src property test - page 1</title>
+ <script type="text/javascript" src="chrome_frame_tester_helpers.js"> + </script> <script type="text/javascript">
- function redirect(){
+ function redirect() {
+ if (!isRunningInChrome()) {
+ onFailure("SrcProperty", 1,
+ "src_property_frame1.html should not load in Chrome");
+ return;
+ }
window.location = "src_property_frame2.html";
}
</script>
diff --git a/chrome_frame/test/data/src_property_frame2.html b/chrome_frame/test/data/src_property_frame2.html index c5c0364..4a7c63e 100644 --- a/chrome_frame/test/data/src_property_frame2.html +++ b/chrome_frame/test/data/src_property_frame2.html @@ -1,7 +1,20 @@ <html>
<head><title>src property test - page 2</title>
+ <script type="text/javascript" src="chrome_frame_tester_helpers.js"> + </script> + <script type="text/javascript">
+ function onLoad() {
+ if (isRunningInChrome()) {
+ onFailure("SrcProperty", 1,
+ "src_property_frame2.html should not load in Chrome");
+ return;
+ } else {
+ onSuccess("SrcProperty", 1);
+ }
+ }
+ </script>
</head>
- <body>
+ <body onload="onLoad();">
<h2>Redirected!</h2>
<p>All finished.</p>
</body>
diff --git a/chrome_frame/test/data/src_property_host.html b/chrome_frame/test/data/src_property_host.html index b17dd1b..ee25208 100644 --- a/chrome_frame/test/data/src_property_host.html +++ b/chrome_frame/test/data/src_property_host.html @@ -7,43 +7,19 @@ onFailure("ChromeFrame_SrcTest", 1, "ChromeFrame Navigation failed"); } - var load_count = 2;
-
function OnChromeFrameLoaded(url) { - try { - url = url.data; - - var chromeFrame = GetChromeFrame(); - var frame_url = chromeFrame.src; - - appendStatus("Loaded URL: " + url + " Frame url: " + frame_url); - load_count--; + url = url.data; - if (load_count) { - // For the first load, the URLs should match. - if (frame_url != url) { - onFailure("SrcProperty", 1, "Url: " + url); - } - } else { - // Previous versions changed the frame URL when internal navigation - // was performed. This does not match how iframes behave, and so we - // report success only in the case that they continue to match, even - // though the "internal" URL is different (and not visible) to the - // external host. - if (frame_url == url) { - onFailure("SrcProperty", 1, "Url: " + url); - } else { - onSuccess("SrcProperty", 1); - } - }
- } catch (e) {
- onFailure("SrcProperty", 1, "OnChromeFrameLoaded: " + e.description);
- } + var chromeFrame = GetChromeFrame(); + var frame_url = chromeFrame.src; + + appendStatus("Loaded URL: " + url + " Frame url: " + frame_url); } function GetChromeFrame() { - return window.document.ChromeFrame; - } + return window.document.ChromeFrame;
+ }
+
</script> </head> <body> diff --git a/chrome_frame/test/proxy_factory_mock.cc b/chrome_frame/test/proxy_factory_mock.cc index 4e9ddbc..6e15104 100644 --- a/chrome_frame/test/proxy_factory_mock.cc +++ b/chrome_frame/test/proxy_factory_mock.cc @@ -21,7 +21,7 @@ TEST(ProxyFactoryTest, CreateDestroy) { FilePath profile_path; scoped_refptr<ChromeFrameLaunchParams> params( new ChromeFrameLaunchParams(empty, empty, profile_path, - L"Adam.N.Epilinter", L"", false, false)); + L"Adam.N.Epilinter", L"", false, false, false)); params->set_launch_timeout(0); params->set_version_check(false); @@ -41,7 +41,7 @@ TEST(ProxyFactoryTest, CreateSameProfile) { FilePath profile_path; scoped_refptr<ChromeFrameLaunchParams> params( new ChromeFrameLaunchParams(empty, empty, profile_path, - L"Dr. Gratiano Forbeson", L"", false, false)); + L"Dr. Gratiano Forbeson", L"", false, false, false)); params->set_launch_timeout(0); params->set_version_check(false); @@ -65,13 +65,13 @@ TEST(ProxyFactoryTest, CreateDifferentProfiles) { FilePath profile_path; scoped_refptr<ChromeFrameLaunchParams> params1( new ChromeFrameLaunchParams(empty, empty, profile_path, - L"Adam.N.Epilinter", L"", false, false)); + L"Adam.N.Epilinter", L"", false, false, false)); params1->set_launch_timeout(0); params1->set_version_check(false); scoped_refptr<ChromeFrameLaunchParams> params2( new ChromeFrameLaunchParams(empty, empty, profile_path, - L"Dr. Gratiano Forbeson", L"", false, false)); + L"Dr. Gratiano Forbeson", L"", false, false, false)); params2->set_launch_timeout(0); params2->set_version_check(false); @@ -95,7 +95,7 @@ TEST(ProxyFactoryTest, FastCreateDestroy) { FilePath profile_path; scoped_refptr<ChromeFrameLaunchParams> params( new ChromeFrameLaunchParams(empty, empty, profile_path, - L"Dr. Gratiano Forbeson", L"", false, false)); + L"Dr. Gratiano Forbeson", L"", false, false, false)); params->set_launch_timeout(10000); params->set_version_check(false); |