Chromium Code Reviews| Index: chrome/browser/extensions/api/storage/managed_value_store_cache.cc |
| diff --git a/chrome/browser/extensions/api/storage/managed_value_store_cache.cc b/chrome/browser/extensions/api/storage/managed_value_store_cache.cc |
| index 267ee70b05d050a76dbb7fb3508d71c07d9959f3..98e7b955bff76877162167fb96c28621e17677c4 100644 |
| --- a/chrome/browser/extensions/api/storage/managed_value_store_cache.cc |
| +++ b/chrome/browser/extensions/api/storage/managed_value_store_cache.cc |
| @@ -106,6 +106,13 @@ void ManagedValueStoreCache::ExtensionTracker::Observe( |
| int type, |
| const content::NotificationSource& source, |
| const content::NotificationDetails& details) { |
| + // Some extensions are installed on the first run before the ExtensionService |
| + // becomes ready. Wait until all of them are ready before registering the |
| + // schemas of managed extensions, so that the policy loaders are reloaded at |
| + // most once. |
| + if (!ExtensionSystem::Get(profile_)->ready().is_signaled()) |
|
bartfab (slow)
2013/11/25 14:24:02
Nit: #include "extensions/common/one_shot_event.h"
Joao da Silva
2013/11/25 15:40:38
Done.
|
| + return; |
| + |
| scoped_ptr<ExtensionSet> added; |
| const Extension* removed = NULL; |
| @@ -269,8 +276,7 @@ void ManagedValueStoreCache::DeleteStorageSoon( |
| // It's possible that the store exists, but hasn't been loaded yet |
| // (because the extension is unloaded, for example). Open the database to |
| // clear it if it exists. |
| - // TODO(joaodasilva): move this check to a ValueStore method. |
| - if (!base::DirectoryExists(base_path_.AppendASCII(extension_id))) |
| + if (!HasStore(extension_id)) |
| return; |
| GetStoreFor(extension_id)->DeleteStorage(); |
| store_map_.erase(extension_id); |
| @@ -328,6 +334,14 @@ void ManagedValueStoreCache::UpdatePolicyOnFILE( |
| const std::string& extension_id, |
| scoped_ptr<policy::PolicyMap> current_policy) { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| + |
| + if (!HasStore(extension_id) && current_policy->empty()) { |
| + // Don't create the store now if there are no concrete policies configured |
|
bartfab (slow)
2013/11/25 14:24:02
Nit: What do you mean by "concrete policies"? Do y
Joao da Silva
2013/11/25 15:40:38
Yes; removed the "concrete" since it was just conf
|
| + // for this extension. If the extension uses the storage.managed API then |
| + // the store will be created at RunWithValueStoreForExtension(). |
| + return; |
| + } |
| + |
| GetStoreFor(extension_id)->SetCurrentPolicy(*current_policy); |
| } |
| @@ -350,4 +364,9 @@ PolicyValueStore* ManagedValueStoreCache::GetStoreFor( |
| return store; |
| } |
| +bool ManagedValueStoreCache::HasStore(const std::string& extension_id) { |
| + // TODO(joaodasilva): move this check to a ValueStore method. |
| + return base::DirectoryExists(base_path_.AppendASCII(extension_id)); |
| +} |
| + |
| } // namespace extensions |