1 // Copyright 2015 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 #include "chrome/browser/android/document/document_web_contents_delegate.h"
7 #include "components/web_contents_delegate_android/web_contents_delegate_android.h"
8 #include "content/public/browser/web_contents.h"
9 #include "jni/DocumentWebContentsDelegate_jni.h"
11 DocumentWebContentsDelegate::DocumentWebContentsDelegate(JNIEnv
* env
,
13 : WebContentsDelegateAndroid(env
, obj
) {
16 DocumentWebContentsDelegate::~DocumentWebContentsDelegate() {
19 void DocumentWebContentsDelegate::AttachContents(JNIEnv
* env
,
21 jobject jweb_contents
) {
22 content::WebContents
* web_contents
=
23 content::WebContents::FromJavaWebContents(jweb_contents
);
24 web_contents
->SetDelegate(this);
27 bool DocumentWebContentsDelegate::Register(JNIEnv
* env
) {
28 return RegisterNativesImpl(env
);
31 void DocumentWebContentsDelegate::AddNewContents(
32 content::WebContents
* source
,
33 content::WebContents
* new_contents
,
34 WindowOpenDisposition disposition
,
35 const gfx::Rect
& initial_pos
,
41 void DocumentWebContentsDelegate::CloseContents(content::WebContents
* source
) {
45 bool DocumentWebContentsDelegate::ShouldCreateWebContents(
46 content::WebContents
* web_contents
,
48 int main_frame_route_id
,
49 WindowContainerType window_container_type
,
50 const std::string
& frame_name
,
51 const GURL
& target_url
,
52 const std::string
& partition_id
,
53 content::SessionStorageNamespace
* session_storage_namespace
) {
58 static jlong
Initialize(JNIEnv
* env
, const JavaParamRef
<jobject
>& obj
) {
59 return reinterpret_cast<intptr_t>(new DocumentWebContentsDelegate(env
, obj
));