| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_FRONTEND_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_FRONTEND_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_FRONTEND_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_FRONTEND_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/observer_list_threadsafe.h" | 13 #include "base/observer_list_threadsafe.h" |
| 14 #include "chrome/browser/extensions/settings/settings_leveldb_storage.h" |
| 14 #include "chrome/browser/extensions/settings/settings_observer.h" | 15 #include "chrome/browser/extensions/settings/settings_observer.h" |
| 15 #include "chrome/browser/sync/api/syncable_service.h" | 16 #include "chrome/browser/sync/api/syncable_service.h" |
| 16 #include "content/public/browser/notification_observer.h" | 17 #include "content/public/browser/notification_observer.h" |
| 17 #include "content/public/browser/notification_registrar.h" | 18 #include "content/public/browser/notification_registrar.h" |
| 18 | 19 |
| 19 class FilePath; | 20 class FilePath; |
| 20 class Profile; | 21 class Profile; |
| 21 | 22 |
| 22 namespace extensions { | 23 namespace extensions { |
| 23 | 24 |
| 24 class SettingsStorage; | 25 class SettingsStorage; |
| 25 | 26 |
| 26 // The component of extension settings which runs on the UI thread, as opposed | 27 // The component of extension settings which runs on the UI thread, as opposed |
| 27 // to SettingsBackend which lives on the FILE thread. | 28 // to SettingsBackend which lives on the FILE thread. |
| 28 // All public methods must be called on the UI thread. | 29 // All public methods must be called on the UI thread. |
| 29 class SettingsFrontend { | 30 class SettingsFrontend { |
| 30 public: | 31 public: |
| 31 explicit SettingsFrontend(Profile* profile); | 32 // Creates with the default factory. Ownership of |profile| not taken. |
| 33 static SettingsFrontend* Create(Profile* profile); |
| 34 |
| 35 static SettingsFrontend* Create( |
| 36 // Ownership taken. |
| 37 SettingsStorageFactory* storage_factory, |
| 38 // Owership NOT taken. |
| 39 Profile* profile); |
| 40 |
| 32 virtual ~SettingsFrontend(); | 41 virtual ~SettingsFrontend(); |
| 33 | 42 |
| 34 typedef base::Callback<void(SyncableService*)> SyncableServiceCallback; | 43 typedef base::Callback<void(SyncableService*)> SyncableServiceCallback; |
| 35 typedef base::Callback<void(SettingsStorage*)> StorageCallback; | 44 typedef base::Callback<void(SettingsStorage*)> StorageCallback; |
| 36 | 45 |
| 37 // Runs |callback| on the FILE thread with the SyncableService for | 46 // Runs |callback| on the FILE thread with the SyncableService for |
| 38 // |model_type|, either SETTINGS or APP_SETTINGS. | 47 // |model_type|, either SETTINGS or APP_SETTINGS. |
| 39 void RunWithSyncableService( | 48 void RunWithSyncableService( |
| 40 syncable::ModelType model_type, const SyncableServiceCallback& callback); | 49 syncable::ModelType model_type, const SyncableServiceCallback& callback); |
| 41 | 50 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 61 | 70 |
| 62 // SettingsObserver implementation. | 71 // SettingsObserver implementation. |
| 63 virtual void OnSettingsChanged( | 72 virtual void OnSettingsChanged( |
| 64 const std::string& extension_id, | 73 const std::string& extension_id, |
| 65 const std::string& change_json) OVERRIDE; | 74 const std::string& change_json) OVERRIDE; |
| 66 | 75 |
| 67 private: | 76 private: |
| 68 Profile* const profile_; | 77 Profile* const profile_; |
| 69 }; | 78 }; |
| 70 | 79 |
| 80 SettingsFrontend( |
| 81 // Ownership taken. |
| 82 SettingsStorageFactory* storage_factory, |
| 83 // Ownership NOT taken. |
| 84 Profile* profile); |
| 85 |
| 71 // The (non-incognito) Profile this Frontend belongs to. | 86 // The (non-incognito) Profile this Frontend belongs to. |
| 72 Profile* const profile_; | 87 Profile* const profile_; |
| 73 | 88 |
| 74 // List of observers to settings changes. | 89 // List of observers to settings changes. |
| 75 scoped_refptr<SettingsObserverList> observers_; | 90 scoped_refptr<SettingsObserverList> observers_; |
| 76 | 91 |
| 77 // Observer for |profile_|. | 92 // Observer for |profile_|. |
| 78 DefaultObserver default_observer_; | 93 DefaultObserver default_observer_; |
| 79 | 94 |
| 80 // Ref-counted container for the SettingsBackend object. | 95 // Ref-counted container for the SettingsBackend object. |
| 81 class Core; | 96 class Core; |
| 82 scoped_refptr<Core> core_; | 97 scoped_refptr<Core> core_; |
| 83 | 98 |
| 84 DISALLOW_COPY_AND_ASSIGN(SettingsFrontend); | 99 DISALLOW_COPY_AND_ASSIGN(SettingsFrontend); |
| 85 }; | 100 }; |
| 86 | 101 |
| 87 } // namespace extensions | 102 } // namespace extensions |
| 88 | 103 |
| 89 #endif // CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_FRONTEND_H_ | 104 #endif // CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_FRONTEND_H_ |
| OLD | NEW |