Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support for nsPrefBranch::{get,set}StringPref() #901

Merged
merged 1 commit into from
Nov 19, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions extension/lib/prefs.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ get = (branch, key) ->
when branch.PREF_INT
branch.getIntPref(key)
when branch.PREF_STRING
branch.getComplexValue(key, Ci.nsISupportsString).data
if branch.getStringPref
branch.getStringPref(key)
else
branch.getComplexValue(key, Ci.nsISupportsString).data

set = (branch, key, value) ->
switch typeof value
Expand All @@ -32,10 +35,13 @@ set = (branch, key, value) ->
when 'number'
branch.setIntPref(key, value) # `value` will be `Math.floor`ed.
when 'string'
str = Cc['@mozilla.org/supports-string;1']
.createInstance(Ci.nsISupportsString)
str.data = value
branch.setComplexValue(key, Ci.nsISupportsString, str)
if branch.setStringPref
branch.setStringPref(key, value)
else
str = Cc['@mozilla.org/supports-string;1']
.createInstance(Ci.nsISupportsString)
str.data = value
branch.setComplexValue(key, Ci.nsISupportsString, str)
else
if value == null
branch.clearUserPref(key)
Expand Down