Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(257)

Side by Side Diff: chrome/browser/extensions/test_extension_prefs.cc

Issue 64193003: Clean up PrefServiceBuilder (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix memory ownership bug in ProxyPolicyTest Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/message_loop.h" 11 #include "base/message_loop/message_loop.h"
12 #include "base/message_loop/message_loop_proxy.h" 12 #include "base/message_loop/message_loop_proxy.h"
13 #include "base/prefs/json_pref_store.h" 13 #include "base/prefs/json_pref_store.h"
14 #include "base/prefs/pref_value_store.h" 14 #include "base/prefs/pref_value_store.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/values.h" 18 #include "base/values.h"
19 #include "chrome/browser/extensions/extension_pref_store.h" 19 #include "chrome/browser/extensions/extension_pref_store.h"
20 #include "chrome/browser/extensions/extension_pref_value_map.h" 20 #include "chrome/browser/extensions/extension_pref_value_map.h"
21 #include "chrome/browser/extensions/extension_prefs.h" 21 #include "chrome/browser/extensions/extension_prefs.h"
22 #include "chrome/browser/prefs/pref_service_mock_builder.h" 22 #include "chrome/browser/prefs/pref_service_mock_factory.h"
23 #include "chrome/browser/prefs/pref_service_syncable.h" 23 #include "chrome/browser/prefs/pref_service_syncable.h"
24 #include "components/user_prefs/pref_registry_syncable.h" 24 #include "components/user_prefs/pref_registry_syncable.h"
25 #include "content/public/browser/browser_thread.h" 25 #include "content/public/browser/browser_thread.h"
26 #include "extensions/common/extension.h" 26 #include "extensions/common/extension.h"
27 #include "extensions/common/manifest_constants.h" 27 #include "extensions/common/manifest_constants.h"
28 #include "sync/api/string_ordinal.h" 28 #include "sync/api/string_ordinal.h"
29 #include "testing/gtest/include/gtest/gtest.h" 29 #include "testing/gtest/include/gtest/gtest.h"
30 30
31 using content::BrowserThread; 31 using content::BrowserThread;
32 32
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 base::RunLoop run_loop; 96 base::RunLoop run_loop;
97 ASSERT_TRUE( 97 ASSERT_TRUE(
98 task_runner_->PostTaskAndReply( 98 task_runner_->PostTaskAndReply(
99 FROM_HERE, 99 FROM_HERE,
100 base::Bind(&base::DoNothing), 100 base::Bind(&base::DoNothing),
101 run_loop.QuitClosure())); 101 run_loop.QuitClosure()));
102 run_loop.Run(); 102 run_loop.Run();
103 } 103 }
104 104
105 extension_pref_value_map_.reset(new ExtensionPrefValueMap); 105 extension_pref_value_map_.reset(new ExtensionPrefValueMap);
106 PrefServiceMockBuilder builder; 106 PrefServiceMockFactory factory;
107 builder.WithUserFilePrefs(preferences_file_, task_runner_.get()); 107 factory.SetUserPrefsFile(preferences_file_, task_runner_.get());
108 builder.WithExtensionPrefs( 108 factory.set_extension_prefs(
109 new ExtensionPrefStore(extension_pref_value_map_.get(), false)); 109 new ExtensionPrefStore(extension_pref_value_map_.get(), false));
110 pref_service_.reset(builder.CreateSyncable(pref_registry_.get())); 110 pref_service_ = factory.CreateSyncable(pref_registry_.get()).Pass();
111 111
112 prefs_.reset(ExtensionPrefs::Create( 112 prefs_.reset(ExtensionPrefs::Create(
113 pref_service_.get(), 113 pref_service_.get(),
114 temp_dir_.path(), 114 temp_dir_.path(),
115 extension_pref_value_map_.get(), 115 extension_pref_value_map_.get(),
116 extensions_disabled_, 116 extensions_disabled_,
117 // Guarantee that no two extensions get the same installation time 117 // Guarantee that no two extensions get the same installation time
118 // stamp and we can reliably assert the installation order in the tests. 118 // stamp and we can reliably assert the installation order in the tests.
119 scoped_ptr<ExtensionPrefs::TimeProvider>( 119 scoped_ptr<ExtensionPrefs::TimeProvider>(
120 new IncrementalTimeProvider()))); 120 new IncrementalTimeProvider())));
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 PrefService* TestExtensionPrefs::CreateIncognitoPrefService() const { 173 PrefService* TestExtensionPrefs::CreateIncognitoPrefService() const {
174 return pref_service_->CreateIncognitoPrefService( 174 return pref_service_->CreateIncognitoPrefService(
175 new ExtensionPrefStore(extension_pref_value_map_.get(), true)); 175 new ExtensionPrefStore(extension_pref_value_map_.get(), true));
176 } 176 }
177 177
178 void TestExtensionPrefs::set_extensions_disabled(bool extensions_disabled) { 178 void TestExtensionPrefs::set_extensions_disabled(bool extensions_disabled) {
179 extensions_disabled_ = extensions_disabled; 179 extensions_disabled_ = extensions_disabled;
180 } 180 }
181 181
182 } // namespace extensions 182 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_service_unittest.cc ('k') | chrome/browser/net/pref_proxy_config_tracker_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698