summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
Diffstat (limited to 'webkit')
-rw-r--r--webkit/glue/alt_error_page_resource_fetcher.cc11
-rw-r--r--webkit/glue/alt_error_page_resource_fetcher.h17
-rw-r--r--webkit/glue/webframe.h13
-rw-r--r--webkit/glue/webframe_impl.cc47
-rw-r--r--webkit/glue/webframe_impl.h16
-rw-r--r--webkit/glue/webframeloaderclient_impl.cc14
-rw-r--r--webkit/glue/webframeloaderclient_impl.h4
7 files changed, 36 insertions, 86 deletions
diff --git a/webkit/glue/alt_error_page_resource_fetcher.cc b/webkit/glue/alt_error_page_resource_fetcher.cc
index 5d1a3dc..6c8bad9 100644
--- a/webkit/glue/alt_error_page_resource_fetcher.cc
+++ b/webkit/glue/alt_error_page_resource_fetcher.cc
@@ -18,10 +18,11 @@ static const int kDownloadTimeoutSec = 3;
AltErrorPageResourceFetcher::AltErrorPageResourceFetcher(
const GURL& url,
WebFrame* frame,
- const GURL& unreachable_url,
+ const WebURLError& original_error,
Callback* callback)
- : callback_(callback),
- unreachable_url_(unreachable_url) {
+ : frame_(frame),
+ callback_(callback),
+ original_error_(original_error) {
fetcher_.reset(new ResourceFetcherWithTimeout(
url, frame, kDownloadTimeoutSec,
NewCallback(this, &AltErrorPageResourceFetcher::OnURLFetchComplete)));
@@ -39,9 +40,9 @@ void AltErrorPageResourceFetcher::OnURLFetchComplete(
const std::string& data) {
// A null response indicates a network error.
if (!response.isNull() && response.httpStatusCode() == 200) {
- callback_->Run(unreachable_url_, data);
+ callback_->Run(frame_, original_error_, data);
} else {
- callback_->Run(unreachable_url_, std::string());
+ callback_->Run(frame_, original_error_, std::string());
}
}
diff --git a/webkit/glue/alt_error_page_resource_fetcher.h b/webkit/glue/alt_error_page_resource_fetcher.h
index 3d50972..d591e02 100644
--- a/webkit/glue/alt_error_page_resource_fetcher.h
+++ b/webkit/glue/alt_error_page_resource_fetcher.h
@@ -8,6 +8,7 @@
#include "base/scoped_ptr.h"
#include "base/task.h"
#include "googleurl/src/gurl.h"
+#include "webkit/api/public/WebURLError.h"
class WebFrame;
@@ -16,7 +17,6 @@ class WebURLResponse;
}
namespace webkit_glue {
-
class ResourceFetcherWithTimeout;
// Used for downloading alternate dns error pages. Once downloading is done
@@ -24,13 +24,14 @@ class ResourceFetcherWithTimeout;
class AltErrorPageResourceFetcher {
public:
// This will be called when the alternative error page has been fetched,
- // successfully or not. If there is a failure, the second parameter (the
+ // successfully or not. If there is a failure, the third parameter (the
// data) will be empty.
- typedef Callback2<const GURL&, const std::string&>::Type Callback;
+ typedef Callback3<
+ WebFrame*, const WebKit::WebURLError&, const std::string&>::Type Callback;
AltErrorPageResourceFetcher(const GURL& url,
WebFrame* frame,
- const GURL& unreachable_url,
+ const WebKit::WebURLError& original_error,
Callback* callback);
~AltErrorPageResourceFetcher();
@@ -44,12 +45,12 @@ class AltErrorPageResourceFetcher {
// Does the actual fetching.
scoped_ptr<ResourceFetcherWithTimeout> fetcher_;
+ WebFrame* frame_;
scoped_ptr<Callback> callback_;
- // The "unreachable url" associated with this load. If there's an error
- // talking with the alt 404 page server, we need this to complete the
- // original load.
- GURL unreachable_url_;
+ // The error associated with this load. If there's an error talking with the
+ // alt error page server, we need this to complete the original load.
+ WebKit::WebURLError original_error_;
DISALLOW_COPY_AND_ASSIGN(AltErrorPageResourceFetcher);
};
diff --git a/webkit/glue/webframe.h b/webkit/glue/webframe.h
index fc09458..554bf90 100644
--- a/webkit/glue/webframe.h
+++ b/webkit/glue/webframe.h
@@ -118,16 +118,6 @@ class WebFrame {
const WebKit::WebURL& unreachable_url = WebKit::WebURL(),
bool replace = false) = 0;
- // Asks the WebFrame to try and download the alternate error page. We notify
- // the WebViewDelegate of the results so it can decide whether or not to show
- // something to the user (e.g., a local error page or the alternate error
- // page).
- virtual void LoadAlternateHTMLErrorPage(const WebKit::WebURLRequest& request,
- const WebKit::WebURLError& error,
- const GURL& error_page_url,
- bool replace,
- const GURL& fake_url) = 0;
-
// Called to associate the WebURLRequest with this frame. The request will
// be modified to inherit parameters that allow it to be loaded. This method
// ends up triggering WebViewDelegate::WillSendRequest.
@@ -213,6 +203,9 @@ class WebFrame {
// - (void)stopLoading;
virtual void StopLoading() = 0;
+ // Returns true if this frame is loading its main resource or a subresource.
+ virtual bool IsLoading() const = 0;
+
// Returns the frame that opened this frame, or NULL if this window has no
// opener.
virtual WebFrame* GetOpener() const = 0;
diff --git a/webkit/glue/webframe_impl.cc b/webkit/glue/webframe_impl.cc
index eed9443..3564e45 100644
--- a/webkit/glue/webframe_impl.cc
+++ b/webkit/glue/webframe_impl.cc
@@ -152,7 +152,6 @@ MSVC_POP_WARNING();
#include "webkit/api/public/WebScriptSource.h"
#include "webkit/api/public/WebSize.h"
#include "webkit/api/public/WebURLError.h"
-#include "webkit/glue/alt_error_page_resource_fetcher.h"
#include "webkit/glue/chrome_client_impl.h"
#include "webkit/glue/dom_operations.h"
#include "webkit/glue/dom_operations_private.h"
@@ -604,6 +603,12 @@ void WebFrameImpl::StopLoading() {
frame_->loader()->stopLoading(false);
}
+bool WebFrameImpl::IsLoading() const {
+ if (!frame_)
+ return false;
+ return frame_->loader()->isLoading();
+}
+
WebFrame* WebFrameImpl::GetOpener() const {
if (frame_) {
Frame* opener = frame_->loader()->opener();
@@ -1504,13 +1509,7 @@ void WebFrameImpl::Paint(skia::PlatformCanvas* canvas, const WebRect& rect) {
}
}
-bool WebFrameImpl::IsLoading() {
- // I'm assuming this does what we want.
- return frame_->loader()->isLoading();
-}
-
void WebFrameImpl::Closing() {
- alt_error_page_fetcher_.reset();
frame_ = NULL;
}
@@ -1528,11 +1527,6 @@ void WebFrameImpl::DidReceiveData(DocumentLoader* loader,
// NOTE: mac only does this if there is a document
frame_->loader()->addData(data, length);
-
- // It's possible that we get a DNS failure followed by a second load that
- // succeeds before we hear back from the alternate error page server. In
- // that case, cancel the alt error page download.
- alt_error_page_fetcher_.reset();
}
void WebFrameImpl::DidFail(const ResourceError& error, bool was_provisional) {
@@ -1549,25 +1543,6 @@ void WebFrameImpl::DidFail(const ResourceError& error, bool was_provisional) {
}
}
-void WebFrameImpl::LoadAlternateHTMLErrorPage(const WebURLRequest& request,
- const WebURLError& error,
- const GURL& error_page_url,
- bool replace,
- const GURL& fake_url) {
- // Load alternate HTML in place of the previous request. We use a fake_url
- // for the Base URL. That prevents other web content from the same origin
- // as the failed URL to script the error page.
-
- LoadHTMLString("", // Empty document
- fake_url,
- error.unreachableURL,
- replace);
-
- alt_error_page_fetcher_.reset(new AltErrorPageResourceFetcher(
- error_page_url, this, error.unreachableURL,
- NewCallback(this, &WebFrameImpl::AltErrorPageFinished)));
-}
-
void WebFrameImpl::DispatchWillSendRequest(WebURLRequest* request) {
ResourceResponse response;
frame_->loader()->client()->dispatchWillSendRequest(NULL, 0,
@@ -1847,13 +1822,3 @@ void WebFrameImpl::LoadJavaScriptURL(const KURL& url) {
frame_->loader()->end();
}
}
-
-void WebFrameImpl::AltErrorPageFinished(const GURL& unreachable_url,
- const std::string& html) {
- WebViewDelegate* d = GetWebViewImpl()->delegate();
- if (!d)
- return;
- WebURLError error;
- error.unreachableURL = unreachable_url;
- d->LoadNavigationErrorPage(this, WebURLRequest(), error, html, true);
-}
diff --git a/webkit/glue/webframe_impl.h b/webkit/glue/webframe_impl.h
index d7f0c1d..79f2f01 100644
--- a/webkit/glue/webframe_impl.h
+++ b/webkit/glue/webframe_impl.h
@@ -62,10 +62,6 @@ class SubstituteData;
struct WindowFeatures;
}
-namespace webkit_glue {
-class AltErrorPageResourceFetcher;
-}
-
// Implementation of WebFrame, note that this is a reference counted object.
class WebFrameImpl : public WebFrame, public base::RefCounted<WebFrameImpl> {
public:
@@ -95,12 +91,6 @@ class WebFrameImpl : public WebFrame, public base::RefCounted<WebFrameImpl> {
const WebKit::WebURL& base_url,
const WebKit::WebURL& unreachable_url = WebKit::WebURL(),
bool replace = false);
- virtual void LoadAlternateHTMLErrorPage(
- const WebKit::WebURLRequest& request,
- const WebKit::WebURLError& error,
- const GURL& error_page_url,
- bool replace,
- const GURL& fake_url);
virtual void DispatchWillSendRequest(WebKit::WebURLRequest* request);
virtual void ExecuteScript(const WebKit::WebScriptSource& source);
virtual void ExecuteScriptInNewContext(
@@ -119,6 +109,7 @@ class WebFrameImpl : public WebFrame, public base::RefCounted<WebFrameImpl> {
virtual WebKit::WebDataSource* GetDataSource() const;
virtual WebKit::WebDataSource* GetProvisionalDataSource() const;
virtual void StopLoading();
+ virtual bool IsLoading() const;
virtual WebFrame* GetOpener() const;
virtual WebFrame* GetParent() const;
virtual WebFrame* GetTop() const;
@@ -208,8 +199,6 @@ class WebFrameImpl : public WebFrame, public base::RefCounted<WebFrameImpl> {
void Layout();
void Paint(skia::PlatformCanvas* canvas, const WebKit::WebRect& rect);
- bool IsLoading();
-
void CreateFrameView();
// The plugin delegate is used to get notifications when downloads complete.
@@ -287,9 +276,6 @@ class WebFrameImpl : public WebFrame, public base::RefCounted<WebFrameImpl> {
int active_match_ordinal,
int request_id);
- // Resource fetcher for downloading an alternate DNS error page.
- scoped_ptr<webkit_glue::AltErrorPageResourceFetcher> alt_error_page_fetcher_;
-
// Used to check for leaks of this object.
static int live_object_count_;
diff --git a/webkit/glue/webframeloaderclient_impl.cc b/webkit/glue/webframeloaderclient_impl.cc
index 90f059e..3006fe4 100644
--- a/webkit/glue/webframeloaderclient_impl.cc
+++ b/webkit/glue/webframeloaderclient_impl.cc
@@ -354,8 +354,10 @@ void WebFrameLoaderClient::dispatchDidFinishLoading(DocumentLoader* loader,
const GURL& url = GetAlt404PageUrl(loader);
DCHECK(url.is_valid()) <<
"URL changed? It was valid in dispatchDidReceiveResponse.";
+ WebURLError original_error;
+ original_error.unreachableURL = webkit_glue::KURLToWebURL(loader->url());
alt_404_page_fetcher_.reset(new AltErrorPageResourceFetcher(
- url, webframe_, webkit_glue::KURLToGURL(loader->url()),
+ url, webframe_, original_error,
NewCallback(this, &WebFrameLoaderClient::Alt404PageFinished)));
}
@@ -383,7 +385,8 @@ GURL WebFrameLoaderClient::GetAlt404PageUrl(DocumentLoader* loader) {
return d->GetAlternateErrorPageURL(failedURL, WebViewDelegate::HTTP_404);
}
-void WebFrameLoaderClient::Alt404PageFinished(const GURL& unreachable_url,
+void WebFrameLoaderClient::Alt404PageFinished(WebFrame* frame,
+ const WebURLError& original_error,
const std::string& html) {
// TODO(darin): Move this processing out to the embedder.
if (!html.empty()) {
@@ -392,12 +395,11 @@ void WebFrameLoaderClient::Alt404PageFinished(const GURL& unreachable_url,
WebViewDelegate* d = webframe_->GetWebViewImpl()->delegate();
if (!d)
return;
- WebURLError error;
- error.unreachableURL = unreachable_url;
- d->LoadNavigationErrorPage(webframe_, WebURLRequest(), error, html, false);
+ d->LoadNavigationErrorPage(webframe_, WebURLRequest(), original_error, html,
+ false);
} else {
// Fall back on original text
- webframe_->LoadHTMLString(postponed_data_, unreachable_url);
+ webframe_->LoadHTMLString(postponed_data_, original_error.unreachableURL);
}
}
diff --git a/webkit/glue/webframeloaderclient_impl.h b/webkit/glue/webframeloaderclient_impl.h
index defa4d2..cdae117 100644
--- a/webkit/glue/webframeloaderclient_impl.h
+++ b/webkit/glue/webframeloaderclient_impl.h
@@ -206,7 +206,9 @@ class WebFrameLoaderClient : public WebCore::FrameLoaderClient {
private:
// Callback function for download of alternate 404 pages. If the server is
// down or we take too long to download the page, |html| will be empty.
- void Alt404PageFinished(const GURL& unreachable_url, const std::string& html);
+ void Alt404PageFinished(WebFrame* frame,
+ const WebKit::WebURLError& original_error,
+ const std::string& html);
void makeDocumentView();