Title: [171928] trunk/Source/WebKit2
Revision
171928
Author
m...@apple.com
Date
2014-08-01 11:22:38 -0700 (Fri, 01 Aug 2014)

Log Message

<rdar://problem/17862013> REGRESSION (r169357): Disabling "allow plug-ins" doesn't stick on quit/relaunch
https://bugs.webkit.org/show_bug.cgi?id=135511

Reviewed by Alexey Proskuryakov.

Since the values map in the preferences store doesn’t include values that are equal to the
defaults, we need to update it when a new default is registered.

* UIProcess/WebPreferences.cpp:
(WebKit::WebPreferences::createWithLegacyDefaults): Changed to use new member functions
for registering defaults.
(WebKit::WebPreferences::registerDefaultBoolValueForKey): Added. Sets an override default
in the store, and sets the user default, if there is one, on top of it.
(WebKit::WebPreferences::registerDefaultUInt32ValueForKey): Ditto.
* UIProcess/WebPreferences.h: Declared new member functions for getting the user default
value for a key.

* UIProcess/efl/WebPreferencesEfl.cpp:
(WebKit::WebPreferences::platformGetStringUserValueForKey): Added an implementation that
returns false, because the EFL port doesn’t support persistent user defaults.
(WebKit::WebPreferences::platformGetBoolUserValueForKey): Ditto.
(WebKit::WebPreferences::platformGetUInt32UserValueForKey): Ditto.
(WebKit::WebPreferences::platformGetDoubleUserValueForKey): Ditto.

* UIProcess/gtk/WebPreferencesGtk.cpp:
(WebKit::WebPreferences::platformGetStringUserValueForKey): Ditto for the GTK port.
(WebKit::WebPreferences::platformGetBoolUserValueForKey): Ditto.
(WebKit::WebPreferences::platformGetUInt32UserValueForKey): Ditto.
(WebKit::WebPreferences::platformGetDoubleUserValueForKey): Ditto.

* UIProcess/mac/WebPreferencesMac.mm:
(WebKit::WebPreferences::platformGetStringUserValueForKey): Added. Replaces
setStringValueIfInUserDefaults, on which it is based.
(WebKit::WebPreferences::platformGetBoolUserValueForKey): Similarly for booleans.
(WebKit::WebPreferences::platformGetUInt32UserValueForKey): Similarly for integers.
(WebKit::WebPreferences::platformGetDoubleUserValueForKey): Similarly for doubles.
(WebKit::WebPreferences::platformInitializeStore): Changed to use the above functions.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (171927 => 171928)


--- trunk/Source/WebKit2/ChangeLog	2014-08-01 18:21:59 UTC (rev 171927)
+++ trunk/Source/WebKit2/ChangeLog	2014-08-01 18:22:38 UTC (rev 171928)
@@ -1,3 +1,43 @@
+2014-08-01  Dan Bernstein  <m...@apple.com>
+
+        <rdar://problem/17862013> REGRESSION (r169357): Disabling "allow plug-ins" doesn't stick on quit/relaunch
+        https://bugs.webkit.org/show_bug.cgi?id=135511
+
+        Reviewed by Alexey Proskuryakov.
+
+        Since the values map in the preferences store doesn’t include values that are equal to the
+        defaults, we need to update it when a new default is registered.
+
+        * UIProcess/WebPreferences.cpp:
+        (WebKit::WebPreferences::createWithLegacyDefaults): Changed to use new member functions
+        for registering defaults.
+        (WebKit::WebPreferences::registerDefaultBoolValueForKey): Added. Sets an override default
+        in the store, and sets the user default, if there is one, on top of it.
+        (WebKit::WebPreferences::registerDefaultUInt32ValueForKey): Ditto.
+        * UIProcess/WebPreferences.h: Declared new member functions for getting the user default
+        value for a key.
+
+        * UIProcess/efl/WebPreferencesEfl.cpp:
+        (WebKit::WebPreferences::platformGetStringUserValueForKey): Added an implementation that
+        returns false, because the EFL port doesn’t support persistent user defaults.
+        (WebKit::WebPreferences::platformGetBoolUserValueForKey): Ditto.
+        (WebKit::WebPreferences::platformGetUInt32UserValueForKey): Ditto.
+        (WebKit::WebPreferences::platformGetDoubleUserValueForKey): Ditto.
+
+        * UIProcess/gtk/WebPreferencesGtk.cpp:
+        (WebKit::WebPreferences::platformGetStringUserValueForKey): Ditto for the GTK port.
+        (WebKit::WebPreferences::platformGetBoolUserValueForKey): Ditto.
+        (WebKit::WebPreferences::platformGetUInt32UserValueForKey): Ditto.
+        (WebKit::WebPreferences::platformGetDoubleUserValueForKey): Ditto.
+
+        * UIProcess/mac/WebPreferencesMac.mm:
+        (WebKit::WebPreferences::platformGetStringUserValueForKey): Added. Replaces
+        setStringValueIfInUserDefaults, on which it is based.
+        (WebKit::WebPreferences::platformGetBoolUserValueForKey): Similarly for booleans.
+        (WebKit::WebPreferences::platformGetUInt32UserValueForKey): Similarly for integers.
+        (WebKit::WebPreferences::platformGetDoubleUserValueForKey): Similarly for doubles.
+        (WebKit::WebPreferences::platformInitializeStore): Changed to use the above functions.
+
 2014-08-01  Brent Fulgham  <bfulg...@apple.com>
 
         [Mac] Fullscreen mode for some applications shows only a black screen.

