38 const Ci = Components.interfaces;
39 const Cc = Components.classes;
41 Components.utils.import(
"resource://gre/modules/XPCOMUtils.jsm");
48 if (!this._bookmarks) {
49 this._bookmarks =
Cc[
"@mozilla.org/browser/nav-bookmarks-service;1"].
52 return this._bookmarks;
57 if (!this._livemarks) {
58 this._livemarks =
Cc[
"@mozilla.org/browser/livemark-service;2"].
61 return this._livemarks;
66 if (!this._annotations) {
67 this._annotations =
Cc[
"@mozilla.org/browser/annotation-service;1"].
70 return this._annotations;
76 this._history =
Cc[
"@mozilla.org/browser/nav-history-service;1"].
82 _windowMediator :
null,
83 get windowMediator() {
84 if (!this._windowMediator) {
85 this._windowMediator =
Cc[
"@mozilla.org/appshell/window-mediator;1"].
88 return this._windowMediator;
94 var
ios =
Cc[
"@mozilla.org/network/io-service;1"].getService(
Ci.nsIIOService);
95 return ios.newURI(aSpec,
null,
null);
99 this._bookmarks =
null;
100 this._livemarks =
null;
101 this._annotations =
null;
102 this._history =
null;
103 this._windowMediator =
null;
112 this._tabbrowser = aWindow.getBrowser();
113 this._events =
new Events();
116 this._watch(
"TabOpen");
117 this._watch(
"TabMove");
118 this._watch(
"TabClose");
119 this._watch(
"TabSelect");
122 gShutdown.push(
function() {
self._shutdown(); });
134 _watch :
function win_watch(aType) {
136 this._tabbrowser.addEventListener(aType,
137 this._cleanup[aType] =
function(e){
self._event(e); },
144 _event :
function win_event(aEvent) {
145 this._events.dispatch(aEvent.type,
new BrowserTab(
this, aEvent.originalTarget.linkedBrowser));
149 var browsers = this._tabbrowser.browsers;
150 for (var
i=0;
i<browsers.length;
i++)
155 return new BrowserTab(
this, this._tabbrowser.selectedBrowser);
157 open :
function win_open(aURI) {
158 return new BrowserTab(
this, this._tabbrowser.addTab(aURI.spec).linkedBrowser);
160 _shutdown :
function win_shutdown() {
161 for (var type in this._cleanup)
162 this._tabbrowser.removeEventListener(type, this._cleanup[type],
true);
163 this._cleanup =
null;
166 this._tabbrowser =
null;
177 this._tabbrowser = aFUELWindow._tabbrowser;
179 this._events =
new Events();
185 gShutdown.push(
function() {
self._shutdown(); });
194 var
tabs = this._tabbrowser.mTabs;
195 for (var
i=0;
i<tabs.length;
i++) {
196 if (tabs[
i].linkedBrowser == this.
_browser)
211 return this.
_browser.contentDocument;
217 _watch :
function bt_watch(aType) {
219 this.
_browser.addEventListener(aType,
220 this._cleanup[aType] =
function(e){
self._event(e); },
227 _event :
function bt_event(aEvent) {
228 if (aEvent.type ==
"load") {
229 if (!(aEvent.originalTarget instanceof
Ci.nsIDOMDocument))
232 if (aEvent.originalTarget.defaultView instanceof
Ci.nsIDOMWindowInternal &&
233 aEvent.originalTarget.defaultView.frameElement)
236 this._events.dispatch(aEvent.type,
this);
241 _getTab :
function bt_gettab() {
242 var tabs = this._tabbrowser.mTabs;
243 return tabs[this.index] ||
null;
246 load :
function bt_load(aURI) {
250 focus :
function bt_focus() {
251 this._tabbrowser.selectedTab = this._getTab();
252 this._tabbrowser.focus();
255 close :
function bt_close() {
256 this._tabbrowser.removeTab(this._getTab());
259 moveBefore :
function bt_movebefore(aBefore) {
260 this._tabbrowser.moveTabTo(this._getTab(), aBefore.index);
263 moveToEnd :
function bt_moveend() {
264 this._tabbrowser.moveTabTo(this._getTab(), this._tabbrowser.browsers.length);
267 _shutdown :
function bt_shutdown() {
268 for (var type in this._cleanup)
269 this.
_browser.removeEventListener(type, this._cleanup[type],
true);
270 this._cleanup =
null;
273 this._tabbrowser =
null;
290 return Utilities.annotations.getItemAnnotationNames(this._id, {});
293 has :
function ann_has(
aName) {
294 return Utilities.annotations.itemHasAnnotation(this._id,
aName);
297 get :
function(
aName) {
299 return Utilities.annotations.getItemAnnotation(
this._id,
aName);
304 Utilities.annotations.setItemAnnotation(this._id,
aName, aValue, 0, aExpiration);
307 remove :
function ann_remove(
aName) {
309 Utilities.annotations.removeItemAnnotation(this._id,
aName);
320 this._parent = aParent;
321 this._type = aType ||
"bookmark";
323 this._events =
new Events();
325 Utilities.bookmarks.addObserver(
this,
false);
328 gShutdown.push(
function() {
self._shutdown(); });
332 _shutdown :
function bm_shutdown() {
333 this._annotations =
null;
336 Utilities.bookmarks.removeObserver(
this);
344 return Utilities.bookmarks.getItemTitle(this._id);
348 Utilities.bookmarks.setItemTitle(this._id, aTitle);
352 return Utilities.bookmarks.getBookmarkURI(this._id);
356 return Utilities.bookmarks.changeBookmarkURI(this._id, aURI);
360 return this._annotations.get(
"bookmarkProperties/description");
363 set description(aDesc) {
364 this._annotations.set(
"bookmarkProperties/description", aDesc,
Ci.nsIAnnotationService.EXPIRE_NEVER);
368 return Utilities.bookmarks.getKeywordForBookmark(this._id);
371 set keyword(aKeyword) {
372 Utilities.bookmarks.setKeywordForBookmark(this._id, aKeyword);
383 set parent(aFolder) {
384 Utilities.bookmarks.moveItem(this._id, aFolder.id, Utilities.bookmarks.DEFAULT_INDEX);
389 return this._annotations;
396 remove :
function bm_remove() {
397 Utilities.bookmarks.removeItem(this._id);
407 onItemAdded :
function bm_oia(aId, aFolder, aIndex) {
411 onBeforeItemRemoved :
function bm_obir(aId) {
414 onItemRemoved :
function bm_oir(aId, aFolder, aIndex) {
416 this._events.dispatch(
"remove", aId);
419 onItemChanged :
function bm_oic(aId, aProperty, aIsAnnotationProperty, aValue) {
421 this._events.dispatch(
"change", aProperty);
424 onItemVisited:
function bm_oiv(aId, aVisitID, aTime) {
427 onItemMoved:
function bm_oim(aId, aOldParent, aOldIndex, aNewParent, aNewIndex) {
428 if (this._id == aId) {
429 this._parent =
new BookmarkFolder(aNewParent, Utilities.bookmarks.getFolderIdForItem(aNewParent));
430 this._events.dispatch(
"move", aId);
442 this._parent = aParent;
444 this._events =
new Events();
446 Utilities.bookmarks.addObserver(
this,
false);
449 gShutdown.push(
function() {
self._shutdown(); });
453 _shutdown :
function bmf_shutdown() {
454 this._annotations =
null;
457 Utilities.bookmarks.removeObserver(
this);
465 return Utilities.bookmarks.getItemTitle(this._id);
469 Utilities.bookmarks.setItemTitle(this._id, aTitle);
473 return this._annotations.get(
"bookmarkProperties/description");
476 set description(aDesc) {
477 this._annotations.set(
"bookmarkProperties/description", aDesc,
Ci.nsIAnnotationService.EXPIRE_NEVER);
488 set parent(aFolder) {
489 Utilities.bookmarks.moveItem(this._id, aFolder.id, Utilities.bookmarks.DEFAULT_INDEX);
494 return this._annotations;
504 var
options = Utilities.history.getNewQueryOptions();
505 var query = Utilities.history.getNewQuery();
506 query.setFolders([this._id], 1);
507 var result = Utilities.history.executeQuery(query, options);
508 var rootNode = result.root;
509 rootNode.containerOpen =
true;
510 var cc = rootNode.childCount;
511 for (var
i=0;
i<cc; ++
i) {
512 var
node = rootNode.getChild(
i);
513 if (node.type == node.RESULT_TYPE_FOLDER) {
517 else if (node.type == node.RESULT_TYPE_SEPARATOR) {
518 var separator =
new Bookmark(node.itemId,
this._id,
"separator");
519 items.push(separator);
522 var bookmark =
new Bookmark(node.itemId,
this._id,
"bookmark");
523 items.push(bookmark);
526 rootNode.containerOpen =
false;
531 addBookmark :
function bmf_addbm(aTitle, aUri) {
532 var newBookmarkID = Utilities.bookmarks.insertBookmark(this._id, aUri, Utilities.bookmarks.DEFAULT_INDEX, aTitle);
533 var newBookmark =
new Bookmark(newBookmarkID,
this,
"bookmark");
537 addSeparator :
function bmf_addsep() {
538 var newBookmarkID = Utilities.bookmarks.insertSeparator(this._id, Utilities.bookmarks.DEFAULT_INDEX);
539 var newBookmark =
new Bookmark(newBookmarkID,
this,
"separator");
543 addFolder :
function bmf_addfolder(aTitle) {
544 var newFolderID = Utilities.bookmarks.createFolder(this._id, aTitle, Utilities.bookmarks.DEFAULT_INDEX);
549 remove :
function bmf_remove() {
550 Utilities.bookmarks.removeItem(this._id);
560 onItemAdded :
function bmf_oia(aId, aFolder, aIndex) {
563 this._events.dispatch(
"add", aId);
566 if (this._id == aFolder)
567 this._events.dispatch(
"addchild", aId);
570 onBeforeItemRemoved :
function bmf_oir(aId) {
573 onItemRemoved :
function bmf_oir(aId, aFolder, aIndex) {
575 if (!this._parent || this._id == aId)
576 this._events.dispatch(
"remove", aId);
579 if (this._id == aFolder)
580 this._events.dispatch(
"removechild", aId);
583 onItemChanged :
function bmf_oic(aId, aProperty, aIsAnnotationProperty, aValue) {
585 if (!this._parent || this._id == aId)
586 this._events.dispatch(
"change", aProperty);
589 onItemVisited:
function bmf_oiv(aId, aVisitID, aTime) {
592 onItemMoved:
function bmf_oim(aId, aOldParent, aOldIndex, aNewParent, aNewIndex) {
594 if (this._id == aId) {
595 this._parent =
new BookmarkFolder(aNewParent, Utilities.bookmarks.getFolderIdForItem(aNewParent));
596 this._events.dispatch(
"move", aId);
600 QueryInterface : XPCOMUtils.generateQI([
Ci.fuelIBookmarkFolder,
Ci.nsINavBookmarkObserver])
607 gShutdown.push(
function() {
self._shutdown(); });
611 _shutdown :
function bmr_shutdown() {
613 this._toolbar =
null;
615 this._unfiled =
null;
629 return this._toolbar;
643 return this._unfiled;
659 throw Components.results.NS_ERROR_NO_AGGREGATION;
661 if (gSingleton ==
null) {
665 return gSingleton.QueryInterface(aIID);
674 this.initToolkitHelpers();
675 this._bookmarks =
null;
683 classID: Components.ID(
"fe74cf80-aa2d-11db-abbd-0800200c9a66"),
684 contractID:
"@mozilla.org/fuel/application;1",
690 QueryInterface : XPCOMUtils.generateQI([
Ci.fuelIApplication,
Ci.extIApplication,
Ci.nsIObserver,
Ci.nsIClassInfo]),
693 var
interfaces = [
Ci.fuelIApplication,
Ci.extIApplication,
Ci.nsIObserver,
Ci.nsIClassInfo];
694 aCount.value = interfaces.length;
699 observe:
function app_observe(aSubject, aTopic,
aData) {
701 this.__proto__.__proto__.observe.call(
this, aSubject, aTopic,
aData);
702 if (aTopic ==
"xpcom-shutdown") {
703 this._bookmarks =
null;
709 if (this._bookmarks ==
null)
712 return this._bookmarks;
717 var
enum = Utilities.windowMediator.getEnumerator(
"navigator:browser");
720 win.push(
new Window(
enum.getNext()));
726 return new Window(Utilities.windowMediator.getMostRecentWindow(
"navigator:browser"));
737 #include ../../../mozexthelper/extApplication.js
function BrowserTab(aFUELWindow, aBrowser)
onPageChanged onEndUpdateBatch
sbDeviceFirmwareAutoCheckForUpdate prototype contractID
sbOSDControlService prototype QueryInterface
sbDeviceFirmwareAutoCheckForUpdate prototype classDescription
function BookmarkFolder(aId, aParent)
getService(Ci.sbIFaceplateManager)
BogusChannel prototype open
function makeURI(aURLSpec, aCharset)
onPageChanged onBeginUpdateBatch
function Bookmark(aId, aParent, aType)
SimpleArrayEnumerator prototype hasMoreElements
_updateTextAndScrollDataForTab aBrowser
sbDeviceFirmwareAutoCheckForUpdate prototype classID
function Annotations(aId)
restoreHistoryPrecursor aCount
sbDeviceFirmwareAutoCheckForUpdate prototype getInterfaces
sbDeviceFirmwareAutoCheckForUpdate prototype interfaces
function NSGetModule(aCompMgr, aFileSpec)
let< body >< buttononblur="this.parentNode.removeChild(this);">< script > document body firstChild focus()
_getSelectedPageStyle s i
function extApplication()
_updateTextAndScrollDataForFrame aData
sbDeviceFirmwareAutoCheckForUpdate prototype observe