Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "nsAndroidNetworkLinkService.h"
8 #include "nsServiceManagerUtils.h"
9 #include "mozilla/Services.h"
11 #include "AndroidBridge.h"
13 using namespace mozilla::widget::android;
15 NS_IMPL_ISUPPORTS(nsAndroidNetworkLinkService,
16 nsINetworkLinkService)
18 nsAndroidNetworkLinkService::nsAndroidNetworkLinkService()
19 {
20 }
22 nsAndroidNetworkLinkService::~nsAndroidNetworkLinkService()
23 {
24 }
26 NS_IMETHODIMP
27 nsAndroidNetworkLinkService::GetIsLinkUp(bool *aIsUp)
28 {
29 if (!mozilla::AndroidBridge::Bridge()) {
30 // Fail soft here and assume a connection exists
31 NS_WARNING("GetIsLinkUp is not supported without a bridge connection");
32 *aIsUp = true;
33 return NS_OK;
34 }
36 *aIsUp = mozilla::widget::android::GeckoAppShell::IsNetworkLinkUp();
37 return NS_OK;
38 }
40 NS_IMETHODIMP
41 nsAndroidNetworkLinkService::GetLinkStatusKnown(bool *aIsKnown)
42 {
43 NS_ENSURE_TRUE(mozilla::AndroidBridge::Bridge(), NS_ERROR_NOT_IMPLEMENTED);
45 *aIsKnown = mozilla::widget::android::GeckoAppShell::IsNetworkLinkKnown();
46 return NS_OK;
47 }
49 NS_IMETHODIMP
50 nsAndroidNetworkLinkService::GetLinkType(uint32_t *aLinkType)
51 {
52 NS_ENSURE_ARG_POINTER(aLinkType);
54 if (!mozilla::AndroidBridge::Bridge()) {
55 // Fail soft here and assume a connection exists
56 NS_WARNING("GetLinkType is not supported without a bridge connection");
57 *aLinkType = nsINetworkLinkService::LINK_TYPE_UNKNOWN;
58 return NS_OK;
59 }
61 *aLinkType = mozilla::widget::android::GeckoAppShell::NetworkLinkType();
62 return NS_OK;
63 }