widget/cocoa/nsWidgetFactory.mm

Thu, 15 Jan 2015 15:59:08 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:59:08 +0100
branch
TOR_BUG_9701
changeset 10
ac0c01689b40
permissions
-rw-r--r--

Implement a real Private Browsing Mode condition by changing the API/ABI;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

michael@0 1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #include "nsIFactory.h"
michael@0 7 #include "nsISupports.h"
michael@0 8 #include "nsIComponentManager.h"
michael@0 9 #include "mozilla/ModuleUtils.h"
michael@0 10
michael@0 11 #include "nsWidgetsCID.h"
michael@0 12
michael@0 13 #include "nsChildView.h"
michael@0 14 #include "nsCocoaWindow.h"
michael@0 15 #include "nsAppShell.h"
michael@0 16 #include "nsAppShellSingleton.h"
michael@0 17 #include "nsFilePicker.h"
michael@0 18 #include "nsColorPicker.h"
michael@0 19
michael@0 20 #include "nsClipboard.h"
michael@0 21 #include "nsClipboardHelper.h"
michael@0 22 #include "nsTransferable.h"
michael@0 23 #include "nsHTMLFormatConverter.h"
michael@0 24 #include "nsDragService.h"
michael@0 25 #include "nsToolkit.h"
michael@0 26
michael@0 27 #include "nsLookAndFeel.h"
michael@0 28
michael@0 29 #include "nsSound.h"
michael@0 30 #include "nsIdleServiceX.h"
michael@0 31 #include "NativeKeyBindings.h"
michael@0 32 #include "OSXNotificationCenter.h"
michael@0 33
michael@0 34 #include "nsScreenManagerCocoa.h"
michael@0 35 #include "nsDeviceContextSpecX.h"
michael@0 36 #include "nsPrintOptionsX.h"
michael@0 37 #include "nsPrintDialogX.h"
michael@0 38 #include "nsPrintSession.h"
michael@0 39 #include "nsToolkitCompsCID.h"
michael@0 40
michael@0 41 #include "mozilla/Module.h"
michael@0 42
michael@0 43 using namespace mozilla;
michael@0 44 using namespace mozilla::widget;
michael@0 45
michael@0 46 NS_GENERIC_FACTORY_CONSTRUCTOR(nsCocoaWindow)
michael@0 47 NS_GENERIC_FACTORY_CONSTRUCTOR(nsChildView)
michael@0 48 NS_GENERIC_FACTORY_CONSTRUCTOR(nsFilePicker)
michael@0 49 NS_GENERIC_FACTORY_CONSTRUCTOR(nsColorPicker)
michael@0 50 NS_GENERIC_FACTORY_CONSTRUCTOR(nsSound)
michael@0 51 NS_GENERIC_FACTORY_CONSTRUCTOR(nsTransferable)
michael@0 52 NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTMLFormatConverter)
michael@0 53 NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboard)
michael@0 54 NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboardHelper)
michael@0 55 NS_GENERIC_FACTORY_CONSTRUCTOR(nsDragService)
michael@0 56 NS_GENERIC_FACTORY_CONSTRUCTOR(nsScreenManagerCocoa)
michael@0 57 NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecX)
michael@0 58 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintOptionsX, Init)
michael@0 59 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintDialogServiceX, Init)
michael@0 60 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintSession, Init)
michael@0 61 NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsIdleServiceX, nsIdleServiceX::GetInstance)
michael@0 62 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(OSXNotificationCenter, Init)
michael@0 63
michael@0 64 #include "nsMenuBarX.h"
michael@0 65 NS_GENERIC_FACTORY_CONSTRUCTOR(nsNativeMenuServiceX)
michael@0 66
michael@0 67 #include "nsBidiKeyboard.h"
michael@0 68 NS_GENERIC_FACTORY_CONSTRUCTOR(nsBidiKeyboard)
michael@0 69
michael@0 70 #include "nsNativeThemeCocoa.h"
michael@0 71 NS_GENERIC_FACTORY_CONSTRUCTOR(nsNativeThemeCocoa)
michael@0 72
michael@0 73 #include "nsMacDockSupport.h"
michael@0 74 NS_GENERIC_FACTORY_CONSTRUCTOR(nsMacDockSupport)
michael@0 75
michael@0 76 #include "nsMacWebAppUtils.h"
michael@0 77 NS_GENERIC_FACTORY_CONSTRUCTOR(nsMacWebAppUtils)
michael@0 78
michael@0 79 #include "nsStandaloneNativeMenu.h"
michael@0 80 NS_GENERIC_FACTORY_CONSTRUCTOR(nsStandaloneNativeMenu)
michael@0 81
michael@0 82 #include "GfxInfo.h"
michael@0 83 namespace mozilla {
michael@0 84 namespace widget {
michael@0 85 // This constructor should really be shared with all platforms.
michael@0 86 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(GfxInfo, Init)
michael@0 87 }
michael@0 88 }
michael@0 89
michael@0 90 NS_DEFINE_NAMED_CID(NS_WINDOW_CID);
michael@0 91 NS_DEFINE_NAMED_CID(NS_POPUP_CID);
michael@0 92 NS_DEFINE_NAMED_CID(NS_CHILD_CID);
michael@0 93 NS_DEFINE_NAMED_CID(NS_FILEPICKER_CID);
michael@0 94 NS_DEFINE_NAMED_CID(NS_COLORPICKER_CID);
michael@0 95 NS_DEFINE_NAMED_CID(NS_APPSHELL_CID);
michael@0 96 NS_DEFINE_NAMED_CID(NS_SOUND_CID);
michael@0 97 NS_DEFINE_NAMED_CID(NS_TRANSFERABLE_CID);
michael@0 98 NS_DEFINE_NAMED_CID(NS_HTMLFORMATCONVERTER_CID);
michael@0 99 NS_DEFINE_NAMED_CID(NS_CLIPBOARD_CID);
michael@0 100 NS_DEFINE_NAMED_CID(NS_CLIPBOARDHELPER_CID);
michael@0 101 NS_DEFINE_NAMED_CID(NS_DRAGSERVICE_CID);
michael@0 102 NS_DEFINE_NAMED_CID(NS_BIDIKEYBOARD_CID);
michael@0 103 NS_DEFINE_NAMED_CID(NS_THEMERENDERER_CID);
michael@0 104 NS_DEFINE_NAMED_CID(NS_SCREENMANAGER_CID);
michael@0 105 NS_DEFINE_NAMED_CID(NS_DEVICE_CONTEXT_SPEC_CID);
michael@0 106 NS_DEFINE_NAMED_CID(NS_PRINTSESSION_CID);
michael@0 107 NS_DEFINE_NAMED_CID(NS_PRINTSETTINGSSERVICE_CID);
michael@0 108 NS_DEFINE_NAMED_CID(NS_PRINTDIALOGSERVICE_CID);
michael@0 109 NS_DEFINE_NAMED_CID(NS_IDLE_SERVICE_CID);
michael@0 110 NS_DEFINE_NAMED_CID(NS_SYSTEMALERTSSERVICE_CID);
michael@0 111 NS_DEFINE_NAMED_CID(NS_NATIVEMENUSERVICE_CID);
michael@0 112 NS_DEFINE_NAMED_CID(NS_MACDOCKSUPPORT_CID);
michael@0 113 NS_DEFINE_NAMED_CID(NS_MACWEBAPPUTILS_CID);
michael@0 114 NS_DEFINE_NAMED_CID(NS_STANDALONENATIVEMENU_CID);
michael@0 115 NS_DEFINE_NAMED_CID(NS_GFXINFO_CID);
michael@0 116
michael@0 117 static const mozilla::Module::CIDEntry kWidgetCIDs[] = {
michael@0 118 { &kNS_WINDOW_CID, false, NULL, nsCocoaWindowConstructor },
michael@0 119 { &kNS_POPUP_CID, false, NULL, nsCocoaWindowConstructor },
michael@0 120 { &kNS_CHILD_CID, false, NULL, nsChildViewConstructor },
michael@0 121 { &kNS_FILEPICKER_CID, false, NULL, nsFilePickerConstructor,
michael@0 122 mozilla::Module::MAIN_PROCESS_ONLY },
michael@0 123 { &kNS_COLORPICKER_CID, false, NULL, nsColorPickerConstructor,
michael@0 124 mozilla::Module::MAIN_PROCESS_ONLY },
michael@0 125 { &kNS_APPSHELL_CID, false, NULL, nsAppShellConstructor },
michael@0 126 { &kNS_SOUND_CID, false, NULL, nsSoundConstructor,
michael@0 127 mozilla::Module::MAIN_PROCESS_ONLY },
michael@0 128 { &kNS_TRANSFERABLE_CID, false, NULL, nsTransferableConstructor },
michael@0 129 { &kNS_HTMLFORMATCONVERTER_CID, false, NULL, nsHTMLFormatConverterConstructor },
michael@0 130 { &kNS_CLIPBOARD_CID, false, NULL, nsClipboardConstructor,
michael@0 131 mozilla::Module::MAIN_PROCESS_ONLY },
michael@0 132 { &kNS_CLIPBOARDHELPER_CID, false, NULL, nsClipboardHelperConstructor },
michael@0 133 { &kNS_DRAGSERVICE_CID, false, NULL, nsDragServiceConstructor,
michael@0 134 mozilla::Module::MAIN_PROCESS_ONLY },
michael@0 135 { &kNS_BIDIKEYBOARD_CID, false, NULL, nsBidiKeyboardConstructor },
michael@0 136 { &kNS_THEMERENDERER_CID, false, NULL, nsNativeThemeCocoaConstructor },
michael@0 137 { &kNS_SCREENMANAGER_CID, false, NULL, nsScreenManagerCocoaConstructor },
michael@0 138 { &kNS_DEVICE_CONTEXT_SPEC_CID, false, NULL, nsDeviceContextSpecXConstructor,
michael@0 139 mozilla::Module::MAIN_PROCESS_ONLY },
michael@0 140 { &kNS_PRINTSESSION_CID, false, NULL, nsPrintSessionConstructor,
michael@0 141 mozilla::Module::MAIN_PROCESS_ONLY },
michael@0 142 { &kNS_PRINTSETTINGSSERVICE_CID, false, NULL, nsPrintOptionsXConstructor },
michael@0 143 { &kNS_PRINTDIALOGSERVICE_CID, false, NULL, nsPrintDialogServiceXConstructor,
michael@0 144 mozilla::Module::MAIN_PROCESS_ONLY },
michael@0 145 { &kNS_IDLE_SERVICE_CID, false, NULL, nsIdleServiceXConstructor },
michael@0 146 { &kNS_SYSTEMALERTSSERVICE_CID, false, NULL, OSXNotificationCenterConstructor },
michael@0 147 { &kNS_NATIVEMENUSERVICE_CID, false, NULL, nsNativeMenuServiceXConstructor },
michael@0 148 { &kNS_MACDOCKSUPPORT_CID, false, NULL, nsMacDockSupportConstructor },
michael@0 149 { &kNS_MACWEBAPPUTILS_CID, false, NULL, nsMacWebAppUtilsConstructor },
michael@0 150 { &kNS_STANDALONENATIVEMENU_CID, false, NULL, nsStandaloneNativeMenuConstructor },
michael@0 151 { &kNS_GFXINFO_CID, false, NULL, mozilla::widget::GfxInfoConstructor },
michael@0 152 { NULL }
michael@0 153 };
michael@0 154
michael@0 155 static const mozilla::Module::ContractIDEntry kWidgetContracts[] = {
michael@0 156 { "@mozilla.org/widgets/window/mac;1", &kNS_WINDOW_CID },
michael@0 157 { "@mozilla.org/widgets/popup/mac;1", &kNS_POPUP_CID },
michael@0 158 { "@mozilla.org/widgets/childwindow/mac;1", &kNS_CHILD_CID },
michael@0 159 { "@mozilla.org/filepicker;1", &kNS_FILEPICKER_CID,
michael@0 160 mozilla::Module::MAIN_PROCESS_ONLY },
michael@0 161 { "@mozilla.org/colorpicker;1", &kNS_COLORPICKER_CID,
michael@0 162 mozilla::Module::MAIN_PROCESS_ONLY },
michael@0 163 { "@mozilla.org/widget/appshell/mac;1", &kNS_APPSHELL_CID },
michael@0 164 { "@mozilla.org/sound;1", &kNS_SOUND_CID,
michael@0 165 mozilla::Module::MAIN_PROCESS_ONLY },
michael@0 166 { "@mozilla.org/widget/transferable;1", &kNS_TRANSFERABLE_CID },
michael@0 167 { "@mozilla.org/widget/htmlformatconverter;1", &kNS_HTMLFORMATCONVERTER_CID },
michael@0 168 { "@mozilla.org/widget/clipboard;1", &kNS_CLIPBOARD_CID,
michael@0 169 mozilla::Module::MAIN_PROCESS_ONLY },
michael@0 170 { "@mozilla.org/widget/clipboardhelper;1", &kNS_CLIPBOARDHELPER_CID },
michael@0 171 { "@mozilla.org/widget/dragservice;1", &kNS_DRAGSERVICE_CID,
michael@0 172 mozilla::Module::MAIN_PROCESS_ONLY },
michael@0 173 { "@mozilla.org/widget/bidikeyboard;1", &kNS_BIDIKEYBOARD_CID },
michael@0 174 { "@mozilla.org/chrome/chrome-native-theme;1", &kNS_THEMERENDERER_CID },
michael@0 175 { "@mozilla.org/gfx/screenmanager;1", &kNS_SCREENMANAGER_CID },
michael@0 176 { "@mozilla.org/gfx/devicecontextspec;1", &kNS_DEVICE_CONTEXT_SPEC_CID,
michael@0 177 mozilla::Module::MAIN_PROCESS_ONLY },
michael@0 178 { "@mozilla.org/gfx/printsession;1", &kNS_PRINTSESSION_CID,
michael@0 179 mozilla::Module::MAIN_PROCESS_ONLY },
michael@0 180 { "@mozilla.org/gfx/printsettings-service;1", &kNS_PRINTSETTINGSSERVICE_CID },
michael@0 181 { NS_PRINTDIALOGSERVICE_CONTRACTID, &kNS_PRINTDIALOGSERVICE_CID,
michael@0 182 mozilla::Module::MAIN_PROCESS_ONLY },
michael@0 183 { "@mozilla.org/widget/idleservice;1", &kNS_IDLE_SERVICE_CID },
michael@0 184 { "@mozilla.org/system-alerts-service;1", &kNS_SYSTEMALERTSSERVICE_CID },
michael@0 185 { "@mozilla.org/widget/nativemenuservice;1", &kNS_NATIVEMENUSERVICE_CID },
michael@0 186 { "@mozilla.org/widget/macdocksupport;1", &kNS_MACDOCKSUPPORT_CID },
michael@0 187 { "@mozilla.org/widget/mac-web-app-utils;1", &kNS_MACWEBAPPUTILS_CID },
michael@0 188 { "@mozilla.org/widget/standalonenativemenu;1", &kNS_STANDALONENATIVEMENU_CID },
michael@0 189 { "@mozilla.org/gfx/info;1", &kNS_GFXINFO_CID },
michael@0 190 { NULL }
michael@0 191 };
michael@0 192
michael@0 193 static void
michael@0 194 nsWidgetCocoaModuleDtor()
michael@0 195 {
michael@0 196 NativeKeyBindings::Shutdown();
michael@0 197 nsLookAndFeel::Shutdown();
michael@0 198 nsToolkit::Shutdown();
michael@0 199 nsAppShellShutdown();
michael@0 200 }
michael@0 201
michael@0 202 static const mozilla::Module kWidgetModule = {
michael@0 203 mozilla::Module::kVersion,
michael@0 204 kWidgetCIDs,
michael@0 205 kWidgetContracts,
michael@0 206 NULL,
michael@0 207 NULL,
michael@0 208 nsAppShellInit,
michael@0 209 nsWidgetCocoaModuleDtor
michael@0 210 };
michael@0 211
michael@0 212 NSMODULE_DEFN(nsWidgetMacModule) = &kWidgetModule;

mercurial