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
52
53
54
55
android_webview / browser / network_service / aw_web_resource_intercept_response.h [blame]
// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ANDROID_WEBVIEW_BROWSER_NETWORK_SERVICE_AW_WEB_RESOURCE_INTERCEPT_RESPONSE_H_
#define ANDROID_WEBVIEW_BROWSER_NETWORK_SERVICE_AW_WEB_RESOURCE_INTERCEPT_RESPONSE_H_
#include <memory>
#include <vector>
#include "base/android/jni_android.h"
#include "base/android/scoped_java_ref.h"
#include "base/compiler_specific.h"
namespace embedder_support {
class WebResourceResponse;
}
namespace android_webview {
class AwWebResourceInterceptResponse {
public:
AwWebResourceInterceptResponse() = delete;
// It is expected that |obj| is an instance of the Java-side
// org.chromium.android_webview.AwWebResourceInterceptResponse class.
explicit AwWebResourceInterceptResponse(
const base::android::JavaRef<jobject>& obj);
AwWebResourceInterceptResponse(const AwWebResourceInterceptResponse&) =
delete;
AwWebResourceInterceptResponse& operator=(
const AwWebResourceInterceptResponse&) = delete;
~AwWebResourceInterceptResponse();
// True if the call to shouldInterceptRequest raised an exception.
bool RaisedException(JNIEnv* env) const;
// True if this object contains a response.
bool HasResponse(JNIEnv* env) const;
// The response returned by the Java-side handler. Caller should first check
// if an exception was caught via RaisedException() before calling
// this method. A null value means do not intercept the response.
std::unique_ptr<embedder_support::WebResourceResponse> GetResponse(
JNIEnv* env) const;
private:
base::android::ScopedJavaGlobalRef<jobject> java_object_;
};
} // namespace android_webview
#endif // ANDROID_WEBVIEW_BROWSER_NETWORK_SERVICE_AW_WEB_RESOURCE_INTERCEPT_RESPONSE_H_