Skip to content

Commit

Permalink
Bug 1513039 - part9 : remove autoplayMediaCombobox. r=daleharvey,flod
Browse files Browse the repository at this point in the history
Use CheckedBox instead.

Differential Revision: https://phabricator.services.mozilla.com/D14334

--HG--
extra : moz-landing-system : lando
  • Loading branch information
alastor0325 committed Jan 7, 2019
1 parent 3e58175 commit 99419e9
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 209 deletions.
45 changes: 8 additions & 37 deletions browser/components/preferences/in-content/privacy.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ Preferences.addAll([

// Media
{ id: "media.autoplay.default", type: "int" },
{ id: "media.autoplay.enabled.ask-permission", type: "bool" },
{ id: "media.autoplay.enabled.user-gestures-needed", type: "bool" },

// Popups
{ id: "dom.disable_open_during_load", type: "bool" },
Expand Down Expand Up @@ -271,8 +269,6 @@ var gPrivacyPane = {
init() {
this._updateSanitizeSettingsButton();
this.initializeHistoryMode();
this.initAutoplay();
this.updateAutoplayMediaControlsVisibility();
this.updateHistoryModePane();
this.updatePrivacyMicroControls();
this.initAutoStartPrivateBrowsingReverter();
Expand All @@ -281,10 +277,14 @@ var gPrivacyPane = {
/* Initialize Content Blocking */
this.initContentBlocking();

this.blockAutoplayReadPrefs();
this.trackingProtectionReadPrefs();
this.networkCookieBehaviorReadPrefs();
this._initTrackingProtectionExtensionControl();

Preferences.get("media.autoplay.default").on("change",
gPrivacyPane.blockAutoplayReadPrefs.bind(gPrivacyPane));

Preferences.get("privacy.trackingprotection.enabled").on("change",
gPrivacyPane.trackingProtectionReadPrefs.bind(gPrivacyPane));
Preferences.get("privacy.trackingprotection.pbmode.enabled").on("change",
Expand All @@ -305,10 +305,6 @@ var gPrivacyPane = {
gPrivacyPane._updateSanitizeSettingsButton.bind(gPrivacyPane));
Preferences.get("browser.privatebrowsing.autostart").on("change",
gPrivacyPane.updatePrivacyMicroControls.bind(gPrivacyPane));
Preferences.get("media.autoplay.enabled.ask-permission").on("change",
gPrivacyPane.updateAutoplayMediaControlsVisibility.bind(gPrivacyPane));
Preferences.get("media.autoplay.enabled.user-gestures-needed").on("change",
gPrivacyPane.updateAutoplayMediaControlsVisibility.bind(gPrivacyPane));
setEventListener("historyMode", "command", function() {
gPrivacyPane.updateHistoryModePane();
gPrivacyPane.updateHistoryModePrefs();
Expand Down Expand Up @@ -366,8 +362,6 @@ var gPrivacyPane = {
gPrivacyPane.toggleAutoplayMedia);
setEventListener("autoplayMediaPolicyButton", "command",
gPrivacyPane.showAutoplayMediaExceptions);
setEventListener("autoplayMediaPolicyComboboxButton", "command",
gPrivacyPane.showAutoplayMediaExceptions);
setEventListener("notificationsDoNotDisturb", "command",
gPrivacyPane.toggleDoNotDisturbNotifications);

Expand Down Expand Up @@ -1109,10 +1103,10 @@ var gPrivacyPane = {

// MEDIA

initAutoplay() {
let url = Services.urlFormatter.formatURLPref("app.support.baseURL") +
"block-autoplay";
document.getElementById("autoplayLearnMoreLink").setAttribute("href", url);
blockAutoplayReadPrefs() {
let blocked =
Preferences.get("media.autoplay.default").value == Ci.nsIAutoplay.BLOCKED;
document.getElementById("autoplayMediaCheckbox").checked = blocked;
},

/**
Expand All @@ -1123,29 +1117,6 @@ var gPrivacyPane = {
Services.prefs.setIntPref("media.autoplay.default", blocked);
},

/**
* If user-gestures-needed is false we do not show any UI for configuring autoplay,
* if user-gestures-needed is false and ask-permission is false we show a checkbox
* which only allows the user to block autoplay
* if user-gestures-needed and ask-permission are true we show a combobox that
* allows the user to block / allow or prompt for autoplay
* We will be performing a shield study to determine the behaviour to be
* shipped, at which point we can remove these pref switches.
* https://bugzilla.mozilla.org/show_bug.cgi?id=1475099
*/
updateAutoplayMediaControlsVisibility() {
let askPermission =
Services.prefs.getBoolPref("media.autoplay.ask-permission", false);
let userGestures =
Services.prefs.getBoolPref("media.autoplay.enabled.user-gestures-needed", false);
// Hide the combobox if we don't let the user ask for permission.
document.getElementById("autoplayMediaComboboxWrapper").hidden =
!userGestures || !askPermission;
// If the user may ask for permission, hide the checkbox instead.
document.getElementById("autoplayMediaCheckboxWrapper").hidden =
!userGestures || askPermission;
},

/**
* Displays the autoplay exceptions dialog where specific site autoplay preferences
* can be set.
Expand Down
34 changes: 1 addition & 33 deletions browser/components/preferences/in-content/privacy.xul
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@

<separator flex="1"/>

<hbox align="start" id="autoplayMediaCheckboxWrapper" hidden="true">
<hbox align="start" id="autoplayMediaCheckboxWrapper">
<checkbox id="autoplayMediaCheckbox"
data-l10n-id="permissions-block-autoplay-media"
flex="1" />
Expand Down Expand Up @@ -631,38 +631,6 @@
</hbox>
</vbox>

<hbox align="center" id="autoplayMediaComboboxWrapper" hidden="true">
<hbox align="center" flex="1">
<label id="autoplayMediaPolicy"
control="autoplayMediaPolicyMenu"
data-l10n-id="permissions-block-autoplay-media-menu"/>
<menulist id="autoplayMediaPolicyMenu"
sizetopopup="always"
preference="media.autoplay.default">
<menupopup>
<!-- Defined in dom/media/nsIAutoplay.idl -->
<menuitem data-l10n-id="autoplay-option-allow" value="0"/>
<menuitem data-l10n-id="autoplay-option-ask" value="2"/>
<menuitem data-l10n-id="autoplay-option-dont" value="1"/>
</menupopup>
</menulist>
<label id="autoplayLearnMoreLink" class="learnMore text-link"
data-l10n-id="permissions-autoplay-link"/>
</hbox>

<hbox pack="end">
<button id="autoplayMediaPolicyComboboxButton"
class="accessory-button"
data-l10n-id="permissions-block-autoplay-media-exceptions"
search-l10n-ids="permissions-address,
permissions-button-cancel.label,
permissions-button-ok.label,
permissions-exceptions-autoplay-media-window2.title,
permissions-exceptions-autoplay-media-desc2
" />
</hbox>
</hbox>

</groupbox>

<!-- Firefox Data Collection and Use -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ run-if = nightly_build
[browser_spotlight.js]
[browser_site_login_exceptions.js]
[browser_site_autoplay_media_exceptions.js]
[browser_site_autoplay_media_prompt.js]
[browser_permissions_dialog.js]
[browser_subdialogs.js]
support-files =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,10 @@ const PRINCIPAL = Services.scriptSecurityManager

const PERMISSIONS_URL = "chrome://browser/content/preferences/permissions.xul";
const AUTOPLAY_ENABLED_KEY = "media.autoplay.default";
const GESTURES_NEEDED_KEY = "media.autoplay.enabled.user-gestures-needed";
const ASK_PERMISSIONS_KEY = "media.autoplay.enabled.ask-permissions";

var exceptionsDialog;

Services.prefs.setIntPref(AUTOPLAY_ENABLED_KEY, Ci.nsIAutoplay.ALLOWED);
Services.prefs.setBoolPref(GESTURES_NEEDED_KEY, false);
Services.prefs.setBoolPref(ASK_PERMISSIONS_KEY, true);

async function openExceptionsDialog() {
let dialogOpened = promiseLoadSubDialog(PERMISSIONS_URL);
Expand All @@ -26,25 +22,19 @@ async function openExceptionsDialog() {
exceptionsDialog = await dialogOpened;
}

add_task(async function ensureCheckboxHidden() {

add_task(async function ensureCheckboxVisible() {
registerCleanupFunction(async function() {
Services.prefs.clearUserPref(AUTOPLAY_ENABLED_KEY);
Services.prefs.clearUserPref(GESTURES_NEEDED_KEY);
Services.prefs.clearUserPref(ASK_PERMISSIONS_KEY);
gBrowser.removeCurrentTab();
});

await openPreferencesViaOpenPreferencesAPI("privacy", {leaveOpen: true});
let win = gBrowser.selectedBrowser.contentWindow;
is_element_hidden(win.document.getElementById("autoplayMediaPolicy"),
"Ensure checkbox is hidden when preffed off");
is_element_visible(win.document.getElementById("autoplayMediaCheckbox"),
"Ensure checkbox is visible");
});

add_task(async function enableBlockingAutoplay() {

Services.prefs.setBoolPref(GESTURES_NEEDED_KEY, true);

await ContentTask.spawn(gBrowser.selectedBrowser, null, function() {
let doc = content.document;
let autoplayCheckBox = doc.getElementById("autoplayMediaCheckbox");
Expand Down

This file was deleted.

11 changes: 0 additions & 11 deletions browser/locales/en-US/browser/preferences/preferences.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -900,21 +900,10 @@ permissions-block-autoplay-media =
.label = Block websites from automatically playing media with sound
.accesskey = B
permissions-block-autoplay-media-menu = For websites that autoplay sound
permissions-block-autoplay-media-exceptions =
.label = Exceptions…
.accesskey = E
autoplay-option-ask =
.label = Always Ask
autoplay-option-allow =
.label = Allow Autoplay
autoplay-option-dont =
.label = Don't Autoplay
permissions-autoplay-link = Learn more
permissions-block-popups =
.label = Block pop-up windows
.accesskey = B
Expand Down

0 comments on commit 99419e9

Please sign in to comment.