summaryrefslogtreecommitdiffstats
path: root/android_webview/native/aw_web_resource_response_impl.h
blob: e3ec387544092690ce5d55db2bf9b477d8d85c0c (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
// Copyright 2014 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_NATIVE_INTERCEPTED_REQUEST_DATA_IMPL_H_
#define ANDROID_WEBVIEW_NATIVE_INTERCEPTED_REQUEST_DATA_IMPL_H_

#include "android_webview/browser/net/aw_web_resource_response.h"
#include "base/android/scoped_java_ref.h"
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"

namespace net {
class HttpResponseHeaders;
}

namespace android_webview {

class InputStream;

class AwWebResourceResponseImpl : public AwWebResourceResponse {
 public:
  // It is expected that |obj| is an instance of the Java-side
  // org.chromium.android_webview.AwWebResourceResponse class.
  AwWebResourceResponseImpl(const base::android::JavaRef<jobject>& obj);
  ~AwWebResourceResponseImpl() override;

  scoped_ptr<InputStream> GetInputStream(JNIEnv* env) const override;
  bool GetMimeType(JNIEnv* env, std::string* mime_type) const override;
  bool GetCharset(JNIEnv* env, std::string* charset) const override;
  bool GetStatusInfo(JNIEnv* env,
                     int* status_code,
                     std::string* reason_phrase) const override;
  bool GetResponseHeaders(JNIEnv* env,
                          net::HttpResponseHeaders* headers) const override;

 private:
  base::android::ScopedJavaGlobalRef<jobject> java_object_;

  DISALLOW_COPY_AND_ASSIGN(AwWebResourceResponseImpl);
};

bool RegisterAwWebResourceResponse(JNIEnv* env);

} // namespace android_webview

#endif  // ANDROID_WEBVIEW_NATIVE_INTERCEPTED_REQUEST_DATA_IMPL_H_