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

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

Issue 185003002: Revert 254207 "Switch to using the new Link Doctor API." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 10 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: trunk/src/chrome/renderer/net/net_error_helper.cc
===================================================================
--- trunk/src/chrome/renderer/net/net_error_helper.cc (revision 254240)
+++ trunk/src/chrome/renderer/net/net_error_helper.cc (working copy)
@@ -6,11 +6,11 @@
#include <string>
-#include "base/i18n/rtl.h"
#include "base/json/json_writer.h"
#include "base/metrics/histogram.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
+#include "chrome/common/localized_error.h"
#include "chrome/common/net/net_error_info.h"
#include "chrome/common/render_messages.h"
#include "content/public/common/content_client.h"
@@ -45,9 +45,9 @@
namespace {
-// Number of seconds to wait for the navigation correction service to return
-// suggestions. If it takes too long, just use the local error page.
-static const int kNavigationCorrectionFetchTimeoutSec = 3;
+// Number of seconds to wait for the alternate error page server. If it takes
+// too long, just use the local error page.
+static const int kAlterErrorPageFetchTimeoutSec = 3000;
NetErrorHelperCore::PageType GetLoadingPageType(const blink::WebFrame* frame) {
GURL url = frame->provisionalDataSource()->request().url();
@@ -62,18 +62,6 @@
return NetErrorHelperCore::SUB_FRAME;
}
-// Copied from localized_error.cc.
-// TODO(mmenke): Share code?
-bool LocaleIsRTL() {
-#if defined(TOOLKIT_GTK)
- // base::i18n::IsRTL() uses the GTK text direction, which doesn't work within
- // the renderer sandbox.
- return base::i18n::ICUIsRTL();
-#else
- return base::i18n::IsRTL();
-#endif
-}
-
} // namespace
NetErrorHelper::NetErrorHelper(RenderFrame* render_view)
@@ -109,8 +97,7 @@
IPC_BEGIN_MESSAGE_MAP(NetErrorHelper, message)
IPC_MESSAGE_HANDLER(ChromeViewMsg_NetErrorInfo, OnNetErrorInfo)
- IPC_MESSAGE_HANDLER(ChromeViewMsg_SetNavigationCorrectionInfo,
- OnSetNavigationCorrectionInfo);
+ IPC_MESSAGE_HANDLER(ChromeViewMsg_SetAltErrorPageURL, OnSetAltErrorPageURL);
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
@@ -125,11 +112,9 @@
core_.GetErrorHTML(GetFrameType(frame), error, is_failed_post, error_html);
}
-void NetErrorHelper::GenerateLocalizedErrorPage(
- const blink::WebURLError& error,
- bool is_failed_post,
- scoped_ptr<LocalizedError::ErrorPageParams> params,
- std::string* error_html) const {
+void NetErrorHelper::GenerateLocalizedErrorPage(const blink::WebURLError& error,
+ bool is_failed_post,
+ std::string* error_html) const {
error_html->clear();
int resource_id = IDR_NET_ERROR_HTML;
@@ -145,7 +130,7 @@
RenderThread::Get()->GetLocale(),
render_frame()->GetRenderView()->
GetAcceptLanguages(),
- params.Pass(), &error_strings);
+ &error_strings);
// "t" is the id of the template's root node.
*error_html = webui::GetTemplatesHtml(template_html, &error_strings, "t");
}
@@ -171,7 +156,6 @@
RenderThread::Get()->GetLocale(),
render_frame()->GetRenderView()->
GetAcceptLanguages(),
- scoped_ptr<LocalizedError::ErrorPageParams>(),
&error_strings);
std::string json;
@@ -189,32 +173,27 @@
render_frame()->GetRenderView()->EvaluateScript(frame_xpath, js16, 0, false);
}
-void NetErrorHelper::FetchNavigationCorrections(
- const GURL& navigation_correction_url,
- const std::string& navigation_correction_request_body) {
- DCHECK(!correction_fetcher_.get());
+void NetErrorHelper::FetchErrorPage(const GURL& url) {
+ DCHECK(!alt_error_page_fetcher_.get());
blink::WebView* web_view = render_frame()->GetRenderView()->GetWebView();
if (!web_view)
return;
blink::WebFrame* frame = web_view->mainFrame();
- correction_fetcher_.reset(
- content::ResourceFetcher::Create(navigation_correction_url));
- correction_fetcher_->SetMethod("POST");
- correction_fetcher_->SetBody(navigation_correction_request_body);
- correction_fetcher_->SetHeader("Content-Type", "application/json");
- correction_fetcher_->Start(
+ alt_error_page_fetcher_.reset(content::ResourceFetcher::Create(url));
+
+ alt_error_page_fetcher_->Start(
frame, blink::WebURLRequest::TargetIsMainFrame,
- base::Bind(&NetErrorHelper::OnNavigationCorrectionsFetched,
+ base::Bind(&NetErrorHelper::OnAlternateErrorPageRetrieved,
base::Unretained(this)));
- correction_fetcher_->SetTimeout(
- base::TimeDelta::FromSeconds(kNavigationCorrectionFetchTimeoutSec));
+ alt_error_page_fetcher_->SetTimeout(
+ base::TimeDelta::FromSeconds(kAlterErrorPageFetchTimeoutSec));
}
-void NetErrorHelper::CancelFetchNavigationCorrections() {
- correction_fetcher_.reset();
+void NetErrorHelper::CancelFetchErrorPage() {
+ alt_error_page_fetcher_.reset();
}
void NetErrorHelper::OnNetErrorInfo(int status_num) {
@@ -225,30 +204,20 @@
core_.OnNetErrorInfo(static_cast<DnsProbeStatus>(status_num));
}
-void NetErrorHelper::OnSetNavigationCorrectionInfo(
- const GURL& navigation_correction_url,
- const std::string& language,
- const std::string& country_code,
- const std::string& api_key,
- const GURL& search_url) {
- core_.OnSetNavigationCorrectionInfo(navigation_correction_url, language,
- country_code, api_key, search_url);
+void NetErrorHelper::OnSetAltErrorPageURL(const GURL& alt_error_page_url) {
+ core_.set_alt_error_page_url(alt_error_page_url);
}
-void NetErrorHelper::OnNavigationCorrectionsFetched(
+void NetErrorHelper::OnAlternateErrorPageRetrieved(
const blink::WebURLResponse& response,
const std::string& data) {
// The fetcher may only be deleted after |data| is passed to |core_|. Move
// it to a temporary to prevent any potential re-entrancy issues.
scoped_ptr<content::ResourceFetcher> fetcher(
- correction_fetcher_.release());
+ alt_error_page_fetcher_.release());
if (!response.isNull() && response.httpStatusCode() == 200) {
- core_.OnNavigationCorrectionsFetched(
- data, render_frame()->GetRenderView()->GetAcceptLanguages(),
- LocaleIsRTL());
+ core_.OnAlternateErrorPageFetched(data);
} else {
- core_.OnNavigationCorrectionsFetched(
- "", render_frame()->GetRenderView()->GetAcceptLanguages(),
- LocaleIsRTL());
+ core_.OnAlternateErrorPageFetched("");
}
}
« no previous file with comments | « trunk/src/chrome/renderer/net/net_error_helper.h ('k') | trunk/src/chrome/renderer/net/net_error_helper_core.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698