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

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

Issue 2806283002: Revert of Stop passing raw pointers to base::Value API in c/b/chromeos and c/b/extensions (Closed)
Patch Set: Created 3 years, 8 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) 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 <memory> 5 #include <memory>
6 #include <string> 6 #include <string>
7 #include <utility>
8 7
9 #include "base/auto_reset.h" 8 #include "base/auto_reset.h"
10 #include "base/command_line.h" 9 #include "base/command_line.h"
11 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
12 #include "base/json/json_writer.h" 11 #include "base/json/json_writer.h"
13 #include "base/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
14 #include "base/message_loop/message_loop.h" 13 #include "base/message_loop/message_loop.h"
15 #include "chrome/browser/content_settings/content_settings_mock_observer.h" 14 #include "chrome/browser/content_settings/content_settings_mock_observer.h"
16 #include "chrome/browser/content_settings/cookie_settings_factory.h" 15 #include "chrome/browser/content_settings/cookie_settings_factory.h"
17 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" 16 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
(...skipping 961 matching lines...) Expand 10 before | Expand all | Expand 10 after
979 TestingProfile profile; 978 TestingProfile profile;
980 PrefService* prefs = profile.GetPrefs(); 979 PrefService* prefs = profile.GetPrefs();
981 980
982 // Set utf-8 data. 981 // Set utf-8 data.
983 { 982 {
984 DictionaryPrefUpdate update(prefs, 983 DictionaryPrefUpdate update(prefs,
985 GetPrefName(CONTENT_SETTINGS_TYPE_COOKIES)); 984 GetPrefName(CONTENT_SETTINGS_TYPE_COOKIES));
986 base::DictionaryValue* all_settings_dictionary = update.Get(); 985 base::DictionaryValue* all_settings_dictionary = update.Get();
987 ASSERT_TRUE(NULL != all_settings_dictionary); 986 ASSERT_TRUE(NULL != all_settings_dictionary);
988 987
989 auto dummy_payload = base::MakeUnique<base::DictionaryValue>(); 988 base::DictionaryValue* dummy_payload = new base::DictionaryValue;
990 dummy_payload->SetInteger("setting", CONTENT_SETTING_ALLOW); 989 dummy_payload->SetInteger("setting", CONTENT_SETTING_ALLOW);
991 all_settings_dictionary->SetWithoutPathExpansion("[*.]\xC4\x87ira.com,*", 990 all_settings_dictionary->SetWithoutPathExpansion("[*.]\xC4\x87ira.com,*",
992 std::move(dummy_payload)); 991 dummy_payload);
993 } 992 }
994 993
995 HostContentSettingsMapFactory::GetForProfile(&profile); 994 HostContentSettingsMapFactory::GetForProfile(&profile);
996 995
997 const base::DictionaryValue* all_settings_dictionary = 996 const base::DictionaryValue* all_settings_dictionary =
998 prefs->GetDictionary(GetPrefName(CONTENT_SETTINGS_TYPE_COOKIES)); 997 prefs->GetDictionary(GetPrefName(CONTENT_SETTINGS_TYPE_COOKIES));
999 const base::DictionaryValue* result = NULL; 998 const base::DictionaryValue* result = NULL;
1000 EXPECT_FALSE(all_settings_dictionary->GetDictionaryWithoutPathExpansion( 999 EXPECT_FALSE(all_settings_dictionary->GetDictionaryWithoutPathExpansion(
1001 "[*.]\xC4\x87ira.com,*", &result)); 1000 "[*.]\xC4\x87ira.com,*", &result));
1002 EXPECT_TRUE(all_settings_dictionary->GetDictionaryWithoutPathExpansion( 1001 EXPECT_TRUE(all_settings_dictionary->GetDictionaryWithoutPathExpansion(
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after
1514 GURL http_host_narrower("http://a.example.com/"); 1513 GURL http_host_narrower("http://a.example.com/");
1515 std::string host_pattern_string = 1514 std::string host_pattern_string =
1516 ContentSettingsPattern::FromURL(http_host).ToString(); 1515 ContentSettingsPattern::FromURL(http_host).ToString();
1517 1516
1518 { 1517 {
1519 DictionaryPrefUpdate update(prefs, 1518 DictionaryPrefUpdate update(prefs,
1520 GetPrefName(CONTENT_SETTINGS_TYPE_POPUPS)); 1519 GetPrefName(CONTENT_SETTINGS_TYPE_POPUPS));
1521 base::DictionaryValue* all_settings_dictionary = update.Get(); 1520 base::DictionaryValue* all_settings_dictionary = update.Get();
1522 ASSERT_TRUE(NULL != all_settings_dictionary); 1521 ASSERT_TRUE(NULL != all_settings_dictionary);
1523 1522
1524 auto domain_setting = base::MakeUnique<base::DictionaryValue>(); 1523 base::DictionaryValue* domain_setting = new base::DictionaryValue;
1525 domain_setting->SetInteger("setting", CONTENT_SETTING_ALLOW); 1524 domain_setting->SetInteger("setting", CONTENT_SETTING_ALLOW);
1526 all_settings_dictionary->SetWithoutPathExpansion(host_pattern_string + ",*", 1525 all_settings_dictionary->SetWithoutPathExpansion(host_pattern_string + ",*",
1527 std::move(domain_setting)); 1526 domain_setting);
1528 } 1527 }
1529 1528
1530 const base::DictionaryValue* all_settings_dictionary = 1529 const base::DictionaryValue* all_settings_dictionary =
1531 prefs->GetDictionary(GetPrefName(CONTENT_SETTINGS_TYPE_POPUPS)); 1530 prefs->GetDictionary(GetPrefName(CONTENT_SETTINGS_TYPE_POPUPS));
1532 const base::DictionaryValue* result = NULL; 1531 const base::DictionaryValue* result = NULL;
1533 EXPECT_TRUE(all_settings_dictionary->GetDictionaryWithoutPathExpansion( 1532 EXPECT_TRUE(all_settings_dictionary->GetDictionaryWithoutPathExpansion(
1534 "[*.]example.com,*", &result)); 1533 "[*.]example.com,*", &result));
1535 1534
1536 // Migration is done on construction of HostContentSettingsMap. Try to run it 1535 // Migration is done on construction of HostContentSettingsMap. Try to run it
1537 // again. This should not do anything as it has already ran. 1536 // again. This should not do anything as it has already ran.
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
1751 EXPECT_TRUE(map->CanSetNarrowestContentSetting( 1750 EXPECT_TRUE(map->CanSetNarrowestContentSetting(
1752 valid_url, valid_url, 1751 valid_url, valid_url,
1753 CONTENT_SETTINGS_TYPE_POPUPS)); 1752 CONTENT_SETTINGS_TYPE_POPUPS));
1754 1753
1755 GURL invalid_url("about:blank"); 1754 GURL invalid_url("about:blank");
1756 EXPECT_FALSE(map->CanSetNarrowestContentSetting( 1755 EXPECT_FALSE(map->CanSetNarrowestContentSetting(
1757 invalid_url, invalid_url, 1756 invalid_url, invalid_url,
1758 CONTENT_SETTINGS_TYPE_POPUPS)); 1757 CONTENT_SETTINGS_TYPE_POPUPS));
1759 } 1758 }
1760 1759
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698