-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[webview_flutter_platform_interface] Adds method to receive permission requests #3767
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
Merged
bparrishMines
merged 5 commits into
flutter:main
from
bparrishMines:webview_permissions_interface
Apr 21, 2023
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
800ec2b
interface commit
bparrishMines fca0bab
update pubspec
bparrishMines 87bda0a
Merge branch 'main' of github.com:flutter/packages into webview_permi…
bparrishMines 728c6e2
add export back and todo
bparrishMines 2e68808
fix import lint
bparrishMines File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
packages/webview_flutter/webview_flutter_platform_interface/CHANGELOG.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 98 additions & 0 deletions
98
...webview_flutter_platform_interface/lib/src/types/platform_webview_permission_request.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
// 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 'package:flutter/cupertino.dart'; | ||
|
||
/// Types of resources that can require permissions. | ||
/// | ||
/// Platform specific implementations can create their own resource types. | ||
/// | ||
/// This example demonstrates how to extend the [WebViewPermissionResourceType] | ||
/// to create additional platform-specific types: | ||
/// | ||
/// ```dart | ||
/// class AndroidWebViewPermissionResourceType | ||
/// extends WebViewPermissionResourceType { | ||
/// const AndroidWebViewPermissionResourceType._(super.name); | ||
/// | ||
/// static const AndroidWebViewPermissionResourceType midiSysex = | ||
/// AndroidWebViewPermissionResourceType._('midiSysex'); | ||
/// | ||
/// static const AndroidWebViewPermissionResourceType protectedMediaId = | ||
/// AndroidWebViewPermissionResourceType._('protectedMediaId'); | ||
/// } | ||
///``` | ||
/// | ||
@immutable | ||
class WebViewPermissionResourceType { | ||
/// Constructs a [WebViewPermissionResourceType]. | ||
/// | ||
/// This should only be used by this class and subclasses in platform | ||
/// implementations. | ||
@protected | ||
const WebViewPermissionResourceType(this.name); | ||
|
||
/// Unique name of the resource type. | ||
/// | ||
/// For platform implementations, this should match the name of variable. | ||
final String name; | ||
|
||
/// A media device that can capture video. | ||
static const WebViewPermissionResourceType camera = | ||
WebViewPermissionResourceType('camera'); | ||
|
||
/// A media device that can capture audio. | ||
static const WebViewPermissionResourceType microphone = | ||
WebViewPermissionResourceType('microphone'); | ||
} | ||
|
||
/// Permissions request when web content requests access to protected resources. | ||
/// | ||
/// A response MUST be provided by calling a provided method. | ||
/// | ||
/// Platform specific implementations can add additional methods when extending | ||
/// this class. | ||
/// | ||
/// This example demonstrates how to extend the | ||
/// [PlatformWebViewPermissionRequest] to provide additional platform-specific | ||
/// features: | ||
/// | ||
/// ```dart | ||
/// class WebKitWebViewPermissionRequest extends PlatformWebViewPermissionRequest { | ||
/// const WebKitWebViewPermissionRequest._({ | ||
/// required super.types, | ||
/// required void Function(WKPermissionDecision decision) onDecision, | ||
/// }) : _onDecision = onDecision; | ||
/// | ||
/// final void Function(WKPermissionDecision) _onDecision; | ||
/// | ||
/// @override | ||
/// Future<void> grant() async { | ||
/// _onDecision(WKPermissionDecision.grant); | ||
/// } | ||
/// | ||
/// @override | ||
/// Future<void> deny() async { | ||
/// _onDecision(WKPermissionDecision.deny); | ||
/// } | ||
/// | ||
/// Future<void> prompt() async { | ||
/// _onDecision(WKPermissionDecision.prompt); | ||
/// } | ||
/// } | ||
/// ``` | ||
@immutable | ||
abstract class PlatformWebViewPermissionRequest { | ||
/// Creates a [PlatformWebViewPermissionRequest]. | ||
const PlatformWebViewPermissionRequest({required this.types}); | ||
|
||
/// All resources access has been requested for. | ||
final Set<WebViewPermissionResourceType> types; | ||
|
||
/// Grant permission for the requested resource(s). | ||
Future<void> grant(); | ||
|
||
/// Deny permission for the requested resource(s). | ||
Future<void> deny(); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 is an implementation file and is being used by our platform implementations tests for this export: https://github.com/flutter/packages/blob/main/packages/webview_flutter/webview_flutter_android/test/android_webview_controller_test.dart#L21
I think this export may had caused the IDE to choose this file to import when accessing the classes from this file. Instead of the
package:webview_flutter_platform_interface/webview_flutter_platform_interface.dart
. In the platform PRs I'll change the imports in the tests.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.
Aren't there types that are part of this interface that come from there? Like the param object types?
Uh oh!
There was an error while loading. Please reload this page.
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.
Yes, but it's already included in the
webview_flutter_platform_interface.dart
file: https://github.com/flutter/packages/blob/main/packages/webview_flutter/webview_flutter_platform_interface/lib/webview_flutter_platform_interface.dart#L9