You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by GitBox <gi...@apache.org> on 2018/02/14 10:09:59 UTC

[GitHub] denisx304 closed pull request #238: added cookies support for Android and iOS

denisx304 closed pull request #238: added cookies support for Android and iOS
URL: https://github.com/apache/cordova-plugin-inappbrowser/pull/238
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/src/android/InAppBrowser.java b/src/android/InAppBrowser.java
index fefbcece..b12125c4 100644
--- a/src/android/InAppBrowser.java
+++ b/src/android/InAppBrowser.java
@@ -21,6 +21,7 @@ Licensed to the Apache Software Foundation (ASF) under one
 import android.annotation.SuppressLint;
 import android.content.Context;
 import android.content.Intent;
+import android.graphics.Color;
 import android.provider.Browser;
 import android.content.res.Resources;
 import android.graphics.Bitmap;
@@ -51,6 +52,7 @@ Licensed to the Apache Software Foundation (ASF) under one
 import android.widget.ImageView;
 import android.widget.LinearLayout;
 import android.widget.RelativeLayout;
+import android.widget.TextView;
 
 import org.apache.cordova.CallbackContext;
 import org.apache.cordova.Config;
@@ -67,7 +69,10 @@ Licensed to the Apache Software Foundation (ASF) under one
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
+import java.net.MalformedURLException;
+import java.net.URL;
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.StringTokenizer;
 
 @SuppressLint("SetJavaScriptEnabled")
@@ -95,6 +100,7 @@ Licensed to the Apache Software Foundation (ASF) under one
     private InAppBrowserDialog dialog;
     private WebView inAppWebView;
     private EditText edittext;
+    private TextView titleLabel;
     private CallbackContext callbackContext;
     private boolean showLocationBar = true;
     private boolean showZoomControls = true;
@@ -122,12 +128,30 @@ public boolean execute(String action, CordovaArgs args, final CallbackContext ca
         if (action.equals("open")) {
             this.callbackContext = callbackContext;
             final String url = args.getString(0);
+            String domain = url;
+            try {
+                domain = new URL(url).getProtocol() + "://" + new URL(url).getHost();
+            } catch (MalformedURLException e) {
+                LOG.d(LOG_TAG, e.getLocalizedMessage());
+            }
             String t = args.optString(1);
             if (t == null || t.equals("") || t.equals(NULL)) {
                 t = SELF;
             }
             final String target = t;
             final HashMap<String, Boolean> features = parseFeature(args.optString(2));
+            final JSONObject cookies = args.getJSONObject(3);
+
+            if (null != cookies) {
+                Iterator<?> cookiesNames = cookies.keys();
+                while (cookiesNames.hasNext()) {
+                    String key = (String)cookiesNames.next();
+                    CookieManager.getInstance().setCookie(domain, key + "=" + cookies.get(key));
+                    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
+                        CookieSyncManager.getInstance().sync();
+                    }
+                }
+            }
 
             LOG.d(LOG_TAG, "target = " + target);
 
@@ -612,14 +636,16 @@ public void run() {
                 // Toolbar layout
                 RelativeLayout toolbar = new RelativeLayout(cordova.getActivity());
                 //Please, no more black!
-                toolbar.setBackgroundColor(android.graphics.Color.LTGRAY);
+                toolbar.setBackgroundColor(Color.parseColor("#ff9415"));
                 toolbar.setLayoutParams(new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, this.dpToPixels(44)));
                 toolbar.setPadding(this.dpToPixels(2), this.dpToPixels(2), this.dpToPixels(2), this.dpToPixels(2));
                 toolbar.setHorizontalGravity(Gravity.LEFT);
                 toolbar.setVerticalGravity(Gravity.TOP);
 
+
+
                 // Action Button Container layout
-                RelativeLayout actionButtonContainer = new RelativeLayout(cordova.getActivity());
+                /*RelativeLayout actionButtonContainer = new RelativeLayout(cordova.getActivity());
                 actionButtonContainer.setLayoutParams(new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
                 actionButtonContainer.setHorizontalGravity(Gravity.LEFT);
                 actionButtonContainer.setVerticalGravity(Gravity.CENTER_VERTICAL);
@@ -632,7 +658,6 @@ public void run() {
                 back.setLayoutParams(backLayoutParams);
                 back.setContentDescription("Back Button");
                 back.setId(Integer.valueOf(2));
-                Resources activityRes = cordova.getActivity().getResources();
                 int backResId = activityRes.getIdentifier("ic_action_previous_item", "drawable", cordova.getActivity().getPackageName());
                 Drawable backIcon = activityRes.getDrawable(backResId);
                 if (Build.VERSION.SDK_INT >= 16)
@@ -674,39 +699,20 @@ public void onClick(View v) {
                     public void onClick(View v) {
                         goForward();
                     }
-                });
+                });*/
 
                 // Edit Text Box
                 edittext = new EditText(cordova.getActivity());
-                RelativeLayout.LayoutParams textLayoutParams = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
-                textLayoutParams.addRule(RelativeLayout.RIGHT_OF, 1);
-                textLayoutParams.addRule(RelativeLayout.LEFT_OF, 5);
-                edittext.setLayoutParams(textLayoutParams);
-                edittext.setId(Integer.valueOf(4));
-                edittext.setSingleLine(true);
-                edittext.setText(url);
-                edittext.setInputType(InputType.TYPE_TEXT_VARIATION_URI);
-                edittext.setImeOptions(EditorInfo.IME_ACTION_GO);
-                edittext.setInputType(InputType.TYPE_NULL); // Will not except input... Makes the text NON-EDITABLE
-                edittext.setOnKeyListener(new View.OnKeyListener() {
-                    public boolean onKey(View v, int keyCode, KeyEvent event) {
-                        // If the event is a key-down event on the "enter" button
-                        if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) {
-                          navigate(edittext.getText().toString());
-                          return true;
-                        }
-                        return false;
-                    }
-                });
 
