michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* Copyright 2012 Mozilla Foundation and Mozilla contributors michael@0: * michael@0: * Licensed under the Apache License, Version 2.0 (the "License"); michael@0: * you may not use this file except in compliance with the License. michael@0: * You may obtain a copy of the License at michael@0: * michael@0: * http://www.apache.org/licenses/LICENSE-2.0 michael@0: * michael@0: * Unless required by applicable law or agreed to in writing, software michael@0: * distributed under the License is distributed on an "AS IS" BASIS, michael@0: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. michael@0: * See the License for the specific language governing permissions and michael@0: * limitations under the License. michael@0: */ michael@0: michael@0: #include "base/basictypes.h" michael@0: michael@0: #include "mozilla/ModuleUtils.h" michael@0: michael@0: #include "nsCOMPtr.h" michael@0: #include "nsWidgetsCID.h" michael@0: #include "nsAppShell.h" michael@0: michael@0: #include "nsWindow.h" michael@0: #include "nsLookAndFeel.h" michael@0: #include "nsAppShellSingleton.h" michael@0: #include "nsScreenManagerGonk.h" michael@0: #include "nsIdleServiceGonk.h" michael@0: #include "nsTransferable.h" michael@0: #include "nsClipboard.h" michael@0: #include "nsClipboardHelper.h" michael@0: michael@0: #include "nsHTMLFormatConverter.h" michael@0: #include "nsXULAppAPI.h" michael@0: michael@0: #include "PuppetWidget.h" michael@0: michael@0: using namespace mozilla::widget; michael@0: michael@0: // taken from android/nsWidgetFactory.cpp. GfxInfo is a legacy kludge, unfortunately michael@0: // for the time being we still have to implement it on all platforms. michael@0: #include "GfxInfo.h" michael@0: namespace mozilla { michael@0: namespace widget { michael@0: // This constructor should really be shared with all platforms. michael@0: NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(GfxInfo, Init) michael@0: } michael@0: } michael@0: michael@0: NS_GENERIC_FACTORY_CONSTRUCTOR(nsWindow) michael@0: NS_GENERIC_FACTORY_CONSTRUCTOR(nsScreenManagerGonk) michael@0: NS_GENERIC_FACTORY_CONSTRUCTOR(PuppetScreenManager) michael@0: NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTMLFormatConverter) michael@0: NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsIdleServiceGonk, nsIdleServiceGonk::GetInstance) michael@0: NS_GENERIC_FACTORY_CONSTRUCTOR(nsTransferable) michael@0: NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboard) michael@0: NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboardHelper) michael@0: michael@0: NS_DEFINE_NAMED_CID(NS_APPSHELL_CID); michael@0: NS_DEFINE_NAMED_CID(NS_WINDOW_CID); michael@0: NS_DEFINE_NAMED_CID(NS_CHILD_CID); michael@0: NS_DEFINE_NAMED_CID(NS_SCREENMANAGER_CID); michael@0: NS_DEFINE_NAMED_CID(NS_HTMLFORMATCONVERTER_CID); michael@0: NS_DEFINE_NAMED_CID(NS_IDLE_SERVICE_CID); michael@0: NS_DEFINE_NAMED_CID(NS_TRANSFERABLE_CID); michael@0: NS_DEFINE_NAMED_CID(NS_GFXINFO_CID); michael@0: NS_DEFINE_NAMED_CID(NS_CLIPBOARD_CID); michael@0: NS_DEFINE_NAMED_CID(NS_CLIPBOARDHELPER_CID); michael@0: michael@0: static nsresult michael@0: ScreenManagerConstructor(nsISupports *aOuter, REFNSIID aIID, void **aResult) michael@0: { michael@0: return (XRE_GetProcessType() == GeckoProcessType_Default) ? michael@0: nsScreenManagerGonkConstructor(aOuter, aIID, aResult) : michael@0: PuppetScreenManagerConstructor(aOuter, aIID, aResult); michael@0: } michael@0: michael@0: static const mozilla::Module::CIDEntry kWidgetCIDs[] = { michael@0: { &kNS_WINDOW_CID, false, nullptr, nsWindowConstructor }, michael@0: { &kNS_CHILD_CID, false, nullptr, nsWindowConstructor }, michael@0: { &kNS_APPSHELL_CID, false, nullptr, nsAppShellConstructor }, michael@0: { &kNS_SCREENMANAGER_CID, false, nullptr, ScreenManagerConstructor }, michael@0: { &kNS_HTMLFORMATCONVERTER_CID, false, nullptr, nsHTMLFormatConverterConstructor }, michael@0: { &kNS_IDLE_SERVICE_CID, false, nullptr, nsIdleServiceGonkConstructor }, michael@0: { &kNS_TRANSFERABLE_CID, false, nullptr, nsTransferableConstructor }, michael@0: { &kNS_GFXINFO_CID, false, nullptr, mozilla::widget::GfxInfoConstructor }, michael@0: { &kNS_CLIPBOARD_CID, false, nullptr, nsClipboardConstructor }, michael@0: { &kNS_CLIPBOARDHELPER_CID, false, nullptr, nsClipboardHelperConstructor }, michael@0: { nullptr } michael@0: }; michael@0: michael@0: static const mozilla::Module::ContractIDEntry kWidgetContracts[] = { michael@0: { "@mozilla.org/widgets/window/gonk;1", &kNS_WINDOW_CID }, michael@0: { "@mozilla.org/widgets/child_window/gonk;1", &kNS_CHILD_CID }, michael@0: { "@mozilla.org/widget/appshell/gonk;1", &kNS_APPSHELL_CID }, michael@0: { "@mozilla.org/gfx/screenmanager;1", &kNS_SCREENMANAGER_CID }, michael@0: { "@mozilla.org/widget/htmlformatconverter;1", &kNS_HTMLFORMATCONVERTER_CID }, michael@0: { "@mozilla.org/widget/idleservice;1", &kNS_IDLE_SERVICE_CID }, michael@0: { "@mozilla.org/widget/transferable;1", &kNS_TRANSFERABLE_CID }, michael@0: { "@mozilla.org/gfx/info;1", &kNS_GFXINFO_CID }, michael@0: { "@mozilla.org/widget/clipboard;1", &kNS_CLIPBOARD_CID }, michael@0: { "@mozilla.org/widget/clipboardhelper;1", &kNS_CLIPBOARDHELPER_CID }, michael@0: { nullptr } michael@0: }; michael@0: michael@0: static void michael@0: nsWidgetGonkModuleDtor() michael@0: { michael@0: nsLookAndFeel::Shutdown(); michael@0: nsAppShellShutdown(); michael@0: } michael@0: michael@0: static const mozilla::Module kWidgetModule = { michael@0: mozilla::Module::kVersion, michael@0: kWidgetCIDs, michael@0: kWidgetContracts, michael@0: nullptr, michael@0: nullptr, michael@0: nsAppShellInit, michael@0: nsWidgetGonkModuleDtor michael@0: }; michael@0: michael@0: NSMODULE_DEFN(nsWidgetGonkModule) = &kWidgetModule;