|
|
@ -301,46 +301,36 @@ public class LightningWebClient extends WebViewClient { |
|
|
|
|
|
|
|
|
|
|
|
Map<String, String> headers = mLightningView.getRequestHeaders(); |
|
|
|
Map<String, String> headers = mLightningView.getRequestHeaders(); |
|
|
|
|
|
|
|
|
|
|
|
// If the headers are empty, the user has not expressed the desire
|
|
|
|
|
|
|
|
// to use them and therefore we can revert back to the old way of loading
|
|
|
|
|
|
|
|
if (headers.isEmpty()) { |
|
|
|
|
|
|
|
if (mLightningView.isIncognito()) { |
|
|
|
if (mLightningView.isIncognito()) { |
|
|
|
// If we are in incognito, immediately load, we don't want the url to leave the app
|
|
|
|
// If we are in incognito, immediately load, we don't want the url to leave the app
|
|
|
|
return false; |
|
|
|
return continueLoadingUrl(view, url, headers); |
|
|
|
} |
|
|
|
} |
|
|
|
if (url.startsWith(Constants.ABOUT)) { |
|
|
|
if (url.startsWith(Constants.ABOUT)) { |
|
|
|
// If this is an about page, immediately load, we don't need to leave the app
|
|
|
|
// If this is an about page, immediately load, we don't need to leave the app
|
|
|
|
return false; |
|
|
|
return continueLoadingUrl(view, url, headers); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (isMailOrIntent(url, view) || mIntentUtils.startActivityForUrl(view, url)) { |
|
|
|
if (isMailOrIntent(url, view) || mIntentUtils.startActivityForUrl(view, url)) { |
|
|
|
// If it was a mailto: link, or an intent, or could be launched elsewhere, do that
|
|
|
|
// If it was a mailto: link, or an intent, or could be launched elsewhere, do that
|
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
|
|
|
|
if (mLightningView.isIncognito() && Utils.doesSupportHeaders()) { |
|
|
|
// If none of the special conditions was met, continue with loading the url
|
|
|
|
// If we are in incognito, immediately load, we don't want the url to leave the app
|
|
|
|
return continueLoadingUrl(view, url, headers); |
|
|
|
view.loadUrl(url, headers); |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (url.startsWith(Constants.ABOUT) && Utils.doesSupportHeaders()) { |
|
|
|
|
|
|
|
// If this is an about page, immediately load, we don't need to leave the app
|
|
|
|
|
|
|
|
view.loadUrl(url, headers); |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (isMailOrIntent(url, view) || mIntentUtils.startActivityForUrl(view, url)) { |
|
|
|
private boolean continueLoadingUrl(@NonNull WebView webView, |
|
|
|
// If it was a mailto: link, or an intent, or could be launched elsewhere, do that
|
|
|
|
@NonNull String url, |
|
|
|
return true; |
|
|
|
@NonNull Map<String, String> headers) { |
|
|
|
|
|
|
|
if (headers.isEmpty()) { |
|
|
|
|
|
|
|
return false; |
|
|
|
} else if (Utils.doesSupportHeaders()) { |
|
|
|
} else if (Utils.doesSupportHeaders()) { |
|
|
|
// Otherwise, load the headers.
|
|
|
|
webView.loadUrl(url, headers); |
|
|
|
view.loadUrl(url, headers); |
|
|
|
|
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} else { |
|
|
|
} |
|
|
|
|
|
|
|
// If none of those instances was true, revert back to the old way of loading
|
|
|
|
|
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private boolean isMailOrIntent(@NonNull String url, @NonNull WebView view) { |
|
|
|
private boolean isMailOrIntent(@NonNull String url, @NonNull WebView view) { |
|
|
|
if (url.startsWith("mailto:")) { |
|
|
|
if (url.startsWith("mailto:")) { |
|
|
|