summaryrefslogtreecommitdiff
path: root/android_webview/browser/intercepted_request_data.h
blob: acf031d338c788eef6583ccd393d90aaf6779a31 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef ANDROID_WEBVIEW_BROWSER_INTERCEPTED_REQUEST_DATA_H_
#define ANDROID_WEBVIEW_BROWSER_INTERCEPTED_REQUEST_DATA_H_

#include <string>

#include "base/android/jni_android.h"
#include "base/memory/scoped_ptr.h"

namespace net {
class URLRequest;
class URLRequestJob;
class NetworkDelegate;
}

namespace android_webview {

class InputStream;

// This class represents the Java-side data that is to be used to complete a
// particular URLRequest.
class InterceptedRequestData {
 public:
  virtual ~InterceptedRequestData() {}

  virtual scoped_ptr<InputStream> GetInputStream(JNIEnv* env) const = 0;
  virtual bool GetMimeType(JNIEnv* env, std::string* mime_type) const = 0;
  virtual bool GetCharset(JNIEnv* env, std::string* charset) const = 0;

  // This creates a URLRequestJob for the |request| wich will read data from
  // the |intercepted_request_data| structure (instead of going to the network
  // or to the cache).
  // The newly created job takes ownership of |intercepted_request_data|.
  static net::URLRequestJob* CreateJobFor(
      scoped_ptr<InterceptedRequestData> intercepted_request_data,
      net::URLRequest* request,
      net::NetworkDelegate* network_delegate);

 protected:
  InterceptedRequestData() {}

 private:
  DISALLOW_COPY_AND_ASSIGN(InterceptedRequestData);
};

} // namespace android_webview

#endif  // ANDROID_WEBVIEW_BROWSER_INTERCEPTED_REQUEST_DATA_H_