Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: declarative way for opening an extension page in a new tab when click the extension icon #267

Closed
hanguokai opened this issue Aug 26, 2022 · 4 comments
Labels
discussion Needs further discussion opposed: chrome Opposed by Chrome opposed: firefox Opposed by Firefox opposed: safari Opposed by Safari proposal Proposal for a change or new feature

Comments

@hanguokai
Copy link
Member

Popup is a temporary small window. Sometimes, developers want another behavior: open a page in a new tab when users click the extension icon.

At present, developers must declare a background script(service worker), and add one line of code in it:
browser.action.onClicked.addListener(_ => chrome.tabs.create({url: "index.html"}));

My proposal likes below:

  // manifest.json
  "action": {
    "default_tab_page": "index.html",
  }
  // action api
  browser.action.getTabPage();
  browser.action.setTabPage('index.html');

Unlike popup page, tab page has no per-tab state. When click the extension icon, just open that page in a new tab.

@fregante
Copy link

fregante commented Aug 26, 2022

This is already trivial to implement, but it's also a very simple request. I would not mind such interface.

@xeenon xeenon added future topics discussion Needs further discussion proposal Proposal for a change or new feature and removed future topics labels Aug 31, 2022
@Rob--W Rob--W added opposed: chrome Opposed by Chrome opposed: safari Opposed by Safari opposed: firefox Opposed by Firefox labels Sep 1, 2022
@Rob--W
Copy link
Member

Rob--W commented Sep 1, 2022

Discussed during the meeting; Since the feature can already trivially be implemented with a background worker/script, it is not necessary to add the functionality to the extension API. Extension API additions are better reserved for features that are difficult to achieve otherwise.

@Rob--W Rob--W closed this as completed Sep 1, 2022
@carlosjeurissen
Copy link
Contributor

In the current form, it indeed seems quite trivial to implement something like this.

However, when exploring further options / features, this could start becoming useful. Think about the browser being smart enough to focus the full tab page if it is already opened, instead of opening a new one. And/or have this full tab page be a pinned tab right away when opening it.

@Rob--W
Copy link
Member

Rob--W commented Sep 1, 2022

In the current form, it indeed seems quite trivial to implement something like this.

However, when exploring further options / features, this could start becoming useful. Think about the browser being smart enough to focus the full tab page if it is already opened, instead of opening a new one. And/or have this full tab page be a pinned tab right away when opening it.

If that is the desired result, then we could repurpose the existing default_popup and setPopup APIs along with a new property open_in_tab (similar to options_ui). Clicking the popup and responding to a click are mutually exclusive anyway.

But unlike options pages and (browser) action panels, opening a new tab is already easily possible with existing extension APIs, which was the reason for closing this feature request.

The participants in the meeting, including representatives of Apple (Timothy), Google (Simeon) and Mozilla (me), were all not against the functionality itself, but after weighing implementation/maintenance effort and balancing that against the benefits to developers, we decided to not add a new API requested here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Needs further discussion opposed: chrome Opposed by Chrome opposed: firefox Opposed by Firefox opposed: safari Opposed by Safari proposal Proposal for a change or new feature
Projects
None yet
Development

No branches or pull requests

5 participants