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

Unified Diff: ios/web/public/test/response_providers/error_page_response_provider.mm

Issue 2259393002: Upstream ErrorPageResponseProvider to be used in integration tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments addressed Created 4 years, 4 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 | « ios/web/public/test/response_providers/error_page_response_provider.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/web/public/test/response_providers/error_page_response_provider.mm
diff --git a/ios/web/public/test/response_providers/error_page_response_provider.mm b/ios/web/public/test/response_providers/error_page_response_provider.mm
new file mode 100644
index 0000000000000000000000000000000000000000..9980891b723fe4a6967245a6c0c5cbb49f836d5a
--- /dev/null
+++ b/ios/web/public/test/response_providers/error_page_response_provider.mm
@@ -0,0 +1,41 @@
+// Copyright 2016 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.
+
+#include "ios/web/public/test/response_providers/error_page_response_provider.h"
+
+#include "base/logging.h"
+#import "ios/web/public/test/http_server.h"
+#include "net/http/http_status_code.h"
+
+// static
+GURL ErrorPageResponseProvider::GetDnsFailureUrl() {
+ return GURL("http://mock/bad");
+}
+
+// static
+GURL ErrorPageResponseProvider::GetRedirectToDnsFailureUrl() {
+ return web::test::HttpServer::MakeUrl("http://mock/redirect");
+}
+
+// Returns true for |RedirectToDnsFailureUrl|.
+bool ErrorPageResponseProvider::CanHandleRequest(const Request& request) {
+ return (HtmlResponseProvider::CanHandleRequest(request) ||
+ request.url ==
+ ErrorPageResponseProvider::GetRedirectToDnsFailureUrl());
+}
+
+void ErrorPageResponseProvider::GetResponseHeadersAndBody(
+ const Request& request,
+ scoped_refptr<net::HttpResponseHeaders>* headers,
+ std::string* response_body) {
+ if (HtmlResponseProvider::CanHandleRequest(request)) {
+ HtmlResponseProvider::GetResponseHeadersAndBody(request, headers,
+ response_body);
+ } else if (request.url == GetRedirectToDnsFailureUrl()) {
+ *headers = web::ResponseProvider::GetRedirectResponseHeaders(
+ ErrorPageResponseProvider::GetDnsFailureUrl().spec(), net::HTTP_FOUND);
+ } else {
+ NOTREACHED();
+ }
+}
« no previous file with comments | « ios/web/public/test/response_providers/error_page_response_provider.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698