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 <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
12 #include "base/files/file_util.h" | 12 #include "base/files/file_util.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
15 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
16 #include "base/sequenced_task_runner.h" | 16 #include "base/sequenced_task_runner.h" |
17 #include "base/synchronization/waitable_event.h" | 17 #include "base/synchronization/waitable_event.h" |
18 #include "base/threading/thread_task_runner_handle.h" | 18 #include "base/threading/thread_task_runner_handle.h" |
19 #include "base/values.h" | 19 #include "base/values.h" |
20 #include "chrome/browser/extensions/chrome_app_sorting.h" | 20 #include "chrome/browser/extensions/chrome_app_sorting.h" |
21 #include "chrome/browser/extensions/test_extension_system.h" | 21 #include "chrome/browser/extensions/test_extension_system.h" |
22 #include "chrome/browser/prefs/pref_service_syncable_util.h" | 22 #include "chrome/browser/prefs/pref_service_syncable_util.h" |
23 #include "chrome/common/chrome_constants.h" | 23 #include "chrome/common/chrome_constants.h" |
24 #include "components/crx_file/id_util.h" | 24 #include "components/crx_file/id_util.h" |
25 #include "components/pref_registry/pref_registry_syncable.h" | 25 #include "components/pref_registry/pref_registry_syncable.h" |
26 #include "components/prefs/json_pref_store.h" | 26 #include "components/prefs/json_pref_store.h" |
27 #include "components/prefs/pref_value_store.h" | 27 #include "components/prefs/pref_value_store.h" |
28 #include "components/sync/model/string_ordinal.h" | 28 #include "components/sync/model/string_ordinal.h" |
29 #include "components/syncable_prefs/pref_service_mock_factory.h" | 29 #include "components/sync_preferences/pref_service_mock_factory.h" |
30 #include "components/syncable_prefs/pref_service_syncable.h" | 30 #include "components/sync_preferences/pref_service_syncable.h" |
31 #include "content/public/browser/browser_thread.h" | 31 #include "content/public/browser/browser_thread.h" |
32 #include "extensions/browser/extension_pref_store.h" | 32 #include "extensions/browser/extension_pref_store.h" |
33 #include "extensions/browser/extension_pref_value_map.h" | 33 #include "extensions/browser/extension_pref_value_map.h" |
34 #include "extensions/browser/extension_prefs.h" | 34 #include "extensions/browser/extension_prefs.h" |
35 #include "extensions/browser/extension_prefs_factory.h" | 35 #include "extensions/browser/extension_prefs_factory.h" |
36 #include "extensions/browser/extension_system.h" | 36 #include "extensions/browser/extension_system.h" |
37 #include "extensions/browser/extensions_browser_client.h" | 37 #include "extensions/browser/extensions_browser_client.h" |
38 #include "extensions/common/extension.h" | 38 #include "extensions/common/extension.h" |
39 #include "extensions/common/manifest_constants.h" | 39 #include "extensions/common/manifest_constants.h" |
40 #include "testing/gtest/include/gtest/gtest.h" | 40 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 base::RunLoop run_loop; | 111 base::RunLoop run_loop; |
112 ASSERT_TRUE( | 112 ASSERT_TRUE( |
113 task_runner_->PostTaskAndReply( | 113 task_runner_->PostTaskAndReply( |
114 FROM_HERE, | 114 FROM_HERE, |
115 base::Bind(&base::DoNothing), | 115 base::Bind(&base::DoNothing), |
116 run_loop.QuitClosure())); | 116 run_loop.QuitClosure())); |
117 run_loop.Run(); | 117 run_loop.Run(); |
118 } | 118 } |
119 | 119 |
120 extension_pref_value_map_.reset(new ExtensionPrefValueMap); | 120 extension_pref_value_map_.reset(new ExtensionPrefValueMap); |
121 syncable_prefs::PrefServiceMockFactory factory; | 121 sync_preferences::PrefServiceMockFactory factory; |
122 factory.SetUserPrefsFile(preferences_file_, task_runner_.get()); | 122 factory.SetUserPrefsFile(preferences_file_, task_runner_.get()); |
123 factory.set_extension_prefs( | 123 factory.set_extension_prefs( |
124 new ExtensionPrefStore(extension_pref_value_map_.get(), false)); | 124 new ExtensionPrefStore(extension_pref_value_map_.get(), false)); |
125 pref_service_ = factory.CreateSyncable(pref_registry_.get()); | 125 pref_service_ = factory.CreateSyncable(pref_registry_.get()); |
126 std::unique_ptr<ExtensionPrefs> prefs(ExtensionPrefs::Create( | 126 std::unique_ptr<ExtensionPrefs> prefs(ExtensionPrefs::Create( |
127 &profile_, pref_service_.get(), temp_dir_.GetPath(), | 127 &profile_, pref_service_.get(), temp_dir_.GetPath(), |
128 extension_pref_value_map_.get(), extensions_disabled_, | 128 extension_pref_value_map_.get(), extensions_disabled_, |
129 std::vector<ExtensionPrefsObserver*>(), | 129 std::vector<ExtensionPrefsObserver*>(), |
130 // Guarantee that no two extensions get the same installation time | 130 // Guarantee that no two extensions get the same installation time |
131 // stamp and we can reliably assert the installation order in the tests. | 131 // stamp and we can reliably assert the installation order in the tests. |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 void TestExtensionPrefs::set_extensions_disabled(bool extensions_disabled) { | 207 void TestExtensionPrefs::set_extensions_disabled(bool extensions_disabled) { |
208 extensions_disabled_ = extensions_disabled; | 208 extensions_disabled_ = extensions_disabled; |
209 } | 209 } |
210 | 210 |
211 ChromeAppSorting* TestExtensionPrefs::app_sorting() { | 211 ChromeAppSorting* TestExtensionPrefs::app_sorting() { |
212 return static_cast<ChromeAppSorting*>( | 212 return static_cast<ChromeAppSorting*>( |
213 ExtensionSystem::Get(&profile_)->app_sorting()); | 213 ExtensionSystem::Get(&profile_)->app_sorting()); |
214 } | 214 } |
215 | 215 |
216 } // namespace extensions | 216 } // namespace extensions |
OLD | NEW |