Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

setAcceptFileSchemeCookies Support cookies on file:// option #98

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ public XWalkCordovaCookieManager() {
cookieManager = new XWalkCookieManager();
}

public void setAcceptFileSchemeCookies(boolean accept) {
cookieManager.setAcceptFileSchemeCookies(accept);
}

public void setCookiesEnabled(boolean accept) {
cookieManager.setAcceptCookie(accept);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public class XWalkWebViewEngine implements CordovaWebViewEngine {
public static final String XWALK_Z_ORDER_ON_TOP = "xwalkZOrderOnTop";

private static final String XWALK_EXTENSIONS_FOLDER = "xwalk-extensions";
private static final String XWALK_FILE_SCHEME_COOKIES = "xwalkFileSchemeCookies";

protected final XWalkCordovaView webView;
protected XWalkCordovaCookieManager cookieManager;
Expand All @@ -72,9 +73,12 @@ public class XWalkWebViewEngine implements CordovaWebViewEngine {
protected XWalkActivityDelegate activityDelegate;
protected String startUrl;
protected CordovaPreferences preferences;
protected boolean xwalkFileSchemeCookies;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

local variable please


/** Used when created via reflection. */
public XWalkWebViewEngine(Context context, CordovaPreferences preferences) {
xwalkFileSchemeCookies = preferences == null ? false : preferences.getBoolean(XWALK_FILE_SCHEME_COOKIES, false);

this.preferences = preferences;
Runnable cancelCommand = new Runnable() {
@Override
Expand All @@ -87,6 +91,11 @@ public void run() {
public void run() {
cookieManager = new XWalkCordovaCookieManager();

if (xwalkFileSchemeCookies) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move to initWebViewSettings() function

cookieManager.setCookiesEnabled(true);
cookieManager.setAcceptFileSchemeCookies(true);
}

initWebViewSettings();
exposeJsInterface(webView, bridge);
loadExtensions();
Expand Down
2 changes: 2 additions & 0 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@
<preference name="XWALK_COMMANDLINE" default="--disable-pull-to-refresh-effect"/>
<preference name="XWALK_MODE" default="embedded" />
<preference name="XWALK_MULTIPLEAPK" default="true" />
<preference name="XWALK_FILE_SCHEME_COOKIES" default="false" />
<config-file target="res/xml/config.xml" parent="/*">
<preference name="webView" value="org.crosswalk.engine.XWalkWebViewEngine"/>
<preference name="xwalkVersion" value="$XWALK_VERSION"/>
<preference name="xwalkLiteVersion" value="$XWALK_LITEVERSION"/>
<preference name="xwalkCommandLine" value="$XWALK_COMMANDLINE"/>
<preference name="xwalkMode" value="$XWALK_MODE" />
<preference name="xwalkMultipleApk" value="$XWALK_MULTIPLEAPK" />
<preference name="xwalkFileSchemeCookies" default="$XWALK_FILE_SCHEME_COOKIES" />
<preference name="android-minSdkVersion" value="16" />
</config-file>

Expand Down