From 1ccad4a7e96e9f53a00393def19aaa81c160f088 Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Sun, 10 Dec 2017 11:04:05 -0500 Subject: [PATCH] fix capitalization and clean logic --- .../browser/api/atom_api_system_preferences.h | 2 +- .../api/atom_api_system_preferences_mac.mm | 20 +++++-------------- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/atom/browser/api/atom_api_system_preferences.h b/atom/browser/api/atom_api_system_preferences.h index 658f6eebb402..872f822ed74b 100644 --- a/atom/browser/api/atom_api_system_preferences.h +++ b/atom/browser/api/atom_api_system_preferences.h @@ -73,7 +73,7 @@ class SystemPreferences : public mate::EventEmitter void UnsubscribeLocalNotification(int request_id); v8::Local GetUserDefault(const std::string& name, const std::string& type); - void registerDefaults(const base::DictionaryValue& defaults); + void RegisterDefaults(const base::DictionaryValue& defaults); void SetUserDefault(const std::string& name, const std::string& type, mate::Arguments* args); diff --git a/atom/browser/api/atom_api_system_preferences_mac.mm b/atom/browser/api/atom_api_system_preferences_mac.mm index 1317b3026e2b..8f1df7746ff9 100644 --- a/atom/browser/api/atom_api_system_preferences_mac.mm +++ b/atom/browser/api/atom_api_system_preferences_mac.mm @@ -145,21 +145,11 @@ v8::Local 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]; + if (NSDictionary* defaultsDict = DictionaryValueToNSDictionary(defaults)) { + [[NSUserDefaults standardUserDefaults] registerDefaults:defaultsDict]; + } else { + defaults->ThrowError("Unable to parse userDefaults"); + } } void SystemPreferences::SetUserDefault(const std::string& name,