[WebKit2] Add better default preferences while keeping backward compatibility for...
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 26 May 2014 18:01:45 +0000 (18:01 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 26 May 2014 18:01:45 +0000 (18:01 +0000)
https://bugs.webkit.org/show_bug.cgi?id=133289

Reviewed by Anders Carlsson.

* Shared/WebPreferencesStore.h:
Change a few defaults:
- PluginsEnabled -> false
- JavaEnabled -> false
- JavaEnabledForLocalFiles -> false
- StorageBlockingPolicy -> BlockThirdPartyStorage

* UIProcess/API/C/WKPreferences.cpp:
(WKPreferencesCreate):
(WKPreferencesCreateWithIdentifier):
* UIProcess/WebPageGroup.cpp:
(WebKit::WebPageGroup::WebPageGroup):
Switch to using WebPreferences::createWithLegacyDefaults().

* UIProcess/WebPreferences.cpp:
(WebKit::WebPreferences::create):
(WebKit::WebPreferences::createWithLegacyDefaults):
* UIProcess/WebPreferences.h:
Move create functions to the cpp file and add createWithLegacyDefaults() which keeps
the old defaults;

* UIProcess/API/C/WKPreferencesRef.h:
Fix the comment.

* UIProcess/API/Cocoa/WKPreferences.h:
Update the comment to reflect the new defaults.

* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::updatePreferences):
Unconditionally set setShouldDispatchJavaScriptWindowOnErrorEvents() to true. This setting only
exists for legacy WebKit.

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

Source/WebKit2/ChangeLog
Source/WebKit2/Shared/WebPreferencesStore.h
Source/WebKit2/UIProcess/API/C/WKPreferences.cpp
Source/WebKit2/UIProcess/API/C/WKPreferencesRef.h
Source/WebKit2/UIProcess/API/Cocoa/WKPreferences.h
Source/WebKit2/UIProcess/WebPageGroup.cpp
Source/WebKit2/UIProcess/WebPreferences.cpp
Source/WebKit2/UIProcess/WebPreferences.h
Source/WebKit2/WebProcess/WebPage/WebPage.cpp

index 095d17c..d4db1e4 100644 (file)
@@ -1,3 +1,42 @@
+2014-05-26  Sam Weinig  <sam@webkit.org>
+
+        [WebKit2] Add better default preferences while keeping backward compatibility for the C-SPI
+        https://bugs.webkit.org/show_bug.cgi?id=133289
+
+        Reviewed by Anders Carlsson.
+
+        * Shared/WebPreferencesStore.h:
+        Change a few defaults:
+        - PluginsEnabled -> false
+        - JavaEnabled -> false
+        - JavaEnabledForLocalFiles -> false
+        - StorageBlockingPolicy -> BlockThirdPartyStorage
+
+        * UIProcess/API/C/WKPreferences.cpp:
+        (WKPreferencesCreate):
+        (WKPreferencesCreateWithIdentifier):
+        * UIProcess/WebPageGroup.cpp:
+        (WebKit::WebPageGroup::WebPageGroup):
+        Switch to using WebPreferences::createWithLegacyDefaults().
+
+        * UIProcess/WebPreferences.cpp:
+        (WebKit::WebPreferences::create):
+        (WebKit::WebPreferences::createWithLegacyDefaults):
+        * UIProcess/WebPreferences.h:
+        Move create functions to the cpp file and add createWithLegacyDefaults() which keeps
+        the old defaults;
+
+        * UIProcess/API/C/WKPreferencesRef.h:
+        Fix the comment.
+
+        * UIProcess/API/Cocoa/WKPreferences.h:
+        Update the comment to reflect the new defaults.
+
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::updatePreferences):
+        Unconditionally set setShouldDispatchJavaScriptWindowOnErrorEvents() to true. This setting only
+        exists for legacy WebKit.
+
 2014-05-26  Dan Bernstein  <mitz@apple.com>
 
         [Cocoa] Rewrite WK_DESIGNATED_INITIALIZER in installed headers
