Migration
From previous versions to 8.16.0
In JxBrowser 8.16.0, we cleaned up the context menu API, improved error handling for adding passwords and credit cards, and upgraded to Chromium 144. These changes require updates to context menu callbacks, error handling code, and handling of removed network error values.
Context menu API cleanup
To improve API consistency, we moved ContextMenuContentType to a public
package and renamed the related method.
ContextMenuContentType
The ContextMenuContentType enum moved to a public package, and its values no
longer have the CONTEXT_MENU_CONTENT_TYPE_ prefix. Additionally, the method
ShowContextMenuCallback.Params.contentType() was renamed to
contentTypes().
Previous versions:
import com.teamdev.jxbrowser.menu.internal.rpc.ContextMenuContentType;
browser.set(ShowContextMenuCallback.class, (params, tell) -> {
var contentType = params.contentType();
if (contentType.contains(ContextMenuContentType.CONTEXT_MENU_CONTENT_TYPE_EDITABLE)) {
// Handle editable content
}
tell.close();
});
8.16.0:
import com.teamdev.jxbrowser.menu.ContextMenuContentType;
browser.set(ShowContextMenuCallback.class, (params, tell) -> {
var contentTypes = params.contentTypes();
if (contentTypes.contains(ContextMenuContentType.EDITABLE)) {
// Handle editable content
}
tell.close();
});
Error handling with exceptions
To improve API consistency, methods for adding passwords, credit cards, and user data profiles now throw exceptions for validation errors instead of returning error strings.
PasswordStore.add()
Previous versions:
String result = passwordStore.add(invalidPasswordRecord);
if (!result.isEmpty()) {
System.err.println("Failed to add password: " + result);
}
8.16.0:
try {
passwordStore.add(invalidPasswordRecord);
} catch (IllegalArgumentException e) {
System.err.println("Failed to add password: " + e.getMessage());
}
The method now throws IllegalArgumentException when the password record has
an invalid URL or an empty password.
CreditCards.add()
Previous versions:
String result = creditCards.add(expiredCreditCard);
if (!result.isEmpty()) {
System.err.println("Failed to add credit card: " + result);
}
8.16.0:
try {
creditCards.add(expiredCreditCard);
} catch (IllegalArgumentException e) {
System.err.println("Failed to add credit card: " + e.getMessage());
}
The method now throws IllegalArgumentException when the credit card has
already expired.
UserDataProfiles.add()
Previous versions:
String result = userDataProfiles.add(invalidUserProfile);
if (!result.isEmpty()) {
System.err.println("Failed to add profile: " + result);
}
8.16.0:
try {
userDataProfiles.add(invalidUserProfile);
} catch (IllegalArgumentException e) {
System.err.println("Failed to add profile: " + e.getMessage());
}
The method now throws IllegalArgumentException on validation errors.
Enum technical values cleanup
We removed *_UNRECOGNIZED and *_UNSPECIFIED values from all enumerations.
These were technical values for internal use and should not have been used in
application code.
For a limited number of enums where the Chromium counterpart has an unknown
state, we added UNKNOWN values:
PermissionType.UNKNOWNCreditCardNetwork.UNKNOWNUrlRequestStatus.UNKNOWNNetError.UNKNOWNSuggestionsPopupType.UNKNOWNColorModel.UNKNOWNDuplexMode.UNKNOWN
Where applicable, replace these values with the new UNKNOWN value and remove the old usages.
Removed NetError values
We removed certain NetError enum values that no longer exist in Chromium.
If your code references any of these values, you will see compilation errors indicating which specific
values are no longer available:
NO_SSL_VERSIONS_ENABLEDHTTPS_PROXY_TUNNEL_RESPONSE_REDIRECTSSL_HANDSHAKE_NOT_COMPLETEDSSL_BAD_PEER_PUBLIC_KEYSYN_REPLY_NOT_RECEIVEDENCODING_CONVERSION_FAILEDUNRECOGNIZED_FTP_DIRECTORY_LISTING_FORMAT