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

Commit

Permalink
[webview_flutter_platform_interface] Updates platform interface to ne…
Browse files Browse the repository at this point in the history
…w interface (#6846)

* Set new interface in main

* update pubspec changelog and readme

* exclude from all plugins app test

* delete all of platform interface

* add all back to platform interface
  • Loading branch information
bparrishMines authored Dec 15, 2022
1 parent 3a093e4 commit 78de28c
Show file tree
Hide file tree
Showing 58 changed files with 606 additions and 1,539 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 2.0.0

* **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)
for more details.
* **Breaking Change**: Removes MethodChannel implementation of interface. All platform
implementations will now need to create their own by implementing `WebViewPlatform`.

## 1.9.5

* Updates code for `no_leading_underscores_for_local_identifiers` lint.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ same interface.
# Usage

To implement a new platform-specific implementation of `webview_flutter`, extend
[`WebviewPlatform`](lib/src/platform_interface/webview_platform.dart) with an implementation that performs the
[`WebviewPlatform`](lib/src/webview_platform.dart) with an implementation that performs the
platform-specific behavior, and when you register your plugin, set the default
`WebviewPlatform` by calling
`WebviewPlatform.setInstance(MyPlatformWebview())`.
`WebviewPlatform.instance = MyPlatformWebview()`.

# Note on breaking changes

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// 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.

/// A message that was sent by JavaScript code running in a [WebView].
class JavascriptMessage {
/// Constructs a JavaScript message object.
///
/// The `message` parameter must not be null.
const JavascriptMessage(this.message) : assert(message != null);

/// The contents of the message that was sent by the JavaScript code.
final String message;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// found in the LICENSE file.

/// Describes the state of JavaScript support in a given web view.
enum JavaScriptMode {
enum JavascriptMode {
/// JavaScript execution is disabled.
disabled,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

export 'auto_media_playback_policy.dart';
export 'creation_params.dart';
export 'javascript_channel.dart';
export 'javascript_message.dart';
export 'javascript_mode.dart';
export 'load_request_params.dart';
export 'platform_navigation_delegate_creation_params.dart';
export 'platform_webview_controller_creation_params.dart';
export 'platform_webview_cookie_manager_creation_params.dart';
export 'platform_webview_widget_creation_params.dart';
export 'web_resource_error.dart';
export 'web_resource_error_type.dart';
export 'web_settings.dart';
export 'webview_cookie.dart';
export 'webview_request.dart';
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// 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 'web_resource_error_type.dart';

/// Error returned in `WebView.onWebResourceError` when a web resource loading error has occurred.
class WebResourceError {
/// Creates a new [WebResourceError]
///
/// A user should not need to instantiate this class, but will receive one in
/// [WebResourceErrorCallback].
WebResourceError({
required this.errorCode,
required this.description,
this.domain,
this.errorType,
this.failingUrl,
}) : assert(errorCode != null),
assert(description != null);

/// Raw code of the error from the respective platform.
///
/// On Android, the error code will be a constant from a
/// [WebViewClient](https://developer.android.com/reference/android/webkit/WebViewClient#summary) and
/// will have a corresponding [errorType].
///
/// On iOS, the error code will be a constant from `NSError.code` in
/// Objective-C. See
/// https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/ErrorHandlingCocoa/ErrorObjectsDomains/ErrorObjectsDomains.html
/// for more information on error handling on iOS. Some possible error codes
/// can be found at https://developer.apple.com/documentation/webkit/wkerrorcode?language=objc.
final int errorCode;

/// The domain of where to find the error code.
///
/// This field is only available on iOS and represents a "domain" from where
/// the [errorCode] is from. This value is taken directly from an `NSError`
/// in Objective-C. See
/// https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/ErrorHandlingCocoa/ErrorObjectsDomains/ErrorObjectsDomains.html
/// for more information on error handling on iOS.
final String? domain;

/// Description of the error that can be used to communicate the problem to the user.
final String description;

/// The type this error can be categorized as.
///
/// This will never be `null` on Android, but can be `null` on iOS.
final WebResourceErrorType? errorType;

/// Gets the URL for which the resource request was made.
///
/// This value is not provided on iOS. Alternatively, you can keep track of
/// the last values provided to [WebViewPlatformController.loadUrl].
final String? failingUrl;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:flutter/foundation.dart';

/// A cookie that can be set globally for all web views using [WebViewCookieManagerPlatform].
@immutable
/// A cookie that can be set globally for all web views
/// using [WebViewCookieManagerPlatform].
class WebViewCookie {
/// Creates a new [WebViewCookieDelegate]
const WebViewCookie({
required this.name,
required this.value,
required this.domain,
this.path = '/',
});
/// Constructs a new [WebViewCookie].
const WebViewCookie(
{required this.name,
required this.value,
required this.domain,
this.path = '/'});

/// The cookie-name of the cookie.
///
Expand All @@ -33,9 +30,20 @@ class WebViewCookie {
/// https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-rfc6265bis-02#section-4.1.1
final String domain;

/// The path-value of the cookie, set to `/` by default.
/// The path-value of the cookie.
/// Is set to `/` in the constructor by default.
///
/// Its value should match "path-value" in RFC6265bis:
/// https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-rfc6265bis-02#section-4.1.1
final String path;

/// Serializes the [WebViewCookie] to a Map<String, String>.
Map<String, String> toJson() {
return <String, String>{
'name': name,
'value': value,
'domain': domain,
'path': path
};
}
}
Loading

0 comments on commit 78de28c

Please sign in to comment.