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

Unified Diff: trunk/src/chrome/common/localized_error.cc

Issue 235883010: Revert 262846, as the revert has now been merged to M35. (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: 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
« no previous file with comments | « trunk/src/chrome/common/localized_error.h ('k') | trunk/src/chrome/common/render_messages.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: trunk/src/chrome/common/localized_error.cc
===================================================================
--- trunk/src/chrome/common/localized_error.cc (revision 263955)
+++ trunk/src/chrome/common/localized_error.cc (working copy)
@@ -23,7 +23,6 @@
#include "third_party/WebKit/public/platform/WebURLError.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/webui/web_ui_util.h"
-#include "url/gurl.h"
#if defined(OS_WIN)
#include "base/win/windows_version.h"
@@ -484,6 +483,12 @@
const char LocalizedError::kHttpErrorDomain[] = "http";
+LocalizedError::ErrorPageParams::ErrorPageParams() : suggest_reload(false) {
+}
+
+LocalizedError::ErrorPageParams::~ErrorPageParams() {
+}
+
void LocalizedError::GetStrings(int error_code,
const std::string& error_domain,
const GURL& failed_url,
@@ -491,6 +496,7 @@
bool stale_copy_in_cache,
const std::string& locale,
const std::string& accept_languages,
+ scoped_ptr<ErrorPageParams> params,
base::DictionaryValue* error_strings) {
bool rtl = LocaleIsRTL();
error_strings->SetString("textdirection", rtl ? "rtl" : "ltr");
@@ -553,15 +559,7 @@
error_strings->SetString(
"less", l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_LESS));
error_strings->Set("summary", summary);
- error_strings->SetBoolean("staleCopyInCache", stale_copy_in_cache);
-#if defined(OS_CHROMEOS)
- error_strings->SetString(
- "diagnose", l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_DIAGNOSE));
-#endif // defined(OS_CHROMEOS)
-
- error_strings->SetBoolean("staleCopyInCache", stale_copy_in_cache);
-
if (options.details_resource_id != kErrorPagesNoDetails) {
error_strings->SetString(
"errorDetails", l10n_util::GetStringUTF16(options.details_resource_id));
@@ -585,9 +583,7 @@
error_strings->SetString("errorCode",
l10n_util::GetStringFUTF16(IDS_ERRORPAGES_ERROR_CODE, error_string));
- base::ListValue* suggestions = new base::ListValue();
-
- // Platform specific instructions for diagnosing network issues on OSX and
+ // Platform specific information for diagnosing network issues on OSX and
// Windows.
#if defined(OS_MACOSX) || defined(OS_WIN)
if (error_domain == net::kErrorDomain &&
@@ -617,7 +613,32 @@
}
#endif // defined(OS_MACOSX) || defined(OS_WIN)
- if (options.suggestions & SUGGEST_RELOAD) {
+ // If no parameters were provided, use the defaults.
+ if (!params) {
+ params.reset(new ErrorPageParams());
+ params->suggest_reload = !!(options.suggestions & SUGGEST_RELOAD);
+ }
+
+ base::ListValue* suggestions = NULL;
+ bool use_default_suggestions = true;
+ if (!params->override_suggestions) {
+ suggestions = new base::ListValue();
+ } else {
+ suggestions = params->override_suggestions.release();
+ use_default_suggestions = false;
+ }
+
+ error_strings->Set("suggestions", suggestions);
+
+ if (params->search_url.is_valid()) {
+ error_strings->SetString("searchHeader",
+ l10n_util::GetStringUTF16(IDS_ERRORPAGES_SUGGESTION_GOOGLE_SEARCH));
+ error_strings->SetString("searchUrl", params->search_url.spec());
+ error_strings->SetString("searchTerms", params->search_terms);
+ }
+
+ // Add the reload suggestion, if needed.
+ if (params->suggest_reload) {
if (!is_post) {
base::DictionaryValue* reload_button = new base::DictionaryValue;
reload_button->SetString("msg",
@@ -636,10 +657,23 @@
suggest_reload_repost->SetString("body",
l10n_util::GetStringUTF16(
IDS_ERRORPAGES_SUGGESTION_RELOAD_REPOST_BODY));
- suggestions->Append(suggest_reload_repost);
+ // Add at the front, so it appears before other suggestions, in the case
+ // suggestions are being overridden by |params|.
+ suggestions->Insert(0, suggest_reload_repost);
}
}
+ // If not using the default suggestions, nothing else to do.
+ if (!use_default_suggestions)
+ return;
+
+ error_strings->SetBoolean("staleCopyInCache", stale_copy_in_cache);
+
+#if defined(OS_CHROMEOS)
+ error_strings->SetString(
+ "diagnose", l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_DIAGNOSE));
+#endif // defined(OS_CHROMEOS)
+
if (options.suggestions & SUGGEST_CHECK_CONNECTION) {
base::DictionaryValue* suggest_check_connection = new base::DictionaryValue;
suggest_check_connection->SetString("header",
@@ -763,8 +797,6 @@
suggestions->Append(suggest_learn_more);
}
}
-
- error_strings->Set("suggestions", suggestions);
}
base::string16 LocalizedError::GetErrorDetails(const blink::WebURLError& error,
« no previous file with comments | « trunk/src/chrome/common/localized_error.h ('k') | trunk/src/chrome/common/render_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698