diff options
author | Pierre Rossi <pierre.rossi@digia.com> | 2014-08-21 14:02:10 +0200 |
---|---|---|
committer | Jocelyn Turcotte <jocelyn.turcotte@digia.com> | 2014-09-02 23:55:38 +0200 |
commit | ede95c2a1186c17996091950ec57c5998f73fa7a (patch) | |
tree | 96703d5c7c5968d775517ca249123c97890873eb /src/core | |
parent | ce7797dadce021c7da5d18a9b945100ae08c8224 (diff) |
Don't forward loading of error pages to the API layer
The fact that the error pages are HTML and get loaded through the
same mechanism should be kept an implementation detail and not be
considered as a new load in the API sense.
Also implement HasErrorPage for good measure and remove an anoying
warning from the demo browser.
The issue of the url not being changed remains in the QML test (but
it doesn't affect a typical browser-like UI since the user input is
still there untouched in the address bar), just make sure that failure
does not affect the later checks. It also seems like we have a focus
problem somehow, but the test should probably use a click for that
matter.
Change-Id: Ib5e363981a11287fdf4bfe84b93c999d96ed8087
Reviewed-by: Jocelyn Turcotte <jocelyn.turcotte@digia.com>
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/renderer/content_renderer_client_qt.cpp | 11 | ||||
-rw-r--r-- | src/core/renderer/content_renderer_client_qt.h | 3 | ||||
-rw-r--r-- | src/core/web_contents_adapter.cpp | 6 | ||||
-rw-r--r-- | src/core/web_contents_adapter.h | 1 | ||||
-rw-r--r-- | src/core/web_contents_delegate_qt.cpp | 27 | ||||
-rw-r--r-- | src/core/web_contents_delegate_qt.h | 1 |
6 files changed, 35 insertions, 14 deletions
diff --git a/src/core/renderer/content_renderer_client_qt.cpp b/src/core/renderer/content_renderer_client_qt.cpp index bb8c52266..6d4315b64 100644 --- a/src/core/renderer/content_renderer_client_qt.cpp +++ b/src/core/renderer/content_renderer_client_qt.cpp @@ -73,6 +73,17 @@ void ContentRendererClientQt::RenderViewCreated(content::RenderView* render_view new QtRenderViewObserver(render_view); } +bool ContentRendererClientQt::HasErrorPage(int httpStatusCode, std::string *errorDomain) +{ + // Use an internal error page, if we have one for the status code. + if (!LocalizedError::HasStrings(LocalizedError::kHttpErrorDomain, httpStatusCode)) { + return false; + } + + *errorDomain = LocalizedError::kHttpErrorDomain; + return true; +} + // To tap into the chromium localized strings. Ripped from the chrome layer (highly simplified). void ContentRendererClientQt::GetNavigationErrorStrings(content::RenderView* render_view, blink::WebFrame *frame, const blink::WebURLRequest &failed_request, const blink::WebURLError &error, std::string *error_html, base::string16 *error_description) { diff --git a/src/core/renderer/content_renderer_client_qt.h b/src/core/renderer/content_renderer_client_qt.h index af1aa0676..386495e20 100644 --- a/src/core/renderer/content_renderer_client_qt.h +++ b/src/core/renderer/content_renderer_client_qt.h @@ -50,7 +50,8 @@ public: virtual void RenderThreadStarted() Q_DECL_OVERRIDE; virtual void RenderViewCreated(content::RenderView *render_view) Q_DECL_OVERRIDE; - virtual bool ShouldSuppressErrorPage(content::RenderFrame *, const GURL &) Q_DECL_OVERRIDE { return true; } + virtual bool ShouldSuppressErrorPage(content::RenderFrame *, const GURL &) Q_DECL_OVERRIDE { return false; } + virtual bool HasErrorPage(int httpStatusCode, std::string *errorDomain) Q_DECL_OVERRIDE; virtual void GetNavigationErrorStrings(content::RenderView* render_view, blink::WebFrame* frame, const blink::WebURLRequest& failed_request , const blink::WebURLError& error, std::string* error_html, base::string16* error_description) Q_DECL_OVERRIDE; diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp index e221e0ce8..739b3b423 100644 --- a/src/core/web_contents_adapter.cpp +++ b/src/core/web_contents_adapter.cpp @@ -399,12 +399,6 @@ bool WebContentsAdapter::canGoForward() const return d->webContents->GetController().CanGoForward(); } -bool WebContentsAdapter::isLoading() const -{ - Q_D(const WebContentsAdapter); - return d->webContents->IsLoading(); -} - void WebContentsAdapter::stop() { Q_D(WebContentsAdapter); diff --git a/src/core/web_contents_adapter.h b/src/core/web_contents_adapter.h index bddc3e045..6bec50316 100644 --- a/src/core/web_contents_adapter.h +++ b/src/core/web_contents_adapter.h @@ -64,7 +64,6 @@ public: bool canGoBack() const; bool canGoForward() const; - bool isLoading() const; void stop(); void reload(); void load(const QUrl&); diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp index 0523d8b22..5de433b3b 100644 --- a/src/core/web_contents_delegate_qt.cpp +++ b/src/core/web_contents_delegate_qt.cpp @@ -56,9 +56,9 @@ #include "content/public/common/favicon_url.h" #include "content/public/common/file_chooser_params.h" #include "content/public/common/frame_navigate_params.h" +#include "content/public/common/url_constants.h" #include "webkit/common/webpreferences.h" - // Maps the LogSeverity defines in base/logging.h to the web engines message levels. static WebContentsAdapterClient::JavaScriptConsoleMessageLevel mapToJavascriptConsoleMessageLevel(int32 messageLevel) { if (messageLevel < 1) @@ -72,6 +72,7 @@ static WebContentsAdapterClient::JavaScriptConsoleMessageLevel mapToJavascriptCo WebContentsDelegateQt::WebContentsDelegateQt(content::WebContents *webContents, WebContentsAdapterClient *adapterClient) : m_viewClient(adapterClient) , m_lastReceivedFindReply(0) + , m_isLoadingErrorPage(false) { webContents->SetDelegate(this); Observe(webContents); @@ -124,11 +125,16 @@ void WebContentsDelegateQt::CloseContents(content::WebContents *source) void WebContentsDelegateQt::LoadProgressChanged(content::WebContents* source, double progress) { + if (m_isLoadingErrorPage) + return; m_viewClient->loadProgressChanged(qRound(progress * 100)); } -void WebContentsDelegateQt::DidStartProvisionalLoadForFrame(int64, int64, bool is_main_frame, const GURL &validated_url, bool, bool, content::RenderViewHost*) +void WebContentsDelegateQt::DidStartProvisionalLoadForFrame(int64, int64, bool is_main_frame, const GURL &validated_url, bool isErrorPage, bool, content::RenderViewHost*) { + m_isLoadingErrorPage = isErrorPage; + if (isErrorPage) + return; if (is_main_frame) m_viewClient->loadStarted(toQt(validated_url)); } @@ -147,15 +153,24 @@ void WebContentsDelegateQt::DidFailProvisionalLoad(int64 frame_id, const base::s DidFailLoad(frame_id, validated_url, is_main_frame, error_code, error_description, render_view_host); } -void WebContentsDelegateQt::DidFailLoad(int64, const GURL&, bool is_main_frame, int error_code, const base::string16 &error_description, content::RenderViewHost*) +void WebContentsDelegateQt::DidFailLoad(int64, const GURL&, bool is_main_frame, int error_code, const base::string16 &error_description, content::RenderViewHost *rvh) { - if (is_main_frame) - m_viewClient->loadFinished(false, error_code, toQt(error_description)); + if (!is_main_frame || m_isLoadingErrorPage) + return; + m_viewClient->loadFinished(false, error_code, toQt(error_description)); + m_viewClient->loadProgressChanged(0); } -void WebContentsDelegateQt::DidFinishLoad(int64, const GURL&, bool is_main_frame, content::RenderViewHost*) +void WebContentsDelegateQt::DidFinishLoad(int64, const GURL &url, bool is_main_frame, content::RenderViewHost*) { + if (m_isLoadingErrorPage) { + Q_ASSERT(url.is_valid() && url.spec() == content::kUnreachableWebDataURL); + m_viewClient->iconChanged(QUrl()); + return; + } + if (is_main_frame) { + m_viewClient->loadProgressChanged(100); m_viewClient->loadFinished(true); content::NavigationEntry *entry = web_contents()->GetController().GetActiveEntry(); diff --git a/src/core/web_contents_delegate_qt.h b/src/core/web_contents_delegate_qt.h index c1f0c4647..b7a23d3c2 100644 --- a/src/core/web_contents_delegate_qt.h +++ b/src/core/web_contents_delegate_qt.h @@ -94,6 +94,7 @@ private: WebContentsAdapterClient *m_viewClient; QString m_lastSearchedString; int m_lastReceivedFindReply; + bool m_isLoadingErrorPage; }; #endif // WEB_CONTENTS_DELEGATE_QT_H |