Bug 532444 - Create search engine cache in BrowserCLH.js [r=gavin.sharp]
authorMark Finkle <mfinkle@mozilla.com>
Fri, 04 Dec 2009 16:02:38 -0500
changeset 1202 fae38ea6ab0ed91bd76e7a4b55f0eaf39ecdd417
parent 1201 339f988d5d9bfe312b1c0179f51cf5128ee72222
child 1203 b7972754e94def5c745f54e96fd0cdb748d8e62a
push id1066
push usermfinkle@mozilla.com
push dateFri, 04 Dec 2009 21:06:35 +0000
reviewersgavin
bugs532444
Bug 532444 - Create search engine cache in BrowserCLH.js [r=gavin.sharp]
components/BrowserCLH.js
components/BrowserStartup.js
--- a/components/BrowserCLH.js
+++ b/components/BrowserCLH.js
@@ -45,16 +45,27 @@ Cu.import("resource://gre/modules/XPCOMU
 
 function BrowserCLH() { }
 
 BrowserCLH.prototype = {
   //
   // nsICommandLineHandler
   //
   handle: function fs_handle(cmdLine) {
+    // Instantiate the search service so the search engine cache is created now
+    // instead when the application is running. The install process will register
+    // this component by using the -silent command line flag, thereby creating
+    // the cache during install, not runtime.
+    // NOTE: This code assumes this CLH is run before the nsDefaultCLH, which
+    // consumes the "-silent" flag.
+    if (cmdLine.findFlag("silent", false) > -1) {
+      let searchService = Cc["@mozilla.org/browser/search-service;1"].
+                          getService(Ci.nsIBrowserSearchService);
+    }
+
     let win;
     try {
       var windowMediator =
         Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator);
 
       win = windowMediator.getMostRecentWindow("navigator:browser");
       if (!win)
         return;
--- a/components/BrowserStartup.js
+++ b/components/BrowserStartup.js
@@ -64,17 +64,17 @@ BrowserStartup.prototype = {
   _xpcom_categories: [
     // make BrowserStartup a startup observer
     { category: "app-startup", service: true }
   ],
 
   _xpcom_factory: BrowserStartupServiceFactory,
 
   _init: function () {
-    this._observerService = Cc['@mozilla.org/observer-service;1'].
+    this._observerService = Cc["@mozilla.org/observer-service;1"].
                             getService(Ci.nsIObserverService);
     this._observerService.addObserver(this, "places-init-complete", false);
   },
 
   _initDefaultBookmarks: function () {
     // We must instantiate the history service since it will tell us if we
     // need to import or restore bookmarks due to first-run, corruption or
     // forced migration (due to a major schema change).