| 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/files/file_util.h" | 10 #include "base/files/file_util.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 | 61 |
| 62 // This helper observes initialization of all the installed extensions and | 62 // This helper observes initialization of all the installed extensions and |
| 63 // subsequent loads and unloads, and keeps the SchemaRegistry of the Profile | 63 // subsequent loads and unloads, and keeps the SchemaRegistry of the Profile |
| 64 // in sync with the current list of extensions. This allows the PolicyService | 64 // in sync with the current list of extensions. This allows the PolicyService |
| 65 // to fetch cloud policy for those extensions, and allows its providers to | 65 // to fetch cloud policy for those extensions, and allows its providers to |
| 66 // selectively load only extension policy that has users. | 66 // selectively load only extension policy that has users. |
| 67 class ManagedValueStoreCache::ExtensionTracker | 67 class ManagedValueStoreCache::ExtensionTracker |
| 68 : public ExtensionRegistryObserver { | 68 : public ExtensionRegistryObserver { |
| 69 public: | 69 public: |
| 70 explicit ExtensionTracker(Profile* profile); | 70 explicit ExtensionTracker(Profile* profile); |
| 71 virtual ~ExtensionTracker() {} | 71 ~ExtensionTracker() override {} |
| 72 | 72 |
| 73 private: | 73 private: |
| 74 // ExtensionRegistryObserver implementation. | 74 // ExtensionRegistryObserver implementation. |
| 75 virtual void OnExtensionWillBeInstalled( | 75 void OnExtensionWillBeInstalled(content::BrowserContext* browser_context, |
| 76 content::BrowserContext* browser_context, | 76 const Extension* extension, |
| 77 const Extension* extension, | 77 bool is_update, |
| 78 bool is_update, | 78 bool from_ephemeral, |
| 79 bool from_ephemeral, | 79 const std::string& old_name) override; |
| 80 const std::string& old_name) override; | 80 void OnExtensionUninstalled(content::BrowserContext* browser_context, |
| 81 virtual void OnExtensionUninstalled( | 81 const Extension* extension, |
| 82 content::BrowserContext* browser_context, | 82 extensions::UninstallReason reason) override; |
| 83 const Extension* extension, | |
| 84 extensions::UninstallReason reason) override; | |
| 85 | 83 |
| 86 // Handler for the signal from ExtensionSystem::ready(). | 84 // Handler for the signal from ExtensionSystem::ready(). |
| 87 void OnExtensionsReady(); | 85 void OnExtensionsReady(); |
| 88 | 86 |
| 89 // Starts a schema load for all extensions that use managed storage. | 87 // Starts a schema load for all extensions that use managed storage. |
| 90 void LoadSchemas(scoped_ptr<ExtensionSet> added); | 88 void LoadSchemas(scoped_ptr<ExtensionSet> added); |
| 91 | 89 |
| 92 bool UsesManagedStorage(const Extension* extension) const; | 90 bool UsesManagedStorage(const Extension* extension) const; |
| 93 | 91 |
| 94 // Loads the schemas of the |extensions| and passes a ComponentMap to | 92 // Loads the schemas of the |extensions| and passes a ComponentMap to |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 | 366 |
| 369 return store; | 367 return store; |
| 370 } | 368 } |
| 371 | 369 |
| 372 bool ManagedValueStoreCache::HasStore(const std::string& extension_id) const { | 370 bool ManagedValueStoreCache::HasStore(const std::string& extension_id) const { |
| 373 // TODO(joaodasilva): move this check to a ValueStore method. | 371 // TODO(joaodasilva): move this check to a ValueStore method. |
| 374 return base::DirectoryExists(base_path_.AppendASCII(extension_id)); | 372 return base::DirectoryExists(base_path_.AppendASCII(extension_id)); |
| 375 } | 373 } |
| 376 | 374 |
| 377 } // namespace extensions | 375 } // namespace extensions |
| OLD | NEW |