mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 13:21:05 +00:00
Bug 1037269 - Use CheckPermissions instead of Func on more interfaces. r=smaug
This commit is contained in:
parent
c3a80ae7ac
commit
ad03973670
@ -2183,33 +2183,6 @@ Navigator::HasWakeLockSupport(JSContext* /* unused*/, JSObject* /*unused */)
|
||||
return !!pmService;
|
||||
}
|
||||
|
||||
/* static */
|
||||
bool
|
||||
Navigator::HasMobileMessageSupport(JSContext* /* unused */, JSObject* aGlobal)
|
||||
{
|
||||
nsCOMPtr<nsPIDOMWindow> win = GetWindowFromGlobal(aGlobal);
|
||||
|
||||
#ifndef MOZ_WEBSMS_BACKEND
|
||||
return false;
|
||||
#endif
|
||||
|
||||
// First of all, the general pref has to be turned on.
|
||||
bool enabled = false;
|
||||
Preferences::GetBool("dom.sms.enabled", &enabled);
|
||||
if (!enabled) {
|
||||
return false;
|
||||
}
|
||||
|
||||
NS_ENSURE_TRUE(win, false);
|
||||
NS_ENSURE_TRUE(win->GetDocShell(), false);
|
||||
|
||||
if (!CheckPermission(win, "sms")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* static */
|
||||
bool
|
||||
Navigator::HasCameraSupport(JSContext* /* unused */, JSObject* aGlobal)
|
||||
@ -2255,16 +2228,6 @@ Navigator::HasNFCSupport(JSContext* /* unused */, JSObject* aGlobal)
|
||||
}
|
||||
#endif // MOZ_NFC
|
||||
|
||||
#ifdef MOZ_TIME_MANAGER
|
||||
/* static */
|
||||
bool
|
||||
Navigator::HasTimeSupport(JSContext* /* unused */, JSObject* aGlobal)
|
||||
{
|
||||
nsCOMPtr<nsPIDOMWindow> win = GetWindowFromGlobal(aGlobal);
|
||||
return win && CheckPermission(win, "time");
|
||||
}
|
||||
#endif // MOZ_TIME_MANAGER
|
||||
|
||||
#ifdef MOZ_MEDIA_NAVIGATOR
|
||||
/* static */
|
||||
bool
|
||||
@ -2366,22 +2329,6 @@ Navigator::HasDataStoreSupport(JSContext* aCx, JSObject* aGlobal)
|
||||
return HasDataStoreSupport(doc->NodePrincipal());
|
||||
}
|
||||
|
||||
/* static */
|
||||
bool
|
||||
Navigator::HasNetworkStatsSupport(JSContext* /* unused */, JSObject* aGlobal)
|
||||
{
|
||||
nsCOMPtr<nsPIDOMWindow> win = GetWindowFromGlobal(aGlobal);
|
||||
return CheckPermission(win, "networkstats-manage");
|
||||
}
|
||||
|
||||
/* static */
|
||||
bool
|
||||
Navigator::HasFeatureDetectionSupport(JSContext* /* unused */, JSObject* aGlobal)
|
||||
{
|
||||
nsCOMPtr<nsPIDOMWindow> win = GetWindowFromGlobal(aGlobal);
|
||||
return CheckPermission(win, "feature-detection");
|
||||
}
|
||||
|
||||
#ifdef MOZ_B2G
|
||||
/* static */
|
||||
bool
|
||||
|
@ -268,8 +268,6 @@ public:
|
||||
|
||||
// WebIDL helper methods
|
||||
static bool HasWakeLockSupport(JSContext* /* unused*/, JSObject* /*unused */);
|
||||
static bool HasMobileMessageSupport(JSContext* /* unused */,
|
||||
JSObject* aGlobal);
|
||||
static bool HasCameraSupport(JSContext* /* unused */,
|
||||
JSObject* aGlobal);
|
||||
static bool HasWifiManagerSupport(JSContext* /* unused */,
|
||||
@ -277,9 +275,6 @@ public:
|
||||
#ifdef MOZ_NFC
|
||||
static bool HasNFCSupport(JSContext* /* unused */, JSObject* aGlobal);
|
||||
#endif // MOZ_NFC
|
||||
#ifdef MOZ_TIME_MANAGER
|
||||
static bool HasTimeSupport(JSContext* /* unused */, JSObject* aGlobal);
|
||||
#endif // MOZ_TIME_MANAGER
|
||||
#ifdef MOZ_MEDIA_NAVIGATOR
|
||||
static bool HasUserMediaSupport(JSContext* /* unused */,
|
||||
JSObject* /* unused */);
|
||||
@ -291,10 +286,6 @@ public:
|
||||
|
||||
static bool HasDataStoreSupport(JSContext* cx, JSObject* aGlobal);
|
||||
|
||||
static bool HasNetworkStatsSupport(JSContext* aCx, JSObject* aGlobal);
|
||||
|
||||
static bool HasFeatureDetectionSupport(JSContext* aCx, JSObject* aGlobal);
|
||||
|
||||
#ifdef MOZ_B2G
|
||||
static bool HasMobileIdSupport(JSContext* aCx, JSObject* aGlobal);
|
||||
#endif
|
||||
|
@ -26,8 +26,8 @@ dictionary NetworkStatsAlarmOptions
|
||||
|
||||
[JSImplementation="@mozilla.org/networkstats;1",
|
||||
ChromeOnly,
|
||||
Pref="dom.mozNetworkStats.enabled",
|
||||
Func="Navigator::HasNetworkStatsSupport"]
|
||||
CheckPermissions="networkstats-manage",
|
||||
Pref="dom.mozNetworkStats.enabled"]
|
||||
interface MozNetworkStats {
|
||||
/**
|
||||
* App manifest URL of an application for specifying the per-app stats of the
|
||||
|
@ -4,8 +4,8 @@
|
||||
|
||||
[JSImplementation="@mozilla.org/networkstatsalarm;1",
|
||||
ChromeOnly,
|
||||
Pref="dom.mozNetworkStats.enabled",
|
||||
Func="Navigator::HasNetworkStatsSupport"]
|
||||
CheckPermissions="networkstats-manage",
|
||||
Pref="dom.mozNetworkStats.enabled"]
|
||||
interface MozNetworkStatsAlarm {
|
||||
readonly attribute unsigned long alarmId;
|
||||
readonly attribute MozNetworkStatsInterface network;
|
||||
|
@ -4,8 +4,8 @@
|
||||
|
||||
[JSImplementation="@mozilla.org/networkStatsdata;1",
|
||||
ChromeOnly,
|
||||
Pref="dom.mozNetworkStats.enabled",
|
||||
Func="Navigator::HasNetworkStatsSupport"]
|
||||
CheckPermissions="networkstats-manage",
|
||||
Pref="dom.mozNetworkStats.enabled"]
|
||||
interface MozNetworkStatsData {
|
||||
readonly attribute unsigned long rxBytes; // Received bytes.
|
||||
readonly attribute unsigned long txBytes; // Sent bytes.
|
||||
|
@ -12,8 +12,8 @@ dictionary NetworkInterface {
|
||||
*/
|
||||
[Constructor(optional NetworkInterface networkinterface),
|
||||
JSImplementation="@mozilla.org/networkstatsinterface;1",
|
||||
Pref="dom.mozNetworkStats.enabled",
|
||||
Func="Navigator::HasNetworkStatsSupport"]
|
||||
CheckPermissions="networkstats-manage",
|
||||
Pref="dom.mozNetworkStats.enabled"]
|
||||
interface MozNetworkStatsInterface {
|
||||
readonly attribute long type;
|
||||
|
||||
|
@ -83,7 +83,7 @@ interface NavigatorStorageUtils {
|
||||
|
||||
[NoInterfaceObject]
|
||||
interface NavigatorFeatures {
|
||||
[Func="Navigator::HasFeatureDetectionSupport"]
|
||||
[CheckPermissions="feature-detection"]
|
||||
Promise getFeature(DOMString name);
|
||||
};
|
||||
|
||||
@ -252,10 +252,12 @@ partial interface Navigator {
|
||||
boolean mozIsLocallyAvailable(DOMString uri, boolean whenOffline);
|
||||
};
|
||||
|
||||
#ifdef MOZ_WEBSMS_BACKEND
|
||||
partial interface Navigator {
|
||||
[Func="Navigator::HasMobileMessageSupport"]
|
||||
[CheckPermissions="sms", Pref="dom.sms.enabled"]
|
||||
readonly attribute MozMobileMessageManager? mozMobileMessage;
|
||||
};
|
||||
#endif
|
||||
|
||||
// NetworkInformation
|
||||
partial interface Navigator {
|
||||
@ -331,7 +333,7 @@ partial interface Navigator {
|
||||
#ifdef MOZ_TIME_MANAGER
|
||||
// nsIDOMMozNavigatorTime
|
||||
partial interface Navigator {
|
||||
[Throws, Func="Navigator::HasTimeSupport"]
|
||||
[Throws, CheckPermissions="time"]
|
||||
readonly attribute MozTimeManager mozTime;
|
||||
};
|
||||
#endif // MOZ_TIME_MANAGER
|
||||
|
Loading…
Reference in New Issue
Block a user