Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(250)

Side by Side Diff: chrome/browser/android/content_view_util.cc

Issue 831523005: Remove most native WebContents references from Java (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Kept same error checking behavior for aw_contents.cc Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/android/content_view_core.h"
12 #include "content/public/browser/web_contents.h" 12 #include "content/public/browser/web_contents.h"
13 #include "jni/ContentViewUtil_jni.h" 13 #include "jni/ContentViewUtil_jni.h"
14 14
15 static jlong CreateNativeWebContents( 15 static jobject CreateWebContents(
16 JNIEnv* env, jclass clazz, jboolean incognito, jboolean initially_hidden) { 16 JNIEnv* env, jclass clazz, jboolean incognito, jboolean initially_hidden) {
17 Profile* profile = g_browser_process->profile_manager()->GetLastUsedProfile(); 17 Profile* profile = g_browser_process->profile_manager()->GetLastUsedProfile();
18 if (incognito) 18 if (incognito)
19 profile = profile->GetOffTheRecordProfile(); 19 profile = profile->GetOffTheRecordProfile();
20 20
21 content::WebContents::CreateParams params(profile); 21 content::WebContents::CreateParams params(profile);
22 params.initially_hidden = static_cast<bool>(initially_hidden); 22 params.initially_hidden = static_cast<bool>(initially_hidden);
23 return reinterpret_cast<intptr_t>(content::WebContents::Create(params)); 23 return content::WebContents::Create(params)->GetJavaWebContents().Release();
24 } 24 }
25 25
26 static jlong CreateNativeWebContentsWithSharedSiteInstance( 26 static jobject CreateWebContentsWithSharedSiteInstance(
27 JNIEnv* env, 27 JNIEnv* env,
28 jclass clazz, 28 jclass clazz,
29 jobject jcontent_view_core) { 29 jobject jcontent_view_core) {
30 content::ContentViewCore* content_view_core = 30 content::ContentViewCore* content_view_core =
31 content::ContentViewCore::GetNativeContentViewCore(env, 31 content::ContentViewCore::GetNativeContentViewCore(env,
32 jcontent_view_core); 32 jcontent_view_core);
33 CHECK(content_view_core); 33 CHECK(content_view_core);
34 34
35 Profile* profile = Profile::FromBrowserContext( 35 Profile* profile = Profile::FromBrowserContext(
36 content_view_core->GetWebContents()->GetBrowserContext()); 36 content_view_core->GetWebContents()->GetBrowserContext());
37 37
38 content::WebContents::CreateParams params( 38 content::WebContents::CreateParams params(
39 profile, content_view_core->GetWebContents()->GetSiteInstance()); 39 profile, content_view_core->GetWebContents()->GetSiteInstance());
40 40
41 return reinterpret_cast<intptr_t>(content::WebContents::Create(params)); 41 return content::WebContents::Create(params)->GetJavaWebContents().Release();
42 } 42 }
43 43
44 static void DestroyNativeWebContents( 44 static jobject GetWebContentsFromNative(
45 JNIEnv* env, jclass clazz, jlong web_contents_ptr) { 45 JNIEnv* env, jclass clazz, jlong web_contents_ptr) {
46 content::WebContents* web_contents = 46 content::WebContents* web_contents =
47 reinterpret_cast<content::WebContents*>(web_contents_ptr); 47 reinterpret_cast<content::WebContents*>(web_contents_ptr);
Ted C 2015/01/21 20:45:42 indented too much
David Trainor- moved to gerrit 2015/01/21 23:13:24 Done.
48 delete web_contents; 48 if (!web_contents)
49 return NULL;
50 return web_contents->GetJavaWebContents().Release();
51 }
52
53 static jlong GetNativeWebContentsPtr(
54 JNIEnv* env, jclass clazz, jobject jweb_contents) {
55 return reinterpret_cast<intptr_t>(
56 content::WebContents::FromJavaWebContents(jweb_contents));
49 } 57 }
50 58
51 bool RegisterContentViewUtil(JNIEnv* env) { 59 bool RegisterContentViewUtil(JNIEnv* env) {
52 return RegisterNativesImpl(env); 60 return RegisterNativesImpl(env);
53 } 61 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698