From 5cbbc8e26ee6f9231b319229eaf75d5e008d5e64 Mon Sep 17 00:00:00 2001
From: ipaterson <ipaterson@newstex.com>
Date: Wed, 1 Jul 2015 14:10:18 -0400
Subject: [PATCH] CB-9274 Adds missing methods to InAppBrowser to allow
 compilation for Amazon FireOS.

 This closes #107
---
 src/amazon/InAppBrowser.java | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/src/amazon/InAppBrowser.java b/src/amazon/InAppBrowser.java
index 5c53488..c5d6f66 100644
--- a/src/amazon/InAppBrowser.java
+++ b/src/amazon/InAppBrowser.java
@@ -84,6 +84,7 @@ public class InAppBrowser extends CordovaPlugin {
     private static final String LOAD_ERROR_EVENT = "loaderror";
     private static final String CLEAR_ALL_CACHE = "clearcache";
     private static final String CLEAR_SESSION_CACHE = "clearsessioncache";
+    private static final String HARDWARE_BACK_BUTTON = "hardwareback";
 
     private InAppBrowserDialog dialog;
     private AmazonWebView inAppWebView;
@@ -94,6 +95,7 @@ public class InAppBrowser extends CordovaPlugin {
     private boolean openWindowHidden = false;
     private boolean clearAllCache= false;
     private boolean clearSessionCache=false;
+    private boolean hadwareBackButton=true;
 
     /**
      * Executes the request and returns PluginResult.
@@ -378,7 +380,7 @@ public class InAppBrowser extends CordovaPlugin {
     /**
      * Checks to see if it is possible to go back one page in history, then does so.
      */
-    private void goBack() {
+    public void goBack() {
         this.cordova.getActivity().runOnUiThread(new Runnable() {
             public void run() {
                 if (InAppBrowser.this.inAppWebView.canGoBack()) {
@@ -388,6 +390,22 @@ public class InAppBrowser extends CordovaPlugin {
         });
     }
 
+    /**
+     * Can the web browser go back?
+     * @return boolean
+     */
+    public boolean canGoBack() {
+        return this.inAppWebView.canGoBack();
+    }
+
+    /**
+     * Has the user set the hardware back button to go back
+     * @return boolean
+     */
+    public boolean hardwareBack() {
+        return hadwareBackButton;
+    } 
+
     /**
      * Checks to see if it is possible to go forward one page in history, then does so.
      */
@@ -469,6 +487,10 @@ public class InAppBrowser extends CordovaPlugin {
             if (hidden != null) {
                 openWindowHidden = hidden.booleanValue();
             }
+            Boolean hardwareBack = features.get(HARDWARE_BACK_BUTTON);
+            if (hardwareBack != null) {
+                hadwareBackButton = hardwareBack.booleanValue();
+            }
             Boolean cache = features.get(CLEAR_ALL_CACHE);
             if (cache != null) {
                 clearAllCache = cache.booleanValue();