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

Unified Diff: android_webview/browser/net/aw_url_request_context_getter.cc

Issue 12377051: [android_webview] Don't intercept resource and asset URLRequests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: use request restart to fall-through to other handlers Created 7 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: android_webview/browser/net/aw_url_request_context_getter.cc
diff --git a/android_webview/browser/net/aw_url_request_context_getter.cc b/android_webview/browser/net/aw_url_request_context_getter.cc
index 1b7177b641a846cb6198c2bd460a835ab24a48ec..af23b500a976dc1df718125a164a4b111b84bceb 100644
--- a/android_webview/browser/net/aw_url_request_context_getter.cc
+++ b/android_webview/browser/net/aw_url_request_context_getter.cc
@@ -4,6 +4,8 @@
#include "android_webview/browser/net/aw_url_request_context_getter.h"
+#include <vector>
+
#include "android_webview/browser/aw_browser_context.h"
#include "android_webview/browser/aw_request_interceptor.h"
#include "android_webview/browser/net/aw_network_delegate.h"
@@ -123,18 +125,37 @@ net::URLRequestContext* AwURLRequestContextGetter::GetURLRequestContext() {
chrome::kChromeDevToolsScheme,
chrome_devtools_protocol_handler_.release());
DCHECK(set_protocol);
- // Create a chain of URLRequestJobFactories. Keep |job_factory_| pointed
- // at the beginning of the chain.
- job_factory_ = CreateAndroidJobFactory(job_factory.Pass());
- job_factory_.reset(new net::ProtocolInterceptJobFactory(
- job_factory_.Pass(),
- scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>(
- new AwRequestInterceptor())));
- job_factory_.reset(new net::ProtocolInterceptJobFactory(
- job_factory_.Pass(),
- developer_protocol_handler_.Pass()));
+
+ // Create a chain of URLRequestJobFactories. The handlers will be invoked
+ // in the order in which they appear in the protocol_handlers vector.
+ typedef std::vector<net::URLRequestJobFactory::ProtocolHandler*>
+ ProtocolHandlerVector;
+ ProtocolHandlerVector protocol_handlers;
+
+ protocol_handlers.push_back(
+ CreateAndroidContentProtocolHandler().release());
+ protocol_handlers.push_back(
+ CreateAndroidAssetFileProtocolHandler().release());
+ protocol_handlers.push_back(developer_protocol_handler_.release());
+ // The AwRequestInterceptor must come after the content and asset file job
+ // factories. This for WebViewClassic compatibility where it was not
+ // possible to intercept resource loads to resolvable content:// and
+ // file:// URIs.
+ protocol_handlers.push_back(new AwRequestInterceptor());
+ job_factory_ = job_factory.PassAs<net::URLRequestJobFactory>();
+
+ // The chain of responsibility will execute the handlers in reverse to the
+ // order in which the elements of the chain are created.
+ for (ProtocolHandlerVector::reverse_iterator i = protocol_handlers.rbegin();
+ i != protocol_handlers.rend();
+ ++i) {
+ job_factory_.reset(new net::ProtocolInterceptJobFactory(
+ job_factory_.Pass(), make_scoped_ptr(*i)));
+ }
+
url_request_context_->set_job_factory(job_factory_.get());
}
+
return url_request_context_.get();
}

Powered by Google App Engine
This is Rietveld 408576698