home *** CD-ROM | disk | FTP | other *** search
- // Copyright 2006 and onwards, Google
- // Author: Aaron Boodman
- // Stolen and modified by: Fritz Schneider
- //
- // We run our application in a separate context from the browser. Our
- // app gets its own context by virtue of the fact that it is an XPCOM
- // component. Glue code in the overlay will call into our component
- // to interact with the app.
- //
- // This file implements a loader for our component. It takes a list of
- // js files and dynamically loads them into this context. It then
- // registers to hear xpcom startup, at which point it instantiates our
- // application in this context. This context is exposed to overlay
- // code via a property of the object returned when you get the service
- // from contract @google.com/toolbar/application;1.
- //
- // Lots of JS and XPCOM voodoo going on here; tread lightly unless you
- // understand it.
- //
- // TODO: delete category entry for startup on shutdown?
-
- const Cc = Components.classes;
- const Ci = Components.interfaces;
- const Cr = Components.results;
-
- // Load our component JS file.
- Cc["@mozilla.org/moz/jssubscript-loader;1"]
- .getService(Ci.mozIJSSubScriptLoader)
- .loadSubScript(getLibFile("lib/toolbar.js"));
-
- // Load Google domain information
- Cc["@mozilla.org/moz/jssubscript-loader;1"]
- .getService(Ci.mozIJSSubScriptLoader)
- .loadSubScript("chrome://google-toolbar/locale/domains.js");
-
- // Now we can make our js module
- var GTB_module = new G_JSModule();
-
- // Register the application.
- GTB_module.registerObject("{66f4ea38-ca54-4c81-b145-858a27aea21b}",
- "@google.com/toolbar/application;1",
- "GTB_Context",
- new GTB_Application(),
- ["xpcom-startup"]);
- var localeFeatureListService = new GTB_LocaleFeatureListService();
- GTB_module.registerObject("{42495560-aa41-11db-abbd-0800200c9a66}",
- "@google.com/toolbar/locale-features-list-service;1",
- "Google Toolbar Locale Features List Service",
- localeFeatureListService);
- GTB_module.registerObject("{71631a52-b676-4628-8831-f777932b82ec}",
- "@mozilla.org/autocomplete/search;1?name=google-search-suggest",
- "Google Search Suggest",
- new SearchSuggestAutoComplete());
- GTB_module.registerObject("{0706d4a9-df9a-4d57-9b5f-c2c050006db8}",
- "@google.com/toolbar/search-history;1",
- "Google Toolbar Search History",
- new GTB_SearchHistoryService());
- GTB_module.registerObject("{2897397f-ba06-4563-b32e-0003c360bcf6}",
- "@google.com/toolbar/search-types;1",
- "Google Toolbar Search Types",
- new GTB_SearchTypeService());
- GTB_module.registerObject("{2de1131b-01de-42e8-99d3-4b34654e491f}",
- "@google.com/toolbar/gaia-service;1",
- "Google Toolbar Gaia Service",
- new GTB_GaiaService());
- GTB_module.registerObject("{dbb5b4b6-1094-4160-8c77-5df04583f420}",
- "@google.com/toolbar/bookmarks;1",
- "Google Toolbar Server Bookmarks",
- new GTB_BookmarksService());
- GTB_module.registerObject("{2f2f5706-4145-437e-9959-a0f3072bd1af}",
- "@mozilla.org/autocomplete/search;1?name=bookmark-labels-suggest",
- "Google Toolbar Bookmark Label Suggest",
- new LabelAutoComplete());
- GTB_module.registerObject("{caf13f42-59e6-4d0e-abd0-8d0587c7e320}",
- "@mozilla.org/network/protocol;1?name=mailto",
- "Google Mail Protocol",
- new GTB_MailtoProtocolHandler());
- GTB_module.registerObject("{af2bee5f-bb24-53e0-f922-5288ed0180fe}",
- "@google.com/toolbar/custom-buttons-service;1",
- "Google Toolbar Custom Buttons Service",
- new GTB_CustomButtonsService());
- GTB_module.registerObject("{cc743e19-174c-4a61-a376-ce30f3c67112}",
- "@google.com/toolbar/cb-submithelper;1",
- "Google Toolbar Submit Helper Service",
- new GTB_CB_SubmitHelperService());
- GTB_module.registerObject("{80ed2c93-2340-41c3-84c9-b496c978fad1}",
- "@google.com/toolbar/pagerank-progress;1",
- "Google Toolbar PageRank Web Progress",
- new GTB_PageRankWebProgress());
- GTB_module.registerObject("{f1d3ee04-9baa-4f2b-96ed-23cd17f8a96f}",
- "@google.com/toolbar/search-service;1",
- "Google Toolbar Search Service",
- new GTB_SearchService());
- var chPrefs = new GTB_ContentPrefsService();
- GTB_module.registerObject("{034f1b81-d347-4485-ad25-a75ac5fa9017}",
- "@google.com/toolbar/content-prefs;1",
- "Google Toolbar Content Prefs Helper",
- chPrefs);
- for (var t in chPrefs.fileTypes) {
- for (var i = 0; i < chPrefs.fileTypes[t].mime.length; i++) {
- GTB_module.registerObject(chPrefs.fileTypes[t].uuid,
- "@mozilla.org/uriloader/content-handler;1?type=" +
- chPrefs.fileTypes[t].mime[i],
- "Google Toolbar " + chPrefs.fileTypes[t].mime,
- new GTB_MimeTypeHandler(chPrefs.fileTypes[t].mime,
- t,
- "{HOST}?action=updoc&formsubmitted=true&client=navclient-ff&uploadURL={URL}",
- localeFeatureListService));
- }
- }
- GTB_module.registerObject("{251e6f99-12c3-4935-8f22-75832f87baf9}",
- "@google.com/toolbar/command-line-handler;1",
- "Google Toolbar Command Line Handler",
- new GTB_CommandLineHandler());
-
- // Register the command line handler
- var catMgr = Cc["@mozilla.org/categorymanager;1"]
- .getService(Ci.nsICategoryManager);
-
- catMgr.addCategoryEntry("command-line-handler",
- "m-googletoolbar", // priority(a-z)-name
- "@google.com/toolbar/command-line-handler;1",
- true, true);
-
- // For the "content-policy" topic, the name for the category entry must be
- // the contract ID of the component.
- // http://www.opensubscriber.com/message/mozilla-xpcom@mozilla.org/924255.html
- GTB_module.registerObject("{f4c526c9-d4e9-a521-0f7c-eef1e979e811}",
- "@google.com/toolbar/custom-buttons-urlchecker;1",
- "@google.com/toolbar/custom-buttons-urlchecker;1",
- new GTB_CB_UrlChecker(),
- ["content-policy"]);
- GTB_module.registerObject("{33f776e5-004d-4f25-a24b-e60d93251058}",
- "@google.com/toolbar/web-progress-listener;1",
- "Google Toolbar WebProgressListener",
- new GTB_WebProgress());
- function NSGetModule() {
- return GTB_module;
- }
-
- /**
- * Gets a file:// URL for the given physical path relative to the libs/
- * folder.
- */
- function getLibFile(path) {
- var file = __LOCATION__.clone().parent.parent;
- var parts = path.split("/");
-
- for (var i = 0, part; part = parts[i]; i++)
- file.append(part);
-
- if (!file.exists())
- throw new Error("Specified library {" + file.path + "} does not exist");
-
- return Cc["@mozilla.org/network/protocol;1?name=file"]
- .getService(Ci.nsIFileProtocolHandler)
- .getURLSpecFromFile(file);
- };
-