Changeset 171928 in webkit


Ignore:
Timestamp:
Aug 1, 2014 11:22:38 AM (10 years ago)
Author:
mitz@apple.com
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.

Location:
trunk/Source/WebKit2
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r171920 r171928  
     12014-08-01  Dan Bernstein  <mitz@apple.com>
     2
     3        <rdar://problem/17862013> REGRESSION (r169357): Disabling "allow plug-ins" doesn't stick on quit/relaunch
     4        https://bugs.webkit.org/show_bug.cgi?id=135511
     5
     6        Reviewed by Alexey Proskuryakov.
     7
     8        Since the values map in the preferences store doesn’t include values that are equal to the
     9        defaults, we need to update it when a new default is registered.
     10
     11        * UIProcess/WebPreferences.cpp:
     12        (WebKit::WebPreferences::createWithLegacyDefaults): Changed to use new member functions
     13        for registering defaults.
     14        (WebKit::WebPreferences::registerDefaultBoolValueForKey): Added. Sets an override default
     15        in the store, and sets the user default, if there is one, on top of it.
     16        (WebKit::WebPreferences::registerDefaultUInt32ValueForKey): Ditto.
     17        * UIProcess/WebPreferences.h: Declared new member functions for getting the user default
     18        value for a key.
     19
     20        * UIProcess/efl/WebPreferencesEfl.cpp:
     21        (WebKit::WebPreferences::platformGetStringUserValueForKey): Added an implementation that
     22        returns false, because the EFL port doesn’t support persistent user defaults.
     23        (WebKit::WebPreferences::platformGetBoolUserValueForKey): Ditto.
     24        (WebKit::WebPreferences::platformGetUInt32UserValueForKey): Ditto.
     25        (WebKit::WebPreferences::platformGetDoubleUserValueForKey): Ditto.
     26
     27        * UIProcess/gtk/WebPreferencesGtk.cpp:
     28        (WebKit::WebPreferences::platformGetStringUserValueForKey): Ditto for the GTK port.
     29        (WebKit::WebPreferences::platformGetBoolUserValueForKey): Ditto.
     30        (WebKit::WebPreferences::platformGetUInt32UserValueForKey): Ditto.
     31        (WebKit::WebPreferences::platformGetDoubleUserValueForKey): Ditto.
     32
     33        * UIProcess/mac/WebPreferencesMac.mm:
     34        (WebKit::WebPreferences::platformGetStringUserValueForKey): Added. Replaces
     35        setStringValueIfInUserDefaults, on which it is based.
     36        (WebKit::WebPreferences::platformGetBoolUserValueForKey): Similarly for booleans.
     37        (WebKit::WebPreferences::platformGetUInt32UserValueForKey): Similarly for integers.
     38        (WebKit::WebPreferences::platformGetDoubleUserValueForKey): Similarly for doubles.
     39        (WebKit::WebPreferences::platformInitializeStore): Changed to use the above functions.
     40
    1412014-08-01  Brent Fulgham  <bfulgham@apple.com>
    242
  • trunk/Source/WebKit2/UIProcess/WebPreferences.cpp

    r170253 r171928  
    4646{
    4747    RefPtr<WebPreferences> preferences = adoptRef(new WebPreferences(identifier, keyPrefix, globalDebugKeyPrefix));
    48     preferences->m_store.setOverrideDefaultsBoolValueForKey(WebPreferencesKey::javaEnabledKey(), true);
    49     preferences->m_store.setOverrideDefaultsBoolValueForKey(WebPreferencesKey::javaEnabledForLocalFilesKey(), true);
    50     preferences->m_store.setOverrideDefaultsBoolValueForKey(WebPreferencesKey::pluginsEnabledKey(), true);
    51     preferences->m_store.setOverrideDefaultsUInt32ValueForKey(WebPreferencesKey::storageBlockingPolicyKey(), WebCore::SecurityOrigin::AllowAllStorage);
     48    preferences->registerDefaultBoolValueForKey(WebPreferencesKey::javaEnabledKey(), true);
     49    preferences->registerDefaultBoolValueForKey(WebPreferencesKey::javaEnabledForLocalFilesKey(), true);
     50    preferences->registerDefaultBoolValueForKey(WebPreferencesKey::pluginsEnabledKey(), true);
     51    preferences->registerDefaultUInt32ValueForKey(WebPreferencesKey::storageBlockingPolicyKey(), WebCore::SecurityOrigin::AllowAllStorage);
    5252    return preferences.release();
    5353}
     
    193193}
    194194
     195void WebPreferences::registerDefaultBoolValueForKey(const String& key, bool value)
     196{
     197    m_store.setOverrideDefaultsBoolValueForKey(key, value);
     198    bool userValue;
     199    if (platformGetBoolUserValueForKey(key, userValue))
     200        m_store.setBoolValueForKey(key, userValue);
     201}
     202
     203void WebPreferences::registerDefaultUInt32ValueForKey(const String& key, uint32_t value)
     204{
     205    m_store.setOverrideDefaultsUInt32ValueForKey(key, value);
     206    uint32_t userValue;
     207    if (platformGetUInt32UserValueForKey(key, userValue))
     208        m_store.setUInt32ValueForKey(key, userValue);
     209}
     210
    195211} // namespace WebKit
  • trunk/Source/WebKit2/UIProcess/WebPreferences.h

    r170253 r171928  
    9292    void updatePrivateBrowsingValue(bool value);
    9393
     94    void registerDefaultBoolValueForKey(const String&, bool);
     95    void registerDefaultUInt32ValueForKey(const String&, uint32_t);
     96
     97    bool platformGetStringUserValueForKey(const String& key, String& userValue);
     98    bool platformGetBoolUserValueForKey(const String&, bool&);
     99    bool platformGetUInt32UserValueForKey(const String&, uint32_t&);
     100    bool platformGetDoubleUserValueForKey(const String&, double&);
     101
    94102    const String m_identifier;
    95103    const String m_keyPrefix;
  • trunk/Source/WebKit2/UIProcess/efl/WebPreferencesEfl.cpp

    r131825 r171928  
    6161}
    6262
     63bool WebPreferences::platformGetStringUserValueForKey(const String&, String&)
     64{
     65    notImplemented();
     66    return false;
     67}
     68
     69bool WebPreferences::platformGetBoolUserValueForKey(const String&, bool&)
     70{
     71    notImplemented();
     72    return false;
     73}
     74
     75bool WebPreferences::platformGetUInt32UserValueForKey(const String&, uint32_t&)
     76{
     77    notImplemented();
     78    return false;
     79}
     80
     81bool WebPreferences::platformGetDoubleUserValueForKey(const String&, double&)
     82{
     83    notImplemented();
     84    return false;
     85}
     86
    6387} // namespace WebKit
  • trunk/Source/WebKit2/UIProcess/gtk/WebPreferencesGtk.cpp

    r131825 r171928  
    6262}
    6363
     64bool WebPreferences::platformGetStringUserValueForKey(const String&, String&)
     65{
     66    notImplemented();
     67    return false;
     68}
     69
     70bool WebPreferences::platformGetBoolUserValueForKey(const String&, bool&)
     71{
     72    notImplemented();
     73    return false;
     74}
     75
     76bool WebPreferences::platformGetUInt32UserValueForKey(const String&, uint32_t&)
     77{
     78    notImplemented();
     79    return false;
     80}
     81
     82bool WebPreferences::platformGetDoubleUserValueForKey(const String&, double&)
     83{
     84    notImplemented();
     85    return false;
     86}
     87
    6488} // namespace WebKit
  • trunk/Source/WebKit2/UIProcess/mac/WebPreferencesMac.mm

    r170253 r171928  
    4242}
    4343
    44 static void setStringValueIfInUserDefaults(const String& identifier, const String& keyPrefix, const String& key, WebPreferencesStore& store)
     44bool WebPreferences::platformGetStringUserValueForKey(const String& key, String& userValue)
    4545{
    46     id object = [[NSUserDefaults standardUserDefaults] objectForKey:makeKey(identifier, keyPrefix, key)];
     46    if (!m_identifier)
     47        return false;
     48
     49    id object = [[NSUserDefaults standardUserDefaults] objectForKey:makeKey(m_identifier, m_keyPrefix, key)];
    4750    if (!object)
    48         return;
     51        return false;
    4952    if (![object isKindOfClass:[NSString class]])
    50         return;
     53        return false;
    5154
    52     store.setStringValueForKey(key, (NSString *)object);
     55    userValue = (NSString *)object;
     56    return true;
    5357}
    5458
    55 static void setBoolValueIfInUserDefaults(const String& identifier, const String& keyPrefix, const String& key, WebPreferencesStore& store)
     59bool WebPreferences::platformGetBoolUserValueForKey(const String& key, bool& userValue)
    5660{
    57     id object = [[NSUserDefaults standardUserDefaults] objectForKey:makeKey(identifier, keyPrefix, key)];
     61    if (!m_identifier)
     62        return false;
     63
     64    id object = [[NSUserDefaults standardUserDefaults] objectForKey:makeKey(m_identifier, m_keyPrefix, key)];
    5865    if (!object)
    59         return;
     66        return false;
    6067    if (![object respondsToSelector:@selector(boolValue)])
    61         return;
     68        return false;
    6269
    63     store.setBoolValueForKey(key, [object boolValue]);
     70    userValue = [object boolValue];
     71    return true;
    6472}
    6573
    66 static void setUInt32ValueIfInUserDefaults(const String& identifier, const String& keyPrefix, const String& key, WebPreferencesStore& store)
     74bool WebPreferences::platformGetUInt32UserValueForKey(const String& key, uint32_t& userValue)
    6775{
    68     id object = [[NSUserDefaults standardUserDefaults] objectForKey:makeKey(identifier, keyPrefix, key)];
     76    if (!m_identifier)
     77        return false;
     78
     79    id object = [[NSUserDefaults standardUserDefaults] objectForKey:makeKey(m_identifier, m_keyPrefix, key)];
    6980    if (!object)
    70         return;
     81        return false;
    7182    if (![object respondsToSelector:@selector(intValue)])
    72         return;
     83        return false;
    7384
    74     store.setUInt32ValueForKey(key, [object intValue]);
     85    userValue = [object intValue];
     86    return true;
    7587}
    7688
    77 static void setDoubleValueIfInUserDefaults(const String& identifier, const String& keyPrefix, const String& key, WebPreferencesStore& store)
     89bool WebPreferences::platformGetDoubleUserValueForKey(const String& key, double& userValue)
    7890{
    79     id object = [[NSUserDefaults standardUserDefaults] objectForKey:makeKey(identifier, keyPrefix, key)];
     91    if (!m_identifier)
     92        return false;
     93
     94    id object = [[NSUserDefaults standardUserDefaults] objectForKey:makeKey(m_identifier, m_keyPrefix, key)];
    8095    if (!object)
    81         return;
     96        return false;
    8297    if (![object respondsToSelector:@selector(doubleValue)])
    83         return;
     98        return false;
    8499
    85     store.setDoubleValueForKey(key, [object doubleValue]);
     100    userValue = [object doubleValue];
     101    return true;
    86102}
    87 
    88103
    89104static id debugUserDefaultsValue(NSString *identifier, NSString *keyPrefix, NSString *globalDebugKeyPrefix, NSString *key)
     
    130145
    131146#define INITIALIZE_PREFERENCE_FROM_NSUSERDEFAULTS(KeyUpper, KeyLower, TypeName, Type, DefaultValue) \
    132     set##TypeName##ValueIfInUserDefaults(m_identifier, m_keyPrefix, WebPreferencesKey::KeyLower##Key(), m_store);
     147    Type user##KeyUpper##Value; \
     148    if (platformGet##TypeName##UserValueForKey(WebPreferencesKey::KeyLower##Key(), user##KeyUpper##Value)) \
     149        m_store.set##TypeName##ValueForKey(WebPreferencesKey::KeyLower##Key(), user##KeyUpper##Value);
    133150
    134151    FOR_EACH_WEBKIT_PREFERENCE(INITIALIZE_PREFERENCE_FROM_NSUSERDEFAULTS)
Note: See TracChangeset for help on using the changeset viewer.