|
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
|
2 /* Copyright 2012 Mozilla Foundation and Mozilla contributors |
|
3 * |
|
4 * Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 * you may not use this file except in compliance with the License. |
|
6 * You may obtain a copy of the License at |
|
7 * |
|
8 * http://www.apache.org/licenses/LICENSE-2.0 |
|
9 * |
|
10 * Unless required by applicable law or agreed to in writing, software |
|
11 * distributed under the License is distributed on an "AS IS" BASIS, |
|
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
13 * See the License for the specific language governing permissions and |
|
14 * limitations under the License. |
|
15 */ |
|
16 |
|
17 #include "base/basictypes.h" |
|
18 |
|
19 #include "mozilla/ModuleUtils.h" |
|
20 |
|
21 #include "nsCOMPtr.h" |
|
22 #include "nsWidgetsCID.h" |
|
23 #include "nsAppShell.h" |
|
24 |
|
25 #include "nsWindow.h" |
|
26 #include "nsLookAndFeel.h" |
|
27 #include "nsAppShellSingleton.h" |
|
28 #include "nsScreenManagerGonk.h" |
|
29 #include "nsIdleServiceGonk.h" |
|
30 #include "nsTransferable.h" |
|
31 #include "nsClipboard.h" |
|
32 #include "nsClipboardHelper.h" |
|
33 |
|
34 #include "nsHTMLFormatConverter.h" |
|
35 #include "nsXULAppAPI.h" |
|
36 |
|
37 #include "PuppetWidget.h" |
|
38 |
|
39 using namespace mozilla::widget; |
|
40 |
|
41 // taken from android/nsWidgetFactory.cpp. GfxInfo is a legacy kludge, unfortunately |
|
42 // for the time being we still have to implement it on all platforms. |
|
43 #include "GfxInfo.h" |
|
44 namespace mozilla { |
|
45 namespace widget { |
|
46 // This constructor should really be shared with all platforms. |
|
47 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(GfxInfo, Init) |
|
48 } |
|
49 } |
|
50 |
|
51 NS_GENERIC_FACTORY_CONSTRUCTOR(nsWindow) |
|
52 NS_GENERIC_FACTORY_CONSTRUCTOR(nsScreenManagerGonk) |
|
53 NS_GENERIC_FACTORY_CONSTRUCTOR(PuppetScreenManager) |
|
54 NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTMLFormatConverter) |
|
55 NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsIdleServiceGonk, nsIdleServiceGonk::GetInstance) |
|
56 NS_GENERIC_FACTORY_CONSTRUCTOR(nsTransferable) |
|
57 NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboard) |
|
58 NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboardHelper) |
|
59 |
|
60 NS_DEFINE_NAMED_CID(NS_APPSHELL_CID); |
|
61 NS_DEFINE_NAMED_CID(NS_WINDOW_CID); |
|
62 NS_DEFINE_NAMED_CID(NS_CHILD_CID); |
|
63 NS_DEFINE_NAMED_CID(NS_SCREENMANAGER_CID); |
|
64 NS_DEFINE_NAMED_CID(NS_HTMLFORMATCONVERTER_CID); |
|
65 NS_DEFINE_NAMED_CID(NS_IDLE_SERVICE_CID); |
|
66 NS_DEFINE_NAMED_CID(NS_TRANSFERABLE_CID); |
|
67 NS_DEFINE_NAMED_CID(NS_GFXINFO_CID); |
|
68 NS_DEFINE_NAMED_CID(NS_CLIPBOARD_CID); |
|
69 NS_DEFINE_NAMED_CID(NS_CLIPBOARDHELPER_CID); |
|
70 |
|
71 static nsresult |
|
72 ScreenManagerConstructor(nsISupports *aOuter, REFNSIID aIID, void **aResult) |
|
73 { |
|
74 return (XRE_GetProcessType() == GeckoProcessType_Default) ? |
|
75 nsScreenManagerGonkConstructor(aOuter, aIID, aResult) : |
|
76 PuppetScreenManagerConstructor(aOuter, aIID, aResult); |
|
77 } |
|
78 |
|
79 static const mozilla::Module::CIDEntry kWidgetCIDs[] = { |
|
80 { &kNS_WINDOW_CID, false, nullptr, nsWindowConstructor }, |
|
81 { &kNS_CHILD_CID, false, nullptr, nsWindowConstructor }, |
|
82 { &kNS_APPSHELL_CID, false, nullptr, nsAppShellConstructor }, |
|
83 { &kNS_SCREENMANAGER_CID, false, nullptr, ScreenManagerConstructor }, |
|
84 { &kNS_HTMLFORMATCONVERTER_CID, false, nullptr, nsHTMLFormatConverterConstructor }, |
|
85 { &kNS_IDLE_SERVICE_CID, false, nullptr, nsIdleServiceGonkConstructor }, |
|
86 { &kNS_TRANSFERABLE_CID, false, nullptr, nsTransferableConstructor }, |
|
87 { &kNS_GFXINFO_CID, false, nullptr, mozilla::widget::GfxInfoConstructor }, |
|
88 { &kNS_CLIPBOARD_CID, false, nullptr, nsClipboardConstructor }, |
|
89 { &kNS_CLIPBOARDHELPER_CID, false, nullptr, nsClipboardHelperConstructor }, |
|
90 { nullptr } |
|
91 }; |
|
92 |
|
93 static const mozilla::Module::ContractIDEntry kWidgetContracts[] = { |
|
94 { "@mozilla.org/widgets/window/gonk;1", &kNS_WINDOW_CID }, |
|
95 { "@mozilla.org/widgets/child_window/gonk;1", &kNS_CHILD_CID }, |
|
96 { "@mozilla.org/widget/appshell/gonk;1", &kNS_APPSHELL_CID }, |
|
97 { "@mozilla.org/gfx/screenmanager;1", &kNS_SCREENMANAGER_CID }, |
|
98 { "@mozilla.org/widget/htmlformatconverter;1", &kNS_HTMLFORMATCONVERTER_CID }, |
|
99 { "@mozilla.org/widget/idleservice;1", &kNS_IDLE_SERVICE_CID }, |
|
100 { "@mozilla.org/widget/transferable;1", &kNS_TRANSFERABLE_CID }, |
|
101 { "@mozilla.org/gfx/info;1", &kNS_GFXINFO_CID }, |
|
102 { "@mozilla.org/widget/clipboard;1", &kNS_CLIPBOARD_CID }, |
|
103 { "@mozilla.org/widget/clipboardhelper;1", &kNS_CLIPBOARDHELPER_CID }, |
|
104 { nullptr } |
|
105 }; |
|
106 |
|
107 static void |
|
108 nsWidgetGonkModuleDtor() |
|
109 { |
|
110 nsLookAndFeel::Shutdown(); |
|
111 nsAppShellShutdown(); |
|
112 } |
|
113 |
|
114 static const mozilla::Module kWidgetModule = { |
|
115 mozilla::Module::kVersion, |
|
116 kWidgetCIDs, |
|
117 kWidgetContracts, |
|
118 nullptr, |
|
119 nullptr, |
|
120 nsAppShellInit, |
|
121 nsWidgetGonkModuleDtor |
|
122 }; |
|
123 |
|
124 NSMODULE_DEFN(nsWidgetGonkModule) = &kWidgetModule; |