-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[webview_flutter_wkwebview] Updates the internal wrapper to use @ProxyApi
from pigeon
#8311
base: main
Are you sure you want to change the base?
Changes from all commits
c432fd0
5948bf4
f75f6b1
859c3d3
5496891
999bf22
b5930f8
913b245
9dbf0a5
5050376
5135ffe
24f601f
2d7b482
e1281ba
13dbc4d
bee1811
ff64f90
419a2eb
1740a29
389788e
40ae802
13fc34c
b15cdde
7dcc650
0d22adf
a35c48e
f0fc827
e6fe379
6494a65
07f3410
3ad8d9f
85fa2b2
98aee69
f0b0a94
cbc0856
b863f4d
fa4c951
49a1a05
5e5781f
97d6e96
bf679bf
ebe0ba9
7eb6fdf
f93a7cc
b485d72
7d39659
f6a041b
a566208
ec576a4
068942a
612ceb8
edcd528
f204985
c63fa97
fcd8b6a
54043b4
869da71
c922725
41b9e19
81fd166
daf7e50
54bfff1
f14a81e
b41c21e
349c0f7
d512f44
d494275
bfa91ce
bff9db6
0cdf137
3d76c72
c236616
5190205
00d1ecd
dd70fa2
a080026
668cdeb
8816103
1b23304
ffb8b9c
c0e5ab3
a302eb2
38c43a2
d4acfda
88dc3bc
882504d
943d55c
ae8dc8c
9981881
0db825e
66b37e9
6ebba32
edabb71
e488ab4
e01b4b0
8ce00bb
88df578
64a9c4d
ff705af
2474f2f
babc179
56083c5
973e2be
1d43b03
d03f8fc
53d8aef
50c3e76
e251caa
a3eed42
c016464
3004001
52cae3a
3c14d7f
ec28dae
30b49a3
f91b734
f883a5b
538e24b
47afa83
701ab08
3a59e7e
d8b7c83
793ef57
787df3e
9b8548b
f5ec093
ad3d45c
9242d92
bd54c6d
4c39451
3291608
ab9210e
20e9791
a4b2c85
ddadc15
fb0bc68
4fb75b6
109fb15
814b33f
79e57a8
e42c018
1f24e57
ec50474
c8417c6
25d90fd
de9f446
3e6f3cf
ab4dac6
fb0649c
8f98ec1
80588ac
6b9f199
1e16ac4
44c8bc0
f1c874b
48b3d4d
05f4fcd
d2c657b
7fb5ac4
3a477c3
449930a
2a9896f
11a3d90
0096db3
48957f7
d707b60
afa75fd
5098045
e5bab49
8a0c9e2
7806985
0a81947
082e628
7b06141
beed9f5
a0c595f
0763edb
86bc1a2
ef63401
183d263
8b1b448
adcc442
19af387
7f01bd1
dc138c4
9dcf6f2
9e3b41e
eff8031
98bab3e
2cb82a2
230bdac
a2f9cd5
7aa551b
f6df68b
0fccbdc
fc57cbf
9eeabc7
6a8c6ae
644c204
56d57b4
4c38801
d20fbcf
129aeda
d9bd5b2
6ac9d27
57065b7
900786b
0cad230
700af73
7dfb124
04384e3
d3811a6
b609bc4
95b6cc5
122524c
9f4de6b
926f4d0
8ae290e
46bc96b
d335c3a
0481342
7600657
4472130
7e4d554
a3e7538
854e470
a53db25
976750a
59254d7
c0d3558
d0847df
0798846
27a409e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Contributing to `webview_flutter_wkwebview` | ||
|
||
Please start by taking a look at the general guide to contributing to the `flutter/packages` repo: | ||
https://github.com/flutter/packages/blob/main/CONTRIBUTING.md | ||
|
||
## Package Structure | ||
|
||
This plugin serves as a platform implementation plugin as outlined in [federated plugins](https://docs.flutter.dev/packages-and-plugins/developing-packages#federated-plugins). | ||
The sections below will provide an overview of how this plugin implements this portion with Android. | ||
|
||
For making changes to this package, please take a look at [changing federated plugins](https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins). | ||
|
||
### Quick Overview | ||
|
||
This plugin implements the platform interface provided by `webview_flutter_platform_interface` using | ||
the native WebKit APIs for Android. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "WebKit APIs for Android" -> "WKWebView APIs". |
||
|
||
#### SDK Wrappers | ||
|
||
To access native APIS, this plugins uses Dart wrappers of the native library. The native library is | ||
wrapped using using the `ProxyApi` feature from the `pigeon` package. | ||
|
||
The wrappers for the native library can be updated and modified by changing `pigeons/web_kit.dart`. | ||
|
||
The generated files are located: | ||
* `lib/src/common/web_kit.g.dart` | ||
* `darwin/webview_flutter_wkwebview/Sources/webview_flutter_wkwebview/WebKitLibrary.g.swift` | ||
|
||
To update the wrapper, follow the steps below: | ||
|
||
##### 1. Ensure the project has been built at least once | ||
|
||
Run `flutter build ios --simulator` in `example/`. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this actually necessary to run |
||
|
||
##### 2. Make changes to the respective pigeon file that matches the native SDK | ||
|
||
* WebKit Dependency: https://developer.apple.com/documentation/webkit | ||
* Pigeon file to update: `pigeons/web_kit.dart` | ||
|
||
##### 3. Run the code generator from the terminal | ||
|
||
Run: `dart run pigeon --input pigeons/web_kit.dart` | ||
|
||
##### 4. Update the generated APIs in native code | ||
|
||
Running the `flutter build` command from step 1 again should provide build errors and indicate what | ||
needs to be done. Alternatively, it can be easier to update native code with the platform's specific | ||
IDE: | ||
|
||
Open `example/android/` in a separate Android Studio project. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Open |
||
|
||
##### 5. Write API tests | ||
|
||
Assuming a non-static method or constructor was added to the native wrapper, a native test will need | ||
to be added. | ||
|
||
Tests location: `darwin/Tests` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// 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 XCTest | ||
|
||
@testable import webview_flutter_wkwebview | ||
|
||
class AuthenticationChallengeResponseProxyAPITests: XCTestCase { | ||
func testPigeonDefaultConstructor() { | ||
let registrar = TestProxyApiRegistrar() | ||
let api = registrar.apiDelegate.pigeonApiAuthenticationChallengeResponse(registrar) | ||
|
||
let instance = try? api.pigeonDelegate.pigeonDefaultConstructor( | ||
pigeonApi: api, disposition: UrlSessionAuthChallengeDisposition.useCredential, | ||
credential: URLCredential()) | ||
XCTAssertNotNil(instance) | ||
} | ||
|
||
func testDisposition() { | ||
let registrar = TestProxyApiRegistrar() | ||
let api = registrar.apiDelegate.pigeonApiAuthenticationChallengeResponse(registrar) | ||
|
||
let instance = AuthenticationChallengeResponse( | ||
disposition: .useCredential, credential: URLCredential()) | ||
let value = try? api.pigeonDelegate.disposition(pigeonApi: api, pigeonInstance: instance) | ||
|
||
XCTAssertEqual(value, UrlSessionAuthChallengeDisposition.useCredential) | ||
} | ||
|
||
func testCredential() { | ||
let registrar = TestProxyApiRegistrar() | ||
let api = registrar.apiDelegate.pigeonApiAuthenticationChallengeResponse(registrar) | ||
|
||
let instance = AuthenticationChallengeResponse( | ||
disposition: .useCredential, credential: URLCredential()) | ||
let value = try? api.pigeonDelegate.credential(pigeonApi: api, pigeonInstance: instance) | ||
|
||
XCTAssertEqual(value, instance.credential) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// 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 XCTest | ||
|
||
@testable import webview_flutter_wkwebview | ||
|
||
class ErrorProxyAPITests: XCTestCase { | ||
func testCode() { | ||
let registrar = TestProxyApiRegistrar() | ||
let api = registrar.apiDelegate.pigeonApiNSError(registrar) | ||
|
||
let code = 0 | ||
let instance = NSError(domain: "", code: code) | ||
let value = try? api.pigeonDelegate.code(pigeonApi: api, pigeonInstance: instance) | ||
|
||
XCTAssertEqual(value, Int64(code)) | ||
} | ||
|
||
func testDomain() { | ||
let registrar = TestProxyApiRegistrar() | ||
let api = registrar.apiDelegate.pigeonApiNSError(registrar) | ||
|
||
let domain = "domain" | ||
let instance = NSError(domain: domain, code: 0) | ||
let value = try? api.pigeonDelegate.domain(pigeonApi: api, pigeonInstance: instance) | ||
|
||
XCTAssertEqual(value, domain) | ||
} | ||
|
||
func testUserInfo() { | ||
let registrar = TestProxyApiRegistrar() | ||
let api = registrar.apiDelegate.pigeonApiNSError(registrar) | ||
|
||
let userInfo: [String: String?] = ["some": "info"] | ||
let instance = NSError(domain: "", code: 0, userInfo: userInfo as [String: Any]) | ||
let value = try? api.pigeonDelegate.userInfo(pigeonApi: api, pigeonInstance: instance) | ||
|
||
XCTAssertEqual(value as! [String: String?], userInfo) | ||
} | ||
} |
This file was deleted.
This file was deleted.
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.
"with Android" -> "for iOS and macOS".