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

Get Opera Ready for MV3 #13190

Merged
merged 8 commits into from
Feb 11, 2025
Merged
16 changes: 15 additions & 1 deletion apps/browser/src/manifest.v3.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,13 @@
},
"description": "__MSG_commandOpenSidebar__"
},
"__opera___execute_sidebar_action": {
"suggested_key": {
"default": "Alt+Shift+Y",
"linux": "Alt+Shift+U"
},
"description": "__MSG_commandOpenSidebar__"
},
Comment on lines +131 to +137
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy from MV2 manifest:

"__opera___execute_sidebar_action": {
"suggested_key": {
"default": "Alt+Shift+Y",
"linux": "Alt+Shift+U"
},
"description": "__MSG_commandOpenSidebar__"
},

"autofill_login": {
"suggested_key": {
"default": "Ctrl+Shift+L"
Expand Down Expand Up @@ -182,5 +189,12 @@
"storage": {
"managed_schema": "managed_schema.json"
},
"__firefox__storage": null
"__firefox__storage": null,
"__opera__sidebar_action": {
"default_title": "Bitwarden",
"default_panel": "popup/index.html?uilocation=sidebar",
"default_icon": "images/icon19.png",
"open_at_install": false,
"browser_style": false
}
Comment on lines +193 to +199
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy from MV2 manifest:

"__opera__sidebar_action": {
"default_title": "Bitwarden",
"default_panel": "popup/index.html?uilocation=sidebar",
"default_icon": "images/icon19.png",
"open_at_install": false,
"browser_style": false
},

}
11 changes: 8 additions & 3 deletions apps/browser/src/platform/browser/browser-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -530,10 +530,15 @@
win: Window & typeof globalThis,
): OperaSidebarAction | FirefoxSidebarAction | null {
const deviceType = BrowserPlatformUtilsService.getDevice(win);
if (deviceType !== DeviceType.FirefoxExtension && deviceType !== DeviceType.OperaExtension) {
return null;
if (deviceType === DeviceType.FirefoxExtension) {
return browser.sidebarAction;

Check warning on line 534 in apps/browser/src/platform/browser/browser-api.ts

View check run for this annotation

Codecov / codecov/patch

apps/browser/src/platform/browser/browser-api.ts#L534

Added line #L534 was not covered by tests
}

if (deviceType === DeviceType.OperaExtension) {
return win.opr?.sidebarAction;
}
return win.opr?.sidebarAction || browser.sidebarAction;

return null;

Check warning on line 541 in apps/browser/src/platform/browser/browser-api.ts

View check run for this annotation

Codecov / codecov/patch

apps/browser/src/platform/browser/browser-api.ts#L541

Added line #L541 was not covered by tests
}

static captureVisibleTab(): Promise<string> {
Expand Down
7 changes: 7 additions & 0 deletions apps/browser/src/platform/listeners/update-badge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,13 @@
return;
}

if ("opr" in this.win && BrowserApi.isManifestVersion(3)) {
// setIcon API is currenly broken for Opera MV3 extensions
// https://forums.opera.com/topic/75680/opr-sidebaraction-seticon-api-is-broken-access-to-extension-api-denied?_=1738349261570
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// The API currently crashes on MacOS
return;

Check warning on line 172 in apps/browser/src/platform/listeners/update-badge.ts

View check run for this annotation

Codecov / codecov/patch

apps/browser/src/platform/listeners/update-badge.ts#L172

Added line #L172 was not covered by tests
}

if (this.isOperaSidebar(this.sidebarAction)) {
await new Promise<void>((resolve) =>
(this.sidebarAction as OperaSidebarAction).setIcon(options, () => resolve()),
Expand Down