Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
e7389cc
[ci] migrate to Apple Silicon
fkorotkov May 10, 2022
c71b646
Fix RunnerTest config for google_maps_flutter
stuartmorgan-g May 11, 2022
eea37d5
changelog
stuartmorgan-g May 11, 2022
49e16fc
Move some tasks back to Intel
stuartmorgan-g May 11, 2022
e31c427
Log unexpeted FlutterErrors in tests instead of throwing
stuartmorgan-g May 11, 2022
7f6506c
Add temp debug NSLog statements
stuartmorgan-g May 11, 2022
225df85
Remove failed logging, add some details
stuartmorgan-g May 12, 2022
91ea52d
Don't assert for overfullfillment
fkorotkov May 12, 2022
d65a77f
Fullfill only when initialized
fkorotkov May 12, 2022
1ddf2a7
Move linting back to ARM
stuartmorgan-g May 13, 2022
001e214
Log event for debugging
fkorotkov May 13, 2022
5ceab37
Remove NSLog
stuartmorgan-g May 13, 2022
d68340a
Remove duplicate details from error
stuartmorgan-g May 13, 2022
6b47358
video_player changelog
stuartmorgan-g May 13, 2022
9caf835
iPhone 12
fkorotkov May 15, 2022
b490760
Reverted iPhone version
fkorotkov May 15, 2022
7fffeb9
Try Xcode 13.4 and macOS 12.4
fkorotkov May 16, 2022
4e0b259
Revert "Try Xcode 13.4 and macOS 12.4"
fkorotkov May 16, 2022
9713866
Revert "Revert "Try Xcode 13.4 and macOS 12.4""
fkorotkov May 16, 2022
60eb2f5
Try experimental config
fkorotkov May 17, 2022
d9d7875
Revert "Try experimental config"
fkorotkov May 18, 2022
a3771c4
Use only one simulator
fkorotkov May 18, 2022
71e2cb5
Set timeout to not waste resources in case of a hanging
fkorotkov May 18, 2022
d44df7c
[tools] Fix `publish` flag calculation (#5694)
stuartmorgan-g May 14, 2022
8ee7bd8
[camera]handle iOS camera access permission (#5215)
hellohuanlin May 14, 2022
2ccc39e
[image_picker] Fix 'messages.g.h' file not found (#5635)
co-kevin May 16, 2022
29241ad
[ci] Manually roll Flutter master (#5765)
stuartmorgan-g May 16, 2022
1fd508f
Roll Flutter from 036cae36697a to bf7a32628eef (49 revisions) (#5768)
engine-flutter-autoroll May 17, 2022
33934de
Roll Flutter from bf7a32628eef to bb9bbc601345 (1 revision) (#5769)
engine-flutter-autoroll May 17, 2022
63a6039
Roll Flutter from bb9bbc601345 to fd312f1ccff9 (1 revision) (#5770)
engine-flutter-autoroll May 17, 2022
c1c1332
Roll Flutter from fd312f1ccff9 to c248854d176b (1 revision) (#5771)
engine-flutter-autoroll May 17, 2022
f586229
[in_app_purchase] fixed a memory leak error (#5358)
yimao009 May 17, 2022
2656002
[local_auth] Windows support. (#4806)
azchohfi May 17, 2022
9cdd4b5
[google_sign_in_platform_interface] Add availability to mock models (…
Hwan-seok May 17, 2022
74042c0
Update cirrus secret. (#5774)
godofredoc May 17, 2022
18283a7
Add more Android plugin owners (#5624)
stuartmorgan-g May 17, 2022
66e56f0
[video_player]: Bump exoplayer from 2.17.0 to 2.17.1 in /packages/vid…
dependabot[bot] May 17, 2022
9da2a72
[tools] Validate example READMEs (#5775)
stuartmorgan-g May 18, 2022
c62a7ed
[webview_flutter] Initial v4.0 platform interface implementation (#5…
mvanbeusekom May 18, 2022
bd40099
[camera] Request access permission for audio (#5766)
hellohuanlin May 18, 2022
2e81edb
Roll Flutter from c248854d176b to 1994027986cf (1 revision) (#5777)
engine-flutter-autoroll May 18, 2022
f3d955a
[ci/tools] Add iOS/macOS analysis to catch deprecated code (#5778)
stuartmorgan-g May 18, 2022
72c1752
Add more CODEOWNERS (#5779)
stuartmorgan-g May 18, 2022
bf35c1b
[tools] Add `update-release-info` (#5643)
stuartmorgan-g May 18, 2022
dfa3e84
[local_auth] Adds federated Windows support (#5776)
azchohfi May 19, 2022
b0c19f0
[google_sign_in] Upgrade to GoogleSignIn 6.2, support arm64 simulator…
jmagman May 19, 2022
9d1311d
Roll Flutter from 1994027986cf to a4a8e73bce15 (31 revisions) (#5782)
engine-flutter-autoroll May 19, 2022
afc26ec
[ci] Updates iOS deprecation check to iOS 13 (#5786)
stuartmorgan-g May 19, 2022
216b216
[various] Set minimum Flutter versions to 2.8 (#5792)
stuartmorgan-g May 19, 2022
87cd4e7
[google_maps_flutter_web] Remove custom analysis file. (#5791)
ditman May 20, 2022
82cbfc8
[path_provider] Fix integration tests on macOS (#5773)
stuartmorgan-g May 20, 2022
0fcac82
iPhone 12
fkorotkov May 15, 2022
fc971fb
Use only one simulator
fkorotkov May 18, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[webview_flutter] Initial v4.0 platform interface implementation (#5109)
  • Loading branch information
mvanbeusekom authored and fkorotkov committed May 20, 2022
commit c62a7ede1766dab3d7e8d67b4b0429aea3cc2a59
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## NEXT
## 1.9.0

* Adds the first iteration of the v4 webview_flutter interface implementation.
* Removes unnecessary imports.

## 1.8.2
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'dart:async';

import 'package:flutter/foundation.dart';
import 'package:plugin_platform_interface/plugin_platform_interface.dart';

import 'webview_platform.dart';

/// An interface defining navigation events that occur on the native platform.
///
/// The [PlatformWebViewController] is notifying this delegate on events that
/// happened on the platform's webview. Platform implementations should
/// implement this class and pass an instance to the [PlatformWebViewController].
abstract class PlatformNavigationDelegate extends PlatformInterface {
/// Creates a new [PlatformNavigationDelegate]
factory PlatformNavigationDelegate(
PlatformNavigationDelegateCreationParams params) {
final PlatformNavigationDelegate callbackDelegate =
WebViewPlatform.instance!.createPlatformNavigationDelegate(params);
PlatformInterface.verify(callbackDelegate, _token);
return callbackDelegate;
}

/// Used by the platform implementation to create a new [PlatformNavigationDelegate].
///
/// Should only be used by platform implementations because they can't extend
/// a class that only contains a factory constructor.
@protected
PlatformNavigationDelegate.implementation(this.params) : super(token: _token);

static final Object _token = Object();

/// The parameters used to initialize the [PlatformNavigationDelegate].
final PlatformNavigationDelegateCreationParams params;

/// Invoked when a navigation request is pending.
///
/// See [PlatformWebViewController.setPlatformNavigationDelegate].
Future<void> setOnNavigationRequest(
FutureOr<bool> Function({required String url, required bool isForMainFrame})
onNavigationRequest,
) {
throw UnimplementedError(
'setOnNavigationRequest is not implemented on the current platform.');
}

/// Invoked when a page has started loading.
///
/// See [PlatformWebViewController.setPlatformNavigationDelegate].
Future<void> setOnPageStarted(
void Function(String url) onPageStarted,
) {
throw UnimplementedError(
'setOnPageStarted is not implemented on the current platform.');
}

/// Invoked when a page has finished loading.
///
/// See [PlatformWebViewController.setPlatformNavigationDelegate].
Future<void> setOnPageFinished(
void Function(String url) onPageFinished,
) {
throw UnimplementedError(
'setOnPageFinished is not implemented on the current platform.');
}

/// Invoked when a page is loading to report the progress.
///
/// See [PlatformWebViewController.setPlatformNavigationDelegate].
Future<void> setOnProgress(
void Function(int progress) onProgress,
) {
throw UnimplementedError(
'setOnProgress is not implemented on the current platform.');
}

/// Invoked when a resource loading error occurred.
///
/// See [PlatformWebViewController.setPlatformNavigationDelegate].
Future<void> setOnWebResourceError(
void Function(WebResourceError error) onWebResourceError,
) {
throw UnimplementedError(
'setOnWebResourceError is not implemented on the current platform.');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,285 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'dart:math';
import 'dart:ui';

import 'package:flutter/foundation.dart';
import 'package:plugin_platform_interface/plugin_platform_interface.dart';

import 'platform_navigation_delegate.dart';
import 'webview_platform.dart';

/// Interface for a platform implementation of a web view controller.
///
/// Platform implementations should extend this class rather than implement it
/// as `webview_flutter` does not consider newly added methods to be breaking
/// changes. Extending this class (using `extends`) ensures that the subclass
/// will get the default implementation, while platform implementations that
/// `implements` this interface will be broken by newly added
/// [PlatformWebViewCookieManager] methods.
abstract class PlatformWebViewController extends PlatformInterface {
/// Creates a new [PlatformWebViewController]
factory PlatformWebViewController(
PlatformWebViewControllerCreationParams params) {
final PlatformWebViewController webViewControllerDelegate =
WebViewPlatform.instance!.createPlatformWebViewController(params);
PlatformInterface.verify(webViewControllerDelegate, _token);
return webViewControllerDelegate;
}

/// Used by the platform implementation to create a new [PlatformWebViewController].
///
/// Should only be used by platform implementations because they can't extend
/// a class that only contains a factory constructor.
@protected
PlatformWebViewController.implementation(this.params) : super(token: _token);

static final Object _token = Object();

/// The parameters used to initialize the [PlatformWebViewController].
final PlatformWebViewControllerCreationParams params;

/// Loads the file located on the specified [absoluteFilePath].
///
/// The [absoluteFilePath] parameter should contain the absolute path to the
/// file as it is stored on the device. For example:
/// `/Users/username/Documents/www/index.html`.
///
/// Throws an ArgumentError if the [absoluteFilePath] does not exist.
Future<void> loadFile(
String absoluteFilePath,
) {
throw UnimplementedError(
'loadFile is not implemented on the current platform');
}

/// Loads the Flutter asset specified in the pubspec.yaml file.
///
/// Throws an ArgumentError if [key] is not part of the specified assets
/// in the pubspec.yaml file.
Future<void> loadFlutterAsset(
String key,
) {
throw UnimplementedError(
'loadFlutterAsset is not implemented on the current platform');
}

/// Loads the supplied HTML string.
///
/// The [baseUrl] parameter is used when resolving relative URLs within the
/// HTML string.
Future<void> loadHtmlString(
String html, {
String? baseUrl,
}) {
throw UnimplementedError(
'loadHtmlString is not implemented on the current platform');
}

/// Makes a specific HTTP request ands loads the response in the webview.
///
/// [WebViewRequest.method] must be one of the supported HTTP methods
/// in [WebViewRequestMethod].
///
/// If [WebViewRequest.headers] is not empty, its key-value pairs will be
/// added as the headers for the request.
///
/// If [WebViewRequest.body] is not null, it will be added as the body
/// for the request.
///
/// Throws an ArgumentError if [WebViewRequest.uri] has empty scheme.
Future<void> loadRequest(
LoadRequestParams params,
) {
throw UnimplementedError(
'loadRequest is not implemented on the current platform');
}

/// Accessor to the current URL that the WebView is displaying.
///
/// If no URL was ever loaded, returns `null`.
Future<String?> currentUrl() {
throw UnimplementedError(
'currentUrl is not implemented on the current platform');
}

/// Checks whether there's a back history item.
Future<bool> canGoBack() {
throw UnimplementedError(
'canGoBack is not implemented on the current platform');
}

/// Checks whether there's a forward history item.
Future<bool> canGoForward() {
throw UnimplementedError(
'canGoForward is not implemented on the current platform');
}

/// Goes back in the history of this WebView.
///
/// If there is no back history item this is a no-op.
Future<void> goBack() {
throw UnimplementedError(
'goBack is not implemented on the current platform');
}

/// Goes forward in the history of this WebView.
///
/// If there is no forward history item this is a no-op.
Future<void> goForward() {
throw UnimplementedError(
'goForward is not implemented on the current platform');
}

/// Reloads the current URL.
Future<void> reload() {
throw UnimplementedError(
'reload is not implemented on the current platform');
}

/// Clears all caches used by the [WebView].
///
/// The following caches are cleared:
/// 1. Browser HTTP Cache.
/// 2. [Cache API](https://developers.google.com/web/fundamentals/instant-and-offline/web-storage/cache-api) caches.
/// These are not yet supported in iOS WkWebView. Service workers tend to use this cache.
/// 3. Application cache.
Future<void> clearCache() {
throw UnimplementedError(
'clearCache is not implemented on the current platform');
}

/// Clears the local storage used by the [WebView].
Future<void> clearLocalStorage() {
throw UnimplementedError(
'clearLocalStorage is not implemented on the current platform');
}

/// Sets the [PlatformNavigationDelegate] containing the callback methods that
/// are called during navigation events.
Future<void> setPlatformNavigationDelegate(
PlatformNavigationDelegate handler) {
throw UnimplementedError(
'setPlatformNavigationDelegate is not implemented on the current platform');
}

/// Runs the given JavaScript in the context of the current page.
///
/// The Future completes with an error if a JavaScript error occurred.
Future<void> runJavaScript(String javaScript) {
throw UnimplementedError(
'runJavaScript is not implemented on the current platform');
}

/// Runs the given JavaScript in the context of the current page, and returns the result.
///
/// The Future completes with an error if a JavaScript error occurred, or if the
/// type the given expression evaluates to is unsupported. Unsupported values include
/// certain non-primitive types on iOS, as well as `undefined` or `null` on iOS 14+.
Future<String> runJavaScriptReturningResult(String javaScript) {
throw UnimplementedError(
'runJavaScriptReturningResult is not implemented on the current platform');
}

/// Adds a new JavaScript channel to the set of enabled channels.
Future<void> addJavaScriptChannel(
JavaScriptChannelParams javaScriptChannelParams,
) {
throw UnimplementedError(
'addJavaScriptChannel is not implemented on the current platform');
}

/// Removes the JavaScript channel with the matching name from the set of
/// enabled channels.
///
/// This disables the channel with the matching name if it was previously
/// enabled through the [addJavaScriptChannel].
Future<void> removeJavaScriptChannel(String javaScriptChannelName) {
throw UnimplementedError(
'removeJavaScriptChannel is not implemented on the current platform');
}

/// Returns the title of the currently loaded page.
Future<String?> getTitle() {
throw UnimplementedError(
'getTitle is not implemented on the current platform');
}

/// Set the scrolled position of this view.
///
/// The parameters `x` and `y` specify the position to scroll to in WebView pixels.
Future<void> scrollTo(int x, int y) {
throw UnimplementedError(
'scrollTo is not implemented on the current platform');
}

/// Move the scrolled position of this view.
///
/// The parameters `x` and `y` specify the amount of WebView pixels to scroll by.
Future<void> scrollBy(int x, int y) {
throw UnimplementedError(
'scrollBy is not implemented on the current platform');
}

/// Return the current scroll position of this view.
///
/// Scroll position is measured from the top left.
Future<Point<int>> getScrollPosition() {
throw UnimplementedError(
'getScrollPosition is not implemented on the current platform');
}

/// Whether to enable the platform's webview content debugging tools.
Future<void> enableDebugging(bool enabled) {
throw UnimplementedError(
'enableDebugging is not implemented on the current platform');
}

/// Whether to allow swipe based navigation on supported platforms.
Future<void> enableGestureNavigation(bool enabled) {
throw UnimplementedError(
'enableGestureNavigation is not implemented on the current platform');
}

/// Whhether to support zooming using its on-screen zoom controls and gestures.
Future<void> enableZoom(bool enabled) {
throw UnimplementedError(
'enableZoom is not implemented on the current platform');
}

/// Set the current background color of this view.
Future<void> setBackgroundColor(Color color) {
throw UnimplementedError(
'setBackgroundColor is not implemented on the current platform');
}

/// Sets the JavaScript execution mode to be used by the webview.
Future<void> setJavaScriptMode(JavaScriptMode javaScriptMode) {
throw UnimplementedError(
'setJavaScriptMode is not implemented on the current platform');
}

/// Sets the value used for the HTTP `User-Agent:` request header.
Future<void> setUserAgent(String? userAgent) {
throw UnimplementedError(
'setUserAgent is not implemented on the current platform');
}
}

/// Describes the parameters necessary for registering a JavaScript channel.
class JavaScriptChannelParams {
/// Creates a new [JavaScriptChannelParams] object.
JavaScriptChannelParams({
required this.name,
required this.onMessageReceived,
});

/// The name that identifies the JavaScript channel.
final String name;

/// The callback method that is invoked when a [JavaScriptMessage] is
/// received.
final void Function(JavaScriptMessage) onMessageReceived;
}
Loading