-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[webview_flutter] Implementation of the webview_flutter_platform_interface package #4302
[webview_flutter] Implementation of the webview_flutter_platform_interface package #4302
Conversation
eb1bb34
to
c3e2fdd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few things from a first pass:
- This is a big enough PR that I'd rather it not do two things at once; let's make moving to a subfolder its own separate precursor PR. (That's actually an example of something that would fail the new check I'm adding.)
- There should be an AUTHORS file for the new package (filed [flutter_plugin_tools] Validate that AUTHORS exists flutter#89680), cloned from the main package as a starting point.
- Because it's a copy rather than a move it's hard to know what (if anything) has changed. Could you separate out a first commit that is just a straight copy of all the relevant files to the new location, then do any changes in separate commits? I see that there's some of that, but, e.g., the new CHANGELOG is in that commit so I know it's not a pure copy. I can't easily see what other actual changes are there to review.
@@ -0,0 +1,3 @@ | |||
## 1.0.0 | |||
|
|||
* Initial open-source release. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This description doesn't really make sense; how about "Extracted platform interface from webview_flutter
"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Much better, thank you. I will pay more attention to this in the future.
void main() { | ||
TestWidgetsFlutterBinding.ensureInitialized(); | ||
|
||
group('$MethodChannelWebViewPlatform', () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know why the plugins repo does so much of this; tests are already grouped by the file they are in. I'd rather just not have a group wrapping all tests. (Logic groups of sets of tests within the file are fine, it's just these top-level ones that seem like noise.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have updated the description so the grouping makes more sense. At the moment there are 2 groups:
- One that tests the API on the
plugin.flutter.io/webview_<channel_id>
method channel; - A second group that tests the API on the
plugins.flutter.io/cookie_manager
method channel.
Creates a new `webview_flutter_platform_interface` directory and adds the following meta-data files: - `AUTHORS`: copied from the `webview_flutter` package and added my name; - `CHANGELOG.md`: new file adding description for release 1.0.0; - `LICENSE`: copied from the `webview_flutter` package; - `README.md`: new file adding the standard platform interface description; - `pubspec.yaml`: new file adding package meta-data for the `webview_flutter_platform_interface` package.
This commit contains a pure copy of the `lib/platform_interface.dart` and `lib/src/webview_method_channel.dart` files from the `webview_flutter` package to the `webview_flutter_platform_interface` package. The `auto_media_playback_policy.dart` and `javascript_mode.dart` contain the `AutoMediaPlaybackPolicy` and `JavascriptMode` enums copied directly from the `webview_flutter/lib/webview_flutter.dart` package. The code doesn't contain any modifications.
Moves all types defined in the `./lib/platform_interface.dart` file into their own respective files. Except for adding the required `import` statements no code has been modified.
The original `webview_flutter/lib/src/webview_method_channel.dart` was not covered by unit-tests. This commit adds unit-tests for all methods in the `webview_method_channel.dart` file that is part of the new platform interface package.
Copies the `JavascriptChannel` and `JavascriptMessage` classes from the `webview_flutter/lib/webview_flutter.dart` file into their own files and expose them through the platform interface. Note: the code has not been modified.
Adds the JavascriptChannelRegistry implementation which is a class that helps managing multiple Javascript channels and sends messages arrived from the native webview control to the correct JavascriptChannel instance in Dart.
This commit modifies the existing code to make use of the JavascriptChannelRegistry class.
e83c6cc
to
a7ece38
Compare
@stuartmorgan I have redone the pull request and divided it into 9 logical commits and added additional explanation with each commit to explain the changes made. I have made al changes based on copied files I done in commit bc79ecd which should make it easier for you to follow the changes. One more thing, to not make to many changes I left the code as-is and did not update it according to the latest I would appreciate it if you could have another look. |
Yes, that should definitely be separate. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for tweaking the commits; much easier to review. LGTM modulo some nits, and getting the format
bots green.
See https://flutter.dev/go/platform-interface-breaking-changes for a discussion | ||
on why a less-clean interface is preferable to a breaking change. | ||
|
||
[1]: ../webview_flutter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This won't work on pub.dev; let's link to https://pub.dev/packages/webview_flutter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
throw UnimplementedError( | ||
"WebView getScrollY is not implemented on the current platform"); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A bunch of the files in this PR don't have the final newline (which causes churn when people touch them using many editors). Could you do a pass to fix that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did a full sweep, thanks for pointing it out.
group('Tests on `plugin.flutter.io/webview_<channel_id>` channel', () { | ||
const int channelId = 1; | ||
const MethodChannel channel = | ||
MethodChannel('plugins.flutter.io/webview_$channelId'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs an auto-formatter pass.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Run the auto-formatter so formatting steps should go green soon.
@@ -0,0 +1,451 @@ | |||
// Copyright 2013 The Flutter Authors. All rights reserved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are the test files in test/src/
rather than just test/
? That's not a standard practice in this repo (or Flutter in generally AFAIK).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is my mistake. I try to keep the directory structure the test is in as close as possible to the directory structure to the file containing the code it is testing.
So in this case when I need to write tests for code that is in the lib/src/types/javascript_channel.dart
I create a test file at test/src/types/javascript_channel_test.dart
. It helps me navigate to the correct test file if I am looking to extend certain tests for an existing file.
Updated links to markdown links as the footnote notation doesn't render correctly on pub.dev.
Oh, I didn't consider this effect of my change to the Windows bots... the two "Windows Plugins" jobs are never going to run because the builders no longer exist for them (I renamed them). You'll need to sync in the last master. |
No worries, will do in a few minutes. |
…_architecture_part_2
…orm_interface package (flutter/plugins#4302)
…orm_interface package (flutter/plugins#4302)
* master: [webview_flutter] Add download listener to Android webview (flutter#4322) [video_player] add support for content-uri based videos (flutter#4330) [webview_flutter] Implementation of the webview_flutter_platform_interface package (flutter#4302) [camera] Bump minimum Flutter version and iOS deployment target (flutter#4327) [video_player] interface: add support for content-uri based videos (android only) (flutter#4307) Ignore unnecessary_import in legacy analysis options (flutter#4129) [ci] Enable the new Windows targets (flutter#4325) # Conflicts: # packages/webview_flutter/webview_flutter/android/src/main/java/io/flutter/plugins/webviewflutter/FlutterWebView.java # packages/webview_flutter/webview_flutter/android/src/main/java/io/flutter/plugins/webviewflutter/WebViewBuilder.java
This PR adds the webview_flutter_platform_interface package which can be used by plugin developers to add platform support to the webview_flutter plugin.
flutter/flutter#86286
Pre-launch Checklist
dart format
.)[shared_preferences]
///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.