B2G/gecko/browser/base/content/browser-places.js
/**
   * Adds a bookmark to the page loaded in the given browser.
   *
   * @param aBrowser
   *        a <browser> element.
   * @param [optional] aParent
   *        The folder in which to create a new bookmark if the page loaded in
   *        aBrowser isn't bookmarked yet, defaults to the unfiled root.
   * @param [optional] aShowEditUI
   *        whether or not to show the edit-bookmark UI for the bookmark item
   */
Adds a bookmark to the page loaded in the given browser.
@param aBrowser
a  element.
@param [optional] aParent
The folder in which to create a new bookmark if the page loaded in
aBrowser isn't bookmarked yet, defaults to the unfiled root.
@param [optional] aShowEditUI
whether or not to show the edit-bookmark UI for the bookmark item
Adds a bookmark to the page loaded in the given browser . @param aBrowser a element . @param [ optional ] aParent The folder in which to create a new bookmark if the page loaded in aBrowser isn ' t bookmarked yet defaults to the unfiled root . @param [ optional ] aShowEditUI whether or not to show the edit - bookmark UI for the bookmark item
function PCH_bookmarkPage(aBrowser, aParent, aShowEditUI) {
    var uri = aBrowser.currentURI;
    var itemId = PlacesUtils.getMostRecentBookmarkForURI(uri);
    if (itemId == -1) {
      var webNav = aBrowser.webNavigation;
      var url = webNav.currentURI;
      var title;
      var description;
      var charset;
      try {
        title = webNav.document.title || url.spec;
        description = PlacesUIUtils.getDescriptionFromDocument(webNav.document);
        charset = webNav.document.characterSet;
      }
      catch (e) { }
      if (aShowEditUI) {
        StarUI.beginBatch();
      }
      var parent = aParent != undefined ?
                   aParent : PlacesUtils.unfiledBookmarksFolderId;
      var descAnno = { name: PlacesUIUtils.DESCRIPTION_ANNO, value: description };
      var txn = new PlacesCreateBookmarkTransaction(uri, parent, 
                                                    PlacesUtils.bookmarks.DEFAULT_INDEX,
                                                    title, null, [descAnno]);
      PlacesUtils.transactionManager.doTransaction(txn);
      if (charset)
        PlacesUtils.history.setCharsetForURI(uri, charset);
      itemId = PlacesUtils.getMostRecentBookmarkForURI(uri);
    }
    if (gURLBar)
      gURLBar.handleRevert();
    if (aBrowser.contentWindow == window.content) {
      var starIcon = aBrowser.ownerDocument.getElementById("star-button");
      if (starIcon && isElementVisible(starIcon)) {
        if (aShowEditUI)
          StarUI.showEditBookmarkPopup(itemId, starIcon, "bottomcenter topright");
        return;
      }
    }
    StarUI.showEditBookmarkPopup(itemId, aBrowser, "overlap");
  }
function PCH_bookmarkPage ( aBrowser , aParent , aShowEditUI ) { var uri = aBrowser . currentURI ; var itemId = PlacesUtils . getMostRecentBookmarkForURI ( uri ) ; if ( itemId == - 1 ) { var webNav = aBrowser . webNavigation ; var url = webNav . currentURI ; var title ; var description ; var charset ; try { title = webNav . document . title || url . spec ; description = PlacesUIUtils . getDescriptionFromDocument ( webNav . document ) ; charset = webNav . document . characterSet ; } catch ( e ) { } if ( aShowEditUI ) { StarUI . beginBatch ( ) ; } var parent = aParent != undefined ? aParent : PlacesUtils . unfiledBookmarksFolderId ; var descAnno = { name : PlacesUIUtils . DESCRIPTION_ANNO , value : description } ; var txn = new PlacesCreateBookmarkTransaction ( uri , parent , PlacesUtils . bookmarks . DEFAULT_INDEX , title , null , [ descAnno ] ) ; PlacesUtils . transactionManager . doTransaction ( txn ) ; if ( charset ) PlacesUtils . history . setCharsetForURI ( uri , charset ) ; itemId = PlacesUtils . getMostRecentBookmarkForURI ( uri ) ; } if ( gURLBar ) gURLBar . handleRevert ( ) ; if ( aBrowser . contentWindow == window . content ) { var starIcon = aBrowser . ownerDocument . getElementById ( "star-button" ) ; if ( starIcon && isElementVisible ( starIcon ) ) { if ( aShowEditUI ) StarUI . showEditBookmarkPopup ( itemId , starIcon , "bottomcenter topright" ) ; return ; } } StarUI . showEditBookmarkPopup ( itemId , aBrowser , "overlap" ) ; }
Adds a bookmark to the page loaded in the given browser.
Adds a bookmark to the page loaded in the given browser .
// Copied over from addBookmarkForBrowser: // Bug 52536: We obtain the URL and title from the nsIWebNavigation // associated with a <browser/> rather than from a DOMWindow. // This is because when a full page plugin is loaded, there is // no DOMWindow (?) but information about the loaded document // may still be obtained from the webNavigation. // If we bookmark the page here (i.e. page was not "starred" already) // but open right into the "edit" state, start batching here, so // "Cancel" in that state removes the bookmark. // Set the character-set // Revert the contents of the location bar // dock the panel to the star icon when possible, otherwise dock // it to the content area