Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(255)

Unified Diff: chrome/renderer/net/net_error_helper.cc

Issue 207553008: Surface button for loading stale cache copy on net error page. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix incorrect spelling of iOS. Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/renderer/net/net_error_helper.cc
diff --git a/chrome/renderer/net/net_error_helper.cc b/chrome/renderer/net/net_error_helper.cc
index 1d9529ad033a817fac667a8fde02be29a26fe5ac..5ef563f7354e61d1f00b82d0dd07212da09f399d 100644
--- a/chrome/renderer/net/net_error_helper.cc
+++ b/chrome/renderer/net/net_error_helper.cc
@@ -16,7 +16,7 @@
#include "chrome/common/localized_error.h"
#include "chrome/common/net/net_error_info.h"
#include "chrome/common/render_messages.h"
-#include "chrome/renderer/net/error_cache_load.h"
+#include "chrome/renderer/net/net_error_page_controller.h"
#include "content/public/common/content_client.h"
#include "content/public/common/url_constants.h"
#include "content/public/renderer/content_renderer_client.h"
@@ -95,6 +95,18 @@ NetErrorHelper::~NetErrorHelper() {
RenderThread::Get()->RemoveObserver(this);
}
+void NetErrorHelper::ReloadButtonPressed() {
+ core_.ExecuteButtonPress(NetErrorHelperCore::RELOAD_BUTTON);
+}
+
+void NetErrorHelper::LoadStaleButtonPressed() {
+ core_.ExecuteButtonPress(NetErrorHelperCore::LOAD_STALE_BUTTON);
+}
+
+void NetErrorHelper::MoreButtonPressed() {
+ core_.ExecuteButtonPress(NetErrorHelperCore::MORE_BUTTON);
+}
+
void NetErrorHelper::DidStartProvisionalLoad() {
blink::WebFrame* frame = render_frame()->GetWebFrame();
core_.OnStartLoad(GetFrameType(frame), GetLoadingPageType(frame));
@@ -148,6 +160,8 @@ void NetErrorHelper::GenerateLocalizedErrorPage(
const blink::WebURLError& error,
bool is_failed_post,
scoped_ptr<LocalizedError::ErrorPageParams> params,
+ bool* reload_button_shown,
+ bool* load_stale_button_shown,
std::string* error_html) const {
error_html->clear();
@@ -160,11 +174,14 @@ void NetErrorHelper::GenerateLocalizedErrorPage(
base::DictionaryValue error_strings;
LocalizedError::GetStrings(error.reason, error.domain.utf8(),
error.unreachableURL, is_failed_post,
- error.staleCopyInCache,
+ error.staleCopyInCache && !is_failed_post,
RenderThread::Get()->GetLocale(),
render_frame()->GetRenderView()->
GetAcceptLanguages(),
params.Pass(), &error_strings);
+ *reload_button_shown = error_strings.Get("reloadButton", NULL);
+ *load_stale_button_shown = error_strings.Get("staleLoadButton", NULL);
+
// "t" is the id of the template's root node.
*error_html = webui::GetTemplatesHtml(template_html, &error_strings, "t");
}
@@ -179,8 +196,8 @@ void NetErrorHelper::LoadErrorPageInMainFrame(const std::string& html,
frame->loadHTMLString(html, GURL(kUnreachableWebDataURL), failed_url, true);
}
-void NetErrorHelper::EnableStaleLoadBindings(const GURL& page_url) {
- ErrorCacheLoad::Install(render_frame(), page_url);
+void NetErrorHelper::EnablePageHelperFunctions() {
+ NetErrorPageController::Install(render_frame());
}
void NetErrorHelper::UpdateErrorPage(const blink::WebURLError& error,
@@ -190,7 +207,7 @@ void NetErrorHelper::UpdateErrorPage(const blink::WebURLError& error,
error.domain.utf8(),
error.unreachableURL,
is_failed_post,
- error.staleCopyInCache,
+ error.staleCopyInCache && !is_failed_post,
RenderThread::Get()->GetLocale(),
render_frame()->GetRenderView()->
GetAcceptLanguages(),
@@ -243,6 +260,16 @@ void NetErrorHelper::ReloadPage() {
render_frame()->GetWebFrame()->reload(false);
}
+void NetErrorHelper::LoadPageFromCache(const GURL& page_url) {
+ blink::WebFrame* web_frame = render_frame()->GetWebFrame();
+ DCHECK(!EqualsASCII(web_frame->dataSource()->request().httpMethod(), "POST"));
+
+ blink::WebURLRequest request(page_url);
+ request.setCachePolicy(blink::WebURLRequest::ReturnCacheDataDontLoad);
+
+ web_frame->loadRequest(request);
+}
+
void NetErrorHelper::OnNetErrorInfo(int status_num) {
DCHECK(status_num >= 0 && status_num < chrome_common_net::DNS_PROBE_MAX);

Powered by Google App Engine
This is Rietveld 408576698