| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // URL request job for reading from resources and assets. | 5 // URL request job for reading from resources and assets. |
| 6 | 6 |
| 7 #include "chrome/browser/android/android_protocol_adapter.h" | 7 #include "chrome/browser/android/android_protocol_adapter.h" |
| 8 | 8 |
| 9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
| 10 #include "base/android/jni_helper.h" | 10 #include "base/android/jni_helper.h" |
| 11 #include "base/android/jni_string.h" | 11 #include "base/android/jni_string.h" |
| 12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
| 13 #include "chrome/browser/android/android_stream_reader_url_request_job.h" | 13 #include "chrome/browser/android/android_stream_reader_url_request_job.h" |
| 14 #include "chrome/common/url_constants.h" | 14 #include "chrome/common/url_constants.h" |
| 15 #include "googleurl/src/gurl.h" | 15 #include "googleurl/src/gurl.h" |
| 16 #include "jni/AndroidProtocolAdapter_jni.h" | 16 #include "jni/AndroidProtocolAdapter_jni.h" |
| 17 #include "net/base/io_buffer.h" | 17 #include "net/base/io_buffer.h" |
| 18 #include "net/base/mime_util.h" | 18 #include "net/base/mime_util.h" |
| 19 #include "net/base/net_errors.h" | 19 #include "net/base/net_errors.h" |
| 20 #include "net/base/net_util.h" | 20 #include "net/base/net_util.h" |
| 21 #include "net/http/http_util.h" | 21 #include "net/http/http_util.h" |
| 22 #include "net/url_request/url_request.h" |
| 23 #include "net/url_request/url_request_context.h" |
| 24 #include "net/url_request/file_protocol_handler.h" |
| 22 #include "net/url_request/url_request_error_job.h" | 25 #include "net/url_request/url_request_error_job.h" |
| 23 #include "net/url_request/url_request_file_job.h" | |
| 24 #include "net/url_request/url_request_job_manager.h" | 26 #include "net/url_request/url_request_job_manager.h" |
| 25 | 27 |
| 26 using base::android::AttachCurrentThread; | 28 using base::android::AttachCurrentThread; |
| 27 using base::android::ClearException; | 29 using base::android::ClearException; |
| 28 using base::android::ConvertUTF8ToJavaString; | 30 using base::android::ConvertUTF8ToJavaString; |
| 29 using base::android::ScopedJavaGlobalRef; | 31 using base::android::ScopedJavaGlobalRef; |
| 30 using base::android::ScopedJavaLocalRef; | 32 using base::android::ScopedJavaLocalRef; |
| 31 | 33 |
| 32 namespace { | 34 namespace { |
| 33 | 35 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 // handler. | 87 // handler. |
| 86 const std::string& url = request->url().spec(); | 88 const std::string& url = request->url().spec(); |
| 87 std::string assetPrefix = std::string(chrome::kFileScheme) + "://" + | 89 std::string assetPrefix = std::string(chrome::kFileScheme) + "://" + |
| 88 chrome::kAndroidAssetPath; | 90 chrome::kAndroidAssetPath; |
| 89 std::string resourcePrefix = std::string(chrome::kFileScheme) + "://" + | 91 std::string resourcePrefix = std::string(chrome::kFileScheme) + "://" + |
| 90 chrome::kAndroidResourcePath; | 92 chrome::kAndroidResourcePath; |
| 91 | 93 |
| 92 if (scheme == chrome::kFileScheme && | 94 if (scheme == chrome::kFileScheme && |
| 93 !StartsWithASCII(url, assetPrefix, /*case_sensitive=*/ true) && | 95 !StartsWithASCII(url, assetPrefix, /*case_sensitive=*/ true) && |
| 94 !StartsWithASCII(url, resourcePrefix, /*case_sensitive=*/ true)) { | 96 !StartsWithASCII(url, resourcePrefix, /*case_sensitive=*/ true)) { |
| 95 return net::URLRequestFileJob::Factory(request, network_delegate, scheme); | 97 net::FileProtocolHandler file_protocol_handler; |
| 98 return file_protocol_handler.MaybeCreateJob(request, network_delegate); |
| 96 } | 99 } |
| 97 | 100 |
| 98 return new AndroidStreamReaderURLRequestJob( | 101 return new AndroidStreamReaderURLRequestJob( |
| 99 request, | 102 request, |
| 100 network_delegate, | 103 network_delegate, |
| 101 scoped_ptr<AndroidStreamReaderURLRequestJob::Delegate>( | 104 scoped_ptr<AndroidStreamReaderURLRequestJob::Delegate>( |
| 102 new AndroidStreamReaderURLRequestJobDelegateImpl())); | 105 new AndroidStreamReaderURLRequestJobDelegateImpl())); |
| 103 } | 106 } |
| 104 | 107 |
| 105 // static | 108 // static |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 } | 221 } |
| 219 | 222 |
| 220 bool AndroidStreamReaderURLRequestJobDelegateImpl::GetCharset( | 223 bool AndroidStreamReaderURLRequestJobDelegateImpl::GetCharset( |
| 221 JNIEnv* env, | 224 JNIEnv* env, |
| 222 net::URLRequest* request, | 225 net::URLRequest* request, |
| 223 jobject stream, | 226 jobject stream, |
| 224 std::string* charset) { | 227 std::string* charset) { |
| 225 // TODO: We should probably be getting this from the managed side. | 228 // TODO: We should probably be getting this from the managed side. |
| 226 return false; | 229 return false; |
| 227 } | 230 } |
| OLD | NEW |