Bug 1414406: Switch plugins to use inline browser options. r=aswan

MozReview-Commit-ID: 2hE7lYny6li

--HG--
extra : rebase_source : 0e5c7a3171b19cc78ef91d136130b7a3ab8248ff
This commit is contained in:
Dave Townsend 2017-11-13 15:08:34 -08:00
Родитель 7da9e15ced
Коммит b184ffe5e8
5 изменённых файлов: 101 добавлений и 32 удалений

Просмотреть файл

@ -0,0 +1,26 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
const { utils: Cu } = Components;
const { Services } = Cu.import("resource://gre/modules/Services.jsm", {});
const PREFS = {
"pluginFlashBlockingCheckbox": "plugins.flashBlock.enabled",
"pluginEnableProtectedModeCheckbox": "dom.ipc.plugins.flash.disable-protected-mode",
};
function init() {
for (let id of Object.keys(PREFS)) {
let checkbox = document.getElementById(id);
checkbox.checked = Services.prefs.getBoolPref(PREFS[id]);
checkbox.addEventListener("command", () => {
Services.prefs.setBoolPref(PREFS[id], checkbox.checked);
});
}
}
window.addEventListener("load", init, { once: true });

Просмотреть файл

@ -4,21 +4,54 @@
- License, v. 2.0. If a copy of the MPL was not distributed with this file,
- You can obtain one at http://mozilla.org/MPL/2.0/. -->
<!DOCTYPE window SYSTEM "chrome://pluginproblem/locale/pluginproblem.dtd">
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://mozapps/content/extensions/extensions.css"?>
<?xml-stylesheet href="chrome://mozapps/skin/extensions/extensions.css"?>
<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<setting type="control" title="&plugin.file;">
<label class="text-list" id="pluginLibraries"/>
</setting>
<setting type="control" title="&plugin.mimeTypes;">
<label class="text-list" id="pluginMimeTypes"/>
</setting>
<setting type="bool" pref="plugins.flashBlock.enabled"
id="pluginFlashBlocking"
title="&plugin.enableBlocklists.label;"
learnmore="https://support.mozilla.org/kb/flash-blocklists" />
<setting type="bool" pref="dom.ipc.plugins.flash.disable-protected-mode"
inverted="true" title="&plugin.flashProtectedMode.label;"
id="pluginEnableProtectedMode"
learnmore="https://support.mozilla.org/kb/flash-protected-mode-settings" />
</vbox>
<!DOCTYPE window [
<!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd" >
%brandDTD;
<!ENTITY % pluginsDTD SYSTEM "chrome://pluginproblem/locale/pluginproblem.dtd">
%pluginsDTD;
<!ENTITY % extensionsDTD SYSTEM "chrome://mozapps/locale/extensions/extensions.dtd">
%extensionsDTD;
]>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript"
src="chrome://mozapps/content/extensions/pluginPrefs.js"/>
<vbox class="detail-view-container">
<grid id="detail-grid">
<columns>
<column flex="1"/>
<column flex="2"/>
</columns>
<rows id="detail-rows">
<row class="detail-row-complex">
<label>&plugin.file;</label>
<label class="text-list" id="pluginLibraries"/>
</row>
<row class="detail-row-complex">
<label>&plugin.mimeTypes;</label>
<label class="text-list" id="pluginMimeTypes"/>
</row>
<row id="pluginFlashBlocking" class="detail-row-complex">
<vbox>
<label>&plugin.enableBlocklists.label;</label>
<label class="preferences-learnmore text-link">&setting.learnmore;</label>
</vbox>
<checkbox id="pluginFlashBlockingCheckbox"/>
</row>
<row id="pluginEnableProtectedMode" class="detail-row-complex">
<vbox>
<label>&plugin.flashProtectedMode.label;</label>
<label class="preferences-learnmore text-link">&setting.learnmore;</label>
</vbox>
<checkbox id="pluginEnableProtectedModeCheckbox"/>
</row>
</rows>
</grid>
</vbox>
</window>

Просмотреть файл

