B2G/gecko/browser/components/places/content/places.js
/**
   * Save the current search (or advanced query) to the bookmarks root.
   */
Save the current search (or advanced query) to the bookmarks root.
Save the current search ( or advanced query ) to the bookmarks root .
function PO_saveSearch() {
    var options = this.getCurrentOptions();
    var queries = this.getCurrentQueries();
    var placeSpec = PlacesUtils.history.queriesToQueryString(queries,
                                                             queries.length,
                                                             options);
    var placeURI = Cc["@mozilla.org/network/io-service;1"].
                   getService(Ci.nsIIOService).
                   newURI(placeSpec, null, null);
    var title = PlacesUIUtils.getString("saveSearch.title");
    var inputLabel = PlacesUIUtils.getString("saveSearch.inputLabel");
    var defaultText = PlacesUIUtils.getString("saveSearch.inputDefaultText");
    var prompts = Cc["@mozilla.org/embedcomp/prompt-service;1"].
                  getService(Ci.nsIPromptService);
    var check = {value: false};
    var input = {value: defaultText};
    var save = prompts.prompt(null, title, inputLabel, input, null, check);
    if (!save || input.value == "")
     return;
    var txn = new PlacesCreateBookmarkTransaction(placeURI,
                                                  PlacesUtils.bookmarksMenuFolderId,
                                                  PlacesUtils.bookmarks.DEFAULT_INDEX,
                                                  input.value);
    PlacesUtils.transactionManager.doTransaction(txn);
    this._places.selectPlaceURI(placeSpec);
  }
function PO_saveSearch ( ) { var options = this . getCurrentOptions ( ) ; var queries = this . getCurrentQueries ( ) ; var placeSpec = PlacesUtils . history . queriesToQueryString ( queries , queries . length , options ) ; var placeURI = Cc [ "@mozilla.org/network/io-service;1" ] . getService ( Ci . nsIIOService ) . newURI ( placeSpec , null , null ) ; var title = PlacesUIUtils . getString ( "saveSearch.title" ) ; var inputLabel = PlacesUIUtils . getString ( "saveSearch.inputLabel" ) ; var defaultText = PlacesUIUtils . getString ( "saveSearch.inputDefaultText" ) ; var prompts = Cc [ "@mozilla.org/embedcomp/prompt-service;1" ] . getService ( Ci . nsIPromptService ) ; var check = { value : false } ; var input = { value : defaultText } ; var save = prompts . prompt ( null , title , inputLabel , input , null , check ) ; if ( ! save || input . value == "" ) return ; var txn = new PlacesCreateBookmarkTransaction ( placeURI , PlacesUtils . bookmarksMenuFolderId , PlacesUtils . bookmarks . DEFAULT_INDEX , input . value ) ; PlacesUtils . transactionManager . doTransaction ( txn ) ; this . _places . selectPlaceURI ( placeSpec ) ; }
Save the current search (or advanced query) to the bookmarks root.
Save the current search ( or advanced query ) to the bookmarks root .
// Get the place: uri for the query. // If the advanced query builder is showing, use that. // Prompt the user for a name for the query. // XXX - using prompt service for now; will need to make // a real dialog and localize when we're sure this is the UI we want. // Don't add the query if the user cancels or clears the seach name. // Add the place: uri as a bookmark under the bookmarks root. // select and load the new query