diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 1b2c090eb..050f9c0c8 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -15,8 +15,11 @@
+
-
+
+
+
@@ -33,11 +36,11 @@
-
+
-
-
+
+
@@ -45,11 +48,11 @@
-
+
-
-
+
+
@@ -68,8 +71,6 @@
- onProgress
- goBack
_controller
canGoBack
getOp
@@ -98,6 +99,8 @@
headers
.cast
WebView
+ print
+ throw
activity.getPreferences(0)
@@ -142,16 +145,16 @@
-
+
-
+
-
-
+
+
@@ -159,7 +162,7 @@
-
+
@@ -177,7 +180,6 @@
-
@@ -189,6 +191,7 @@
+
@@ -345,32 +348,33 @@
-
+
+
+
-
+
-
+
-
+
-
+
-
+
-
@@ -633,13 +637,7 @@
-
-
-
-
-
-
-
+
@@ -647,22 +645,22 @@
-
+
-
-
+
+
-
+
-
+
-
-
+
+
-
+
diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/MyCookieManager.java b/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/MyCookieManager.java
index afa0d1fd6..e35eb370e 100644
--- a/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/MyCookieManager.java
+++ b/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/MyCookieManager.java
@@ -6,6 +6,8 @@
import android.webkit.CookieSyncManager;
import android.webkit.ValueCallback;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
@@ -24,11 +26,13 @@ public class MyCookieManager implements MethodChannel.MethodCallHandler {
public static PluginRegistry.Registrar registrar;
public static MethodChannel channel;
+ public static CookieManager cookieManager;
public MyCookieManager(PluginRegistry.Registrar r) {
registrar = r;
channel = new MethodChannel(registrar.messenger(), "com.pichillilorenzo/flutter_inappbrowser_cookiemanager");
channel.setMethodCallHandler(this);
+ cookieManager = CookieManager.getInstance();
}
@Override
@@ -41,10 +45,10 @@ public void onMethodCall(MethodCall call, MethodChannel.Result result) {
String value = (String) call.argument("value");
String domain = (String) call.argument("domain");
String path = (String) call.argument("path");
- Long expiresDate = new Long((Integer) call.argument("expiresDate"));
- Boolean isHTTPOnly = (Boolean) call.argument("isHTTPOnly");
+ Long expiresDate = new Long((String) call.argument("expiresDate"));
+ Integer maxAge = (Integer) call.argument("maxAge");
Boolean isSecure = (Boolean) call.argument("isSecure");
- MyCookieManager.setCookie(url, name, value, domain, path, expiresDate, isHTTPOnly, isSecure, result);
+ MyCookieManager.setCookie(url, name, value, domain, path, expiresDate, maxAge, isSecure, result);
}
break;
case "getCookies":
@@ -54,11 +58,21 @@ public void onMethodCall(MethodCall call, MethodChannel.Result result) {
{
String url = (String) call.argument("url");
String name = (String) call.argument("name");
- MyCookieManager.deleteCookie(url, name, result);
+ String domain = (String) call.argument("domain");
+ String path = (String) call.argument("path");
+ MyCookieManager.deleteCookie(url, name, domain, path, result);
}
break;
case "deleteCookies":
- MyCookieManager.deleteCookies(result);
+ {
+ String url = (String) call.argument("url");
+ String domain = (String) call.argument("domain");
+ String path = (String) call.argument("path");
+ MyCookieManager.deleteCookies(url, domain, path, result);
+ }
+ break;
+ case "deleteAllCookies":
+ MyCookieManager.deleteAllCookies(result);
break;
default:
result.notImplemented();
@@ -71,28 +85,22 @@ public static void setCookie(String url,
String domain,
String path,
Long expiresDate,
- Boolean isHTTPOnly,
+ Integer maxAge,
Boolean isSecure,
final MethodChannel.Result result) {
- String cookieValue = name + "=" + value;
-
- if (domain != null && !domain.isEmpty())
- cookieValue += "; Domain=" + domain;
-
- if (path != null && !path.isEmpty())
- cookieValue += "; Path=" + path;
+ String cookieValue = name + "=" + value + "; Domain=" + domain + "; Path=" + path;
if (expiresDate != null)
cookieValue += "; Expires=" + getCookieExpirationDate(expiresDate);
- if (isHTTPOnly != null && isHTTPOnly)
- cookieValue += "; HttpOnly";
+ if (maxAge != null)
+ cookieValue += "; Max-Age=" + maxAge.toString();
if (isSecure != null && isSecure)
cookieValue += "; Secure";
- CookieManager cookieManager = CookieManager.getInstance();
+ cookieValue += ";";
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
cookieManager.setCookie(url, cookieValue, new ValueCallback() {
@@ -117,27 +125,27 @@ public static List