@ -57,10 +57,12 @@ var PluginProvider = {
if (!plugin)
return;
let libLabel = aSubject.getElementById("pluginLibraries");
let document = aSubject.getElementById("addon-options").contentDocument;
let libLabel = document.getElementById("pluginLibraries");
libLabel.textContent = plugin.pluginLibraries.join(", ");
let typeLabel = aSubject.getElementById("pluginMimeTypes"), types = [];
let typeLabel = document.getElementById("pluginMimeTypes"), types = [];
for (let type of plugin.pluginMimeTypes) {
let extras = [type.description.trim(), type.suffixes].
filter(x => x).join(": ");
@ -68,7 +70,7 @@ var PluginProvider = {
}
typeLabel.textContent = types.join(",\n");
let showProtectedModePref = canDisableFlashProtectedMode(plugin);
aSubject.getElementById("pluginEnableProtectedMode")
document.getElementById("pluginEnableProtectedMode")
.setAttribute("collapsed", showProtectedModePref ? "" : "true");
});
break;
@ -525,7 +527,7 @@ PluginWrapper.prototype = {
},
get optionsType() {
return AddonManager.OPTIONS_TYPE_INLINE;
return AddonManager.OPTIONS_TYPE_INLINE_BROWSER;
},
get optionsURL() {

Просмотреть файл

@ -24,6 +24,7 @@ toolkit.jar:
content/mozapps/extensions/newaddon.xul (content/newaddon.xul)
content/mozapps/extensions/newaddon.js (content/newaddon.js)
content/mozapps/extensions/pluginPrefs.xul (content/pluginPrefs.xul)
content/mozapps/extensions/pluginPrefs.js (content/pluginPrefs.js)
content/mozapps/extensions/gmpPrefs.xul (content/gmpPrefs.xul)
content/mozapps/extensions/OpenH264-license.txt (content/OpenH264-license.txt)
#endif

Просмотреть файл

@ -35,7 +35,7 @@ add_test(function() {
AddonManager.getAddonByID(testPluginId, function(testPlugin) {
let pluginEl = get_addon_element(gManagerWindow, testPluginId);
is(pluginEl.mAddon.optionsType, AddonManager.OPTIONS_TYPE_INLINE, "Options should be inline type");
is(pluginEl.mAddon.optionsType, AddonManager.OPTIONS_TYPE_INLINE_BROWSER, "Options should be inline type");
pluginEl.parentNode.ensureElementIsVisible(pluginEl);
let button = gManagerWindow.document.getAnonymousElementByAttribute(pluginEl, "anonid", "preferences-btn");
@ -44,18 +44,25 @@ add_test(function() {
button = gManagerWindow.document.getAnonymousElementByAttribute(pluginEl, "anonid", "details-btn");
EventUtils.synthesizeMouseAtCenter(button, { clickCount: 1 }, gManagerWindow);
wait_for_view_load(gManagerWindow, function() {
let pluginLibraries = gManagerWindow.document.getElementById("pluginLibraries");
ok(pluginLibraries, "Plugin file name row should be displayed");
// the file name depends on the platform
ok(pluginLibraries.textContent, testPlugin.pluginLibraries, "Plugin file name should be displayed");
Services.obs.addObserver(function observer(subject, topic, data) {
Services.obs.removeObserver(observer, topic);
let pluginMimeTypes = gManagerWindow.document.getElementById("pluginMimeTypes");
ok(pluginMimeTypes, "Plugin mime type row should be displayed");
ok(pluginMimeTypes.textContent, "application/x-test (tst)", "Plugin mime type should be displayed");
// Wait for PluginProvider to do its stuff.
executeSoon(function() {
let doc = gManagerWindow.document.getElementById("addon-options").contentDocument;
run_next_test();
});
let pluginLibraries = doc.getElementById("pluginLibraries");
ok(pluginLibraries, "Plugin file name row should be displayed");
// the file name depends on the platform
ok(pluginLibraries.textContent, testPlugin.pluginLibraries, "Plugin file name should be displayed");
let pluginMimeTypes = doc.getElementById("pluginMimeTypes");
ok(pluginMimeTypes, "Plugin mime type row should be displayed");
ok(pluginMimeTypes.textContent, "application/x-test (tst)", "Plugin mime type should be displayed");
run_next_test();
});
}, AddonManager.OPTIONS_NOTIFICATION_DISPLAYED);
});
});
});