How to use the devtools/sham/services.Services.prefs function in devtools

To help you get started, we’ve selected a few devtools examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github joewalker / devtools.html / client / styleinspector / rule-view.js View on Github external
this.pseudoClassToggle.addEventListener("click",
                                          this._onTogglePseudoClassPanel);
  this.hoverCheckbox.addEventListener("click", this._onTogglePseudoClass);
  this.activeCheckbox.addEventListener("click", this._onTogglePseudoClass);
  this.focusCheckbox.addEventListener("click", this._onTogglePseudoClass);

  this._handlePrefChange = this._handlePrefChange.bind(this);
  this._onSourcePrefChanged = this._onSourcePrefChanged.bind(this);

  this._prefObserver = new PrefObserver("devtools.");
  this._prefObserver.on(PREF_ORIG_SOURCES, this._onSourcePrefChanged);
  this._prefObserver.on(PREF_UA_STYLES, this._handlePrefChange);
  this._prefObserver.on(PREF_DEFAULT_COLOR_UNIT, this._handlePrefChange);
  this._prefObserver.on(PREF_ENABLE_MDN_DOCS_TOOLTIP, this._handlePrefChange);

  this.showUserAgentStyles = Services.prefs.getBoolPref(PREF_UA_STYLES);
  this.enableMdnDocsTooltip =
    Services.prefs.getBoolPref(PREF_ENABLE_MDN_DOCS_TOOLTIP);

  let options = {
    autoSelect: true,
    theme: "auto"
  };
  this.popup = new AutocompletePopup(this.styleWindow.parent.document, options);

  this._showEmpty();

  this._contextmenu = new StyleInspectorMenu(this, { isRuleView: true });

  // Add the tooltips and highlighters to the view
  this.tooltips = new overlays.TooltipsOverlay(this);
  this.tooltips.addToView();
github joewalker / devtools.html / client / scratchpad / scratchpad.js View on Github external
XPCOMUtils.defineConstant(this, "BUTTON_POSITION_SAVE", BUTTON_POSITION_SAVE);
XPCOMUtils.defineConstant(this, "BUTTON_POSITION_CANCEL", BUTTON_POSITION_CANCEL);
XPCOMUtils.defineConstant(this, "BUTTON_POSITION_DONT_SAVE", BUTTON_POSITION_DONT_SAVE);
XPCOMUtils.defineConstant(this, "BUTTON_POSITION_REVERT", BUTTON_POSITION_REVERT);

const { VariablesView, escapeHTML } = require("devtools/client/shared/widgets/VariablesView");

const { VariablesViewController, StackFrameUtils } = require("devtools/client/shared/widgets/VariablesViewController");

const { DebuggerServer } = require("devtools/server/main");

const { DebuggerClient } = require("devtools/shared/client/main");
const { EnvironmentClient } = require("devtools/shared/client/main");
const { ObjectClient } = require("devtools/shared/client/main");

const REMOTE_TIMEOUT = Services.prefs.getIntPref("devtools.debugger.remote-timeout");

//XPCOMUtils.defineLazyModuleGetter(this, "ShortcutUtils",
//  "resource://gre/modules/ShortcutUtils.jsm");
//
//XPCOMUtils.defineLazyModuleGetter(this, "Reflect",
//  "resource://gre/modules/reflect.jsm");

// Because we have no constructor / destructor where we can log metrics we need
// to do so here.
var telemetry = new Telemetry();
telemetry.toolOpened("scratchpad");

var WebConsoleUtils = require("devtools/shared/webconsole/utils").Utils;

