fix capitalization and clean logic

This commit is contained in:
Shelley Vohr 2017-12-10 11:04:05 -05:00
parent f82086e6d3
commit 1ccad4a7e9
No known key found for this signature in database
GPG key ID: F13993A75599653C
2 changed files with 6 additions and 16 deletions

View file

@ -73,7 +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 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);

View file

@ -145,21 +145,11 @@ v8::Local<v8::Value> SystemPreferences::GetUserDefault(
} }
void SystemPreferences::RegisterDefaults(const base::DictionaryValue& defaults) { void SystemPreferences::RegisterDefaults(const base::DictionaryValue& defaults) {
NSString *userDefaultsValuesPath; if (NSDictionary* defaultsDict = DictionaryValueToNSDictionary(defaults)) {
NSDictionary *userDefaultsValuesDict; [[NSUserDefaults standardUserDefaults] registerDefaults:defaultsDict];
NSDictionary *initialValuesDict; } else {
NSArray *resettableUserDefaultsKeys; defaults->ThrowError("Unable to parse userDefaults");
}
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,