Back to index

lightning-sunbird  0.9+nobinonly
nsDebugFactory.cpp
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is mozilla.org code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either the GNU General Public License Version 2 or later (the "GPL"), or
00026  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 
00038 #include "nscore.h"
00039 #include "nsLayoutDebugCIID.h"
00040 #include "nsIFactory.h"
00041 #include "nsISupports.h"
00042 #include "nsRegressionTester.h"
00043 #include "nsLayoutDebuggingTools.h"
00044 #include "nsLayoutDebugCLH.h"
00045 #include "nsIGenericFactory.h"
00046 #include "nsICategoryManager.h"
00047 #include "nsIServiceManager.h"
00048 
00049 NS_GENERIC_FACTORY_CONSTRUCTOR(nsRegressionTester)
00050 NS_GENERIC_FACTORY_CONSTRUCTOR(nsLayoutDebuggingTools)
00051 NS_GENERIC_FACTORY_CONSTRUCTOR(nsLayoutDebugCLH)
00052 
00053 #ifdef MOZ_XUL_APP
00054 
00055 static NS_IMETHODIMP
00056 RegisterCommandLineHandlers(nsIComponentManager* compMgr, nsIFile* path,
00057                             const char *location, const char *type,
00058                             const nsModuleComponentInfo *info)
00059 {
00060   nsresult rv;
00061   nsCOMPtr<nsICategoryManager> catMan (do_GetService(NS_CATEGORYMANAGER_CONTRACTID));
00062   NS_ENSURE_TRUE(catMan, NS_ERROR_FAILURE);
00063 
00064   rv = catMan->AddCategoryEntry("command-line-handler", "m-layoutdebug",
00065                                 "@mozilla.org/commandlinehandler/general-startup;1?type=layoutdebug",
00066                                 PR_TRUE, PR_TRUE, nsnull);
00067   if (NS_FAILED(rv))
00068     return NS_ERROR_FAILURE;
00069 
00070   return NS_OK;
00071 }
00072 
00073 static NS_IMETHODIMP
00074 UnregisterCommandLineHandlers(nsIComponentManager* compMgr, nsIFile *path,
00075                               const char *location,
00076                               const nsModuleComponentInfo *info)
00077 {
00078   nsCOMPtr<nsICategoryManager> catMan (do_GetService(NS_CATEGORYMANAGER_CONTRACTID));
00079   NS_ENSURE_TRUE(catMan, NS_ERROR_FAILURE);
00080 
00081   catMan->DeleteCategoryEntry("command-line-handler", "m-layoutdebug",
00082                               PR_TRUE);
00083 
00084   return NS_OK;
00085 }
00086 
00087 #endif
00088 
00089 static const nsModuleComponentInfo components[] =
00090 {
00091   { "nsRegressionTester",
00092     NS_REGRESSION_TESTER_CID,
00093     "@mozilla.org/layout-debug/regressiontester;1",
00094     nsRegressionTesterConstructor 
00095   },
00096   { "nsLayoutDebuggingTools",
00097     NS_LAYOUT_DEBUGGINGTOOLS_CID,
00098     NS_LAYOUT_DEBUGGINGTOOLS_CONTRACTID,
00099     nsLayoutDebuggingToolsConstructor
00100   },
00101   { "LayoutDebug Startup Handler",
00102     NS_LAYOUTDEBUGCLH_CID,
00103     "@mozilla.org/commandlinehandler/general-startup;1?type=layoutdebug",
00104     nsLayoutDebugCLHConstructor,
00105 #ifdef MOZ_XUL_APP
00106     RegisterCommandLineHandlers,
00107     UnregisterCommandLineHandlers
00108 #else
00109     nsLayoutDebugCLH::RegisterProc,
00110     nsLayoutDebugCLH::UnregisterProc
00111 #endif
00112   }
00113 };
00114 
00115 NS_IMPL_NSGETMODULE(nsLayoutDebugModule, components)