Chromium Code Reviews| Index: content/browser/frame_host/navigation_controller_android.cc |
| diff --git a/content/browser/frame_host/navigation_controller_android.cc b/content/browser/frame_host/navigation_controller_android.cc |
| index 4f3f45a684f393ae7777c948f04b77d3378ed0bc..adec9269ccb8cf7c15e8bf57ce3d0e01cfe05b04 100644 |
| --- a/content/browser/frame_host/navigation_controller_android.cc |
| +++ b/content/browser/frame_host/navigation_controller_android.cc |
| @@ -22,11 +22,14 @@ using base::android::ConvertUTF8ToJavaString; |
| namespace { |
| // static |
| -static void AddNavigationEntryToHistory(JNIEnv* env, |
| - jobject obj, |
| - jobject history, |
| - content::NavigationEntry* entry, |
| - int index) { |
| +static base::android::ScopedJavaLocalRef<jobject> CreateJavaNavigationEntry( |
| + JNIEnv* env, |
| + jobject obj, |
| + content::NavigationEntry* entry, |
| + int index) { |
| + if (!entry) |
|
Ted C
2014/09/18 20:29:06
I don't think we should support NULL entries. Tha
David Trainor- moved to gerrit
2014/09/18 21:06:24
Done.
|
| + return base::android::ScopedJavaLocalRef<jobject>(); |
| + |
| // Get the details of the current entry |
| ScopedJavaLocalRef<jstring> j_url( |
| ConvertUTF8ToJavaString(env, entry->GetURL().spec())); |
| @@ -41,11 +44,9 @@ static void AddNavigationEntryToHistory(JNIEnv* env, |
| if (status.valid && status.image.ToSkBitmap()->getSize() > 0) |
| j_bitmap = gfx::ConvertToJavaBitmap(status.image.ToSkBitmap()); |
| - // Add the item to the list |
| - content::Java_NavigationControllerImpl_addToNavigationHistory( |
| + return content::Java_NavigationControllerImpl_createNavigationEntry( |
| env, |
| obj, |
|
Ted C
2014/09/18 20:29:06
wha? Why is this method not static? Why was it n
David Trainor- moved to gerrit
2014/09/18 21:06:24
hah good question!
|
| - history, |
| index, |
| j_url.obj(), |
| j_virtual_url.obj(), |
| @@ -54,6 +55,23 @@ static void AddNavigationEntryToHistory(JNIEnv* env, |
| j_bitmap.obj()); |
| } |
| +static void AddNavigationEntryToHistory(JNIEnv* env, |
| + jobject obj, |
| + jobject history, |
| + content::NavigationEntry* entry, |
| + int index) { |
| + base::android::ScopedJavaLocalRef<jobject> j_entry = |
| + CreateJavaNavigationEntry(env, obj, entry, index); |
| + if (j_entry.is_null()) |
|
Ted C
2014/09/18 20:29:06
would be able to remove this check here based on a
David Trainor- moved to gerrit
2014/09/18 21:06:24
Done.
|
| + return; |
| + |
| + content::Java_NavigationControllerImpl_addToNavigationHistory( |
| + env, |
| + obj, |
| + history, |
| + j_entry.obj()); |
| +} |
| + |
| } // namespace |
| namespace content { |
| @@ -292,4 +310,13 @@ void NavigationControllerAndroid::SetUseDesktopUserAgent( |
| } |
| } |
| +base::android::ScopedJavaLocalRef<jobject> |
| +NavigationControllerAndroid::GetPendingEntry(JNIEnv* env, jobject obj) { |
| + return CreateJavaNavigationEntry( |
| + env, |
| + obj, |
| + navigation_controller_->GetPendingEntry(), |
| + navigation_controller_->GetPendingEntryIndex()); |
| +} |
| + |
| } // namespace content |