Skip to content

Commit

Permalink
Merge r172920 - [GTK] Older versions of WebKit should use the plugins…
Browse files Browse the repository at this point in the history
… 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:
  • Loading branch information
carlosgcampos committed Oct 1, 2014
1 parent 5c030ce commit 1706242
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
18 changes: 18 additions & 0 deletions Source/WebKit2/ChangeLog
@@ -1,3 +1,21 @@
2014-08-25 Carlos Garcia Campos <cgarcia@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 <cgarcia@igalia.com>

[GTK] The plugins metadata cache doesn't work if the user cache directory doesn't exist
Expand Down
16 changes: 11 additions & 5 deletions Source/WebKit2/UIProcess/Plugins/gtk/PluginInfoCache.cpp
Expand Up @@ -46,6 +46,7 @@ PluginInfoCache& PluginInfoCache::shared()
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())) {
Expand All @@ -55,11 +56,16 @@ PluginInfoCache::PluginInfoCache()

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));
Expand Down Expand Up @@ -134,7 +140,7 @@ void PluginInfoCache::updatePluginInfo(const String& pluginPath, const PluginMod
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);
Expand Down
1 change: 1 addition & 0 deletions Source/WebKit2/UIProcess/Plugins/gtk/PluginInfoCache.h
Expand Up @@ -54,6 +54,7 @@ class PluginInfoCache {
GOwnPtr<GKeyFile> m_cacheFile;
GOwnPtr<char> m_cachePath;
unsigned m_saveToFileIdleId;
bool m_readOnlyMode;
std::mutex m_mutex;
};

Expand Down

0 comments on commit 1706242

Please sign in to comment.