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

Commit e42b9ff

Browse files
committed
add all back to platform interface
1 parent 61b217c commit e42b9ff

File tree

52 files changed

+3670
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+3670
-0
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Below is a list of people and organizations that have contributed
2+
# to the Flutter project. Names should be added to the list like so:
3+
#
4+
# Name/Organization <email address>
5+
6+
Google Inc.
7+
The Chromium Authors
8+
German Saprykin <[email protected]>
9+
Benjamin Sauer <[email protected]>
10+
11+
Ali Bitek <[email protected]>
12+
Pol Batlló <[email protected]>
13+
Anatoly Pulyaevskiy
14+
Hayden Flinner <[email protected]>
15+
Stefano Rodriguez <[email protected]>
16+
Salvatore Giordano <[email protected]>
17+
Brian Armstrong <[email protected]>
18+
Paul DeMarco <[email protected]>
19+
Fabricio Nogueira <[email protected]>
20+
Simon Lightfoot <[email protected]>
21+
Ashton Thomas <[email protected]>
22+
Thomas Danner <[email protected]>
23+
Diego Velásquez <[email protected]>
24+
Hajime Nakamura <[email protected]>
25+
Tuyển Vũ Xuân <[email protected]>
26+
Miguel Ruivo <[email protected]>
27+
Sarthak Verma <[email protected]>
28+
Mike Diarmid <[email protected]>
29+
Invertase <[email protected]>
30+
Elliot Hesp <[email protected]>
31+
Vince Varga <[email protected]>
32+
Aawaz Gyawali <[email protected]>
33+
EUI Limited <[email protected]>
34+
Katarina Sheremet <[email protected]>
35+
Thomas Stockx <[email protected]>
36+
Sarbagya Dhaubanjar <[email protected]>
37+
Ozkan Eksi <[email protected]>
38+
Rishab Nayak <[email protected]>
39+
40+
Jonathan Younger <[email protected]>
41+
Jose Sanchez <[email protected]>
42+
Debkanchan Samadder <[email protected]>
43+
Audrius Karosevicius <[email protected]>
44+
Lukasz Piliszczuk <[email protected]>
45+
SoundReply Solutions GmbH <[email protected]>
46+
Rafal Wachol <[email protected]>
47+
Pau Picas <[email protected]>
48+
Christian Weder <[email protected]>
49+
Alexandru Tuca <[email protected]>
50+
Christian Weder <[email protected]>
51+
Rhodes Davis Jr. <[email protected]>
52+
Luigi Agosti <[email protected]>
53+
Quentin Le Guennec <[email protected]>
54+
Koushik Ravikumar <[email protected]>
55+
Nissim Dsilva <[email protected]>
56+
Giancarlo Rocha <[email protected]>
57+
Ryo Miyake <[email protected]>
58+
Théo Champion <[email protected]>
59+
Kazuki Yamaguchi <[email protected]>
60+
Eitan Schwartz <[email protected]>
61+
Chris Rutkowski <[email protected]>
62+
Juan Alvarez <[email protected]>
63+
Aleksandr Yurkovskiy <[email protected]>
64+
Anton Borries <[email protected]>
65+
66+
Rahul Raj <[email protected]>
67+
Maurits van Beusekom <[email protected]>
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
## 2.0.0
2+
3+
* **Breaking Change**: Releases new interface. See [documentation](https://pub.dev/documentation/webview_flutter_platform_interface/2.0.0/) and [design doc](https://flutter.dev/go/webview_flutter_4_interface)
4+
for more details.
5+
* **Breaking Change**: Removes MethodChannel implementation of interface. All platform
6+
implementations will now need to create their own by implementing `WebViewPlatform`.
7+
8+
## 1.9.5
9+
10+
* Updates code for `no_leading_underscores_for_local_identifiers` lint.
11+
12+
## 1.9.4
13+
14+
* Updates imports for `prefer_relative_imports`.
15+
16+
## 1.9.3
17+
18+
* Updates minimum Flutter version to 2.10.
19+
* Removes `BuildParams` from v4 interface and adds `layoutDirection` to the creation params.
20+
21+
## 1.9.2
22+
23+
* Fixes avoid_redundant_argument_values lint warnings and minor typos.
24+
* Ignores unnecessary import warnings in preparation for [upcoming Flutter changes](https://github.com/flutter/flutter/pull/106316).
25+
* Adds missing build params for v4 WebViewWidget interface.
26+
27+
## 1.9.1
28+
29+
* Ignores unnecessary import warnings in preparation for [upcoming Flutter changes](https://github.com/flutter/flutter/pull/104231).
30+
31+
## 1.9.0
32+
33+
* Adds the first iteration of the v4 webview_flutter interface implementation.
34+
* Removes unnecessary imports.
35+
36+
## 1.8.2
37+
38+
* Migrates from `ui.hash*` to `Object.hash*`.
39+
* Updates minimum Flutter version to 2.5.0.
40+
41+
## 1.8.1
42+
43+
* Update to use the `verify` method introduced in platform_plugin_interface 2.1.0.
44+
45+
## 1.8.0
46+
47+
* Adds the `loadFlutterAsset` method to the platform interface.
48+
49+
## 1.7.0
50+
51+
* Add an option to set the background color of the webview.
52+
53+
## 1.6.1
54+
55+
* Revert deprecation of `clearCookies` in WebViewPlatform for later deprecation.
56+
57+
## 1.6.0
58+
59+
* Adds platform interface for cookie manager.
60+
* Deprecates `clearCookies` in WebViewPlatform in favour of `CookieManager#clearCookies`.
61+
* Expanded `CreationParams` to include cookies to be set at webview creation.
62+
63+
## 1.5.2
64+
65+
* Mirgrates from analysis_options_legacy.yaml to the more strict analysis_options.yaml.
66+
67+
## 1.5.1
68+
69+
* Reverts the addition of `onUrlChanged`, which was unintentionally a breaking
70+
change.
71+
72+
## 1.5.0
73+
74+
* Added `onUrlChanged` callback to platform callback handler.
75+
76+
## 1.4.0
77+
78+
* Added `loadFile` and `loadHtml` interface methods.
79+
80+
## 1.3.0
81+
82+
* Added `loadRequest` method to platform interface.
83+
84+
## 1.2.0
85+
86+
* Added `runJavascript` and `runJavascriptReturningResult` interface methods to supersede `evaluateJavascript`.
87+
88+
## 1.1.0
89+
90+
* Add `zoomEnabled` functionality to `WebSettings`.
91+
92+
## 1.0.0
93+
94+
* Extracted platform interface from `webview_flutter`.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Copyright 2013 The Flutter Authors. All rights reserved.
2+
3+
Redistribution and use in source and binary forms, with or without modification,
4+
are permitted provided that the following conditions are met:
5+
6+
* Redistributions of source code must retain the above copyright
7+
notice, this list of conditions and the following disclaimer.
8+
* Redistributions in binary form must reproduce the above
9+
copyright notice, this list of conditions and the following
10+
disclaimer in the documentation and/or other materials provided
11+
with the distribution.
12+
* Neither the name of Google Inc. nor the names of its
13+
contributors may be used to endorse or promote products derived
14+
from this software without specific prior written permission.
15+
16+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
20+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
23+
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# webview_flutter_platform_interface
2+
3+
A common platform interface for the [`webview_flutter`](https://pub.dev/packages/webview_flutter) plugin.
4+
5+
This interface allows platform-specific implementations of the `webview_flutter`
6+
plugin, as well as the plugin itself, to ensure they are supporting the
7+
same interface.
8+
9+
# Usage
10+
11+
To implement a new platform-specific implementation of `webview_flutter`, extend
12+
[`WebviewPlatform`](lib/src/webview_platform.dart) with an implementation that performs the
13+
platform-specific behavior, and when you register your plugin, set the default
14+
`WebviewPlatform` by calling
15+
`WebviewPlatform.instance = MyPlatformWebview()`.
16+
17+
# Note on breaking changes
18+
19+
Strongly prefer non-breaking changes (such as adding a method to the interface)
20+
over breaking changes for this package.
21+
22+
See https://flutter.dev/go/platform-interface-breaking-changes for a discussion
23+
on why a less-clean interface is preferable to a breaking change.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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 '../types/javascript_channel.dart';
6+
import '../types/javascript_message.dart';
7+
8+
/// Utility class for managing named JavaScript channels and forwarding incoming
9+
/// messages on the correct channel.
10+
class JavascriptChannelRegistry {
11+
/// Constructs a [JavascriptChannelRegistry] initializing it with the given
12+
/// set of [JavascriptChannel]s.
13+
JavascriptChannelRegistry(Set<JavascriptChannel>? channels) {
14+
updateJavascriptChannelsFromSet(channels);
15+
}
16+
17+
/// Maps a channel name to a channel.
18+
final Map<String, JavascriptChannel> channels = <String, JavascriptChannel>{};
19+
20+
/// Invoked when a JavaScript channel message is received.
21+
void onJavascriptChannelMessage(String channel, String message) {
22+
final JavascriptChannel? javascriptChannel = channels[channel];
23+
24+
if (javascriptChannel == null) {
25+
throw ArgumentError('No channel registered with name $channel.');
26+
}
27+
28+
javascriptChannel.onMessageReceived(JavascriptMessage(message));
29+
}
30+
31+
/// Updates the set of [JavascriptChannel]s with the new set.
32+
void updateJavascriptChannelsFromSet(Set<JavascriptChannel>? channels) {
33+
this.channels.clear();
34+
if (channels == null) {
35+
return;
36+
}
37+
38+
for (final JavascriptChannel channel in channels) {
39+
this.channels[channel.name] = channel;
40+
}
41+
}
42+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
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+
export 'javascript_channel_registry.dart';
6+
export 'webview_cookie_manager.dart';
7+
export 'webview_platform.dart';
8+
export 'webview_platform_callbacks_handler.dart';
9+
export 'webview_platform_controller.dart';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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:plugin_platform_interface/plugin_platform_interface.dart';
6+
7+
import '../types/webview_cookie.dart';
8+
9+
/// Interface for a platform implementation of a cookie manager.
10+
///
11+
/// Platform implementations should extend this class rather than implement it as `webview_flutter`
12+
/// does not consider newly added methods to be breaking changes. Extending this class
13+
/// (using `extends`) ensures that the subclass will get the default implementation, while
14+
/// platform implementations that `implements` this interface will be broken by newly added
15+
/// [WebViewCookieManagerPlatform] methods.
16+
abstract class WebViewCookieManagerPlatform extends PlatformInterface {
17+
/// Constructs a WebViewCookieManagerPlatform.
18+
WebViewCookieManagerPlatform() : super(token: _token);
19+
20+
static final Object _token = Object();
21+
22+
static WebViewCookieManagerPlatform? _instance;
23+
24+
/// The instance of [WebViewCookieManagerPlatform] to use.
25+
static WebViewCookieManagerPlatform? get instance => _instance;
26+
27+
/// Platform-specific plugins should set this with their own platform-specific
28+
/// class that extends [WebViewCookieManagerPlatform] when they register themselves.
29+
static set instance(WebViewCookieManagerPlatform? instance) {
30+
if (instance == null) {
31+
throw AssertionError(
32+
'Platform interfaces can only be set to a non-null instance');
33+
}
34+
PlatformInterface.verify(instance, _token);
35+
_instance = instance;
36+
}
37+
38+
/// Clears all cookies for all [WebView] instances.
39+
///
40+
/// Returns true if cookies were present before clearing, else false.
41+
Future<bool> clearCookies() {
42+
throw UnimplementedError(
43+
'clearCookies is not implemented on the current platform');
44+
}
45+
46+
/// Sets a cookie for all [WebView] instances.
47+
Future<void> setCookie(WebViewCookie cookie) {
48+
throw UnimplementedError(
49+
'setCookie is not implemented on the current platform');
50+
}
51+
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
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/foundation.dart';
6+
import 'package:flutter/gestures.dart';
7+
import 'package:flutter/widgets.dart';
8+
9+
import '../platform_interface/javascript_channel_registry.dart';
10+
import '../types/types.dart';
11+
import 'webview_platform_callbacks_handler.dart';
12+
import 'webview_platform_controller.dart';
13+
14+
/// Signature for callbacks reporting that a [WebViewPlatformController] was created.
15+
///
16+
/// See also the `onWebViewPlatformCreated` argument for [WebViewPlatform.build].
17+
typedef WebViewPlatformCreatedCallback = void Function(
18+
WebViewPlatformController? webViewPlatformController);
19+
20+
/// Interface for a platform implementation of a WebView.
21+
///
22+
/// [WebView.platform] controls the builder that is used by [WebView].
23+
/// [AndroidWebViewPlatform] and [CupertinoWebViewPlatform] are the default implementations
24+
/// for Android and iOS respectively.
25+
abstract class WebViewPlatform {
26+
/// Builds a new WebView.
27+
///
28+
/// Returns a Widget tree that embeds the created webview.
29+
///
30+
/// `creationParams` are the initial parameters used to setup the webview.
31+
///
32+
/// `webViewPlatformHandler` will be used for handling callbacks that are made by the created
33+
/// [WebViewPlatformController].
34+
///
35+
/// `onWebViewPlatformCreated` will be invoked after the platform specific [WebViewPlatformController]
36+
/// implementation is created with the [WebViewPlatformController] instance as a parameter.
37+
///
38+
/// `gestureRecognizers` specifies which gestures should be consumed by the web view.
39+
/// It is possible for other gesture recognizers to be competing with the web view on pointer
40+
/// events, e.g if the web view is inside a [ListView] the [ListView] will want to handle
41+
/// vertical drags. The web view will claim gestures that are recognized by any of the
42+
/// recognizers on this list.
43+
/// When `gestureRecognizers` is empty or null, the web view will only handle pointer events for gestures that
44+
/// were not claimed by any other gesture recognizer.
45+
///
46+
/// `webViewPlatformHandler` must not be null.
47+
Widget build({
48+
required BuildContext context,
49+
// TODO(amirh): convert this to be the actual parameters.
50+
// I'm starting without it as the PR is starting to become pretty big.
51+
// I'll followup with the conversion PR.
52+
required CreationParams creationParams,
53+
required WebViewPlatformCallbacksHandler webViewPlatformCallbacksHandler,
54+
required JavascriptChannelRegistry javascriptChannelRegistry,
55+
WebViewPlatformCreatedCallback? onWebViewPlatformCreated,
56+
Set<Factory<OneSequenceGestureRecognizer>>? gestureRecognizers,
57+
});
58+
59+
/// Clears all cookies for all [WebView] instances.
60+
///
61+
/// Returns true if cookies were present before clearing, else false.
62+
/// Soon to be deprecated. 'Use `WebViewCookieManagerPlatform.clearCookies` instead.
63+
Future<bool> clearCookies() {
64+
throw UnimplementedError(
65+
'WebView clearCookies is not implemented on the current platform');
66+
}
67+
}

0 commit comments

Comments
 (0)