| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_PREFS_DUMMY_PREF_STORE_H_ | 5 #ifndef CHROME_BROWSER_PREFS_DUMMY_PREF_STORE_H_ |
| 6 #define CHROME_BROWSER_PREFS_DUMMY_PREF_STORE_H_ | 6 #define CHROME_BROWSER_PREFS_DUMMY_PREF_STORE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/scoped_ptr.h" | 10 #include "base/scoped_ptr.h" |
| 11 #include "chrome/common/pref_store.h" | 11 #include "chrome/common/pref_store.h" |
| 12 | 12 |
| 13 class DictionaryValue; | 13 class DictionaryValue; |
| 14 | 14 |
| 15 // |DummyPrefStore| is a stub implementation of the |PrefStore| interface. | 15 // |DummyPrefStore| is a stub implementation of the |PrefStore| interface. |
| 16 // It allows to get and set the state of the |PrefStore|. | 16 // It allows to get and set the state of the |PrefStore|. |
| 17 class DummyPrefStore : public PrefStore { | 17 class DummyPrefStore : public PrefStore { |
| 18 public: | 18 public: |
| 19 DummyPrefStore(); | 19 DummyPrefStore(); |
| 20 | |
| 21 virtual ~DummyPrefStore() {} | 20 virtual ~DummyPrefStore() {} |
| 22 | 21 |
| 23 virtual DictionaryValue* prefs() { return prefs_.get(); } | 22 virtual DictionaryValue* prefs() const { return prefs_.get(); } |
| 24 | 23 |
| 25 virtual PrefStore::PrefReadError ReadPrefs(); | 24 virtual PrefStore::PrefReadError ReadPrefs(); |
| 26 | 25 |
| 27 virtual bool ReadOnly() { return read_only_; } | 26 virtual bool ReadOnly() { return read_only_; } |
| 28 | 27 |
| 29 virtual bool WritePrefs(); | 28 virtual bool WritePrefs(); |
| 30 | 29 |
| 31 // Getter and Setter methods for setting and getting the state of the | 30 // Getter and Setter methods for setting and getting the state of the |
| 32 // |DummyPrefStore|. | 31 // |DummyPrefStore|. |
| 33 virtual void set_read_only(bool read_only) { read_only_ = read_only; } | 32 virtual void set_read_only(bool read_only) { read_only_ = read_only; } |
| 34 virtual void set_prefs(DictionaryValue* prefs) { prefs_.reset(prefs); } | 33 virtual void set_prefs(DictionaryValue* prefs) { prefs_.reset(prefs); } |
| 35 virtual void set_prefs_written(bool status) { prefs_written_ = status; } | 34 virtual void set_prefs_written(bool status) { prefs_written_ = status; } |
| 36 virtual bool get_prefs_written() { return prefs_written_; } | 35 virtual bool get_prefs_written() { return prefs_written_; } |
| 37 | 36 |
| 38 private: | 37 private: |
| 39 scoped_ptr<DictionaryValue> prefs_; | 38 scoped_ptr<DictionaryValue> prefs_; |
| 40 | 39 |
| 41 // Flag that indicates if the PrefStore is read-only | 40 // Flag that indicates if the PrefStore is read-only |
| 42 bool read_only_; | 41 bool read_only_; |
| 43 | 42 |
| 44 // Flag that indicates if the method WritePrefs was called. | 43 // Flag that indicates if the method WritePrefs was called. |
| 45 bool prefs_written_; | 44 bool prefs_written_; |
| 46 | 45 |
| 47 DISALLOW_COPY_AND_ASSIGN(DummyPrefStore); | 46 DISALLOW_COPY_AND_ASSIGN(DummyPrefStore); |
| 48 }; | 47 }; |
| 49 | 48 |
| 50 #endif // CHROME_BROWSER_PREFS_DUMMY_PREF_STORE_H_ | 49 #endif // CHROME_BROWSER_PREFS_DUMMY_PREF_STORE_H_ |
| OLD | NEW |