+                Resources activityRes = cordova.getActivity().getResources();
                 // Close/Done button
                 ImageButton close = new ImageButton(cordova.getActivity());
                 RelativeLayout.LayoutParams closeLayoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
-                closeLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
+                closeLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
                 close.setLayoutParams(closeLayoutParams);
                 close.setContentDescription("Close Button");
-                close.setId(Integer.valueOf(5));
-                int closeResId = activityRes.getIdentifier("ic_action_remove", "drawable", cordova.getActivity().getPackageName());
+                close.setId(Integer.valueOf(1));
+                int closeResId = activityRes.getIdentifier("back", "drawable", cordova.getActivity().getPackageName());
                 Drawable closeIcon = activityRes.getDrawable(closeResId);
                 if (Build.VERSION.SDK_INT >= 16)
                     close.setBackground(null);
@@ -714,7 +720,7 @@ public boolean onKey(View v, int keyCode, KeyEvent event) {
                     close.setBackgroundDrawable(null);
                 close.setImageDrawable(closeIcon);
                 close.setScaleType(ImageView.ScaleType.FIT_CENTER);
-                back.setPadding(0, this.dpToPixels(10), 0, this.dpToPixels(10));
+                //back.setPadding(0, this.dpToPixels(10), 0, this.dpToPixels(10));
                 if (Build.VERSION.SDK_INT >= 16)
                     close.getAdjustViewBounds();
 
@@ -724,10 +730,20 @@ public void onClick(View v) {
                     }
                 });
 
+                titleLabel = new TextView(cordova.getActivity());
+                titleLabel.setId(Integer.valueOf(2));
+                titleLabel.setGravity(Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL);
+                RelativeLayout.LayoutParams titleLayoutParams = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
+                titleLayoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
+                titleLabel.setLayoutParams(titleLayoutParams);
+                titleLabel.setTextSize(TypedValue.COMPLEX_UNIT_DIP, (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10, activityRes.getDisplayMetrics()));
+                titleLabel.setTextColor(Color.WHITE);
+                titleLabel.setText("");
+
                 // WebView
                 inAppWebView = new WebView(cordova.getActivity());
                 inAppWebView.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
-                inAppWebView.setId(Integer.valueOf(6));
+                inAppWebView.setId(Integer.valueOf(3));
                 // File Chooser Implemented ChromeClient
                 inAppWebView.setWebChromeClient(new InAppChromeClient(thatWebView) {
                     // For Android 5.0+
@@ -771,7 +787,7 @@ public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType)
                     }
 
                 });
