зеркало из https://github.com/mozilla/gecko-dev.git
Bug 819493: the Know Your Rights notification box has moved to be shown as default snippet on first startup. r=gavin
--HG-- extra : rebase_source : f16a45e155e1a151c010ceaaab0d2878ea4a5da4
This commit is contained in:
Родитель
837aa0ba81
Коммит
17e22dafd8
|
@ -140,7 +140,8 @@ a {
|
|||
}
|
||||
|
||||
#defaultSnippet1,
|
||||
#defaultSnippet2 {
|
||||
#defaultSnippet2,
|
||||
#rightsSnippet {
|
||||
display: block;
|
||||
min-height: 38px;
|
||||
background: 30px center no-repeat;
|
||||
|
@ -148,8 +149,13 @@ a {
|
|||
-moz-padding-start: 79px;
|
||||
}
|
||||
|
||||
#rightsSnippet[hidden] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#defaultSnippet1:-moz-dir(rtl),
|
||||
#defaultSnippet2:-moz-dir(rtl) {
|
||||
#defaultSnippet2:-moz-dir(rtl),
|
||||
#rightsSnippet:-moz-dir(rtl) {
|
||||
background-position: right 30px center;
|
||||
}
|
||||
|
||||
|
@ -351,7 +357,8 @@ body[narrow] #restorePreviousSession::before {
|
|||
*/
|
||||
@media not all and (max-resolution: 1dppx) {
|
||||
#defaultSnippet1,
|
||||
#defaultSnippet2 {
|
||||
#defaultSnippet2,
|
||||
#rightsSnippet {
|
||||
background-size: 40px;
|
||||
}
|
||||
|
||||
|
|
|
@ -340,6 +340,19 @@ function loadSnippets()
|
|||
let _snippetsShown = false;
|
||||
function showSnippets()
|
||||
{
|
||||
let snippetsElt = document.getElementById("snippets");
|
||||
|
||||
// Show about:rights notification, if needed.
|
||||
let showRights = document.documentElement.getAttribute("showKnowYourRights");
|
||||
if (showRights) {
|
||||
let rightsElt = document.getElementById("rightsSnippet");
|
||||
let anchor = rightsElt.getElementsByTagName("a")[0];
|
||||
anchor.href = "about:rights";
|
||||
snippetsElt.appendChild(rightsElt);
|
||||
rightsElt.removeAttribute("hidden");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!gSnippetsMap)
|
||||
throw new Error("Snippets map has not properly been initialized");
|
||||
if (_snippetsShown) {
|
||||
|
@ -350,7 +363,6 @@ function showSnippets()
|
|||
}
|
||||
_snippetsShown = true;
|
||||
|
||||
let snippetsElt = document.getElementById("snippets");
|
||||
let snippets = gSnippetsMap.get("snippets");
|
||||
// If there are remotely fetched snippets, try to to show them.
|
||||
if (snippets) {
|
||||
|
|
|
@ -49,6 +49,7 @@
|
|||
<span id="defaultSnippet1">&abouthome.defaultSnippet1.v1;</span>
|
||||
<span id="defaultSnippet2">&abouthome.defaultSnippet2.v1;</span>
|
||||
</div>
|
||||
<span id="rightsSnippet" hidden="true">&abouthome.rightsSnippet;</span>
|
||||
<div id="snippets"/>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -2276,7 +2276,15 @@ function BrowserOnAboutPageLoad(doc) {
|
|||
|
||||
// Inject search engine and snippets URL.
|
||||
let docElt = doc.documentElement;
|
||||
// set the following attributes BEFORE searchEngineURL, which triggers to
|
||||
// show the snippets when it's set.
|
||||
docElt.setAttribute("snippetsURL", AboutHomeUtils.snippetsURL);
|
||||
if (AboutHomeUtils.showKnowYourRights) {
|
||||
docElt.setAttribute("showKnowYourRights", "true");
|
||||
// Set pref to indicate we've shown the notification.
|
||||
let currentVersion = Services.prefs.getIntPref("browser.rights.version");
|
||||
Services.prefs.setBoolPref("browser.rights." + currentVersion + ".shown", true);
|
||||
}
|
||||
docElt.setAttribute("snippetsVersion", AboutHomeUtils.snippetsVersion);
|
||||
docElt.setAttribute("searchEngineName",
|
||||
AboutHomeUtils.defaultSearchEngine.name);
|
||||
|
|
|
@ -9,14 +9,14 @@ XPCOMUtils.defineLazyModuleGetter(this, "Task",
|
|||
XPCOMUtils.defineLazyModuleGetter(this, "AboutHomeUtils",
|
||||
"resource:///modules/AboutHomeUtils.jsm");
|
||||
|
||||
let gRightsVersion = Services.prefs.getIntPref("browser.rights.version");
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
// Ensure we don't pollute prefs for next tests.
|
||||
try {
|
||||
Services.prefs.clearUserPref("network.cookies.cookieBehavior");
|
||||
} catch (ex) {}
|
||||
try {
|
||||
Services.prefs.clearUserPref("network.cookie.lifetimePolicy");
|
||||
} catch (ex) {}
|
||||
Services.prefs.clearUserPref("network.cookies.cookieBehavior");
|
||||
Services.prefs.clearUserPref("network.cookie.lifetimePolicy");
|
||||
Services.prefs.clearUserPref("browser.rights.override");
|
||||
Services.prefs.clearUserPref("browser.rights." + gRightsVersion + ".shown");
|
||||
});
|
||||
|
||||
let gTests = [
|
||||
|
@ -200,6 +200,50 @@ let gTests = [
|
|||
}
|
||||
},
|
||||
|
||||
{
|
||||
desc: "Check if the 'Know Your Rights default snippet is shown when 'browser.rights.override' pref is set",
|
||||
beforeRun: function ()
|
||||
{
|
||||
Services.prefs.setBoolPref("browser.rights.override", false);
|
||||
},
|
||||
setup: function () { },
|
||||
run: function (aSnippetsMap)
|
||||
{
|
||||
let doc = gBrowser.selectedTab.linkedBrowser.contentDocument;
|
||||
let showRights = AboutHomeUtils.showKnowYourRights;
|
||||
|
||||
ok(showRights, "AboutHomeUtils.showKnowYourRights should be TRUE");
|
||||
|
||||
let snippetsElt = doc.getElementById("snippets");
|
||||
ok(snippetsElt, "Found snippets element");
|
||||
is(snippetsElt.getElementsByTagName("a")[0].href, "about:rights", "Snippet link is present.");
|
||||
|
||||
Services.prefs.clearUserPref("browser.rights.override");
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
desc: "Check if the 'Know Your Rights default snippet is NOT shown when 'browser.rights.override' pref is NOT set",
|
||||
beforeRun: function ()
|
||||
{
|
||||
Services.prefs.setBoolPref("browser.rights.override", true);
|
||||
},
|
||||
setup: function () { },
|
||||
run: function (aSnippetsMap)
|
||||
{
|
||||
let doc = gBrowser.selectedTab.linkedBrowser.contentDocument;
|
||||
let rightsData = AboutHomeUtils.knowYourRightsData;
|
||||
|
||||
ok(!rightsData, "AboutHomeUtils.knowYourRightsData should be FALSE");
|
||||
|
||||
let snippetsElt = doc.getElementById("snippets");
|
||||
ok(snippetsElt, "Found snippets element");
|
||||
ok(snippetsElt.getElementsByTagName("a")[0].href != "about:rights", "Snippet link should not point to about:rights.");
|
||||
|
||||
Services.prefs.clearUserPref("browser.rights.override");
|
||||
}
|
||||
}
|
||||
|
||||
];
|
||||
|
||||
function test()
|
||||
|
@ -210,6 +254,9 @@ function test()
|
|||
for (let test of gTests) {
|
||||
info(test.desc);
|
||||
|
||||
if (test.beforeRun)
|
||||
yield test.beforeRun();
|
||||
|
||||
let tab = yield promiseNewTabLoadEvent("about:home", "DOMContentLoaded");
|
||||
|
||||
// Must wait for both the snippets map and the browser attributes, since
|
||||
|
|
|
@ -20,8 +20,4 @@ EXTRA_PP_COMPONENTS = \
|
|||
|
||||
EXTRA_JS_MODULES = distribution.js
|
||||
|
||||
ifdef MOZILLA_OFFICIAL
|
||||
DEFINES += -DOFFICIAL_BUILD=1
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
|
|
@ -528,11 +528,6 @@ BrowserGlue.prototype = {
|
|||
|
||||
// All initial windows have opened.
|
||||
_onWindowsRestored: function BG__onWindowsRestored() {
|
||||
// Show about:rights notification, if needed.
|
||||
if (this._shouldShowRights()) {
|
||||
this._showRightsNotification();
|
||||
}
|
||||
|
||||
// Show update notification, if needed.
|
||||
if (Services.prefs.prefHasUserValue("app.update.postupdate"))
|
||||
this._showUpdateNotification();
|
||||
|
@ -761,78 +756,6 @@ BrowserGlue.prototype = {
|
|||
}
|
||||
},
|
||||
|
||||
/*
|
||||
* _shouldShowRights - Determines if the user should be shown the
|
||||
* about:rights notification. The notification should *not* be shown if
|
||||
* we've already shown the current version, or if the override pref says to
|
||||
* never show it. The notification *should* be shown if it's never been seen
|
||||
* before, if a newer version is available, or if the override pref says to
|
||||
* always show it.
|
||||
*/
|
||||
_shouldShowRights: function BG__shouldShowRights() {
|
||||
// Look for an unconditional override pref. If set, do what it says.
|
||||
// (true --> never show, false --> always show)
|
||||
try {
|
||||
return !Services.prefs.getBoolPref("browser.rights.override");
|
||||
} catch (e) { }
|
||||
// Ditto, for the legacy EULA pref.
|
||||
try {
|
||||
return !Services.prefs.getBoolPref("browser.EULA.override");
|
||||
} catch (e) { }
|
||||
|
||||
#ifndef OFFICIAL_BUILD
|
||||
// Non-official builds shouldn't shouldn't show the notification.
|
||||
return false;
|
||||
#endif
|
||||
|
||||
// Look to see if the user has seen the current version or not.
|
||||
var currentVersion = Services.prefs.getIntPref("browser.rights.version");
|
||||
try {
|
||||
return !Services.prefs.getBoolPref("browser.rights." + currentVersion + ".shown");
|
||||
} catch (e) { }
|
||||
|
||||
// Legacy: If the user accepted a EULA, we won't annoy them with the
|
||||
// equivalent about:rights page until the version changes.
|
||||
try {
|
||||
return !Services.prefs.getBoolPref("browser.EULA." + currentVersion + ".accepted");
|
||||
} catch (e) { }
|
||||
|
||||
// We haven't shown the notification before, so do so now.
|
||||
return true;
|
||||
},
|
||||
|
||||
_showRightsNotification: function BG__showRightsNotification() {
|
||||
// Stick the notification onto the selected tab of the active browser window.
|
||||
var win = this.getMostRecentBrowserWindow();
|
||||
var notifyBox = win.gBrowser.getNotificationBox();
|
||||
|
||||
var brandBundle = Services.strings.createBundle("chrome://branding/locale/brand.properties");
|
||||
var rightsBundle = Services.strings.createBundle("chrome://global/locale/aboutRights.properties");
|
||||
|
||||
var buttonLabel = rightsBundle.GetStringFromName("buttonLabel");
|
||||
var buttonAccessKey = rightsBundle.GetStringFromName("buttonAccessKey");
|
||||
var productName = brandBundle.GetStringFromName("brandFullName");
|
||||
var notifyRightsText = rightsBundle.formatStringFromName("notifyRightsText", [productName], 1);
|
||||
|
||||
var buttons = [
|
||||
{
|
||||
label: buttonLabel,
|
||||
accessKey: buttonAccessKey,
|
||||
popup: null,
|
||||
callback: function(aNotificationBar, aButton) {
|
||||
win.openUILinkIn("about:rights", "tab");
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
// Set pref to indicate we've shown the notification.
|
||||
var currentVersion = Services.prefs.getIntPref("browser.rights.version");
|
||||
Services.prefs.setBoolPref("browser.rights." + currentVersion + ".shown", true);
|
||||
|
||||
var notification = notifyBox.appendNotification(notifyRightsText, "about-rights", null, notifyBox.PRIORITY_INFO_LOW, buttons);
|
||||
notification.persistence = -1; // Until user closes it
|
||||
},
|
||||
|
||||
_showUpdateNotification: function BG__showUpdateNotification() {
|
||||
Services.prefs.clearUserPref("app.update.postupdate");
|
||||
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
text in <a/> will be linked to the featured add-ons on addons.mozilla.org
|
||||
-->
|
||||
<!ENTITY abouthome.defaultSnippet2.v1 "It's easy to customize your Firefox exactly the way you want it. <a>Choose from thousands of add-ons</a>.">
|
||||
<!-- LOCALIZATION NOTE (abouthome.rightsSnippet): text in <a/> will be linked to about:rights -->
|
||||
<!ENTITY abouthome.rightsSnippet "&brandFullName; is free and open source software from the non-profit Mozilla Foundation. <a>Know your rights…</a>">
|
||||
|
||||
<!ENTITY abouthome.bookmarksButton.label "Bookmarks">
|
||||
<!ENTITY abouthome.historyButton.label "History">
|
||||
|
|
|
@ -16,7 +16,47 @@ const SNIPPETS_URL_PREF = "browser.aboutHomeSnippets.updateUrl";
|
|||
const STARTPAGE_VERSION = 4;
|
||||
|
||||
this.AboutHomeUtils = {
|
||||
get snippetsVersion() STARTPAGE_VERSION
|
||||
get snippetsVersion() STARTPAGE_VERSION,
|
||||
|
||||
/*
|
||||
* showKnowYourRights - Determines if the user should be shown the
|
||||
* about:rights notification. The notification should *not* be shown if
|
||||
* we've already shown the current version, or if the override pref says to
|
||||
* never show it. The notification *should* be shown if it's never been seen
|
||||
* before, if a newer version is available, or if the override pref says to
|
||||
* always show it.
|
||||
*/
|
||||
get showKnowYourRights() {
|
||||
// Look for an unconditional override pref. If set, do what it says.
|
||||
// (true --> never show, false --> always show)
|
||||
try {
|
||||
return !Services.prefs.getBoolPref("browser.rights.override");
|
||||
} catch (e) { }
|
||||
// Ditto, for the legacy EULA pref.
|
||||
try {
|
||||
return !Services.prefs.getBoolPref("browser.EULA.override");
|
||||
} catch (e) { }
|
||||
|
||||
#ifndef MOZILLA_OFFICIAL
|
||||
// Non-official builds shouldn't show the notification.
|
||||
return false;
|
||||
#endif
|
||||
|
||||
// Look to see if the user has seen the current version or not.
|
||||
var currentVersion = Services.prefs.getIntPref("browser.rights.version");
|
||||
try {
|
||||
return !Services.prefs.getBoolPref("browser.rights." + currentVersion + ".shown");
|
||||
} catch (e) { }
|
||||
|
||||
// Legacy: If the user accepted a EULA, we won't annoy them with the
|
||||
// equivalent about:rights page until the version changes.
|
||||
try {
|
||||
return !Services.prefs.getBoolPref("browser.EULA." + currentVersion + ".accepted");
|
||||
} catch (e) { }
|
||||
|
||||
// We haven't shown the notification before, so do so now.
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -12,7 +12,6 @@ include $(DEPTH)/config/autoconf.mk
|
|||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
EXTRA_JS_MODULES = \
|
||||
AboutHomeUtils.jsm \
|
||||
BrowserNewTabPreloader.jsm \
|
||||
openLocationLastURL.jsm \
|
||||
NetworkPrioritizer.jsm \
|
||||
|
@ -26,6 +25,7 @@ EXTRA_JS_MODULES = \
|
|||
$(NULL)
|
||||
|
||||
EXTRA_PP_JS_MODULES = \
|
||||
AboutHomeUtils.jsm \
|
||||
RecentWindow.jsm \
|
||||
$(NULL)
|
||||
|
||||
|
@ -37,4 +37,8 @@ EXTRA_JS_MODULES += \
|
|||
$(NULL)
|
||||
endif
|
||||
|
||||
ifdef MOZILLA_OFFICIAL
|
||||
DEFINES += -DMOZILLA_OFFICIAL=1
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
# 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/.
|
||||
|
||||
buttonLabel = Know your rights…
|
||||
buttonAccessKey = K
|
||||
notifyRightsText = %S is free and open source software from the non-profit Mozilla Foundation.
|
|
@ -9,7 +9,6 @@
|
|||
locale/@AB_CD@/global/about.dtd (%chrome/global/about.dtd)
|
||||
locale/@AB_CD@/global/aboutAbout.dtd (%chrome/global/aboutAbout.dtd)
|
||||
locale/@AB_CD@/global/aboutRights.dtd (%chrome/global/aboutRights.dtd)
|
||||
locale/@AB_CD@/global/aboutRights.properties (%chrome/global/aboutRights.properties)
|
||||
locale/@AB_CD@/global/aboutSupport.dtd (%chrome/global/aboutSupport.dtd)
|
||||
locale/@AB_CD@/global/aboutSupport.properties (%chrome/global/aboutSupport.properties)
|
||||
locale/@AB_CD@/global/aboutTelemetry.dtd (%chrome/global/aboutTelemetry.dtd)
|
||||
|
|
Загрузка…
Ссылка в новой задаче