OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_ACTION_STORAGE_MANAGER_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_ACTION_STORAGE_MANAGER_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/memory/weak_ptr.h" |
| 11 #include "base/scoped_observer.h" |
| 12 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" |
| 13 #include "extensions/browser/extension_registry_observer.h" |
| 14 |
| 15 class ExtensionAction; |
| 16 |
| 17 namespace content { |
| 18 class BrowserContext; |
| 19 } |
| 20 |
| 21 namespace extensions { |
| 22 class ExtensionRegistry; |
| 23 class StateStore; |
| 24 |
| 25 // This class manages reading and writing browser action values from storage. |
| 26 class ExtensionActionStorageManager : public ExtensionActionAPI::Observer, |
| 27 public ExtensionRegistryObserver { |
| 28 public: |
| 29 explicit ExtensionActionStorageManager(content::BrowserContext* context); |
| 30 virtual ~ExtensionActionStorageManager(); |
| 31 |
| 32 private: |
| 33 // ExtensionActionAPI::Observer: |
| 34 virtual void OnExtensionActionUpdated( |
| 35 ExtensionAction* extension_action, |
| 36 content::WebContents* web_contents, |
| 37 content::BrowserContext* browser_context) OVERRIDE; |
| 38 virtual void OnExtensionActionAPIShuttingDown() OVERRIDE; |
| 39 |
| 40 // ExtensionRegistryObserver: |
| 41 virtual void OnExtensionLoaded(content::BrowserContext* browser_context, |
| 42 const Extension* extension) OVERRIDE; |
| 43 |
| 44 // Reads/Writes the ExtensionAction's default values to/from storage. |
| 45 void WriteToStorage(ExtensionAction* extension_action); |
| 46 void ReadFromStorage( |
| 47 const std::string& extension_id, scoped_ptr<base::Value> value); |
| 48 |
| 49 // Returns the Extensions StateStore for the |browser_context_|. |
| 50 // May return NULL. |
| 51 StateStore* GetStateStore(); |
| 52 |
| 53 content::BrowserContext* browser_context_; |
| 54 |
| 55 ScopedObserver<ExtensionActionAPI, ExtensionActionAPI::Observer> |
| 56 extension_action_observer_; |
| 57 |
| 58 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> |
| 59 extension_registry_observer_; |
| 60 |
| 61 base::WeakPtrFactory<ExtensionActionStorageManager> weak_factory_; |
| 62 |
| 63 DISALLOW_COPY_AND_ASSIGN(ExtensionActionStorageManager); |
| 64 }; |
| 65 |
| 66 } // namespace extensions |
| 67 |
| 68 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_ACTION_STORAGE_MANAGER_H_ |
OLD | NEW |