Add WebPreferences::setValueForKey
authoraroben@apple.com <aroben@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 1 Mar 2008 00:13:29 +0000 (00:13 +0000)
committeraroben@apple.com <aroben@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 1 Mar 2008 00:13:29 +0000 (00:13 +0000)
        This is just a small refactoring of some duplicated logic into a
        shared method.

        Reviewed by Sam.

        * WebPreferences.cpp:
        (WebPreferences::setValueForKey): Added.
        (WebPreferences::setStringValue): Call setValueForKey.
        (WebPreferences::setIntegerValue): Ditto.
        (WebPreferences::setBoolValue): Ditto.
        (WebPreferences::setLongLongValue): Ditto.
        * WebPreferences.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@30682 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebKit/win/ChangeLog
WebKit/win/WebPreferences.cpp
WebKit/win/WebPreferences.h

index bb523e77fe759fa9c4180dae344d9b329519f3ed..da034b617170c80ad6f815b8dcb83faa66ce4f9d 100644 (file)
@@ -1,3 +1,20 @@
+2008-02-27  Adam Roben  <aroben@apple.com>
+
+        Add WebPreferences::setValueForKey
+
+        This is just a small refactoring of some duplicated logic into a
+        shared method.
+
+        Reviewed by Sam.
+
+        * WebPreferences.cpp:
+        (WebPreferences::setValueForKey): Added.
+        (WebPreferences::setStringValue): Call setValueForKey.
+        (WebPreferences::setIntegerValue): Ditto.
+        (WebPreferences::setBoolValue): Ditto.
+        (WebPreferences::setLongLongValue): Ditto.
+        * WebPreferences.h:
+
 2008-02-27  Adam Roben  <aroben@apple.com>
 
         Remove WebPreferences' static members
 2008-02-27  Adam Roben  <aroben@apple.com>
 
         Remove WebPreferences' static members
index 454b7951035f07ba6693bab55056b60426e085e6..ceedc6711914a1c10461ede08b6856a16d3b046e 100644 (file)
@@ -206,6 +206,13 @@ const void* WebPreferences::valueForKey(CFStringRef key)
     return value;
 }
 
     return value;
 }
 
+void WebPreferences::setValueForKey(CFStringRef key, CFPropertyListRef value)
+{
+    CFDictionarySetValue(m_privatePrefs.get(), key, value);
+    if (m_autoSaves)
+        save();
+}
+
 BSTR WebPreferences::stringValueForKey(CFStringRef key)
 {
     CFStringRef str = (CFStringRef)valueForKey(key);
 BSTR WebPreferences::stringValueForKey(CFStringRef key)
 {
     CFStringRef str = (CFStringRef)valueForKey(key);
@@ -311,9 +318,7 @@ void WebPreferences::setStringValue(CFStringRef key, LPCTSTR value)
     
     RetainPtr<CFStringRef> valueRef(AdoptCF,
         CFStringCreateWithCharactersNoCopy(0, (UniChar*)_wcsdup(value), (CFIndex)_tcslen(value), kCFAllocatorMalloc));
     
     RetainPtr<CFStringRef> valueRef(AdoptCF,
         CFStringCreateWithCharactersNoCopy(0, (UniChar*)_wcsdup(value), (CFIndex)_tcslen(value), kCFAllocatorMalloc));
-    CFDictionarySetValue(m_privatePrefs.get(), key, valueRef.get());
-    if (m_autoSaves)
-        save();
+    setValueForKey(key, valueRef.get());
 
     postPreferencesChangesNotification();
 }
 
     postPreferencesChangesNotification();
 }
@@ -324,9 +329,7 @@ void WebPreferences::setIntegerValue(CFStringRef key, int value)
         return;
 
     RetainPtr<CFNumberRef> valueRef(AdoptCF, CFNumberCreate(0, kCFNumberSInt32Type, &value));
         return;
 
     RetainPtr<CFNumberRef> valueRef(AdoptCF, CFNumberCreate(0, kCFNumberSInt32Type, &value));
-    CFDictionarySetValue(m_privatePrefs.get(), key, valueRef.get());
-    if (m_autoSaves)
-        save();
+    setValueForKey(key, valueRef.get());
 
     postPreferencesChangesNotification();
 }
 
     postPreferencesChangesNotification();
 }
@@ -336,9 +339,7 @@ void WebPreferences::setBoolValue(CFStringRef key, BOOL value)
     if (boolValueForKey(key) == value)
         return;
 
     if (boolValueForKey(key) == value)
         return;
 
-    CFDictionarySetValue(m_privatePrefs.get(), key, value ? kCFBooleanTrue : kCFBooleanFalse);
-    if (m_autoSaves)
-        save();
+    setValueForKey(key, value ? kCFBooleanTrue : kCFBooleanFalse);
 
     postPreferencesChangesNotification();
 }
 
     postPreferencesChangesNotification();
 }
@@ -349,9 +350,7 @@ void WebPreferences::setLongLongValue(CFStringRef key, LONGLONG value)
         return;
 
     RetainPtr<CFNumberRef> valueRef(AdoptCF, CFNumberCreate(0, kCFNumberLongLongType, &value));
         return;
 
     RetainPtr<CFNumberRef> valueRef(AdoptCF, CFNumberCreate(0, kCFNumberLongLongType, &value));
-    CFDictionarySetValue(m_privatePrefs.get(), key, valueRef.get());
-    if (m_autoSaves)
-        save();
+    setValueForKey(key, valueRef.get());
 
     postPreferencesChangesNotification();
 }
 
     postPreferencesChangesNotification();
 }
index 7716269c0a244683e2c0d307019d4106cfc13f2d..aa74f2fac4daf7cefb57dad97a9c999f529e26af 100644 (file)
@@ -315,6 +315,7 @@ public:
     HRESULT postPreferencesChangesNotification();
 
 protected:
     HRESULT postPreferencesChangesNotification();
 
 protected:
+    void setValueForKey(CFStringRef key, CFPropertyListRef value);
     const void* valueForKey(CFStringRef key);
     BSTR stringValueForKey(CFStringRef key);
     int integerValueForKey(CFStringRef key);
     const void* valueForKey(CFStringRef key);
     BSTR stringValueForKey(CFStringRef key);
     int integerValueForKey(CFStringRef key);