first pass at adding infra for registerDefaults
This commit is contained in:
parent
6af18895c3
commit
f82086e6d3
2 changed files with 19 additions and 0 deletions
|
@ -73,6 +73,7 @@ class SystemPreferences : public mate::EventEmitter<SystemPreferences>
|
||||||
void UnsubscribeLocalNotification(int request_id);
|
void UnsubscribeLocalNotification(int request_id);
|
||||||
v8::Local<v8::Value> GetUserDefault(const std::string& name,
|
v8::Local<v8::Value> GetUserDefault(const std::string& name,
|
||||||
const std::string& type);
|
const std::string& type);
|
||||||
|
void registerDefaults(const base::DictionaryValue& defaults);
|
||||||
void SetUserDefault(const std::string& name,
|
void SetUserDefault(const std::string& name,
|
||||||
const std::string& type,
|
const std::string& type,
|
||||||
mate::Arguments* args);
|
mate::Arguments* args);
|
||||||
|
|
|
@ -144,6 +144,24 @@ v8::Local<v8::Value> SystemPreferences::GetUserDefault(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SystemPreferences::RegisterDefaults(const base::DictionaryValue& defaults) {
|
||||||
|
NSString *userDefaultsValuesPath;
|
||||||
|
NSDictionary *userDefaultsValuesDict;
|
||||||
|
NSDictionary *initialValuesDict;
|
||||||
|
NSArray *resettableUserDefaultsKeys;
|
||||||
|
|
||||||
|
userDefaultsValuesPath=[[NSBundle mainBundle] pathForResource:@"UserDefaults"
|
||||||
|
ofType:@"plist"];
|
||||||
|
userDefaultsValuesDict=[NSDictionary dictionaryWithContentsOfFile:userDefaultsValuesPath];
|
||||||
|
|
||||||
|
[[NSUserDefaults standardUserDefaults] registerDefaults:userDefaultsValuesDict];
|
||||||
|
|
||||||
|
resettableUserDefaultsKeys=[NSArray arrayWithObjects:@"Value1",@"Value2",@"Value3",nil];
|
||||||
|
initialValuesDict=[userDefaultsValuesDict dictionaryWithValuesForKeys:resettableUserDefaultsKeys];
|
||||||
|
|
||||||
|
[[NSUserDefaultsController sharedUserDefaultsController] setInitialValues:initialValuesDict];
|
||||||
|
}
|
||||||
|
|
||||||
void SystemPreferences::SetUserDefault(const std::string& name,
|
void SystemPreferences::SetUserDefault(const std::string& name,
|
||||||
const std::string& type,
|
const std::string& type,
|
||||||
mate::Arguments* args) {
|
mate::Arguments* args) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue