Skip to content

Commit

Permalink
[wpe] Rename PageSettings to WKSettings to better match native code
Browse files Browse the repository at this point in the history
  • Loading branch information
Jani Hautakangas committed Sep 5, 2024
1 parent 49264e1 commit f7e55bf
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
try {
String content = getHtmlContent();
WPEView view = findViewById(R.id.wpe_view);
view.getWKWebView().getPageSettings().setAllowFileUrls(true);
view.getWKWebView().getWKSettings().setAllowFileUrls(true);
view.loadHtml(content, "file:///");
} catch (IOException ex) {
String message = "Cannot initialize web application";
Expand Down
4 changes: 2 additions & 2 deletions wpe/src/main/cpp/Browser/EntryPoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
*/

#include "Browser.h"
#include "PageSettings.h"
#include "WKCallback.h"
#include "WKCookieManager.h"
#include "WKNetworkSession.h"
#include "WKSettings.h"
#include "WKWebContext.h"
#include "WKWebView.h"
#include "WKWebsiteDataManager.h"
Expand All @@ -38,7 +38,7 @@ extern "C" JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* javaVM, void* /*reserved*/)
WKWebContext::configureJNIMappings();
WKWebsiteDataManager::configureJNIMappings();
WKWebView::configureJNIMappings();
PageSettings::configureJNIMappings();
WKSettings::configureJNIMappings();

return JNI::VERSION;
} catch (...) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

#include "PageSettings.h"
#include "WKSettings.h"

#include "WKWebView.h"

Expand Down Expand Up @@ -52,9 +52,9 @@ void setNativeAllowFileUrls(JNIEnv* /*env*/, jobject /*obj*/, jlong wkWebViewPtr
}
} // namespace

void PageSettings::configureJNIMappings()
void WKSettings::configureJNIMappings()
{
JNI::Class("org/wpewebkit/wpe/PageSettings")
JNI::Class("org/wpewebkit/wpe/WKSettings")
.registerNativeMethods(JNI::NativeMethod<void(jlong, jstring)>("setNativeUserAgent", setNativeUserAgent),
JNI::NativeMethod<void(jlong, jboolean)>(
"setNativeMediaPlaybackRequiresUserGesture", setNativeMediaPlaybackRequiresUserGesture),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@

#pragma once

class PageSettings final {
class WKSettings final {
public:
PageSettings() = delete;
WKSettings() = delete;

static void configureJNIMappings();
};
2 changes: 1 addition & 1 deletion wpe/src/main/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ add_library(
Browser/LooperThread.cpp
Browser/MessagePump.cpp
Browser/WKWebView.cpp
Browser/PageSettings.cpp
Browser/WKSettings.cpp
Browser/RendererSurfaceControl.cpp
Browser/SurfaceControl.cpp
Browser/WKCallback.cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public final class PageSettings {
public final class WKSettings {
private static final int DEFAULT_MAJOR_VERSION = 12;
private static final int DEFAULT_MINOR_VERSION = 0;
private static final int DEFAULT_BUGFIX_VERSION = 0;
Expand Down Expand Up @@ -60,7 +60,7 @@ private static String getOsVersion() {
private native void setNativeMediaPlaybackRequiresUserGesture(long nativePtr, boolean requires);
private native void setNativeAllowFileUrls(long nativePtr, boolean allow);

public PageSettings(@NonNull WKWebView wkWebView) {
public WKSettings(@NonNull WKWebView wkWebView) {
this.wkWebView = wkWebView;
setUserAgent(null);
setMediaPlaybackRequiresUserGesture(true);
Expand Down
6 changes: 3 additions & 3 deletions wpe/src/main/java/org/wpewebkit/wpe/WKWebView.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ public final class WKWebView {
private final WPEView wpeView;
private final PageSurfaceView surfaceView;
protected final ScaleGestureDetector scaleDetector;
private final PageSettings pageSettings;
private final WKSettings wkSettings;

public @NonNull PageSettings getPageSettings() { return pageSettings; }
public @NonNull WKSettings getWKSettings() { return wkSettings; }

private boolean isClosed = false;
private boolean canGoBack = true;
Expand Down Expand Up @@ -156,7 +156,7 @@ public WKWebView(@NonNull WPEView wpeView, @NonNull WKWebContext context, boolea
wpeView.onPageSurfaceViewCreated(surfaceView);
wpeView.onPageSurfaceViewReady(surfaceView);

pageSettings = new PageSettings(this);
wkSettings = new WKSettings(this);
}

public void close() {
Expand Down

0 comments on commit f7e55bf

Please sign in to comment.