Bug 1255461 - Notify pref handlers when pseudo-prefs change; r=snorp a=ritu

When "pseudo-prefs" change, the Java side expects the same change
notification as regular prefs.

MozReview-Commit-ID: GKVJlMJJ7OX
This commit is contained in:
Jim Chen 2016-03-18 15:18:51 -04:00
parent b72c12cd79
commit 378aaa58d6
2 changed files with 11 additions and 5 deletions

View File

@ -44,7 +44,6 @@ var MasterPassword = {
else if (status == Ci.nsIPKCS11Slot.SLOT_READY)
token.changePassword("", aPassword);
BrowserApp.notifyPrefObservers(this.pref);
return true;
} catch(e) {
dump("MasterPassword.setPassword: " + e);
@ -57,7 +56,6 @@ var MasterPassword = {
let token = this._pk11DB.getInternalKeyToken();
if (token.checkPassword(aOldPassword)) {
token.changePassword(aOldPassword, "");
BrowserApp.notifyPrefObservers(this.pref);
return true;
}
} catch(e) {

View File

@ -27,7 +27,7 @@ class PrefsHelper
static bool GetVariantPref(nsIObserverService* aObsServ,
nsIWritableVariant* aVariant,
jni::Object::Param aPrefHandler,
jni::String::LocalRef& aPrefName)
const jni::String::LocalRef& aPrefName)
{
if (NS_FAILED(aObsServ->NotifyObservers(aVariant, "android-get-pref",
aPrefName->ToString().get()))) {
@ -71,8 +71,13 @@ class PrefsHelper
jni::StringParam(strVal, aPrefName.Env()) :
jni::StringParam(nullptr);
widget::PrefsHelper::CallPrefHandler(
aPrefHandler, type, aPrefName, boolVal, intVal, jstrVal);
if (aPrefHandler) {
widget::PrefsHelper::CallPrefHandler(
aPrefHandler, type, aPrefName, boolVal, intVal, jstrVal);
} else {
widget::PrefsHelper::OnPrefChange(
aPrefName, type, boolVal, intVal, jstrVal);
}
return true;
}
@ -213,6 +218,9 @@ public:
nsCOMPtr<nsIWritableVariant> value = new nsVariant();
if (obsServ && SetVariantPref(obsServ, value, aPrefName, aFlush,
aType, aBoolVal, aIntVal, aStrVal)) {
// The "pref" has changed; send a notification.
GetVariantPref(obsServ, value, nullptr,
jni::String::LocalRef(aPrefName));
return;
}
}