Skip to content

Commit

Permalink
Merge branch 'jb32815' into 'nemo_embedlite_38'
Browse files Browse the repository at this point in the history
[embedlite-component] Report to chrome when a search engine is added. Contributes to JB#32815



See merge request !16
  • Loading branch information
rainemak committed Jun 23, 2016
2 parents 8538f6a + bd2a897 commit a72513c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
29 changes: 25 additions & 4 deletions jscomps/EmbedLiteSearchEngine.js
Expand Up @@ -19,21 +19,42 @@ EmbedLiteSearchEngine.prototype = {
classID: Components.ID("{924fe7ba-afa1-11e2-9d4f-533572064b73}"),

observe: function (aSubject, aTopic, aData) {
let searchCallback = {
onSuccess: function (engine) {
var message = {
"msg": "search-engine-added",
"engine": (engine && engine.name) || "",
"errorCode": 0,
}
Services.obs.notifyObservers(null, "embed:search", JSON.stringify(message));
},
onError: function (errorCode) {
// Checked possible failures from nsIBrowserSearchService.idl
var message = {
"msg": "search-engine-added",
"engine": "",
"errorCode": errorCode
}
Services.obs.notifyObservers(null, "embed:search", JSON.stringify(message));
}
}

switch(aTopic) {
// Engine DownloadManager notifications
case "app-startup": {
Services.obs.addObserver(this, "xpcom-shutdown", true);
Services.obs.addObserver(this, "embedui:search", true);
Services.obs.addObserver(this, "embedliteInitialized", true);
Services.obs.addObserver(this, "profile-after-change", false);
break;
}
case "embedliteInitialized": {
Services.obs.removeObserver(this, "embedliteInitialized");
case "profile-after-change": {
Services.obs.removeObserver(this, "profile-after-change");
Services.search.init(function addEngine_cb(rv) {
let engines = Services.search.getEngines({});
let engineNames = engines.map(function (element) {
return element.name;
});

let enginesAvailable = (engines && engines.length > 0);
var messg = {
msg: "init",
Expand All @@ -49,7 +70,7 @@ EmbedLiteSearchEngine.prototype = {
var data = JSON.parse(aData);
switch (data.msg) {
case "loadxml": {
Services.search.addEngine(data.uri, Ci.nsISearchEngine.DATA_XML, null, data.confirm);
Services.search.addEngine(data.uri, Ci.nsISearchEngine.DATA_XML, null, data.confirm, searchCallback);
break;
}
case "restoreDefault": {
Expand Down
2 changes: 1 addition & 1 deletion rpm/embedlite-components-qt5.spec
Expand Up @@ -18,7 +18,7 @@

Name: embedlite-components-qt5
Summary: EmbedLite components Qt5
Version: 1.9.13
Version: 1.9.14
Release: 1
Group: Applications/Internet
License: MPLv2
Expand Down

0 comments on commit a72513c

Please sign in to comment.