Chromium Code Reviews| 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/browser/extensions/test_extension_prefs.h" | 5 #include "chrome/browser/extensions/test_extension_prefs.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
| 12 #include "base/message_loop_proxy.h" | 12 #include "base/message_loop_proxy.h" |
| 13 #include "base/prefs/json_pref_store.h" | 13 #include "base/prefs/json_pref_store.h" |
| 14 #include "base/run_loop.h" | 14 #include "base/run_loop.h" |
| 15 #include "base/sequenced_task_runner.h" | 15 #include "base/sequenced_task_runner.h" |
| 16 #include "base/synchronization/waitable_event.h" | 16 #include "base/synchronization/waitable_event.h" |
| 17 #include "base/values.h" | 17 #include "base/values.h" |
| 18 #include "chrome/browser/extensions/extension_pref_store.h" | 18 #include "chrome/browser/extensions/extension_pref_store.h" |
| 19 #include "chrome/browser/extensions/extension_pref_value_map.h" | 19 #include "chrome/browser/extensions/extension_pref_value_map.h" |
| 20 #include "chrome/browser/extensions/extension_prefs.h" | 20 #include "chrome/browser/extensions/extension_prefs.h" |
| 21 #include "chrome/browser/prefs/pref_service.h" | 21 #include "chrome/browser/prefs/pref_registry_syncable.h" |
| 22 #include "chrome/browser/prefs/pref_service_mock_builder.h" | 22 #include "chrome/browser/prefs/pref_service_mock_builder.h" |
| 23 #include "chrome/browser/prefs/pref_service_syncable.h" | |
| 23 #include "chrome/browser/prefs/pref_value_store.h" | 24 #include "chrome/browser/prefs/pref_value_store.h" |
| 24 #include "chrome/common/extensions/extension.h" | 25 #include "chrome/common/extensions/extension.h" |
| 25 #include "chrome/common/extensions/extension_manifest_constants.h" | 26 #include "chrome/common/extensions/extension_manifest_constants.h" |
| 26 #include "content/public/browser/browser_thread.h" | 27 #include "content/public/browser/browser_thread.h" |
| 27 #include "sync/api/string_ordinal.h" | 28 #include "sync/api/string_ordinal.h" |
| 28 #include "testing/gtest/include/gtest/gtest.h" | 29 #include "testing/gtest/include/gtest/gtest.h" |
| 29 | 30 |
| 30 using content::BrowserThread; | 31 using content::BrowserThread; |
| 31 | 32 |
| 32 namespace extensions { | 33 namespace extensions { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 86 base::Bind(&base::DoNothing), | 87 base::Bind(&base::DoNothing), |
| 87 run_loop.QuitClosure())); | 88 run_loop.QuitClosure())); |
| 88 run_loop.Run(); | 89 run_loop.Run(); |
| 89 } | 90 } |
| 90 | 91 |
| 91 extension_pref_value_map_.reset(new ExtensionPrefValueMap); | 92 extension_pref_value_map_.reset(new ExtensionPrefValueMap); |
| 92 PrefServiceMockBuilder builder; | 93 PrefServiceMockBuilder builder; |
| 93 builder.WithUserFilePrefs(preferences_file_, task_runner_); | 94 builder.WithUserFilePrefs(preferences_file_, task_runner_); |
| 94 builder.WithExtensionPrefs( | 95 builder.WithExtensionPrefs( |
| 95 new ExtensionPrefStore(extension_pref_value_map_.get(), false)); | 96 new ExtensionPrefStore(extension_pref_value_map_.get(), false)); |
| 96 pref_service_.reset(builder.CreateSyncable()); | 97 scoped_refptr<PrefRegistrySyncable> registry(new PrefRegistrySyncable); |
|
Mattias Nissler (ping if slow)
2013/02/06 17:53:33
As mentioned elsewhere, it would probably be nice
Jói
2013/02/07 14:52:32
Done.
| |
| 97 ExtensionPrefs::RegisterUserPrefs(pref_service_.get()); | 98 pref_service_.reset(builder.CreateSyncable(registry)); |
| 99 ExtensionPrefs::RegisterUserPrefs(registry); | |
|
Mattias Nissler (ping if slow)
2013/02/06 17:53:33
For good measure, can we swap lines 98 and 99?
Jói
2013/02/07 14:52:32
Done.
| |
| 98 | 100 |
| 99 prefs_ = ExtensionPrefs::Create( | 101 prefs_ = ExtensionPrefs::Create( |
| 100 pref_service_.get(), | 102 pref_service_.get(), |
| 101 temp_dir_.path(), | 103 temp_dir_.path(), |
| 102 extension_pref_value_map_.get(), | 104 extension_pref_value_map_.get(), |
| 103 extensions_disabled_, | 105 extensions_disabled_, |
| 104 // Guarantee that no two extensions get the same installation time | 106 // Guarantee that no two extensions get the same installation time |
| 105 // stamp and we can reliably assert the installation order in the tests. | 107 // stamp and we can reliably assert the installation order in the tests. |
| 106 scoped_ptr<ExtensionPrefs::TimeProvider>( | 108 scoped_ptr<ExtensionPrefs::TimeProvider>( |
| 107 new IncrementalTimeProvider())); | 109 new IncrementalTimeProvider())); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 159 PrefServiceSyncable* TestExtensionPrefs::CreateIncognitoPrefService() const { | 161 PrefServiceSyncable* TestExtensionPrefs::CreateIncognitoPrefService() const { |
| 160 return pref_service_->CreateIncognitoPrefService( | 162 return pref_service_->CreateIncognitoPrefService( |
| 161 new ExtensionPrefStore(extension_pref_value_map_.get(), true)); | 163 new ExtensionPrefStore(extension_pref_value_map_.get(), true)); |
| 162 } | 164 } |
| 163 | 165 |
| 164 void TestExtensionPrefs::set_extensions_disabled(bool extensions_disabled) { | 166 void TestExtensionPrefs::set_extensions_disabled(bool extensions_disabled) { |
| 165 extensions_disabled_ = extensions_disabled; | 167 extensions_disabled_ = extensions_disabled; |
| 166 } | 168 } |
| 167 | 169 |
| 168 } // namespace extensions | 170 } // namespace extensions |
| OLD | NEW |