void WebHistory::AddItem(const AutoJObject& list, WebCore::HistoryItem* item) { LOG_ASSERT(item, "newItem must take a valid HistoryItem!"); // Item already added. Should only happen when we are inflating the list. if (item->bridge() || !list.get()) return; JNIEnv* env = list.env(); // Allocate a blank WebHistoryItem jclass clazz = env->FindClass("android/webkit/WebHistoryItem"); jobject newItem = env->NewObject(clazz, gWebHistoryItem.mInit); // Create the bridge, make it active, and attach it to the item. WebHistoryItem* bridge = new WebHistoryItem(env, newItem, item); bridge->setActive(); item->setBridge(bridge); // Update the history item which will flatten the data and call update on // the java item. bridge->updateHistoryItem(item); // Add it to the list. env->CallVoidMethod(list.get(), gWebBackForwardList.mAddHistoryItem, newItem); // Delete our local reference. env->DeleteLocalRef(newItem); }
void WebHistory::UpdateHistoryIndex(const AutoJObject& list, int newIndex) { if (list.get()) list.env()->CallVoidMethod(list.get(), gWebBackForwardList.mSetCurrentIndex, newIndex); }
void WebHistory::RemoveItem(const AutoJObject& list, int index) { if (list.get()) list.env()->CallVoidMethod(list.get(), gWebBackForwardList.mRemoveHistoryItem, index); }