Bug 1618987 - Removed WebExtensionController#setTabDelegate and related methods r=agi,geckoview-reviewers

Updated API docs to reflect removed method

Removed incorrect line to fix some bugs

Updated changelog

Added listener registration back into WebExtension Listener constructor

Differential Revision: https://phabricator.services.mozilla.com/D78977
This commit is contained in:
Grace Bramley-Simmons 2020-06-09 21:49:56 +00:00
Родитель ca91b4a954
Коммит 4ab1c522b1
4 изменённых файлов: 5 добавлений и 105 удалений

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

@ -1652,7 +1652,6 @@ package org.mozilla.geckoview {
method @AnyThread @NonNull public GeckoResult<WebExtension> disable(@NonNull WebExtension, int); method @AnyThread @NonNull public GeckoResult<WebExtension> disable(@NonNull WebExtension, int);
method @AnyThread @NonNull public GeckoResult<WebExtension> enable(@NonNull WebExtension, int); method @AnyThread @NonNull public GeckoResult<WebExtension> enable(@NonNull WebExtension, int);
method @UiThread @Nullable public WebExtensionController.PromptDelegate getPromptDelegate(); method @UiThread @Nullable public WebExtensionController.PromptDelegate getPromptDelegate();
method @UiThread @Nullable @Deprecated public WebExtensionController.TabDelegate getTabDelegate();
method @NonNull @AnyThread public GeckoResult<WebExtension> install(@NonNull String); method @NonNull @AnyThread public GeckoResult<WebExtension> install(@NonNull String);
method @NonNull @AnyThread public GeckoResult<WebExtension> installBuiltIn(@NonNull String); method @NonNull @AnyThread public GeckoResult<WebExtension> installBuiltIn(@NonNull String);
method @AnyThread @NonNull public GeckoResult<List<WebExtension>> list(); method @AnyThread @NonNull public GeckoResult<List<WebExtension>> list();
@ -1660,7 +1659,6 @@ package org.mozilla.geckoview {
method @UiThread public void setDebuggerDelegate(@NonNull WebExtensionController.DebuggerDelegate); method @UiThread public void setDebuggerDelegate(@NonNull WebExtensionController.DebuggerDelegate);
method @UiThread public void setPromptDelegate(@Nullable WebExtensionController.PromptDelegate); method @UiThread public void setPromptDelegate(@Nullable WebExtensionController.PromptDelegate);
method @AnyThread public void setTabActive(@NonNull GeckoSession, boolean); method @AnyThread public void setTabActive(@NonNull GeckoSession, boolean);
method @Deprecated @UiThread public void setTabDelegate(@Nullable WebExtensionController.TabDelegate);
method @NonNull @AnyThread public GeckoResult<Void> uninstall(@NonNull WebExtension); method @NonNull @AnyThread public GeckoResult<Void> uninstall(@NonNull WebExtension);
method @AnyThread @NonNull public GeckoResult<WebExtension> update(@NonNull WebExtension); method @AnyThread @NonNull public GeckoResult<WebExtension> update(@NonNull WebExtension);
} }

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

