Commit 932d6172 authored by Jonathan Almeida [:jonalmeida]'s avatar Jonathan Almeida [:jonalmeida]
Browse files

Bug 1644595 - Support requiring user interaction for session navigation. r=geckoview-reviewers,calu

parent 222f4654
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -837,7 +837,9 @@ package org.mozilla.geckoview {
    method @AnyThread @NonNull public GeckoResult<String> getUserAgent();
    method @NonNull @UiThread public WebExtension.SessionController getWebExtensionController();
    method @AnyThread public void goBack();
    method @AnyThread public void goBack(boolean);
    method @AnyThread public void goForward();
    method @AnyThread public void goForward(boolean);
    method @AnyThread public void gotoHistoryIndex(int);
    method @AnyThread public boolean isOpen();
    method @AnyThread public void load(@NonNull GeckoSession.Loader);
+36 −4
Original line number Diff line number Diff line
@@ -1872,16 +1872,48 @@ public class GeckoSession {
    mEventDispatcher.dispatch("GeckoView:Stop", null);
  }

  /** Go back in history. */
  /**
   * Go back in history and assumes the call was based on a user interaction.
   *
   * @see #goBack(boolean)
   */
  @AnyThread
  public void goBack() {
    mEventDispatcher.dispatch("GeckoView:GoBack", null);
    goBack(true);
  }

  /**
   * Go back in history.
   *
   * @param userInteraction Whether the action was invoked by a user interaction.
   */
  @AnyThread
  public void goBack(final boolean userInteraction) {
    final GeckoBundle msg = new GeckoBundle(1);
    msg.putBoolean("userInteraction", userInteraction);
    mEventDispatcher.dispatch("GeckoView:GoBack", msg);
  }

  /** Go forward in history. */
  /**
   * Go forward in history and assumes the call was based on a user interaction.
   *
   * @see #goForward(boolean)
   */
  @AnyThread
  public void goForward() {
    mEventDispatcher.dispatch("GeckoView:GoForward", null);
    goForward(true);
  }

  /**
   * Go forward in history.
   *
   * @param userInteraction Whether the action was invoked by a user interaction.
   */
  @AnyThread
  public void goForward(final boolean userInteraction) {
    final GeckoBundle msg = new GeckoBundle(1);
    msg.putBoolean("userInteraction", userInteraction);
    mEventDispatcher.dispatch("GeckoView:GoForward", msg);
  }

  /**
+7 −4
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ exclude: true
  type of process a crash occured in.
- ⚠️ Deprecated [`EXTRA_CRASH_FATAL`][97.5]. Use `EXTRA_CRASH_PROCESS_TYPE` instead.
- Added [`OrientationController`][97.6] to allow GeckoView to handle orientation locking.
- Added [GeckoSession.goBack][97.7] and [GeckoSession.goForward][97.8] with a `userInteraction` parameter. Updated the default goBack/goForward behaviour to also be considered as a user interaction.

[97.1]: {{javadoc_uri}}/GeckoSession.PermissionDelegate.MediaSource.html#rawId
[97.2]: {{javadoc_uri}}/GeckoSession.PermissionDelegate.MediaSource.html#id
@@ -28,6 +29,8 @@ exclude: true
[97.4]: {{javadoc_uri}}/GeckoRuntime.html#CRASHED_PROCESS_TYPE_MAIN
[97.5]: {{javadoc_uri}}/GeckoRuntime.html#EXTRA_CRASH_FATAL
[97.6]: {{javadoc_uri}}/OrientationController.html
[97.7]: {{javadoc_uri}}/GeckoSession.html#goBack-boolean-
[97.8]: {{javadoc_uri}}/GeckoSession.html#goForward-boolean-

## v96
- Added [`onLoginFetch`][96.1] which allows apps to provide all saved logins to
@@ -1107,4 +1110,4 @@ to allow adding gecko profiler markers.
[65.24]: {{javadoc_uri}}/CrashReporter.html#sendCrashReport-android.content.Context-android.os.Bundle-java.lang.String-
[65.25]: {{javadoc_uri}}/GeckoResult.html

[api-version]: f109d55f4da6ba24b94fa8cb8f42fe7e68d11426
[api-version]: ae48110979be68338211be23a6839b1064a51deb
+2 −2
Original line number Diff line number Diff line
@@ -160,10 +160,10 @@ class GeckoViewNavigation extends GeckoViewModule {

    switch (aEvent) {
      case "GeckoView:GoBack":
        this.browser.goBack();
        this.browser.goBack(aData.userInteraction);
        break;
      case "GeckoView:GoForward":
        this.browser.goForward();
        this.browser.goForward(aData.userInteraction);
        break;
      case "GeckoView:GotoHistoryIndex":
        this.browser.gotoIndex(aData.index);