| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/permissions/permission_decision_auto_blocker.h" | 5 #include "chrome/browser/permissions/permission_decision_auto_blocker.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 829 EXPECT_EQ(0, autoblocker()->GetDismissCount( | 829 EXPECT_EQ(0, autoblocker()->GetDismissCount( |
| 830 url, CONTENT_SETTINGS_TYPE_GEOLOCATION)); | 830 url, CONTENT_SETTINGS_TYPE_GEOLOCATION)); |
| 831 EXPECT_EQ( | 831 EXPECT_EQ( |
| 832 0, autoblocker()->GetIgnoreCount(url, CONTENT_SETTINGS_TYPE_GEOLOCATION)); | 832 0, autoblocker()->GetIgnoreCount(url, CONTENT_SETTINGS_TYPE_GEOLOCATION)); |
| 833 | 833 |
| 834 // Trigger pref migration which happens at the creation of the | 834 // Trigger pref migration which happens at the creation of the |
| 835 // HostContentSettingsMap. | 835 // HostContentSettingsMap. |
| 836 { | 836 { |
| 837 scoped_refptr<HostContentSettingsMap> temp_map(new HostContentSettingsMap( | 837 scoped_refptr<HostContentSettingsMap> temp_map(new HostContentSettingsMap( |
| 838 profile()->GetPrefs(), false /* is_incognito_profile */, | 838 profile()->GetPrefs(), false /* is_incognito_profile */, |
| 839 false /* is_guest_profile */)); | 839 false /* is_guest_profile */, false /* store_last_modified */)); |
| 840 temp_map->ShutdownOnUIThread(); | 840 temp_map->ShutdownOnUIThread(); |
| 841 } | 841 } |
| 842 | 842 |
| 843 // The values should now be migrated. | 843 // The values should now be migrated. |
| 844 EXPECT_EQ(100, autoblocker()->GetDismissCount( | 844 EXPECT_EQ(100, autoblocker()->GetDismissCount( |
| 845 url, CONTENT_SETTINGS_TYPE_GEOLOCATION)); | 845 url, CONTENT_SETTINGS_TYPE_GEOLOCATION)); |
| 846 EXPECT_EQ(50, autoblocker()->GetIgnoreCount( | 846 EXPECT_EQ(50, autoblocker()->GetIgnoreCount( |
| 847 url, CONTENT_SETTINGS_TYPE_GEOLOCATION)); | 847 url, CONTENT_SETTINGS_TYPE_GEOLOCATION)); |
| 848 | 848 |
| 849 // The old pref should be deleted. | 849 // The old pref should be deleted. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 861 PermissionUtil::GetPermissionString(CONTENT_SETTINGS_TYPE_GEOLOCATION), | 861 PermissionUtil::GetPermissionString(CONTENT_SETTINGS_TYPE_GEOLOCATION), |
| 862 permissions_dict.CreateDeepCopy()); | 862 permissions_dict.CreateDeepCopy()); |
| 863 map->SetWebsiteSettingDefaultScope( | 863 map->SetWebsiteSettingDefaultScope( |
| 864 url, GURL(), CONTENT_SETTINGS_TYPE_PROMPT_NO_DECISION_COUNT, | 864 url, GURL(), CONTENT_SETTINGS_TYPE_PROMPT_NO_DECISION_COUNT, |
| 865 std::string(), origin_dict.CreateDeepCopy()); | 865 std::string(), origin_dict.CreateDeepCopy()); |
| 866 | 866 |
| 867 // Ensure that migrating again does nothing. | 867 // Ensure that migrating again does nothing. |
| 868 { | 868 { |
| 869 scoped_refptr<HostContentSettingsMap> temp_map(new HostContentSettingsMap( | 869 scoped_refptr<HostContentSettingsMap> temp_map(new HostContentSettingsMap( |
| 870 profile()->GetPrefs(), false /* is_incognito_profile */, | 870 profile()->GetPrefs(), false /* is_incognito_profile */, |
| 871 false /* is_guest_profile */)); | 871 false /* is_guest_profile */, false /* store_last_modified */)); |
| 872 temp_map->ShutdownOnUIThread(); | 872 temp_map->ShutdownOnUIThread(); |
| 873 } | 873 } |
| 874 | 874 |
| 875 EXPECT_EQ(100, autoblocker()->GetDismissCount( | 875 EXPECT_EQ(100, autoblocker()->GetDismissCount( |
| 876 url, CONTENT_SETTINGS_TYPE_GEOLOCATION)); | 876 url, CONTENT_SETTINGS_TYPE_GEOLOCATION)); |
| 877 EXPECT_EQ(50, autoblocker()->GetIgnoreCount( | 877 EXPECT_EQ(50, autoblocker()->GetIgnoreCount( |
| 878 url, CONTENT_SETTINGS_TYPE_GEOLOCATION)); | 878 url, CONTENT_SETTINGS_TYPE_GEOLOCATION)); |
| 879 } | 879 } |
| 880 | 880 |
| 881 // Test that a blacklisted permission should not be autoblocked if the database | 881 // Test that a blacklisted permission should not be autoblocked if the database |
| (...skipping 24 matching lines...) Expand all Loading... |
| 906 db_manager->BlacklistUrlPermissions(url, blacklisted_permissions); | 906 db_manager->BlacklistUrlPermissions(url, blacklisted_permissions); |
| 907 SetSafeBrowsingDatabaseManagerAndTimeoutForTesting(db_manager, | 907 SetSafeBrowsingDatabaseManagerAndTimeoutForTesting(db_manager, |
| 908 0 /* timeout in ms */); | 908 0 /* timeout in ms */); |
| 909 | 909 |
| 910 CheckSafeBrowsingBlacklist(url, CONTENT_SETTINGS_TYPE_NOTIFICATIONS); | 910 CheckSafeBrowsingBlacklist(url, CONTENT_SETTINGS_TYPE_NOTIFICATIONS); |
| 911 EXPECT_FALSE(last_embargoed_status()); | 911 EXPECT_FALSE(last_embargoed_status()); |
| 912 histograms.ExpectUniqueSample( | 912 histograms.ExpectUniqueSample( |
| 913 "Permissions.AutoBlocker.SafeBrowsingResponse", | 913 "Permissions.AutoBlocker.SafeBrowsingResponse", |
| 914 static_cast<int>(SafeBrowsingResponse::NOT_BLACKLISTED), 1); | 914 static_cast<int>(SafeBrowsingResponse::NOT_BLACKLISTED), 1); |
| 915 } | 915 } |
| OLD | NEW |