| 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" | |
| 6 | |
| 7 #include "base/android/jni_android.h" | 5 #include "base/android/jni_android.h" |
| 8 #include "chrome/browser/browser_process.h" | 6 #include "chrome/browser/browser_process.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 7 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/profiles/profile_manager.h" | 8 #include "chrome/browser/profiles/profile_manager.h" |
| 11 #include "content/public/browser/web_contents.h" | 9 #include "content/public/browser/web_contents.h" |
| 12 #include "jni/ContentViewUtil_jni.h" | 10 #include "jni/ContentViewUtil_jni.h" |
| 13 | 11 |
| 14 static jlong CreateNativeWebContents( | 12 static jlong CreateNativeWebContents( |
| 15 JNIEnv* env, jclass clazz, jboolean incognito, jboolean initially_hidden) { | 13 JNIEnv* env, jclass clazz, jboolean incognito, jboolean initially_hidden) { |
| 16 Profile* profile = g_browser_process->profile_manager()->GetLastUsedProfile(); | 14 Profile* profile = g_browser_process->profile_manager()->GetLastUsedProfile(); |
| 17 if (incognito) | 15 if (incognito) |
| 18 profile = profile->GetOffTheRecordProfile(); | 16 profile = profile->GetOffTheRecordProfile(); |
| 19 | 17 |
| 20 content::WebContents::CreateParams params = | 18 content::WebContents::CreateParams params = |
| 21 content::WebContents::CreateParams(profile); | 19 content::WebContents::CreateParams(profile); |
| 22 params.initially_hidden = static_cast<bool>(initially_hidden); | 20 params.initially_hidden = static_cast<bool>(initially_hidden); |
| 23 return reinterpret_cast<intptr_t>(content::WebContents::Create(params)); | 21 return reinterpret_cast<intptr_t>(content::WebContents::Create(params)); |
| 24 } | 22 } |
| 25 | 23 |
| 26 static void DestroyNativeWebContents( | 24 static void DestroyNativeWebContents( |
| 27 JNIEnv* env, jclass clazz, jlong web_contents_ptr) { | 25 JNIEnv* env, jclass clazz, jlong web_contents_ptr) { |
| 28 content::WebContents* web_contents = | 26 content::WebContents* web_contents = |
| 29 reinterpret_cast<content::WebContents*>(web_contents_ptr); | 27 reinterpret_cast<content::WebContents*>(web_contents_ptr); |
| 30 delete web_contents; | 28 delete web_contents; |
| 31 } | 29 } |
| 32 | |
| 33 bool RegisterContentViewUtil(JNIEnv* env) { | |
| 34 return RegisterNativesImpl(env); | |
| 35 } | |
| OLD | NEW |