Modified: trunk/Source/WebKit2/UIProcess/WebPreferences.cpp (171927 => 171928)


--- trunk/Source/WebKit2/UIProcess/WebPreferences.cpp	2014-08-01 18:21:59 UTC (rev 171927)
+++ trunk/Source/WebKit2/UIProcess/WebPreferences.cpp	2014-08-01 18:22:38 UTC (rev 171928)
@@ -45,10 +45,10 @@
 PassRefPtr<WebPreferences> WebPreferences::createWithLegacyDefaults(const String& identifier, const String& keyPrefix, const String& globalDebugKeyPrefix)
 {
     RefPtr<WebPreferences> preferences = adoptRef(new WebPreferences(identifier, keyPrefix, globalDebugKeyPrefix));
-    preferences->m_store.setOverrideDefaultsBoolValueForKey(WebPreferencesKey::javaEnabledKey(), true);
-    preferences->m_store.setOverrideDefaultsBoolValueForKey(WebPreferencesKey::javaEnabledForLocalFilesKey(), true);
-    preferences->m_store.setOverrideDefaultsBoolValueForKey(WebPreferencesKey::pluginsEnabledKey(), true);
-    preferences->m_store.setOverrideDefaultsUInt32ValueForKey(WebPreferencesKey::storageBlockingPolicyKey(), WebCore::SecurityOrigin::AllowAllStorage);
+    preferences->registerDefaultBoolValueForKey(WebPreferencesKey::javaEnabledKey(), true);
+    preferences->registerDefaultBoolValueForKey(WebPreferencesKey::javaEnabledForLocalFilesKey(), true);
+    preferences->registerDefaultBoolValueForKey(WebPreferencesKey::pluginsEnabledKey(), true);
+    preferences->registerDefaultUInt32ValueForKey(WebPreferencesKey::storageBlockingPolicyKey(), WebCore::SecurityOrigin::AllowAllStorage);
     return preferences.release();
 }
 
@@ -192,4 +192,20 @@
     return privateBrowsingPageCount;
 }
 
+void WebPreferences::registerDefaultBoolValueForKey(const String& key, bool value)
+{
+    m_store.setOverrideDefaultsBoolValueForKey(key, value);
+    bool userValue;
+    if (platformGetBoolUserValueForKey(key, userValue))
+        m_store.setBoolValueForKey(key, userValue);
+}
+
+void WebPreferences::registerDefaultUInt32ValueForKey(const String& key, uint32_t value)
+{
+    m_store.setOverrideDefaultsUInt32ValueForKey(key, value);
+    uint32_t userValue;
+    if (platformGetUInt32UserValueForKey(key, userValue))
+        m_store.setUInt32ValueForKey(key, userValue);
+}
+
 } // namespace WebKit

