Skip to content

Commit b307e0f

Browse files
Revert "WebView JavasScript channels Android implementation. (flutter#1130)"
This reverts commit ad0c63e.
1 parent b96792c commit b307e0f

File tree

2 files changed

+3
-79
lines changed

2 files changed

+3
-79
lines changed

packages/webview_flutter/android/src/main/java/io/flutter/plugins/webviewflutter/FlutterWebView.java

Lines changed: 3 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,22 @@
99
import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
1010
import io.flutter.plugin.common.MethodChannel.Result;
1111
import io.flutter.plugin.platform.PlatformView;
12-
import java.util.List;
1312
import java.util.Map;
1413

1514
public class FlutterWebView implements PlatformView, MethodCallHandler {
16-
private static final String JS_CHANNEL_NAMES_FIELD = "javascriptChannelNames";
1715
private final WebView webView;
1816
private final MethodChannel methodChannel;
1917

2018
@SuppressWarnings("unchecked")
2119
FlutterWebView(Context context, BinaryMessenger messenger, int id, Map<String, Object> params) {
2220
webView = new WebView(context);
23-
24-
methodChannel = new MethodChannel(messenger, "plugins.flutter.io/webview_" + id);
25-
methodChannel.setMethodCallHandler(this);
26-
27-
applySettings((Map<String, Object>) params.get("settings"));
28-
29-
if (params.containsKey(JS_CHANNEL_NAMES_FIELD)) {
30-
registerJavaScriptChannelNames((List<String>) params.get(JS_CHANNEL_NAMES_FIELD));
31-
}
32-
3321
if (params.containsKey("initialUrl")) {
3422
String url = (String) params.get("initialUrl");
3523
webView.loadUrl(url);
3624
}
25+
applySettings((Map<String, Object>) params.get("settings"));
26+
methodChannel = new MethodChannel(messenger, "plugins.flutter.io/webview_" + id);
27+
methodChannel.setMethodCallHandler(this);
3728
}
3829

3930
@Override
@@ -71,12 +62,6 @@ public void onMethodCall(MethodCall methodCall, Result result) {
7162
case "evaluateJavascript":
7263
evaluateJavaScript(methodCall, result);
7364
break;
74-
case "addJavascriptChannels":
75-
addJavaScriptChannels(methodCall, result);
76-
break;
77-
case "removeJavascriptChannels":
78-
removeJavaScriptChannels(methodCall, result);
79-
break;
8065
default:
8166
result.notImplemented();
8267
}
@@ -140,22 +125,6 @@ public void onReceiveValue(String value) {
140125
});
141126
}
142127

143-
@SuppressWarnings("unchecked")
144-
private void addJavaScriptChannels(MethodCall methodCall, Result result) {
145-
List<String> channelNames = (List<String>) methodCall.arguments;
146-
registerJavaScriptChannelNames(channelNames);
147-
result.success(null);
148-
}
149-
150-
@SuppressWarnings("unchecked")
151-
private void removeJavaScriptChannels(MethodCall methodCall, Result result) {
152-
List<String> channelNames = (List<String>) methodCall.arguments;
153-
for (String channelName : channelNames) {
154-
webView.removeJavascriptInterface(channelName);
155-
}
156-
result.success(null);
157-
}
158-
159128
private void applySettings(Map<String, Object> settings) {
160129
for (String key : settings.keySet()) {
161130
switch (key) {
@@ -181,13 +150,6 @@ private void updateJsMode(int mode) {
181150
}
182151
}
183152

184-
private void registerJavaScriptChannelNames(List<String> channelNames) {
185-
for (String channelName : channelNames) {
186-
webView.addJavascriptInterface(
187-
new JavaScriptChannel(methodChannel, channelName), channelName);
188-
}
189-
}
190-
191153
@Override
192154
public void dispose() {}
193155
}

packages/webview_flutter/android/src/main/java/io/flutter/plugins/webviewflutter/JavaScriptChannel.java

Lines changed: 0 additions & 38 deletions
This file was deleted.

0 commit comments

Comments
 (0)