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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <iterator> | 10 #include <iterator> |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 | 96 |
97 // Need to construct the full SafeBrowsingCheck rather than calling | 97 // Need to construct the full SafeBrowsingCheck rather than calling |
98 // OnCheckExtensionsResult directly because it's protected. Grr! | 98 // OnCheckExtensionsResult directly because it's protected. Grr! |
99 std::vector<std::string> extension_ids_vector(extension_ids.begin(), | 99 std::vector<std::string> extension_ids_vector(extension_ids.begin(), |
100 extension_ids.end()); | 100 extension_ids.end()); |
101 std::vector<safe_browsing::SBFullHash> extension_id_hashes; | 101 std::vector<safe_browsing::SBFullHash> extension_id_hashes; |
102 std::transform(extension_ids_vector.begin(), extension_ids_vector.end(), | 102 std::transform(extension_ids_vector.begin(), extension_ids_vector.end(), |
103 std::back_inserter(extension_id_hashes), | 103 std::back_inserter(extension_id_hashes), |
104 safe_browsing::StringToSBFullHash); | 104 safe_browsing::StringToSBFullHash); |
105 | 105 |
106 scoped_ptr<SafeBrowsingCheck> safe_browsing_check( | 106 std::unique_ptr<SafeBrowsingCheck> safe_browsing_check( |
107 new SafeBrowsingCheck(std::vector<GURL>(), extension_id_hashes, client, | 107 new SafeBrowsingCheck(std::vector<GURL>(), extension_id_hashes, client, |
108 safe_browsing::EXTENSIONBLACKLIST, | 108 safe_browsing::EXTENSIONBLACKLIST, |
109 std::vector<safe_browsing::SBThreatType>( | 109 std::vector<safe_browsing::SBThreatType>( |
110 1, safe_browsing::SB_THREAT_TYPE_EXTENSION))); | 110 1, safe_browsing::SB_THREAT_TYPE_EXTENSION))); |
111 | 111 |
112 for (size_t i = 0; i < extension_ids_vector.size(); ++i) { | 112 for (size_t i = 0; i < extension_ids_vector.size(); ++i) { |
113 const std::string& extension_id = extension_ids_vector[i]; | 113 const std::string& extension_id = extension_ids_vector[i]; |
114 if (unsafe_ids_.count(extension_id)) | 114 if (unsafe_ids_.count(extension_id)) |
115 safe_browsing_check->full_hash_results[i] = | 115 safe_browsing_check->full_hash_results[i] = |
116 safe_browsing::SB_THREAT_TYPE_EXTENSION; | 116 safe_browsing::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 std::unique_ptr<SafeBrowsingCheck> result) { |
128 result->OnSafeBrowsingResult(); | 128 result->OnSafeBrowsingResult(); |
129 } | 129 } |
130 | 130 |
131 } // namespace extensions | 131 } // namespace extensions |
OLD | NEW |