Skip to content

CDVWebViewEngine needs a way to set the websiteDataStore of its configuration #900

Closed
@msmtamburro

Description

@msmtamburro

Feature Request

Motivation Behind Feature

A websiteDataStore can both be configured (e.g., set to non-persistent) and re-used (e.g., in other web browser components).

Feature Description

Optionally exposing the configuration as typically done with the "Cordova settings" model may not suffice. For example, if you only added a Cordova setting for persistent vs. non-persistent, this would still not give us a handle to the websiteDataStore for re-use elsewhere. More specifically, allowing Cordova to use an existing websiteDataStore that was created and used prior to Cordova reaching its createConfigurationFromSettings method is important in my case. You could accomplish this by providing a protocol that allows us to return a websiteDataStore.

For example, add the following lines to CDVWebViewEngine.h:

@protocol CDVWebViewEngineConfigurationDelegate <NSObject>
/// Provides a fully configured WKWebsiteDataStore; useful for customizing configuration
- (nonnull WKWebViewConfiguration *)configuration;
@end

and then expose this property:

@property (nullable, nonatomic, weak) CDVPlugin<CDVWebViewEngineConfigurationDelegate>* configurationDelegate;

And finally, in CDVWebViewEngine.m, inside of createConfigurationFromSettings: start with:

    WKWebViewConfiguration* configuration = [_configurationDelegate configuration];
    if (configuration) {
        return configuration;
    }

Alternatives or Workarounds

When using the CDVWKWebViewEngine (the old plugin), it was possible to override createConfigurationFromSettings to customize portions of the configuration that were not exposed through Cordova settings. With the migration to CDVWebViewEngine, its private status prevents this type of customization without resorting to swizzling.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions