AboutHomeUtils.jsm 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /* This Source Code Form is subject to the terms of the Mozilla Public
  2. * License, v. 2.0. If a copy of the MPL was not distributed with this
  3. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  4. "use strict";
  5. this.EXPORTED_SYMBOLS = [ "AboutHomeUtils" ];
  6. Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
  7. Components.utils.import("resource://gre/modules/Services.jsm");
  8. this.AboutHomeUtils = {
  9. /**
  10. * Returns an object containing the name and searchURL of the original default
  11. * search engine.
  12. */
  13. get defaultSearchEngine() {
  14. let defaultEngine = Services.search.defaultEngine;
  15. let submission = defaultEngine.getSubmission("_searchTerms_", null, "homepage");
  16. return Object.freeze({
  17. name: defaultEngine.name,
  18. searchURL: submission.uri.spec,
  19. postDataString: submission.postDataString
  20. });
  21. },
  22. /*
  23. * showKnowYourRights - Determines if the user should be shown the
  24. * about:rights notification. The notification should *not* be shown if
  25. * we've already shown the current version, or if the override pref says to
  26. * never show it. The notification *should* be shown if it's never been seen
  27. * before, if a newer version is available, or if the override pref says to
  28. * always show it.
  29. */
  30. get showKnowYourRights() {
  31. // Look for an unconditional override pref. If set, do what it says.
  32. // (true --> never show, false --> always show)
  33. try {
  34. return !Services.prefs.getBoolPref("browser.rights.override");
  35. } catch (e) { }
  36. // Ditto, for the legacy EULA pref.
  37. try {
  38. return !Services.prefs.getBoolPref("browser.EULA.override");
  39. } catch (e) { }
  40. #ifndef MC_OFFICIAL
  41. // Non-official builds shouldn't show the notification.
  42. return false;
  43. #endif
  44. // Look to see if the user has seen the current version or not.
  45. var currentVersion = Services.prefs.getIntPref("browser.rights.version");
  46. try {
  47. return !Services.prefs.getBoolPref("browser.rights." + currentVersion + ".shown");
  48. } catch (e) { }
  49. // Legacy: If the user accepted a EULA, we won't annoy them with the
  50. // equivalent about:rights page until the version changes.
  51. try {
  52. return !Services.prefs.getBoolPref("browser.EULA." + currentVersion + ".accepted");
  53. } catch (e) { }
  54. // We haven't shown the notification before, so do so now.
  55. return true;
  56. }
  57. };