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

Unified Diff: content/browser/net/network_error_request_job.cc

Issue 1421743002: Implement chrome://network-errors for direct access to network error interstitials (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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: content/browser/net/network_error_request_job.cc
diff --git a/content/browser/net/network_error_request_job.cc b/content/browser/net/network_error_request_job.cc
new file mode 100644
index 0000000000000000000000000000000000000000..a69402514f730ed3d5d55f5525437688147bc763
--- /dev/null
+++ b/content/browser/net/network_error_request_job.cc
@@ -0,0 +1,43 @@
+// Copyright 2015 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 "content/browser/net/network_error_request_job.h"
+
+#include "base/strings/string_number_conversions.h"
+#include "base/values.h"
+#include "net/base/escape.h"
+#include "net/base/net_errors.h"
+#include "net/log/net_log_util.h"
+#include "net/url_request/url_request.h"
+#include "url/gurl.h"
+
+namespace content {
+
+NetworkErrorRequestJob::NetworkErrorRequestJob(
+ net::URLRequest* request,
+ net::NetworkDelegate* network_delegate)
+ : net::URLRequestSimpleJob(request, network_delegate),
+ error_code_(net::Error::OK) {
+ std::basic_string<char> error_code_string =
+ request->url().path().substr(1, std::string::npos);
+
+ if (!base::StringToInt(error_code_string, &error_code_))
+ error_code_ = 0;
+}
+
+int NetworkErrorRequestJob::GetData(
+ std::string* mime_type,
+ std::string* charset,
+ std::string* data,
+ const net::CompletionCallback& callback) const {
+ mime_type->assign("text/html");
+ charset->assign("UTF8");
+
+ if (error_code_ == 0 || error_code_ == net::Error::ERR_IO_PENDING) {
+ return net::OK;
+ }
Dan Beam 2015/11/24 20:08:20 nit: no curlies
edwardjung 2015/11/24 21:42:12 Done.
+ return error_code_;
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698