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

Commit ca99630

Browse files
committed
Refactored 'Delegate' postfix according to latest discussion
1 parent 51a1f76 commit ca99630

21 files changed

+316
-507
lines changed

packages/webview_flutter/webview_flutter_platform_interface/lib/v4/src/javascript_channel_registry.dart

Lines changed: 0 additions & 45 deletions
This file was deleted.

packages/webview_flutter/webview_flutter_platform_interface/lib/v4/src/navigation_callback_delegate.dart renamed to packages/webview_flutter/webview_flutter_platform_interface/lib/v4/src/platform_navigation_callback_delegate.dart

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,29 @@ import 'webview_platform.dart';
1414
/// The [WebViewControllerDelegate] is notifying this delegate on events that
1515
/// happened on the platform's webview. Platform implementations should
1616
/// implement this class and pass an instance to the [WebViewControllerDelegate].
17-
abstract class NavigationCallbackDelegate extends PlatformInterface {
18-
/// Creates a new [NavigationCallbackDelegate]
19-
factory NavigationCallbackDelegate(NavigationCallbackCreationParams params) {
20-
final NavigationCallbackDelegate callbackDelegate =
21-
WebViewPlatform.instance!.createNavigationCallbackDelegate(params);
17+
abstract class PlatformNavigationCallbackDelegate extends PlatformInterface {
18+
/// Creates a new [PlatformNavigationCallbackDelegate]
19+
factory PlatformNavigationCallbackDelegate(
20+
PlatformNavigationCallbackDelegateCreationParams params) {
21+
final PlatformNavigationCallbackDelegate callbackDelegate = WebViewPlatform
22+
.instance!
23+
.createPlatformNavigationCallbackDelegate(params);
2224
PlatformInterface.verify(callbackDelegate, _token);
2325
return callbackDelegate;
2426
}
2527

26-
/// Used by the platform implementation to create a new [NavigationCallbackDelegate].
28+
/// Used by the platform implementation to create a new [PlatformNavigationCallbackDelegate].
2729
///
2830
/// Should only be used by platform implementations because they can't extend
2931
/// a class that only contains a factory constructor.
3032
@protected
31-
NavigationCallbackDelegate.implementation(this.params) : super(token: _token);
33+
PlatformNavigationCallbackDelegate.implementation(this.params)
34+
: super(token: _token);
3235

3336
static final Object _token = Object();
3437

35-
/// The parameters used to initialize the [NavigationCallbackDelegate].
36-
final NavigationCallbackCreationParams params;
38+
/// The parameters used to initialize the [PlatformNavigationCallbackDelegate].
39+
final PlatformNavigationCallbackDelegateCreationParams params;
3740

3841
/// Invoked when a navigation request is pending.
3942
///

packages/webview_flutter/webview_flutter_platform_interface/lib/v4/src/webview_controller_delegate.dart renamed to packages/webview_flutter/webview_flutter_platform_interface/lib/v4/src/platform_webview_controller.dart

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ import 'dart:ui';
88
import 'package:flutter/foundation.dart';
99
import 'package:plugin_platform_interface/plugin_platform_interface.dart';
1010

11-
import 'navigation_callback_delegate.dart';
12-
import 'types/types.dart';
11+
import 'platform_navigation_callback_delegate.dart';
1312
import 'webview_platform.dart';
1413

1514
/// Interface for a platform implementation of a web view controller.
@@ -20,25 +19,25 @@ import 'webview_platform.dart';
2019
/// will get the default implementation, while platform implementations that
2120
/// `implements` this interface will be broken by newly added
2221
/// [WebViewCookieManagerDelegate] methods.
23-
abstract class WebViewControllerDelegate extends PlatformInterface {
24-
/// Creates a new [WebViewControllerDelegate]
25-
factory WebViewControllerDelegate(WebViewControllerCreationParams params) {
26-
final WebViewControllerDelegate webViewControllerDelegate =
27-
WebViewPlatform.instance!.createWebViewControllerDelegate(params);
22+
abstract class PlatformWebViewController extends PlatformInterface {
23+
/// Creates a new [PlatformWebViewController]
24+
factory PlatformWebViewController(WebViewControllerCreationParams params) {
25+
final PlatformWebViewController webViewControllerDelegate =
26+
WebViewPlatform.instance!.createPlatformWebViewController(params);
2827
PlatformInterface.verify(webViewControllerDelegate, _token);
2928
return webViewControllerDelegate;
3029
}
3130

32-
/// Used by the platform implementation to create a new [WebViewControllerDelegate].
31+
/// Used by the platform implementation to create a new [PlatformWebViewController].
3332
///
3433
/// Should only be used by platform implementations because they can't extend
3534
/// a class that only contains a factory constructor.
3635
@protected
37-
WebViewControllerDelegate.implementation(this.params) : super(token: _token);
36+
PlatformWebViewController.implementation(this.params) : super(token: _token);
3837

3938
static final Object _token = Object();
4039

41-
/// The parameters used to initialize the [WebViewControllerDelegate].
40+
/// The parameters used to initialize the [PlatformWebViewController].
4241
final WebViewControllerCreationParams params;
4342

4443
/// Loads the file located on the specified [absoluteFilePath].
@@ -160,7 +159,7 @@ abstract class WebViewControllerDelegate extends PlatformInterface {
160159
/// Sets the [NavigationCallbackDelegate] containing the callback methods that
161160
/// are called during navigation events.
162161
Future<void> setNavigationCallbackDelegate(
163-
NavigationCallbackDelegate handler) {
162+
PlatformNavigationCallbackDelegate handler) {
164163
throw UnimplementedError(
165164
'setNavigationCallbackDelegate is not implemented on the current platform');
166165
}

packages/webview_flutter/webview_flutter_platform_interface/lib/v4/src/webview_cookie_manager_delegate.dart renamed to packages/webview_flutter/webview_flutter_platform_interface/lib/v4/src/platform_webview_cookie_manager.dart

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import 'package:flutter/foundation.dart';
66
import 'package:plugin_platform_interface/plugin_platform_interface.dart';
77

8-
import 'types/types.dart';
98
import 'webview_platform.dart';
109

1110
/// Interface for a platform implementation of a cookie manager.
@@ -15,30 +14,30 @@ import 'webview_platform.dart';
1514
/// changes. Extending this class (using `extends`) ensures that the subclass
1615
/// will get the default implementation, while platform implementations that
1716
/// `implements` this interface will be broken by newly added
18-
/// [WebViewCookieManagerDelegate] methods.
19-
abstract class WebViewCookieManagerDelegate extends PlatformInterface {
20-
/// Creates a new [WebViewCookieManagerDelegate]
21-
factory WebViewCookieManagerDelegate(
22-
WebViewCookieManagerCreationParams params) {
23-
final WebViewCookieManagerDelegate cookieManagerDelegate =
24-
WebViewPlatform.instance!.createCookieManagerDelegate(params);
17+
/// [PlatformWebViewCookieManager] methods.
18+
abstract class PlatformWebViewCookieManager extends PlatformInterface {
19+
/// Creates a new [PlatformWebViewCookieManager]
20+
factory PlatformWebViewCookieManager(
21+
PlatformWebViewCookieManagerCreationParams params) {
22+
final PlatformWebViewCookieManager cookieManagerDelegate =
23+
WebViewPlatform.instance!.createPlatformCookieManager(params);
2524
PlatformInterface.verify(cookieManagerDelegate, _token);
2625
return cookieManagerDelegate;
2726
}
2827

2928
/// Used by the platform implementation to create a new
30-
/// [WebViewCookieManagerDelegate].
29+
/// [PlatformWebViewCookieManager].
3130
///
3231
/// Should only be used by platform implementations because they can't extend
3332
/// a class that only contains a factory constructor.
3433
@protected
35-
WebViewCookieManagerDelegate.implementation(this.params)
34+
PlatformWebViewCookieManager.implementation(this.params)
3635
: super(token: _token);
3736

3837
static final Object _token = Object();
3938

40-
/// The parameters used to initialize the [WebViewCookieManagerDelegate].
41-
final WebViewCookieManagerCreationParams params;
39+
/// The parameters used to initialize the [PlatformWebViewCookieManager].
40+
final PlatformWebViewCookieManagerCreationParams params;
4241

4342
/// Clears all cookies for all [WebView] instances.
4443
///

packages/webview_flutter/webview_flutter_platform_interface/lib/v4/src/webview_widget_delegate.dart renamed to packages/webview_flutter/webview_flutter_platform_interface/lib/v4/src/platform_webview_widget.dart

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,33 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
import 'package:flutter/foundation.dart';
65
import 'package:flutter/widgets.dart';
76
import 'package:plugin_platform_interface/plugin_platform_interface.dart';
87

98
import 'webview_platform.dart';
109

1110
/// Interface for a platform implementation of a web view widget.
12-
abstract class WebViewWidgetDelegate extends PlatformInterface {
13-
/// Creates a new [WebViewWidgetDelegate]
14-
factory WebViewWidgetDelegate(WebViewWidgetCreationParams params) {
15-
final WebViewWidgetDelegate webViewWidgetDelegate =
11+
abstract class PlatformWebViewWidget extends PlatformInterface {
12+
/// Creates a new [PlatformWebViewWidget]
13+
factory PlatformWebViewWidget(PlatformWebViewWidgetCreationParams params) {
14+
final PlatformWebViewWidget webViewWidgetDelegate =
1615
WebViewPlatform.instance!.createWebViewWidgetDelegate(params);
1716
PlatformInterface.verify(webViewWidgetDelegate, _token);
1817
return webViewWidgetDelegate;
1918
}
2019

2120
/// Used by the platform implementation to create a new
22-
/// [WebViewWidgetDelegate].
21+
/// [PlatformWebViewWidget].
2322
///
2423
/// Should only be used by platform implementations because they can't extend
2524
/// a class that only contains a factory constructor.
2625
@protected
27-
WebViewWidgetDelegate.implementation(this.params) : super(token: _token);
26+
PlatformWebViewWidget.implementation(this.params) : super(token: _token);
2827

2928
static final Object _token = Object();
3029

31-
/// The parameters used to initialize the [WebViewWidgetDelegate].
32-
final WebViewWidgetCreationParams params;
30+
/// The parameters used to initialize the [PlatformWebViewWidget].
31+
final PlatformWebViewWidgetCreationParams params;
3332

3433
/// Builds a new WebView.
3534
///

packages/webview_flutter/webview_flutter_platform_interface/lib/v4/src/types/javascript_channel.dart

Lines changed: 0 additions & 35 deletions
This file was deleted.

packages/webview_flutter/webview_flutter_platform_interface/lib/v4/src/types/load_request_params.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
// found in the LICENSE file.
44

55
import 'dart:typed_data';
6+
67
import 'package:flutter/foundation.dart';
78

8-
import '../webview_controller_delegate.dart';
9+
import '../platform_webview_controller.dart';
910

10-
/// Defines the supported HTTP methods for loading a page in [WebViewControllerDelegate].
11+
/// Defines the supported HTTP methods for loading a page in [PlatformWebViewController].
1112
enum LoadRequestMethod {
1213
/// HTTP GET method.
1314
get,
@@ -29,7 +30,7 @@ extension LoadRequestMethodExtensions on LoadRequestMethod {
2930
}
3031
}
3132

32-
/// Defines the parameters that can be used to load a page with the [WebViewControllerDelegate].
33+
/// Defines the parameters that can be used to load a page with the [PlatformWebViewController].
3334
///
3435
/// Platform specific implementations can add additional fields by extending
3536
/// this class.

packages/webview_flutter/webview_flutter_platform_interface/lib/v4/src/types/navigation_callback_creation_params.dart

Lines changed: 0 additions & 44 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
import 'package:flutter/material.dart';
6+
7+
/// Object specifying creation parameters for creating a [PlatformNavigationCallbackDelegate].
8+
///
9+
/// Platform specific implementations can add additional fields by extending
10+
/// this class.
11+
///
12+
/// {@tool sample}
13+
/// This example demonstrates how to extend the [PlatformNavigationCallbackDelegateCreationParams] to
14+
/// provide additional platform specific parameters.
15+
///
16+
/// When extending [PlatformNavigationCallbackDelegateCreationParams] additional
17+
/// parameters should always accept `null` or have a default value to prevent
18+
/// breaking changes.
19+
///
20+
/// ```dart
21+
/// class AndroidNavigationCallbackDelegateCreationParams extends PlatformNavigationCallbackDelegateCreationParams {
22+
/// AndroidNavigationCallbackDelegateCreationParams._(
23+
/// // This parameter prevents breaking changes later.
24+
/// // ignore: avoid_unused_constructor_parameters
25+
/// PlatformNavigationCallbackDelegateCreationParams params, {
26+
/// this.filter,
27+
/// }) : super();
28+
///
29+
/// factory AndroidNavigationCallbackDelegateCreationParams.fromPlatformNavigationCallbackDelegateCreationParams(
30+
/// PlatformNavigationCallbackDelegateCreationParams params, {
31+
/// String? filter,
32+
/// }) {
33+
/// return AndroidNavigationCallbackDelegateCreationParams._(params, filter: filter);
34+
/// }
35+
///
36+
/// final String? filter;
37+
/// }
38+
/// ```
39+
/// {@end-tool}
40+
@immutable
41+
class PlatformNavigationCallbackDelegateCreationParams {
42+
/// Used by the platform implementation to create a new [PlatformNavigationCallbackDelegate].
43+
const PlatformNavigationCallbackDelegateCreationParams();
44+
}

0 commit comments

Comments
 (0)