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

Unified Diff: chrome/browser/android/tab_android.cc

Issue 363563005: Adding jobject null check before calling CalledByNative JNI functions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « AUTHORS ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/android/tab_android.cc
diff --git a/chrome/browser/android/tab_android.cc b/chrome/browser/android/tab_android.cc
index baa0a000cb2aeef6856c7b08386b17534184d8da..076434444697a51418c59383d2d279837aa3cf43 100644
--- a/chrome/browser/android/tab_android.cc
+++ b/chrome/browser/android/tab_android.cc
@@ -208,20 +208,23 @@ void TabAndroid::SwapTabContents(content::WebContents* old_contents,
bool did_start_load,
bool did_finish_load) {
JNIEnv* env = base::android::AttachCurrentThread();
+ ScopedJavaLocalRef<jobject> obj = weak_java_tab_.get(env);
+ if (obj.is_null())
+ return;
// We need to notify the native InfobarContainer so infobars can be swapped.
InfoBarContainerAndroid* infobar_container =
reinterpret_cast<InfoBarContainerAndroid*>(
Java_Tab_getNativeInfoBarContainer(
env,
- weak_java_tab_.get(env).obj()));
+ obj.obj()));
InfoBarService* new_infobar_service =
new_contents ? InfoBarService::FromWebContents(new_contents) : NULL;
infobar_container->ChangeInfoBarManager(new_infobar_service);
Java_Tab_swapWebContents(
env,
- weak_java_tab_.get(env).obj(),
+ obj.obj(),
reinterpret_cast<intptr_t>(new_contents),
did_start_load,
did_finish_load);
@@ -231,6 +234,10 @@ void TabAndroid::Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
JNIEnv* env = base::android::AttachCurrentThread();
+ ScopedJavaLocalRef<jobject> obj = weak_java_tab_.get(env);
Yaron 2014/07/02 17:36:16 I'm wondering about this one. Even if we don't hav
Abhishek 2014/07/02 19:44:56 I think if java tab is gone, then there is no mean
Yaron 2014/07/02 20:25:39 Agreed. I was referring to NOTIFICATION_WEB_CONTEN
Abhishek 2014/07/03 05:10:42 Done.
+ if (obj.is_null())
+ return;
+
switch (type) {
case chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED: {
TabSpecificContentSettings* settings =
@@ -253,10 +260,10 @@ void TabAndroid::Observe(int type,
break;
}
case chrome::NOTIFICATION_FAVICON_UPDATED:
- Java_Tab_onFaviconUpdated(env, weak_java_tab_.get(env).obj());
+ Java_Tab_onFaviconUpdated(env, obj.obj());
break;
case content::NOTIFICATION_NAV_ENTRY_CHANGED:
- Java_Tab_onNavEntryChanged(env, weak_java_tab_.get(env).obj());
+ Java_Tab_onNavEntryChanged(env, obj.obj());
break;
default:
NOTREACHED() << "Unexpected notification " << type;
« no previous file with comments | « AUTHORS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698