63 const SIDEBAR_CID = Components.ID(
"{22117140-9c6e-11d3-aaf1-00805f8a4905}");
75 const PROMPTSERVICE_CONTRACTID =
"@mozilla.org/embedcomp/prompt-service;1";
76 const nsIPromptService = Components.interfaces.nsIPromptService;
78 Components.classes[PROMPTSERVICE_CONTRACTID].getService(nsIPromptService);
80 const SEARCHSERVICE_CONTRACTID =
"@mozilla.org/browser/search-service;1";
86 nsSidebar.prototype.nc =
"http://home.netscape.com/NC-rdf#";
90 if (!/^(https?:|ftp:)/
i.test(
url)) {
91 Components.utils.reportError(
"Invalid argument passed to window.sidebar.addPanel: Unsupported panel URL." );
99 function (aTitle, aContentURL, aCustomizeURL)
101 debug(
"addPanel(" + aTitle +
", " + aContentURL +
", " +
102 aCustomizeURL +
")");
104 return this.addPanelInternal(aTitle, aContentURL, aCustomizeURL,
false);
108 function(aTitle, aContentURL, aCustomizeURL)
110 debug(
"addPersistentPanel(" + aTitle +
", " + aContentURL +
", " +
111 aCustomizeURL +
")\n");
113 return this.addPanelInternal(aTitle, aContentURL, aCustomizeURL,
true);
117 function (aTitle, aContentURL, aCustomizeURL, aPersist)
119 var WINMEDSVC = Components.classes[
'@mozilla.org/appshell/window-mediator;1']
120 .getService(Components.interfaces.nsIWindowMediator);
121 var
win = WINMEDSVC.getMostRecentWindow(
"navigator:browser" );
128 var
ioService = Components.classes[
"@mozilla.org/network/io-service;1"]
129 .getService(Components.interfaces.nsIIOService);
131 uri = ioService.newURI(aContentURL,
null,
null);
133 catch(ex) {
return; }
135 win.PlacesUIUtils.showMinimalAddBookmarkUI(uri, aTitle,
null,
null,
true,
true);
138 nsSidebar.prototype.validateSearchEngine =
139 function (engineURL, iconURL)
144 if (! /^(https?|ftp):\/\
145 throw "Unsupported search engine URL";
150 ! /^(https?|ftp):\/\/.+\.(gif|jpg|jpeg|png|ico)$/
i.test(iconURL))
151 throw "Unsupported search icon URL.";
156 Components.utils.reportError(
"Invalid argument passed to window.sidebar.addSearchEngine: " + ex);
158 var searchBundle =
srGetStrBundle(
"chrome://global/locale/search/search.properties");
160 var brandName = brandBundle.GetStringFromName(
"brandShortName");
161 var title = searchBundle.GetStringFromName(
"error_invalid_engine_title");
162 var
msg = searchBundle.formatStringFromName(
"error_invalid_engine_msg",
164 var
ww = Components.classes[
"@mozilla.org/embedcomp/window-watcher;1"].
165 getService(Components.interfaces.nsIWindowWatcher);
166 ww.getNewPrompter(
null).alert(title, msg);
176 function (engineURL, iconURL, suggestedTitle, suggestedCategory)
178 debug(
"addSearchEngine(" + engineURL +
", " + iconURL +
", " +
179 suggestedCategory +
", " + suggestedTitle +
")");
181 if (!this.validateSearchEngine(engineURL, iconURL))
189 dataType = Components.interfaces.nsISearchEngine.DATA_TEXT;
191 dataType = Components.interfaces.nsISearchEngine.DATA_XML;
193 this.searchService.addEngine(engineURL, dataType, iconURL,
true);
200 function (aDescriptionURL)
206 var WINMEDSVC = Components.classes[
'@mozilla.org/appshell/window-mediator;1']
207 .getService(Components.interfaces.nsIWindowMediator);
208 var win = WINMEDSVC.getMostRecentWindow(
"Songbird:Main");
209 var
browser = win.document.getElementById(
"content");
213 if (browser.shouldLoadFavIcon(browser.selectedBrowser
215 .documentURIObject)) {
218 iconURL = browser.selectedBrowser.mIconURL;
221 if (!this.validateSearchEngine(aDescriptionURL, iconURL))
224 const typeXML = Components.interfaces.nsISearchEngine.DATA_XML;
225 this.searchService.addEngine(aDescriptionURL, typeXML, iconURL,
true);
236 nsSidebar.prototype.IsSearchProviderInstalled =
237 function (aSearchURL)
242 nsSidebar.prototype.addMicrosummaryGenerator =
243 function (generatorURL)
246 throw Components.Exception(Components.results.NS_ERROR_NOT_IMPLEMENTED);
247 debug(
"addMicrosummaryGenerator(" + generatorURL +
")");
249 if (!/^https?:/
i.test(generatorURL))
252 var stringBundle =
srGetStrBundle(
"chrome://browser/locale/sidebar/sidebar.properties");
253 var titleMessage = stringBundle.GetStringFromName(
"addMicsumGenConfirmTitle");
254 var dialogMessage = stringBundle.formatStringFromName(
"addMicsumGenConfirmText", [generatorURL], 1);
259 var ioService = Components.classes[
"@mozilla.org/network/io-service;1"].
260 getService(Components.interfaces.nsIIOService);
261 var generatorURI = ioService.newURI(generatorURL,
null,
null);
263 var microsummaryService = Components.classes[
"@mozilla.org/microsummary/service;1"].
264 getService(Components.interfaces.nsIMicrosummaryService);
265 if (microsummaryService)
266 microsummaryService.addGenerator(generatorURI);
278 count.value = interfaceList.length;
279 return interfaceList;
293 throw Components.results.NS_ERROR_NO_INTERFACE;
296 var sidebarModule =
new Object();
298 sidebarModule.registerSelf =
299 function (compMgr, fileSpec, location, type)
301 debug(
"registering (all right -- a JavaScript module!)");
302 compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
305 "Sidebar JS Component",
311 const CATMAN_CONTRACTID =
"@mozilla.org/categorymanager;1";
313 var catman = Components.classes[CATMAN_CONTRACTID].
316 const JAVASCRIPT_GLOBAL_PROPERTY_CATEGORY =
"JavaScript global property";
317 catman.addCategoryEntry(JAVASCRIPT_GLOBAL_PROPERTY_CATEGORY,
323 catman.addCategoryEntry(JAVASCRIPT_GLOBAL_PROPERTY_CATEGORY,
330 sidebarModule.getClassObject =
331 function (compMgr, cid, iid) {
333 throw Components.results.NS_ERROR_NO_INTERFACE;
335 if (!iid.equals(Components.interfaces.nsIFactory))
336 throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
338 return sidebarFactory;
341 sidebarModule.canUnload =
344 debug(
"Unloading component.");
349 var sidebarFactory =
new Object();
351 sidebarFactory.createInstance =
352 function (outer, iid) {
355 throw Components.results.NS_ERROR_NO_AGGREGATION;
357 return (
new nsSidebar()).QueryInterface(iid);
362 return sidebarModule;
367 debug =
function (s) { dump(
"-*- sidebar component: " + s +
"\n"); }
369 debug =
function (s) {}
372 var gStrBundleService =
null;
376 if (!gStrBundleService)
378 Components.classes[
"@mozilla.org/intl/stringbundle;1"]
379 .getService(Components.interfaces.nsIStringBundleService);
381 return gStrBundleService.createBundle(
path);
getService(Ci.sbIFaceplateManager)
const nsIBrowserSearchService
_getSelectedPageStyle s i