diff --git a/plugin.xml b/plugin.xml index 45aa981..5b78494 100644 --- a/plugin.xml +++ b/plugin.xml @@ -66,6 +66,13 @@ + + + + + + + diff --git a/src/android/InAppBrowser.java b/src/android/InAppBrowser.java index ebd7736..a4f6b8b 100644 --- a/src/android/InAppBrowser.java +++ b/src/android/InAppBrowser.java @@ -51,6 +51,7 @@ import android.view.WindowManager; import android.view.WindowManager.LayoutParams; import android.view.inputmethod.EditorInfo; import android.view.inputmethod.InputMethodManager; +import android.webkit.CookieManager; import android.webkit.WebChromeClient; import android.webkit.GeolocationPermissions.Callback; import android.webkit.JsPromptResult; @@ -78,6 +79,9 @@ public class InAppBrowser extends CordovaPlugin { private static final String LOAD_STOP_EVENT = "loadstop"; private static final String LOAD_ERROR_EVENT = "loaderror"; private static final String CLOSE_BUTTON_CAPTION = "closebuttoncaption"; + private static final String CLEAR_ALL_CACHE = "clearcache"; + private static final String CLEAR_SESSION_CACHE = "clearsessioncache"; + private long MAX_QUOTA = 100 * 1024 * 1024; private Dialog dialog; @@ -87,7 +91,9 @@ public class InAppBrowser extends CordovaPlugin { private boolean showLocationBar = true; private boolean openWindowHidden = false; private String buttonLabel = "Done"; - + private boolean clearAllCache= false; + private boolean clearSessionCache=false; + /** * Executes the request and returns PluginResult. * @@ -382,9 +388,18 @@ public class InAppBrowser extends CordovaPlugin { showLocationBar = show.booleanValue(); } Boolean hidden = features.get(HIDDEN); - if(hidden != null) { + if (hidden != null) { openWindowHidden = hidden.booleanValue(); } + Boolean cache = features.get(CLEAR_ALL_CACHE); + if (cache != null) { + clearAllCache = cache.booleanValue(); + } else { + cache = features.get(CLEAR_SESSION_CACHE); + if (cache != null) { + clearSessionCache = cache.booleanValue(); + } + } } final CordovaWebView thatWebView = this.webView; @@ -522,14 +537,19 @@ public class InAppBrowser extends CordovaPlugin { //Toggle whether this is enabled or not! Bundle appSettings = cordova.getActivity().getIntent().getExtras(); boolean enableDatabase = appSettings == null ? true : appSettings.getBoolean("InAppBrowserStorageEnabled", true); - if(enableDatabase) - { + if (enableDatabase) { String databasePath = cordova.getActivity().getApplicationContext().getDir("inAppBrowserDB", Context.MODE_PRIVATE).getPath(); settings.setDatabasePath(databasePath); settings.setDatabaseEnabled(true); } settings.setDomStorageEnabled(true); - + + if (clearAllCache) { + CookieManager.getInstance().removeAllCookie(); + } else if (clearSessionCache) { + CookieManager.getInstance().removeSessionCookie(); + } + inAppWebView.loadUrl(url); inAppWebView.setId(6); inAppWebView.getSettings().setLoadWithOverviewMode(true); diff --git a/www/windows8/InAppBrowserProxy.js b/www/windows8/InAppBrowserProxy.js new file mode 100644 index 0000000..9928d19 --- /dev/null +++ b/www/windows8/InAppBrowserProxy.js @@ -0,0 +1,117 @@ +cordova.define("org.apache.cordova.core.inappbrowser.InAppBrowserProxy", function(require, exports, module) { /* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * +*/ + +/*global Windows:true */ + + + +var cordova = require('cordova'), + channel = require('cordova/channel'); + +var browserWrap; + +var IAB = { + + close: function (win,lose) { + if (browserWrap) { + browserWrap.parentNode.removeChild(browserWrap); + browserWrap = null; + } + }, + show: function (win,lose) { + if (browserWrap) { + + } + }, + open: function (win,lose,args) { + var strUrl = args[0]; + var target = args[1]; + var features = args[2]; + + if (target == "_system") { + var url = new Windows.Foundation.Uri(strUrl) + Windows.System.Launcher.launchUriAsync(url); + } + else if (target == "_blank") { + if (!browserWrap) { + browserWrap = document.createElement("div"); + browserWrap.style.position = "absolute"; + browserWrap.style.width = (window.innerWidth - 80) + "px"; + browserWrap.style.height = (window.innerHeight - 80) + "px"; + browserWrap.style.borderWidth = "40px"; + browserWrap.style.borderStyle = "solid"; + browserWrap.style.borderColor = "rgba(0,0,0,0.25)"; + + browserWrap.onclick = function () { + setTimeout(function () { + IAB.close(); + }, 0); + } + + document.body.appendChild(browserWrap); + } + + var elem = document.createElement("iframe"); + elem.style.width = (window.innerWidth - 80)+ "px"; + elem.style.height = (window.innerHeight - 80) + "px"; + elem.style.borderWidth = "0px"; + elem.name = "targetFrame"; + elem.src = strUrl; + + window.addEventListener("resize", function () { + if (browserWrap && elem) { + elem.style.width = (window.innerWidth - 80) + "px"; + elem.style.height = (window.innerHeight - 80) + "px"; + } + }); + + browserWrap.appendChild(elem); + } + else { + window.location = strUrl; + } + + + + + + //var object = new WinJS.UI.HtmlControl(elem, { uri: strUrl }); + + + }, + + injectScriptCode:function(code, bCB) { + + // "(function(d) { var c = d.createElement('script'); c.src = %@; d.body.appendChild(c); })(document)" + }, + + injectScriptFile:function(file, bCB) { + + } +}; + + + + +module.exports = IAB; + + +require("cordova/commandProxy").add("InAppBrowser",IAB);});