List icon Contents

From 7.7.1 to 7.8

In JxBrowser 7.8 the Chromium engine has been upgraded to version 79. This Chromium version has several breaking changes in the source code that affect the public API of JxBrowser. In this migration guide we describe what API has been removed in 7.8 and what alternatives you should use instead.

Downloads

Accepting download

v7.7.1

In order to accept a file download request the following callback is used:

Java
Kotlin
Downloads downloads = engine.downloads();
downloads.set(StartDownloadCallback.class, (params, tell) -> tell.cancel());
val downloads = engine.downloads()
downloads.set(StartDownloadCallback::class.java,
    StartDownloadCallback { params, tell -> tell.cancel() }
)

v7.8

In 7.8 this functionality has been moved to Browser, so now you can accept a file download request for each Browser instance independently. For example:

Java
Kotlin
browser.set(StartDownloadCallback.class, (params, tell) -> tell.cancel());
browser.set(StartDownloadCallback::class.java,
    StartDownloadCallback { params, tell -> tell.cancel() }
)

Network

Accessing browser

v7.7.1

Java
Kotlin
network.set(BeforeSendHeadersCallback.class, params -> {
    params.browser().ifPresent(browser -> {});
    ...
});

network.set(BeforeUrlRequestCallback.class, params -> {
    params.browser().ifPresent(browser -> {});
    ...
});

network.set(ReceiveHeadersCallback.class, params -> {
    params.browser().ifPresent(browser -> {});
    ...
});
network.set(BeforeSendHeadersCallback::class.java,
    BeforeSendHeadersCallback { params -> 
        params.browser().ifPresent{ browser -> {}}
    }
)
network.set(BeforeUrlRequestCallback::class.java,
    BeforeUrlRequestCallback { params -> 
        params.browser().ifPresent{ browser -> {}}
    }
)
network.set(ReceiveHeadersCallback::class.java,
    ReceiveHeadersCallback { params -> 
        params.browser().ifPresent{ browser -> {}}
    }
)

v7.8

Java
Kotlin
network.set(BeforeSendHeadersCallback.class, params -> {
    params.urlRequest().browser().ifPresent(browser -> {});
    ...
});

network.set(BeforeUrlRequestCallback.class, params -> {
    params.urlRequest().browser().ifPresent(browser -> {});
    ...
});

network.set(ReceiveHeadersCallback.class, params -> {
    params.urlRequest().browser().ifPresent(browser -> {});
    ...
});
network.set(BeforeSendHeadersCallback::class.java,
    BeforeSendHeadersCallback { params -> 
        params.urlRequest().browser().ifPresent{browser -> {}}
        ...
    }
)
network.set(BeforeUrlRequestCallback::class.java,
    BeforeUrlRequestCallback { params -> 
        params.urlRequest().browser().ifPresent{browser -> {}}
        ...
    }
)
network.set(ReceiveHeadersCallback::class.java,
    ReceiveHeadersCallback { params -> 
        params.urlRequest().browser().ifPresent{browser -> {}}
        ...
    }
)

BytesSent

v7.7.1

Java
Kotlin
network.on(BytesSent.class, event -> {
    int bytesSentCount = event.count();
});
network.on(BytesSent.class) { event ->
    val bytesSentCount = event.count()
});

v7.8

Java
Kotlin
network.on(RequestCompleted.class, event -> {
    long bytesSent = event.urlRequest().totalBytesSent();
});
network.on(RequestCompleted.class) { event ->
    val bytesSent = event.urlRequest().totalBytesSent()
});

BytesReceived

v7.7.1

Java
Kotlin
network.on(BytesReceived.class, event -> {
    int bytesReceivedCount = event.count();
});
network.on(BytesReceived.class) { event ->
    val bytesReceivedCount = event.count()
});

v7.8

Java
Kotlin
network.on(RequestCompleted.class, event -> {
    long bytesReceived = event.urlRequest().totalBytesReceived();
});
network.on(RequestCompleted.class) { event ->
    val bytesReceived = event.urlRequest().totalBytesReceived()
});

Content

Taking Bitmap of a Web Page

The deprecated com.teamdev.jxbrowser.view.javafx.BitmapUtil and com.teamdev.jxbrowser.view.swing.BitmapUtil classes have been removed. Use the com.teamdev.jxbrowser.view.swing.graphics.BitmapImage and com.teamdev.jxbrowser.view.javafx.graphics.BitmapImage classes instead.

Removed API

The following classes and methods have been removed because the corresponding functionality in Chromium 79 does not exist anymore:

  • com.teamdev.jxbrowser.net.event.TransactionStarted
  • com.teamdev.jxbrowser.net.callback.CanAccessFileCallback.url()
  • com.teamdev.jxbrowser.browser.callback.CertificateErrorCallback.resourceType()