Bug 1543009 - Move Android widget xpcom components to static registration. r=kmag

Differential Revision: https://phabricator.services.mozilla.com/D26891
This commit is contained in:
Mike Hommey 2019-04-05 10:34:58 +09:00
parent 360d145ec2
commit 07aab2b391
5 changed files with 138 additions and 114 deletions

View File

@ -0,0 +1,108 @@
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
Headers = [
'/widget/android/nsWidgetFactory.h',
]
InitFunc = 'nsWidgetAndroidModuleCtor'
UnloadFunc = 'nsWidgetAndroidModuleDtor'
Classes = [
{
'cid': '{2d96b3df-c051-11d1-a827-0040959a28c9}',
'contract_ids': ['@mozilla.org/widget/appshell/android;1'],
'legacy_constructor': 'nsAppShellConstructor',
'headers': ['/widget/android/nsWidgetFactory.h'],
},
{
'cid': '{c401eb80-f9ea-11d3-bb6f-e732b73ebe7c}',
'contract_ids': ['@mozilla.org/gfx/screenmanager;1'],
'singleton': True,
'type': 'mozilla::widget::ScreenManager',
'headers': ['mozilla/widget/ScreenManager.h'],
'constructor': 'mozilla::widget::ScreenManager::GetAddRefedSingleton',
'processes': ProcessSelector.MAIN_PROCESS_ONLY,
},
{
'cid': '{6987230e-0098-4e78-bc5f-1493ee7519fa}',
'contract_ids': ['@mozilla.org/widget/idleservice;1'],
'singleton': True,
'type': 'nsIdleServiceAndroid',
'headers': ['/widget/android/nsIdleServiceAndroid.h'],
'constructor': 'nsIdleServiceAndroid::GetInstance',
},
{
'cid': '{8b5314bc-db01-11d2-96ce-0060b0fb9956}',
'contract_ids': ['@mozilla.org/widget/transferable;1'],
'type': 'nsTransferable',
'headers': ['/widget/nsTransferable.h'],
},
{
'cid': '{8b5314ba-db01-11d2-96ce-0060b0fb9956}',
'contract_ids': ['@mozilla.org/widget/clipboard;1'],
'type': 'nsClipboard',
'headers': ['/widget/android/nsClipboard.h'],
'processes': ProcessSelector.MAIN_PROCESS_ONLY,
},
{
'cid': '{77221d5a-1dd2-11b2-8c69-c710f15d2ed5}',
'contract_ids': ['@mozilla.org/widget/clipboardhelper;1'],
'type': 'nsClipboardHelper',
'headers': ['/widget/nsClipboardHelper.h'],
},
{
'cid': '{841387c8-72e6-484b-9296-bf6eea80d58a}',
'contract_ids': ['@mozilla.org/gfx/printsettings-service;1'],
'type': 'nsPrintSettingsServiceAndroid',
'headers': ['/widget/android/nsPrintSettingsServiceAndroid.h'],
'init_method': 'Init',
},
{
'cid': '{2f977d53-5485-11d4-87e2-0010a4e75ef2}',
'contract_ids': ['@mozilla.org/gfx/printsession;1'],
'type': 'nsPrintSession',
'headers': ['/widget/nsPrintSession.h'],
'init_method': 'Init',
},
{
'cid': '{d3f69889-e13a-4321-980c-a39332e21f34}',
'contract_ids': ['@mozilla.org/gfx/devicecontextspec;1'],
'type': 'nsDeviceContextSpecAndroid',
'headers': ['/widget/android/nsDeviceContextAndroid.h'],
},
{
'cid': '{948a0023-e3a7-11d2-96cf-0060b0fb9956}',
'contract_ids': ['@mozilla.org/widget/htmlformatconverter;1'],
'type': 'nsHTMLFormatConverter',
'headers': ['/widget/nsHTMLFormatConverter.h'],
},
{
'cid': '{d755a760-9f27-11df-0800-200c9a664242}',
'contract_ids': ['@mozilla.org/gfx/info;1'],
'type': 'mozilla::widget::GfxInfo',
'headers': ['/widget/android/GfxInfo.h'],
'init_method': 'Init',
},
{
'cid': '{0fe2321d-ebd9-467d-a743-03a68d40599e}',
'contract_ids': ['@mozilla.org/android/bridge;1'],
'type': 'nsAndroidBridge',
'headers': ['/widget/android/AndroidBridge.h'],
},
{
'cid': '{e9cd2b7f-8386-441b-aaf5-0b371846bfd0}',
'contract_ids': ['@mozilla.org/network/protocol;1?name=android'],
'type': 'nsAndroidProtocolHandler',
'headers': ['/widget/android/nsAndroidProtocolHandler.h'],
},
{
'cid': '{84e11f80-ca55-11dd-ad8b-0800200c9a66}',
'contract_ids': ['@mozilla.org/system-alerts-service;1'],
'type': 'mozilla::widget::AndroidAlerts',
'headers': ['/widget/android/AndroidAlerts.h'],
},
]

