Exemplo n.º 1
0
    addNetworkLocationsObserver(this.onNetworkLocationsUpdated);
    addUSBRuntimesObserver(this.onUSBRuntimesUpdated);
    await enableUSBRuntimes();
  },

  async createMessageContexts() {
    // XXX Until the strings for the updated about:debugging stabilize, we
    // locate them outside the regular directory for locale resources so that
    // they don't get picked up by localization tools.
    if (!L10nRegistry.sources.has("aboutdebugging")) {
      const temporarySource = new FileSource(
        "aboutdebugging",
        ["en-US"],
        "chrome://devtools/content/aboutdebugging-new/tmp-locale/{locale}/"
      );
      L10nRegistry.registerSource(temporarySource);
    }

    const locales = Services.locale.appLocalesAsBCP47;
    const generator =
      L10nRegistry.generateContexts(locales, ["aboutdebugging.ftl"]);

    const contexts = [];
    for await (const context of generator) {
      contexts.push(context);
    }

    return contexts;
  },

  onNetworkLocationsUpdated() {
Exemplo n.º 2
0
    const messageContexts = await this.createMessageContexts();

    // Render the root Application component.
    const app = App({ client: this.client, messageContexts, serviceContainer });
    render(Provider({ store: this.store }, app), this.mount);
  },

  /**
   * Retrieve message contexts for the current locales, and return them as an array of
   * MessageContext elements.
   */
  async createMessageContexts() {
    const locales = Services.locale.appLocalesAsBCP47;
    const generator =
      L10nRegistry.generateContexts(locales, ["devtools/application.ftl"]);

    // Return value of generateContexts is a generator and should be converted to
    // a sync iterable before using it with React.
    const contexts = [];
    for await (const message of generator) {
      contexts.push(message);
    }

    return contexts;
  },

  async updateWorkers() {
    const { service } = await this.client.mainRoot.listAllWorkers();
    this.actions.updateWorkers(service);
  },