-                WebViewClient client = new InAppBrowserClient(thatWebView, edittext);
+                WebViewClient client = new InAppBrowserClient(thatWebView, titleLabel);
                 inAppWebView.setWebViewClient(client);
                 WebSettings settings = inAppWebView.getSettings();
                 settings.setJavaScriptEnabled(true);
@@ -810,20 +826,21 @@ public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType)
                 }
 
                 inAppWebView.loadUrl(url);
-                inAppWebView.setId(Integer.valueOf(6));
+                inAppWebView.setId(Integer.valueOf(3));
                 inAppWebView.getSettings().setLoadWithOverviewMode(true);
                 inAppWebView.getSettings().setUseWideViewPort(useWideViewPort);
                 inAppWebView.requestFocus();
                 inAppWebView.requestFocusFromTouch();
 
                 // Add the back and forward buttons to our action button container layout
-                actionButtonContainer.addView(back);
-                actionButtonContainer.addView(forward);
+                //actionButtonContainer.addView(back);
+                //actionButtonContainer.addView(forward);
 
                 // Add the views to our toolbar
-                toolbar.addView(actionButtonContainer);
-                toolbar.addView(edittext);
+                //toolbar.addView(actionButtonContainer);
+                //toolbar.addView(edittext);
                 toolbar.addView(close);
