| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef ANDROID_WEBVIEW_BROWSER_INTERCEPTED_REQUEST_DATA_H_ | 5 #ifndef ANDROID_WEBVIEW_BROWSER_NET_AW_WEB_RESOURCE_RESPONSE_H_ |
| 6 #define ANDROID_WEBVIEW_BROWSER_INTERCEPTED_REQUEST_DATA_H_ | 6 #define ANDROID_WEBVIEW_BROWSER_NET_AW_WEB_RESOURCE_RESPONSE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/android/jni_android.h" | 10 #include "base/android/jni_android.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 | 12 |
| 13 namespace net { | 13 namespace net { |
| 14 class HttpResponseHeaders; | 14 class HttpResponseHeaders; |
| 15 class NetworkDelegate; | 15 class NetworkDelegate; |
| 16 class URLRequest; | 16 class URLRequest; |
| 17 class URLRequestJob; | |
| 18 } | 17 } |
| 19 | 18 |
| 20 namespace android_webview { | 19 namespace android_webview { |
| 21 | 20 |
| 22 class InputStream; | 21 class InputStream; |
| 23 | 22 |
| 24 // This class represents the Java-side data that is to be used to complete a | 23 // This class represents the Java-side data that is to be used to complete a |
| 25 // particular URLRequest. | 24 // particular URLRequest. |
| 26 class AwWebResourceResponse { | 25 class AwWebResourceResponse { |
| 27 public: | 26 public: |
| 28 virtual ~AwWebResourceResponse() {} | 27 virtual ~AwWebResourceResponse() {} |
| 29 | 28 |
| 30 virtual scoped_ptr<InputStream> GetInputStream(JNIEnv* env) const = 0; | 29 virtual scoped_ptr<InputStream> GetInputStream(JNIEnv* env) const = 0; |
| 31 virtual bool GetMimeType(JNIEnv* env, std::string* mime_type) const = 0; | 30 virtual bool GetMimeType(JNIEnv* env, std::string* mime_type) const = 0; |
| 32 virtual bool GetCharset(JNIEnv* env, std::string* charset) const = 0; | 31 virtual bool GetCharset(JNIEnv* env, std::string* charset) const = 0; |
| 33 virtual bool GetStatusInfo(JNIEnv* env, | 32 virtual bool GetStatusInfo(JNIEnv* env, |
| 34 int* status_code, | 33 int* status_code, |
| 35 std::string* reason_phrase) const = 0; | 34 std::string* reason_phrase) const = 0; |
| 36 // If true is returned then |headers| contain the headers, if false is | 35 // If true is returned then |headers| contain the headers, if false is |
| 37 // returned |headers| were not updated. | 36 // returned |headers| were not updated. |
| 38 virtual bool GetResponseHeaders( | 37 virtual bool GetResponseHeaders( |
| 39 JNIEnv* env, | 38 JNIEnv* env, |
| 40 net::HttpResponseHeaders* headers) const = 0; | 39 net::HttpResponseHeaders* headers) const = 0; |
| 41 | 40 |
| 42 // This creates a URLRequestJob for the |request| wich will read data from | |
| 43 // the |aw_web_resource_response| structure (instead of going to the network | |
| 44 // or to the cache). | |
| 45 // The newly created job takes ownership of |aw_web_resource_response|. | |
| 46 static net::URLRequestJob* CreateJobFor( | |
| 47 scoped_ptr<AwWebResourceResponse> aw_web_resource_response, | |
| 48 net::URLRequest* request, | |
| 49 net::NetworkDelegate* network_delegate); | |
| 50 | |
| 51 protected: | 41 protected: |
| 52 AwWebResourceResponse() {} | 42 AwWebResourceResponse() {} |
| 53 | 43 |
| 54 private: | 44 private: |
| 55 DISALLOW_COPY_AND_ASSIGN(AwWebResourceResponse); | 45 DISALLOW_COPY_AND_ASSIGN(AwWebResourceResponse); |
| 56 }; | 46 }; |
| 57 | 47 |
| 58 } // namespace android_webview | 48 } // namespace android_webview |
| 59 | 49 |
| 60 #endif // ANDROID_WEBVIEW_BROWSER_INTERCEPTED_REQUEST_DATA_H_ | 50 #endif // ANDROID_WEBVIEW_BROWSER_NET_AW_WEB_RESOURCE_RESPONSE_H_ |
| OLD | NEW |