/**
 * The scratchpad object handles the Scratchpad window functionality.
github joewalker / devtools.html / client / webide / modules / simulator-process.js View on Github external
log(level, message) {
    if (!Services.prefs.getBoolPref("devtools.webide.logSimulatorOutput")) {
      return;
    }
    if (level === "stderr" || level === "error") {
      console.error(message);
      return;
    }
    console.log(message);
  },
github joewalker / devtools.html / client / responsivedesign / responsivedesign.js View on Github external
toggleTouch: Task.async(function*() {
     this.hideTouchNotification();
     if (this.touchEventSimulator.enabled) {
       this.disableTouch();
     } else {
       let isReloadNeeded = yield this.enableTouch();
       if (isReloadNeeded) {
         if (Services.prefs.getBoolPref("devtools.responsiveUI.no-reload-notification")) {
           return;
         }

         let nbox = this.mainWindow.gBrowser.getNotificationBox(this.browser);

         var buttons = [{
           label: this.strings.GetStringFromName("responsiveUI.notificationReload"),
           callback: () => {
             this.browser.reload();
           },
           accessKey: this.strings.GetStringFromName("responsiveUI.notificationReload_accesskey"),
         }, {
           label: this.strings.GetStringFromName("responsiveUI.dontShowReloadNotification"),
           callback: function() {
             Services.prefs.setBoolPref("devtools.responsiveUI.no-reload-notification", true);
           },
github joewalker / devtools.html / client / webide / content / prefs.js View on Github external
function SetPref(name, value) {
  let type = Services.prefs.getPrefType(name);
  switch (type) {
    case Services.prefs.PREF_STRING:
      return Services.prefs.setCharPref(name, value);
    case Services.prefs.PREF_INT:
      return Services.prefs.setIntPref(name, value);
    case Services.prefs.PREF_BOOL:
      return Services.prefs.setBoolPref(name, value);
    default:
      throw new Error("Unknown type");
  }
}
github joewalker / devtools.html / client / framework / toolbox-options.js View on Github external
function SetPref(name, value) {
  let type = Services.prefs.getPrefType(name);
  switch (type) {
    case Services.prefs.PREF_STRING:
      return Services.prefs.setCharPref(name, value);
    case Services.prefs.PREF_INT:
      return Services.prefs.setIntPref(name, value);
    case Services.prefs.PREF_BOOL:
      return Services.prefs.setBoolPref(name, value);
    default:
      throw new Error("Unknown type");
  }
}
github joewalker / devtools.html / shared / indentation.js View on Github external
function getIndentationFromIteration(iterFunc) {
  let indentWithTabs = !Services.prefs.getBoolPref(EXPAND_TAB);
  let indentUnit = Services.prefs.getIntPref(TAB_SIZE);
  let shouldDetect = Services.prefs.getBoolPref(DETECT_INDENT);

  if (shouldDetect) {
    let indent = detectIndentation(iterFunc);
    if (indent != null) {
      indentWithTabs = indent.tabs;
      indentUnit = indent.spaces ? indent.spaces : indentUnit;
    }
  }

  return {indentUnit, indentWithTabs};
}
github joewalker / devtools.html / client / framework / toolbox-options.js View on Github external
function GetPref(name) {
  let type = Services.prefs.getPrefType(name);
  switch (type) {
    case Services.prefs.PREF_STRING:
      return Services.prefs.getCharPref(name);
    case Services.prefs.PREF_INT:
      return Services.prefs.getIntPref(name);
    case Services.prefs.PREF_BOOL:
      return Services.prefs.getBoolPref(name);
    default:
      throw new Error("Unknown type");
  }
}
github joewalker / devtools.html / client / performance / legacy / front.js View on Github external
function getLegacyPerformanceRecordingPrefs () {
  return {
    withMarkers: true,
    withMemory: Services.prefs.getBoolPref("devtools.performance.ui.enable-memory"),
    withTicks: Services.prefs.getBoolPref("devtools.performance.ui.enable-framerate"),
    withAllocations: Services.prefs.getBoolPref("devtools.performance.ui.enable-allocations"),
    withJITOptimizations: Services.prefs.getBoolPref("devtools.performance.ui.enable-jit-optimizations"),
    allocationsSampleProbability: +Services.prefs.getCharPref("devtools.performance.memory.sample-probability"),
    allocationsMaxLogLength: Services.prefs.getIntPref("devtools.performance.memory.max-log-length")
  };
}
github joewalker / devtools.html / client / styleeditor / utils.js View on Github external
function PrefObserver(branchName) {
  this.branchName = branchName;
  this.branch = Services.prefs.getBranch(branchName);
  this.branch.addObserver("", this, false);

  EventEmitter.decorate(this);
}