Modified: trunk/Source/WebKit2/UIProcess/WebPreferences.h (171927 => 171928)


--- trunk/Source/WebKit2/UIProcess/WebPreferences.h	2014-08-01 18:21:59 UTC (rev 171927)
+++ trunk/Source/WebKit2/UIProcess/WebPreferences.h	2014-08-01 18:22:38 UTC (rev 171928)
@@ -91,6 +91,14 @@
 
     void updatePrivateBrowsingValue(bool value);
 
+    void registerDefaultBoolValueForKey(const String&, bool);
+    void registerDefaultUInt32ValueForKey(const String&, uint32_t);
+
+    bool platformGetStringUserValueForKey(const String& key, String& userValue);
+    bool platformGetBoolUserValueForKey(const String&, bool&);
+    bool platformGetUInt32UserValueForKey(const String&, uint32_t&);
+    bool platformGetDoubleUserValueForKey(const String&, double&);
+
     const String m_identifier;
     const String m_keyPrefix;
     const String m_globalDebugKeyPrefix;

Modified: trunk/Source/WebKit2/UIProcess/efl/WebPreferencesEfl.cpp (171927 => 171928)


--- trunk/Source/WebKit2/UIProcess/efl/WebPreferencesEfl.cpp	2014-08-01 18:21:59 UTC (rev 171927)
+++ trunk/Source/WebKit2/UIProcess/efl/WebPreferencesEfl.cpp	2014-08-01 18:22:38 UTC (rev 171928)
@@ -60,4 +60,28 @@
     notImplemented();
 }
 
+bool WebPreferences::platformGetStringUserValueForKey(const String&, String&)
+{
+    notImplemented();
+    return false;
+}
+
+bool WebPreferences::platformGetBoolUserValueForKey(const String&, bool&)
+{
+    notImplemented();
+    return false;
+}
+
+bool WebPreferences::platformGetUInt32UserValueForKey(const String&, uint32_t&)
+{
+    notImplemented();
+    return false;
+}
+
+bool WebPreferences::platformGetDoubleUserValueForKey(const String&, double&)
+{
+    notImplemented();
+    return false;
+}
+
 } // namespace WebKit

Modified: trunk/Source/WebKit2/UIProcess/gtk/WebPreferencesGtk.cpp (171927 => 171928)


--- trunk/Source/WebKit2/UIProcess/gtk/WebPreferencesGtk.cpp	2014-08-01 18:21:59 UTC (rev 171927)
+++ trunk/Source/WebKit2/UIProcess/gtk/WebPreferencesGtk.cpp	2014-08-01 18:22:38 UTC (rev 171928)
@@ -61,4 +61,28 @@
     notImplemented();
 }
 
+bool WebPreferences::platformGetStringUserValueForKey(const String&, String&)
+{
+    notImplemented();
+    return false;
+}
+
+bool WebPreferences::platformGetBoolUserValueForKey(const String&, bool&)
+{
+    notImplemented();
+    return false;
+}
+
+bool WebPreferences::platformGetUInt32UserValueForKey(const String&, uint32_t&)
+{
+    notImplemented();
+    return false;
+}
+
+bool WebPreferences::platformGetDoubleUserValueForKey(const String&, double&)
+{
+    notImplemented();
+    return false;
+}
+
 } // namespace WebKit

Modified: trunk/Source/WebKit2/UIProcess/mac/WebPreferencesMac.mm (171927 => 171928)


--- trunk/Source/WebKit2/UIProcess/mac/WebPreferencesMac.mm	2014-08-01 18:21:59 UTC (rev 171927)
+++ trunk/Source/WebKit2/UIProcess/mac/WebPreferencesMac.mm	2014-08-01 18:22:38 UTC (rev 171928)
@@ -41,51 +41,66 @@
     return [NSString stringWithFormat:@"%@%@%@", identifier, keyPrefix, key];
 }
 
