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.
5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_ACTION_STORAGE_MANAGER_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_ACTION_STORAGE_MANAGER_H_
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"
15 class ExtensionAction
;
21 namespace extensions
{
22 class ExtensionRegistry
;
25 // This class manages reading and writing browser action values from storage.
26 class ExtensionActionStorageManager
: public ExtensionActionAPI::Observer
,
27 public ExtensionRegistryObserver
{
29 explicit ExtensionActionStorageManager(content::BrowserContext
* context
);
30 ~ExtensionActionStorageManager() override
;
33 // ExtensionActionAPI::Observer:
34 void OnExtensionActionUpdated(
35 ExtensionAction
* extension_action
,
36 content::WebContents
* web_contents
,
37 content::BrowserContext
* browser_context
) override
;
38 void OnExtensionActionAPIShuttingDown() override
;
40 // ExtensionRegistryObserver:
41 void OnExtensionLoaded(content::BrowserContext
* browser_context
,
42 const Extension
* extension
) override
;
44 // Reads/Writes the ExtensionAction's default values to/from storage.
45 void WriteToStorage(ExtensionAction
* extension_action
);
47 const std::string
& extension_id
, scoped_ptr
<base::Value
> value
);
49 // Returns the Extensions StateStore for the |browser_context_|.
51 StateStore
* GetStateStore();
53 content::BrowserContext
* browser_context_
;
55 ScopedObserver
<ExtensionActionAPI
, ExtensionActionAPI::Observer
>
56 extension_action_observer_
;
58 ScopedObserver
<ExtensionRegistry
, ExtensionRegistryObserver
>
59 extension_registry_observer_
;
61 base::WeakPtrFactory
<ExtensionActionStorageManager
> weak_factory_
;
63 DISALLOW_COPY_AND_ASSIGN(ExtensionActionStorageManager
);
66 } // namespace extensions
68 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_ACTION_STORAGE_MANAGER_H_