Skip to content

Commit

Permalink
nativeMessaging can always be optional
Browse files Browse the repository at this point in the history
this is the only blocker to Firefox for Android.
  • Loading branch information
praschke committed Oct 29, 2023
1 parent e61a69f commit bbefd8a
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 39 deletions.
29 changes: 6 additions & 23 deletions dev/data/manifest-variants.json
Original file line number Diff line number Diff line change
Expand Up @@ -229,25 +229,12 @@
"gecko": {
"id": "{cb7c0bec-7085-4f84-8422-7b55a7c4467c}",
"strict_min_version": "115.0"
},
"gecko_android": {
"strict_min_version": "115.0"
}
}
},
{
"action": "remove",
"path": [
"optional_permissions"
],
"item": "nativeMessaging"
},
{
"action": "add",
"path": [
"permissions"
],
"items": [
"nativeMessaging"
]
},
{
"action": "remove",
"path": [
Expand Down Expand Up @@ -327,13 +314,6 @@
],
"item": "clipboardRead"
},
{
"action": "remove",
"path": [
"permissions"
],
"item": "webRequestBlocking"
},
{
"action": "remove",
"path": [
Expand Down Expand Up @@ -365,6 +345,9 @@
],
"excludeFiles": [
"sw.js",
"offscreen.html",
"js/background/offscreen.js",
"js/background/offscreen-main.js",
"js/dom/simple-dom-parser.js",
"lib/parse5.js"
]
Expand Down
5 changes: 2 additions & 3 deletions docs/permissions.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,14 @@
Yomichan supports simulating the `Ctrl+C` (copy to clipboard) keyboard shortcut
when a definitions popup is open and focused.

* `clipboardRead` (optional) <br>
* `clipboardRead` _(optional)_ <br>
Yomichan supports automatically opening a search window when Japanese text is copied to the clipboard
while the browser is running, depending on how certain settings are configured.
This allows Yomichan to support scanning text from external applications, provided there is a way
to copy text from those applications to the clipboard.

* `nativeMessaging` (optional on Chrome) <br>
* `nativeMessaging` _(optional, unavailable on Firefox for Android)_ <br>
Yomichan has the ability to communicate with an optional native messaging component in order to support
parsing large blocks of Japanese text using
[MeCab](https://en.wikipedia.org/wiki/MeCab).
The installation of this component is optional and is not included by default.
This permission is optional on Chrome, but required on Firefox, because Firefox does not permit it to be optional.
16 changes: 6 additions & 10 deletions ext/js/extension/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ class Environment {
}

async _loadEnvironmentInfo() {
const browser = await this._getBrowser();
const os = await this._getOperatingSystem();
const browser = await this._getBrowser(os);

return {
browser,
platform: {os}
Expand Down Expand Up @@ -64,7 +65,7 @@ class Environment {
});
}

async _getBrowser() {
async _getBrowser(os) {
try {
if (chrome.runtime.getURL('/').startsWith('ms-browser-extension://')) {
return 'edge-legacy';
Expand All @@ -76,17 +77,12 @@ class Environment {
// NOP
}
if (typeof browser !== 'undefined') {
try {
const info = await browser.runtime.getBrowserInfo();
if (info.name === 'Fennec') {
return 'firefox-mobile';
}
} catch (e) {
// NOP
}
if (this._isSafari()) {
return 'safari';
}
if (os === 'android') {
return 'firefox-mobile';
}
return 'firefox';
} else {
return 'chrome';
Expand Down
4 changes: 2 additions & 2 deletions ext/permissions.html
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ <h2 id="permissions"></h2>
<label class="toggle"><input type="checkbox" class="permissions-toggle" data-required-permissions="clipboardRead"><span class="toggle-body"><span class="toggle-track"></span><span class="toggle-knob"></span></span></label>
</div>
</div></div>
<div class="settings-item"><div class="settings-item-inner">
<div class="settings-item" data-hide-for-browser="firefox-mobile"><div class="settings-item-inner">
<div class="settings-item-left">
<div class="settings-item-label"><code>nativeMessaging</code> <span class="light" data-show-for-browser="chrome edge">(optional)</span></div>
<div class="settings-item-label"><code>nativeMessaging</code> <span class="light">(optional)</span></div>
<div class="settings-item-description">
Yomitan has the ability to communicate with an optional native messaging component in order to support
parsing large blocks of Japanese text using
Expand Down
2 changes: 1 addition & 1 deletion ext/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -1372,7 +1372,7 @@ <h1>Yomitan Settings</h1>
</p>
</div>
</div>
<div class="settings-item advanced-only">
<div class="settings-item advanced-only" data-hide-for-browser="firefox-mobile">
<div class="settings-item-inner">
<div class="settings-item-left">
<div class="settings-item-invalid-indicator"></div>
Expand Down

0 comments on commit bbefd8a

Please sign in to comment.