Bug 1728669 - Simplify GeckoView:WebExtension:Connect/Message handlers r=agi

Differential Revision: https://phabricator.services.mozilla.com/D124260
This commit is contained in:
Rob Wu 2021-09-01 21:57:20 +00:00
Родитель 18d37eb7a8
Коммит 8bf1867b97
2 изменённых файлов: 6 добавлений и 11 удалений

Просмотреть файл

@ -724,15 +724,7 @@ public class WebExtensionController {
return;
}
final GeckoBundle senderBundle;
if ("GeckoView:WebExtension:Connect".equals(event) ||
"GeckoView:WebExtension:Message".equals(event)) {
senderBundle = bundle.getBundle("sender");
} else {
senderBundle = bundle;
}
extensionFromBundle(senderBundle).accept(extension -> {
extensionFromBundle(bundle).accept(extension -> {
if ("GeckoView:WebExtension:NewTab".equals(event)) {
newTab(message, extension);
return;
@ -767,6 +759,9 @@ public class WebExtensionController {
download(message, extension);
return;
}
// GeckoView:WebExtension:Connect and GeckoView:WebExtension:Message
// are handled below.
final String nativeApp = bundle.getString("nativeApp");
if (nativeApp == null) {
if (BuildConfig.DEBUG) {
@ -776,6 +771,7 @@ public class WebExtensionController {
return;
}
final GeckoBundle senderBundle = bundle.getBundle("sender");
final WebExtension.MessageSender sender = fromBundle(extension, senderBundle, session);
if (sender == null) {
if (callback != null) {

Просмотреть файл

@ -221,8 +221,6 @@ class EmbedderPort {
class GeckoViewConnection {
constructor(sender, target, nativeApp, allowContentMessaging) {
this.sender = sender;
// Map from the extension MessageSender to the android GeckoBundle format.
sender.extensionId = sender.id;
this.target = target;
this.nativeApp = nativeApp;
this.allowContentMessaging = allowContentMessaging;
@ -265,6 +263,7 @@ class GeckoViewConnection {
sender: this.sender,
data,
portId,
extensionId: this.sender.id,
nativeApp: this.nativeApp,
};