blob: 4c9d555186039c0e4817b33f30e41ca7bee1ad6c [file] [log] [blame]
// 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.
#include "android_webview/browser/aw_contents_io_thread_client.h"
#include "base/android/scoped_java_ref.h"
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
class GURL;
namespace content {
class ResourceRequestInfo;
class WebContents;
namespace net {
class URLRequest;
namespace android_webview {
class AwWebResourceResponse;
class AwContentsIoThreadClientImpl : public AwContentsIoThreadClient {
// Called when AwContents is created before there is a Java client.
static void RegisterPendingContents(content::WebContents* web_contents);
// Associates the |jclient| instance (which must implement the
// AwContentsIoThreadClient Java interface) with the |web_contents|.
// This should be called at most once per |web_contents|.
static void Associate(content::WebContents* web_contents,
const base::android::JavaRef<jobject>& jclient);
// Either |pending_associate| is true or |jclient| holds a non-null
// Java object.
AwContentsIoThreadClientImpl(bool pending_associate,
const base::android::JavaRef<jobject>& jclient);
virtual ~AwContentsIoThreadClientImpl() override;
// Implementation of AwContentsIoThreadClient.
virtual bool PendingAssociation() const override;
virtual CacheMode GetCacheMode() const override;
virtual scoped_ptr<AwWebResourceResponse> ShouldInterceptRequest(
const GURL& location,
const net::URLRequest* request) override;
virtual bool ShouldBlockContentUrls() const override;
virtual bool ShouldBlockFileUrls() const override;
virtual bool ShouldAcceptThirdPartyCookies() const override;
virtual bool ShouldBlockNetworkLoads() const override;
virtual void NewDownload(const GURL& url,
const std::string& user_agent,
const std::string& content_disposition,
const std::string& mime_type,
int64 content_length) override;
virtual void NewLoginRequest(const std::string& realm,
const std::string& account,
const std::string& args) override;
bool pending_association_;
base::android::ScopedJavaGlobalRef<jobject> java_object_;
// JNI registration method.
bool RegisterAwContentsIoThreadClientImpl(JNIEnv* env);
} // namespace android_webview