Closed Bug 1559495 Opened 5 months ago Closed 26 days ago

[meta] Quantum Bar Contextual Tip API for Nudges

Categories

(Firefox :: Address Bar, task, P3)

task

Tracking

()

RESOLVED FIXED

People

(Reporter: okonaraddi, Unassigned)

References

(Blocks 3 open bugs)

Details

(Keywords: meta)

Depends on: 1559498
Depends on: 1559499
Depends on: 1559501
Assignee: nobody → okonaraddi
Status: NEW → ASSIGNED
Depends on: 1559504
Depends on: 1559502
Depends on: 1559505
Depends on: 1559508
Depends on: 1559509
Blocks: 1560020
Priority: -- → P3
Summary: [meta] Quantum Bar Infobar API → [meta] Quantum Bar Infobar API for Nudges
Summary: [meta] Quantum Bar Infobar API for Nudges → [meta] Quantum Bar Contextual Tip API for Nudges
Blocks: 1568594

Proposing changes to the contextual tip API

I spoke with Drew earlier today about making some changes to the contextual tip api and the following is a list of changes we think would be good to make for the contextual tip API:

  1. Remove defaults from the manifest

Currently, a web extension can set defaults for the contextual tip’s default icon, theme icons, title, button title, and link title. If there are defaults defined in the manifest, then a contextual tip is set in all existing and new windows. We don’t seem to have a use case for using defaults set in the manifest, and we don’t anticipate a use case, so we can remove this.

  1. Changes to icon support

Currently, icons for higher/lower res screens and light/dark themes are set in the manifest defaults. An icon can be set programmatically by providing a path to an icon when calling setContextualTip.

If we’re removing the defaults, then icons for higher/lower res screens and light/dark themes should also be set programmatically through setContextualTip.

  1. Remove the “contextual_tip” permission from the manifest

In my most recent revision at https://phabricator.services.mozilla.com/D37809?id=136085 , I added a permission called “contextual_tip”. A web extension that wants to use a contextual tip would have to add “contextual_tip” to the list of permissions in its manifest and an error is thrown if it’s missing. Ultimately, it would’ve been used to ensure that only one web extension can use the contextual tip (one possible solution to “what happens if multiple extensions try to set a contextual tip?”) but that has not been written and is not part of the revision.

Handling multiple extensions is something to think about and eventually address but not a top priority at the moment. So I think the “contextual_tip” permission can be removed for now (but we’ll still require the “urlbar” permission).

  1. Change the way setContextualTip behaves and remove the show/hide functions

Currently, the setContextualTip function accepts two arguments: a details object and a window id. The details object represents the details of the contextual tip (icon, title, etc.) and the window id is the corresponding window’s contextual tip to set. So if a web extension wants to set the contextual tip on a specific window, they could call setContextualTip({…details}, window.id). If the web extension omits the windowId then the contextual tip’s details would be set for all windows. All existing windows’ contextual tips would be updated with the given details. New windows would have contextual tips with the given details too. Unless hide is called, the tip always appears when the user clicks in the urlbar input field.

Given that the contextual tip is shown only on the current window, only one urlbar popup is open at a time, and we don’t have a use case for setting a contextual tip across all windows (especially since we’re removing the defaults from the manifest), we can change the setContextualTip function to only accept a details object. We would set the contextual tip only for the current window. We can remove code for handling existing and new windows in the current contextual tip API.

Our current use cases, search tips and interventions, require setting a contextual tip once. So setContextualTip should open the current window’s (or most recent window’s) urlbar’s popup panel, display a tip with the given details, and the tip should be removed/hidden when the popup closes. If the popup is already open then setContextualTip should just display/update the tip then be removed/hidden when the popup closes. This fits the use case for search tips where a user should see a contextual tip in the popup panel without having to click in the urlbar’s input field. For search interventions, this works but we’ll want to be able to set and hide the contextual tip as the user is typing. We already support setting the tip through setContextualTip but to support hiding the contextual tip, the search intervention web extension could pass null to setContextualTip which would tell setContextualTip to hide the tip (we currently don’t accept null so this would be another change). With these changes, there would be no need to make a browser.urlbar.onViewShowing event or browser.urlbar.openPopup function accessible to web extensions (both of which are needed for search tips with the current contextual tip API). Using the contextual tip API would be more intuitive for developers since they don’t need to keep track of whether there’s a tip already set and they don’t need to use show/hide, in addition to setContextualTip, to ensure that the tip is visible only when they want it to be visible.

Depends on: 1568705
Depends on: 1568708
Depends on: 1571144
Depends on: 1573308
Depends on: 1573320
Depends on: 1573321
Depends on: 1573323
Depends on: 1575972
Depends on: 1576888
Depends on: 1576889
Assignee: okonaraddi → nobody
Status: ASSIGNED → NEW
No longer blocks: urlbar-interventions

All blocking bugs have been either fixed or wontfixed (in favor of tip results), so I'll mark this bug as fixed.

Status: NEW → RESOLVED
Closed: 26 days ago
Resolution: --- → FIXED
Blocks: 1590450
You need to log in before you can comment on or make changes to this bug.