NS_IMETHOD Handle(const nsAString& aName, const jsval& aResult) { MOZ_ASSERT(NS_IsMainThread()); // The geolocation is enabled by default: bool value = true; if (aResult.isBoolean()) { value = aResult.toBoolean(); } MozSettingValue(value); return NS_OK; }
NS_DECL_ISUPPORTS NS_IMETHOD Handle(const nsAString& aName, const jsval& aResult, JSContext* aCx) { MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(gBluetoothService); if (!aResult.isBoolean()) { NS_WARNING("Setting for '" BLUETOOTH_ENABLED_SETTING "' is not a boolean!"); return NS_OK; } return aResult.toBoolean() ? gBluetoothService->Start() : NS_OK; }
NS_DECL_ISUPPORTS NS_IMETHOD Handle(const nsAString& aName, const jsval& aResult) { MOZ_ASSERT(NS_IsMainThread()); if (!aResult.isBoolean()) { NS_WARNING("Setting for '" BLUETOOTH_ENABLED_SETTING "' is not a boolean!"); return NS_OK; } // It is theoretically possible to shut down before the first settings check // has completed (though extremely unlikely). if (gBluetoothService) { return gBluetoothService->HandleStartupSettingsCheck(aResult.toBoolean()); } return NS_OK; }
bool JavaScriptShared::toVariant(JSContext *cx, jsval from, JSVariant *to) { switch (JS_TypeOfValue(cx, from)) { case JSTYPE_VOID: *to = void_t(); return true; case JSTYPE_NULL: { *to = uint64_t(0); return true; } case JSTYPE_OBJECT: case JSTYPE_FUNCTION: { JSObject *obj = from.toObjectOrNull(); if (!obj) { JS_ASSERT(from == JSVAL_NULL); *to = uint64_t(0); return true; } if (xpc_JSObjectIsID(cx, obj)) { JSIID iid; const nsID *id = xpc_JSObjectToID(cx, obj); ConvertID(*id, &iid); *to = iid; return true; } ObjectId id; if (!makeId(cx, obj, &id)) return false; *to = uint64_t(id); return true; } case JSTYPE_STRING: { nsDependentJSString dep; if (!dep.init(cx, from)) return false; *to = dep; return true; } case JSTYPE_NUMBER: if (JSVAL_IS_INT(from)) *to = double(from.toInt32()); else *to = from.toDouble(); return true; case JSTYPE_BOOLEAN: *to = from.toBoolean(); return true; default: MOZ_ASSERT(false); return false; } }