index 253014f..cdfe035 100644 (file)
@@ -106,9 +106,9 @@ namespace WebKit {
     macro(JavaScriptMarkupEnabled, javaScriptMarkupEnabled, Bool, bool, true) \
     macro(LoadsImagesAutomatically, loadsImagesAutomatically, Bool, bool, true) \
     macro(LoadsSiteIconsIgnoringImageLoadingPreference, loadsSiteIconsIgnoringImageLoadingPreference, Bool, bool, false) \
-    macro(PluginsEnabled, pluginsEnabled, Bool, bool, true) \
-    macro(JavaEnabled, javaEnabled, Bool, bool, true) \
-    macro(JavaEnabledForLocalFiles, javaEnabledForLocalFiles, Bool, bool, true) \
+    macro(PluginsEnabled, pluginsEnabled, Bool, bool, false) \
+    macro(JavaEnabled, javaEnabled, Bool, bool, false) \
+    macro(JavaEnabledForLocalFiles, javaEnabledForLocalFiles, Bool, bool, false) \
     macro(OfflineWebApplicationCacheEnabled, offlineWebApplicationCacheEnabled, Bool, bool, false) \
     macro(LocalStorageEnabled, localStorageEnabled, Bool, bool, true) \
     macro(DatabasesEnabled, databasesEnabled, Bool, bool, true) \
@@ -243,7 +243,7 @@ namespace WebKit {
     macro(InspectorAttachedHeight, inspectorAttachedHeight, UInt32, uint32_t, 300) \
     macro(InspectorAttachedWidth, inspectorAttachedWidth, UInt32, uint32_t, 750) \
     macro(InspectorAttachmentSide, inspectorAttachmentSide, UInt32, uint32_t, 0) \
-    macro(StorageBlockingPolicy, storageBlockingPolicy, UInt32, uint32_t, WebCore::SecurityOrigin::AllowAllStorage) \
+    macro(StorageBlockingPolicy, storageBlockingPolicy, UInt32, uint32_t, WebCore::SecurityOrigin::BlockThirdPartyStorage) \
     \
 
 #if PLATFORM(COCOA)
index 98f6e04..0934648 100644 (file)
@@ -43,13 +43,13 @@ WKTypeID WKPreferencesGetTypeID()
 
 WKPreferencesRef WKPreferencesCreate()
 {
-    RefPtr<WebPreferences> preferences = WebPreferences::create(String(), "WebKit2.");
+    RefPtr<WebPreferences> preferences = WebPreferences::createWithLegacyDefaults(String(), "WebKit2.");
     return toAPI(preferences.release().leakRef());
 }
 
 WKPreferencesRef WKPreferencesCreateWithIdentifier(WKStringRef identifierRef)
 {
-    RefPtr<WebPreferences> preferences = WebPreferences::create(toWTFString(identifierRef), "WebKit2.");
+    RefPtr<WebPreferences> preferences = WebPreferences::createWithLegacyDefaults(toWTFString(identifierRef), "WebKit2.");
     return toAPI(preferences.release().leakRef());
 }
 
index 7bec508..9e79a20 100644 (file)
@@ -216,7 +216,7 @@ WK_EXPORT bool WKPreferencesGetNotificationsEnabled(WKPreferencesRef preferences
 WK_EXPORT void WKPreferencesSetShouldRespectImageOrientation(WKPreferencesRef preferencesRef, bool enabled);
 WK_EXPORT bool WKPreferencesGetShouldRespectImageOrientation(WKPreferencesRef preferencesRef);
 
-// Defaults to false
+// Defaults to kWKAllowAllStorage 
 WK_EXPORT void WKPreferencesSetStorageBlockingPolicy(WKPreferencesRef preferencesRef, WKStorageBlockingPolicy policy);
 WK_EXPORT WKStorageBlockingPolicy WKPreferencesGetStorageBlockingPolicy(WKPreferencesRef preferencesRef);
 
index 229c6b5..62a86e6 100644 (file)
@@ -79,11 +79,11 @@ WK_CLASS_AVAILABLE(10_10, 8_0)
 #endif
 
 #if !TARGET_OS_IPHONE
-/*! @abstract Whether Java is enabled. Defaults to YES.
+/*! @abstract Whether Java is enabled. Defaults to NO.
  */
 @property (nonatomic, getter=isJavaEnabled) BOOL javaEnabled;
 
-/*! abstract Whether plug-ins are enabled. Defaults to YES.
+/*! abstract Whether plug-ins are enabled. Defaults to NO.
  */
 @property (nonatomic, getter=arePlugInsEnabled) BOOL plugInsEnabled;
 #endif
index bab8346..d88cb56 100644 (file)
@@ -84,7 +84,7 @@ static WebPageGroupData pageGroupData(const String& identifier, bool visibleToIn
 
 WebPageGroup::WebPageGroup(const String& identifier, bool visibleToInjectedBundle, bool visibleToHistoryClient)
     : m_data(pageGroupData(identifier, visibleToInjectedBundle, visibleToHistoryClient))
-    , m_preferences(WebPreferences::create(m_data.identifer, ".WebKit2"))
+    , m_preferences(WebPreferences::createWithLegacyDefaults(m_data.identifer, ".WebKit2"))
 {
     webPageGroupMap().set(m_data.pageGroupID, this);
 }
index 7c39c5c..25c39c8 100644 (file)
@@ -36,6 +36,21 @@ namespace WebKit {
 // Instead of tracking private browsing state as a boolean preference, we should let the client provide storage sessions explicitly.
 static unsigned privateBrowsingPageCount;
 
+PassRefPtr<WebPreferences> WebPreferences::create(const String& identifier, const String& keyPrefix)
+{
+    return adoptRef(new WebPreferences(identifier, keyPrefix));
+}
+
+PassRefPtr<WebPreferences> WebPreferences::createWithLegacyDefaults(const String& identifier, const String& keyPrefix)
+{
+    RefPtr<WebPreferences> preferences = adoptRef(new WebPreferences(identifier, keyPrefix));
+    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);
+    return preferences.release();
+}
+
 WebPreferences::WebPreferences(const String& identifier, const String& keyPrefix)
     : m_identifier(identifier)
     , m_keyPrefix(keyPrefix)
index c6a2a87..8e526d6 100644 (file)
@@ -43,10 +43,8 @@ class WebPageProxy;
 
 class WebPreferences : public API::ObjectImpl<API::Object::Type::Preferences> {
 public:
-    static PassRefPtr<WebPreferences> create(const String& identifier, const String& keyPrefix)
-    {
-        return adoptRef(new WebPreferences(identifier, keyPrefix));
-    }
+    static PassRefPtr<WebPreferences> create(const String& identifier, const String& keyPrefix);
+    static PassRefPtr<WebPreferences> createWithLegacyDefaults(const String& identifier, const String& keyPrefix);
 
     virtual ~WebPreferences();
 
index 07cc664..cbb2bd3 100644 (file)
@@ -2739,6 +2739,8 @@ void WebPage::updatePreferences(const WebPreferencesStore& store)
 
     settings.setEnableInheritURIQueryComponent(store.getBoolValueForKey(WebPreferencesKey::enableInheritURIQueryComponentKey()));
 
+    settings.setShouldDispatchJavaScriptWindowOnErrorEvents(true);
+
     if (store.getBoolValueForKey(WebPreferencesKey::pageVisibilityBasedProcessSuppressionEnabledKey()))
         m_processSuppressionDisabledByWebPreference.stop();
     else