View File

@ -68,6 +68,10 @@ UNIFIED_SOURCES += [
'WebExecutorSupport.cpp',
]
XPCOM_MANIFESTS += [
'components.conf',
]
include('/ipc/chromium/chromium-config.mozbuild')
# The recursive make backend treats the first output specially: it's passed as

View File

@ -3,129 +3,19 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/ModuleUtils.h"
#include "mozilla/WidgetUtils.h"
#include "nsCOMPtr.h"
#include "nsWidgetsCID.h"
#include "nsAppShell.h"
#include "AndroidBridge.h"
#include "nsWindow.h"
#include "nsLookAndFeel.h"
#include "nsAppShellSingleton.h"
#include "nsIdleServiceAndroid.h"
#include "nsClipboard.h"
#include "nsClipboardHelper.h"
#include "nsTransferable.h"
#include "nsPrintSession.h"
#include "nsPrintSettingsServiceAndroid.h"
#include "nsDeviceContextAndroid.h"
#include "nsHTMLFormatConverter.h"
#include "nsXULAppAPI.h"
#include "nsAndroidProtocolHandler.h"
nsresult nsWidgetAndroidModuleCtor() { return nsAppShellInit(); }
#include "nsToolkitCompsCID.h"
#include "AndroidAlerts.h"
#include "mozilla/widget/ScreenManager.h"
using namespace mozilla;
using namespace mozilla::widget;
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(ScreenManager,
ScreenManager::GetAddRefedSingleton)
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsIdleServiceAndroid,
nsIdleServiceAndroid::GetInstance)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsTransferable)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboard)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboardHelper)
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintSettingsServiceAndroid, Init)
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintSession, Init)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecAndroid)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTMLFormatConverter)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAndroidBridge)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAndroidProtocolHandler)
#include "GfxInfo.h"
namespace mozilla {
namespace widget {
// This constructor should really be shared with all platforms.
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(GfxInfo, Init)
NS_GENERIC_FACTORY_CONSTRUCTOR(AndroidAlerts)
} // namespace widget
} // namespace mozilla
NS_DEFINE_NAMED_CID(NS_APPSHELL_CID);
NS_DEFINE_NAMED_CID(NS_SCREENMANAGER_CID);
NS_DEFINE_NAMED_CID(NS_IDLE_SERVICE_CID);
NS_DEFINE_NAMED_CID(NS_TRANSFERABLE_CID);
NS_DEFINE_NAMED_CID(NS_CLIPBOARD_CID);
NS_DEFINE_NAMED_CID(NS_CLIPBOARDHELPER_CID);
NS_DEFINE_NAMED_CID(NS_PRINTSETTINGSSERVICE_CID);
NS_DEFINE_NAMED_CID(NS_PRINTSESSION_CID);
NS_DEFINE_NAMED_CID(NS_DEVICE_CONTEXT_SPEC_CID);
NS_DEFINE_NAMED_CID(NS_HTMLFORMATCONVERTER_CID);
NS_DEFINE_NAMED_CID(NS_GFXINFO_CID);
NS_DEFINE_NAMED_CID(NS_ANDROIDBRIDGE_CID);
NS_DEFINE_NAMED_CID(NS_ANDROIDPROTOCOLHANDLER_CID);
NS_DEFINE_NAMED_CID(NS_SYSTEMALERTSSERVICE_CID);
static const mozilla::Module::CIDEntry kWidgetCIDs[] = {
{&kNS_APPSHELL_CID, false, nullptr, nsAppShellConstructor},
{&kNS_SCREENMANAGER_CID, false, nullptr, ScreenManagerConstructor,
mozilla::Module::MAIN_PROCESS_ONLY},
{&kNS_IDLE_SERVICE_CID, false, nullptr, nsIdleServiceAndroidConstructor},
{&kNS_TRANSFERABLE_CID, false, nullptr, nsTransferableConstructor},
{&kNS_CLIPBOARD_CID, false, nullptr, nsClipboardConstructor},
{&kNS_CLIPBOARDHELPER_CID, false, nullptr, nsClipboardHelperConstructor},
{&kNS_PRINTSETTINGSSERVICE_CID, false, nullptr,
nsPrintSettingsServiceAndroidConstructor},
{&kNS_PRINTSESSION_CID, false, nullptr, nsPrintSessionConstructor},
{&kNS_DEVICE_CONTEXT_SPEC_CID, false, nullptr,
nsDeviceContextSpecAndroidConstructor},
{&kNS_HTMLFORMATCONVERTER_CID, false, nullptr,
nsHTMLFormatConverterConstructor},
{&kNS_GFXINFO_CID, false, nullptr, mozilla::widget::GfxInfoConstructor},
{&kNS_ANDROIDBRIDGE_CID, false, nullptr, nsAndroidBridgeConstructor},
{&kNS_ANDROIDPROTOCOLHANDLER_CID, false, nullptr,
nsAndroidProtocolHandlerConstructor},
{&kNS_SYSTEMALERTSSERVICE_CID, false, nullptr,
mozilla::widget::AndroidAlertsConstructor},
{nullptr}};
static const mozilla::Module::ContractIDEntry kWidgetContracts[] = {
{"@mozilla.org/widget/appshell/android;1", &kNS_APPSHELL_CID},
{"@mozilla.org/gfx/screenmanager;1", &kNS_SCREENMANAGER_CID,
mozilla::Module::MAIN_PROCESS_ONLY},
{"@mozilla.org/widget/idleservice;1", &kNS_IDLE_SERVICE_CID},
{"@mozilla.org/widget/transferable;1", &kNS_TRANSFERABLE_CID},
{"@mozilla.org/widget/clipboard;1", &kNS_CLIPBOARD_CID},
{"@mozilla.org/widget/clipboardhelper;1", &kNS_CLIPBOARDHELPER_CID},
{"@mozilla.org/gfx/printsettings-service;1", &kNS_PRINTSETTINGSSERVICE_CID},
{"@mozilla.org/gfx/printsession;1", &kNS_PRINTSESSION_CID},
{"@mozilla.org/gfx/devicecontextspec;1", &kNS_DEVICE_CONTEXT_SPEC_CID},
{"@mozilla.org/widget/htmlformatconverter;1", &kNS_HTMLFORMATCONVERTER_CID},
{"@mozilla.org/gfx/info;1", &kNS_GFXINFO_CID},
{"@mozilla.org/android/bridge;1", &kNS_ANDROIDBRIDGE_CID},
{NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "android",
&kNS_ANDROIDPROTOCOLHANDLER_CID},
{NS_SYSTEMALERTSERVICE_CONTRACTID, &kNS_SYSTEMALERTSSERVICE_CID},
{nullptr}};
static void nsWidgetAndroidModuleDtor() {
void nsWidgetAndroidModuleDtor() {
// Shutdown all XP level widget classes.
mozilla::widget::WidgetUtils::Shutdown();
nsLookAndFeel::Shutdown();
nsAppShellShutdown();
}
extern const mozilla::Module kWidgetModule = {mozilla::Module::kVersion,
kWidgetCIDs,
kWidgetContracts,
nullptr,
nullptr,
nsAppShellInit,
nsWidgetAndroidModuleDtor};

View File

@ -0,0 +1,22 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:expandtab:shiftwidth=4:tabstop=4:
*/
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef widget_android_nsWidgetFactory_h
#define widget_android_nsWidgetFactory_h
#include "nscore.h"
#include "nsID.h"
class nsISupports;
nsresult nsAppShellConstructor(nsISupports *outer, const nsIID &iid,
void **result);
nsresult nsWidgetAndroidModuleCtor();
void nsWidgetAndroidModuleDtor();
#endif // defined widget_android_nsWidgetFactory_h

View File

@ -353,7 +353,7 @@ nsComponentManagerImpl::nsComponentManagerImpl()
extern const mozilla::Module kNeckoModule;
extern const mozilla::Module kPowerManagerModule;
extern const mozilla::Module kContentProcessWidgetModule;
#if defined(MOZ_WIDGET_ANDROID) || defined(MOZ_WIDGET_COCOA) || defined(MOZ_WIDGET_UIKIT)
#if defined(MOZ_WIDGET_COCOA) || defined(MOZ_WIDGET_UIKIT)
extern const mozilla::Module kWidgetModule;
#endif
extern const mozilla::Module kLayoutModule;
@ -458,7 +458,7 @@ nsresult nsComponentManagerImpl::Init() {
RegisterModule(&kNeckoModule);
RegisterModule(&kPowerManagerModule);
RegisterModule(&kContentProcessWidgetModule);
#if defined(MOZ_WIDGET_ANDROID) || defined(MOZ_WIDGET_COCOA) || defined(MOZ_WIDGET_UIKIT)
#if defined(MOZ_WIDGET_COCOA) || defined(MOZ_WIDGET_UIKIT)
RegisterModule(&kWidgetModule);
#endif
RegisterModule(&kLayoutModule);