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 | 7 |
8 #include "base/auto_reset.h" | 8 #include "base/auto_reset.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
11 #include "base/json/json_writer.h" | 11 #include "base/json/json_writer.h" |
12 #include "base/memory/ptr_util.h" | |
12 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
13 #include "chrome/browser/content_settings/content_settings_mock_observer.h" | 14 #include "chrome/browser/content_settings/content_settings_mock_observer.h" |
14 #include "chrome/browser/content_settings/cookie_settings_factory.h" | 15 #include "chrome/browser/content_settings/cookie_settings_factory.h" |
15 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 16 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
16 #include "chrome/browser/content_settings/mock_settings_observer.h" | 17 #include "chrome/browser/content_settings/mock_settings_observer.h" |
17 #include "chrome/common/url_constants.h" | 18 #include "chrome/common/url_constants.h" |
18 #include "chrome/test/base/testing_profile.h" | 19 #include "chrome/test/base/testing_profile.h" |
19 #include "components/content_settings/core/browser/content_settings_details.h" | 20 #include "components/content_settings/core/browser/content_settings_details.h" |
20 #include "components/content_settings/core/browser/cookie_settings.h" | 21 #include "components/content_settings/core/browser/cookie_settings.h" |
21 #include "components/content_settings/core/browser/host_content_settings_map.h" | 22 #include "components/content_settings/core/browser/host_content_settings_map.h" |
(...skipping 822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
844 host, host, CONTENT_SETTINGS_TYPE_USB_CHOOSER_DATA, | 845 host, host, CONTENT_SETTINGS_TYPE_USB_CHOOSER_DATA, |
845 std::string(), nullptr)); | 846 std::string(), nullptr)); |
846 EXPECT_EQ(nullptr, otr_map->GetWebsiteSetting( | 847 EXPECT_EQ(nullptr, otr_map->GetWebsiteSetting( |
847 host, host, CONTENT_SETTINGS_TYPE_USB_CHOOSER_DATA, | 848 host, host, CONTENT_SETTINGS_TYPE_USB_CHOOSER_DATA, |
848 std::string(), nullptr)); | 849 std::string(), nullptr)); |
849 | 850 |
850 base::DictionaryValue test_value; | 851 base::DictionaryValue test_value; |
851 test_value.SetString("test", "value"); | 852 test_value.SetString("test", "value"); |
852 host_content_settings_map->SetWebsiteSettingDefaultScope( | 853 host_content_settings_map->SetWebsiteSettingDefaultScope( |
853 host, host, CONTENT_SETTINGS_TYPE_USB_CHOOSER_DATA, std::string(), | 854 host, host, CONTENT_SETTINGS_TYPE_USB_CHOOSER_DATA, std::string(), |
854 test_value.DeepCopy()); | 855 base::WrapUnique(test_value.DeepCopy())); |
855 | 856 |
856 // The setting is not inherted by |otr_map|. | 857 // The setting is not inherted by |otr_map|. |
857 std::unique_ptr<base::Value> stored_value = | 858 std::unique_ptr<base::Value> stored_value = |
858 host_content_settings_map->GetWebsiteSetting( | 859 host_content_settings_map->GetWebsiteSetting( |
859 host, host, CONTENT_SETTINGS_TYPE_USB_CHOOSER_DATA, std::string(), | 860 host, host, CONTENT_SETTINGS_TYPE_USB_CHOOSER_DATA, std::string(), |
860 nullptr); | 861 nullptr); |
861 EXPECT_TRUE(stored_value && stored_value->Equals(&test_value)); | 862 EXPECT_TRUE(stored_value && stored_value->Equals(&test_value)); |
862 EXPECT_EQ(nullptr, otr_map->GetWebsiteSetting( | 863 EXPECT_EQ(nullptr, otr_map->GetWebsiteSetting( |
863 host, host, CONTENT_SETTINGS_TYPE_USB_CHOOSER_DATA, | 864 host, host, CONTENT_SETTINGS_TYPE_USB_CHOOSER_DATA, |
864 std::string(), nullptr)); | 865 std::string(), nullptr)); |
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1309 host_content_settings_map->GetContentSetting( | 1310 host_content_settings_map->GetContentSetting( |
1310 host, host, CONTENT_SETTINGS_TYPE_KEYGEN, std::string())); | 1311 host, host, CONTENT_SETTINGS_TYPE_KEYGEN, std::string())); |
1311 | 1312 |
1312 // After migrating old settings, changes to the setting works. | 1313 // After migrating old settings, changes to the setting works. |
1313 host_content_settings_map->SetContentSettingDefaultScope( | 1314 host_content_settings_map->SetContentSettingDefaultScope( |
1314 host, GURL(), CONTENT_SETTINGS_TYPE_KEYGEN, std::string(), | 1315 host, GURL(), CONTENT_SETTINGS_TYPE_KEYGEN, std::string(), |
1315 CONTENT_SETTING_BLOCK); | 1316 CONTENT_SETTING_BLOCK); |
1316 EXPECT_EQ(CONTENT_SETTING_BLOCK, | 1317 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
1317 host_content_settings_map->GetContentSetting( | 1318 host_content_settings_map->GetContentSetting( |
1318 host, host, CONTENT_SETTINGS_TYPE_KEYGEN, std::string())); | 1319 host, host, CONTENT_SETTINGS_TYPE_KEYGEN, std::string())); |
1319 } | 1320 } |
raymes
2016/06/09 05:59:21
Could we add a simple test to cover the case of an
dominickn
2016/06/09 06:09:44
Thanks for the test! Done!
| |
OLD | NEW |