1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include "nsISupports.h"
7 #include "mozilla/Components.h"
8 #include "mozilla/ModuleUtils.h"
9 #include "mozilla/WidgetUtils.h"
11 #include "nsWidgetsCID.h"
13 #include "nsChildView.h"
14 #include "nsAppShell.h"
15 #include "nsAppShellSingleton.h"
16 #include "nsFilePicker.h"
17 #include "nsColorPicker.h"
19 #include "nsClipboard.h"
20 #include "nsClipboardHelper.h"
21 #include "HeadlessClipboard.h"
22 #include "gfxPlatform.h"
23 #include "nsTransferable.h"
24 #include "nsHTMLFormatConverter.h"
25 #include "nsDragService.h"
26 #include "nsToolkit.h"
28 #include "nsLookAndFeel.h"
31 #include "nsUserIdleServiceX.h"
32 #include "NativeKeyBindings.h"
33 #include "OSXNotificationCenter.h"
35 #include "nsDeviceContextSpecX.h"
36 #include "nsPrinterListCUPS.h"
37 #include "nsPrintSettingsServiceX.h"
38 #include "nsPrintDialogX.h"
39 #include "nsPrintSession.h"
40 #include "nsToolkitCompsCID.h"
42 #include "mozilla/widget/ScreenManager.h"
44 using namespace mozilla;
45 using namespace mozilla::widget;
47 NS_IMPL_COMPONENT_FACTORY(nsIClipboard) {
48 nsCOMPtr<nsIClipboard> inst;
49 if (gfxPlatform::IsHeadless()) {
50 inst = new HeadlessClipboard();
52 inst = new nsClipboard();
58 NS_GENERIC_FACTORY_CONSTRUCTOR(nsFilePicker)
59 NS_GENERIC_FACTORY_CONSTRUCTOR(nsColorPicker)
60 NS_GENERIC_FACTORY_CONSTRUCTOR(nsSound)
61 NS_GENERIC_FACTORY_CONSTRUCTOR(nsTransferable)
62 NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTMLFormatConverter)
63 NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboardHelper)
64 NS_GENERIC_FACTORY_CONSTRUCTOR(nsDragService)
65 NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecX)
66 NS_GENERIC_FACTORY_CONSTRUCTOR(nsPrinterListCUPS)
67 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintSettingsServiceX, Init)
68 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintDialogServiceX, Init)
69 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintSession, Init)
70 NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsUserIdleServiceX, nsUserIdleServiceX::GetInstance)
71 NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(ScreenManager, ScreenManager::GetAddRefedSingleton)
72 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(OSXNotificationCenter, Init)
74 #include "nsMacDockSupport.h"
75 NS_GENERIC_FACTORY_CONSTRUCTOR(nsMacDockSupport)
77 #include "nsMacFinderProgress.h"
78 NS_GENERIC_FACTORY_CONSTRUCTOR(nsMacFinderProgress)
80 #include "nsMacSharingService.h"
81 NS_GENERIC_FACTORY_CONSTRUCTOR(nsMacSharingService)
83 #include "nsMacWebAppUtils.h"
84 NS_GENERIC_FACTORY_CONSTRUCTOR(nsMacWebAppUtils)
86 #include "nsStandaloneNativeMenu.h"
87 NS_GENERIC_FACTORY_CONSTRUCTOR(nsStandaloneNativeMenu)
89 #include "nsSystemStatusBarCocoa.h"
90 NS_GENERIC_FACTORY_CONSTRUCTOR(nsSystemStatusBarCocoa)
92 #include "nsTouchBarUpdater.h"
93 NS_GENERIC_FACTORY_CONSTRUCTOR(nsTouchBarUpdater)
95 NS_DEFINE_NAMED_CID(NS_FILEPICKER_CID);
96 NS_DEFINE_NAMED_CID(NS_COLORPICKER_CID);
97 NS_DEFINE_NAMED_CID(NS_APPSHELL_CID);
98 NS_DEFINE_NAMED_CID(NS_SOUND_CID);
99 NS_DEFINE_NAMED_CID(NS_TRANSFERABLE_CID);
100 NS_DEFINE_NAMED_CID(NS_HTMLFORMATCONVERTER_CID);
101 NS_DEFINE_NAMED_CID(NS_CLIPBOARDHELPER_CID);
102 NS_DEFINE_NAMED_CID(NS_DRAGSERVICE_CID);
103 NS_DEFINE_NAMED_CID(NS_SCREENMANAGER_CID);
104 NS_DEFINE_NAMED_CID(NS_DEVICE_CONTEXT_SPEC_CID);
105 NS_DEFINE_NAMED_CID(NS_PRINTER_LIST_CID);
106 NS_DEFINE_NAMED_CID(NS_PRINTSESSION_CID);
107 NS_DEFINE_NAMED_CID(NS_PRINTSETTINGSSERVICE_CID);
108 NS_DEFINE_NAMED_CID(NS_PRINTDIALOGSERVICE_CID);
109 NS_DEFINE_NAMED_CID(NS_IDLE_SERVICE_CID);
110 NS_DEFINE_NAMED_CID(NS_SYSTEMALERTSSERVICE_CID);
111 NS_DEFINE_NAMED_CID(NS_MACDOCKSUPPORT_CID);
112 NS_DEFINE_NAMED_CID(NS_MACFINDERPROGRESS_CID);
113 NS_DEFINE_NAMED_CID(NS_MACSHARINGSERVICE_CID);
114 NS_DEFINE_NAMED_CID(NS_MACWEBAPPUTILS_CID);
115 NS_DEFINE_NAMED_CID(NS_STANDALONENATIVEMENU_CID);
116 NS_DEFINE_NAMED_CID(NS_SYSTEMSTATUSBAR_CID);
117 NS_DEFINE_NAMED_CID(NS_TOUCHBARUPDATER_CID);
119 static const mozilla::Module::CIDEntry kWidgetCIDs[] = {
120 {&kNS_FILEPICKER_CID, false, NULL, nsFilePickerConstructor, mozilla::Module::MAIN_PROCESS_ONLY},
121 {&kNS_COLORPICKER_CID, false, NULL, nsColorPickerConstructor,
122 mozilla::Module::MAIN_PROCESS_ONLY},
123 {&kNS_APPSHELL_CID, false, NULL, nsAppShellConstructor,
124 mozilla::Module::ALLOW_IN_GPU_RDD_VR_AND_SOCKET_PROCESS},
125 {&kNS_SOUND_CID, false, NULL, nsSoundConstructor, mozilla::Module::MAIN_PROCESS_ONLY},
126 {&kNS_TRANSFERABLE_CID, false, NULL, nsTransferableConstructor},
127 {&kNS_HTMLFORMATCONVERTER_CID, false, NULL, nsHTMLFormatConverterConstructor},
128 {&kNS_CLIPBOARDHELPER_CID, false, NULL, nsClipboardHelperConstructor},
129 {&kNS_DRAGSERVICE_CID, false, NULL, nsDragServiceConstructor,
130 mozilla::Module::MAIN_PROCESS_ONLY},
131 {&kNS_SCREENMANAGER_CID, false, NULL, ScreenManagerConstructor,
132 mozilla::Module::MAIN_PROCESS_ONLY},
133 {&kNS_DEVICE_CONTEXT_SPEC_CID, false, NULL, nsDeviceContextSpecXConstructor},
134 {&kNS_PRINTER_LIST_CID, false, NULL, nsPrinterListCUPSConstructor,
135 mozilla::Module::MAIN_PROCESS_ONLY},
136 {&kNS_PRINTSESSION_CID, false, NULL, nsPrintSessionConstructor},
137 {&kNS_PRINTSETTINGSSERVICE_CID, false, NULL, nsPrintSettingsServiceXConstructor},
138 {&kNS_PRINTDIALOGSERVICE_CID, false, NULL, nsPrintDialogServiceXConstructor},
139 {&kNS_IDLE_SERVICE_CID, false, NULL, nsUserIdleServiceXConstructor},
140 {&kNS_SYSTEMALERTSSERVICE_CID, false, NULL, OSXNotificationCenterConstructor},
141 {&kNS_MACDOCKSUPPORT_CID, false, NULL, nsMacDockSupportConstructor},
142 {&kNS_MACFINDERPROGRESS_CID, false, NULL, nsMacFinderProgressConstructor},
143 {&kNS_MACSHARINGSERVICE_CID, false, NULL, nsMacSharingServiceConstructor},
144 {&kNS_MACWEBAPPUTILS_CID, false, NULL, nsMacWebAppUtilsConstructor},
145 {&kNS_STANDALONENATIVEMENU_CID, false, NULL, nsStandaloneNativeMenuConstructor},
146 {&kNS_SYSTEMSTATUSBAR_CID, false, NULL, nsSystemStatusBarCocoaConstructor},
147 {&kNS_TOUCHBARUPDATER_CID, false, NULL, nsTouchBarUpdaterConstructor},
150 static const mozilla::Module::ContractIDEntry kWidgetContracts[] = {
151 {"@mozilla.org/filepicker;1", &kNS_FILEPICKER_CID, mozilla::Module::MAIN_PROCESS_ONLY},
152 {"@mozilla.org/colorpicker;1", &kNS_COLORPICKER_CID, mozilla::Module::MAIN_PROCESS_ONLY},
153 {"@mozilla.org/widget/appshell/mac;1", &kNS_APPSHELL_CID,
154 mozilla::Module::ALLOW_IN_GPU_RDD_VR_AND_SOCKET_PROCESS},
155 {"@mozilla.org/sound;1", &kNS_SOUND_CID, mozilla::Module::MAIN_PROCESS_ONLY},
156 {"@mozilla.org/widget/transferable;1", &kNS_TRANSFERABLE_CID},
157 {"@mozilla.org/widget/htmlformatconverter;1", &kNS_HTMLFORMATCONVERTER_CID},
158 {"@mozilla.org/widget/clipboardhelper;1", &kNS_CLIPBOARDHELPER_CID},
159 {"@mozilla.org/widget/dragservice;1", &kNS_DRAGSERVICE_CID, mozilla::Module::MAIN_PROCESS_ONLY},
160 {"@mozilla.org/gfx/screenmanager;1", &kNS_SCREENMANAGER_CID,
161 mozilla::Module::MAIN_PROCESS_ONLY},
162 {"@mozilla.org/gfx/devicecontextspec;1", &kNS_DEVICE_CONTEXT_SPEC_CID},
163 {"@mozilla.org/gfx/printerlist;1", &kNS_PRINTER_LIST_CID, mozilla::Module::MAIN_PROCESS_ONLY},
164 {"@mozilla.org/gfx/printsession;1", &kNS_PRINTSESSION_CID},
165 {"@mozilla.org/gfx/printsettings-service;1", &kNS_PRINTSETTINGSSERVICE_CID},
166 {NS_PRINTDIALOGSERVICE_CONTRACTID, &kNS_PRINTDIALOGSERVICE_CID},
167 {"@mozilla.org/widget/useridleservice;1", &kNS_IDLE_SERVICE_CID},
168 {"@mozilla.org/system-alerts-service;1", &kNS_SYSTEMALERTSSERVICE_CID},
169 {"@mozilla.org/widget/macdocksupport;1", &kNS_MACDOCKSUPPORT_CID},
170 {"@mozilla.org/widget/macfinderprogress;1", &kNS_MACFINDERPROGRESS_CID},
171 {"@mozilla.org/widget/macsharingservice;1", &kNS_MACSHARINGSERVICE_CID},
172 {"@mozilla.org/widget/mac-web-app-utils;1", &kNS_MACWEBAPPUTILS_CID},
173 {"@mozilla.org/widget/standalonenativemenu;1", &kNS_STANDALONENATIVEMENU_CID},
174 {"@mozilla.org/widget/systemstatusbar;1", &kNS_SYSTEMSTATUSBAR_CID},
175 {"@mozilla.org/widget/touchbarupdater;1", &kNS_TOUCHBARUPDATER_CID},
178 static void nsWidgetCocoaModuleDtor() {
179 // Shutdown all XP level widget classes.
180 WidgetUtils::Shutdown();
182 NativeKeyBindings::Shutdown();
183 nsLookAndFeel::Shutdown();
184 nsToolkit::Shutdown();
185 nsAppShellShutdown();
188 extern const mozilla::Module kWidgetModule = {
189 mozilla::Module::kVersion,
195 nsWidgetCocoaModuleDtor,
196 mozilla::Module::ALLOW_IN_GPU_RDD_VR_AND_SOCKET_PROCESS};