Commit 897fa201 authored by luca020400's avatar luca020400 Committed by Danny Baumann

Jelly: Propagate custom request headers to WebClient

Change-Id: I0241957271a70285d10cc49d56815e476d9d1910
parent 58c2aed4
......@@ -40,18 +40,24 @@ class WebClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
String url = request.getUrl().toString();
Context context = view.getContext();
if (!url.startsWith("http")) {
try {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(request.getUrl());
context.startActivity(intent);
} catch (ActivityNotFoundException e) {
Snackbar.make(view, context.getString(R.string.error_no_activity_found),
Snackbar.LENGTH_LONG).show();
if (request.isForMainFrame()) {
WebViewExt webViewExt = (WebViewExt) view;
String url = request.getUrl().toString();
if (!url.startsWith("http")) {
Context context = view.getContext();
try {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(request.getUrl());
context.startActivity(intent);
} catch (ActivityNotFoundException e) {
Snackbar.make(view, context.getString(R.string.error_no_activity_found),
Snackbar.LENGTH_LONG).show();
}
return true;
} else if (!webViewExt.getRequestHeaders().isEmpty()) {
webViewExt.loadUrl(url);
return true;
}
return true;
}
return false;
......
......@@ -133,8 +133,6 @@ public class WebViewExt extends WebView {
if (PrefsUtils.getDoNotTrack(mActivity)) {
mRequestHeaders.put(HEADER_DNT, "1");
} else {
mRequestHeaders.remove(HEADER_DNT);
}
}
......@@ -182,4 +180,8 @@ public class WebViewExt extends WebView {
public boolean isDesktopMode() {
return mDesktopMode;
}
Map<String, String> getRequestHeaders() {
return mRequestHeaders;
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment