コード例 #1
0
 SearchProvider.search.state.then(state => {
   let win = windowMediator.getMostRecentWindow("navigator:browser");
   let gBrowser = win.getBrowser();
   let browser = gBrowser.selectedBrowser;
   let searchData = {
     engineName: state.currentEngine.name,
     searchString: msg.data,
     healthReportKey: "d",
     searchPurpose: "d"
   };
   SearchProvider.search.performSearch(browser, searchData);
 });
コード例 #2
0
exports.test_SearchProvider_observe = function*(assert) {
  // test that the event emitter is working by setting a new current engine "TestSearch2"
  let engineName = "TestSearch2";
  SearchProvider.search.init();

  // event emitter will fire when current engine is changed
  let promise = new Promise(resolve => {
    SearchProvider.search.once("browser-search-engine-modified", (name, data) => { // jshint ignore:line
      resolve([name, data.name]);
    });
  });

  // set a new current engine
  Services.search.currentEngine = Services.search.getEngineByName(engineName);
  let expectedEngineName = Services.search.currentEngine.name;

  // emitter should fire and return the new engine
  let [eventName, actualEngineName] = yield promise;
  assert.equal(eventName, "browser-search-engine-modified", `emitter sent the correct event ${eventName}`);
  assert.equal(expectedEngineName, actualEngineName, `emitter set the correct engine ${expectedEngineName}`);
  SearchProvider.search.uninit();
};
コード例 #3
0
    }
  },

  _logPerfMeter({msg, worker}) {
    this._perfMeter.log(worker.tab, msg.type, msg.data);
  },

  /**
   * Sets up various listeners for the pages
   */
  _setupListeners() {
    this._handlePlacesChanges = this._handlePlacesChanges.bind(this);
    PLACES_CHANGES_EVENTS.forEach(event => PlacesProvider.links.on(event, this._handlePlacesChanges));

    this._handleCurrentEngineChanges = this._handleCurrentEngineChanges.bind(this);
    SearchProvider.search.on("browser-search-engine-modified", this._handleCurrentEngineChanges);

    // This is a collection of handlers that receive messages from content
    this._contentToAddonHandlers = (msgName, args) => {
      this._respondToUIChanges(args);
      this._respondToPlacesRequests(args);
      this._respondToSearchRequests(args);
      this._logPerfMeter(args);
    };
    this.on(CONTENT_TO_ADDON, this._contentToAddonHandlers);
  },

  /**
   * Turns off various listeners for the pages
   */
  _removeListeners() {
コード例 #4
0
ファイル: main.js プロジェクト: dan-l/activity-stream
const {MetadataStore} = require("lib/MetadataStore");
const {ActivityStreams} = require("lib/ActivityStreams");
const {Cu} = require("chrome");

Cu.import("resource://gre/modules/ClientID.jsm");
Cu.import("resource://gre/modules/Task.jsm");

let app = null;
let metadataStore = null;

Object.assign(exports, {
  main(options) {

    // options.loadReason can be install/enable/startup/upgrade/downgrade
    PlacesProvider.links.init();
    SearchProvider.search.init();
    options.telemetry = false;

    Task.spawn(function*() {
      options.clientID = yield ClientID.getClientID();
      metadataStore = new MetadataStore();
      yield metadataStore.asyncConnect();
      app = new ActivityStreams(metadataStore, options);
    }.bind(this));
  },

  onUnload(reason) {
    if (app) {
      app.unload(reason);
      if (reason === "uninstall" || reason === "disable") {
        metadataStore.asyncTearDown();
コード例 #5
0
 let promise = new Promise(resolve => {
   SearchProvider.search.once("browser-search-engine-modified", (name, data) => { // jshint ignore:line
     resolve([name, data.name]);
   });
 });