| 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 |
| 11 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/message_loop/message_loop_proxy.h" | 13 #include "base/message_loop/message_loop_proxy.h" |
| 14 #include "base/run_loop.h" | 14 #include "base/run_loop.h" |
| 15 #include "base/thread_task_runner_handle.h" |
| 15 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 16 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 16 #include "chrome/browser/safe_browsing/safe_browsing_util.h" | 17 #include "chrome/browser/safe_browsing/safe_browsing_util.h" |
| 17 | 18 |
| 18 namespace extensions { | 19 namespace extensions { |
| 19 | 20 |
| 20 FakeSafeBrowsingDatabaseManager::FakeSafeBrowsingDatabaseManager(bool enabled) | 21 FakeSafeBrowsingDatabaseManager::FakeSafeBrowsingDatabaseManager(bool enabled) |
| 21 : SafeBrowsingDatabaseManager( | 22 : SafeBrowsingDatabaseManager( |
| 22 make_scoped_refptr(SafeBrowsingService::CreateSafeBrowsingService())), | 23 make_scoped_refptr(SafeBrowsingService::CreateSafeBrowsingService())), |
| 23 enabled_(enabled) { | 24 enabled_(enabled) { |
| 24 } | 25 } |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 client, | 110 client, |
| 110 safe_browsing_util::EXTENSIONBLACKLIST, | 111 safe_browsing_util::EXTENSIONBLACKLIST, |
| 111 std::vector<SBThreatType>(1, SB_THREAT_TYPE_EXTENSION))); | 112 std::vector<SBThreatType>(1, SB_THREAT_TYPE_EXTENSION))); |
| 112 | 113 |
| 113 for (size_t i = 0; i < extension_ids_vector.size(); ++i) { | 114 for (size_t i = 0; i < extension_ids_vector.size(); ++i) { |
| 114 const std::string& extension_id = extension_ids_vector[i]; | 115 const std::string& extension_id = extension_ids_vector[i]; |
| 115 if (unsafe_ids_.count(extension_id)) | 116 if (unsafe_ids_.count(extension_id)) |
| 116 safe_browsing_check->full_hash_results[i] = SB_THREAT_TYPE_EXTENSION; | 117 safe_browsing_check->full_hash_results[i] = SB_THREAT_TYPE_EXTENSION; |
| 117 } | 118 } |
| 118 | 119 |
| 119 base::MessageLoopProxy::current()->PostTask( | 120 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 120 FROM_HERE, | 121 FROM_HERE, |
| 121 base::Bind(&FakeSafeBrowsingDatabaseManager::OnSafeBrowsingResult, | 122 base::Bind(&FakeSafeBrowsingDatabaseManager::OnSafeBrowsingResult, |
| 122 this, | 123 this, |
| 123 base::Passed(&safe_browsing_check), | 124 base::Passed(&safe_browsing_check), |
| 124 client)); | 125 client)); |
| 125 return false; | 126 return false; |
| 126 } | 127 } |
| 127 | 128 |
| 128 void FakeSafeBrowsingDatabaseManager::OnSafeBrowsingResult( | 129 void FakeSafeBrowsingDatabaseManager::OnSafeBrowsingResult( |
| 129 scoped_ptr<SafeBrowsingCheck> result, | 130 scoped_ptr<SafeBrowsingCheck> result, |
| 130 Client* client) { | 131 Client* client) { |
| 131 client->OnSafeBrowsingResult(*result); | 132 client->OnSafeBrowsingResult(*result); |
| 132 } | 133 } |
| 133 | 134 |
| 134 } // namespace extensions | 135 } // namespace extensions |
| OLD | NEW |