OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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/web_contents_factory.h" | 5 #include "chrome/browser/android/web_contents_factory.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/android/content_view_core.h" |
12 #include "content/public/browser/web_contents.h" | 12 #include "content/public/browser/web_contents.h" |
13 #include "jni/WebContentsFactory_jni.h" | 13 #include "jni/WebContentsFactory_jni.h" |
14 | 14 |
15 static jobject CreateWebContents( | 15 static ScopedJavaLocalRef<jobject> CreateWebContents( |
16 JNIEnv* env, jclass clazz, jboolean incognito, jboolean initially_hidden) { | 16 JNIEnv* env, |
| 17 jclass clazz, |
| 18 jboolean incognito, |
| 19 jboolean initially_hidden) { |
17 Profile* profile = g_browser_process->profile_manager()->GetLastUsedProfile(); | 20 Profile* profile = g_browser_process->profile_manager()->GetLastUsedProfile(); |
18 if (incognito) | 21 if (incognito) |
19 profile = profile->GetOffTheRecordProfile(); | 22 profile = profile->GetOffTheRecordProfile(); |
20 | 23 |
21 content::WebContents::CreateParams params(profile); | 24 content::WebContents::CreateParams params(profile); |
22 params.initially_hidden = static_cast<bool>(initially_hidden); | 25 params.initially_hidden = static_cast<bool>(initially_hidden); |
23 return content::WebContents::Create(params)->GetJavaWebContents().Release(); | 26 return content::WebContents::Create(params)->GetJavaWebContents(); |
24 } | 27 } |
25 | 28 |
26 bool RegisterWebContentsFactory(JNIEnv* env) { | 29 bool RegisterWebContentsFactory(JNIEnv* env) { |
27 return RegisterNativesImpl(env); | 30 return RegisterNativesImpl(env); |
28 } | 31 } |
OLD | NEW |