-static void setStringValueIfInUserDefaults(const String& identifier, const String& keyPrefix, const String& key, WebPreferencesStore& store)
+bool WebPreferences::platformGetStringUserValueForKey(const String& key, String& userValue)
 {
-    id object = [[NSUserDefaults standardUserDefaults] objectForKey:makeKey(identifier, keyPrefix, key)];
+    if (!m_identifier)
+        return false;
+
+    id object = [[NSUserDefaults standardUserDefaults] objectForKey:makeKey(m_identifier, m_keyPrefix, key)];
     if (!object)
-        return;
+        return false;
     if (![object isKindOfClass:[NSString class]])
-        return;
+        return false;
 
-    store.setStringValueForKey(key, (NSString *)object);
+    userValue = (NSString *)object;
+    return true;
 }
 
-static void setBoolValueIfInUserDefaults(const String& identifier, const String& keyPrefix, const String& key, WebPreferencesStore& store)
+bool WebPreferences::platformGetBoolUserValueForKey(const String& key, bool& userValue)
 {
-    id object = [[NSUserDefaults standardUserDefaults] objectForKey:makeKey(identifier, keyPrefix, key)];
+    if (!m_identifier)
+        return false;
+
+    id object = [[NSUserDefaults standardUserDefaults] objectForKey:makeKey(m_identifier, m_keyPrefix, key)];
     if (!object)
-        return;
+        return false;
     if (![object respondsToSelector:@selector(boolValue)])
-        return;
+        return false;
 
-    store.setBoolValueForKey(key, [object boolValue]);
+    userValue = [object boolValue];
+    return true;
 }
 
-static void setUInt32ValueIfInUserDefaults(const String& identifier, const String& keyPrefix, const String& key, WebPreferencesStore& store)
+bool WebPreferences::platformGetUInt32UserValueForKey(const String& key, uint32_t& userValue)
 {
-    id object = [[NSUserDefaults standardUserDefaults] objectForKey:makeKey(identifier, keyPrefix, key)];
+    if (!m_identifier)
+        return false;
+
+    id object = [[NSUserDefaults standardUserDefaults] objectForKey:makeKey(m_identifier, m_keyPrefix, key)];
     if (!object)
-        return;
+        return false;
     if (![object respondsToSelector:@selector(intValue)])
-        return;
+        return false;
 
-    store.setUInt32ValueForKey(key, [object intValue]);
+    userValue = [object intValue];
+    return true;
 }
 
-static void setDoubleValueIfInUserDefaults(const String& identifier, const String& keyPrefix, const String& key, WebPreferencesStore& store)
+bool WebPreferences::platformGetDoubleUserValueForKey(const String& key, double& userValue)
 {
-    id object = [[NSUserDefaults standardUserDefaults] objectForKey:makeKey(identifier, keyPrefix, key)];
+    if (!m_identifier)
+        return false;
+
+    id object = [[NSUserDefaults standardUserDefaults] objectForKey:makeKey(m_identifier, m_keyPrefix, key)];
     if (!object)
-        return;
+        return false;
     if (![object respondsToSelector:@selector(doubleValue)])
-        return;
+        return false;
 
-    store.setDoubleValueForKey(key, [object doubleValue]);
+    userValue = [object doubleValue];
+    return true;
 }
 
-
 static id debugUserDefaultsValue(NSString *identifier, NSString *keyPrefix, NSString *globalDebugKeyPrefix, NSString *key)
 {
     ASSERT(keyPrefix);
@@ -129,7 +144,9 @@
         return;
 
 #define INITIALIZE_PREFERENCE_FROM_NSUSERDEFAULTS(KeyUpper, KeyLower, TypeName, Type, DefaultValue) \
-    set##TypeName##ValueIfInUserDefaults(m_identifier, m_keyPrefix, WebPreferencesKey::KeyLower##Key(), m_store);
+    Type user##KeyUpper##Value; \
+    if (platformGet##TypeName##UserValueForKey(WebPreferencesKey::KeyLower##Key(), user##KeyUpper##Value)) \
+        m_store.set##TypeName##ValueForKey(WebPreferencesKey::KeyLower##Key(), user##KeyUpper##Value);
 
     FOR_EACH_WEBKIT_PREFERENCE(INITIALIZE_PREFERENCE_FROM_NSUSERDEFAULTS)
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to