Title: [174145] releases/WebKitGTK/webkit-2.2/Source/WebKit2
Revision
174145
Author
carlo...@webkit.org
Date
2014-10-01 00:20:30 -0700 (Wed, 01 Oct 2014)

Log Message

Merge r172920 - [GTK] Older versions of WebKit should use the plugins cache in read only mode
https://bugs.webkit.org/show_bug.cgi?id=136215

Reviewed by Philippe Normand.

Now that WebKitGTK+ 2.4 and 2.5 are parallel installable, since
they use different versions of the plugins cache, apps using 2.4
might override the plugins cache file. We should prevent this from
happening by making older versions use the plugin cache, but not
downgrade it.

* UIProcess/Plugins/gtk/PluginInfoCache.cpp:
(WebKit::PluginInfoCache::PluginInfoCache):
(WebKit::PluginInfoCache::updatePluginInfo):
* UIProcess/Plugins/gtk/PluginInfoCache.h:

Modified Paths

Diff

Modified: releases/WebKitGTK/webkit-2.2/Source/WebKit2/ChangeLog (174144 => 174145)


--- releases/WebKitGTK/webkit-2.2/Source/WebKit2/ChangeLog	2014-10-01 06:40:33 UTC (rev 174144)
+++ releases/WebKitGTK/webkit-2.2/Source/WebKit2/ChangeLog	2014-10-01 07:20:30 UTC (rev 174145)
@@ -1,3 +1,21 @@
+2014-08-25  Carlos Garcia Campos  <cgar...@igalia.com>
+
+        [GTK] Older versions of WebKit should use the plugins cache in read only mode
+        https://bugs.webkit.org/show_bug.cgi?id=136215
+
+        Reviewed by Philippe Normand.
+
+        Now that WebKitGTK+ 2.4 and 2.5 are parallel installable, since
+        they use different versions of the plugins cache, apps using 2.4
+        might override the plugins cache file. We should prevent this from
+        happening by making older versions use the plugin cache, but not
+        downgrade it.
+
+        * UIProcess/Plugins/gtk/PluginInfoCache.cpp:
+        (WebKit::PluginInfoCache::PluginInfoCache):
+        (WebKit::PluginInfoCache::updatePluginInfo):
+        * UIProcess/Plugins/gtk/PluginInfoCache.h:
+
 2014-08-12  Carlos Garcia Campos  <cgar...@igalia.com>
 
         [GTK] The plugins metadata cache doesn't work if the user cache directory doesn't exist

Modified: releases/WebKitGTK/webkit-2.2/Source/WebKit2/UIProcess/Plugins/gtk/PluginInfoCache.cpp (174144 => 174145)


--- releases/WebKitGTK/webkit-2.2/Source/WebKit2/UIProcess/Plugins/gtk/PluginInfoCache.cpp	2014-10-01 06:40:33 UTC (rev 174144)
+++ releases/WebKitGTK/webkit-2.2/Source/WebKit2/UIProcess/Plugins/gtk/PluginInfoCache.cpp	2014-10-01 07:20:30 UTC (rev 174145)
@@ -46,6 +46,7 @@
 PluginInfoCache::PluginInfoCache()
     : m_cacheFile(g_key_file_new())
     , m_saveToFileIdleId(0)
+    , m_readOnlyMode(false)
 {
     GOwnPtr<char> cacheDirectory(g_build_filename(g_get_user_cache_dir(), "webkitgtk", nullptr));
     if (WebCore::makeAllDirectories(cacheDirectory.get())) {
@@ -55,11 +56,16 @@
 
     if (g_key_file_has_group(m_cacheFile.get(), "schema")) {
         unsigned schemaVersion = static_cast<unsigned>(g_key_file_get_integer(m_cacheFile.get(), "schema", "version", nullptr));
-        if (schemaVersion == gSchemaVersion)
+        if (schemaVersion < gSchemaVersion) {
+            // Cache file using an old schema, create a new empty file.
+            m_cacheFile.set(g_key_file_new());
+        } else if (schemaVersion > gSchemaVersion) {
+            // Cache file using a newer schema, use the cache in read only mode.
+            m_readOnlyMode = true;
+        } else {
+            // Same schema version, we don't need to update it.
             return;
-
-        // Cache file using an old schema, create a new empty file.
-        m_cacheFile.set(g_key_file_new());
+        }
     }
 
     g_key_file_set_integer(m_cacheFile.get(), "schema", "version", static_cast<unsigned>(gSchemaVersion));
@@ -134,7 +140,7 @@
     String mimeDescription = NetscapePluginModule::buildMIMEDescription(plugin.info.mimes);
     g_key_file_set_string(m_cacheFile.get(), pluginGroup.data(), "mime-description", mimeDescription.utf8().data());
 
-    if (m_cachePath) {
+    if (m_cachePath && !m_readOnlyMode) {
         // Save the cache file in an idle to make sure it happens in the main thread and
         // it's done only once when this is called multiple times in a very short time.
         std::lock_guard<std::mutex> lock(m_mutex);

Modified: releases/WebKitGTK/webkit-2.2/Source/WebKit2/UIProcess/Plugins/gtk/PluginInfoCache.h (174144 => 174145)


--- releases/WebKitGTK/webkit-2.2/Source/WebKit2/UIProcess/Plugins/gtk/PluginInfoCache.h	2014-10-01 06:40:33 UTC (rev 174144)
+++ releases/WebKitGTK/webkit-2.2/Source/WebKit2/UIProcess/Plugins/gtk/PluginInfoCache.h	2014-10-01 07:20:30 UTC (rev 174145)
@@ -54,6 +54,7 @@
     GOwnPtr<GKeyFile> m_cacheFile;
     GOwnPtr<char> m_cachePath;
     unsigned m_saveToFileIdleId;
+    bool m_readOnlyMode;
     std::mutex m_mutex;
 };
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to