44 "@mozilla.org/autocomplete/search;1?name=songbird-autocomplete";
47 Components.ID(
"{0be64502-ee00-11db-8314-0800200c9a66}");
51 const Cc = Components.classes;
52 const Ci = Components.interfaces;
53 const Cr = Components.results;
67 this._searchString = searchString;
68 this._defaultIndex = defaultIndex;
69 this._errorDescription = errorDescription;
70 this._results = results;
71 this._comments = comments;
90 _errorDescription:
"",
110 return this._searchString;
121 if (this._results.length > 0) {
122 return Ci.nsIAutoCompleteResult.RESULT_SUCCESS;
124 Ci.nsIAutoCompleteResult.RESULT_NOMATCH;
132 return this._defaultIndex;
138 get errorDescription() {
139 return this._errorDescription;
146 return this._results.length;
154 getValueAt:
function(index) {
155 return this._results[index];
163 getCommentAt:
function(index) {
164 return this._comments[index];
172 getStyleAt:
function(index) {
173 if (!this._comments[index])
177 return "suggestfirst";
179 return "suggesthint";
187 getImageAt:
function(index) {
195 removeValueAt:
function(index, removeFromDatabase) {
196 this._results.splice(index, 1);
197 this._comments.splice(index, 1);
207 if (!iid.equals(
Ci.nsIAutoCompleteResult) &&
208 !iid.equals(
Ci.nsISupports))
209 throw Cr.NS_ERROR_NO_INTERFACE;
229 this._addObservers();
230 this._loadSuggestPref();
231 this._loadDataRemotes();
239 if (!this.__strings) {
240 var sbs =
Cc[
"@mozilla.org/intl/stringbundle;1"].
245 return this.__strings;
252 _loadSuggestPref:
function SAC_loadSuggestPref() {
253 var prefService =
Cc[
"@mozilla.org/preferences-service;1"].
257 _suggestEnabled:
null,
260 _metadataTitle:
null,
261 _metadataArtist:
null,
262 _metadataAlbum:
null,
267 _loadDataRemotes:
function SAC_loadDataRemotes() {
280 _releaseDataRemotes:
function() {
281 this._metadataTitle.unbind();
282 this._metadataArtist.unbind();
283 this._metadataAlbum.unbind();
302 onSearchResult:
function(searchString, results, comments) {
303 if (this._listener) {
311 this._listener.onSearchResult(
this, result);
315 this._listener =
null;
334 startSearch:
function(searchString, searchParam, previousResult,
listener) {
337 var searchService =
Cc[
"@mozilla.org/browser/search-service;1"].
347 var engine = searchService.currentEngine;
354 if (searchString ==
"") {
355 results = this._getPlayerContextSuggestions();
360 for (var
i = 0;
i < results.length;
i++) {
364 this.onSearchResult(searchString, results, comments);
371 stopSearch:
function() {
379 _getPlayerContextSuggestions:
function() {
385 if (this._metadataTitle.stringValue !=
"") {
386 results.push(this._metadataTitle.stringValue);
388 if (this._metadataAlbum.stringValue !=
"") {
389 results.push(this._metadataAlbum.stringValue);
391 if (this._metadataArtist.stringValue !=
"") {
392 results.push(this._metadataArtist.stringValue);
401 observe:
function SAC_observe(aSubject, aTopic,
aData) {
404 this._loadSuggestPref();
408 this._removeObservers();
409 this._releaseDataRemotes();
414 _addObservers:
function SAC_addObservers() {
415 var prefService2 =
Cc[
"@mozilla.org/preferences-service;1"].
419 var
os =
Cc[
"@mozilla.org/observer-service;1"].
424 _removeObservers:
function SAC_removeObservers() {
425 var prefService2 =
Cc[
"@mozilla.org/preferences-service;1"].
429 var os =
Cc[
"@mozilla.org/observer-service;1"].
441 if (!iid.equals(
Ci.nsIAutoCompleteSearch) &&
442 !iid.equals(
Ci.nsIObserver) &&
443 !iid.equals(
Ci.nsISupports))
444 throw Cr.NS_ERROR_NO_INTERFACE;
460 registerSelf:
function(componentManager, location, loaderString, type) {
461 if (this._firstTime) {
462 this._firstTime =
false;
463 throw Cr.NS_ERROR_FACTORY_REGISTER_AGAIN;
466 componentManager.QueryInterface(
Ci.nsIComponentRegistrar);
468 for (var
key in this.objects) {
469 var obj = this.objects[
key];
470 componentManager.registerFactoryLocation(obj.CID, obj.className, obj.contractID,
471 location, loaderString, type);
484 if (!iid.equals(
Ci.nsIFactory))
485 throw Cr.NS_ERROR_NOT_IMPLEMENTED;
487 for (var
key in this.objects) {
488 if (cid.equals(
this.objects[
key].CID))
489 return this.objects[
key].factory;
492 throw Cr.NS_ERROR_NO_INTERFACE;
503 throw Cr.NS_ERROR_NO_AGGREGATION;
513 canUnload:
function(componentManager) {
const SEARCH_SUGGEST_CONTRACTID
sbOSDControlService prototype className
SafebrowsingApplicationMod prototype registerSelf
for(let i=0;i< aHistory.count;i++)
sbDeviceFirmwareAutoCheckForUpdate prototype contractID
const BROWSER_SUGGEST_PREF
sbOSDControlService prototype QueryInterface
const SONGBIRD_DATAREMOTE_CONTRACTID
An interface for accessing, and binding to, stored data.
getService(Ci.sbIFaceplateManager)
SafebrowsingApplicationMod prototype getClassObject
function search(aFolderId, aSearchStr, aExpectedScopeButtonId)
const SEARCH_SUGGEST_CLASSID
DataRemote prototype constructor
function AutoCompleteResult(searchString, defaultIndex, errorDescription, results, comments)
const SEARCH_SUGGEST_CLASSNAME
const NS_PREFBRANCH_PREFCHANGE_TOPIC_ID
function SearchSuggester()
_getSelectedPageStyle s i
const XPCOM_SHUTDOWN_TOPIC
_updateTextAndScrollDataForFrame aData
sbDeviceFirmwareAutoCheckForUpdate prototype observe
function NSGetModule(componentManager, location)