diff options
Diffstat (limited to 'android_webview/native')
-rw-r--r-- | android_webview/native/android_protocol_handler.cc | 31 | ||||
-rw-r--r-- | android_webview/native/aw_contents.cc | 6 | ||||
-rw-r--r-- | android_webview/native/aw_contents.h | 2 |
3 files changed, 10 insertions, 29 deletions
diff --git a/android_webview/native/android_protocol_handler.cc b/android_webview/native/android_protocol_handler.cc index dd4db90..be3376c 100644 --- a/android_webview/native/android_protocol_handler.cc +++ b/android_webview/native/android_protocol_handler.cc @@ -11,7 +11,6 @@ #include "base/android/jni_android.h" #include "base/android/jni_string.h" #include "base/android/jni_weak_ref.h" -#include "base/strings/string_util.h" #include "content/public/common/url_constants.h" #include "jni/AndroidProtocolHandler_jni.h" #include "net/base/io_buffer.h" @@ -95,15 +94,7 @@ class AndroidRequestInterceptorBase : public net::URLRequestInterceptor { class AssetFileRequestInterceptor : public AndroidRequestInterceptorBase { public: AssetFileRequestInterceptor(); - - ~AssetFileRequestInterceptor() override; bool ShouldHandleRequest(const net::URLRequest* request) const override; - - private: - // file:///android_asset/ - const std::string asset_prefix_; - // file:///android_res/ - const std::string resource_prefix_; }; // Protocol handler for content:// scheme requests. @@ -235,30 +226,12 @@ net::URLRequestJob* AndroidRequestInterceptorBase::MaybeInterceptRequest( // AssetFileRequestInterceptor ------------------------------------------------ -AssetFileRequestInterceptor::AssetFileRequestInterceptor() - : asset_prefix_(std::string(url::kFileScheme) + - std::string(url::kStandardSchemeSeparator) + - android_webview::kAndroidAssetPath), - resource_prefix_(std::string(url::kFileScheme) + - std::string(url::kStandardSchemeSeparator) + - android_webview::kAndroidResourcePath) { -} - -AssetFileRequestInterceptor::~AssetFileRequestInterceptor() { +AssetFileRequestInterceptor::AssetFileRequestInterceptor() { } bool AssetFileRequestInterceptor::ShouldHandleRequest( const net::URLRequest* request) const { - if (!request->url().SchemeIsFile()) - return false; - - const std::string& url = request->url().spec(); - if (!base::StartsWith(url, asset_prefix_, base::CompareCase::SENSITIVE) && - !base::StartsWith(url, resource_prefix_, base::CompareCase::SENSITIVE)) { - return false; - } - - return true; + return android_webview::IsAndroidSpecialFileUrl(request->url()); } // ContentSchemeRequestInterceptor -------------------------------------------- diff --git a/android_webview/native/aw_contents.cc b/android_webview/native/aw_contents.cc index 7d34034..84c2457 100644 --- a/android_webview/native/aw_contents.cc +++ b/android_webview/native/aw_contents.cc @@ -53,6 +53,7 @@ #include "content/public/browser/android/synchronous_compositor.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/cert_store.h" +#include "content/public/browser/child_process_security_policy.h" #include "content/public/browser/favicon_status.h" #include "content/public/browser/message_port_provider.h" #include "content/public/browser/navigation_entry.h" @@ -1205,6 +1206,11 @@ void AwContents::CreateMessageChannel(JNIEnv* env, jobject obj, GetMessagePortMessageFilter()); } +void AwContents::GrantFileSchemeAccesstoChildProcess(JNIEnv* env, jobject obj) { + content::ChildProcessSecurityPolicy::GetInstance()->GrantScheme( + web_contents_->GetRenderProcessHost()->GetID(), url::kFileScheme); +} + void SetShouldDownloadFavicons(JNIEnv* env, jclass jclazz) { g_should_download_favicons = true; } diff --git a/android_webview/native/aw_contents.h b/android_webview/native/aw_contents.h index 7600051..cbdb8b2 100644 --- a/android_webview/native/aw_contents.h +++ b/android_webview/native/aw_contents.h @@ -237,6 +237,8 @@ class AwContents : public FindHelper::Listener, jstring message, jstring target_origin, jintArray sent_ports); void CreateMessageChannel(JNIEnv* env, jobject obj, jobjectArray ports); + void GrantFileSchemeAccesstoChildProcess(JNIEnv* env, jobject obj); + private: void InitDataReductionProxyIfNecessary(); void InitAutofillIfNecessary(bool enabled); |