Skip to content

Commit

Permalink
Add a pref to know if the alt-text must be automatically generated (b…
Browse files Browse the repository at this point in the history
…ug 1909310)
  • Loading branch information
calixteman committed Jul 22, 2024
1 parent 91655aa commit c4594a1
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
4 changes: 4 additions & 0 deletions extensions/chromium/preferences_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@
"type": "boolean",
"default": false
},
"enableGuessAltText": {
"type": "boolean",
"default": true
},
"altTextLearnMoreUrl": {
"type": "string",
"default": ""
Expand Down
4 changes: 2 additions & 2 deletions web/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,10 @@ const PDFViewerApplication = {
if (mode) {
document.documentElement.classList.add(mode);
}
} else {
} else if (AppOptions.get("enableAltText")) {
// We want to load the image-to-text AI engine as soon as possible.
this.mlManager = new MLManager({
enableAltText: AppOptions.get("enableAltText"),
enableGuessAltText: AppOptions.get("enableGuessAltText"),
altTextLearnMoreUrl: AppOptions.get("altTextLearnMoreUrl"),
});
}
Expand Down
5 changes: 5 additions & 0 deletions web/app_options.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,11 @@ const defaultOptions = {
value: false,
kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
},
enableGuessAltText: {
/** @type {boolean} */
value: true,
kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
},
enableHighlightEditor: {
// We'll probably want to make some experiments before enabling this
// in Firefox release, but it has to be temporary.
Expand Down
4 changes: 2 additions & 2 deletions web/firefoxcom.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,8 @@ class MLManager {
return FirefoxCom.requestAsync("mlGuess", data);
}

enable({ altTextLearnMoreUrl, enableAltText, listenToProgress }) {
if (enableAltText) {
enable({ altTextLearnMoreUrl, enableGuessAltText, listenToProgress }) {
if (enableGuessAltText) {
this.#loadAltTextEngine(listenToProgress);
}
// The `altTextLearnMoreUrl` is used to provide a link to the user to learn
Expand Down

0 comments on commit c4594a1

Please sign in to comment.