summaryrefslogtreecommitdiffstats
path: root/chrome/browser/external_tab_container.cc
diff options
context:
space:
mode:
authorananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-27 01:11:02 +0000
committerananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-27 01:11:02 +0000
commit085d9cf7081dbb63842e91f369b7eb6974ad752b (patch)
tree25bd3645186969db236df55ae4c960a9b1efc95d /chrome/browser/external_tab_container.cc
parent7dab56cc74dd0298771058a2ae26a956e7f027a6 (diff)
downloadchromium_src-085d9cf7081dbb63842e91f369b7eb6974ad752b.zip
chromium_src-085d9cf7081dbb63842e91f369b7eb6974ad752b.tar.gz
chromium_src-085d9cf7081dbb63842e91f369b7eb6974ad752b.tar.bz2
Unload and BeforeUnload handlers would not get invoked within pages inside ChromeFrame. This was because
the ExternalTabContainer would close the underlying tab contents in its OnDestroy handler without invoking unload handlers on the page if any. In Chrome the TabStripModel invokes the RunUnloadListenerBeforeClosing on the delegate which is implemented by the browser. We need to mimic this in the external tab container. To achieve this we now have a static helper function RunUnloadListenerBeforeClosingHelper in the browser class which is called by the ExternalTabContainer and the Browser::RunUnloadListenerBeforeClosing function. The ExternalTabContainer also needs to wait for the unload handlers on the page to return before it returns control back to the host browser. To achieve this we enter a nested modal loop which is exited when the underlying tab is closed. Fixes bug http://code.google.com/p/chromium/issues/detail?id=31853 Bug=31853 Test=Covered by ChromeFrame unit test. Review URL: http://codereview.chromium.org/543183 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@37197 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/external_tab_container.cc')
-rw-r--r--chrome/browser/external_tab_container.cc12
1 files changed, 11 insertions, 1 deletions
diff --git a/chrome/browser/external_tab_container.cc b/chrome/browser/external_tab_container.cc
index 26da69f..8ec811c 100644
--- a/chrome/browser/external_tab_container.cc
+++ b/chrome/browser/external_tab_container.cc
@@ -47,7 +47,8 @@ ExternalTabContainer::ExternalTabContainer(
load_requests_via_automation_(false),
handle_top_level_requests_(false),
external_method_factory_(this),
- enabled_extension_automation_(false) {
+ enabled_extension_automation_(false),
+ waiting_for_unload_event_(false) {
}
ExternalTabContainer::~ExternalTabContainer() {
@@ -162,6 +163,12 @@ void ExternalTabContainer::Uninitialize() {
registrar_.RemoveAll();
if (tab_contents_) {
+ if (Browser::RunUnloadEventsHelper(tab_contents_)) {
+ waiting_for_unload_event_ = true;
+ MessageLoop::current()->Run();
+ waiting_for_unload_event_ = false;
+ }
+
RenderViewHost* rvh = tab_contents_->render_view_host();
if (rvh && DevToolsManager::GetInstance()) {
DevToolsManager::GetInstance()->UnregisterDevToolsClientHostFor(rvh);
@@ -361,6 +368,9 @@ void ExternalTabContainer::LoadingStateChanged(TabContents* source) {
}
void ExternalTabContainer::CloseContents(TabContents* source) {
+ if (waiting_for_unload_event_) {
+ MessageLoop::current()->Quit();
+ }
}
void ExternalTabContainer::MoveContents(TabContents* source,