Merge branch 'master' into dev

This commit is contained in:
Steven Gill 2013-08-19 15:09:47 -07:00
commit be364c081d
3 changed files with 149 additions and 5 deletions

View File

@ -67,5 +67,12 @@
<source-file src="src/wp/InAppBrowser.cs" /> <source-file src="src/wp/InAppBrowser.cs" />
</platform> </platform>
<!-- windows8 -->
<platform name="windows8">
<js-module src="www/windows8/InAppBrowserProxy.js" name="InAppBrowserProxy">
<merges target="" />
</js-module>
</platform>
</plugin> </plugin>

View File

@ -51,6 +51,7 @@ import android.view.WindowManager;
import android.view.WindowManager.LayoutParams; import android.view.WindowManager.LayoutParams;
import android.view.inputmethod.EditorInfo; import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodManager;
import android.webkit.CookieManager;
import android.webkit.WebChromeClient; import android.webkit.WebChromeClient;
import android.webkit.GeolocationPermissions.Callback; import android.webkit.GeolocationPermissions.Callback;
import android.webkit.JsPromptResult; 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_STOP_EVENT = "loadstop";
private static final String LOAD_ERROR_EVENT = "loaderror"; private static final String LOAD_ERROR_EVENT = "loaderror";
private static final String CLOSE_BUTTON_CAPTION = "closebuttoncaption"; 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 long MAX_QUOTA = 100 * 1024 * 1024;
private Dialog dialog; private Dialog dialog;
@ -87,6 +91,8 @@ public class InAppBrowser extends CordovaPlugin {
private boolean showLocationBar = true; private boolean showLocationBar = true;
private boolean openWindowHidden = false; private boolean openWindowHidden = false;
private String buttonLabel = "Done"; private String buttonLabel = "Done";
private boolean clearAllCache= false;
private boolean clearSessionCache=false;
/** /**
* Executes the request and returns PluginResult. * Executes the request and returns PluginResult.
@ -382,9 +388,18 @@ public class InAppBrowser extends CordovaPlugin {
showLocationBar = show.booleanValue(); showLocationBar = show.booleanValue();
} }
Boolean hidden = features.get(HIDDEN); Boolean hidden = features.get(HIDDEN);
if(hidden != null) { if (hidden != null) {
openWindowHidden = hidden.booleanValue(); 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; final CordovaWebView thatWebView = this.webView;
@ -522,14 +537,19 @@ public class InAppBrowser extends CordovaPlugin {
//Toggle whether this is enabled or not! //Toggle whether this is enabled or not!
Bundle appSettings = cordova.getActivity().getIntent().getExtras(); Bundle appSettings = cordova.getActivity().getIntent().getExtras();
boolean enableDatabase = appSettings == null ? true : appSettings.getBoolean("InAppBrowserStorageEnabled", true); boolean enableDatabase = appSettings == null ? true : appSettings.getBoolean("InAppBrowserStorageEnabled", true);
if(enableDatabase) if (enableDatabase) {
{
String databasePath = cordova.getActivity().getApplicationContext().getDir("inAppBrowserDB", Context.MODE_PRIVATE).getPath(); String databasePath = cordova.getActivity().getApplicationContext().getDir("inAppBrowserDB", Context.MODE_PRIVATE).getPath();
settings.setDatabasePath(databasePath); settings.setDatabasePath(databasePath);
settings.setDatabaseEnabled(true); settings.setDatabaseEnabled(true);
} }
settings.setDomStorageEnabled(true); settings.setDomStorageEnabled(true);
if (clearAllCache) {
CookieManager.getInstance().removeAllCookie();
} else if (clearSessionCache) {
CookieManager.getInstance().removeSessionCookie();
}
inAppWebView.loadUrl(url); inAppWebView.loadUrl(url);
inAppWebView.setId(6); inAppWebView.setId(6);
inAppWebView.getSettings().setLoadWithOverviewMode(true); inAppWebView.getSettings().setLoadWithOverviewMode(true);

View File

@ -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);});