| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "chrome/test/base/testing_pref_service.h" | 5 #include "chrome/test/base/testing_pref_service.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/prefs/default_pref_store.h" | 8 #include "base/prefs/default_pref_store.h" |
| 9 #include "base/prefs/testing_pref_store.h" | 9 #include "base/prefs/testing_pref_store.h" |
| 10 #include "chrome/browser/policy/configuration_policy_pref_store.h" | 10 #include "chrome/browser/policy/configuration_policy_pref_store.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 void HandleReadError(PersistentPrefStore::PrefReadError error) { | 23 void HandleReadError(PersistentPrefStore::PrefReadError error) { |
| 24 } | 24 } |
| 25 | 25 |
| 26 } // namespace | 26 } // namespace |
| 27 | 27 |
| 28 TestingPrefServiceBase::TestingPrefServiceBase( | 28 TestingPrefServiceBase::TestingPrefServiceBase( |
| 29 TestingPrefStore* managed_prefs, | 29 TestingPrefStore* managed_prefs, |
| 30 TestingPrefStore* user_prefs, | 30 TestingPrefStore* user_prefs, |
| 31 TestingPrefStore* recommended_prefs, | 31 TestingPrefStore* recommended_prefs, |
| 32 DefaultPrefStore* default_store, | 32 DefaultPrefStore* default_store, |
| 33 PrefModelAssociator* pref_sync_associator, | |
| 34 PrefNotifierImpl* pref_notifier) | 33 PrefNotifierImpl* pref_notifier) |
| 35 : PrefService(pref_notifier, | 34 : PrefService(pref_notifier, |
| 36 new PrefValueStore( | 35 new PrefValueStore( |
| 37 managed_prefs, | 36 managed_prefs, |
| 38 NULL, | 37 NULL, |
| 39 NULL, | 38 NULL, |
| 40 user_prefs, | 39 user_prefs, |
| 41 recommended_prefs, | 40 recommended_prefs, |
| 42 default_store, | 41 default_store, |
| 43 pref_sync_associator, | 42 pref_sync_associator, |
| 44 pref_notifier), | 43 pref_notifier), |
| 45 user_prefs, | 44 user_prefs, |
| 46 default_store, | 45 default_store, |
| 47 pref_sync_associator, | |
| 48 base::Bind(&l10n_util::GetStringUTF8), | 46 base::Bind(&l10n_util::GetStringUTF8), |
| 49 base::Bind(&HandleReadError), | 47 base::Bind(&HandleReadError), |
| 50 false), | 48 false), |
| 51 managed_prefs_(managed_prefs), | 49 managed_prefs_(managed_prefs), |
| 52 user_prefs_(user_prefs), | 50 user_prefs_(user_prefs), |
| 53 recommended_prefs_(recommended_prefs) { | 51 recommended_prefs_(recommended_prefs) { |
| 54 } | 52 } |
| 55 | 53 |
| 56 TestingPrefServiceBase::~TestingPrefServiceBase() { | 54 TestingPrefServiceBase::~TestingPrefServiceBase() { |
| 57 } | 55 } |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 void TestingPrefServiceBase::RemovePref(TestingPrefStore* pref_store, | 107 void TestingPrefServiceBase::RemovePref(TestingPrefStore* pref_store, |
| 110 const char* path) { | 108 const char* path) { |
| 111 pref_store->RemoveValue(path); | 109 pref_store->RemoveValue(path); |
| 112 } | 110 } |
| 113 | 111 |
| 114 TestingPrefService::TestingPrefService() | 112 TestingPrefService::TestingPrefService() |
| 115 : TestingPrefServiceBase(new TestingPrefStore(), | 113 : TestingPrefServiceBase(new TestingPrefStore(), |
| 116 new TestingPrefStore(), | 114 new TestingPrefStore(), |
| 117 new TestingPrefStore(), | 115 new TestingPrefStore(), |
| 118 new DefaultPrefStore(), | 116 new DefaultPrefStore(), |
| 119 new PrefModelAssociator(), | |
| 120 new PrefNotifierImpl()) { | 117 new PrefNotifierImpl()) { |
| 121 } | 118 } |
| 122 | 119 |
| 123 TestingPrefService::~TestingPrefService() { | 120 TestingPrefService::~TestingPrefService() { |
| 124 } | 121 } |
| 125 | 122 |
| 126 ScopedTestingLocalState::ScopedTestingLocalState( | 123 ScopedTestingLocalState::ScopedTestingLocalState( |
| 127 TestingBrowserProcess* browser_process) | 124 TestingBrowserProcess* browser_process) |
| 128 : browser_process_(browser_process) { | 125 : browser_process_(browser_process) { |
| 129 chrome::RegisterLocalState(&local_state_); | 126 chrome::RegisterLocalState(&local_state_); |
| 130 EXPECT_FALSE(browser_process->local_state()); | 127 EXPECT_FALSE(browser_process->local_state()); |
| 131 browser_process->SetLocalState(&local_state_); | 128 browser_process->SetLocalState(&local_state_); |
| 132 } | 129 } |
| 133 | 130 |
| 134 ScopedTestingLocalState::~ScopedTestingLocalState() { | 131 ScopedTestingLocalState::~ScopedTestingLocalState() { |
| 135 EXPECT_EQ(&local_state_, browser_process_->local_state()); | 132 EXPECT_EQ(&local_state_, browser_process_->local_state()); |
| 136 browser_process_->SetLocalState(NULL); | 133 browser_process_->SetLocalState(NULL); |
| 137 } | 134 } |
| OLD | NEW |