232272-v1v3
Produced: 26/04/2006 4:31:45 PM
   
Mode:  Differences with Context  
   
Left file: I:\manager.diff     Right file: I:\manager3.diff  
36      var searchBar = document.getElementById("searchbar"); = 36      var searchBar = document.getElementById("searchbar");
37      if (searchBar && !searchBar.parentNode.parentNode.collapsed &&   37      if (searchBar && !searchBar.parentNode.parentNode.collapsed &&
38 -        !(window.getComputedStyle(searchBar.parentNode, null).display == "none"))   38 -        !(window.getComputedStyle(searchBar.parentNode, null).display == "none"))
39 +        window.getComputedStyle(searchBar.parentNode, null).display != "none")   39 +        window.getComputedStyle(searchBar.parentNode, null).display != "none")
40        return searchBar;   40        return searchBar;
41      return null;   41      return null;
    -+ 42 +  },
      43 +
      44 +  loadAddEngines: function BrowserSearch_loadAddEngines() {
      45 +    var newWindowPref = gPrefService.getIntPref("browser.link.open_newwindow");
      46 +    var where = newWindowPref == 3 ? "tab" : "window";
      47 +    var regionBundle = document.getElementById("bundle_browser_region");
      48 +    var searchEnginesURL = regionBundle.getString("searchEnginesURL");
      49 +    openUILinkIn(searchEnginesURL, where);
42    } = 50    }
43 }   51 }
44   52
45 function FillHistoryMenu(aParent, aMenu, aInsertBefore)   53 function FillHistoryMenu(aParent, aMenu, aInsertBefore)
46    {   54    {
47      // Remove old entries if any   55      // Remove old entries if any
    -+ 56      deleteHistoryItems(aParent);
      57
48 Index: browser/components/search/jar.mn = 58 Index: browser/components/search/jar.mn
49 ===================================================================   59 ===================================================================
50 RCS file: /cvsroot/mozilla/browser/components/search/jar.mn,v   60 RCS file: /cvsroot/mozilla/browser/components/search/jar.mn,v
51 retrieving revision 1.1   61 retrieving revision 1.1
52 diff -u -p -8 -r1.1 jar.mn   62 diff -u -p -8 -r1.1 jar.mn
53 --- browser/components/search/jar.mn  17 Mar 2006 07:15:42 -0000  1.1   63 --- browser/components/search/jar.mn  17 Mar 2006 07:15:42 -0000  1.1
54 +++ browser/components/search/jar.mn  20 Apr 2006 05:21:42 -0000   64 +++ browser/components/search/jar.mn  26 Apr 2006 20:28:27 -0000
55 @@ -1,3 +1,5 @@   65 @@ -1,3 +1,5 @@
56 browser.jar:   66 browser.jar:
57 *       content/browser/search/search.xml                           (content/search.xml)   67 *       content/browser/search/search.xml                           (content/search.xml)
58          content/browser/search/searchbarBindings.css                (content/searchbarBindings.css)   68          content/browser/search/searchbarBindings.css                (content/searchbarBindings.css)
59 +        content/browser/search/engineManager.xul                    (content/engineManager.xul) <> 69 +*       content/browser/search/engineManager.xul                    (content/engineManager.xul)
60 +*       content/browser/search/engineManager.js                     (content/engineManager.js) = 70 +*       content/browser/search/engineManager.js                     (content/engineManager.js)
61 Index: browser/components/search/nsIBrowserSearchService.idl   71 Index: browser/components/search/nsIBrowserSearchService.idl
62 ===================================================================   72 ===================================================================
63 RCS file: /cvsroot/mozilla/browser/components/search/nsIBrowserSearchService.idl,v   73 RCS file: /cvsroot/mozilla/browser/components/search/nsIBrowserSearchService.idl,v
64 retrieving revision 1.2   74 retrieving revision 1.2
65 diff -u -p -8 -r1.2 nsIBrowserSearchService.idl   75 diff -u -p -8 -r1.2 nsIBrowserSearchService.idl
 
82     * The POST data associated with a search submission, wrapped in a MIME = 92     * The POST data associated with a search submission, wrapped in a MIME
83     * input stream. May be null.   93     * input stream. May be null.
84     */   94     */
85    readonly attribute nsIInputStream postData;   95    readonly attribute nsIInputStream postData;
86   96
      97 @@ -129,17 +129,17 @@ interface nsISearchEngine : nsISupports
    -+ 98
      99    /**
      100     * A URL string pointing to the engine's search form.
      101     */
      102    readonly attribute AString searchForm;
      103
      104 };
      105
      106 -[scriptable, uuid(eaa8c60f-a0d7-4afe-b629-ab5ac9434298)]
      107 +[scriptable, uuid(5bcbc35a-8514-4583-9ef1-5bf5d10327f4)]
      108 interface nsIBrowserSearchService : nsISupports
      109 {
      110    /**
      111     * Adds a new search engine from the file at the supplied URI.
      112     *
      113     * @param engineURL
      114     *        The URL to the search engine's description file.
      115     *
87 @@ -222,32 +222,44 @@ interface nsIBrowserSearchService : nsIS = 116 @@ -208,48 +208,62 @@ interface nsIBrowserSearchService : nsIS
    -+ 117    nsISearchEngine getEngineByName(in AString aEngineName);
      118
      119    /**
      120     * Returns an array of all installed search engines.
88     * = 121     *
89     * @returns an array of nsISearchEngine objects.   122     * @returns an array of nsISearchEngine objects.
90     */   123     */
    -+ 124    void getEngines(
      125 -            out unsigned long engineCount,
      126 +            out unsigned long engineCount,
      127              [retval, array, size_is(engineCount)] out nsISearchEngine engines);
      128
      129    /**
      130     * Returns an array of all installed search engines whose hidden attribute is
      131     * false.
      132     *
      133     * @returns an array of nsISearchEngine objects.
      134     */
91    void getVisibleEngines( = 135    void getVisibleEngines(
92             out unsigned long engineCount, <> 136 -            out unsigned long engineCount,
      137 +            out unsigned long engineCount,
93              [retval, array, size_is(engineCount)] out nsISearchEngine engines); = 138              [retval, array, size_is(engineCount)] out nsISearchEngine engines);
94   139
95    /**   140    /**
96 +   * Moves a search engine.   141 +   * Moves a search engine.
97 +   *   142 +   *
98 +   * @param  engine   143 +   * @param  engine
99 +   *         The engine to remove.   144 +   *         The engine to remove.
100 +   * @param  dir <> 145 +   * @param  newIndex
101 +   *         The direction to move the engine. +1 for "up", -1 for "down".   146 +   *         The engine's new index.
      147 +   *
      148 +   * @throws NS_ERROR_FAILURE if newIndex is out of bounds.
102 +   */ = 149 +   */
103 +  void moveEngine(in nsISearchEngine engine, in long dir); <> 150 +  void moveEngine(in nsISearchEngine engine, in long newIndex);
104 + = 151 +
105 +  /**   152 +  /**
106     * Removes the search engine. If the search engine is installed in a global   153     * Removes the search engine. If the search engine is installed in a global
107     * location, this will just hide the engine. If the engine is in the user's   154     * location, this will just hide the engine. If the engine is in the user's
108     * profile directory, it will be removed from disk.   155     * profile directory, it will be removed from disk.
109     *   156     *
 
121 = 168
122    /**   169    /**
123 -   * The currently active search engine.   170 -   * The currently active search engine.
124 +   * The currently active search engine. May be null if there are no visible   171 +   * The currently active search engine. May be null if there are no visible
125 +   * search engines installed.   172 +   * search engines installed.
126     */   173     */
127   attribute nsISearchEngine currentEngine;  <> 174 -  attribute nsISearchEngine currentEngine; 
      175 +  attribute nsISearchEngine currentEngine;
128 = 176
129 };   177 };
130   178
131 %{ C++   179 %{ C++
132 /**   180 /**
133   * The observer topic to listen to for actions performed on installed   181   * The observer topic to listen to for actions performed on installed
    -+ 182   * search engines.
      183   */
134 Index: browser/components/search/nsSearchService.js = 184 Index: browser/components/search/nsSearchService.js
135 ===================================================================   185 ===================================================================
136 RCS file: /cvsroot/mozilla/browser/components/search/nsSearchService.js,v   186 RCS file: /cvsroot/mozilla/browser/components/search/nsSearchService.js,v
137 retrieving revision 1.15   187 retrieving revision 1.17
138 diff -u -p -8 -r1.15 nsSearchService.js   188 diff -u -p -8 -r1.17 nsSearchService.js
139 --- browser/components/search/nsSearchService.js  19 Apr 2006 21:16:45 -0000  1.15   189 --- browser/components/search/nsSearchService.js  26 Apr 2006 05:13:07 -0000  1.17
 
198              "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; = 248              "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
199 -  var out = "", bits = 0, i, j;   249 -  var out = "", bits = 0, i, j;
200 +  var out = "", bits, i, j;   250 +  var out = "", bits, i, j;
201   251
202    while (aBytes.length >= 3) {   252    while (aBytes.length >= 3) {
203      bits = 0;   253      bits = 0;
204     for (i=0; i<3; i++) { <> 254 -    for (i=0; i<3; i++) {
      255 +    for (i = 0; i < 3; i++) {
205        bits <<= 8; = 256        bits <<= 8;
206        bits |= aBytes[i];   257        bits |= aBytes[i];
207      }   258      }
208     for (j=18; j>=0; j-=6) <> 259 -    for (j=18; j>=0; j-=6)
      260 +    for (j = 18; j >= 0; j -= 6)
      261        out += B64_CHARS[(bits>>j) & 0x3F];
      262
      263      aBytes.splice(0, 3);
      264    }
      265
      266    switch (aBytes.length) {
      267      case 2:
      268        out += B64_CHARS[(aBytes[0]>>2) & 0x3F];
209 @@ -270,17 +270,17 @@ function b64(aBytes) { = 269 @@ -244,17 +244,17 @@ function b64(aBytes) {
210    }   270    }
211    return out;   271    return out;
212 }   272 }
213   273
214 function iconLoadListener(aChannel, aEngine) {   274 function iconLoadListener(aChannel, aEngine) {
 
251        var endMark   = /\s*>\s*$/gi; = 311        var endMark   = /\s*>\s*$/gi;
252   312
253        var foundStart = false;   313        var foundStart = false;
254        var startLine, numberOfLines;   314        var startLine, numberOfLines;
255        // Find the beginning and end of the section   315        // Find the beginning and end of the section
256 -      for (var i=0; i<lines.length; i++) {   316 -      for (var i=0; i<lines.length; i++) {
257 +      for (var i = 0; i<lines.length; i++) { <> 317 +      for (var i = 0; i < lines.length; i++) {
258          if (foundStart) { = 318          if (foundStart) {
259            if (endMark.test(lines[i])) {   319            if (endMark.test(lines[i])) {
260              numberOfLines = i - startLine;   320              numberOfLines = i - startLine;
261              // Remove the end marker   321              // Remove the end marker
262              lines[i] = lines[i].replace(endMark, "");   322              lines[i] = lines[i].replace(endMark, "");
263              // If the endmarker was not the only thing on the line, include   323              // If the endmarker was not the only thing on the line, include
 
270        lines = lines.splice(startLine, numberOfLines); = 330        lines = lines.splice(startLine, numberOfLines);
271        LOG("_parseAsSherlock::getSection: Section lines:\n" +   331        LOG("_parseAsSherlock::getSection: Section lines:\n" +
272            lines.join("\n"));   332            lines.join("\n"));
273   333
274        var section = {};   334        var section = {};
275 -      for (var i=0; i<lines.length; i++) {   335 -      for (var i=0; i<lines.length; i++) {
276 +      for (var i = 0; i<lines.length; i++) { <> 336 +      for (var i = 0; i < lines.length; i++) {
277          var line = sTrim(lines[i]); = 337          var line = sTrim(lines[i]);
278   338
279          var els = line.split("=");   339          var els = line.split("=");
280          var name = sTrim(els.shift().toLowerCase());   340          var name = sTrim(els.shift().toLowerCase());
281          var value = sTrim(els.join("="));   341          var value = sTrim(els.join("="));
282   342
 
308        // <input> is first:  Name Attr:  Prefix      Data           Example: = 368        // <input> is first:  Name Attr:  Prefix      Data           Example:
309        // YES                EMPTY       None        <value>        TEMPLATE<value>   369        // YES                EMPTY       None        <value>        TEMPLATE<value>
310        // YES                NON-EMPTY   ?           <name>=<value> TEMPLATE?<name>=<value>   370        // YES                NON-EMPTY   ?           <name>=<value> TEMPLATE?<name>=<value>
311        // NO                 EMPTY       ------------- <ignored> --------------   371        // NO                 EMPTY       ------------- <ignored> --------------
312        // NO                 NON-EMPTY   &           <name>=<value> TEMPLATE?<n1>=<v1>&<n2>=<v2>   372        // NO                 NON-EMPTY   &           <name>=<value> TEMPLATE?<n1>=<v1>&<n2>=<v2>
313 -      for (var i=0; i<inputs.length; i++) {   373 -      for (var i=0; i<inputs.length; i++) {
314 +      for (var i = 0; i<inputs.length; i++) { <> 374 +      for (var i = 0; i < inputs.length; i++) {
315          var name  = inputs[i][0]; = 375          var name  = inputs[i][0];
316          var value = inputs[i][1];   376          var value = inputs[i][1];
317          if (i==0) {   377          if (i==0) {
318            if (name == "")   378            if (name == "")
319              template += kUserDefined;   379              template += kUserDefined;
320            else   380            else
 
325        url = new EngineURL("text/html", method, template); = 385        url = new EngineURL("text/html", method, template);
326   386
327      } else if (method == "POST") {   387      } else if (method == "POST") {
328        // Create the URL object and just add the parameters directly   388        // Create the URL object and just add the parameters directly
329        url = new EngineURL("text/html", method, template);   389        url = new EngineURL("text/html", method, template);
330 -      for (var i=0; i<inputs.length; i++) {   390 -      for (var i=0; i<inputs.length; i++) {
331 +      for (var i = 0; i<inputs.length; i++) { <> 391 +      for (var i = 0; i < inputs.length; i++) {
332          var name  = inputs[i][0]; = 392          var name  = inputs[i][0];
333          var value = inputs[i][1];   393          var value = inputs[i][1];
334          if (name)   394          if (name)
335            url.addParam(name, value);   395            url.addParam(name, value);
336        }   396        }
337      } else   397      } else
 
380        this._loadEngines(location); = 440        this._loadEngines(location);
381      }   441      }
382   442
383 +    // Now that all engines are loaded, build the sorted engine list   443 +    // Now that all engines are loaded, build the sorted engine list
384 +    this._buildSortedEngineList();   444 +    this._buildSortedEngineList();
385 +   445 +
386 +    // Remove prefs for non-existent engines +-    
387 +    this._clearOldPrefs();      
388 +      
389      selectedEngineName = getLocalizedPref(BROWSER_SEARCH_PREF + = 446      selectedEngineName = getLocalizedPref(BROWSER_SEARCH_PREF +
390                                            "selectedEngine");   447                                            "selectedEngine");
391      this._currentEngine = this.getEngineByName(selectedEngineName) ||   448      this._currentEngine = this.getEngineByName(selectedEngineName) ||
392                            this.defaultEngine;   449                            this.defaultEngine;
393    },   450    },
394   451
 
410    _loadEngines: function SRCH_SVC_loadEngines(aDir) { = 467    _loadEngines: function SRCH_SVC_loadEngines(aDir) {
411      LOG("_loadEngines: Searching in " + aDir.path + " for search engines.");   468      LOG("_loadEngines: Searching in " + aDir.path + " for search engines.");
412   469
413      // Check whether aDir is the user profile dir   470      // Check whether aDir is the user profile dir
414      var isInProfile = aDir.equals(getDir(NS_APP_USER_SEARCH_DIR));   471      var isInProfile = aDir.equals(getDir(NS_APP_USER_SEARCH_DIR));
415 @@ -1772,17 +1780,102 @@ SearchService.prototype = {   472 @@ -1746,18 +1751,78 @@ SearchService.prototype = {
    -+ 473              addedEngine._iconURI = ios.newFileURI(icon);
416          } = 474          }
417        }   475        }
418   476
419        this._addEngineToStore(addedEngine);   477        this._addEngineToStore(addedEngine);
420      }   478      }
421    },   479    },
422   480
423    /** +-    
424 -   * Converts a Sherlock file and it's icon into the custom XML format used by      
425 +   * Clears prefs for search engines that no longer exist. This is done here      
426 +   * in addition to in removeEngine since some engines can be removed without      
427 +   * going through removeEngine (deleted manually, extension uninstalled, etc).      
428 +   */      
429 +  _clearOldPrefs: function SRCH_SVC_clearOldPrefs() {      
430 +    var app = Cc["@mozilla.org/xre/app-info;1"].      
431 +              getService(Components.interfaces.nsIXULAppInfo).      
432 +              QueryInterface(Components.interfaces.nsIXULRuntime);      
433 +      
434 +    var preferences = Cc["@mozilla.org/preferences-service;1"].      
435 +                      getService(Ci.nsIPrefService);      
436 +    var prefb = preferences.getBranch(BROWSER_SEARCH_PREF + "engine.");      
437 +    var prefList = prefb.getChildList("", {});      
438 +      
439 +    for (var i = 0; i<prefList.length; i++) {      
440 +      var engineName = decodeURIComponent(prefList[i].replace(/\.[^.]+$/, ""));      
441 +      if (!(engineName in this._engines) && !app.inSafeMode)      
442 +        prefb.clearUserPref(prefList[i]);      
443 +    }      
444 +  },      
445 +      
446 +  _saveSortedEngineList: function SRCH_SVC_saveSortedEngineList() { = 481 +  _saveSortedEngineList: function SRCH_SVC_saveSortedEngineList() {
447 +    var preferences = Cc["@mozilla.org/preferences-service;1"].   482 +    var preferences = Cc["@mozilla.org/preferences-service;1"].
448 +                      getService(Ci.nsIPrefService);   483 +                      getService(Ci.nsIPrefService);
449 +    var orderBranch = preferences.getBranch(BROWSER_SEARCH_PREF + "order.");   484 +    var orderBranch = preferences.getBranch(BROWSER_SEARCH_PREF + "order.");
450 +   485 +
451 +    // First, reset the old branch   486 +    // First, reset the old branch
452 +    for (var i = 1; ; ++i) { <>    
453 +      if (orderBranch.prefHasUserValue(i))   487 +    for (var i = 1; orderBranch.prefHasUserValue(i); ++i)
454 +        orderBranch.clearUserPref(i);   488 +      orderBranch.clearUserPref(i);
455 +      else      
456 +        break;      
457 +    }   489 +
458 +    // Now, create the new branch = 490 +    // Now, create the new branch
459 +    var pls = Cc["@mozilla.org/pref-localizedstring;1"].   491 +    var pls = Cc["@mozilla.org/pref-localizedstring;1"].
460 +              createInstance(Ci.nsIPrefLocalizedString);   492 +              createInstance(Ci.nsIPrefLocalizedString);
461 +    var engines = this._getSortedEngines(false);   493 +    var engines = this._getSortedEngines(false);
462 +    for (var i = 0; i < engines.length; ++i) {   494 +    for (var i = 0; i < engines.length; ++i) {
463 +      pls.data = engines[i].name;   495 +      pls.data = engines[i].name;
 
503 +                                         return 1; = 535 +                                         return 1;
504 +                                       return 0;   536 +                                       return 0;
505 +                                     });   537 +                                     });
506 +    this._sortedEngines = this._sortedEngines.concat(alphaEngines);   538 +    this._sortedEngines = this._sortedEngines.concat(alphaEngines);
507 +  },   539 +  },
508 +   540 +
509 +  /** <> 541   /**
      542 -   * Converts a Sherlock file and it's icon into the custom XML format used by
510 +   * Converts a Sherlock file and its icon into the custom XML format used by = 543 +   * Converts a Sherlock file and its icon into the custom XML format used by
511     * the Search Service. Saves the engine's icon (if present) into the XML as a   544     * the Search Service. Saves the engine's icon (if present) into the XML as a
512     * data: URI and changes the extension of the source file from ".src" to   545     * data: URI and changes the extension of the source file from ".src" to
513     * ".xml". The engine data is then written to the file as XML.   546     * ".xml". The engine data is then written to the file as XML.
514     * @param aEngine   547     * @param aEngine
515     *        The Engine object that needs to be converted.   548     *        The Engine object that needs to be converted.
 
523     *        The basename of the Sherlock file. = 556     *        The basename of the Sherlock file.
524     *          Example: "foo" for file "foo.src".   557     *          Example: "foo" for file "foo.src".
525     * @see nsIURL::fileBaseName   558     * @see nsIURL::fileBaseName
526     */   559     */
527    _findSherlockIcon: function SRCH_SVC_findSherlock(aEngineFile, aBaseName) {   560    _findSherlockIcon: function SRCH_SVC_findSherlock(aEngineFile, aBaseName) {
528 -    for (var i=0; i<SHERLOCK_ICON_EXTENSIONS.length; i++) {   561 -    for (var i=0; i<SHERLOCK_ICON_EXTENSIONS.length; i++) {
529 +    for (var i = 0; i<SHERLOCK_ICON_EXTENSIONS.length; i++) { <> 562 +    for (var i = 0; i < SHERLOCK_ICON_EXTENSIONS.length; i++) {
530        var icon = aEngineFile.parent.clone(); = 563        var icon = aEngineFile.parent.clone();
531        icon.append(aBaseName + SHERLOCK_ICON_EXTENSIONS[i]);   564        icon.append(aBaseName + SHERLOCK_ICON_EXTENSIONS[i]);
532        if (icon.exists() && icon.isFile())   565        if (icon.exists() && icon.isFile())
533          return icon;   566          return icon;
534      }   567      }
535      return null;   568      return null;
 
547 -    var i = 0; = 580 -    var i = 0;
548 -   581 -
549 -    while (true) {   582 -    while (true) {
550 -      engineName = getLocalizedPref(BROWSER_SEARCH_PREF + "order." + (++i));   583 -      engineName = getLocalizedPref(BROWSER_SEARCH_PREF + "order." + (++i));
551 -      if (!engineName)   584 -      if (!engineName)
552 -        break;   585 -        break;
    <> 586 +    if (aWithHidden)
      587 +      return this._sortedEngines;
553 -   588
554 -      engine = this._engines[engineName]; = 589 -      engine = this._engines[engineName];
555 -      if (engine && !(engineName in addedEngines) &&   590 -      if (engine && !(engineName in addedEngines) &&
556 -          (aWithHidden || !engine.hidden)) {   591 -          (aWithHidden || !engine.hidden)) {
557 -        engines.push(engine);   592 -        engines.push(engine);
558 -        addedEngines[engineName] = engine;   593 -        addedEngines[engineName] = engine;
559 -      }   594 -      }
560 -    }   595 -    }
561 +    if (aWithHidden) <>    
562 +      return this._sortedEngines;      
563   596 -
564 -    // No more sorted engines = 597 -    // No more sorted engines
565 -    for (engineName in this._engines) {   598 -    for (engineName in this._engines) {
566 -      engine = this._engines[engineName];   599 -      engine = this._engines[engineName];
567 -      if (!(engineName in addedEngines) && (aWithHidden || !engine.hidden))   600 -      if (!(engineName in addedEngines) && (aWithHidden || !engine.hidden))
568 -        engines.push(this._engines[engineName]);   601 -        engines.push(this._engines[engineName]);
569 -    }   602 -    }
 
624        delete this._engines[engineToRemove.name]; = 657        delete this._engines[engineToRemove.name];
625 +   658 +
626        notifyAction(engineToRemove, SEARCH_ENGINE_REMOVED);   659        notifyAction(engineToRemove, SEARCH_ENGINE_REMOVED);
627      }   660      }
628    },   661    },
629   662
630 +  moveEngine: function SRCH_SVC_moveEngine(aEngine, aDir) { <> 663 +  moveEngine: function SRCH_SVC_moveEngine(aEngine, aNewIndex) {
631 +    ENSURE_ARG(Math.abs(aDir) < this._sortedEngines.length,   664 +    ENSURE_ARG((aNewIndex < this._sortedEngines.length) && (aNewIndex >= 0),
632 +               "Invalid offset passed to moveEngine!");   665 +               "SRCH_SVC_moveEngine: Index out of bounds!");
633 +    ENSURE_ARG(aEngine instanceof Ci.nsISearchEngine, = 666 +    ENSURE_ARG(aEngine instanceof Ci.nsISearchEngine,
634 +               "Invalid engine passed to moveEngine!"); <> 667 +               "SRCH_SVC_moveEngine: Invalid engine passed to moveEngine!");
635 + = 668 +
636 +    var engine = aEngine.wrappedJSObject;   669 +    var engine = aEngine.wrappedJSObject;
637 +   670 +
638 +    var index = this._sortedEngines.indexOf(engine); <> 671 +    var currentIndex = this._sortedEngines.indexOf(engine);
639 +    ENSURE(index != -1, "moveEngine: Can't find engine to move!",   672 +    ENSURE(currentIndex != -1, "moveEngine: Can't find engine to move!",
640 +           Cr.NS_ERROR_UNEXPECTED); = 673 +           Cr.NS_ERROR_UNEXPECTED);
641 +   674 +
642 +    var newIndex = index - aDir; +-    
643 +    ENSURE_ARG((newIndex < this._sortedEngines.length) && (newIndex >= 0),      
644 +               "Index out of bounds!");      
645 +      
646 +    // Swap the two engines = 675 +    // Swap the two engines
647 +    this._sortedEngines[index] = this._sortedEngines[newIndex]; <> 676 +    this._sortedEngines[currentIndex] = this._sortedEngines[aNewIndex];
648 +    this._sortedEngines[newIndex] = engine;   677 +    this._sortedEngines[aNewIndex] = engine;
649 + = 678 +
650 +    notifyAction(engine, SEARCH_ENGINE_CHANGED);   679 +    notifyAction(engine, SEARCH_ENGINE_CHANGED);
651 +  },   680 +  },
652 +   681 +
653    get defaultEngine() {   682    get defaultEngine() {
654      const defPref = BROWSER_SEARCH_PREF + "defaultenginename";   683      const defPref = BROWSER_SEARCH_PREF + "defaultenginename";
 
662    }, = 691    },
663   692
664    get currentEngine() {   693    get currentEngine() {
665 -    if (this._currentEngine.hidden)   694 -    if (this._currentEngine.hidden)
666 +    if (!this._currentEngine || this._currentEngine.hidden)   695 +    if (!this._currentEngine || this._currentEngine.hidden)
667        this._currentEngine = this.defaultEngine;   696        this._currentEngine = this.defaultEngine;
668 -    return this._currentEngine; <> 697     return this._currentEngine;
669 +    return this._currentEngine || this.defaultEngine;      
670    }, = 698    },
671    set currentEngine(val) {   699    set currentEngine(val) {
672 -    ENSURE_ARG(val.QueryInterface(Ci.nsISearchEngine),   700 -    ENSURE_ARG(val.QueryInterface(Ci.nsISearchEngine),
673 +    ENSURE_ARG(val instanceof Ci.nsISearchEngine,   701 +    ENSURE_ARG(val instanceof Ci.nsISearchEngine,
674                 "Invalid argument passed to currentEngine setter");   702                 "Invalid argument passed to currentEngine setter");
675   703
 
753 +const Ci = Components.interfaces; = 781 +const Ci = Components.interfaces;
754 +const Cc = Components.classes;   782 +const Cc = Components.classes;
755 +   783 +
756 +var gEngineView = null;   784 +var gEngineView = null;
757 +   785 +
758 +var gEngineManagerDialog = {   786 +var gEngineManagerDialog = {
759 +  _strings: null, +-    
760 +      
761 +  init: function engineManager_init() { = 787 +  init: function engineManager_init() {
762 +    gEngineView = new EngineView(new EngineStore());   788 +    gEngineView = new EngineView(new EngineStore());
763 +   789 +
764 +    var tree = document.getElementById("engineList");   790 +    var tree = document.getElementById("engineList");
765 +    tree.view = gEngineView;   791 +    tree.view = gEngineView;
766 +   792 +
767 +    this._strings = document.getElementById("engineManagerBundle"); +-    
768 +      
769 +    var os = Cc["@mozilla.org/observer-service;1"]. = 793 +    var os = Cc["@mozilla.org/observer-service;1"].
770 +             getService(Ci.nsIObserverService);   794 +             getService(Ci.nsIObserverService);
771 +    os.addObserver(this, "browser-search-engine-modified", <> 795 +    os.addObserver(this, "browser-search-engine-modified", false);
772 +                   false);      
773 +      
774 +    // Set the "Add Engines" link's href      
775 +    var regionBundle = document.getElementById("regionBundle");      
776 +    var searchEnginesURL = regionBundle.getString("searchEnginesURL");      
777 +    var addEngines = document.getElementById("addEngines");      
778 +    addEngines.setAttribute("href", searchEnginesURL);      
779 +  }, = 796 +  },
780 +   797 +
781 +  observe: function engineManager_observe(aEngine, aTopic, aVerb) {   798 +  observe: function engineManager_observe(aEngine, aTopic, aVerb) {
782 +    if (aTopic == "browser-search-engine-modified") {   799 +    if (aTopic == "browser-search-engine-modified") {
783 +      aEngine.QueryInterface(Ci.nsISearchEngine)   800 +      aEngine.QueryInterface(Ci.nsISearchEngine)
784 +      switch (aVerb) {   801 +      switch (aVerb) {
 
805 +    os.removeObserver(this, "browser-search-engine-modified"); = 822 +    os.removeObserver(this, "browser-search-engine-modified");
806 +   823 +
807 +    // Commit the changes   824 +    // Commit the changes
808 +    gEngineView._engineStore.commit();   825 +    gEngineView._engineStore.commit();
809 +  },   826 +  },
810 +   827 +
811 remove: function engineManager_remove() { <> 828 loadAddEngines: function engineManager_loadAddEngines() {
812 +    var selectedEngine = gEngineView.selectedEngine;   829 +    this.onOK();
      830 +    window.opener.BrowserSearch.loadAddEngines();
813 +    if (!selectedEngine)   831 +    window.close();
814     return;   832 },
815 + = 833 +
    <> 834 +  remove: function engineManager_remove() {
816 +    gEngineView._engineStore.removeEngine(selectedEngine);   835 +    gEngineView._engineStore.removeEngine(gEngineView.selectedEngine);
817 +    var index = gEngineView.selectedIndex; = 836 +    var index = gEngineView.selectedIndex;
818 +    gEngineView.rowCountChanged(index, -1);   837 +    gEngineView.rowCountChanged(index, -1);
819 +    gEngineView.invalidate();   838 +    gEngineView.invalidate();
820 +    gEngineView.selection.select(Math.min(index, gEngineView.lastIndex));   839 +    gEngineView.selection.select(Math.min(index, gEngineView.lastIndex));
821 +  },   840 +  },
822 +   841 +
823 +  editAlias: function engineManager_editAlias() { +-    
824 +    var selectedEngine = gEngineView.selectedEngine;      
825 +    if (!selectedEngine)      
826 +      return;      
827 +      
828 +    var prompt = Cc["@mozilla.org/embedcomp/prompt-service;1"].      
829 +                 getService(Ci.nsIPromptService);      
830 +      
831 +    var alias = { value: selectedEngine.alias };      
832 +      
833 +    var title = this._strings.getString("edit_alias_title");      
834 +    var msg = this._strings.getString("edit_alias_msg");      
835 +      
836 +    if (prompt.prompt(window, title, msg, alias, null, { })) {      
837 +      gEngineView._engineStore.changeEngine(selectedEngine, "alias",      
838 +                                            alias.value);      
839 +      gEngineView.invalidate();      
840 +    }      
841 +  },      
842 +      
843 +  /** = 842 +  /**
844 +   * Moves the selected engine either up or down in the engine list   843 +   * Moves the selected engine either up or down in the engine list
845 +   * @param aDir   844 +   * @param aDir
846 +   *        -1 to move the selected engine down, +1 to move it up.   845 +   *        -1 to move the selected engine down, +1 to move it up.
847 +   */   846 +   */
848 move: function engineManager_move(aDir) { <> 847 bump: function engineManager_move(aDir) {
849 +    var selectedEngine = gEngineView.selectedEngine; = 848 +    var selectedEngine = gEngineView.selectedEngine;
850 +    if (!selectedEngine) <> 849 +    var newIndex = gEngineView.selectedIndex - aDir;
851 +      return;      
852 + = 850 +
853 +    if (Math.abs(aDir) != 1) <> 851 +    gEngineView._engineStore.moveEngine(selectedEngine, newIndex);
854 +      throw new Error("Invalid direction!");      
855 + = 852 +
    <> 853 +    gEngineView.invalidate();
856 +    var newIndex = gEngineView.selectedIndex - aDir;   854 +    gEngineView.selection.select(newIndex);
      855 +  },
857 + = 856 +
858   if (newIndex < 0 || newIndex > gEngineView.lastIndex) <> 857 /**
859 +      throw new Error("Invalid aDir!");   858 +   * Moves the selected engine to the specified index in the engine list.
      859 +   * @param aNewIndex
      860 +   *        The desired index of the engine in the list.
860 +   861 +   */
      862 +  moveToIndex: function engineManager_moveToIndex(aNewIndex) {
      863 +    var selectedEngine = gEngineView.selectedEngine;
861 +    gEngineView._engineStore.moveEngine(selectedEngine, aDir);   864 +    gEngineView._engineStore.moveEngine(selectedEngine, aNewIndex);
862 + = 865 +
863 +    gEngineView.invalidate();   866 +    gEngineView.invalidate();
864 +    gEngineView.selection.select(newIndex); <> 867 +    gEngineView.selection.select(aNewIndex);
865 +  }, = 868 +  },
866 +   869 +
867 +  onSelect: function engineManager_onSelect() {   870 +  onSelect: function engineManager_onSelect() {
868 +    var noEngineSelected = (gEngineView.selectedIndex == -1);   871 +    var noEngineSelected = (gEngineView.selectedIndex == -1);
869 +    document.getElementById("remove").disabled = noEngineSelected; <> 872 +    var lastSelected = (gEngineView.selectedIndex == gEngineView.lastIndex);
870 +    // document.getElementById("rename").disabled = noEngineSelected;   873 +    var firstSelected = (gEngineView.selectedIndex == 0);
871 +    document.getElementById("alias").disabled  = noEngineSelected;   874 +
      875 +    document.getElementById("cmd_remove").setAttribute("disabled",
      876 +                                                       noEngineSelected);
872 + = 877 +
873 +    document.getElementById("up").disabled = noEngineSelected || <> 878 +    document.getElementById("cmd_moveup").setAttribute("disabled",
874 +                                             (gEngineView.selectedIndex == 0);   879 +                                            noEngineSelected || firstSelected);
875 + = 880 +
876 +    var lastSelected = (gEngineView.selectedIndex == gEngineView.lastIndex); <> 881 +    document.getElementById("cmd_movedown").setAttribute("disabled",
877 +    document.getElementById("dn").disabled = noEngineSelected ||      
878 +                                             lastSelected;   882 +                                             noEngineSelected || lastSelected);
879 +  } = 883 +  }
880 +};   884 +};
881 +   885 +
882 +// "Operation" objects   886 +// "Operation" objects
883 +function EngineMoveOp(aEngineClone, aDir) { <> 887 +function EngineMoveOp(aEngineClone, aNewIndex) {
884 +  if (!aEngineClone || !aDir)   888 +  if (!aEngineClone)
885 +    throw new Error("bad args to new EngineMoveOp!"); = 889 +    throw new Error("bad args to new EngineMoveOp!");
886 +  this._engine = aEngineClone.originalEngine;   890 +  this._engine = aEngineClone.originalEngine;
887 +  this._dir = aDir; <> 891 +  this._newIndex = aNewIndex;
888 +} = 892 +}
889 +EngineMoveOp.prototype = {   893 +EngineMoveOp.prototype = {
890 +  _engine: null,   894 +  _engine: null,
891 +  _dir: null, <> 895 +  _newIndex: null,
892 +  commit: function EMO_commit() { = 896 +  commit: function EMO_commit() {
893 +    var searchService = Cc["@mozilla.org/browser/search-service;1"].   897 +    var searchService = Cc["@mozilla.org/browser/search-service;1"].
894 +                        getService(Ci.nsIBrowserSearchService);   898 +                        getService(Ci.nsIBrowserSearchService);
895 +    searchService.moveEngine(this._engine, this._dir); <> 899 +    searchService.moveEngine(this._engine, this._newIndex);
896 +  } = 900 +  }
897 +}   901 +}
898 +   902 +
899 +function EngineRemoveOp(aEngineClone) {   903 +function EngineRemoveOp(aEngineClone) {
900 +  if (!aEngineClone)   904 +  if (!aEngineClone)
901 +    throw new Error("bad args to new EngineRemoveOp!");   905 +    throw new Error("bad args to new EngineRemoveOp!");
 
904 +EngineRemoveOp.prototype = { = 908 +EngineRemoveOp.prototype = {
905 +  _engine: null,   909 +  _engine: null,
906 +  commit: function ERO_commit() {   910 +  commit: function ERO_commit() {
907 +    var searchService = Cc["@mozilla.org/browser/search-service;1"].   911 +    var searchService = Cc["@mozilla.org/browser/search-service;1"].
908 +                        getService(Ci.nsIBrowserSearchService);   912 +                        getService(Ci.nsIBrowserSearchService);
909 +    searchService.removeEngine(this._engine);   913 +    searchService.removeEngine(this._engine);
910 +  } +-    
911 +}      
912 +      
913 +function EngineChangeOp(aEngineClone, aProp, aNewValue) {      
914 +  if (!aEngineClone || !aProp)      
915 +    throw new Error("bad args to new EngineChangeOp!");      
916 +      
917 +  this._engine = aEngineClone.originalEngine;      
918 +  this._prop = aProp;      
919 +  this._newValue = aNewValue;      
920 +}      
921 +EngineChangeOp.prototype = {      
922 +  _engine: null,      
923 +  _prop: null,      
924 +  _newValue: null,      
925 +  commit: function ERO_commit() {      
926 +    this._engine[this._prop] = this._newValue;      
927 +  } = 914 +  }
928 +}   915 +}
929 +   916 +
930 +function EngineStore() {   917 +function EngineStore() {
931 +  var searchService = Cc["@mozilla.org/browser/search-service;1"].   918 +  var searchService = Cc["@mozilla.org/browser/search-service;1"].
932 +                      getService(Ci.nsIBrowserSearchService);   919 +                      getService(Ci.nsIBrowserSearchService);
 
963 +  }, = 950 +  },
964 +   951 +
965 +  addEngine: function ES_addEngine(aEngine) {   952 +  addEngine: function ES_addEngine(aEngine) {
966 +    this._engines.push(this._cloneEngine(aEngine));   953 +    this._engines.push(this._cloneEngine(aEngine));
967 +  },   954 +  },
968 +   955 +
969 changeEngine: function ES_changeEngine(aEngine, aProp, aNewValue) { <> 956 moveEngine: function ES_moveEngine(aEngine, aNewIndex) {
970 +    var index = this._getIndexForEngine(aEngine);   957 +    if (aNewIndex < 0 || aNewIndex > this._engines.length - 1)
971 +      
972 +    if (index == -1)      
973 +      throw new Error("invalid engine?");   958 +      throw new Error("ES_moveEngine: invalid aNewIndex!");
974 +      
975 +    this._engines[index][aProp] = aNewValue;      
976 +    this._ops.push(new EngineChangeOp(aEngine, aProp, aNewValue));      
977 +  },      
978 +      
979 +  moveEngine: function ES_moveEngine(aEngine, aDir) {      
980 +    var index = this._getIndexForEngine(aEngine); = 959 +    var index = this._getIndexForEngine(aEngine);
981 +    var newIndex = index - aDir; +-    
982 +    if (index == -1) = 960 +    if (index == -1)
983 +      throw new Error("invalid engine?"); <> 961 +      throw new Error("ES_moveEngine: invalid engine?");
984 +    if (newIndex < 0 || newIndex > this._engines.length - 1)      
985 +      throw new Error("invalid aDir!");      
986 + = 962 +
987 +    // Switch the two engines in our internal store   963 +    // Switch the two engines in our internal store
988 +    this._engines[index] = this._engines[newIndex]; <> 964 +    this._engines[index] = this._engines[aNewIndex];
989 +    this._engines[newIndex] = aEngine;   965 +    this._engines[aNewIndex] = aEngine;
990 + = 966 +
991 +    this._ops.push(new EngineMoveOp(aEngine, aDir)); <> 967 +    this._ops.push(new EngineMoveOp(aEngine, aNewIndex));
992 +  }, = 968 +  },
993 +   969 +
994 +  removeEngine: function ES_removeEngine(aEngine) {   970 +  removeEngine: function ES_removeEngine(aEngine) {
995 +    var index = this._getIndexForEngine(aEngine);   971 +    var index = this._getIndexForEngine(aEngine);
996 +    if (index == -1)   972 +    if (index == -1)
997 +      throw new Error("invalid engine?");   973 +      throw new Error("invalid engine?");
998 +   974 +
999 +    this._engines.splice(index, 1);   975 +    this._engines.splice(index, 1);
1000 +    this._ops.push(new EngineRemoveOp(aEngine));   976 +    this._ops.push(new EngineRemoveOp(aEngine));
1001 +  },   977 +  },
1002 +  <> 978 +
1003 +  reloadIcons: function ES_reloadIcons() { = 979 +  reloadIcons: function ES_reloadIcons() {
1004 +    this._engines.forEach(function (e) {   980 +    this._engines.forEach(function (e) {
1005 +      e.uri = e.originalEngine.uri;   981 +      e.uri = e.originalEngine.uri;
1006 +    });   982 +    });
1007 +  }   983 +  }
1008 +}   984 +}
 
1054 +    return ""; = 1030 +    return "";
1055 +  },   1031 +  },
1056 +   1032 +
1057 +  getCellText: function(index, column) {   1033 +  getCellText: function(index, column) {
1058 +    if (column.id == "engineName")   1034 +    if (column.id == "engineName")
1059 +      return this._engineStore.engines[index].name;   1035 +      return this._engineStore.engines[index].name;
1060 +    else if (column.id == "engineAlias") <> 1036 +    return "";
1061 +      return this._engineStore.engines[index].alias;      
1062 +  }, = 1037 +  },
1063 +   1038 +
1064 +  setTree: function(tree) {   1039 +  setTree: function(tree) {
1065 +    this.tree = tree;   1040 +    this.tree = tree;
1066 +  },   1041 +  },
1067 +   1042 +
 
1097 RCS file: browser/components/search/content/engineManager.xul = 1072 RCS file: browser/components/search/content/engineManager.xul
1098 diff -N browser/components/search/content/engineManager.xul   1073 diff -N browser/components/search/content/engineManager.xul
1099 --- /dev/null 1 Jan 1970 00:00:00 -0000   1074 --- /dev/null 1 Jan 1970 00:00:00 -0000
1100 +++ browser/components/search/content/engineManager.xul 20 Apr 2006 05:21:43 -0000   1075 +++ browser/components/search/content/engineManager.xul 26 Apr 2006 20:28:28 -0000
1101 @@ -0,0 +1,60 @@   1076 @@ -0,0 +1,113 @@
1102 +<?xml version="1.0"?>   1077 +<?xml version="1.0"?>
    -+ 1078 +# ***** BEGIN LICENSE BLOCK *****
      1079 +# Version: MPL 1.1/GPL 2.0/LGPL 2.1
      1080 +#
      1081 +# The contents of this file are subject to the Mozilla Public License Version
      1082 +# 1.1 (the "License"); you may not use this file except in compliance with
      1083 +# the License. You may obtain a copy of the License at
      1084 +# http://www.mozilla.org/MPL/
      1085 +#
      1086 +# Software distributed under the License is distributed on an "AS IS" basis,
      1087 +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      1088 +# for the specific language governing rights and limitations under the
      1089 +# License.
      1090 +#
      1091 +# The Original Code is the Browser Search Service.
      1092 +#
      1093 +# The Initial Developer of the Original Code is
      1094 +# Google Inc.
      1095 +# Portions created by the Initial Developer are Copyright (C) 2005
      1096 +# the Initial Developer. All Rights Reserved.
      1097 +#
      1098 +# Contributor(s):
      1099 +#   Ben Goodger <beng@google.com> (Original author)
      1100 +#   Gavin Sharp <gavin@gavinsharp.com>
      1101 +#
      1102 +# Alternatively, the contents of this file may be used under the terms of
      1103 +# either the GNU General Public License Version 2 or later (the "GPL"), or
      1104 +# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      1105 +# in which case the provisions of the GPL or the LGPL are applicable instead
      1106 +# of those above. If you wish to allow use of your version of this file only
      1107 +# under the terms of either the GPL or the LGPL, and not to allow others to
      1108 +# use your version of this file under the terms of the MPL, indicate your
      1109 +# decision by deleting the provisions above and replace them with the notice
      1110 +# and other provisions required by the GPL or the LGPL. If you do not delete
      1111 +# the provisions above, a recipient may use your version of this file under
      1112 +# the terms of any one of the MPL, the GPL or the LGPL.
      1113 +#
      1114 +# ***** END LICENSE BLOCK *****
1103 + = 1115 +
1104 +<?xml-stylesheet href="chrome://global/skin/"?>   1116 +<?xml-stylesheet href="chrome://global/skin/"?>
1105 +   1117 +
1106 +<!DOCTYPE dialog SYSTEM "chrome://browser/locale/engineManager.dtd">   1118 +<!DOCTYPE dialog SYSTEM "chrome://browser/locale/engineManager.dtd">
1107 +   1119 +
1108 +<dialog id="engineManager"   1120 +<dialog id="engineManager"
1109 +        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"   1121 +        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
1110 +        buttons="accept,cancel"   1122 +        buttons="accept,cancel"
1111 +        onload="gEngineManagerDialog.init();"   1123 +        onload="gEngineManagerDialog.init();"
1112 +        ondialogaccept="gEngineManagerDialog.onOK();"   1124 +        ondialogaccept="gEngineManagerDialog.onOK();"
1113 +        title="&engineManager.title;"   1125 +        title="&engineManager.title;"
1114 +        style="min-width: 40em;" <> 1126 +        style="&engineManager.style;"
      1127 +        persist="screenX screenY"
1115 +        windowtype="Browser:SearchManager"> = 1128 +        windowtype="Browser:SearchManager">
1116 +   1129 +
1117 +  <script type="application/x-javascript"   1130 +  <script type="application/x-javascript"
1118 +          src="chrome://browser/content/search/engineManager.js"/>   1131 +          src="chrome://browser/content/search/engineManager.js"/>
1119 +  <stringbundle id="engineManagerBundle"   1132 +  <stringbundle id="engineManagerBundle"
1120 +                src="chrome://browser/locale/search.properties"/>   1133 +                src="chrome://browser/locale/search.properties"/>
    <> 1134 +
1121 +  <stringbundle id="regionBundle"   1135 +  <commandset id="engineManagerCommandSet">
1122 +                src="chrome://browser-region/locale/region.properties"/>   1136 +    <command id="cmd_remove"
      1137 +             oncommand="gEngineManagerDialog.remove();"
      1138 +             disabled="true"/>
      1139 +    <command id="cmd_moveup"
      1140 +             oncommand="gEngineManagerDialog.bump(1);"
      1141 +             disabled="true"/>
      1142 +    <command id="cmd_movedown"
      1143 +             oncommand="gEngineManagerDialog.bump(-1);"
      1144 +             disabled="true"/>
      1145 +    <command id="cmd_editalias"
      1146 +             oncommand="gEngineManagerDialog.editAlias();"
      1147 +             disabled="true"/>
      1148 +  </commandset>
1123 + = 1149 +
1124 +  <keyset id="engineManagerKeyset">   1150 +  <keyset id="engineManagerKeyset">
1125 +    <key id="delete" keycode="VK_DELETE" <> 1151 +    <key id="delete" keycode="VK_DELETE" command="cmd_remove"/>
1126 +         oncommand="gEngineManagerDialog.remove();"/>      
1127 +  </keyset> = 1152 +  </keyset>
1128 +   1153 +
1129 +  <label>&engineManager.intro;</label> <> 1154 +  <description>&engineManager.intro;</description>
1130 + = 1155 +
1131 +  <separator class="thin"/>   1156 +  <separator class="thin"/>
1132 +   1157 +
1133 +  <hbox flex="1">   1158 +  <hbox flex="1">
1134 +    <tree id="engineList" flex="1" rows="10" hidecolumnpicker="true"   1159 +    <tree id="engineList" flex="1" rows="10" hidecolumnpicker="true"
1135 +          seltype="single" onselect="gEngineManagerDialog.onSelect();">   1160 +          seltype="single" onselect="gEngineManagerDialog.onSelect();">
1136 +      <treechildren id="engineChildren" flex="1"/>   1161 +      <treechildren id="engineChildren" flex="1"/>
1137 +      <treecols>   1162 +      <treecols>
1138 +        <treecol id="engineName" class="sortDirectionIndicator" flex="3"   1163 +        <treecol id="engineName" class="sortDirectionIndicator" flex="3"
1139 +                 persist="width" label="&nameColumn.label;"/>   1164 +                 persist="width" label="&nameColumn.label;"/>
1140 +        <splitter class="tree-splitter"/> +-    
1141 +        <treecol id="engineAlias" class="sortDirectionIndicator" flex="2"      
1142 +                 persist="width" label="&aliasColumn.label;"/>      
1143 +      </treecols> = 1165 +      </treecols>
1144 +    </tree>   1166 +    </tree>
1145 +    <vbox>   1167 +    <vbox>
1146 +      <spacer flex="1"/>   1168 +      <spacer flex="1"/>
1147 +      <button id="up" label="&up.label;" accesskey="&up.accesskey;" <> 1169 +      <button id="up"
1148 +              oncommand="gEngineManagerDialog.move(1);"/>   1170 +              label="&up.label;"
1149 +      <button id="dn" label="&dn.label;" accesskey="&dn.accesskey;"   1171 +              accesskey="&up.accesskey;"
1150 +              oncommand="gEngineManagerDialog.move(-1);"/>   1172 +              command="cmd_moveup"/>
      1173 +      <button id="dn"
      1174 +              label="&dn.label;"
      1175 +              accesskey="&dn.accesskey;"
      1176 +              command="cmd_movedown"/>
1151 +      <spacer flex="1"/> = 1177 +      <spacer flex="1"/>
1152 +      <button id="alias" label="&editAlias.label;" <> 1178 +      <button id="remove"
1153 +              accesskey="&editAlias.accesskey;"      
1154 +              oncommand="gEngineManagerDialog.editAlias();"/>      
1155 +      <button id="remove" label="&delete.label;"   1179 +              label="&remove.label;"
1156 +              accesskey="&delete.accesskey;"   1180 +              accesskey="&remove.accesskey;"
1157 +              oncommand="gEngineManagerDialog.remove();"/>   1181 +              command="cmd_remove"/>
1158 +    </vbox> = 1182 +    </vbox>
1159 +  </hbox>   1183 +  </hbox>
    <> 1184 +  <hbox>
1160 +  <label id="addEngines" class="text-link" value="&addEngine.label;"/>   1185   <label id="addEngines" class="text-link" value="&addEngine.label;"
      1186 +           onclick="gEngineManagerDialog.loadAddEngines();"/>
      1187 +    <spacer flex="1"/>
      1188 +  </hbox>
1161 +</dialog> = 1189 +</dialog>
1162 Index: browser/components/search/content/search.xml   1190 Index: browser/components/search/content/search.xml
1163 ===================================================================   1191 ===================================================================
1164 RCS file: /cvsroot/mozilla/browser/components/search/content/search.xml,v   1192 RCS file: /cvsroot/mozilla/browser/components/search/content/search.xml,v
1165 retrieving revision 1.41   1193 retrieving revision 1.43
1166 diff -u -p -8 -r1.41 search.xml   1194 diff -u -p -8 -r1.43 search.xml
 
1368 +                Components.classes["@mozilla.org/appshell/window-mediator;1"] = 1396 +                Components.classes["@mozilla.org/appshell/window-mediator;1"]
1369 +                          .getService(Components.interfaces.nsIWindowMediator);   1397 +                          .getService(Components.interfaces.nsIWindowMediator);
1370 +   1398 +
1371 +          var window = wm.getMostRecentWindow("Browser:SearchManager");   1399 +          var window = wm.getMostRecentWindow("Browser:SearchManager");
1372 +          if (window)   1400 +          if (window)
1373 +            window.focus()   1401 +            window.focus()
1374 +          else <> 1402 +          else {
      1403 +            setTimeout(function () {
1375 +            openDialog("chrome://browser/content/search/engineManager.xul",   1404 +              openDialog("chrome://browser/content/search/engineManager.xul",
1376 +                       "_blank", "resizable,chrome,dialog,modal");   1405 +                         "_blank", "chrome,dialog,modal,centerscreen");
      1406 +            }, 0);
      1407 +          }
1377          ]]></body> = 1408          ]]></body>
1378        </method>   1409        </method>
1379   1410
1380        <method name="onEnginePopupCommand">   1411        <method name="onEnginePopupCommand">
1381          <parameter name="aEvent"/>   1412          <parameter name="aEvent"/>
1382          <body><![CDATA[   1413          <body><![CDATA[
 
1472 RCS file: browser/locales/en-US/chrome/browser/engineManager.dtd = 1503 RCS file: browser/locales/en-US/chrome/browser/engineManager.dtd
1473 diff -N browser/locales/en-US/chrome/browser/engineManager.dtd   1504 diff -N browser/locales/en-US/chrome/browser/engineManager.dtd
1474 --- /dev/null 1 Jan 1970 00:00:00 -0000   1505 --- /dev/null 1 Jan 1970 00:00:00 -0000
1475 +++ browser/locales/en-US/chrome/browser/engineManager.dtd  20 Apr 2006 05:21:45 -0000   1506 +++ browser/locales/en-US/chrome/browser/engineManager.dtd  26 Apr 2006 20:28:29 -0000
1476 @@ -0,0 +1,17 @@   1507 @@ -0,0 +1,16 @@
1477 +<!ENTITY  engineManager.title       "Manage Search Engine List">   1508 +<!ENTITY  engineManager.title       "Manage Search Engine List">
    <> 1509 +<!ENTITY  engineManager.style       "min-width: 35em;">
1478 +<!ENTITY  engineManager.intro       "The following Search Engines are available:">   1510 +<!ENTITY  engineManager.intro       "You have the following search engines installed:">
1479 + = 1511 +
    -+ 1512 +<!-- Buttons -->
1480 +<!ENTITY  up.label                  "Move Up"> = 1513 +<!ENTITY  up.label                  "Move Up">
1481 +<!ENTITY  up.accesskey              "U">   1514 +<!ENTITY  up.accesskey              "U">
1482 +<!ENTITY  dn.label                  "Move Down">   1515 +<!ENTITY  dn.label                  "Move Down">
1483 +<!ENTITY  dn.accesskey              "D">   1516 +<!ENTITY  dn.accesskey              "D">
1484 +<!ENTITY  delete.label              "Remove"> <> 1517 +<!ENTITY  remove.label              "Remove">
1485 +<!ENTITY  delete.accesskey          "R">   1518 +<!ENTITY  remove.accesskey          "R">
1486 +<!ENTITY  nameColumn.label          "Name">      
1487 +<!ENTITY  aliasColumn.label         "Alias">      
1488 + = 1519 +
1489 +<!ENTITY  editAlias.label           "Edit Alias..."> <> 1520 +<!ENTITY  nameColumn.label          "Name">
1490 +<!ENTITY  editAlias.accesskey       "A">      
1491 + = 1521 +
1492 +<!ENTITY  addEngine.label           "Add Search Engines..."> <> 1522 +<!ENTITY  addEngine.label           "Get more search engines...">
1493 +<!ENTITY  addEngine.accesskey       "A"> = 1523 +<!ENTITY  addEngine.accesskey       "A">
1494 Index: browser/locales/en-US/chrome/browser/search.properties   1524 Index: browser/locales/en-US/chrome/browser/search.properties
1495 ===================================================================   1525 ===================================================================
1496 RCS file: /cvsroot/mozilla/browser/locales/en-US/chrome/browser/search.properties,v   1526 RCS file: /cvsroot/mozilla/browser/locales/en-US/chrome/browser/search.properties,v
1497 retrieving revision 1.1   1527 retrieving revision 1.1
1498 diff -u -p -8 -r1.1 search.properties   1528 diff -u -p -8 -r1.1 search.properties
 
1507 cmd_clearHistory_accesskey=C = 1537 cmd_clearHistory_accesskey=C
1508 -cmd_editList=Edit this list...   1538 -cmd_editList=Edit this list...
1509 -cmd_editListAccesskey=E   1539 -cmd_editListAccesskey=E
1510 +   1540 +
1511 error_loading_engine_title=Download Error   1541 error_loading_engine_title=Download Error
1512 error_loading_engine_msg=%S could not download the search plugin from:\n%S\n\nPlease try again or contact the author.   1542 error_loading_engine_msg=%S could not download the search plugin from:\n%S\n\nPlease try again or contact the author.
1513 + <>    
1514 remove_engine_title=Remove Engine?   1543 -remove_engine_title=Remove Engine?
1515 remove_engine_msg=If you remove '%S' you will not be able to search using it from the Search Box any more. Are you sure you want to remove it?   1544 -remove_engine_msg=If you remove '%S' you will not be able to search using it from the Search Box any more. Are you sure you want to remove it?
1516 -edit_name_title=Edit Name = 1545 -edit_name_title=Edit Name
1517 -edit_name_msg=Enter a new Name:   1546 -edit_name_msg=Enter a new Name:
1518 + <>    
1519 edit_alias_title=Edit Alias   1547 -edit_alias_title=Edit Alias
1520 -edit_alias_msg=Enter a new Alias: = 1548 -edit_alias_msg=Enter a new Alias:
1521 +edit_alias_msg=Enter a new alias: +-    
1522 Index: browser/locales/en-US/chrome/browser/searchbar.dtd = 1549 Index: browser/locales/en-US/chrome/browser/searchbar.dtd
1523 ===================================================================   1550 ===================================================================
1524 RCS file: browser/locales/en-US/chrome/browser/searchbar.dtd   1551 RCS file: browser/locales/en-US/chrome/browser/searchbar.dtd
1525 diff -N browser/locales/en-US/chrome/browser/searchbar.dtd   1552 diff -N browser/locales/en-US/chrome/browser/searchbar.dtd
1526 --- /dev/null 1 Jan 1970 00:00:00 -0000   1553 --- /dev/null 1 Jan 1970 00:00:00 -0000
1527 +++ browser/locales/en-US/chrome/browser/searchbar.dtd  20 Apr 2006 05:21:45 -0000   1554 +++ browser/locales/en-US/chrome/browser/searchbar.dtd  26 Apr 2006 20:28:29 -0000
1528 @@ -0,0 +1,2 @@   1555 @@ -0,0 +1,2 @@
1529 +<!ENTITY cmd_engineManager.label        "Manage search engines...">   1556 +<!ENTITY cmd_engineManager.label        "Manage Search Engines...">
1530 +<!ENTITY cmd_engineManager.accesskey    "M">   1557 +<!ENTITY cmd_engineManager.accesskey    "M">