Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Conversation

@amirh
Copy link
Contributor

@amirh amirh commented May 30, 2019

This is a followup for #1618, #1624, and #1645, and moves the plugins.flutter.io/cookie_manager method channel behind the platform interface which allows a third party package to provide a new platform implementation the cooke manager.

See the description for #1618 for more details.

Following this PR all platform specific code can be replaced by an external package.

Note on renamed classes

Before this PR we had a WebViewBuilder class(which had the build method) and a WebViewPlatform class (which abstracted what's currently done on the webview method channel).
A WebViewPlatform instance existed per WebView instance, and WebViewBuilder needs to exist once.

As clearCookies is not associated with a WebView instance I added it to what was previously named WebViewBuilder and renamed both classes:

  • WebViewPlatform -> WebViewPlatformController
  • WebViewBuilder -> WebViewPlatform

With this, to replace the platform implementation you do WebView.platform = FuchsiaWebView();.

I'm far from being in love with the current names, and happy to do something else (we haven't published the plugin yet so this isn't a breaking change yet).

An alternative option I have in mind is to add a separate CookieManagerPlatform interface (this will mean we have to not only do WebView.platformBuilder = FuchsiaWebViewBuilder() but also CookieManager.platform = FuchsiaCookieManager().

@nkoroste, @cyanglaz any thouhgs?
@Hixie you had opinions on these names in #1618, curious to see what you think.

Copy link

@nkoroste nkoroste left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM, I think we should get it in to unblock Fuchsia first. Then during the Fuchsia implementation we can iterate on the naming some more.


typedef WebViewPlatformCreatedCallback = void Function(
WebViewPlatform webViewPlatform);
WebViewPlatformController webViewPlatform);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
WebViewPlatformController webViewPlatform);
WebViewPlatformController webViewPlatformController);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

/// The default value is [AndroidWebViewBuilder] on Android and [CupertinoWebViewBuilder] on iOs.
static set platformBuilder(WebViewBuilder platformBuilder) {
_platformBuilder = platformBuilder;
/// The default value is [AndroidWebView] on Android and [CupertinoWebView] on iOs.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// The default value is [AndroidWebView] on Android and [CupertinoWebView] on iOs.
/// The default value is [AndroidWebView] on Android and [CupertinoWebView] on iOS.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

static set platformBuilder(WebViewBuilder platformBuilder) {
_platformBuilder = platformBuilder;
/// The default value is [AndroidWebView] on Android and [CupertinoWebView] on iOs.
static set platform(WebViewPlatform platformBuilder) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
static set platform(WebViewPlatform platformBuilder) {
static set platform(WebViewPlatform platform) {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

_platformBuilder = platformBuilder;
/// The default value is [AndroidWebView] on Android and [CupertinoWebView] on iOs.
static set platform(WebViewPlatform platformBuilder) {
_platform = platformBuilder;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
_platform = platformBuilder;
_platform = platform;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

}

final WebViewPlatform _webViewPlatform;
final WebViewPlatformController _webViewPlatform;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
final WebViewPlatformController _webViewPlatform;
final WebViewPlatformController _webViewPlatformController;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

}

class MyWebViewBuilder implements WebViewBuilder {
class MyWebViewBuilder implements WebViewPlatform {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
class MyWebViewBuilder implements WebViewPlatform {
class MyWebViewPlatform implements WebViewPlatform {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

);

final MyWebViewBuilder builder = WebView.platformBuilder;
final MyWebViewBuilder builder = WebView.platform;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
final MyWebViewBuilder builder = WebView.platform;
final MyWebViewPlatform builder = WebView.platform;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

);

final MyWebViewBuilder builder = WebView.platformBuilder;
final MyWebViewBuilder builder = WebView.platform;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
final MyWebViewBuilder builder = WebView.platform;
final MyWebViewPlatform builder = WebView.platform;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

}

class MyWebViewPlatform extends WebViewPlatform {
class MyWebViewPlatform extends WebViewPlatformController {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
class MyWebViewPlatform extends WebViewPlatformController {
class MyWebViewPlatformController extends WebViewPlatformController {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@amirh amirh requested a review from iskakaushik as a code owner May 31, 2019 21:32
@amirh amirh merged commit 3b71d6e into flutter:master May 31, 2019
@amirh amirh deleted the multi_platform_webview_4 branch May 31, 2019 22:40
julianscheel pushed a commit to jusst-engineering/plugins that referenced this pull request Mar 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants