summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/extensions/extension_webnavigation_api.cc3
-rw-r--r--chrome/browser/extensions/extension_webnavigation_api.h10
-rw-r--r--chrome/renderer/chrome_content_renderer_client.cc71
-rw-r--r--chrome/renderer/chrome_content_renderer_client.h7
-rw-r--r--chrome/renderer/localized_error.cc9
-rw-r--r--chrome/renderer/localized_error.h6
6 files changed, 67 insertions, 39 deletions
diff --git a/chrome/browser/extensions/extension_webnavigation_api.cc b/chrome/browser/extensions/extension_webnavigation_api.cc
index b675871..c7471f9 100644
--- a/chrome/browser/extensions/extension_webnavigation_api.cc
+++ b/chrome/browser/extensions/extension_webnavigation_api.cc
@@ -547,7 +547,8 @@ void ExtensionWebNavigationTabObserver::DidFailProvisionalLoad(
int64 frame_id,
bool is_main_frame,
const GURL& validated_url,
- int error_code) {
+ int error_code,
+ const string16& error_description) {
if (!navigation_state_.CanSendEvents(frame_id))
return;
navigation_state_.SetErrorOccurredInFrame(frame_id);
diff --git a/chrome/browser/extensions/extension_webnavigation_api.h b/chrome/browser/extensions/extension_webnavigation_api.h
index 932734f..5d24907 100644
--- a/chrome/browser/extensions/extension_webnavigation_api.h
+++ b/chrome/browser/extensions/extension_webnavigation_api.h
@@ -142,10 +142,12 @@ class ExtensionWebNavigationTabObserver : public TabContentsObserver {
bool is_main_frame,
const GURL& url,
PageTransition::Type transition_type) OVERRIDE;
- virtual void DidFailProvisionalLoad(int64 frame_id,
- bool is_main_frame,
- const GURL& validated_url,
- int error_code) OVERRIDE;
+ virtual void DidFailProvisionalLoad(
+ int64 frame_id,
+ bool is_main_frame,
+ const GURL& validated_url,
+ int error_code,
+ const string16& error_description) OVERRIDE;
virtual void DocumentLoadedInFrame(int64 frame_id) OVERRIDE;
virtual void DidFinishLoad(int64 frame_id) OVERRIDE;
virtual void DidOpenRequestedURL(TabContents* new_contents,
diff --git a/chrome/renderer/chrome_content_renderer_client.cc b/chrome/renderer/chrome_content_renderer_client.cc
index 561574d..0c10574 100644
--- a/chrome/renderer/chrome_content_renderer_client.cc
+++ b/chrome/renderer/chrome_content_renderer_client.cc
@@ -533,47 +533,56 @@ bool ChromeContentRendererClient::HasErrorPage(int http_status_code,
return true;
}
-std::string ChromeContentRendererClient::GetNavigationErrorHtml(
- const WebURLRequest& failed_request,
- const WebURLError& error) {
- GURL failed_url = error.unreachableURL;
- std::string html;
+void ChromeContentRendererClient::GetNavigationErrorStrings(
+ const WebKit::WebURLRequest& failed_request,
+ const WebKit::WebURLError& error,
+ std::string* error_html,
+ string16* error_description) {
+ const GURL failed_url = error.unreachableURL;
const Extension* extension = NULL;
+ const bool is_repost =
+ error.reason == net::ERR_CACHE_MISS &&
+ error.domain == WebString::fromUTF8(net::kErrorDomain) &&
+ EqualsASCII(failed_request.httpMethod(), "POST");
- // Use a local error page.
- int resource_id;
- DictionaryValue error_strings;
if (failed_url.is_valid() && !failed_url.SchemeIs(chrome::kExtensionScheme))
extension = extension_dispatcher_->extensions()->GetByURL(failed_url);
- if (extension) {
- LocalizedError::GetAppErrorStrings(error, failed_url, extension,
- &error_strings);
- // TODO(erikkay): Should we use a different template for different
- // error messages?
- resource_id = IDR_ERROR_APP_HTML;
- } else {
- if (error.domain == WebString::fromUTF8(net::kErrorDomain) &&
- error.reason == net::ERR_CACHE_MISS &&
- EqualsASCII(failed_request.httpMethod(), "POST")) {
- LocalizedError::GetFormRepostStrings(failed_url, &error_strings);
+ if (error_html) {
+ // Use a local error page.
+ int resource_id;
+ DictionaryValue error_strings;
+ if (extension) {
+ LocalizedError::GetAppErrorStrings(error, failed_url, extension,
+ &error_strings);
+
+ // TODO(erikkay): Should we use a different template for different
+ // error messages?
+ resource_id = IDR_ERROR_APP_HTML;
} else {
- LocalizedError::GetStrings(error, &error_strings);
+ if (is_repost) {
+ LocalizedError::GetFormRepostStrings(failed_url, &error_strings);
+ } else {
+ LocalizedError::GetStrings(error, &error_strings);
+ }
+ resource_id = IDR_NET_ERROR_HTML;
}
- resource_id = IDR_NET_ERROR_HTML;
- }
- const base::StringPiece template_html(
- ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id));
- if (template_html.empty()) {
- NOTREACHED() << "unable to load template. ID: " << resource_id;
- } else {
- // "t" is the id of the templates root node.
- html = jstemplate_builder::GetTemplatesHtml(
- template_html, &error_strings, "t");
+ const base::StringPiece template_html(
+ ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id));
+ if (template_html.empty()) {
+ NOTREACHED() << "unable to load template. ID: " << resource_id;
+ } else {
+ // "t" is the id of the templates root node.
+ *error_html = jstemplate_builder::GetTemplatesHtml(
+ template_html, &error_strings, "t");
+ }
}
- return html;
+ if (error_description) {
+ if (!extension && !is_repost)
+ *error_description = LocalizedError::GetErrorDetails(error);
+ }
}
bool ChromeContentRendererClient::RunIdleHandlerWhenWidgetsHidden() {
diff --git a/chrome/renderer/chrome_content_renderer_client.h b/chrome/renderer/chrome_content_renderer_client.h
index 9bb6cad..a5b4d29 100644
--- a/chrome/renderer/chrome_content_renderer_client.h
+++ b/chrome/renderer/chrome_content_renderer_client.h
@@ -10,6 +10,7 @@
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
+#include "base/string16.h"
#include "content/public/renderer/content_renderer_client.h"
class ChromeRenderProcessObserver;
@@ -50,9 +51,11 @@ class ChromeContentRendererClient : public content::ContentRendererClient {
WebKit::WebPlugin** plugin) OVERRIDE;
virtual bool HasErrorPage(int http_status_code,
std::string* error_domain) OVERRIDE;
- virtual std::string GetNavigationErrorHtml(
+ virtual void GetNavigationErrorStrings(
const WebKit::WebURLRequest& failed_request,
- const WebKit::WebURLError& error) OVERRIDE;
+ const WebKit::WebURLError& error,
+ std::string* error_html,
+ string16* error_description) OVERRIDE;
virtual bool RunIdleHandlerWhenWidgetsHidden() OVERRIDE;
virtual bool AllowPopup(const GURL& creator) OVERRIDE;
virtual bool ShouldFork(WebKit::WebFrame* frame,
diff --git a/chrome/renderer/localized_error.cc b/chrome/renderer/localized_error.cc
index 681d783..ad14e96 100644
--- a/chrome/renderer/localized_error.cc
+++ b/chrome/renderer/localized_error.cc
@@ -630,6 +630,15 @@ void LocalizedError::GetStrings(const WebKit::WebURLError& error,
}
}
+string16 LocalizedError::GetErrorDetails(const WebKit::WebURLError& error) {
+ const LocalizedErrorMap* error_map =
+ LookupErrorMap(error.domain.utf8(), error.reason);
+ if (error_map)
+ return l10n_util::GetStringUTF16(error_map->details_resource_id);
+ else
+ return l10n_util::GetStringUTF16(IDS_ERRORPAGES_DETAILS_UNKNOWN);
+}
+
bool LocalizedError::HasStrings(const std::string& error_domain,
int error_code) {
return LookupErrorMap(error_domain, error_code) != NULL;
diff --git a/chrome/renderer/localized_error.h b/chrome/renderer/localized_error.h
index f327161..1006ae6 100644
--- a/chrome/renderer/localized_error.h
+++ b/chrome/renderer/localized_error.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -9,6 +9,7 @@
#include <string>
#include "base/basictypes.h"
+#include "base/string16.h"
class Extension;
class GURL;
@@ -28,6 +29,9 @@ class LocalizedError {
static void GetStrings(const WebKit::WebURLError& error,
base::DictionaryValue* strings);
+ // Returns a description of the encountered error.
+ static string16 GetErrorDetails(const WebKit::WebURLError& error);
+
// Returns true if an error page exists for the specified parameters.
static bool HasStrings(const std::string& error_domain, int error_code);