"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "toolkit/modules/NewTabUtils.jsm" between
UXP-2019.03.27.tar.gz and UXP-2019.06.08.tar.gz

About: Basilisk is a full-featured, optimized browser derived from the code behind the pre-Servo Firefox browser (29–56 era). UXP = Unified XUL Platform. Source code.

NewTabUtils.jsm  (UXP-2019.03.27):NewTabUtils.jsm  (UXP-2019.06.08)
skipping to change at line 39 skipping to change at line 39
XPCOMUtils.defineLazyGetter(this, "gUnicodeConverter", function () { XPCOMUtils.defineLazyGetter(this, "gUnicodeConverter", function () {
let converter = Cc["@mozilla.org/intl/scriptableunicodeconverter"] let converter = Cc["@mozilla.org/intl/scriptableunicodeconverter"]
.createInstance(Ci.nsIScriptableUnicodeConverter); .createInstance(Ci.nsIScriptableUnicodeConverter);
converter.charset = 'utf8'; converter.charset = 'utf8';
return converter; return converter;
}); });
// Boolean preferences that control newtab content // Boolean preferences that control newtab content
const PREF_NEWTAB_ENABLED = "browser.newtabpage.enabled"; const PREF_NEWTAB_ENABLED = "browser.newtabpage.enabled";
const PREF_NEWTAB_ENHANCED = "browser.newtabpage.enhanced";
// The preference that tells the number of rows of the newtab grid. // The preference that tells the number of rows of the newtab grid.
const PREF_NEWTAB_ROWS = "browser.newtabpage.rows"; const PREF_NEWTAB_ROWS = "browser.newtabpage.rows";
// The preference that tells the number of columns of the newtab grid. // The preference that tells the number of columns of the newtab grid.
const PREF_NEWTAB_COLUMNS = "browser.newtabpage.columns"; const PREF_NEWTAB_COLUMNS = "browser.newtabpage.columns";
// The maximum number of results PlacesProvider retrieves from history. // The maximum number of results PlacesProvider retrieves from history.
const HISTORY_RESULTS_LIMIT = 100; const HISTORY_RESULTS_LIMIT = 100;
skipping to change at line 122 skipping to change at line 121
get _prefs() { get _prefs() {
return Object.freeze({ return Object.freeze({
pinnedLinks: "browser.newtabpage.pinned", pinnedLinks: "browser.newtabpage.pinned",
blockedLinks: "browser.newtabpage.blocked", blockedLinks: "browser.newtabpage.blocked",
}); });
}, },
get _storedVersion() { get _storedVersion() {
if (this.__storedVersion === undefined) { if (this.__storedVersion === undefined) {
try { // The storage version is unknown, so either:
this.__storedVersion = // - it's a new profile
Services.prefs.getIntPref("browser.newtabpage.storageVersion"); // - it's a profile where versioning information got lost
} catch (ex) { // In this case we still run through all of the valid migrations,
// The storage version is unknown, so either: // starting from 1, as if it was a downgrade. As previously stated the
// - it's a new profile // migrations should already support running on an updated store.
// - it's a profile where versioning information got lost this.__storedVersion =
// In this case we still run through all of the valid migrations, Services.prefs.getIntPref("browser.newtabpage.storageVersion", 1);
// starting from 1, as if it was a downgrade. As previously stated the
// migrations should already support running on an updated store.
this.__storedVersion = 1;
}
} }
return this.__storedVersion; return this.__storedVersion;
}, },
set _storedVersion(aValue) { set _storedVersion(aValue) {
Services.prefs.setIntPref("browser.newtabpage.storageVersion", aValue); Services.prefs.setIntPref("browser.newtabpage.storageVersion", aValue);
this.__storedVersion = aValue; this.__storedVersion = aValue;
return aValue; return aValue;
}, },
/** /**
skipping to change at line 206 skipping to change at line 201
* The array containing all active pages. * The array containing all active pages.
*/ */
_pages: [], _pages: [],
/** /**
* Cached value that tells whether the New Tab Page feature is enabled. * Cached value that tells whether the New Tab Page feature is enabled.
*/ */
_enabled: null, _enabled: null,
/** /**
* Cached value that tells whether the New Tab Page feature is enhanced.
*/
_enhanced: null,
/**
* Adds a page to the internal list of pages. * Adds a page to the internal list of pages.
* @param aPage The page to register. * @param aPage The page to register.
*/ */
register: function AllPages_register(aPage) { register: function AllPages_register(aPage) {
this._pages.push(aPage); this._pages.push(aPage);
this._addObserver(); this._addObserver();
}, },
/** /**
* Removes a page from the internal list of pages. * Removes a page from the internal list of pages.
skipping to change at line 248 skipping to change at line 238
/** /**
* Enables or disables the 'New Tab Page' feature. * Enables or disables the 'New Tab Page' feature.
*/ */
set enabled(aEnabled) { set enabled(aEnabled) {
if (this.enabled != aEnabled) if (this.enabled != aEnabled)
Services.prefs.setBoolPref(PREF_NEWTAB_ENABLED, !!aEnabled); Services.prefs.setBoolPref(PREF_NEWTAB_ENABLED, !!aEnabled);
}, },
/** /**
* Returns whether the history tiles are enhanced.
*/
get enhanced() {
#if defined(MC_BASILISK) || defined(HYPE_ICEWEASEL)
// Hard-block the use of sponsored tiles.
return false;
#else
if (this._enhanced === null)
this._enhanced = Services.prefs.getBoolPref(PREF_NEWTAB_ENHANCED);
return this._enhanced;
#endif
},
/**
* Enables or disables the enhancement of history tiles feature.
*/
set enhanced(aEnhanced) {
if (this.enhanced != aEnhanced)
Services.prefs.setBoolPref(PREF_NEWTAB_ENHANCED, !!aEnhanced);
},
/**
* Returns the number of registered New Tab Pages (i.e. the number of open * Returns the number of registered New Tab Pages (i.e. the number of open
* about:newtab instances). * about:newtab instances).
*/ */
get length() { get length() {
return this._pages.length; return this._pages.length;
}, },
/** /**
* Updates all currently active pages but the given one. * Updates all currently active pages but the given one.
* @param aExceptPage The page to exclude from updating. * @param aExceptPage The page to exclude from updating.
skipping to change at line 302 skipping to change at line 269
* Implements the nsIObserver interface to get notified when the preference * Implements the nsIObserver interface to get notified when the preference
* value changes or when a new copy of a page thumbnail is available. * value changes or when a new copy of a page thumbnail is available.
*/ */
observe: function AllPages_observe(aSubject, aTopic, aData) { observe: function AllPages_observe(aSubject, aTopic, aData) {
if (aTopic == "nsPref:changed") { if (aTopic == "nsPref:changed") {
// Clear the cached value. // Clear the cached value.
switch (aData) { switch (aData) {
case PREF_NEWTAB_ENABLED: case PREF_NEWTAB_ENABLED:
this._enabled = null; this._enabled = null;
break; break;
case PREF_NEWTAB_ENHANCED:
this._enhanced = null;
break;
} }
} }
// and all notifications get forwarded to each page. // and all notifications get forwarded to each page.
this._pages.forEach(function (aPage) { this._pages.forEach(function (aPage) {
aPage.observe(aSubject, aTopic, aData); aPage.observe(aSubject, aTopic, aData);
}, this); }, this);
}, },
/** /**
* Adds a preference and new thumbnail observer and turns itself into a * Adds a preference and new thumbnail observer and turns itself into a
* no-op after the first invokation. * no-op after the first invokation.
*/ */
_addObserver: function AllPages_addObserver() { _addObserver: function AllPages_addObserver() {
Services.prefs.addObserver(PREF_NEWTAB_ENABLED, this, true); Services.prefs.addObserver(PREF_NEWTAB_ENABLED, this, true);
Services.prefs.addObserver(PREF_NEWTAB_ENHANCED, this, true);
Services.obs.addObserver(this, "page-thumbnail:create", true); Services.obs.addObserver(this, "page-thumbnail:create", true);
this._addObserver = function () {}; this._addObserver = function () {};
}, },
QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver, QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver,
Ci.nsISupportsWeakReference]) Ci.nsISupportsWeakReference])
}; };
/** /**
* Singleton that keeps Grid preferences * Singleton that keeps Grid preferences
skipping to change at line 485 skipping to change at line 448
/** /**
* Transforms link into a "history" link * Transforms link into a "history" link
* @param aLink The link to change * @param aLink The link to change
* @return true if link changes, false otherwise * @return true if link changes, false otherwise
*/ */
_makeHistoryLink: function PinnedLinks_makeHistoryLink(aLink) { _makeHistoryLink: function PinnedLinks_makeHistoryLink(aLink) {
if (!aLink.type || aLink.type == "history") { if (!aLink.type || aLink.type == "history") {
return false; return false;
} }
aLink.type = "history"; aLink.type = "history";
// always remove targetedSite
delete aLink.targetedSite;
return true; return true;
}, },
/** /**
* Replaces existing link with another link. * Replaces existing link with another link.
* @param aUrl The url of existing link * @param aUrl The url of existing link
* @param aLink The replacement link * @param aLink The replacement link
*/ */
replace: function PinnedLinks_replace(aUrl, aLink) { replace: function PinnedLinks_replace(aUrl, aLink) {
let index = this._indexOfLink({url: aUrl}); let index = this._indexOfLink({url: aUrl});
skipping to change at line 1104 skipping to change at line 1065
}); });
}, },
/** /**
* Merges the cached lists of links from all providers whose lists are cached. * Merges the cached lists of links from all providers whose lists are cached.
* @return The merged list. * @return The merged list.
*/ */
_getMergedProviderLinks: function Links__getMergedProviderLinks() { _getMergedProviderLinks: function Links__getMergedProviderLinks() {
// Build a list containing a copy of each provider's sortedLinks list. // Build a list containing a copy of each provider's sortedLinks list.
let linkLists = []; let linkLists = [];
let { console } = Cu.import("resource://gre/modules/Console.jsm", {});
for (let provider of this._providers.keys()) { for (let provider of this._providers.keys()) {
if (!AllPages.enhanced && provider != PlacesProvider) {
// Only show history tiles if we're not in 'enhanced' mode.
continue;
}
let links = this._providers.get(provider); let links = this._providers.get(provider);
if (links && links.sortedLinks) { if (links && links.sortedLinks) {
linkLists.push(links.sortedLinks.slice()); linkLists.push(links.sortedLinks.slice());
} }
} }
function getNextLink() { function getNextLink() {
let minLinks = null; let minLinks = null;
for (let links of linkLists) { for (let links of linkLists) {
if (links.length && if (links.length &&
skipping to change at line 1310 skipping to change at line 1268
Services.obs.addObserver(this, TOPIC_GATHER_TELEMETRY, false); Services.obs.addObserver(this, TOPIC_GATHER_TELEMETRY, false);
}, },
/** /**
* Collects data. * Collects data.
*/ */
_collect: function Telemetry_collect() { _collect: function Telemetry_collect() {
let probes = [ let probes = [
{ histogram: "NEWTAB_PAGE_ENABLED", { histogram: "NEWTAB_PAGE_ENABLED",
value: AllPages.enabled }, value: AllPages.enabled },
{ histogram: "NEWTAB_PAGE_ENHANCED",
value: AllPages.enhanced },
{ histogram: "NEWTAB_PAGE_PINNED_SITES_COUNT", { histogram: "NEWTAB_PAGE_PINNED_SITES_COUNT",
value: PinnedLinks.links.length }, value: PinnedLinks.links.length },
{ histogram: "NEWTAB_PAGE_BLOCKED_SITES_COUNT", { histogram: "NEWTAB_PAGE_BLOCKED_SITES_COUNT",
value: Object.keys(BlockedLinks.links).length } value: Object.keys(BlockedLinks.links).length }
]; ];
probes.forEach(function Telemetry_collect_forEach(aProbe) { probes.forEach(function Telemetry_collect_forEach(aProbe) {
Services.telemetry.getHistogramById(aProbe.histogram) Services.telemetry.getHistogramById(aProbe.histogram)
.add(aProbe.value); .add(aProbe.value);
}); });
 End of changes. 10 change blocks. 
53 lines changed or deleted 9 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)