[DeepLink] Rename filter to shouldHandleOpenResource
Bug:427430112
Change-Id: I0d1fbf067daaf69fd5e31074a27698531973a0a1
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6758891
Reviewed-by: Finnur Thorarinsson <[email protected]>
Auto-Submit: Paul Irish <[email protected]>
Commit-Queue: Finnur Thorarinsson <[email protected]>
diff --git a/front_end/models/extensions/ExtensionServer.test.ts b/front_end/models/extensions/ExtensionServer.test.ts
index 552362d..66ebf25 100644
--- a/front_end/models/extensions/ExtensionServer.test.ts
+++ b/front_end/models/extensions/ExtensionServer.test.ts
@@ -194,7 +194,7 @@
assert.strictEqual(registration.title, 'TestExtension');
assert.isUndefined(registration.scheme);
assert.isFunction(registration.handler);
- assert.isFunction(registration.filter);
+ assert.isFunction(registration.shouldHandleOpenResource);
// Now unregister the extension.
context.chrome.devtools?.panels.setOpenResourceHandler();
@@ -203,7 +203,7 @@
assert.strictEqual(unregistration.title, 'TestExtension');
assert.isUndefined(unregistration.scheme);
assert.isFunction(unregistration.handler);
- assert.isFunction(unregistration.filter);
+ assert.isFunction(unregistration.shouldHandleOpenResource);
});
it('can register and unregister a scheme specific open resource handler', async () => {
@@ -216,7 +216,7 @@
assert.strictEqual(registration.title, 'TestExtension');
assert.strictEqual(registration.scheme, 'foo-extension:');
assert.isFunction(registration.handler);
- assert.isFunction(registration.filter);
+ assert.isFunction(registration.shouldHandleOpenResource);
// Now unregister the extension.
context.chrome.devtools?.panels.setOpenResourceHandler();
@@ -225,7 +225,7 @@
assert.strictEqual(unregistration.title, 'TestExtension');
assert.isUndefined(unregistration.scheme);
assert.isFunction(unregistration.handler);
- assert.isFunction(unregistration.filter);
+ assert.isFunction(unregistration.shouldHandleOpenResource);
});
});
diff --git a/front_end/models/extensions/ExtensionServer.ts b/front_end/models/extensions/ExtensionServer.ts
index 7516dc0..9bf2db4 100644
--- a/front_end/models/extensions/ExtensionServer.ts
+++ b/front_end/models/extensions/ExtensionServer.ts
@@ -832,7 +832,7 @@
origin: extensionOrigin,
scheme: message.urlScheme,
handler: this.handleOpenURL.bind(this, port),
- filter: (url: Platform.DevToolsPath.UrlString, schemes: Set<string>) =>
+ shouldHandleOpenResource: (url: Platform.DevToolsPath.UrlString, schemes: Set<string>) =>
Components.Linkifier.Linkifier.shouldHandleOpenResource(extension.openResourceScheme, url, schemes),
};
if (message.handlerPresent) {
diff --git a/front_end/ui/legacy/components/utils/Linkifier.test.ts b/front_end/ui/legacy/components/utils/Linkifier.test.ts
index ae25eac..39d68fa 100644
--- a/front_end/ui/legacy/components/utils/Linkifier.test.ts
+++ b/front_end/ui/legacy/components/utils/Linkifier.test.ts
@@ -412,7 +412,7 @@
origin: urlString`foo-extension:abcdefghijklmnop`,
scheme: urlString`foo-extension:`,
handler,
- filter: (url, schemes) =>
+ shouldHandleOpenResource: (url, schemes) =>
Components.Linkifier.Linkifier.shouldHandleOpenResource(urlString`foo-extension:`, url, schemes),
});
@@ -442,7 +442,8 @@
origin: urlString`global:abcdefghijklmnop`,
scheme: undefined,
handler: () => {},
- filter: (url, schemes) => Components.Linkifier.Linkifier.shouldHandleOpenResource(null, url, schemes),
+ shouldHandleOpenResource: (url, schemes) =>
+ Components.Linkifier.Linkifier.shouldHandleOpenResource(null, url, schemes),
});
// Register a scheme-specific handler for the foo-extension: origin.
@@ -451,7 +452,7 @@
origin: urlString`foo-extension:abcdefghijklmnop`,
scheme: urlString`foo-extension:`,
handler: () => {},
- filter: (url, schemes) =>
+ shouldHandleOpenResource: (url, schemes) =>
Components.Linkifier.Linkifier.shouldHandleOpenResource(urlString`foo-extension:`, url, schemes),
});
diff --git a/front_end/ui/legacy/components/utils/Linkifier.ts b/front_end/ui/legacy/components/utils/Linkifier.ts
index 453ef75..1f0e0b6 100644
--- a/front_end/ui/legacy/components/utils/Linkifier.ts
+++ b/front_end/ui/legacy/components/utils/Linkifier.ts
@@ -798,20 +798,20 @@
// does not match. If no openResourceScheme is provided, it means the handler is
// interested in all urls (except those handled by scheme-specific handlers, see
// otherSchemeRegistrations).
- static shouldHandleOpenResource =
- (openResourceScheme: string|null, url: Platform.DevToolsPath.UrlString, otherSchemeRegistrations: Set<string>):
- boolean => {
- // If this is a scheme-specific handler, make sure the registered scheme is
- // present in the url.
- if (openResourceScheme) {
- return url.startsWith(openResourceScheme);
- }
+ static shouldHandleOpenResource(
+ openResourceScheme: string|null, url: Platform.DevToolsPath.UrlString,
+ otherSchemeRegistrations: Set<string>): boolean {
+ // If this is a scheme-specific handler, make sure the registered scheme is
+ // present in the url.
+ if (openResourceScheme) {
+ return url.startsWith(openResourceScheme);
+ }
- // Global handlers (that register for no scheme) can handle all urls, with the
- // exception of urls that scheme-specific handlers have registered for.
- const scheme = URL.parse(url)?.protocol || '';
- return !otherSchemeRegistrations.has(scheme);
- };
+ // Global handlers (that register for no scheme) can handle all urls, with the
+ // exception of urls that scheme-specific handlers have registered for.
+ const scheme = URL.parse(url)?.protocol || '';
+ return !otherSchemeRegistrations.has(scheme);
+ }
static uiLocation(link: Element): Workspace.UISourceCode.UILocation|null {
const info = Linkifier.linkInfo(link);
@@ -874,11 +874,8 @@
}
}
- for (const registration of linkHandlers.values()) {
- if (!registration?.handler) {
- continue;
- }
- const {title, handler, filter: shouldHandleOpenResource} = registration;
+ for (const registration of linkHandlers.values().filter(r => r.handler)) {
+ const {title, handler, shouldHandleOpenResource} = registration;
if (url && !shouldHandleOpenResource(url, specificSchemeHandlers)) {
continue;
}
@@ -1172,7 +1169,7 @@
// The openResourceHandler handling the requests to open a resource.
handler: LinkHandler;
// A filter function used to determine whether the `handler` wants to handle the link clicks.
- filter: LinkHandlerPredicate;
+ shouldHandleOpenResource: LinkHandlerPredicate;
}
export const enum Events {