Determine wheter a navigation entry is in-page
authorCheng Zhao <zcbenz@gmail.com>
Mon, 11 May 2015 05:51:52 +0000 (13:51 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Mon, 11 May 2015 05:51:52 +0000 (13:51 +0800)
atom/browser/api/atom_api_web_contents.cc
atom/browser/api/lib/navigation-controller.coffee

index c998dec..2fedd10 100644 (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) {
index 75f9dd2..28404b1 100644 (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