mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +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;
|
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 */
|
/* static */
|
||||||
bool
|
bool
|
||||||
Navigator::HasCameraSupport(JSContext* /* unused */, JSObject* aGlobal)
|
Navigator::HasCameraSupport(JSContext* /* unused */, JSObject* aGlobal)
|
||||||
@ -2255,16 +2228,6 @@ Navigator::HasNFCSupport(JSContext* /* unused */, JSObject* aGlobal)
|
|||||||
}
|
}
|
||||||
#endif // MOZ_NFC
|
#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
|
#ifdef MOZ_MEDIA_NAVIGATOR
|
||||||
/* static */
|
/* static */
|
||||||
bool
|
bool
|
||||||
@ -2366,22 +2329,6 @@ Navigator::HasDataStoreSupport(JSContext* aCx, JSObject* aGlobal)
|
|||||||
return HasDataStoreSupport(doc->NodePrincipal());
|
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
|
#ifdef MOZ_B2G
|
||||||
/* static */
|
/* static */
|
||||||
bool
|
bool
|
||||||
|
@ -268,8 +268,6 @@ public:
|
|||||||
|
|
||||||
// WebIDL helper methods
|
// WebIDL helper methods
|
||||||
static bool HasWakeLockSupport(JSContext* /* unused*/, JSObject* /*unused */);
|
static bool HasWakeLockSupport(JSContext* /* unused*/, JSObject* /*unused */);
|
||||||
static bool HasMobileMessageSupport(JSContext* /* unused */,
|
|
||||||
JSObject* aGlobal);
|
|
||||||
static bool HasCameraSupport(JSContext* /* unused */,
|
static bool HasCameraSupport(JSContext* /* unused */,
|
||||||
JSObject* aGlobal);
|
JSObject* aGlobal);
|
||||||
static bool HasWifiManagerSupport(JSContext* /* unused */,
|
static bool HasWifiManagerSupport(JSContext* /* unused */,
|
||||||
@ -277,9 +275,6 @@ public:
|
|||||||
#ifdef MOZ_NFC
|
#ifdef MOZ_NFC
|
||||||
static bool HasNFCSupport(JSContext* /* unused */, JSObject* aGlobal);
|
static bool HasNFCSupport(JSContext* /* unused */, JSObject* aGlobal);
|
||||||
#endif // MOZ_NFC
|
#endif // MOZ_NFC
|
||||||
#ifdef MOZ_TIME_MANAGER
|
|
||||||
static bool HasTimeSupport(JSContext* /* unused */, JSObject* aGlobal);
|
|
||||||
#endif // MOZ_TIME_MANAGER
|
|
||||||
#ifdef MOZ_MEDIA_NAVIGATOR
|
#ifdef MOZ_MEDIA_NAVIGATOR
|
||||||
static bool HasUserMediaSupport(JSContext* /* unused */,
|
static bool HasUserMediaSupport(JSContext* /* unused */,
|
||||||
JSObject* /* unused */);
|
JSObject* /* unused */);
|
||||||
@ -291,10 +286,6 @@ public:
|
|||||||
|
|
||||||
static bool HasDataStoreSupport(JSContext* cx, JSObject* aGlobal);
|
static bool HasDataStoreSupport(JSContext* cx, JSObject* aGlobal);
|
||||||
|
|
||||||
static bool HasNetworkStatsSupport(JSContext* aCx, JSObject* aGlobal);
|
|
||||||
|
|
||||||
static bool HasFeatureDetectionSupport(JSContext* aCx, JSObject* aGlobal);
|
|
||||||
|
|
||||||
#ifdef MOZ_B2G
|
#ifdef MOZ_B2G
|
||||||
static bool HasMobileIdSupport(JSContext* aCx, JSObject* aGlobal);
|
static bool HasMobileIdSupport(JSContext* aCx, JSObject* aGlobal);
|
||||||
#endif
|
#endif
|
||||||
|
@ -26,8 +26,8 @@ dictionary NetworkStatsAlarmOptions
|
|||||||
|
|
||||||
[JSImplementation="@mozilla.org/networkstats;1",
|
[JSImplementation="@mozilla.org/networkstats;1",
|
||||||
ChromeOnly,
|
ChromeOnly,
|
||||||
Pref="dom.mozNetworkStats.enabled",
|
CheckPermissions="networkstats-manage",
|
||||||
Func="Navigator::HasNetworkStatsSupport"]
|
Pref="dom.mozNetworkStats.enabled"]
|
||||||
interface MozNetworkStats {
|
interface MozNetworkStats {
|
||||||
/**
|
/**
|
||||||
* App manifest URL of an application for specifying the per-app stats of the
|
* App manifest URL of an application for specifying the per-app stats of the
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
|
|
||||||
[JSImplementation="@mozilla.org/networkstatsalarm;1",
|
[JSImplementation="@mozilla.org/networkstatsalarm;1",
|
||||||
ChromeOnly,
|
ChromeOnly,
|
||||||
Pref="dom.mozNetworkStats.enabled",
|
CheckPermissions="networkstats-manage",
|
||||||
Func="Navigator::HasNetworkStatsSupport"]
|
Pref="dom.mozNetworkStats.enabled"]
|
||||||
interface MozNetworkStatsAlarm {
|
interface MozNetworkStatsAlarm {
|
||||||
readonly attribute unsigned long alarmId;
|
readonly attribute unsigned long alarmId;
|
||||||
readonly attribute MozNetworkStatsInterface network;
|
readonly attribute MozNetworkStatsInterface network;
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
|
|
||||||
[JSImplementation="@mozilla.org/networkStatsdata;1",
|
[JSImplementation="@mozilla.org/networkStatsdata;1",
|
||||||
ChromeOnly,
|
ChromeOnly,
|
||||||
Pref="dom.mozNetworkStats.enabled",
|
CheckPermissions="networkstats-manage",
|
||||||
Func="Navigator::HasNetworkStatsSupport"]
|
Pref="dom.mozNetworkStats.enabled"]
|
||||||
interface MozNetworkStatsData {
|
interface MozNetworkStatsData {
|
||||||
readonly attribute unsigned long rxBytes; // Received bytes.
|
readonly attribute unsigned long rxBytes; // Received bytes.
|
||||||
readonly attribute unsigned long txBytes; // Sent bytes.
|
readonly attribute unsigned long txBytes; // Sent bytes.
|
||||||
|
@ -12,8 +12,8 @@ dictionary NetworkInterface {
|
|||||||
*/
|
*/
|
||||||
[Constructor(optional NetworkInterface networkinterface),
|
[Constructor(optional NetworkInterface networkinterface),
|
||||||
JSImplementation="@mozilla.org/networkstatsinterface;1",
|
JSImplementation="@mozilla.org/networkstatsinterface;1",
|
||||||
Pref="dom.mozNetworkStats.enabled",
|
CheckPermissions="networkstats-manage",
|
||||||
Func="Navigator::HasNetworkStatsSupport"]
|
Pref="dom.mozNetworkStats.enabled"]
|
||||||
interface MozNetworkStatsInterface {
|
interface MozNetworkStatsInterface {
|
||||||
readonly attribute long type;
|
readonly attribute long type;
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ interface NavigatorStorageUtils {
|
|||||||
|
|
||||||
[NoInterfaceObject]
|
[NoInterfaceObject]
|
||||||
interface NavigatorFeatures {
|
interface NavigatorFeatures {
|
||||||
[Func="Navigator::HasFeatureDetectionSupport"]
|
[CheckPermissions="feature-detection"]
|
||||||
Promise getFeature(DOMString name);
|
Promise getFeature(DOMString name);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -252,10 +252,12 @@ partial interface Navigator {
|
|||||||
boolean mozIsLocallyAvailable(DOMString uri, boolean whenOffline);
|
boolean mozIsLocallyAvailable(DOMString uri, boolean whenOffline);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef MOZ_WEBSMS_BACKEND
|
||||||
partial interface Navigator {
|
partial interface Navigator {
|
||||||
[Func="Navigator::HasMobileMessageSupport"]
|
[CheckPermissions="sms", Pref="dom.sms.enabled"]
|
||||||
readonly attribute MozMobileMessageManager? mozMobileMessage;
|
readonly attribute MozMobileMessageManager? mozMobileMessage;
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
// NetworkInformation
|
// NetworkInformation
|
||||||
partial interface Navigator {
|
partial interface Navigator {
|
||||||
@ -331,7 +333,7 @@ partial interface Navigator {
|
|||||||
#ifdef MOZ_TIME_MANAGER
|
#ifdef MOZ_TIME_MANAGER
|
||||||
// nsIDOMMozNavigatorTime
|
// nsIDOMMozNavigatorTime
|
||||||
partial interface Navigator {
|
partial interface Navigator {
|
||||||
[Throws, Func="Navigator::HasTimeSupport"]
|
[Throws, CheckPermissions="time"]
|
||||||
readonly attribute MozTimeManager mozTime;
|
readonly attribute MozTimeManager mozTime;
|
||||||
};
|
};
|
||||||
#endif // MOZ_TIME_MANAGER
|
#endif // MOZ_TIME_MANAGER
|
||||||
|
Loading…
Reference in New Issue
Block a user