OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/extensions/api/storage/managed_value_store_cache.h" | 5 #include "chrome/browser/extensions/api/storage/managed_value_store_cache.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 | 45 |
46 namespace extensions { | 46 namespace extensions { |
47 | 47 |
48 namespace storage = api::storage; | 48 namespace storage = api::storage; |
49 | 49 |
50 namespace { | 50 namespace { |
51 | 51 |
52 const char kLoadSchemasBackgroundTaskTokenName[] = | 52 const char kLoadSchemasBackgroundTaskTokenName[] = |
53 "load_managed_storage_schemas_token"; | 53 "load_managed_storage_schemas_token"; |
54 | 54 |
| 55 // The Legacy Browser Support was the first user of the policy-for-extensions |
| 56 // API, and relied on behavior that will be phased out. If this extension is |
| 57 // present then its policies will be loaded in a special way. |
| 58 // TODO(joaodasilva): remove this for M35. http://crbug.com/325349 |
| 59 const char kLegacyBrowserSupportExtensionId[] = |
| 60 "heildphpnddilhkemkielfhnkaagiabh"; |
| 61 |
55 } // namespace | 62 } // namespace |
56 | 63 |
57 // This helper observes initialization of all the installed extensions and | 64 // This helper observes initialization of all the installed extensions and |
58 // subsequent loads and unloads, and keeps the SchemaRegistry of the Profile | 65 // subsequent loads and unloads, and keeps the SchemaRegistry of the Profile |
59 // in sync with the current list of extensions. This allows the PolicyService | 66 // in sync with the current list of extensions. This allows the PolicyService |
60 // to fetch cloud policy for those extensions, and allows its providers to | 67 // to fetch cloud policy for those extensions, and allows its providers to |
61 // selectively load only extension policy that has users. | 68 // selectively load only extension policy that has users. |
62 class ManagedValueStoreCache::ExtensionTracker | 69 class ManagedValueStoreCache::ExtensionTracker |
63 : public content::NotificationObserver { | 70 : public content::NotificationObserver { |
64 public: | 71 public: |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 base::Bind(&ExtensionTracker::LoadSchemas, | 173 base::Bind(&ExtensionTracker::LoadSchemas, |
167 base::Passed(&added), | 174 base::Passed(&added), |
168 weak_factory_.GetWeakPtr())); | 175 weak_factory_.GetWeakPtr())); |
169 } | 176 } |
170 | 177 |
171 bool ManagedValueStoreCache::ExtensionTracker::UsesManagedStorage( | 178 bool ManagedValueStoreCache::ExtensionTracker::UsesManagedStorage( |
172 const Extension* extension) const { | 179 const Extension* extension) const { |
173 if (extension->manifest()->HasPath(manifest_keys::kStorageManagedSchema)) | 180 if (extension->manifest()->HasPath(manifest_keys::kStorageManagedSchema)) |
174 return true; | 181 return true; |
175 | 182 |
176 // TODO(joaodasilva): also load extensions that use the storage API for now, | 183 // TODO(joaodasilva): remove this by M35. |
177 // to support the Legacy Browser Support extension. Remove this. | 184 return extension->id() == kLegacyBrowserSupportExtensionId; |
178 // http://crbug.com/240704 | |
179 if (extension->HasAPIPermission(APIPermission::kStorage)) | |
180 return true; | |
181 | |
182 return false; | |
183 } | 185 } |
184 | 186 |
185 // static | 187 // static |
186 void ManagedValueStoreCache::ExtensionTracker::LoadSchemas( | 188 void ManagedValueStoreCache::ExtensionTracker::LoadSchemas( |
187 scoped_ptr<ExtensionSet> extensions, | 189 scoped_ptr<ExtensionSet> extensions, |
188 base::WeakPtr<ExtensionTracker> self) { | 190 base::WeakPtr<ExtensionTracker> self) { |
189 scoped_ptr<policy::ComponentMap> components(new policy::ComponentMap); | 191 scoped_ptr<policy::ComponentMap> components(new policy::ComponentMap); |
190 | 192 |
191 for (ExtensionSet::const_iterator it = extensions->begin(); | 193 for (ExtensionSet::const_iterator it = extensions->begin(); |
192 it != extensions->end(); ++it) { | 194 it != extensions->end(); ++it) { |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 | 366 |
365 return store; | 367 return store; |
366 } | 368 } |
367 | 369 |
368 bool ManagedValueStoreCache::HasStore(const std::string& extension_id) const { | 370 bool ManagedValueStoreCache::HasStore(const std::string& extension_id) const { |
369 // TODO(joaodasilva): move this check to a ValueStore method. | 371 // TODO(joaodasilva): move this check to a ValueStore method. |
370 return base::DirectoryExists(base_path_.AppendASCII(extension_id)); | 372 return base::DirectoryExists(base_path_.AppendASCII(extension_id)); |
371 } | 373 } |
372 | 374 |
373 } // namespace extensions | 375 } // namespace extensions |
OLD | NEW |