OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/safe_browsing_db/safe_browsing_api_handler.h" | 6 #include "components/safe_browsing_db/safe_browsing_api_handler.h" |
6 | 7 |
7 namespace safe_browsing { | 8 namespace safe_browsing { |
8 | 9 |
| 10 namespace { |
| 11 |
| 12 // TODO(nparker): Remove this as part of crbug/589610. |
| 13 void OnRequestDoneShim( |
| 14 const SafeBrowsingApiHandler::URLCheckCallbackMeta& callback, |
| 15 SBThreatType sb_threat_type, |
| 16 const std::string& raw_metadata) { |
| 17 ThreatMetadata metadata_struct; |
| 18 metadata_struct.raw_metadata = raw_metadata; |
| 19 callback.Run(sb_threat_type, metadata_struct); |
| 20 } |
| 21 |
| 22 } // namespace |
| 23 |
9 SafeBrowsingApiHandler* SafeBrowsingApiHandler::instance_ = NULL; | 24 SafeBrowsingApiHandler* SafeBrowsingApiHandler::instance_ = NULL; |
10 | 25 |
11 // static | 26 // static |
12 void SafeBrowsingApiHandler::SetInstance(SafeBrowsingApiHandler* instance) { | 27 void SafeBrowsingApiHandler::SetInstance(SafeBrowsingApiHandler* instance) { |
13 instance_ = instance; | 28 instance_ = instance; |
14 } | 29 } |
15 | 30 |
16 // static | 31 // static |
17 SafeBrowsingApiHandler* SafeBrowsingApiHandler::GetInstance() { | 32 SafeBrowsingApiHandler* SafeBrowsingApiHandler::GetInstance() { |
18 return instance_; | 33 return instance_; |
19 } | 34 } |
20 | 35 |
| 36 // TODO(nparker): Remove this as part of crbug/589610. |
| 37 // Default impl since clank/ code doesn't yet support this. |
| 38 void SafeBrowsingApiHandler::StartURLCheck( |
| 39 const URLCheckCallbackMeta& callback, |
| 40 const GURL& url, |
| 41 const std::vector<SBThreatType>& threat_types) { |
| 42 URLCheckCallback impl_callback = base::Bind(OnRequestDoneShim, callback); |
| 43 StartURLCheck(impl_callback, url, threat_types); |
| 44 } |
| 45 |
21 } // namespace safe_browsing | 46 } // namespace safe_browsing |
OLD | NEW |