Determine wheter a navigation entry is in-page

This commit is contained in:
Cheng Zhao 2015-05-11 13:51:52 +08:00
parent 4a195e6283
commit fc2bc20572
2 changed files with 16 additions and 10 deletions

View file

@ -348,8 +348,9 @@ void WebContents::WebContentsDestroyed() {
}
void WebContents::NavigationEntryCommitted(
const content::LoadCommittedDetails& load_details) {
Emit("navigation-entry-commited", load_details.entry->GetURL());
const content::LoadCommittedDetails& details) {
Emit("navigation-entry-commited", details.entry->GetURL(),
details.is_in_page, details.did_replace_entry);
}
void WebContents::DidAttach(int guest_proxy_routing_id) {

View file

@ -9,16 +9,21 @@ class NavigationController
@currentIndex = -1
@pendingIndex = -1
@webContents.on 'navigation-entry-commited', (event, url) =>
@webContents.on 'navigation-entry-commited', (event, url, inPage, replaceEntry) =>
if replaceEntry
@history[@currentIndex] = {url, inPage}
return
if @pendingIndex is -1 # Normal navigation.
@history = @history.slice 0, @currentIndex + 1 # Clear history.
if @history[@currentIndex] isnt url
currentEntry = @history[@currentIndex]
if currentEntry?.url isnt url or currentEntry?.inPage isnt inPage
@currentIndex++
@history.push url
@history.push {url, inPage}
else # Go to index.
@currentIndex = @pendingIndex
@pendingIndex = -1
@history[@currentIndex] = url
@history[@currentIndex] = {url, inPage}
loadUrl: (url, options={}) ->
@pendingIndex = -1
@ -28,7 +33,7 @@ class NavigationController
if @currentIndex is -1
''
else
@history[@currentIndex]
@history[@currentIndex].url
stop: ->
@pendingIndex = -1
@ -57,17 +62,17 @@ class NavigationController
goBack: ->
return unless @canGoBack()
@pendingIndex = @getActiveIndex() - 1
@webContents._loadUrl @history[@pendingIndex], {}
@webContents._loadUrl @history[@pendingIndex].url, {}
goForward: ->
return unless @canGoForward()
@pendingIndex = @getActiveIndex() + 1
@webContents._loadUrl @history[@pendingIndex], {}
@webContents._loadUrl @history[@pendingIndex].url, {}
goToIndex: (index) ->
return unless @canGoToIndex index
@pendingIndex = index
@webContents._loadUrl @history[@pendingIndex], {}
@webContents._loadUrl @history[@pendingIndex].url, {}
goToOffset: (offset) ->
return unless @canGoToOffset offset