     return unless @canGoToOffset offset
     @goToIndex @currentIndex + offset
 
+  getActiveIndex: ->
+    if @pendingIndex is -1 then @currentIndex else @pendingIndex
+
 module.exports = NavigationController

    @reload()

  canGoBack: ->
    @currentIndex > 0

  canGoForward: ->
    @currentIndex < @history.length

  canGoToIndex: (index) ->
    index >=0 and index < @history.length

    @pendingIndex = -1

    @webContents.on 'navigation-entry-commited', (event, url) =>
      if @pendingIndex is -1  # Normal navigation.
        @history = @history.slice 0, @currentIndex + 1  # Clear history.
        if @history[@currentIndex] isnt url
          @currentIndex++
          @history.push url
      else  # Go to index.
        @currentIndex = @pendingIndex
        @pendingIndex = -1
        @history[@currentIndex] = url

  loadUrl: (url, options={}) ->
    @pendingIndex = -1
