static bool tryAccessHistoryURLs(Page* page, KURL& previousURL, KURL& currentURL) { if (!page) return false; Frame* frame = page->mainFrame(); if (!frame || !frame->document()) return false; BackForwardList* list = page->backForwardList(); if (!list) return false; HistoryItem* previousItem = list->backItem(); if (!previousItem) return false; HistoryItem* currentItem = list->currentItem(); if (!currentItem) return false; previousURL = urlForHistoryItem(frame, previousItem); currentURL = urlForHistoryItem(frame, currentItem); return true; }
JNIEXPORT void JNICALL Java_com_sun_webkit_BackForwardList_bflSetHostObject(JNIEnv* env, jclass z, jlong jpage, jobject host) { BackForwardList* bfl = getBfl(jpage); bfl->setHostObject(JLObject(host, true)); notifyHistoryItemChanged = notifyHistoryItemChangedImpl; }
// BackForwardList.setCurrentIndex() JNIEXPORT jint JNICALL Java_com_sun_webkit_BackForwardList_bflSetCurrentIndex(JNIEnv* env, jclass z, jlong jpage, jint index) { Page* page = getPage(jpage); BackForwardList* bfl = page->backForwardList(); if (index < 0 || index >= getSize(bfl)) return -1; int distance = index - bfl->backListCount(); page->goBackOrForward(distance); return index; }
void WMLDocument::finishedParsing() { if (Tokenizer* tokenizer = this->tokenizer()) { if (!tokenizer->wellFormed()) { Document::finishedParsing(); return; } } bool hasAccess = initialize(true); Document::finishedParsing(); if (!hasAccess) { m_activeCard = 0; WMLPageState* wmlPageState = wmlPageStateForDocument(this); if (!wmlPageState) return; Page* page = wmlPageState->page(); if (!page) return; BackForwardList* list = page->backForwardList(); if (!list) return; HistoryItem* item = list->backItem(); if (!item) return; page->goToItem(item, FrameLoadTypeBackWMLDeckNotAccessible); return; } if (m_activeCard) { m_activeCard->handleIntrinsicEventIfNeeded(); m_activeCard = 0; } }
// Main funnel for navigating to a previous location (back/forward, non-search snap-back) // This includes recursion to handle loading into framesets properly void HistoryController::goToItem(HistoryItem* targetItem, FrameLoadType type) { ASSERT(!m_frame->tree()->parent()); // shouldGoToHistoryItem is a private delegate method. This is needed to fix: // <rdar://problem/3951283> can view pages from the back/forward cache that should be disallowed by Parental Controls // Ultimately, history item navigations should go through the policy delegate. That's covered in: // <rdar://problem/3979539> back/forward cache navigations should consult policy delegate Page* page = m_frame->page(); if (!page) return; if (!m_frame->loader()->client()->shouldGoToHistoryItem(targetItem)) return; // Set the BF cursor before commit, which lets the user quickly click back/forward again. // - plus, it only makes sense for the top level of the operation through the frametree, // as opposed to happening for some/one of the page commits that might happen soon BackForwardList* bfList = page->backForwardList(); HistoryItem* currentItem = bfList->currentItem(); bfList->goToItem(targetItem); Settings* settings = m_frame->settings(); page->setGlobalHistoryItem((!settings || settings->privateBrowsingEnabled()) ? 0 : targetItem); recursiveGoToItem(targetItem, currentItem, type); }
void FrameLoaderClientAndroid::dispatchDidChangeBackForwardIndex() const { ASSERT(m_frame); BackForwardList* list = m_frame->page()->backForwardList(); ASSERT(list); m_webFrame->updateHistoryIndex(list->backListCount()); }
// BackForwardList.getCurrentIndex() JNIEXPORT jint JNICALL Java_com_sun_webkit_BackForwardList_bflGetCurrentIndex(JNIEnv* env, jclass z, jlong jpage) { BackForwardList* bfl = getBfl(jpage); return bfl->currentItem() ? bfl->backListCount() : -1; }