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

Side by Side Diff: chrome/browser/content_settings/content_settings_default_provider_unittest.cc

Issue 1004733003: Split the default content settings into syncable and nonsyncable. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reset PMI, reacting to unsyncable pref changes as well. Created 5 years, 9 months 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/memory/scoped_ptr.h" 5 #include "base/memory/scoped_ptr.h"
6 #include "base/message_loop/message_loop.h" 6 #include "base/message_loop/message_loop.h"
7 #include "base/prefs/pref_service.h" 7 #include "base/prefs/pref_service.h"
8 #include "base/prefs/scoped_user_pref_update.h"
8 #include "base/prefs/testing_pref_service.h" 9 #include "base/prefs/testing_pref_service.h"
9 #include "chrome/browser/content_settings/content_settings_mock_observer.h" 10 #include "chrome/browser/content_settings/content_settings_mock_observer.h"
10 #include "chrome/common/pref_names.h" 11 #include "chrome/common/pref_names.h"
11 #include "chrome/test/base/testing_profile.h" 12 #include "chrome/test/base/testing_profile.h"
12 #include "components/content_settings/core/browser/content_settings_default_prov ider.h" 13 #include "components/content_settings/core/browser/content_settings_default_prov ider.h"
13 #include "components/content_settings/core/browser/content_settings_utils.h" 14 #include "components/content_settings/core/browser/content_settings_utils.h"
14 #include "components/content_settings/core/test/content_settings_test_utils.h" 15 #include "components/content_settings/core/test/content_settings_test_utils.h"
15 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
16 #include "url/gurl.h" 17 #include "url/gurl.h"
17 18
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 245
245 EXPECT_EQ(CONTENT_SETTING_BLOCK, 246 EXPECT_EQ(CONTENT_SETTING_BLOCK,
246 GetContentSetting(&otr_provider, 247 GetContentSetting(&otr_provider,
247 GURL(), 248 GURL(),
248 GURL(), 249 GURL(),
249 CONTENT_SETTINGS_TYPE_COOKIES, 250 CONTENT_SETTINGS_TYPE_COOKIES,
250 std::string(), 251 std::string(),
251 true)); 252 true));
252 otr_provider.ShutdownOnUIThread(); 253 otr_provider.ShutdownOnUIThread();
253 } 254 }
255
256
257 // TODO(msramek): The two tests below test syncing between old versions
258 // of Chrome using a dictionary pref and new versions using individual integer
259 // prefs for default content settings. Remove the tests together with
260 // the dictionary setting after two stable releases.
261 TEST_F(DefaultProviderTest, SyncFromDictionaryToIndividualPreferences) {
262 PrefService* prefs = profile_.GetPrefs();
263
264 {
265 DictionaryPrefUpdate update(prefs, prefs::kDefaultContentSettings);
266 base::DictionaryValue* default_settings_dictionary = update.Get();
267
268 default_settings_dictionary->SetWithoutPathExpansion(
269 content_settings::GetTypeName(CONTENT_SETTINGS_TYPE_COOKIES),
270 new base::FundamentalValue(CONTENT_SETTING_BLOCK));
271 default_settings_dictionary->SetWithoutPathExpansion(
272 content_settings::GetTypeName(CONTENT_SETTINGS_TYPE_GEOLOCATION),
273 new base::FundamentalValue(CONTENT_SETTING_BLOCK));
274 }
275
276 // Cookies should sync, but geolocation should not.
277 EXPECT_EQ(CONTENT_SETTING_BLOCK, IntToContentSetting(
278 prefs->GetInteger(prefs::kDefaultCookiesSetting)));
279 EXPECT_EQ(CONTENT_SETTING_ASK, IntToContentSetting(
280 prefs->GetInteger(prefs::kDefaultGeolocationSetting)));
281 }
282
283 TEST_F(DefaultProviderTest, SyncFromIndividualPreferencesToDictionary) {
284 PrefService* prefs = profile_.GetPrefs();
285
286 prefs->SetInteger(prefs::kDefaultJavaScriptSetting, CONTENT_SETTING_BLOCK);
287 prefs->SetInteger(prefs::kDefaultSSLCertDecisionsSetting,
288 CONTENT_SETTING_BLOCK);
289
290 // Javascript should sync, but cert decisions should not.
291 const base::DictionaryValue* default_settings_dictionary =
292 prefs->GetDictionary(prefs::kDefaultContentSettings);
293 int js_setting;
294 bool has_cd_setting;
295
296 default_settings_dictionary->GetIntegerWithoutPathExpansion(
297 content_settings::GetTypeName(CONTENT_SETTINGS_TYPE_JAVASCRIPT),
298 &js_setting);
299 has_cd_setting = default_settings_dictionary->HasKey(
300 content_settings::GetTypeName(CONTENT_SETTINGS_TYPE_SSL_CERT_DECISIONS));
301
302 EXPECT_EQ(CONTENT_SETTING_BLOCK, IntToContentSetting(js_setting));
303 EXPECT_FALSE(has_cd_setting);
304 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698