home *** CD-ROM | disk | FTP | other *** search
/ PC World 2006 December / PCWorld_2006-12_cd.bin / komunikace / netscape / nsb-install-8-1-2.exe / chrome / browser.jar / content / browser / search.xml < prev    next >
Extensible Markup Language  |  2006-01-06  |  27KB  |  670 lines

  1. <?xml version="1.0"?>
  2.  
  3. <bindings id="SearchBindings"
  4.           xmlns="http://www.mozilla.org/xbl"
  5.           xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
  6.           xmlns:xbl="http://www.mozilla.org/xbl">  
  7.   <binding id="searchbar-base">
  8.     <resources>
  9.       <stylesheet src="chrome://browser/content/searchbarBindings.css"/>
  10.       <stylesheet src="chrome://browser/skin/searchbar.css"/>            
  11.     </resources>   
  12.   </binding>
  13.     <binding id="searchbar" extends="chrome://browser/content/search.xml#searchbar-base"  >
  14.       <!--
  15.                    type="autocomplete"
  16.                    autocompletepopup="SearchBarHistoryPopup"
  17.                    autocompletesearch="form-history"
  18.                    autocompletesearchparam="searchbar-history"
  19.                    disableautocomplete="true"
  20.                    enablehistory="true"
  21.       -->
  22.     <content>
  23.       <xul:stringbundle src="chrome://browser/locale/searchbar.properties"/>
  24.       <xul:textbox class="searchbar-textbox" flex="1"
  25.                    completeselectedindex="true"
  26.                    tabscrolling="true" 
  27.                    onfocus="URLBarFocusHandler(event, this);"
  28.                    onmousedown="URLBarMouseDownHandler(event, this);"
  29.                    onclick="URLBarClickHandler(event, this);"
  30.                    xbl:inherits="searchengine,src">
  31.         <xul:button class="searchbar-dropmarker" type="menu"
  32.                     popup="_child" xbl:inherits="src">
  33.           <xul:menupopup anonid="searchbar-popup" position="after_start"
  34.                         datasources="rdf:null"
  35.                         ref="rdf:null"
  36.                         oncommand="this.parentNode.setAttribute('src',event.target.getAttribute('src')); if (this.parentNode) this.parentNode.parentNode.onEnginePopupCommand(event);search.saveSelectionToPref(event.target);"
  37.                         onpopupshowing="search.PopulateEnginePopup(event);if (this.parentNode) this.parentNode.parentNode.onEnginePopupShowing(event);"
  38.                          onpopuphidden="if (this.parentNode) this.parentNode.parentNode.onEnginePopupHidden(event);">                        
  39.           </xul:menupopup>
  40.         </xul:button>
  41.       </xul:textbox>
  42.       <xul:dropmarker class="searchbar-history-dropmarker"
  43.                       popup="SearchBarHistoryPopup">
  44.         <xul:image class="searchbar-history-dropmarker-image"/>
  45.       </xul:dropmarker>
  46.     </content>
  47.     <implementation>
  48.       <constructor><![CDATA[   
  49.         var broadcaster = window.top.document.getElementById('searchEngineBroadcaster');
  50.         if (!broadcaster) return; // JMC - This broadcaster is probably unneeded, since search sidebar is gone.
  51.         broadcaster.addEventListener('DOMAttrModified', this.onSearchEngineBroadcasterAttribChanged, false);
  52.         ]]></constructor>           
  53.       <field name="mStringBundle">document.getAnonymousNodes(this)[0]</field>
  54.       <field name="mTextbox"> document.getAnonymousNodes(this)[1] </field>      
  55.       <method name="focus">
  56.         <body><![CDATA[
  57.           this.mTextbox.focus();
  58.         ]]></body>
  59.       </method>      
  60.       <method name="clear">
  61.         <body><![CDATA[
  62.           this.mTextbox.value="";
  63.         ]]></body>
  64.       </method>
  65.       <method name="select">
  66.         <body><![CDATA[
  67.           this.mTextbox.select();
  68.         ]]></body>
  69.       </method>         
  70.       <method name="onSearchEngineBroadcasterAttribChanged">
  71.         <parameter name="evt"/>
  72.         <body><![CDATA[          
  73.           // MERC (ccampbell) added this function to watch search engine broadcaster
  74.           if (evt.attrName == 'searchengine') {
  75.             var searchbar = document.getElementById('searchbar');
  76.             searchbar.currentEngine = evt.newValue;                    
  77.             //searchbar.mTextbox.select();            
  78.           } else if (evt.attrName == 'searchStatus'){
  79.                 if (evt.newValue == 'stopped'){                  
  80.                   desktopSearch.StopCurrentSearch();                  
  81.                 }
  82.           }                                                       
  83.         ]]></body>
  84.       </method>  
  85.       
  86.  
  87.     </implementation>
  88.   </binding>
  89.  
  90.   <binding id="searchbar-textbox" extends="chrome://global/content/bindings/autocomplete.xml#autocomplete">
  91.     <implementation>
  92.  
  93.       <constructor><![CDATA[
  94.         
  95.         if (this.parentNode && this.parentNode.parentNode.parentNode.localName ==
  96.             "toolbarpaletteitem")
  97.           return;
  98.         setTimeout(function(a) { a.initialize(); }, 0, this);                
  99.       ]]></constructor>
  100.  
  101.       <destructor><![CDATA[
  102.        if (this.parentNode && this.parentNode.parentNode.parentNode.localName ==
  103.             "toolbarpaletteitem")
  104.           return;
  105.         this.controllers.removeController(this.searchbarController);
  106.       ]]></destructor>
  107.  
  108.       <property name="mContextMenu" readonly="true">
  109.         <getter>
  110.           var textBox = document.getAnonymousElementByAttribute(this,
  111.                         "anonid", "textbox-input-box");
  112.           return document.getAnonymousElementByAttribute(textBox,
  113.                         "anonid", "input-box-contextmenu");
  114.         </getter>
  115.       </property>        
  116.       <method name="initialize">
  117.         <body><![CDATA[   
  118.         if (!this.parentNode || !this.mContextMenu) return;                                   
  119.           this.FORMHISTSVC = Components
  120.                               .classes["@mozilla.org/satchel/form-history;1"]
  121.                               .getService(Components.interfaces.nsIFormHistory);
  122.                                                   
  123.           var engine = this.currentEngine;
  124.             //dump("\nBC: ###\nEngine == " + this.currentEngine + "    \n");
  125.           if (!engine) {
  126.             this.currentEngine = this.getDefaultEngine();          
  127.           } else {
  128.             var rEngine = this.RDF.GetResource(engine);
  129.             var rChild  = this.RDF.GetResource("http://home.netscape.com/NC-rdf#child");
  130.             if (!this.ISEARCHDS.hasArcIn(rEngine, rChild)) {
  131.                 //dump("\nBC: ###\nGetting the default Engine\n");
  132.               this.currentEngine = this.getDefaultEngine();
  133.             } // if default engine not found... XXXblake what to do now?
  134.           }
  135.  
  136.           var element;
  137.           element =document.createElement('menuseparator');
  138.           this.mContextMenu.appendChild(element);
  139.           element = document.createElement('menuitem');
  140.           element.setAttribute("label", this.mStringBundle
  141.                                .getString("cmd_clearHistory"));
  142.           element.setAttribute("accesskey", this.mStringBundle
  143.                                .getString("cmd_clearHistory_accesskey"));
  144.           element.setAttribute("cmd", "cmd_clearhistory");
  145.           this.mContextMenu.appendChild(element);
  146.           this.controllers.appendController(this.searchbarController);
  147.  
  148.         ]]></body>
  149.       </method>
  150.  
  151.       <field name="mStringBundle">if (this.parentNode) this.parentNode.mStringBundle; </field>
  152.       <field name="_RDF"/>      
  153.       <field name="_ISEARCHDS"/>
  154.       
  155.       <property name="RDF" readonly="true">
  156.         <getter><![CDATA[
  157.           if (!this._RDF){
  158.               this._RDF = Components.classes["@mozilla.org/rdf/rdf-service;1"]
  159.                                  .getService(Components.interfaces.nsIRDFService);
  160.            }
  161.                  
  162.           return this._RDF;
  163.            
  164.           ]]></getter>               
  165.       </property>
  166.       
  167.       <property name="ISEARCHDS" readonly="true">
  168.         <getter><![CDATA[                      
  169.           if  (!this._ISEARCHDS) {
  170.             this._ISEARCHDS = this.RDF.GetDataSource("rdf:internetsearch");
  171.             const kNC_Root  = this.RDF.GetResource("NC:SearchEngineRoot");
  172.             const kNC_child = this.RDF.GetResource("http://home.netscape.com/NC-rdf#child");
  173.             const kNC_Name  = this.RDF.GetResource("http://home.netscape.com/NC-rdf#Name");
  174.              var arcs = this._ISEARCHDS.GetTargets(kNC_Root, kNC_child, true);
  175.           }                  
  176.           return this._ISEARCHDS;
  177.            
  178.          ]]></getter>               
  179.       </property>
  180.       
  181.       
  182.       <field name="FORMHISTSVC"/>
  183.       <field name="SEARCH_HISTORY_FILE">"search-history.txt"</field>
  184.       <field name="PR_RDONLY">1</field>
  185.  
  186.  
  187.       <property name="currentEngine"
  188.                 
  189.         onget="if (this.parentNode) return this.parentNode.getAttribute('searchengine'); else return null;">
  190.         <setter><![CDATA[          
  191.           if (!val)
  192.            return;          
  193.           // Set the searchengine attribute on the broadcaster
  194.            var broadcaster = window.top.document.getElementById('searchEngineBroadcaster');
  195.            var src;
  196.            
  197.            var pls = Components.classes["@mozilla.org/pref-localizedstring;1"]
  198.                                 .createInstance(Components.interfaces.nsIPrefLocalizedString);
  199.           
  200.          var PREF = Components.classes["@mozilla.org/preferences-service;1"]
  201.                                  .getService(Components.interfaces.nsIPrefService)
  202.                                  .getBranch(null);
  203.           
  204.           if (val=='DesktopSearch'){
  205.             src = "chrome://browser/skin/search/copernic.png";                        
  206.             pls.data = 'DesktopSearch';
  207.           
  208.           } else {          
  209.           
  210.             const kNC_Icon = this.RDF.GetResource("http://home.netscape.com/NC-rdf#Icon");
  211.             const kNC_Name = this.RDF.GetResource("http://home.netscape.com/NC-rdf#Name");          
  212.             var rEngine = this.RDF.GetResource(val);
  213.             src = this.readRDFString(rEngine, kNC_Icon);            
  214.             pls.data = this.readRDFString(rEngine, kNC_Name);                             
  215.           }
  216.                   
  217.            PREF.setComplexValue("browser.search.selectedEngine",
  218.                                  Components.interfaces.nsIPrefLocalizedString,
  219.                                  pls);      
  220.           
  221.           broadcaster.setAttribute("src", src);
  222.           //alert(broadcaster.getAttribute("src"));
  223.           broadcaster.setAttribute("searchengine", val); 
  224.           //alert(broadcaster.getAttribute("searchengine"));
  225.           
  226.           //alert('searchengine=' + val);
  227.          // alert('src=' + src);
  228.           
  229.  
  230.         ]]></setter>
  231.       </property>
  232.       
  233.       
  234.       <property name="perfmon">
  235.         <getter><![CDATA[
  236.           if (!this.parentNode) return null;
  237.           var rEngine = this.RDF.GetResource(this.currentEngine);
  238.           const kNC_Name = this.RDF.GetResource("http://home.netscape.com/NC-rdf#Name");
  239.           var pls = Components.classes["@mozilla.org/pref-localizedstring;1"]
  240.                               .createInstance(Components.interfaces.nsIPrefLocalizedString);
  241.           var engineID = 'searchbar:'+this.readRDFString(rEngine, kNC_Name);
  242.           //dump('search.xml: perfmon = '+engineID+'\n');
  243.           return engineID;
  244.         ]]></getter>
  245.       </property>
  246.  
  247.       <method name="getDefaultEngine">
  248.         <body><![CDATA[
  249.             //dump('\n **************** getDefaultEngine ************************\n');
  250.           var PREF = Components.classes["@mozilla.org/preferences-service;1"]
  251.                                .getService(Components.interfaces.nsIPrefService)
  252.                                .getBranch(null);
  253.           var defaultName = PREF.getComplexValue("browser.search.defaultenginename",
  254.                                                  Components.interfaces.nsIPrefLocalizedString).data;
  255.  
  256.           const kNC_Root  = this.RDF.GetResource("NC:SearchEngineRoot");
  257.           const kNC_child = this.RDF.GetResource("http://home.netscape.com/NC-rdf#child");
  258.           const kNC_Name  = this.RDF.GetResource("http://home.netscape.com/NC-rdf#Name");                    
  259.           var arcs = this.ISEARCHDS.GetTargets(kNC_Root, kNC_child, true); 
  260.                    
  261.           while (arcs.hasMoreElements()) {
  262.             var rEngine = arcs.getNext().QueryInterface(Components.interfaces.nsIRDFResource);
  263.             var name = this.readRDFString(rEngine, kNC_Name);
  264.             if (name == defaultName){
  265.                 //dump('\n **************** getDefaultEngine = ' + rEngine.Value + '************************\n');                
  266.               return rEngine.Value;
  267.             }
  268.           }          
  269.           return null;
  270.         ]]></body>
  271.       </method>
  272.  
  273.       <method name="readRDFString">
  274.         <parameter name="aRes"/>
  275.         <parameter name="aProp"/>
  276.         <body><![CDATA[
  277.           var n = this.ISEARCHDS.GetTarget(aRes, aProp, true);
  278.           return n ? n.QueryInterface(Components.interfaces.nsIRDFLiteral).Value : null;
  279.         ]]></body>
  280.       </method>
  281.       <!--  // overload |onTextEntered| in autocomplete.xml -->      
  282.       <method name="onTextEntered">
  283.         <body><![CDATA[
  284.           // CDC - Remember the text in the search history list
  285.           var broadcaster = window.top.document.getElementById('searchEngineBroadcaster');
  286.           broadcaster.setAttribute("searchText", this.value);
  287.           
  288.           
  289.                    var PREF = Components.classes["@mozilla.org/preferences-service;1"]
  290.                                  .getService(Components.interfaces.nsIPrefService)
  291.                                  .getBranch(null);
  292.           
  293.           if (this.value) {
  294.             search.AddToHistory(this.value);                        
  295.           }
  296.  
  297.           // CDC - Count search provider hits
  298.           try {
  299.             if (perfmon) {
  300.               this.setAttribute('perfmon', this.perfmon);
  301.               perfmon.trackData(this);
  302.             }
  303.           } catch (ex) { }                   
  304.                   
  305.           // Do we have a desktop search
  306.           if (this.currentEngine=='DesktopSearch' ) {
  307.           
  308.           try {
  309.               if (!desktopSearch.isDesktopSearchAvailable()) {
  310.                     var sDesktopSearchDownloadURL = PREF.getCharPref('sidebar.desktopsearch.url');
  311.                     SearchLoadURL(sDesktopSearchDownloadURL, null, true);
  312.                     return;
  313.                 }
  314.           }catch(e){
  315.             search.logError(e,'Desktop search error - unable to determine if Copernic is installed.');    
  316.           }
  317.  
  318.             try { 
  319.                    //Clear previous search filters
  320.                    desktopSearch.ClearFilters();
  321.                    // Start the desktop search.                   
  322.                    desktopSearch.ExecuteSearch(this.value, this.displayDesktopSearchResults);
  323.                    broadcaster.setAttribute("searchStatus", 'started');          
  324.               }catch (e){
  325.                    //MERC: NAJ: An undetermined search error has occured - dump it to log.
  326.                search.logError(e,'Desktop search error.');
  327.           return;
  328.         }           
  329.                                        
  330.           } else { 
  331.                                     
  332.               var ISEARCHSVC = Components.classes["@mozilla.org/rdf/datasource;1?name=internetsearch"]
  333.                                          .getService(Components.interfaces.nsIInternetSearchService);
  334.                var searchURL = ISEARCHSVC.GetInternetSearchURL(this.currentEngine,
  335.                                            this.value? encodeURIComponent(this.value):"",
  336.                                            0, 0, {value:0});
  337.     
  338.               if (!this.value) {
  339.                 var uri = Components.classes['@mozilla.org/network/standard-url;1']
  340.                                     .createInstance(Components.interfaces.nsIURI);
  341.                 uri.spec = searchURL;
  342.                 searchURL = uri.host;
  343.                 if (!searchURL)
  344.                   return;
  345.               }
  346.     
  347.               // JMC - Why was this commented out?
  348.               SearchLoadURL(searchURL, this.mEnterEvent);
  349.           
  350.         }
  351.         ]]></body>
  352.       </method>
  353.       
  354.       <method name="displayDesktopSearchResults">        
  355.         <body><![CDATA[
  356.                     
  357.               var resultsDoc = desktopSearch.RetrieveResults();
  358.               var searchURL;
  359.               resultsCount =  desktopSearch.GetSearchInfo(resultsDoc, 'count');                                                                                      
  360.                 
  361.               if (resultsCount> 0){
  362.                 searchURL = desktopSearch.CreateResultsPage(resultsDoc);                                                                                                                        
  363.               } else {
  364.                       var prompts = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].
  365.                                         getService(Components.interfaces.nsIPromptService);
  366.                                                                          prompts.alert(window, "Desktop Search", "Desktop Search found no matching results.");
  367.                                         //prompts.alert(window, this.mStringBundle.getString("searchPromptTitle"), this.mStringBundle.getString("searchNoMatchingResultsMsg"));
  368.             
  369.               }                                           
  370.               
  371.               var broadcaster = window.top.document.getElementById('searchEngineBroadcaster');              
  372.               broadcaster.setAttribute("searchStatus", 'complete');             
  373.           
  374.               if (searchURL) {SearchLoadURL(searchURL, this.mEnterEvent, null, true )}              
  375.           ]]></body>
  376.       </method>
  377.  
  378.         <method name="onSearchBoxSize">
  379.         <parameter name="aEvent"/>
  380.         <body><![CDATA[
  381.  
  382.         if (!this.parentNode) return; // JMC - Sanity check fixes BLT bug 127010
  383.  
  384.          var newSize;
  385.            newSize = aEvent.target.getAttribute("value");
  386.             this.parentNode.style.width = newSize;
  387.  
  388.               var prefService = Components.classes["@mozilla.org/preferences-service;1"]
  389.                            .getService(Components.interfaces.nsIPrefBranch);
  390.          prefService.setCharPref("browser.search.size",newSize);
  391.             /*
  392.             var menupopup = document.getAnonymousElementByAttribute(this, "anonid", "searchbar-size-popup");
  393.          var foundme = document.getAnonymousElementByAttribute(menupopup, "value", newSize);
  394.          if (foundme)
  395.              foundme.setAttribute("checked", "true");
  396.                */
  397.          this.focus();
  398.          this.select();
  399.  
  400.         ]]></body>
  401.       </method>
  402.  
  403.  
  404.       <method name="onEnginePopupCommand">
  405.         <parameter name="aEvent"/>
  406.         <body><![CDATA[
  407.           var target = aEvent.target;          
  408.           /*if (target.getAttribute("anonid") == "addengine-menuitem") {
  409.             var regionBundle = document.getElementById("bundle_browser_region");
  410.             loadURI(regionBundle.getString("searchEnginesURL"), null, null);
  411.           } else {*/
  412.             //alert(target.id);
  413.             this.currentEngine = target.id;
  414.             this.focus();
  415.             this.select();
  416.           /*}*/
  417.         ]]></body>
  418.       </method>
  419.  
  420.       <method name="onEnginePopupShowing">
  421.         <parameter name="aEvent"/>
  422.         <body><![CDATA[
  423.             //dump("\n\nOnEnginePopupShowing... executed! \n\n");
  424.             
  425.             if (!this.parentNode) return;
  426.             
  427.           var target = aEvent.target;
  428.           var element = document.getAnonymousElementByAttribute(this.parentNode,
  429.                            "anonid", "searchsize-menuseparator");
  430.  
  431.           if (!element)
  432.             return;
  433.  
  434.             var myParent = element.parentNode;
  435.  
  436.             myParent.removeChild(element);
  437.             myParent.appendChild(element);
  438.  
  439.           element = document.getAnonymousElementByAttribute(this.parentNode,
  440.                            "anonid", "searchsize-menu");
  441.  
  442.             myParent.removeChild(element);
  443.             myParent.appendChild(element);
  444.  
  445.         ]]></body>
  446.       </method>
  447.  
  448.       <method name="onEnginePopupHidden">
  449.         <parameter name="aEvent"/>
  450.         <body><![CDATA[
  451.         if (!this.parentNode) return;
  452.         
  453.           var target = aEvent.target;
  454.           var element = document.getAnonymousElementByAttribute(this.parentNode,
  455.                            "anonid", "addengine-menuitem");
  456.           if (element) {
  457.             target.removeChild(target.lastChild);
  458.             target.removeChild(target.lastChild);
  459.           }
  460.         ]]></body>
  461.       </method>
  462.  
  463.       <!-- nsIController -->
  464.       <field name="searchbarController" readonly="true"><![CDATA[
  465.       ({
  466.         mOuter: this,
  467.  
  468.         supportsCommand: function (aCommand)
  469.         {
  470.           return aCommand == "cmd_clearhistory";
  471.         },
  472.  
  473.         isCommandEnabled: function (aCommand)
  474.         {
  475.            var entries = this.mOuter.ReadSearchHistory();
  476.            // MERC - JCH: If search history file is empty, array still ends up with size == 1.
  477.            return entries.length > 1;
  478.          
  479.            // return this.mOuter.FORMHISTSVC.nameExists(
  480.            //        this.mOuter.getAttribute("autocompletesearchparam"));
  481.         },
  482.  
  483.         doCommand: function (aCommand)
  484.         {
  485.             this.mOuter.ClearSearchHistory();
  486.           //this.mOuter.FORMHISTSVC.removeEntriesForName(
  487.           //    this.mOuter.getAttribute("autocompletesearchparam"));
  488.           //this.mOuter.value = "";
  489.         }
  490.       })
  491.       ]]></field>
  492.  
  493.       <!-- DND Observer -->
  494.       <field name="searchbarDNDObserver" readonly="true"><![CDATA[
  495.       ({
  496.         mOuter: this,
  497.  
  498.         onDrop: function (aEvent, aXferData, aDragSession)
  499.         {
  500.           var data = transferUtils.retrieveURLFromData(aXferData.data,
  501.                          aXferData.flavour.contentType);
  502.           if (data) {
  503.             // XXXBlake Workaround caret crash when you try to set the
  504.             // textbox's value on dropping
  505.             setTimeout(function(This, data, evt) { This.value = data; This.onTextEntered(evt); }, 0, this.mOuter, data, aEvent);
  506.           }
  507.         },
  508.  
  509.         getSupportedFlavours: function ()
  510.         {
  511.           var flavourSet = new FlavourSet();
  512.  
  513.           flavourSet.appendFlavour("text/unicode");
  514.           flavourSet.appendFlavour("text/x-moz-url");
  515.           flavourSet.appendFlavour("application/x-moz-file", "nsIFile");
  516.           return flavourSet;
  517.         }
  518.       })
  519.       ]]></field>
  520.  
  521.     
  522.       <!-- MERC - JCH: The following four methods address BLT# 150209 -->
  523.  
  524.       <method name="GetSearchHistoryFile">
  525.           <body><![CDATA[
  526.           //dump('GetSearchHistoryFile(): '+this.SEARCH_HISTORY_FILE);
  527.  
  528.           // Get the user's profile directory
  529.           var profileDir = Components.classes["@mozilla.org/file/directory_service;1"]
  530.                                         .getService(Components.interfaces.nsIProperties)
  531.                                         .get("ProfD", Components.interfaces.nsILocalFile);
  532.           if (profileDir)
  533.           {
  534.               // Create file descriptor
  535.               var file = profileDir.clone();
  536.               file.append(this.SEARCH_HISTORY_FILE);
  537.               // returns nsILocalFile
  538.                 return file;
  539.           }
  540.          
  541.           ]]></body>
  542.       </method>
  543.  
  544.       <method name="EnsureSearchHistoryFileExists">      
  545.           <body><![CDATA[
  546.           //dump('EnsureSearchHistoryFileExists()');
  547.  
  548.           var file = this.GetSearchHistoryFile();
  549.           if (!file.exists()) {
  550.             //dump(' creating file: '+this.SEARCH_HISTORY_FILE);
  551.             file.create(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 0);
  552.           }
  553.           // returns nsILocalFile
  554.           return file; 
  555.           ]]></body>
  556.       </method>
  557.  
  558.       <method name="ReadSearchHistory">
  559.           <body><![CDATA[
  560.           //dump('ReadSearchHistory()');
  561.  
  562.           var file = this.EnsureSearchHistoryFileExists();
  563.  
  564.           // Init the file input stream
  565.           var fis = Components.classes["@mozilla.org/network/file-input-stream;1"]
  566.                               .createInstance(Components.interfaces.nsIFileInputStream);
  567.           fis.init(file, this.PR_RDONLY, 0, 0);
  568.  
  569.           // Init a scriptable input stream
  570.           var sis = Components.classes["@mozilla.org/scriptableinputstream;1"]
  571.                               .createInstance(Components.interfaces.nsIScriptableInputStream);
  572.           sis.init(fis);
  573.  
  574.           // Read the file
  575.           var fileContents = sis.read(sis.available());
  576.  
  577.           // Close file
  578.           fis.close();
  579.  
  580.           // Return the lines as an array
  581.           return fileContents.split('\n');
  582.           ]]></body>
  583.       </method>
  584.  
  585.       <method name="ClearSearchHistory">
  586.           <body><![CDATA[
  587.           //dump('ClearSearchHistory()');
  588.           var file = this.GetSearchHistoryFile();
  589.           if (file.exists()) 
  590.           {
  591.               // Init the file input stream
  592.               var fis = Components.classes["@mozilla.org/network/file-input-stream;1"]
  593.                                   .createInstance(Components.interfaces.nsIFileInputStream);
  594.               fis.init(file, this.PR_RDONLY, 0, 
  595.                        Components.interfaces.nsIFileInputStream.DELETE_ON_CLOSE);
  596.               fis.close();
  597.           }
  598.           // MERC (rpaul) clear the searchbar text
  599.                 var searchbar = document.getElementById('searchbar');
  600.           if (searchbar)
  601.           {
  602.               searchbar.clear();
  603.           }
  604.  
  605.           // <input name=q> is the entries stored for search engine forms.  Clear them. 
  606.           var formHistSvc = Components.classes["@mozilla.org/satchel/form-history;1"]
  607.                                  .getService(Components.interfaces.nsIFormHistory);
  608.         formHistSvc.removeEntriesForName("q");          
  609.           ]]></body>
  610.       </method>
  611.  
  612.     </implementation>
  613.  
  614.     <handlers>
  615.  
  616.       <handler event="keypress" keycode="vk_up" modifiers="control" phase="capturing">
  617.         <![CDATA[
  618.           var currentEngine = this.currentEngine;
  619.           if (currentEngine) {
  620.           var searchEngineMenuitem = document.getAnonymousElementByAttribute(this.parentNode, "id", currentEngine);
  621.             var newEngine = searchEngineMenuitem.previousSibling;
  622.             if (newEngine)
  623.               this.currentEngine = newEngine.id;
  624.           }
  625.           event.preventDefault();
  626.           event.stopPropagation();
  627.         ]]>
  628.       </handler>
  629.  
  630.       <handler event="keypress" keycode="vk_down" modifiers="control" phase="capturing">
  631.         <![CDATA[
  632.           var currentEngine = this.currentEngine;
  633.           if (currentEngine) {
  634.             var searchEngineMenuitem = document.getAnonymousElementByAttribute(this.parentNode, "id", currentEngine);
  635.  
  636.             var newEngine = searchEngineMenuitem.nextSibling;
  637.  
  638.             if (newEngine)
  639.               this.currentEngine = newEngine.id;
  640.           }
  641.           event.preventDefault();
  642.           event.stopPropagation();
  643.         ]]>
  644.       </handler>
  645.  
  646.       <handler event="dragdrop" phase="capturing">
  647.         nsDragAndDrop.drop(event, this.searchbarDNDObserver);
  648.       </handler>
  649.  
  650.     </handlers>
  651.  
  652.   </binding>
  653.  
  654.   <binding id="searchbar-dropmarker" extends="chrome://browser/content/search.xml#searchbar-base">
  655.     <content>
  656.       <xul:stack flex="1">
  657.         <xul:hbox align="center">
  658.           <xul:image class="searchbar-engine-image" xbl:inherits="src"/>
  659.         </xul:hbox>
  660.         <xul:hbox align="end">
  661.             <xul:spacer flex="1"/>
  662.                 <xul:image class="searchbar-dropmarker-image"/>
  663.           </xul:hbox>
  664.       </xul:stack>
  665.       <children/>
  666.     </content>
  667.   </binding>
  668.  
  669. </bindings>
  670.