@ -836,9 +836,6 @@ public class WebExtension {
private boolean mActionDelegateRegistered = false; private boolean mActionDelegateRegistered = false;
private boolean mTabDelegateRegistered = false; private boolean mTabDelegateRegistered = false;
// TODO: remove Bug 1618987
private WebExtensionController.TabDelegate mLegacyTabDelegate;
public GeckoRuntime runtime; public GeckoRuntime runtime;
public Listener(final GeckoRuntime runtime) { public Listener(final GeckoRuntime runtime) {
@ -847,7 +844,7 @@ public class WebExtension {
public Listener(final GeckoSession session) { public Listener(final GeckoSession session) {
this(session, null); this(session, null);
// TODO: Remove Bug 1618987
// Close tab event is forwarded to the main listener so we need to listen // Close tab event is forwarded to the main listener so we need to listen
// to it here. // to it here.
mEventDispatcher.registerUiThreadListener( mEventDispatcher.registerUiThreadListener(
@ -879,29 +876,6 @@ public class WebExtension {
"GeckoView:WebExtension:Disconnect"); "GeckoView:WebExtension:Disconnect");
} }
// TODO: remove Bug 1618987
@Deprecated
public void setTabDelegate(final WebExtensionController.TabDelegate delegate) {
if (!mTabDelegateRegistered && delegate != null) {
mEventDispatcher.registerUiThreadListener(
this,
"GeckoView:WebExtension:NewTab",
"GeckoView:WebExtension:UpdateTab",
"GeckoView:WebExtension:CloseTab",
"GeckoView:WebExtension:OpenOptionsPage"
);
mTabDelegateRegistered = true;
}
mLegacyTabDelegate = delegate;
}
// TODO: remove Bug 1618987
@Deprecated
public WebExtensionController.TabDelegate getTabDelegate() {
return mLegacyTabDelegate;
}
public void unregisterWebExtension(final WebExtension extension) { public void unregisterWebExtension(final WebExtension extension) {
mMessageDelegates.remove(extension.id); mMessageDelegates.remove(extension.id);
mActionDelegates.remove(extension.id); mActionDelegates.remove(extension.id);
@ -964,19 +938,6 @@ public class WebExtension {
return; return;
} }
// TODO: remove Bug 1618987
final WebExtensionController controller = runtime.getWebExtensionController();
WebExtensionController.TabDelegate delegate = controller.getTabDelegate();
if (delegate != null) {
if ("GeckoView:WebExtension:CloseTab".equals(event)) {
controller.closeTab(message, callback, mSession, delegate);
return;
} else if ("GeckoView:WebExtension:NewTab".equals(event)) {
controller.newTab(message, callback, delegate);
return;
}
}
runtime.getWebExtensionController().handleMessage(event, message, callback, mSession); runtime.getWebExtensionController().handleMessage(event, message, callback, mSession);
} }
} }

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

@ -250,29 +250,6 @@ public class WebExtensionController {
} }
} }
/**
* @deprecated Use {@link WebExtension#getTabDelegate} and
* {@link WebExtension.SessionController#getTabDelegate}.
* @return The {@link TabDelegate} instance.
*/
@UiThread
@Nullable
@Deprecated
public TabDelegate getTabDelegate() {
return mListener.getTabDelegate();
}
/**
* @deprecated Use {@link WebExtension#setTabDelegate} and
* {@link WebExtension.SessionController#setTabDelegate}.
* @param delegate {@link TabDelegate} instance.
*/
@Deprecated
@UiThread
public void setTabDelegate(final @Nullable TabDelegate delegate) {
mListener.setTabDelegate(delegate);
}
/** /**
* This delegate will be called whenever an extension is about to be installed or it needs * This delegate will be called whenever an extension is about to be installed or it needs
* new permissions, e.g during an update or because it called <code>permissions.request</code> * new permissions, e.g during an update or because it called <code>permissions.request</code>
@ -1007,22 +984,7 @@ public class WebExtensionController {
message.callback.sendSuccess(null); message.callback.sendSuccess(null);
} }
/* package */ void newTab(final Message message, final WebExtension extension) { /* package */ void newTab(final Message message,
newTab(message, null, extension);
}
// TODO: remove Bug 1618987
/* package */ void newTab(final GeckoBundle bundle, final EventCallback callback,
final TabDelegate legacyDelegate) {
final Message message = new Message("GeckoView:WebExtension:NewTab",
bundle, callback, null);
extensionFromBundle(bundle).accept(extension ->
newTab(message, legacyDelegate, extension)
);
}
// TODO: remove legacyDelegate Bug 1618987
/* package */ void newTab(final Message message, final TabDelegate legacyDelegate,
final WebExtension extension) { final WebExtension extension) {
final GeckoBundle bundle = message.bundle; final GeckoBundle bundle = message.bundle;
@ -1033,8 +995,6 @@ public class WebExtensionController {
final GeckoResult<GeckoSession> result; final GeckoResult<GeckoSession> result;
if (delegate != null) { if (delegate != null) {
result = delegate.onNewTab(extension, details); result = delegate.onNewTab(extension, details);
} else if (legacyDelegate != null) {
result = legacyDelegate.onNewTab(extension, details.url);
} else { } else {
mPendingNewTab.add(extension.id, message); mPendingNewTab.add(extension.id, message);
return; return;
@ -1082,34 +1042,14 @@ public class WebExtensionController {
}); });
} }
// TODO: remove Bug 1618987
/* package */ void closeTab(final GeckoBundle bundle, final EventCallback callback,
final GeckoSession session,
final TabDelegate legacyDelegate) {
final Message message = new Message("GeckoView:WebExtension:NewTab",
bundle, callback, null);
extensionFromBundle(bundle).accept(extension ->
newTab(message, legacyDelegate, extension)
);
}
/* package */ void closeTab(final Message message, /* package */ void closeTab(final Message message,
final WebExtension extension) { final WebExtension extension) {
closeTab(message, extension, null);
}
// TODO: remove legacyDelegate Bug 1618987
/* package */ void closeTab(final Message message,
final WebExtension extension,
final TabDelegate legacyDelegate) {
final WebExtension.SessionTabDelegate delegate = final WebExtension.SessionTabDelegate delegate =
message.session.getWebExtensionController().getTabDelegate(extension); message.session.getWebExtensionController().getTabDelegate(extension);
final GeckoResult<AllowOrDeny> result; final GeckoResult<AllowOrDeny> result;
if (delegate != null) { if (delegate != null) {
result = delegate.onCloseTab(extension, message.session); result = delegate.onCloseTab(extension, message.session);
} else if (legacyDelegate != null) {
result = legacyDelegate.onCloseTab(extension, message.session);
} else { } else {
result = GeckoResult.fromValue(AllowOrDeny.DENY); result = GeckoResult.fromValue(AllowOrDeny.DENY);
} }

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

@ -19,7 +19,8 @@ exclude: true
([bug 1618058]({{bugzilla}}1619766)) ([bug 1618058]({{bugzilla}}1619766))
- Added [`WebNotification.source`][79.2], which is the URL of the page - Added [`WebNotification.source`][79.2], which is the URL of the page
or Service Worker that created the notification. or Service Worker that created the notification.
- Removed deprecated `WebExtensionController.setTabDelegate` and `WebExtensionController.getTabDelegate`
APIs ([bug 1618987]({{bugzilla}}1618987)).
[79.1]: {{javadoc_uri}}/WebExtension.TabDelegate.html#onOpenOptionsPage-org.mozilla.geckoview.WebExtension- [79.1]: {{javadoc_uri}}/WebExtension.TabDelegate.html#onOpenOptionsPage-org.mozilla.geckoview.WebExtension-
[79.2]: {{javadoc_uri}}/WebNotification.html#source [79.2]: {{javadoc_uri}}/WebNotification.html#source
@ -723,4 +724,4 @@ exclude: true
[65.24]: {{javadoc_uri}}/CrashReporter.html#sendCrashReport-android.content.Context-android.os.Bundle-java.lang.String- [65.24]: {{javadoc_uri}}/CrashReporter.html#sendCrashReport-android.content.Context-android.os.Bundle-java.lang.String-
[65.25]: {{javadoc_uri}}/GeckoResult.html [65.25]: {{javadoc_uri}}/GeckoResult.html
[api-version]: 820c4bbc052bd8b8b19c2460c3996b86e1786ff7 [api-version]: f395ea7c21fe233e4e95d28f255910bcde75dc91