OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/extensions/fake_safe_browsing_database_manager.h" | 5 #include "chrome/browser/extensions/fake_safe_browsing_database_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <iterator> | 8 #include <iterator> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 if (!enabled_) | 93 if (!enabled_) |
94 return true; | 94 return true; |
95 | 95 |
96 // Need to construct the full SafeBrowsingCheck rather than calling | 96 // Need to construct the full SafeBrowsingCheck rather than calling |
97 // OnCheckExtensionsResult directly because it's protected. Grr! | 97 // OnCheckExtensionsResult directly because it's protected. Grr! |
98 std::vector<std::string> extension_ids_vector(extension_ids.begin(), | 98 std::vector<std::string> extension_ids_vector(extension_ids.begin(), |
99 extension_ids.end()); | 99 extension_ids.end()); |
100 std::vector<SBFullHash> extension_id_hashes; | 100 std::vector<SBFullHash> extension_id_hashes; |
101 std::transform(extension_ids_vector.begin(), extension_ids_vector.end(), | 101 std::transform(extension_ids_vector.begin(), extension_ids_vector.end(), |
102 std::back_inserter(extension_id_hashes), | 102 std::back_inserter(extension_id_hashes), |
103 safe_browsing_util::StringToSBFullHash); | 103 safe_browsing::StringToSBFullHash); |
104 | 104 |
105 scoped_ptr<SafeBrowsingCheck> safe_browsing_check( | 105 scoped_ptr<SafeBrowsingCheck> safe_browsing_check( |
106 new SafeBrowsingCheck( | 106 new SafeBrowsingCheck( |
107 std::vector<GURL>(), | 107 std::vector<GURL>(), |
108 extension_id_hashes, | 108 extension_id_hashes, |
109 client, | 109 client, |
110 safe_browsing_util::EXTENSIONBLACKLIST, | 110 safe_browsing::EXTENSIONBLACKLIST, |
111 std::vector<SBThreatType>(1, SB_THREAT_TYPE_EXTENSION))); | 111 std::vector<SBThreatType>(1, SB_THREAT_TYPE_EXTENSION))); |
112 | 112 |
113 for (size_t i = 0; i < extension_ids_vector.size(); ++i) { | 113 for (size_t i = 0; i < extension_ids_vector.size(); ++i) { |
114 const std::string& extension_id = extension_ids_vector[i]; | 114 const std::string& extension_id = extension_ids_vector[i]; |
115 if (unsafe_ids_.count(extension_id)) | 115 if (unsafe_ids_.count(extension_id)) |
116 safe_browsing_check->full_hash_results[i] = SB_THREAT_TYPE_EXTENSION; | 116 safe_browsing_check->full_hash_results[i] = SB_THREAT_TYPE_EXTENSION; |
117 } | 117 } |
118 | 118 |
119 base::ThreadTaskRunnerHandle::Get()->PostTask( | 119 base::ThreadTaskRunnerHandle::Get()->PostTask( |
120 FROM_HERE, | 120 FROM_HERE, |
121 base::Bind(&FakeSafeBrowsingDatabaseManager::OnSafeBrowsingResult, this, | 121 base::Bind(&FakeSafeBrowsingDatabaseManager::OnSafeBrowsingResult, this, |
122 base::Passed(&safe_browsing_check))); | 122 base::Passed(&safe_browsing_check))); |
123 return false; | 123 return false; |
124 } | 124 } |
125 | 125 |
126 void FakeSafeBrowsingDatabaseManager::OnSafeBrowsingResult( | 126 void FakeSafeBrowsingDatabaseManager::OnSafeBrowsingResult( |
127 scoped_ptr<SafeBrowsingCheck> result) { | 127 scoped_ptr<SafeBrowsingCheck> result) { |
128 result->OnSafeBrowsingResult(); | 128 result->OnSafeBrowsingResult(); |
129 } | 129 } |
130 | 130 |
131 } // namespace extensions | 131 } // namespace extensions |
OLD | NEW |