Supervised user whitelists: Cleanup
[chromium-blink-merge.git] / android_webview / native / aw_contents_io_thread_client_impl.h
blob97ba3146091604596ff47d6a80fdd61ac7726384
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.
5 #ifndef ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_IO_THREAD_CLIENT_IMPL_H_
6 #define ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_IO_THREAD_CLIENT_IMPL_H_
8 #include "android_webview/browser/aw_contents_io_thread_client.h"
10 #include "base/android/scoped_java_ref.h"
11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h"
13 #include "base/memory/scoped_ptr.h"
15 class GURL;
17 namespace content {
18 class ResourceRequestInfo;
19 class WebContents;
22 namespace net {
23 class URLRequest;
26 namespace android_webview {
28 class AwWebResourceResponse;
30 class AwContentsIoThreadClientImpl : public AwContentsIoThreadClient {
31 public:
32 // Called when AwContents is created before there is a Java client.
33 static void RegisterPendingContents(content::WebContents* web_contents);
35 // Associates the |jclient| instance (which must implement the
36 // AwContentsIoThreadClient Java interface) with the |web_contents|.
37 // This should be called at most once per |web_contents|.
38 static void Associate(content::WebContents* web_contents,
39 const base::android::JavaRef<jobject>& jclient);
41 // Either |pending_associate| is true or |jclient| holds a non-null
42 // Java object.
43 AwContentsIoThreadClientImpl(bool pending_associate,
44 const base::android::JavaRef<jobject>& jclient);
45 ~AwContentsIoThreadClientImpl() override;
47 // Implementation of AwContentsIoThreadClient.
48 bool PendingAssociation() const override;
49 CacheMode GetCacheMode() const override;
50 scoped_ptr<AwWebResourceResponse> ShouldInterceptRequest(
51 const net::URLRequest* request) override;
52 bool ShouldBlockContentUrls() const override;
53 bool ShouldBlockFileUrls() const override;
54 bool ShouldAcceptThirdPartyCookies() const override;
55 bool ShouldBlockNetworkLoads() const override;
56 void NewDownload(const GURL& url,
57 const std::string& user_agent,
58 const std::string& content_disposition,
59 const std::string& mime_type,
60 int64 content_length) override;
61 void NewLoginRequest(const std::string& realm,
62 const std::string& account,
63 const std::string& args) override;
64 void OnReceivedError(const net::URLRequest* request) override;
65 void OnReceivedHttpError(
66 const net::URLRequest* request,
67 const net::HttpResponseHeaders* response_headers) override;
69 private:
70 bool pending_association_;
71 base::android::ScopedJavaGlobalRef<jobject> java_object_;
73 DISALLOW_COPY_AND_ASSIGN(AwContentsIoThreadClientImpl);
76 // JNI registration method.
77 bool RegisterAwContentsIoThreadClientImpl(JNIEnv* env);
79 } // namespace android_webview
81 #endif // ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_IO_THREAD_CLIENT_IMPL_H_