summaryrefslogtreecommitdiffstats
path: root/android_webview
diff options
context:
space:
mode:
authormmenke@chromium.org <mmenke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-30 17:56:15 +0000
committermmenke@chromium.org <mmenke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-30 17:56:15 +0000
commit3b90aab39f6ce8b1319d34cbf00795e707d37ddc (patch)
treeebfec4af454f844188c59dbd94fedb60dc7db3c2 /android_webview
parentd8a4aec8579e3cf78af5bfc16616287a109148fb (diff)
downloadchromium_src-3b90aab39f6ce8b1319d34cbf00795e707d37ddc.zip
chromium_src-3b90aab39f6ce8b1319d34cbf00795e707d37ddc.tar.gz
chromium_src-3b90aab39f6ce8b1319d34cbf00795e707d37ddc.tar.bz2
Rename ProtocolInterceptJobFactory and make it not use ProtocolHandlers.
ProtocolHandlers are intended to handle all requests for a particular scheme, while UrlRequestInterceptors are intended to sit in front of ProtocolHandlers, and optionally take over handling of any request, regardless of scheme. Separating the classes removes some ambiguity and weirdness, particularly when passing a bunch of interceptors all over the place from content/ to chrome/ during initialization. BUG=373800 Review URL: https://codereview.chromium.org/282103004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@273874 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'android_webview')
-rw-r--r--android_webview/browser/aw_content_browser_client.cc8
-rw-r--r--android_webview/browser/aw_content_browser_client.h5
-rw-r--r--android_webview/browser/aw_request_interceptor.cc2
-rw-r--r--android_webview/browser/aw_request_interceptor.h8
-rw-r--r--android_webview/browser/net/aw_url_request_context_getter.cc33
-rw-r--r--android_webview/browser/net/init_native_callback.h10
-rw-r--r--android_webview/native/android_protocol_handler.cc64
-rw-r--r--android_webview/native/android_protocol_handler.h11
-rw-r--r--android_webview/native/net_init_native_callback.cc15
9 files changed, 78 insertions, 78 deletions
diff --git a/android_webview/browser/aw_content_browser_client.cc b/android_webview/browser/aw_content_browser_client.cc
index 1d0e0ae..62aff35 100644
--- a/android_webview/browser/aw_content_browser_client.cc
+++ b/android_webview/browser/aw_content_browser_client.cc
@@ -212,9 +212,9 @@ void AwContentBrowserClient::RenderProcessWillLaunch(
net::URLRequestContextGetter* AwContentBrowserClient::CreateRequestContext(
content::BrowserContext* browser_context,
content::ProtocolHandlerMap* protocol_handlers,
- content::ProtocolHandlerScopedVector protocol_interceptors) {
+ content::URLRequestInterceptorScopedVector request_interceptors) {
DCHECK(browser_context_.get() == browser_context);
- // TODO(mkosiba,kinuko): protocol_interceptors should be hooked up in the
+ // TODO(mkosiba,kinuko): request_interceptors should be hooked up in the
// downstream. (crbug.com/350286)
return browser_context_->CreateRequestContext(protocol_handlers);
}
@@ -225,8 +225,10 @@ AwContentBrowserClient::CreateRequestContextForStoragePartition(
const base::FilePath& partition_path,
bool in_memory,
content::ProtocolHandlerMap* protocol_handlers,
- content::ProtocolHandlerScopedVector protocol_interceptors) {
+ content::URLRequestInterceptorScopedVector request_interceptors) {
DCHECK(browser_context_.get() == browser_context);
+ // TODO(mkosiba,kinuko): request_interceptors should be hooked up in the
+ // downstream. (crbug.com/350286)
return browser_context_->CreateRequestContextForStoragePartition(
partition_path, in_memory, protocol_handlers);
}
diff --git a/android_webview/browser/aw_content_browser_client.h b/android_webview/browser/aw_content_browser_client.h
index 49a2abc..b313e58 100644
--- a/android_webview/browser/aw_content_browser_client.h
+++ b/android_webview/browser/aw_content_browser_client.h
@@ -10,7 +10,6 @@
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
#include "content/public/browser/content_browser_client.h"
-#include "net/url_request/url_request_job_factory.h"
struct WebPreferences;
@@ -46,13 +45,13 @@ class AwContentBrowserClient : public content::ContentBrowserClient {
virtual net::URLRequestContextGetter* CreateRequestContext(
content::BrowserContext* browser_context,
content::ProtocolHandlerMap* protocol_handlers,
- content::ProtocolHandlerScopedVector protocol_interceptors) OVERRIDE;
+ content::URLRequestInterceptorScopedVector request_interceptors) OVERRIDE;
virtual net::URLRequestContextGetter* CreateRequestContextForStoragePartition(
content::BrowserContext* browser_context,
const base::FilePath& partition_path,
bool in_memory,
content::ProtocolHandlerMap* protocol_handlers,
- content::ProtocolHandlerScopedVector protocol_interceptors) OVERRIDE;
+ content::URLRequestInterceptorScopedVector request_interceptors) OVERRIDE;
virtual std::string GetCanonicalEncodingNameByAliasName(
const std::string& alias_name) OVERRIDE;
virtual void AppendExtraCommandLineSwitches(base::CommandLine* command_line,
diff --git a/android_webview/browser/aw_request_interceptor.cc b/android_webview/browser/aw_request_interceptor.cc
index e61d04b..a53061b 100644
--- a/android_webview/browser/aw_request_interceptor.cc
+++ b/android_webview/browser/aw_request_interceptor.cc
@@ -53,7 +53,7 @@ AwRequestInterceptor::QueryForInterceptedRequestData(
return io_thread_client->ShouldInterceptRequest(location, request).Pass();
}
-net::URLRequestJob* AwRequestInterceptor::MaybeCreateJob(
+net::URLRequestJob* AwRequestInterceptor::MaybeInterceptRequest(
net::URLRequest* request,
net::NetworkDelegate* network_delegate) const {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
diff --git a/android_webview/browser/aw_request_interceptor.h b/android_webview/browser/aw_request_interceptor.h
index 51a7af8..b83ab32 100644
--- a/android_webview/browser/aw_request_interceptor.h
+++ b/android_webview/browser/aw_request_interceptor.h
@@ -6,7 +6,7 @@
#define ANDROID_WEBVIEW_BROWSER_AW_REQUEST_INTERCEPTOR_H_
#include "base/memory/scoped_ptr.h"
-#include "net/url_request/url_request_job_factory.h"
+#include "net/url_request/url_request_interceptor.h"
class GURL;
@@ -24,13 +24,13 @@ class InterceptedRequestData;
// This class allows the Java-side embedder to substitute the default
// URLRequest of a given request for an alternative job that will read data
// from a Java stream.
-class AwRequestInterceptor : public net::URLRequestJobFactory::ProtocolHandler {
+class AwRequestInterceptor : public net::URLRequestInterceptor {
public:
AwRequestInterceptor();
virtual ~AwRequestInterceptor();
- // net::URLRequestJobFactory::ProtocolHandler override -----------------------
- virtual net::URLRequestJob* MaybeCreateJob(
+ // net::URLRequestInterceptor override --------------------------------------
+ virtual net::URLRequestJob* MaybeInterceptRequest(
net::URLRequest* request,
net::NetworkDelegate* network_delegate) const OVERRIDE;
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 218f09a..d456af2 100644
--- a/android_webview/browser/net/aw_url_request_context_getter.cc
+++ b/android_webview/browser/net/aw_url_request_context_getter.cc
@@ -34,9 +34,10 @@
#include "net/socket/next_proto.h"
#include "net/url_request/data_protocol_handler.h"
#include "net/url_request/file_protocol_handler.h"
-#include "net/url_request/protocol_intercept_job_factory.h"
#include "net/url_request/url_request_context_builder.h"
#include "net/url_request/url_request_context.h"
+#include "net/url_request/url_request_intercepting_job_factory.h"
+#include "net/url_request/url_request_interceptor.h"
using content::BrowserThread;
using data_reduction_proxy::DataReductionProxySettings;
@@ -131,36 +132,36 @@ scoped_ptr<net::URLRequestJobFactory> CreateJobFactory(
protocol_handlers->clear();
// 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_interceptors;
+ // in the order in which they appear in the |request_interceptors| vector.
+ typedef std::vector<net::URLRequestInterceptor*>
+ URLRequestInterceptorVector;
+ URLRequestInterceptorVector request_interceptors;
// Note that even though the content:// scheme handler is created here,
// it cannot be used by child processes until access to it is granted via
// ChildProcessSecurityPolicy::GrantScheme(). This is done in
// AwContentBrowserClient.
- protocol_interceptors.push_back(
- CreateAndroidContentProtocolHandler().release());
- protocol_interceptors.push_back(
- CreateAndroidAssetFileProtocolHandler().release());
+ request_interceptors.push_back(
+ CreateAndroidContentRequestInterceptor().release());
+ request_interceptors.push_back(
+ CreateAndroidAssetFileRequestInterceptor().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.
// This logical dependency is also the reason why the Content
- // ProtocolHandler has to be added as a ProtocolInterceptJobFactory rather
- // than via SetProtocolHandler.
- protocol_interceptors.push_back(new AwRequestInterceptor());
+ // URLRequestInterceptor has to be added as an interceptor rather than as a
+ // ProtocolHandler.
+ request_interceptors.push_back(new AwRequestInterceptor());
// The chain of responsibility will execute the handlers in reverse to the
// order in which the elements of the chain are created.
scoped_ptr<net::URLRequestJobFactory> job_factory(aw_job_factory.Pass());
- for (ProtocolHandlerVector::reverse_iterator
- i = protocol_interceptors.rbegin();
- i != protocol_interceptors.rend();
+ for (URLRequestInterceptorVector::reverse_iterator
+ i = request_interceptors.rbegin();
+ i != request_interceptors.rend();
++i) {
- job_factory.reset(new net::ProtocolInterceptJobFactory(
+ job_factory.reset(new net::URLRequestInterceptingJobFactory(
job_factory.Pass(), make_scoped_ptr(*i)));
}
diff --git a/android_webview/browser/net/init_native_callback.h b/android_webview/browser/net/init_native_callback.h
index 5f48e4c..d98867c 100644
--- a/android_webview/browser/net/init_native_callback.h
+++ b/android_webview/browser/net/init_native_callback.h
@@ -7,10 +7,10 @@
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
-#include "net/url_request/url_request_job_factory.h"
namespace net {
class CookieStore;
+class URLRequestInterceptor;
} // namespace net
namespace android_webview {
@@ -21,12 +21,12 @@ scoped_refptr<net::CookieStore> CreateCookieStore(
AwBrowserContext* browser_context);
// Called lazily when the job factory is being constructed.
-scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
- CreateAndroidAssetFileProtocolHandler();
+scoped_ptr<net::URLRequestInterceptor>
+ CreateAndroidAssetFileRequestInterceptor();
// Called lazily when the job factory is being constructed.
-scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
- CreateAndroidContentProtocolHandler();
+scoped_ptr<net::URLRequestInterceptor>
+ CreateAndroidContentRequestInterceptor();
} // namespace android_webview
diff --git a/android_webview/native/android_protocol_handler.cc b/android_webview/native/android_protocol_handler.cc
index a396fb9..1c0c922 100644
--- a/android_webview/native/android_protocol_handler.cc
+++ b/android_webview/native/android_protocol_handler.cc
@@ -19,8 +19,8 @@
#include "net/base/net_errors.h"
#include "net/base/net_util.h"
#include "net/http/http_util.h"
-#include "net/url_request/protocol_intercept_job_factory.h"
#include "net/url_request/url_request.h"
+#include "net/url_request/url_request_interceptor.h"
#include "url/gurl.h"
using android_webview::InputStream;
@@ -80,22 +80,22 @@ class AndroidStreamReaderURLRequestJobDelegateImpl
virtual ~AndroidStreamReaderURLRequestJobDelegateImpl();
};
-class AndroidProtocolHandlerBase :
- public net::URLRequestJobFactory::ProtocolHandler {
+class AndroidRequestInterceptorBase : public net::URLRequestInterceptor {
public:
- virtual net::URLRequestJob* MaybeCreateJob(
+ virtual net::URLRequestJob* MaybeInterceptRequest(
net::URLRequest* request,
net::NetworkDelegate* network_delegate) const OVERRIDE;
- virtual bool CanHandleRequest(const net::URLRequest* request) const = 0;
+ virtual bool ShouldHandleRequest(const net::URLRequest* request) const = 0;
};
-class AssetFileProtocolHandler : public AndroidProtocolHandlerBase {
+class AssetFileRequestInterceptor : public AndroidRequestInterceptorBase {
public:
- AssetFileProtocolHandler();
+ AssetFileRequestInterceptor();
- virtual ~AssetFileProtocolHandler() OVERRIDE;
- virtual bool CanHandleRequest(const net::URLRequest* request) const OVERRIDE;
+ virtual ~AssetFileRequestInterceptor() OVERRIDE;
+ virtual bool ShouldHandleRequest(
+ const net::URLRequest* request) const OVERRIDE;
private:
// file:///android_asset/
@@ -105,10 +105,11 @@ class AssetFileProtocolHandler : public AndroidProtocolHandlerBase {
};
// Protocol handler for content:// scheme requests.
-class ContentSchemeProtocolHandler : public AndroidProtocolHandlerBase {
+class ContentSchemeRequestInterceptor : public AndroidRequestInterceptorBase {
public:
- ContentSchemeProtocolHandler();
- virtual bool CanHandleRequest(const net::URLRequest* request) const OVERRIDE;
+ ContentSchemeRequestInterceptor();
+ virtual bool ShouldHandleRequest(
+ const net::URLRequest* request) const OVERRIDE;
};
static ScopedJavaLocalRef<jobject> GetResourceContext(JNIEnv* env) {
@@ -197,12 +198,13 @@ bool AndroidStreamReaderURLRequestJobDelegateImpl::GetCharset(
return false;
}
-// AndroidProtocolHandlerBase -------------------------------------------------
+// AndroidRequestInterceptorBase ----------------------------------------------
-net::URLRequestJob* AndroidProtocolHandlerBase::MaybeCreateJob(
+net::URLRequestJob* AndroidRequestInterceptorBase::MaybeInterceptRequest(
net::URLRequest* request,
net::NetworkDelegate* network_delegate) const {
- if (!CanHandleRequest(request)) return NULL;
+ if (!ShouldHandleRequest(request))
+ return NULL;
// For WebViewClassic compatibility this job can only accept URLs that can be
// opened. URLs that cannot be opened should be resolved by the next handler.
@@ -214,7 +216,8 @@ net::URLRequestJob* AndroidProtocolHandlerBase::MaybeCreateJob(
// handler will ignore requests know to have previously failed to 1) prevent
// an infinite loop, 2) ensure that the next handler in line gets the
// opportunity to create a job for the request.
- if (HasRequestPreviouslyFailed(request)) return NULL;
+ if (HasRequestPreviouslyFailed(request))
+ return NULL;
scoped_ptr<AndroidStreamReaderURLRequestJobDelegateImpl> reader_delegate(
new AndroidStreamReaderURLRequestJobDelegateImpl());
@@ -225,9 +228,9 @@ net::URLRequestJob* AndroidProtocolHandlerBase::MaybeCreateJob(
reader_delegate.PassAs<AndroidStreamReaderURLRequestJob::Delegate>());
}
-// AssetFileProtocolHandler ---------------------------------------------------
+// AssetFileRequestInterceptor ------------------------------------------------
-AssetFileProtocolHandler::AssetFileProtocolHandler()
+AssetFileRequestInterceptor::AssetFileRequestInterceptor()
: asset_prefix_(std::string(url::kFileScheme) +
std::string(content::kStandardSchemeSeparator) +
android_webview::kAndroidAssetPath),
@@ -236,10 +239,10 @@ AssetFileProtocolHandler::AssetFileProtocolHandler()
android_webview::kAndroidResourcePath) {
}
-AssetFileProtocolHandler::~AssetFileProtocolHandler() {
+AssetFileRequestInterceptor::~AssetFileRequestInterceptor() {
}
-bool AssetFileProtocolHandler::CanHandleRequest(
+bool AssetFileRequestInterceptor::ShouldHandleRequest(
const net::URLRequest* request) const {
if (!request->url().SchemeIsFile())
return false;
@@ -253,12 +256,12 @@ bool AssetFileProtocolHandler::CanHandleRequest(
return true;
}
-// ContentSchemeProtocolHandler -----------------------------------------------
+// ContentSchemeRequestInterceptor --------------------------------------------
-ContentSchemeProtocolHandler::ContentSchemeProtocolHandler() {
+ContentSchemeRequestInterceptor::ContentSchemeRequestInterceptor() {
}
-bool ContentSchemeProtocolHandler::CanHandleRequest(
+bool ContentSchemeRequestInterceptor::ShouldHandleRequest(
const net::URLRequest* request) const {
return request->url().SchemeIs(android_webview::kContentScheme);
}
@@ -272,17 +275,16 @@ bool RegisterAndroidProtocolHandler(JNIEnv* env) {
}
// static
-scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
-CreateContentSchemeProtocolHandler() {
- return make_scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>(
- new ContentSchemeProtocolHandler());
+scoped_ptr<net::URLRequestInterceptor>
+CreateContentSchemeRequestInterceptor() {
+ return make_scoped_ptr<net::URLRequestInterceptor>(
+ new ContentSchemeRequestInterceptor());
}
// static
-scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
-CreateAssetFileProtocolHandler() {
- return make_scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>(
- new AssetFileProtocolHandler());
+scoped_ptr<net::URLRequestInterceptor> CreateAssetFileRequestInterceptor() {
+ return scoped_ptr<net::URLRequestInterceptor>(
+ new AssetFileRequestInterceptor());
}
// Set a context object to be used for resolving resource queries. This can
diff --git a/android_webview/native/android_protocol_handler.h b/android_webview/native/android_protocol_handler.h
index 82266b8..d5a4df1 100644
--- a/android_webview/native/android_protocol_handler.h
+++ b/android_webview/native/android_protocol_handler.h
@@ -7,29 +7,26 @@
#include "base/android/jni_android.h"
#include "base/memory/scoped_ptr.h"
-#include "net/url_request/url_request_job_factory.h"
namespace net {
class URLRequestContext;
+class URLRequestInterceptor;
} // namespace net
namespace android_webview {
-// These method register support for Android WebView-specific protocol schemes:
+// These methods create interceptors for Android WebView-specific schemes:
//
// - "content:" scheme is used for accessing data from Android content
// providers, see http://developer.android.com/guide/topics/providers/
// content-provider-basics.html#ContentURIs
-//
-scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
- CreateContentSchemeProtocolHandler();
+scoped_ptr<net::URLRequestInterceptor> CreateContentSchemeRequestInterceptor();
// - "file:" scheme extension for accessing application assets and resources
// (file:///android_asset/ and file:///android_res/), see
// http://developer.android.com/reference/android/webkit/
// WebSettings.html#setAllowFileAccess(boolean)
-scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
- CreateAssetFileProtocolHandler();
+scoped_ptr<net::URLRequestInterceptor> CreateAssetFileRequestInterceptor();
bool RegisterAndroidProtocolHandler(JNIEnv* env);
diff --git a/android_webview/native/net_init_native_callback.cc b/android_webview/native/net_init_native_callback.cc
index f355c03..22a245b 100644
--- a/android_webview/native/net_init_native_callback.cc
+++ b/android_webview/native/net_init_native_callback.cc
@@ -6,19 +6,18 @@
#include "android_webview/browser/net/aw_url_request_job_factory.h"
#include "android_webview/native/android_protocol_handler.h"
-#include "base/logging.h"
+#include "net/url_request/url_request_interceptor.h"
namespace android_webview {
-class AwURLRequestJobFactory;
-scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
-CreateAndroidAssetFileProtocolHandler() {
- return CreateAssetFileProtocolHandler();
+scoped_ptr<net::URLRequestInterceptor>
+CreateAndroidAssetFileRequestInterceptor() {
+ return CreateAssetFileRequestInterceptor();
}
-scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
-CreateAndroidContentProtocolHandler() {
- return CreateContentSchemeProtocolHandler();
+scoped_ptr<net::URLRequestInterceptor>
+CreateAndroidContentRequestInterceptor() {
+ return CreateContentSchemeRequestInterceptor();
}
} // namespace android_webview