Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/run_loop.h" | 6 #include "base/run_loop.h" |
| 7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
| 8 #include "base/threading/thread_task_runner_handle.h" | 8 #include "base/threading/thread_task_runner_handle.h" |
| 9 #include "chrome/browser/extensions/blacklist.h" | 9 #include "chrome/browser/extensions/blacklist.h" |
| 10 #include "chrome/browser/extensions/blacklist_state_fetcher.h" | 10 #include "chrome/browser/extensions/blacklist_state_fetcher.h" |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 117 // Safe browsing blacklist empty, now enabled. | 117 // Safe browsing blacklist empty, now enabled. |
| 118 EXPECT_EQ(NOT_BLACKLISTED, tester.GetBlacklistState(a)); | 118 EXPECT_EQ(NOT_BLACKLISTED, tester.GetBlacklistState(a)); |
| 119 } | 119 } |
| 120 | 120 |
| 121 // Tests that Blacklist clears the old prefs blacklist on startup. | 121 // Tests that Blacklist clears the old prefs blacklist on startup. |
| 122 TEST_F(BlacklistTest, ClearsPreferencesBlacklist) { | 122 TEST_F(BlacklistTest, ClearsPreferencesBlacklist) { |
| 123 std::string a = AddExtension("a"); | 123 std::string a = AddExtension("a"); |
| 124 std::string b = AddExtension("b"); | 124 std::string b = AddExtension("b"); |
| 125 | 125 |
| 126 // Blacklist an installed extension. | 126 // Blacklist an installed extension. |
| 127 prefs()->SetExtensionBlacklisted(a, true); | 127 prefs()->SetExtensionBlacklistState(a, extensions::BLACKLISTED_MALWARE); |
|
Devlin
2016/07/19 16:02:44
This file is in the extensions namespace, so the e
atuchin
2016/07/20 06:02:45
Done.
| |
| 128 | 128 |
| 129 // Blacklist some non-installed extensions. This is what the old preferences | 129 // Blacklist some non-installed extensions. This is what the old preferences |
| 130 // blacklist looked like. | 130 // blacklist looked like. |
| 131 std::string c = "cccccccccccccccccccccccccccccccc"; | 131 std::string c = "cccccccccccccccccccccccccccccccc"; |
| 132 std::string d = "dddddddddddddddddddddddddddddddd"; | 132 std::string d = "dddddddddddddddddddddddddddddddd"; |
| 133 prefs()->SetExtensionBlacklisted(c, true); | 133 prefs()->SetExtensionBlacklistState(c, extensions::BLACKLISTED_MALWARE); |
| 134 prefs()->SetExtensionBlacklisted(d, true); | 134 prefs()->SetExtensionBlacklistState(d, extensions::BLACKLISTED_MALWARE); |
| 135 | 135 |
| 136 EXPECT_EQ(Set(a, c, d), prefs()->GetBlacklistedExtensions()); | 136 EXPECT_EQ(Set(a, c, d), prefs()->GetBlacklistedExtensions()); |
| 137 | 137 |
| 138 Blacklist blacklist(prefs()); | 138 Blacklist blacklist(prefs()); |
| 139 TestBlacklist tester(&blacklist); | 139 TestBlacklist tester(&blacklist); |
| 140 | 140 |
| 141 // Blacklist has been cleared. Only the installed extension "a" left. | 141 // Blacklist has been cleared. Only the installed extension "a" left. |
| 142 EXPECT_EQ(Set(a), prefs()->GetBlacklistedExtensions()); | 142 EXPECT_EQ(Set(a), prefs()->GetBlacklistedExtensions()); |
| 143 EXPECT_TRUE(prefs()->GetInstalledExtensionInfo(a).get()); | 143 EXPECT_TRUE(prefs()->GetInstalledExtensionInfo(a).get()); |
| 144 EXPECT_TRUE(prefs()->GetInstalledExtensionInfo(b).get()); | 144 EXPECT_TRUE(prefs()->GetInstalledExtensionInfo(b).get()); |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 253 base::RunLoop().RunUntilIdle(); | 253 base::RunLoop().RunUntilIdle(); |
| 254 | 254 |
| 255 // No new fetchers. | 255 // No new fetchers. |
| 256 EXPECT_FALSE(fetcher_tester.HandleFetcher(2)); | 256 EXPECT_FALSE(fetcher_tester.HandleFetcher(2)); |
| 257 EXPECT_EQ(BLACKLISTED_CWS_POLICY_VIOLATION, cached_states[a]); | 257 EXPECT_EQ(BLACKLISTED_CWS_POLICY_VIOLATION, cached_states[a]); |
| 258 EXPECT_EQ(BLACKLISTED_POTENTIALLY_UNWANTED, cached_states[b]); | 258 EXPECT_EQ(BLACKLISTED_POTENTIALLY_UNWANTED, cached_states[b]); |
| 259 EXPECT_EQ(0U, cached_states.count(c)); | 259 EXPECT_EQ(0U, cached_states.count(c)); |
| 260 } | 260 } |
| 261 | 261 |
| 262 } // namespace extensions | 262 } // namespace extensions |
| OLD | NEW |