Index: android_webview/browser/net/fallback_protocol_handler.cc |
diff --git a/android_webview/browser/net/fallback_protocol_handler.cc b/android_webview/browser/net/fallback_protocol_handler.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..2dab03e6cfd7b3a5b56b9e30b7aa1e8b5223213f |
--- /dev/null |
+++ b/android_webview/browser/net/fallback_protocol_handler.cc |
@@ -0,0 +1,42 @@ |
+// Copyright 2013 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 "android_webview/browser/net/fallback_protocol_handler.h" |
+ |
+using net::URLRequestJobFactory; |
+ |
+namespace android_webview { |
+ |
+namespace { |
+ |
+typedef std::vector<net::URLRequestJobFactory::ProtocolHandler*> |
+ ProtocolHandlerVector; |
+ |
+} // namespace |
+ |
+FallbackProtocolHandler::FallbackProtocolHandler( |
+ ProtocolHandlerVector* handlers, |
+ scoped_ptr<URLRequestJobFactory::ProtocolHandler> fallback_handler) |
+ : fallback_handler_(fallback_handler.Pass()) { |
+ handlers_.swap(*handlers); |
+} |
+ |
+FallbackProtocolHandler::~FallbackProtocolHandler() {} |
+ |
+net::URLRequestJob* FallbackProtocolHandler::MaybeCreateJob( |
+ net::URLRequest* request, |
+ net::NetworkDelegate* network_delegate) const { |
+ |
+ for (ProtocolHandlerVector::iterator i = handlers_.begin(); |
+ i != handlers_end(); |
+ ++i) { |
+ net::URLRequestJob* job = i->MaybeCreateJob(request, network_delegate); |
+ if (job) |
+ return job; |
+ } |
+ |
+ return fallback_handler_->MaybeCreateJob(request, network_delegate); |
+} |
+ |
+} // namespace android_webview |