Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2280)

Unified Diff: chrome/browser/plugins/plugin_finder.cc

Issue 11348046: Add versioning to PluginFinder metadata. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/plugins/plugin_finder.cc
diff --git a/chrome/browser/plugins/plugin_finder.cc b/chrome/browser/plugins/plugin_finder.cc
index b362c803d1be44536c0ac62e313059753a25835f..24f6e3e38c492f41322a59013d902d8b1c50f9f1 100644
--- a/chrome/browser/plugins/plugin_finder.cc
+++ b/chrome/browser/plugins/plugin_finder.cc
@@ -146,25 +146,23 @@ PluginFinder* PluginFinder::GetInstance() {
return Singleton<PluginFinder>::get();
}
-PluginFinder::PluginFinder() {
+PluginFinder::PluginFinder() : version_(-1) {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
}
void PluginFinder::Init() {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
- plugin_list_.reset(ComputePluginList());
- DCHECK(plugin_list_.get());
-
- InitInternal();
+ scoped_ptr<DictionaryValue> plugin_list(ComputePluginList());
cevans 2013/02/05 21:06:52 I think I'd have found a comment here useful, alon
Bernhard Bauer 2013/02/06 20:08:24 Done.
+ if (plugin_list)
+ ReinitializePlugins(plugin_list.Pass());
cevans 2013/02/05 21:06:52 In the common case (ENABLE_PLUGIN_INSTALLATION), R
}
// static
DictionaryValue* PluginFinder::ComputePluginList() {
#if defined(ENABLE_PLUGIN_INSTALLATION)
- const base::DictionaryValue* metadata =
- g_browser_process->local_state()->GetDictionary(prefs::kPluginsMetadata);
- if (!metadata->empty())
- return metadata->DeepCopy();
+ scoped_ptr<DictionaryValue> plugin_list(LoadPluginList());
+ if (plugin_list)
+ ReinitializePlugins(plugin_list.Pass());
#endif
base::DictionaryValue* result = LoadPluginList();
cevans 2013/02/05 21:06:52 I'm kind of confused -- we just called LoadPluginL
Bernhard Bauer 2013/02/06 20:08:24 Yes, that's what I meant by "merging it with upstr
if (result)
@@ -209,10 +207,10 @@ bool PluginFinder::FindPlugin(
const std::string& language,
PluginInstaller** installer,
scoped_ptr<PluginMetadata>* plugin_metadata) {
- base::AutoLock lock(mutex_);
if (g_browser_process->local_state()->GetBoolean(prefs::kDisablePluginFinder))
return false;
+ base::AutoLock lock(mutex_);
PluginMap::const_iterator metadata_it = identifier_plugin_.begin();
for (; metadata_it != identifier_plugin_.end(); ++metadata_it) {
if (language == metadata_it->second->language() &&
@@ -250,13 +248,22 @@ bool PluginFinder::FindPluginWithIdentifier(
}
void PluginFinder::ReinitializePlugins(
- const base::DictionaryValue& json_metadata) {
+ scoped_ptr<base::DictionaryValue> json_metadata) {
base::AutoLock lock(mutex_);
+ int version = 0; // If no version is defined, we default to 0.
+ const char kVersionKey[] = "x-version";
+ json_metadata->GetInteger(kVersionKey, &version);
+ if (version <= version_)
+ return;
+
+ json_metadata->Remove(kVersionKey, NULL);
+
+ version_ = version;
+
STLDeleteValues(&identifier_plugin_);
identifier_plugin_.clear();
- plugin_list_.reset(json_metadata.DeepCopy());
- InitInternal();
+ InitInternal(json_metadata.Pass());
}
#endif
@@ -302,12 +309,12 @@ scoped_ptr<PluginMetadata> PluginFinder::GetPluginMetadata(
return metadata->Clone();
}
-void PluginFinder::InitInternal() {
- for (DictionaryValue::Iterator plugin_it(*plugin_list_);
+void PluginFinder::InitInternal(scoped_ptr<base::DictionaryValue> plugin_list) {
+ for (DictionaryValue::Iterator plugin_it(*plugin_list);
plugin_it.HasNext(); plugin_it.Advance()) {
DictionaryValue* plugin = NULL;
const std::string& identifier = plugin_it.key();
- if (plugin_list_->GetDictionaryWithoutPathExpansion(identifier, &plugin)) {
+ if (plugin_list->GetDictionaryWithoutPathExpansion(identifier, &plugin)) {
DCHECK(!identifier_plugin_[identifier]);
identifier_plugin_[identifier] = CreatePluginMetadata(identifier, plugin);

Powered by Google App Engine
This is Rietveld 408576698