Home | History | Annotate | Download | only in browser
      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
      3 // found in the LICENSE file.
      4 
      5 #ifndef ANDROID_WEBVIEW_BROWSER_INTERCEPTED_REQUEST_DATA_H_
      6 #define ANDROID_WEBVIEW_BROWSER_INTERCEPTED_REQUEST_DATA_H_
      7 
      8 #include <string>
      9 
     10 #include "base/android/jni_android.h"
     11 #include "base/memory/scoped_ptr.h"
     12 
     13 namespace net {
     14 class URLRequest;
     15 class URLRequestJob;
     16 class NetworkDelegate;
     17 }
     18 
     19 namespace android_webview {
     20 
     21 class InputStream;
     22 
     23 // This class represents the Java-side data that is to be used to complete a
     24 // particular URLRequest.
     25 class InterceptedRequestData {
     26  public:
     27   virtual ~InterceptedRequestData() {}
     28 
     29   virtual scoped_ptr<InputStream> GetInputStream(JNIEnv* env) const = 0;
     30   virtual bool GetMimeType(JNIEnv* env, std::string* mime_type) const = 0;
     31   virtual bool GetCharset(JNIEnv* env, std::string* charset) const = 0;
     32 
     33   // This creates a URLRequestJob for the |request| wich will read data from
     34   // the |intercepted_request_data| structure (instead of going to the network
     35   // or to the cache).
     36   // The newly created job takes ownership of |intercepted_request_data|.
     37   static net::URLRequestJob* CreateJobFor(
     38       scoped_ptr<InterceptedRequestData> intercepted_request_data,
     39       net::URLRequest* request,
     40       net::NetworkDelegate* network_delegate);
     41 
     42  protected:
     43   InterceptedRequestData() {}
     44 
     45  private:
     46   DISALLOW_COPY_AND_ASSIGN(InterceptedRequestData);
     47 };
     48 
     49 } // namespace android_webview
     50 
     51 #endif  // ANDROID_WEBVIEW_BROWSER_INTERCEPTED_REQUEST_DATA_H_
     52