Chromium Code Reviews| Index: chrome/browser/extensions/extension_settings_frontend.h |
| diff --git a/chrome/browser/extensions/extension_settings_frontend.h b/chrome/browser/extensions/extension_settings_frontend.h |
| index 7fe3dc00b91ae9564be38b910b6cd4b1e2bad315..2020e5e993cabc45893360ccbcc12676ddfc0cdb 100644 |
| --- a/chrome/browser/extensions/extension_settings_frontend.h |
| +++ b/chrome/browser/extensions/extension_settings_frontend.h |
| @@ -6,56 +6,75 @@ |
| #define CHROME_BROWSER_EXTENSIONS_EXTENSION_SETTINGS_FRONTEND_H_ |
| #pragma once |
| +#include "base/callback.h" |
| #include "base/compiler_specific.h" |
| #include "base/memory/ref_counted.h" |
| -#include "base/callback.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "base/observer_list_threadsafe.h" |
| +#include "chrome/browser/extensions/extension_settings_observer.h" |
| #include "chrome/browser/sync/api/syncable_service.h" |
| +#include "content/common/notification_observer.h" |
| +#include "content/common/notification_registrar.h" |
| class FilePath; |
| +class Profile; |
| class ExtensionSettingsBackend; |
| class ExtensionSettingsStorage; |
| // The component of extension settings which runs on the UI thread, as opposed |
| // to ExtensionSettingsBackend which lives on the FILE thread. |
| -class ExtensionSettingsFrontend { |
| +class ExtensionSettingsFrontend : public NotificationObserver { |
| public: |
| - explicit ExtensionSettingsFrontend(const FilePath& base_path); |
| + explicit ExtensionSettingsFrontend(Profile* profile); |
| + virtual ~ExtensionSettingsFrontend(); |
| typedef base::Callback<void(ExtensionSettingsBackend*)> BackendCallback; |
| // Runs |callback| on the FILE thread with the extension settings. |
| void RunWithBackend(const BackendCallback& callback); |
| - ~ExtensionSettingsFrontend(); |
| + // Adds an observer to settings changes. |
| + void AddObserver(ExtensionSettingsObserver* observer); |
| - private: |
| - // Ref-counted container for the ExtensionSettingsBackend object. |
| - class Core : public base::RefCountedThreadSafe<Core> { |
| - public: |
| - // Constructed on UI thread. |
| - Core(); |
| + // Removes an observer to settings changes. |
| + void RemoveObserver(ExtensionSettingsObserver* observer); |
| - // Does any FILE thread specific initialization, such as construction of |
| - // |backend_|. Must be called before any call to |
| - // RunWithBackendOnFileThread(). |
| - void InitOnFileThread(const FilePath& base_path); |
| + // NotificationObserver implementation. |
| + virtual void Observe( |
| + int type, |
| + const NotificationSource& source, |
| + const NotificationDetails& details) OVERRIDE; |
| - // Runs |callback| with the extension backend. |
| - void RunWithBackendOnFileThread(const BackendCallback& callback); |
| + private: |
| + // Called when a profile is created. |
| + void OnProfileCreated(Profile* profile); |
| + |
| + // Called when a profile is destroyed. |
| + void OnProfileDestroyed(Profile* profile); |
| - private: |
| - // Can be destroyed on either the UI or FILE thread. |
| - virtual ~Core(); |
| - friend class base::RefCountedThreadSafe<Core>; |
| + // The Profile this Frontend belongs to. Note that we don't store the |
| + // incognito version of the profile because it will change as its created |
| + // and destroyed during the lifetime of Chrome. |
| + Profile* const profile_; |
| - // Lives on the FILE thread. |
| - ExtensionSettingsBackend* backend_; |
| + // List of observers to settings changes. |
| + scoped_refptr<ObserverListThreadSafe<ExtensionSettingsObserver> > observers_; |
| - DISALLOW_COPY_AND_ASSIGN(Core); |
| - }; |
| + // The "Normal" mode profile observer and "incognito" mode profile observer. |
| + // This class listens to all PROFILE_{CREATED,DESTROYED} events but we're only |
|
akalin
2011/10/19 19:09:49
Ah, I see. I think this comment (after the first
not at google - send to devlin
2011/10/19 22:59:36
Done.
|
| + // interested in those for the Profile given on construction and its incognito |
| + // version. |
| + class DefaultObserver; |
| + scoped_ptr<DefaultObserver> profile_observer_; |
| + scoped_ptr<DefaultObserver> incognito_profile_observer_; |
| + // Ref-counted container for the ExtensionSettingsBackend object. |
| + class Core; |
| scoped_refptr<Core> core_; |
| + // For profile created/destroyed notifications. |
| + NotificationRegistrar registrar_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(ExtensionSettingsFrontend); |
| }; |