+                toolbar.addView(titleLabel);
 
                 // Don't add the toolbar if its been disabled
                 if (getShowLocationBar()) {
@@ -919,18 +936,18 @@ public void onActivityResult(int requestCode, int resultCode, Intent intent) {
      * The webview client receives notifications about appView
      */
     public class InAppBrowserClient extends WebViewClient {
-        EditText edittext;
+        TextView titleLabel;
         CordovaWebView webView;
 
         /**
          * Constructor.
          *
          * @param webView
-         * @param mEditText
+         * @param titleLabel
          */
-        public InAppBrowserClient(CordovaWebView webView, EditText mEditText) {
+        public InAppBrowserClient(CordovaWebView webView, TextView titleLabel) {
             this.webView = webView;
-            this.edittext = mEditText;
+            this.titleLabel = titleLabel;
         }
 
         /**
@@ -1046,6 +1063,8 @@ public void onPageFinished(WebView view, String url) {
                 CookieSyncManager.getInstance().sync();
             }
 
+            this.titleLabel.setText(view.getTitle());
+
             // https://issues.apache.org/jira/browse/CB-11248
             view.clearFocus();
             view.requestFocus();
diff --git a/src/ios/CDVInAppBrowser.h b/src/ios/CDVInAppBrowser.h
index d258eb09..4f1d7e1a 100644
--- a/src/ios/CDVInAppBrowser.h
+++ b/src/ios/CDVInAppBrowser.h
@@ -86,6 +86,7 @@
 @property (nonatomic, strong) IBOutlet UIWebView* webView;
 @property (nonatomic, strong) IBOutlet UIBarButtonItem* closeButton;
 @property (nonatomic, strong) IBOutlet UILabel* addressLabel;
+@property (nonatomic, strong) IBOutlet UILabel* titleLabel;
 @property (nonatomic, strong) IBOutlet UIBarButtonItem* backButton;
 @property (nonatomic, strong) IBOutlet UIBarButtonItem* forwardButton;
 @property (nonatomic, strong) IBOutlet UIActivityIndicatorView* spinner;
diff --git a/src/ios/CDVInAppBrowser.m b/src/ios/CDVInAppBrowser.m
index f5d05f01..941afaed 100644
--- a/src/ios/CDVInAppBrowser.m
+++ b/src/ios/CDVInAppBrowser.m
@@ -84,6 +84,7 @@ - (void)open:(CDVInvokedUrlCommand*)command
     NSString* url = [command argumentAtIndex:0];
     NSString* target = [command argumentAtIndex:1 withDefault:kInAppBrowserTargetSelf];
     NSString* options = [command argumentAtIndex:2 withDefault:@"" andClass:[NSString class]];
+    NSDictionary* cookies = [command argumentAtIndex:3];
 
     self.callbackId = command.callbackId;
 
@@ -100,11 +101,11 @@ - (void)open:(CDVInvokedUrlCommand*)command
         }
 
         if ([target isEqualToString:kInAppBrowserTargetSelf]) {
-            [self openInCordovaWebView:absoluteUrl withOptions:options];
+            [self openInCordovaWebView:absoluteUrl withOptions:options withCookies:cookies];
         } else if ([target isEqualToString:kInAppBrowserTargetSystem]) {
             [self openInSystem:absoluteUrl];
         } else { // _blank or anything else
-            [self openInInAppBrowser:absoluteUrl withOptions:options];
+            [self openInInAppBrowser:absoluteUrl withOptions:options withCookies:cookies];
         }
 
         pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
@@ -116,7 +117,7 @@ - (void)open:(CDVInvokedUrlCommand*)command
     [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
 }
 
-- (void)openInInAppBrowser:(NSURL*)url withOptions:(NSString*)options
+- (void)openInInAppBrowser:(NSURL*)url withOptions:(NSString*)options withCookies:(NSDictionary*)cookies
 {
     CDVInAppBrowserOptions* browserOptions = [CDVInAppBrowserOptions parseOptions:options];
 
@@ -141,6 +142,22 @@ - (void)openInInAppBrowser:(NSURL*)url withOptions:(NSString*)options
             }
         }
     }
+    
+    if (cookies != nil) {
+        for (id key in cookies) {
+            //key = [cookies objectForKey:key];
+            NSDictionary *cookieProperties = [NSDictionary dictionaryWithObjectsAndKeys:
+                                        url.host, NSHTTPCookieDomain,
+										@"/", NSHTTPCookiePath,
+                                        key, NSHTTPCookieName,
+                                        [cookies objectForKey:key], NSHTTPCookieValue,
+                                        nil];
+            NSHTTPCookie *cookie = [NSHTTPCookie cookieWithProperties:cookieProperties];
+            NSLog(@"\nurl: %@\ncookie: %@", url, cookie);
+            [[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookie:cookie];
+            
+        }
+    }
 
     if (self.inAppBrowserViewController == nil) {
         NSString* userAgent = [CDVUserAgentUtil originalUserAgent];
@@ -162,9 +179,6 @@ - (void)openInInAppBrowser:(NSURL*)url withOptions:(NSString*)options
 
     [self.inAppBrowserViewController showLocationBar:browserOptions.location];
     [self.inAppBrowserViewController showToolBar:browserOptions.toolbar :browserOptions.toolbarposition];
-    if (browserOptions.closebuttoncaption != nil) {
-        [self.inAppBrowserViewController setCloseButtonTitle:browserOptions.closebuttoncaption];
-    }
     // Set Presentation Style
     UIModalPresentationStyle presentationStyle = UIModalPresentationFullScreen; // default
     if (browserOptions.presentationstyle != nil) {
@@ -275,7 +289,7 @@ - (void)hide:(CDVInvokedUrlCommand*)command
     });
 }
 
-- (void)openInCordovaWebView:(NSURL*)url withOptions:(NSString*)options
+- (void)openInCordovaWebView:(NSURL*)url withOptions:(NSString*)options withCookies:(NSDictionary*)cookies
 {
     NSURLRequest* request = [NSURLRequest requestWithURL:url];
 
@@ -287,7 +301,7 @@ - (void)openInCordovaWebView:(NSURL*)url withOptions:(NSString*)options
     if ([self.commandDelegate URLIsWhitelisted:url]) {
         [self.webView loadRequest:request];
     } else { // this assumes the InAppBrowser can be excepted from the white-list
-        [self openInInAppBrowser:url withOptions:options];
+        [self openInInAppBrowser:url withOptions:options withCookies:cookies];
     }
 #endif
 }
@@ -543,6 +557,7 @@ - (void)createViews
     CGRect webViewBounds = self.view.bounds;
     BOOL toolbarIsAtBottom = ![_browserOptions.toolbarposition isEqualToString:kInAppBrowserToolbarBarPositionTop];
     webViewBounds.size.height -= _browserOptions.location ? FOOTER_HEIGHT : TOOLBAR_HEIGHT;
+    webViewBounds.origin.y = toolbarIsAtBottom ? 0 : TOOLBAR_HEIGHT;
     self.webView = [[UIWebView alloc] initWithFrame:webViewBounds];
 
     self.webView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
@@ -575,9 +590,14 @@ - (void)createViews
     self.spinner.opaque = NO;
     self.spinner.userInteractionEnabled = NO;
     [self.spinner stopAnimating];
-
-    self.closeButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(close)];
+	
+	UIButton *closeButtonView = [UIButton buttonWithType:UIButtonTypeCustom];
+	[closeButtonView setImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal];
+	closeButtonView.backgroundColor = [UIColor clearColor];
+	[closeButtonView addTarget:self action:@selector(close) forControlEvents:UIControlEventTouchUpInside];
+    self.closeButton = [[UIBarButtonItem alloc] initWithCustomView:closeButtonView];
     self.closeButton.enabled = YES;
+    self.closeButton.tintColor = [UIColor colorWithRed:60.0 / 255.0 green:136.0 / 255.0 blue:230.0 / 255.0 alpha:1];
 
     UIBarButtonItem* flexibleSpaceButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
 
@@ -591,7 +611,7 @@ - (void)createViews
     self.toolbar.alpha = 1.000;
     self.toolbar.autoresizesSubviews = YES;
     self.toolbar.autoresizingMask = toolbarIsAtBottom ? (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin) : UIViewAutoresizingFlexibleWidth;
-    self.toolbar.barStyle = UIBarStyleBlackOpaque;
+    self.toolbar.barTintColor = [UIColor colorWithRed:255.0f/255.0f green:148.0f/255.0f blue:21.0f/255.0f alpha:1.0f];
     self.toolbar.clearsContextBeforeDrawing = NO;
     self.toolbar.clipsToBounds = NO;
     self.toolbar.contentMode = UIViewContentModeScaleToFill;
@@ -631,18 +651,28 @@ - (void)createViews
     self.addressLabel.textAlignment = NSTextAlignmentLeft;
     self.addressLabel.textColor = [UIColor colorWithWhite:1.000 alpha:1.000];
     self.addressLabel.userInteractionEnabled = NO;
-
-    NSString* frontArrowString = NSLocalizedString(@"?", nil); // create arrow from Unicode char
+	
+	self.titleLabel = [[UILabel alloc] init];
+    [self.titleLabel setText:@"                    "];
+	[self.titleLabel setBackgroundColor:[UIColor clearColor]];
+	[self.titleLabel setTextColor:[UIColor whiteColor]];
+	[self.titleLabel setFont:[UIFont fontWithName:@"Helvetica Neue" size:18]];
+	[self.titleLabel setTextAlignment:NSTextAlignmentCenter];
+
+    /*NSString* frontArrowString = NSLocalizedString(@"?", nil); // create arrow from Unicode char
     self.forwardButton = [[UIBarButtonItem alloc] initWithTitle:frontArrowString style:UIBarButtonItemStylePlain target:self action:@selector(goForward:)];
     self.forwardButton.enabled = YES;
-    self.forwardButton.imageInsets = UIEdgeInsetsZero;
+    self.forwardButton.tintColor = UIColor.whiteColor;
+    self.forwardButton.imageInsets = UIEdgeInsetsZero;*/
 
-    NSString* backArrowString = NSLocalizedString(@"?", nil); // create arrow from Unicode char
+    /*NSString* backArrowString = NSLocalizedString(@"?", nil); // create arrow from Unicode char
     self.backButton = [[UIBarButtonItem alloc] initWithTitle:backArrowString style:UIBarButtonItemStylePlain target:self action:@selector(goBack:)];
     self.backButton.enabled = YES;
-    self.backButton.imageInsets = UIEdgeInsetsZero;
+	self.backButton.tintColor = UIColor.whiteColor;
+    self.backButton.imageInsets = UIEdgeInsetsZero;*/
 
-    [self.toolbar setItems:@[self.closeButton, flexibleSpaceButton, self.backButton, fixedSpaceButton, self.forwardButton]];
+    //[self.toolbar setItems:@[self.closeButton, flexibleSpaceButton, self.backButton, fixedSpaceButton, self.forwardButton]];
+    [self.toolbar setItems:@[self.closeButton, flexibleSpaceButton, [[UIBarButtonItem alloc] initWithCustomView:self.titleLabel], flexibleSpaceButton]];
 
     self.view.backgroundColor = [UIColor grayColor];
     [self.view addSubview:self.toolbar];
@@ -655,20 +685,6 @@ - (void) setWebViewFrame : (CGRect) frame {
     [self.webView setFrame:frame];
 }
 
-- (void)setCloseButtonTitle:(NSString*)title
-{
-    // the advantage of using UIBarButtonSystemItemDone is the system will localize it for you automatically
-    // but, if you want to set this yourself, knock yourself out (we can't set the title for a system Done button, so we have to create a new one)
-    self.closeButton = nil;
-    self.closeButton = [[UIBarButtonItem alloc] initWithTitle:title style:UIBarButtonItemStyleBordered target:self action:@selector(close)];
-    self.closeButton.enabled = YES;
-    self.closeButton.tintColor = [UIColor colorWithRed:60.0 / 255.0 green:136.0 / 255.0 blue:230.0 / 255.0 alpha:1];
-
-    NSMutableArray* items = [self.toolbar.items mutableCopy];
-    [items replaceObjectAtIndex:0 withObject:self.closeButton];
-    [self.toolbar setItems:items];
-}
-
 - (void)showLocationBar:(BOOL)show
 {
     CGRect locationbarFrame = self.addressLabel.frame;
@@ -884,8 +900,8 @@ - (void)webViewDidStartLoad:(UIWebView*)theWebView
     // loading url, start spinner, update back/forward
 
     self.addressLabel.text = NSLocalizedString(@"Loading...", nil);
-    self.backButton.enabled = theWebView.canGoBack;
-    self.forwardButton.enabled = theWebView.canGoForward;
+    //self.backButton.enabled = theWebView.canGoBack;
+    //self.forwardButton.enabled = theWebView.canGoForward;
 
     [self.spinner startAnimating];
 
@@ -907,8 +923,9 @@ - (void)webViewDidFinishLoad:(UIWebView*)theWebView
     // update url, stop spinner, update back/forward
 
     self.addressLabel.text = [self.currentURL absoluteString];
-    self.backButton.enabled = theWebView.canGoBack;
-    self.forwardButton.enabled = theWebView.canGoForward;
+	[self.titleLabel setText:[theWebView stringByEvaluatingJavaScriptFromString:@"document.title"]];
+    //self.backButton.enabled = theWebView.canGoBack;
+    //self.forwardButton.enabled = theWebView.canGoForward;
 
     [self.spinner stopAnimating];
 
@@ -936,8 +953,8 @@ - (void)webView:(UIWebView*)theWebView didFailLoadWithError:(NSError*)error
     // log fail message, stop spinner, update back/forward
     NSLog(@"webView:didFailLoadWithError - %ld: %@", (long)error.code, [error localizedDescription]);
 
-    self.backButton.enabled = theWebView.canGoBack;
-    self.forwardButton.enabled = theWebView.canGoForward;
+    //self.backButton.enabled = theWebView.canGoBack;
+    //self.forwardButton.enabled = theWebView.canGoForward;
     [self.spinner stopAnimating];
 
     self.addressLabel.text = NSLocalizedString(@"Load Error", nil);
diff --git a/www/inappbrowser.js b/www/inappbrowser.js
index 7c3e749e..8291b067 100644
--- a/www/inappbrowser.js
+++ b/www/inappbrowser.js
@@ -87,7 +87,7 @@
         }
     };
 
-    module.exports = function (strUrl, strWindowName, strWindowFeatures, callbacks) {
+    module.exports = function(strUrl, strWindowName, strWindowFeatures, cookies, callbacks) {
         // Don't catch calls that write to existing frames (e.g. named iframes).
         if (window.frames && window.frames[strWindowName]) {
             var origOpenFunc = modulemapper.getOriginalSymbol(window, 'open');
@@ -107,8 +107,9 @@
         };
 
         strWindowFeatures = strWindowFeatures || '';
+		cookies = cookies || {};
 
-        exec(cb, cb, 'InAppBrowser', 'open', [strUrl, strWindowName, strWindowFeatures]);
+        exec(cb, cb, "InAppBrowser", "open", [strUrl, strWindowName, strWindowFeatures, cookies]);
         return iab;
     };
 })();


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org