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