|
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
|
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/. */ |
|
5 |
|
6 #include "nsNetUtil.h" |
|
7 #include "nsIURI.h" |
|
8 |
|
9 #include "nsISystemProxySettings.h" |
|
10 #include "nsIServiceManager.h" |
|
11 #include "mozilla/ModuleUtils.h" |
|
12 #include "nsPrintfCString.h" |
|
13 #include "nsNetUtil.h" |
|
14 #include "nsISupportsPrimitives.h" |
|
15 #include "nsIURI.h" |
|
16 |
|
17 #include "AndroidBridge.h" |
|
18 |
|
19 class nsAndroidSystemProxySettings : public nsISystemProxySettings |
|
20 { |
|
21 public: |
|
22 NS_DECL_THREADSAFE_ISUPPORTS |
|
23 NS_DECL_NSISYSTEMPROXYSETTINGS |
|
24 |
|
25 nsAndroidSystemProxySettings() {}; |
|
26 nsresult Init(); |
|
27 |
|
28 private: |
|
29 ~nsAndroidSystemProxySettings() {}; |
|
30 }; |
|
31 |
|
32 NS_IMPL_ISUPPORTS(nsAndroidSystemProxySettings, nsISystemProxySettings) |
|
33 |
|
34 NS_IMETHODIMP |
|
35 nsAndroidSystemProxySettings::GetMainThreadOnly(bool *aMainThreadOnly) |
|
36 { |
|
37 *aMainThreadOnly = true; |
|
38 return NS_OK; |
|
39 } |
|
40 |
|
41 |
|
42 nsresult |
|
43 nsAndroidSystemProxySettings::Init() |
|
44 { |
|
45 return NS_OK; |
|
46 } |
|
47 |
|
48 nsresult |
|
49 nsAndroidSystemProxySettings::GetPACURI(nsACString& aResult) |
|
50 { |
|
51 return NS_OK; |
|
52 } |
|
53 |
|
54 nsresult |
|
55 nsAndroidSystemProxySettings::GetProxyForURI(const nsACString & aSpec, |
|
56 const nsACString & aScheme, |
|
57 const nsACString & aHost, |
|
58 const int32_t aPort, |
|
59 nsACString & aResult) |
|
60 { |
|
61 return mozilla::AndroidBridge::Bridge()->GetProxyForURI(aSpec, aScheme, aHost, aPort, aResult); |
|
62 } |
|
63 |
|
64 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsAndroidSystemProxySettings, Init) |
|
65 |
|
66 #define NS_ANDROIDSYSTEMPROXYSERVICE_CID \ |
|
67 {0xf01f0060, 0x3708, 0x478e, \ |
|
68 {0xb9, 0x35, 0x3e, 0xce, 0x8b, 0xe2, 0x94, 0xb8}} |
|
69 |
|
70 NS_DEFINE_NAMED_CID(NS_ANDROIDSYSTEMPROXYSERVICE_CID); |
|
71 |
|
72 void test() {}; |
|
73 |
|
74 static const mozilla::Module::CIDEntry kSysProxyCIDs[] = { |
|
75 { &kNS_ANDROIDSYSTEMPROXYSERVICE_CID, false, nullptr, nsAndroidSystemProxySettingsConstructor }, |
|
76 { nullptr } |
|
77 }; |
|
78 |
|
79 static const mozilla::Module::ContractIDEntry kSysProxyContracts[] = { |
|
80 { NS_SYSTEMPROXYSETTINGS_CONTRACTID, &kNS_ANDROIDSYSTEMPROXYSERVICE_CID }, |
|
81 { nullptr } |
|
82 }; |
|
83 |
|
84 static const mozilla::Module kSysProxyModule = { |
|
85 mozilla::Module::kVersion, |
|
86 kSysProxyCIDs, |
|
87 kSysProxyContracts |
|
88 }; |
|
89 |
|
90 NSMODULE_DEFN(nsAndroidProxyModule) = &kSysProxyModule; |