1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/system/androidproxy/nsAndroidSystemProxySettings.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,90 @@ 1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#include "nsNetUtil.h" 1.10 +#include "nsIURI.h" 1.11 + 1.12 +#include "nsISystemProxySettings.h" 1.13 +#include "nsIServiceManager.h" 1.14 +#include "mozilla/ModuleUtils.h" 1.15 +#include "nsPrintfCString.h" 1.16 +#include "nsNetUtil.h" 1.17 +#include "nsISupportsPrimitives.h" 1.18 +#include "nsIURI.h" 1.19 + 1.20 +#include "AndroidBridge.h" 1.21 + 1.22 +class nsAndroidSystemProxySettings : public nsISystemProxySettings 1.23 +{ 1.24 +public: 1.25 + NS_DECL_THREADSAFE_ISUPPORTS 1.26 + NS_DECL_NSISYSTEMPROXYSETTINGS 1.27 + 1.28 + nsAndroidSystemProxySettings() {}; 1.29 + nsresult Init(); 1.30 + 1.31 +private: 1.32 + ~nsAndroidSystemProxySettings() {}; 1.33 +}; 1.34 + 1.35 +NS_IMPL_ISUPPORTS(nsAndroidSystemProxySettings, nsISystemProxySettings) 1.36 + 1.37 +NS_IMETHODIMP 1.38 +nsAndroidSystemProxySettings::GetMainThreadOnly(bool *aMainThreadOnly) 1.39 +{ 1.40 + *aMainThreadOnly = true; 1.41 + return NS_OK; 1.42 +} 1.43 + 1.44 + 1.45 +nsresult 1.46 +nsAndroidSystemProxySettings::Init() 1.47 +{ 1.48 + return NS_OK; 1.49 +} 1.50 + 1.51 +nsresult 1.52 +nsAndroidSystemProxySettings::GetPACURI(nsACString& aResult) 1.53 +{ 1.54 + return NS_OK; 1.55 +} 1.56 + 1.57 +nsresult 1.58 +nsAndroidSystemProxySettings::GetProxyForURI(const nsACString & aSpec, 1.59 + const nsACString & aScheme, 1.60 + const nsACString & aHost, 1.61 + const int32_t aPort, 1.62 + nsACString & aResult) 1.63 +{ 1.64 + return mozilla::AndroidBridge::Bridge()->GetProxyForURI(aSpec, aScheme, aHost, aPort, aResult); 1.65 +} 1.66 + 1.67 +NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsAndroidSystemProxySettings, Init) 1.68 + 1.69 +#define NS_ANDROIDSYSTEMPROXYSERVICE_CID \ 1.70 + {0xf01f0060, 0x3708, 0x478e, \ 1.71 + {0xb9, 0x35, 0x3e, 0xce, 0x8b, 0xe2, 0x94, 0xb8}} 1.72 + 1.73 +NS_DEFINE_NAMED_CID(NS_ANDROIDSYSTEMPROXYSERVICE_CID); 1.74 + 1.75 +void test() {}; 1.76 + 1.77 +static const mozilla::Module::CIDEntry kSysProxyCIDs[] = { 1.78 + { &kNS_ANDROIDSYSTEMPROXYSERVICE_CID, false, nullptr, nsAndroidSystemProxySettingsConstructor }, 1.79 + { nullptr } 1.80 +}; 1.81 + 1.82 +static const mozilla::Module::ContractIDEntry kSysProxyContracts[] = { 1.83 + { NS_SYSTEMPROXYSETTINGS_CONTRACTID, &kNS_ANDROIDSYSTEMPROXYSERVICE_CID }, 1.84 + { nullptr } 1.85 +}; 1.86 + 1.87 +static const mozilla::Module kSysProxyModule = { 1.88 + mozilla::Module::kVersion, 1.89 + kSysProxyCIDs, 1.90 + kSysProxyContracts 1.91 +}; 1.92 + 1.93 +NSMODULE_DEFN(nsAndroidProxyModule) = &kSysProxyModule;