| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 8 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
| 9 #include "chrome/test/base/testing_profile.h" | 9 #include "chrome/test/base/testing_profile.h" |
| 10 #include "content/public/browser/permission_type.h" | 10 #include "content/public/browser/permission_type.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 return PermissionDecisionAutoBlocker::GetDismissCount( | 29 return PermissionDecisionAutoBlocker::GetDismissCount( |
| 30 url, permission, profile()); | 30 url, permission, profile()); |
| 31 } | 31 } |
| 32 | 32 |
| 33 int GetIgnoreCount(const GURL& url, content::PermissionType permission) { | 33 int GetIgnoreCount(const GURL& url, content::PermissionType permission) { |
| 34 return PermissionDecisionAutoBlocker::GetIgnoreCount( | 34 return PermissionDecisionAutoBlocker::GetIgnoreCount( |
| 35 url, permission, profile()); | 35 url, permission, profile()); |
| 36 } | 36 } |
| 37 | 37 |
| 38 int RecordDismiss(const GURL& url, content::PermissionType permission) { | 38 int RecordDismiss(const GURL& url, content::PermissionType permission) { |
| 39 PermissionDecisionAutoBlocker blocker(profile()); | 39 return PermissionDecisionAutoBlocker::RecordDismiss(url, permission, |
| 40 blocker.ShouldChangeDismissalToBlock(url, permission); | 40 profile()); |
| 41 return PermissionDecisionAutoBlocker::GetDismissCount( | |
| 42 url, permission, profile()); | |
| 43 } | 41 } |
| 44 | 42 |
| 45 int RecordIgnore(const GURL& url, content::PermissionType permission) { | 43 int RecordIgnore(const GURL& url, content::PermissionType permission) { |
| 46 return PermissionDecisionAutoBlocker(profile()).RecordIgnore(url, | 44 return PermissionDecisionAutoBlocker::RecordIgnore(url, permission, |
| 47 permission); | 45 profile()); |
| 48 } | 46 } |
| 49 }; | 47 }; |
| 50 | 48 |
| 51 TEST_F(PermissionDecisionAutoBlockerUnitTest, RemoveCountsByUrl) { | 49 TEST_F(PermissionDecisionAutoBlockerUnitTest, RemoveCountsByUrl) { |
| 52 GURL url1("https://www.google.com"); | 50 GURL url1("https://www.google.com"); |
| 53 GURL url2("https://www.example.com"); | 51 GURL url2("https://www.example.com"); |
| 54 | 52 |
| 55 // Record some dismissals. | 53 // Record some dismissals. |
| 56 EXPECT_EQ(1, RecordDismiss(url1, content::PermissionType::GEOLOCATION)); | 54 EXPECT_EQ(1, RecordDismiss(url1, content::PermissionType::GEOLOCATION)); |
| 57 EXPECT_EQ(2, RecordDismiss(url1, content::PermissionType::GEOLOCATION)); | 55 EXPECT_EQ(2, RecordDismiss(url1, content::PermissionType::GEOLOCATION)); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 EXPECT_EQ(0, GetDismissalCount(url1, content::PermissionType::GEOLOCATION)); | 93 EXPECT_EQ(0, GetDismissalCount(url1, content::PermissionType::GEOLOCATION)); |
| 96 EXPECT_EQ(0, GetDismissalCount(url1, content::PermissionType::NOTIFICATIONS)); | 94 EXPECT_EQ(0, GetDismissalCount(url1, content::PermissionType::NOTIFICATIONS)); |
| 97 EXPECT_EQ(0, GetDismissalCount(url2, content::PermissionType::GEOLOCATION)); | 95 EXPECT_EQ(0, GetDismissalCount(url2, content::PermissionType::GEOLOCATION)); |
| 98 | 96 |
| 99 EXPECT_EQ(0, GetIgnoreCount(url1, content::PermissionType::GEOLOCATION)); | 97 EXPECT_EQ(0, GetIgnoreCount(url1, content::PermissionType::GEOLOCATION)); |
| 100 EXPECT_EQ(0, GetIgnoreCount(url1, content::PermissionType::NOTIFICATIONS)); | 98 EXPECT_EQ(0, GetIgnoreCount(url1, content::PermissionType::NOTIFICATIONS)); |
| 101 EXPECT_EQ(0, GetIgnoreCount(url2, content::PermissionType::GEOLOCATION)); | 99 EXPECT_EQ(0, GetIgnoreCount(url2, content::PermissionType::GEOLOCATION)); |
| 102 EXPECT_EQ(0, GetIgnoreCount(url2, content::PermissionType::DURABLE_STORAGE)); | 100 EXPECT_EQ(0, GetIgnoreCount(url2, content::PermissionType::DURABLE_STORAGE)); |
| 103 EXPECT_EQ(0, GetIgnoreCount(url2, content::PermissionType::MIDI_SYSEX)); | 101 EXPECT_EQ(0, GetIgnoreCount(url2, content::PermissionType::MIDI_SYSEX)); |
| 104 } | 102 } |
| OLD | NEW |