OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/android/content_view_util.h" | 5 #include "chrome/browser/android/content_view_util.h" |
6 | 6 |
7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/profiles/profile_manager.h" | 10 #include "chrome/browser/profiles/profile_manager.h" |
11 #include "content/public/browser/android/content_view_core.h" | |
11 #include "content/public/browser/web_contents.h" | 12 #include "content/public/browser/web_contents.h" |
12 #include "jni/ContentViewUtil_jni.h" | 13 #include "jni/ContentViewUtil_jni.h" |
13 | 14 |
14 static jlong CreateNativeWebContents( | 15 static jlong CreateNativeWebContents( |
15 JNIEnv* env, jclass clazz, jboolean incognito, jboolean initially_hidden) { | 16 JNIEnv* env, jclass clazz, jboolean incognito, jboolean initially_hidden) { |
16 Profile* profile = g_browser_process->profile_manager()->GetLastUsedProfile(); | 17 Profile* profile = g_browser_process->profile_manager()->GetLastUsedProfile(); |
17 if (incognito) | 18 if (incognito) |
18 profile = profile->GetOffTheRecordProfile(); | 19 profile = profile->GetOffTheRecordProfile(); |
19 | 20 |
20 content::WebContents::CreateParams params(profile); | 21 content::WebContents::CreateParams params(profile); |
21 params.initially_hidden = static_cast<bool>(initially_hidden); | 22 params.initially_hidden = static_cast<bool>(initially_hidden); |
22 return reinterpret_cast<intptr_t>(content::WebContents::Create(params)); | 23 return reinterpret_cast<intptr_t>(content::WebContents::Create(params)); |
23 } | 24 } |
24 | 25 |
26 static jlong CreateNativeWebContentsWithSharedSiteInstance( | |
27 JNIEnv* env, | |
28 jclass clazz, | |
29 jobject jcontent_view_core) { | |
30 Profile* profile = g_browser_process->profile_manager()->GetLastUsedProfile(); | |
David Trainor- moved to gerrit
2014/07/31 00:48:47
Not sure, but should we be grabbing the profile fo
shatch
2014/07/31 18:41:34
Not sure either, but that sounds reasonable. Made
| |
31 | |
32 content::ContentViewCore* content_view_core = | |
33 content::ContentViewCore::GetNativeContentViewCore(env, | |
34 jcontent_view_core); | |
35 CHECK(content_view_core); | |
36 | |
37 content::WebContents::CreateParams params( | |
38 profile, content_view_core->GetWebContents()->GetSiteInstance()); | |
39 | |
40 return reinterpret_cast<intptr_t>(content::WebContents::Create(params)); | |
41 } | |
42 | |
25 static void DestroyNativeWebContents( | 43 static void DestroyNativeWebContents( |
26 JNIEnv* env, jclass clazz, jlong web_contents_ptr) { | 44 JNIEnv* env, jclass clazz, jlong web_contents_ptr) { |
27 content::WebContents* web_contents = | 45 content::WebContents* web_contents = |
28 reinterpret_cast<content::WebContents*>(web_contents_ptr); | 46 reinterpret_cast<content::WebContents*>(web_contents_ptr); |
29 delete web_contents; | 47 delete web_contents; |
30 } | 48 } |
31 | 49 |
32 bool RegisterContentViewUtil(JNIEnv* env) { | 50 bool RegisterContentViewUtil(JNIEnv* env) { |
33 return RegisterNativesImpl(env); | 51 return RegisterNativesImpl(env); |
34 } | 52 } |
OLD | NEW |