Skip to content
Draft
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 @@ -86,7 +86,7 @@ public void navigationStateChanged(int flags) {
}
}

@Override
//@Override
public void onWebAppManifest(WebContents webContents, @NonNull String manifest) {
@Nullable WSession.ContentDelegate delegate = mSession.getContentDelegate();
if (delegate == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public void didFailLoad(boolean isInPrimaryMainFrame, int errorCode, GURL failin

WSession.NavigationDelegate navigationDelegate = mSession.getNavigationDelegate();
if (navigationDelegate != null) {
navigationDelegate.onLoadError(mSession, failingUrl.getSpec(), new WWebRequestError() {
byte[] errorData = navigationDelegate.onLoadErrorData(mSession, failingUrl.getSpec(), new WWebRequestError() {
@Override
public int code() {
return errorCode;
Expand All @@ -135,6 +135,7 @@ public X509Certificate certificate() {
return null;
}
});
mSession.loadData(errorData, "text/html");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,15 @@ WResult<String> onLoadError(
@NonNull final WWebRequestError error) {
return null;
}

@UiThread
default @Nullable
byte[] onLoadErrorData(
@NonNull final WSession session,
@Nullable final String uri,
@NonNull final WWebRequestError error) {
return null;
}
}

@Retention(RetentionPolicy.SOURCE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1244,6 +1244,11 @@ public WResult<String> onLoadError(@NonNull WSession session, @Nullable String u
return WResult.fromValue(InternalPages.createErrorPageDataURI(mContext, uri, error.code()));
}

@Override
public byte[] onLoadErrorData(@NonNull WSession session, @Nullable String uri, @NonNull WWebRequestError error) {
return InternalPages.createErrorPageData(mContext, uri, error.code());
}

// Progress Listener

@Override
Expand Down
13 changes: 12 additions & 1 deletion app/src/common/shared/com/igalia/wolvic/utils/InternalPages.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,16 @@

import mozilla.components.browser.errorpages.ErrorType;

import org.chromium.net.NetError;

public class InternalPages {

private static ErrorType fromSessionErrorToErrorType(int error) {
switch(error) {
case WWebRequestError.ERROR_SECURITY_SSL: {
return ErrorType.ERROR_SECURITY_SSL;
}
case NetError.ERR_CERT_DATE_INVALID:
case WWebRequestError.ERROR_SECURITY_BAD_CERT: {
return ErrorType.ERROR_SECURITY_BAD_CERT;
}
Expand Down Expand Up @@ -117,11 +120,19 @@ public static PageResources create(int html, int css) {
public static String createErrorPageDataURI(Context context,
@Nullable String uri,
int sessionError) {

return "data:text/html;base64," + Base64.encodeToString(createErrorPageData(context, uri, sessionError), Base64.NO_WRAP);
}

public static byte[] createErrorPageData(Context context,
@Nullable String uri,
int sessionError) {
String html = readRawResourceString(context, R.raw.error_pages);
String css = readRawResourceString(context, R.raw.error_style);

boolean showSSLAdvanced;
switch (sessionError) {
case NetError.ERR_CERT_DATE_INVALID:
case WWebRequestError.ERROR_SECURITY_SSL:
case WWebRequestError.ERROR_SECURITY_BAD_CERT:
showSSLAdvanced = true;
Expand All @@ -143,7 +154,7 @@ public static String createErrorPageDataURI(Context context,
html = html.replace("%url%", uri);
}

return "data:text/html;base64," + Base64.encodeToString(html.getBytes(), Base64.NO_WRAP);
return html.getBytes();
}

public static byte[] createAboutPage(Context context,
Expand Down
10 changes: 2 additions & 8 deletions app/src/main/res/raw/error_pages.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,7 @@
advancedVisible = !advancedVisible;
}
function acceptAndContinue(temporary) {
document.addCertException(temporary).then(() => {
location.reload();
},
err => {
console.error("Unexpected error: " + err)
}
);
window.certificateErrorPageController.proceed();
}
</script>
</head>
Expand Down Expand Up @@ -67,7 +61,7 @@ <h1 id="et_dnsNotFound" class="errorTitleText">%messageShort%</h1>
<label>Websites prove their identity via certificates. Wolvic does not trust <b>%url%</b> because its certificate issuer is unknown, the certificate is self-signed, or the server is not sending the correct intermediate certificates.</label>
</p>
<div id="advancedPanelButtonContainer" class="button-container">
<button id="advancedPanelReturnButton" onClick="window.history.back()" class="button">Go Back (Recommended)</button>
<button id="advancedPanelReturnButton" onClick="window.history.go(-2)" class="button">Go Back (Recommended)</button>
</div>
<div id="advancedPanelButtonContainer" class="button-container">
<button id="button" class="buttonSecondary" onClick="acceptAndContinue(true)">Accept the Risk and Continue</button>
Expand Down