summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorerikkay@google.com <erikkay@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-10 19:34:43 +0000
committererikkay@google.com <erikkay@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-10 19:34:43 +0000
commit0578a5011ceff5a50c9e2905d48d5747cf72569b (patch)
tree383666ae6cf1e977c53ba85d81ac98095beb7e81
parent297117029c8cd44b92d8529bc9b29eeb8e5fffb9 (diff)
downloadchromium_src-0578a5011ceff5a50c9e2905d48d5747cf72569b.zip
chromium_src-0578a5011ceff5a50c9e2905d48d5747cf72569b.tar.gz
chromium_src-0578a5011ceff5a50c9e2905d48d5747cf72569b.tar.bz2
Change old code from "unloadListnerChanged" model to new WebKit EnableSuddenTermination, unforking a bunch of code.
BUG=http://crbug.com/4064 Review URL: http://codereview.chromium.org/9746 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5116 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/renderer/render_view.cc24
-rw-r--r--chrome/renderer/render_view.h3
-rw-r--r--webkit/glue/chrome_client_impl.cc12
-rw-r--r--webkit/glue/chrome_client_impl.h3
-rw-r--r--webkit/glue/webframe.h3
-rw-r--r--webkit/glue/webframe_impl.cc8
-rw-r--r--webkit/glue/webframe_impl.h1
-rw-r--r--webkit/glue/webframeloaderclient_impl.cc7
-rw-r--r--webkit/glue/webframeloaderclient_impl.h2
-rw-r--r--webkit/glue/webview_delegate.h6
10 files changed, 27 insertions, 42 deletions
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index cbae9d0..66a5092 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -1647,24 +1647,12 @@ bool RenderView::RunBeforeUnloadConfirm(WebView* webview,
return success;
}
-void RenderView::OnUnloadListenerChanged(WebView* webview, WebFrame* webframe) {
- bool has_listener = false;
- if (!has_unload_listener_) {
- has_listener = webframe->HasUnloadListener();
- } else {
- WebFrame* frame = webview->GetMainFrame();
- while (frame != NULL) {
- if (frame->HasUnloadListener()) {
- has_listener = true;
- break;
- }
- frame = webview->GetNextFrameAfter(frame, false);
- }
- }
- if (has_listener != has_unload_listener_) {
- has_unload_listener_ = has_listener;
- Send(new ViewHostMsg_UnloadListenerChanged(routing_id_, has_listener));
- }
+void RenderView::EnableSuddenTermination() {
+ Send(new ViewHostMsg_UnloadListenerChanged(routing_id_, false));
+}
+
+void RenderView::DisableSuddenTermination() {
+ Send(new ViewHostMsg_UnloadListenerChanged(routing_id_, true));
}
void RenderView::QueryFormFieldAutofill(const std::wstring& field_name,
diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h
index 8484afd..3006448 100644
--- a/chrome/renderer/render_view.h
+++ b/chrome/renderer/render_view.h
@@ -126,7 +126,8 @@ class RenderView : public RenderWidget, public WebViewDelegate,
std::wstring* result);
virtual bool RunBeforeUnloadConfirm(WebView* webview,
const std::wstring& message);
- virtual void OnUnloadListenerChanged(WebView* webview, WebFrame* webframe);
+ virtual void EnableSuddenTermination();
+ virtual void DisableSuddenTermination();
virtual void QueryFormFieldAutofill(const std::wstring& field_name,
const std::wstring& text,
int64 node_id);
diff --git a/webkit/glue/chrome_client_impl.cc b/webkit/glue/chrome_client_impl.cc
index 4142548..4fe6e60 100644
--- a/webkit/glue/chrome_client_impl.cc
+++ b/webkit/glue/chrome_client_impl.cc
@@ -468,3 +468,15 @@ void ChromeClientImpl::SetCursor(const WebCursor& cursor) {
if (d)
d->SetCursor(webview_, cursor);
}
+
+void ChromeClientImpl::enableSuddenTermination() {
+ WebViewDelegate* d = webview_->delegate();
+ if (d)
+ d->EnableSuddenTermination();
+}
+
+void ChromeClientImpl::disableSuddenTermination() {
+ WebViewDelegate* d = webview_->delegate();
+ if (d)
+ d->DisableSuddenTermination();
+}
diff --git a/webkit/glue/chrome_client_impl.h b/webkit/glue/chrome_client_impl.h
index c8951ee..b985103 100644
--- a/webkit/glue/chrome_client_impl.h
+++ b/webkit/glue/chrome_client_impl.h
@@ -120,6 +120,9 @@ public:
void SetCursor(const WebCursor& cursor);
+ virtual void enableSuddenTermination();
+ virtual void disableSuddenTermination();
+
private:
WebViewImpl* webview_; // weak pointer
bool toolbars_visible_;
diff --git a/webkit/glue/webframe.h b/webkit/glue/webframe.h
index 9484d3d..0557e35 100644
--- a/webkit/glue/webframe.h
+++ b/webkit/glue/webframe.h
@@ -352,9 +352,6 @@ class WebFrame : public base::RefCounted<WebFrame> {
// Prints one page. |page| is 0-based.
virtual bool SpoolPage(int page, gfx::PlatformCanvas* canvas) = 0;
- // Does this frame have an onunload or unbeforeunload event listener?
- virtual bool HasUnloadListener() = 0;
-
// Is this frame reloading with allowing stale data? This will be true when
// the encoding of the page is changed and it needs to be re-interpreted,
// but no additional loads should occur.
diff --git a/webkit/glue/webframe_impl.cc b/webkit/glue/webframe_impl.cc
index b749df7..5f1df1d 100644
--- a/webkit/glue/webframe_impl.cc
+++ b/webkit/glue/webframe_impl.cc
@@ -1845,14 +1845,6 @@ bool WebFrameImpl::SpoolPage(int page, gfx::PlatformCanvas* canvas) {
return true;
}
-bool WebFrameImpl::HasUnloadListener() {
- if (frame() && frame()->document()) {
- Document* doc = frame()->document();
- return doc->hasUnloadEventListener();
- }
- return false;
-}
-
bool WebFrameImpl::IsReloadAllowingStaleData() const {
FrameLoader* loader = frame() ? frame()->loader() : NULL;
if (loader) {
diff --git a/webkit/glue/webframe_impl.h b/webkit/glue/webframe_impl.h
index 14756f9..af92cd2 100644
--- a/webkit/glue/webframe_impl.h
+++ b/webkit/glue/webframe_impl.h
@@ -267,7 +267,6 @@ class WebFrameImpl : public WebFrame {
// Returns true if the frame CSS is in "printing" mode.
bool printing() const { return printing_; }
- virtual bool HasUnloadListener();
virtual bool IsReloadAllowingStaleData() const;
protected:
diff --git a/webkit/glue/webframeloaderclient_impl.cc b/webkit/glue/webframeloaderclient_impl.cc
index f7ab5cc..c35cf9d 100644
--- a/webkit/glue/webframeloaderclient_impl.cc
+++ b/webkit/glue/webframeloaderclient_impl.cc
@@ -107,13 +107,6 @@ void WebFrameLoaderClient::didPerformFirstNavigation() const {
void WebFrameLoaderClient::registerForIconNotification(bool listen){
}
-void WebFrameLoaderClient::unloadListenerChanged() {
- WebViewImpl* webview = webframe_->webview_impl();
- WebViewDelegate* d = webview->delegate();
- if (d)
- d->OnUnloadListenerChanged(webview, webframe_);
-}
-
bool WebFrameLoaderClient::hasWebView() const {
return webframe_->webview_impl() != NULL;
}
diff --git a/webkit/glue/webframeloaderclient_impl.h b/webkit/glue/webframeloaderclient_impl.h
index b14450d..5459f93 100644
--- a/webkit/glue/webframeloaderclient_impl.h
+++ b/webkit/glue/webframeloaderclient_impl.h
@@ -187,8 +187,6 @@ class WebFrameLoaderClient : public WebCore::FrameLoaderClient {
virtual void registerForIconNotification(bool listen = true);
- virtual void unloadListenerChanged();
-
// Callback function for download of alternate 404 pages. If the server is
// down or we take more than 1s to download the page, html will be an empty
// string.
diff --git a/webkit/glue/webview_delegate.h b/webkit/glue/webview_delegate.h
index 1ce50c5..dd6ba52 100644
--- a/webkit/glue/webview_delegate.h
+++ b/webkit/glue/webview_delegate.h
@@ -454,8 +454,10 @@ class WebViewDelegate : virtual public WebWidgetDelegate {
const AutofillForm& form) {
}
- //
- virtual void OnUnloadListenerChanged(WebView* webview, WebFrame* webframe) {
+ virtual void EnableSuddenTermination() {
+ }
+
+ virtual void DisableSuddenTermination() {
}
// Queries the browser for suggestions to be shown for the form text field