diff options
author | benwells <benwells@chromium.org> | 2015-06-15 18:55:43 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-06-16 01:56:11 +0000 |
commit | 3410e98a2d250fa6e1b4d8c44bd2b15d077a3bc3 (patch) | |
tree | 08f9a37a9c08ad86577c3864aab0069b1c9a898b | |
parent | 7e1728d593dcc4c8d32da0e27910d906b7a2067b (diff) | |
download | chromium_src-3410e98a2d250fa6e1b4d8c44bd2b15d077a3bc3.zip chromium_src-3410e98a2d250fa6e1b4d8c44bd2b15d077a3bc3.tar.gz chromium_src-3410e98a2d250fa6e1b4d8c44bd2b15d077a3bc3.tar.bz2 |
Use normal offline error page for hosted apps.
Using a customized error page is confusing and doesn't have as much
information as the normal offline page.
BUG=439084
Review URL: https://codereview.chromium.org/1178193006
Cr-Commit-Position: refs/heads/master@{#334529}
-rw-r--r-- | chrome/app/generated_resources.grd | 4 | ||||
-rw-r--r-- | chrome/browser/browser_resources.grd | 1 | ||||
-rw-r--r-- | chrome/browser/chromeos/offline/offline_load_page.cc | 26 | ||||
-rw-r--r-- | chrome/browser/resources/chromeos/offline_app_load.html | 52 | ||||
-rw-r--r-- | chrome/common/localized_error.cc | 53 | ||||
-rw-r--r-- | chrome/common/localized_error.h | 15 | ||||
-rw-r--r-- | chrome/renderer/chrome_content_renderer_client.cc | 59 | ||||
-rw-r--r-- | chrome/renderer/resources/error_app.html | 52 | ||||
-rw-r--r-- | chrome/renderer/resources/renderer_resources.grd | 1 |
9 files changed, 17 insertions, 246 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index 2532663..d685928 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -9628,10 +9628,6 @@ I don't think this site should be blocked! This webpage requires data that you entered earlier in order to be properly displayed. You can send this data again, but by doing so you will repeat any action this page previously performed. </message> - <message name="IDS_ERRORPAGES_APP_WARNING" desc="The error message displayed when the browser can not reach the requested page from an app."> - The app is currently unreachable. - </message> - <message name="IDS_SECURE_CONNECTION_EV" desc="Short text shown in the location bar when the connection is secure with an EV cert."> <ph name="ORGANIZATION">$1<ex>Paypal Inc.</ex></ph> [<ph name="COUNTRY">$2<ex>US</ex></ph>] </message> diff --git a/chrome/browser/browser_resources.grd b/chrome/browser/browser_resources.grd index d79c712..0ecee8a 100644 --- a/chrome/browser/browser_resources.grd +++ b/chrome/browser/browser_resources.grd @@ -316,7 +316,6 @@ <include name="IDR_NFC_DEBUG_CSS" file="resources\chromeos\nfc_debug.css" type="BINDATA" /> <include name="IDR_NFC_DEBUG_JS" file="resources\chromeos\nfc_debug.js" type="BINDATA" /> <include name="IDR_ECHO_MANIFEST" file="resources\chromeos\echo\manifest.json" type="BINDATA" /> - <include name="IDR_OFFLINE_APP_LOAD_HTML" file="resources\chromeos\offline_app_load.html" flattenhtml="true" type="BINDATA" /> <include name="IDR_OFFLINE_NET_LOAD_HTML" file="resources\chromeos\offline_net_load.html" flattenhtml="true" type="BINDATA" /> <include name="IDR_MERGE_SESSION_LOAD_HTML" file="resources\chromeos\merge_session_load.html" flattenhtml="true" type="BINDATA" /> <include name="IDR_OS_CREDITS_HTML" file="resources\chromeos\about_os_credits.html" flattenhtml="true" type="BINDATA" /> diff --git a/chrome/browser/chromeos/offline/offline_load_page.cc b/chrome/browser/chromeos/offline/offline_load_page.cc index 2e80a22..a469925 100644 --- a/chrome/browser/chromeos/offline/offline_load_page.cc +++ b/chrome/browser/chromeos/offline/offline_load_page.cc @@ -32,10 +32,7 @@ #include "content/public/browser/web_contents.h" #include "content/public/common/renderer_preferences.h" #include "extensions/browser/extension_registry.h" -#include "extensions/browser/extension_system.h" #include "extensions/common/extension.h" -#include "extensions/common/extension_icon_set.h" -#include "extensions/common/manifest_handlers/icons_handler.h" #include "net/base/escape.h" #include "net/base/net_errors.h" #include "ui/base/resource/resource_bundle.h" @@ -73,26 +70,17 @@ std::string OfflineLoadPage::GetHTMLContents() { int resource_id; base::DictionaryValue error_strings; - // The offline page for app has icons and slightly different message. Profile* profile = Profile::FromBrowserContext( web_contents_->GetBrowserContext()); DCHECK(profile); - const extensions::Extension* extension = extensions::ExtensionRegistry::Get( - profile)->enabled_extensions().GetHostedAppByURL(url_); const std::string& locale = g_browser_process->GetApplicationLocale(); - if (extension && !extension->from_bookmark()) { - LocalizedError::GetAppErrorStrings(url_, extension, locale, &error_strings); - resource_id = IDR_OFFLINE_APP_LOAD_HTML; - } else { - const std::string accept_languages = - profile->GetPrefs()->GetString(prefs::kAcceptLanguages); - LocalizedError::GetStrings(net::ERR_INTERNET_DISCONNECTED, - net::kErrorDomain, url_, false, false, locale, - accept_languages, - scoped_ptr<error_page::ErrorPageParams>(), - &error_strings); - resource_id = IDR_OFFLINE_NET_LOAD_HTML; - } + const std::string accept_languages = + profile->GetPrefs()->GetString(prefs::kAcceptLanguages); + LocalizedError::GetStrings(net::ERR_INTERNET_DISCONNECTED, net::kErrorDomain, + url_, false, false, locale, accept_languages, + scoped_ptr<error_page::ErrorPageParams>(), + &error_strings); + resource_id = IDR_OFFLINE_NET_LOAD_HTML; std::string template_html = ResourceBundle::GetSharedInstance() .GetRawDataResource(resource_id) diff --git a/chrome/browser/resources/chromeos/offline_app_load.html b/chrome/browser/resources/chromeos/offline_app_load.html deleted file mode 100644 index 4d84c31..0000000 --- a/chrome/browser/resources/chromeos/offline_app_load.html +++ /dev/null @@ -1,52 +0,0 @@ -<!doctype html> -<html i18n-values="dir:textdirection;lang:language"> -<head> -<meta charset="utf-8"> -<title i18n-content="title"> -</title> -<link rel="stylesheet" href="chrome://resources/css/text_defaults.css"> -<style> -html { - height: 100%; -} -body { - color: #000; - background-image: -webkit-linear-gradient(rgb(255, 255, 255) 50%, - rgb(236, 244, 255)); - height: 100%; - padding: 0px; - margin: 0px; -} -#error { - position: absolute; - left: 180px; - top: 150px; - font-size: 24px; -} -#error img { - margin-right: 10px; - vertical-align: middle; -} -#name { - font-weight: bold; -} -#msg { -} -</style> -</head> - -<body id="t"> - -<div id="error" jsvalues=".title:url"> -<img jsvalues=".src:icon" width="96" height="96"> -<div style="display:inline-block; vertical-align: middle;"> -<div id="name" jsvalues=".innerText:name"></div> -<div id="msg" jsvalues=".innerText:msg"></div> -<div id="suggestions" jsselect="suggestionsLearnMore"> - <span jsvalues=".innerHTML:msg"></span> -</div> -</div> -</div> - -</body> -</html> diff --git a/chrome/common/localized_error.cc b/chrome/common/localized_error.cc index cb3aaee..568b780 100644 --- a/chrome/common/localized_error.cc +++ b/chrome/common/localized_error.cc @@ -34,12 +34,6 @@ #include "chrome/common/chrome_switches.h" #endif -#if defined(ENABLE_EXTENSIONS) -#include "extensions/common/constants.h" -#include "extensions/common/extension_icon_set.h" -#include "extensions/common/manifest_handlers/icons_handler.h" -#endif - using blink::WebURLError; // Some error pages have no details. @@ -52,11 +46,6 @@ static const char kRedirectLoopLearnMoreUrl[] = static const char kWeakDHKeyLearnMoreUrl[] = "https://www.chromium.org/administrators/" "err_ssl_weak_server_ephemeral_dh_key"; -#if defined(OS_CHROMEOS) -static const char kAppWarningLearnMoreUrl[] = - "chrome-extension://honijodknafkokifofgiaalefdiedpko/main.html" - "?answer=1721911"; -#endif // defined(OS_CHROMEOS) static const char kCachedCopyButtonFieldTrial[] = "EnableGoogleCachedCopyTextExperiment"; static const char kCachedCopyButtonExpTypeControl[] = "control"; @@ -886,48 +875,6 @@ bool LocalizedError::HasStrings(const std::string& error_domain, return LookupErrorMap(error_domain, error_code, /*is_post=*/false) != NULL; } -#if defined(ENABLE_EXTENSIONS) -void LocalizedError::GetAppErrorStrings( - const GURL& display_url, - const extensions::Extension* app, - const std::string& locale, - base::DictionaryValue* error_strings) { - DCHECK(app); - - webui::SetLoadTimeDataDefaults(locale, error_strings); - - base::string16 failed_url(base::ASCIIToUTF16(display_url.spec())); - // URLs are always LTR. - if (base::i18n::IsRTL()) - base::i18n::WrapStringWithLTRFormatting(&failed_url); - error_strings->SetString( - "url", l10n_util::GetStringFUTF16(IDS_ERRORPAGES_TITLE_NOT_AVAILABLE, - failed_url.c_str())); - - error_strings->SetString("title", app->name()); - error_strings->SetString( - "icon", - extensions::IconsInfo::GetIconURL( - app, - extension_misc::EXTENSION_ICON_GIGANTOR, - ExtensionIconSet::MATCH_SMALLER).spec()); - error_strings->SetString("name", app->name()); - error_strings->SetString( - "msg", - l10n_util::GetStringUTF16(IDS_ERRORPAGES_APP_WARNING)); - -#if defined(OS_CHROMEOS) - GURL learn_more_url(kAppWarningLearnMoreUrl); - base::DictionaryValue* suggest_learn_more = new base::DictionaryValue(); - suggest_learn_more->SetString("msg", - l10n_util::GetStringUTF16( - IDS_ERRORPAGES_SUGGESTION_LEARNMORE_BODY)); - suggest_learn_more->SetString("learnMoreUrl", learn_more_url.spec()); - error_strings->Set("suggestionsLearnMore", suggest_learn_more); -#endif // defined(OS_CHROMEOS) -} -#endif - void LocalizedError::EnableGoogleCachedCopyButtonExperiment( base::ListValue* suggestions, base::DictionaryValue* error_strings) { diff --git a/chrome/common/localized_error.h b/chrome/common/localized_error.h index a71740b..ae6ab2a 100644 --- a/chrome/common/localized_error.h +++ b/chrome/common/localized_error.h @@ -17,10 +17,6 @@ class DictionaryValue; class ListValue; } -namespace extensions { -class Extension; -} - namespace blink { struct WebURLError; } @@ -50,17 +46,6 @@ class LocalizedError { // Returns true if an error page exists for the specified parameters. static bool HasStrings(const std::string& error_domain, int error_code); -#if defined(ENABLE_EXTENSIONS) - // Fills |error_strings| with values to be used to build an error page used - // on HTTP errors, like 404 or connection reset, but using information from - // the associated |app| in order to make the error page look like it's more - // part of the app. - static void GetAppErrorStrings(const GURL& display_url, - const extensions::Extension* app, - const std::string& locale, - base::DictionaryValue* error_strings); -#endif - static const char kHttpErrorDomain[]; private: diff --git a/chrome/renderer/chrome_content_renderer_client.cc b/chrome/renderer/chrome_content_renderer_client.cc index c8b70f6..10edd34 100644 --- a/chrome/renderer/chrome_content_renderer_client.cc +++ b/chrome/renderer/chrome_content_renderer_client.cc @@ -1145,61 +1145,22 @@ void ChromeContentRendererClient::GetNavigationErrorStrings( std::string* error_html, base::string16* error_description) { const GURL failed_url = error.unreachableURL; - const Extension* extension = NULL; - -#if defined(ENABLE_EXTENSIONS) - if (failed_url.is_valid() && - !failed_url.SchemeIs(extensions::kExtensionScheme)) { - extension = extension_dispatcher_->extensions()->GetExtensionOrAppByURL( - failed_url); - } -#endif bool is_post = base::EqualsASCII(failed_request.httpMethod(), "POST"); if (error_html) { - bool extension_but_not_bookmark_app = false; -#if defined(ENABLE_EXTENSIONS) - extension_but_not_bookmark_app = extension && !extension->from_bookmark(); -#endif - // Use a local error page. - if (extension_but_not_bookmark_app) { -#if defined(ENABLE_EXTENSIONS) - // TODO(erikkay): Should we use a different template for different - // error messages? - int resource_id = IDR_ERROR_APP_HTML; - const base::StringPiece template_html( - ResourceBundle::GetSharedInstance().GetRawDataResource( - resource_id)); - if (template_html.empty()) { - NOTREACHED() << "unable to load template. ID: " << resource_id; - } else { - base::DictionaryValue error_strings; - const std::string locale = RenderThread::Get()->GetLocale(); - LocalizedError::GetAppErrorStrings(failed_url, extension, locale, - &error_strings); - // "t" is the id of the template's root node. - *error_html = webui::GetTemplatesHtml(template_html, &error_strings, - "t"); - } -#endif - } else { - // TODO(ellyjones): change GetNavigationErrorStrings to take a RenderFrame - // instead of a RenderView, then pass that in. - // This is safe for now because we only install the NetErrorHelper on the - // main render frame anyway; see the TODO(ellyjones) in - // RenderFrameCreated. - content::RenderFrame* main_render_frame = - render_view->GetMainRenderFrame(); - NetErrorHelper* helper = NetErrorHelper::Get(main_render_frame); - helper->GetErrorHTML(frame, error, is_post, error_html); - } + // TODO(ellyjones): change GetNavigationErrorStrings to take a RenderFrame + // instead of a RenderView, then pass that in. + // This is safe for now because we only install the NetErrorHelper on the + // main render frame anyway; see the TODO(ellyjones) in + // RenderFrameCreated. + content::RenderFrame* main_render_frame = render_view->GetMainRenderFrame(); + NetErrorHelper* helper = NetErrorHelper::Get(main_render_frame); + helper->GetErrorHTML(frame, error, is_post, error_html); } - if (error_description) { - if (!extension) - *error_description = LocalizedError::GetErrorDetails(error, is_post); - } + if (error_description) + *error_description = LocalizedError::GetErrorDetails(error, is_post); } bool ChromeContentRendererClient::RunIdleHandlerWhenWidgetsHidden() { diff --git a/chrome/renderer/resources/error_app.html b/chrome/renderer/resources/error_app.html deleted file mode 100644 index e05439e..0000000 --- a/chrome/renderer/resources/error_app.html +++ /dev/null @@ -1,52 +0,0 @@ -<!doctype html> -<html i18n-values="dir:textdirection;lang:language"> -<head> -<meta charset="utf-8"> -<title i18n-content="title"> -</title> -<style> -html { - height: 100%; -} -body { - color: #000; - font-family: Helvetica, Arial, sans-serif; - background-image: -webkit-linear-gradient(rgb(255, 255, 255) 50%, - rgb(236, 244, 255)); - height: 100%; - padding: 0px; - margin: 0px; -} -#error { - position: absolute; - left: 180px; - top: 150px; - font-size: 24px; -} -#error img { - margin-right: 10px; - vertical-align: middle; -} -#name { - font-weight: bold; -} -#msg { -} -</style> -</head> - -<body id="t"> - -<div id="error" jsvalues=".title:url"> -<img jsvalues=".src:icon" width="96" height="96"> -<div style="display:inline-block; vertical-align: middle;"> -<div id="name" jsvalues=".innerText:name"></div> -<div id="msg" jsvalues=".innerText:msg"></div> -<div id="suggestions" jsselect="suggestionsLearnMore"> - <span jsvalues=".innerHTML:msg"></span> -</div> -</div> -</div> - -</body> -</html> diff --git a/chrome/renderer/resources/renderer_resources.grd b/chrome/renderer/resources/renderer_resources.grd index 4a54580..6c72e4bf 100644 --- a/chrome/renderer/resources/renderer_resources.grd +++ b/chrome/renderer/resources/renderer_resources.grd @@ -19,7 +19,6 @@ </if> <include name="IDR_BLOCKED_PLUGIN_HTML" file="blocked_plugin.html" flattenhtml="true" type="BINDATA" /> <include name="IDR_DISABLED_PLUGIN_HTML" file="disabled_plugin.html" flattenhtml="true" type="BINDATA" /> - <include name="IDR_ERROR_APP_HTML" file="error_app.html" flattenhtml="true" type="BINDATA" /> <include name="IDR_NET_ERROR_HTML" file="neterror.html" flattenhtml="true" type="BINDATA" /> <include name="IDR_PLUGIN_POSTER_HTML" file="plugin_poster.html" flattenhtml="true" type="BINDATA" /> |