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

Side by Side Diff: chrome/browser/content_settings/content_settings_pref_provider_unittest.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/content_settings/content_settings_pref_provider.h" 5 #include "chrome/browser/content_settings/content_settings_pref_provider.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
11 #include "base/prefs/default_pref_store.h" 11 #include "base/prefs/default_pref_store.h"
12 #include "base/prefs/overlay_user_pref_store.h" 12 #include "base/prefs/overlay_user_pref_store.h"
13 #include "base/prefs/pref_change_registrar.h" 13 #include "base/prefs/pref_change_registrar.h"
14 #include "base/prefs/pref_service.h" 14 #include "base/prefs/pref_service.h"
15 #include "base/prefs/scoped_user_pref_update.h" 15 #include "base/prefs/scoped_user_pref_update.h"
16 #include "base/prefs/testing_pref_store.h" 16 #include "base/prefs/testing_pref_store.h"
17 #include "base/threading/platform_thread.h" 17 #include "base/threading/platform_thread.h"
18 #include "base/values.h" 18 #include "base/values.h"
19 #include "chrome/browser/content_settings/content_settings_mock_observer.h" 19 #include "chrome/browser/content_settings/content_settings_mock_observer.h"
20 #include "chrome/browser/content_settings/content_settings_utils.h" 20 #include "chrome/browser/content_settings/content_settings_utils.h"
21 #include "chrome/browser/prefs/browser_prefs.h" 21 #include "chrome/browser/prefs/browser_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 "chrome/common/chrome_switches.h" 24 #include "chrome/common/chrome_switches.h"
25 #include "chrome/common/pref_names.h" 25 #include "chrome/common/pref_names.h"
26 #include "chrome/common/url_constants.h" 26 #include "chrome/common/url_constants.h"
27 #include "chrome/test/base/testing_pref_service_syncable.h" 27 #include "chrome/test/base/testing_pref_service_syncable.h"
28 #include "chrome/test/base/testing_profile.h" 28 #include "chrome/test/base/testing_profile.h"
29 #include "components/user_prefs/pref_registry_syncable.h" 29 #include "components/user_prefs/pref_registry_syncable.h"
30 #include "content/public/test/test_browser_thread.h" 30 #include "content/public/test/test_browser_thread.h"
31 #include "testing/gtest/include/gtest/gtest.h" 31 #include "testing/gtest/include/gtest/gtest.h"
32 #include "url/gurl.h" 32 #include "url/gurl.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 pref_content_settings_provider.ShutdownOnUIThread(); 127 pref_content_settings_provider.ShutdownOnUIThread();
128 } 128 }
129 129
130 // Test for regression in which the PrefProvider modified the user pref store 130 // Test for regression in which the PrefProvider modified the user pref store
131 // of the OTR unintentionally: http://crbug.com/74466. 131 // of the OTR unintentionally: http://crbug.com/74466.
132 TEST_F(PrefProviderTest, Incognito) { 132 TEST_F(PrefProviderTest, Incognito) {
133 PersistentPrefStore* user_prefs = new TestingPrefStore(); 133 PersistentPrefStore* user_prefs = new TestingPrefStore();
134 OverlayUserPrefStore* otr_user_prefs = 134 OverlayUserPrefStore* otr_user_prefs =
135 new OverlayUserPrefStore(user_prefs); 135 new OverlayUserPrefStore(user_prefs);
136 136
137 PrefServiceMockBuilder builder; 137 PrefServiceMockFactory factory;
138 builder.WithUserPrefs(user_prefs); 138 factory.set_user_prefs(make_scoped_refptr(user_prefs));
139 scoped_refptr<user_prefs::PrefRegistrySyncable> registry( 139 scoped_refptr<user_prefs::PrefRegistrySyncable> registry(
140 new user_prefs::PrefRegistrySyncable); 140 new user_prefs::PrefRegistrySyncable);
141 PrefServiceSyncable* regular_prefs = builder.CreateSyncable(registry.get()); 141 PrefServiceSyncable* regular_prefs =
142 factory.CreateSyncable(registry.get()).release();
142 143
143 chrome::RegisterUserProfilePrefs(registry.get()); 144 chrome::RegisterUserProfilePrefs(registry.get());
144 145
145 builder.WithUserPrefs(otr_user_prefs); 146 PrefServiceMockFactory otr_factory;
147 otr_factory.set_user_prefs(make_scoped_refptr(otr_user_prefs));
146 scoped_refptr<user_prefs::PrefRegistrySyncable> otr_registry( 148 scoped_refptr<user_prefs::PrefRegistrySyncable> otr_registry(
147 new user_prefs::PrefRegistrySyncable); 149 new user_prefs::PrefRegistrySyncable);
148 PrefServiceSyncable* otr_prefs = builder.CreateSyncable(otr_registry.get()); 150 PrefServiceSyncable* otr_prefs =
151 otr_factory.CreateSyncable(otr_registry.get()).release();
149 152
150 chrome::RegisterUserProfilePrefs(otr_registry.get()); 153 chrome::RegisterUserProfilePrefs(otr_registry.get());
151 154
152 TestingProfile::Builder profile_builder; 155 TestingProfile::Builder profile_builder;
153 profile_builder.SetPrefService(make_scoped_ptr(regular_prefs)); 156 profile_builder.SetPrefService(make_scoped_ptr(regular_prefs));
154 scoped_ptr<TestingProfile> profile = profile_builder.Build(); 157 scoped_ptr<TestingProfile> profile = profile_builder.Build();
155 158
156 TestingProfile::Builder otr_profile_builder; 159 TestingProfile::Builder otr_profile_builder;
157 otr_profile_builder.SetIncognito(); 160 otr_profile_builder.SetIncognito();
158 otr_profile_builder.SetPrefService(make_scoped_ptr(otr_prefs)); 161 otr_profile_builder.SetPrefService(make_scoped_ptr(otr_prefs));
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 DictionaryValue* mutable_settings = update.Get(); 437 DictionaryValue* mutable_settings = update.Get();
435 mutable_settings->SetWithoutPathExpansion("www.example.com,*", 438 mutable_settings->SetWithoutPathExpansion("www.example.com,*",
436 new base::DictionaryValue()); 439 new base::DictionaryValue());
437 } 440 }
438 EXPECT_TRUE(observer.notification_received()); 441 EXPECT_TRUE(observer.notification_received());
439 442
440 provider.ShutdownOnUIThread(); 443 provider.ShutdownOnUIThread();
441 } 444 }
442 445
443 } // namespace content_settings 446 } // namespace content_settings
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698