| OLD | NEW |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 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/safe_browsing/test_safe_browsing_service.h" | 5 #include "chrome/browser/safe_browsing/test_safe_browsing_service.h" |
| 6 | 6 |
| 7 #include "base/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
| 8 #include "chrome/browser/safe_browsing/download_protection_service.h" | 8 #include "chrome/browser/safe_browsing/download_protection_service.h" |
| 9 #include "chrome/browser/safe_browsing/ping_manager.h" | 9 #include "chrome/browser/safe_browsing/ping_manager.h" |
| 10 #include "chrome/browser/safe_browsing/ui_manager.h" | 10 #include "chrome/browser/safe_browsing/ui_manager.h" |
| 11 #include "components/safe_browsing_db/database_manager.h" | 11 #include "components/safe_browsing_db/database_manager.h" |
| 12 #include "components/safe_browsing_db/test_database_manager.h" | 12 #include "components/safe_browsing_db/test_database_manager.h" |
| 13 | 13 |
| 14 namespace safe_browsing { | 14 namespace safe_browsing { |
| 15 | 15 |
| 16 // TestSafeBrowsingService functions: | 16 // TestSafeBrowsingService functions: |
| 17 TestSafeBrowsingService::TestSafeBrowsingService() | 17 TestSafeBrowsingService::TestSafeBrowsingService(bool v4_enabled, |
| 18 : protocol_manager_delegate_disabled_(false), | 18 bool use_v4_only) |
| 19 : SafeBrowsingService(v4_enabled, use_v4_only), |
| 20 protocol_manager_delegate_disabled_(false), |
| 19 serialized_download_report_(base::EmptyString()) {} | 21 serialized_download_report_(base::EmptyString()) {} |
| 20 | 22 |
| 21 TestSafeBrowsingService::~TestSafeBrowsingService() {} | 23 TestSafeBrowsingService::~TestSafeBrowsingService() {} |
| 22 | 24 |
| 23 SafeBrowsingProtocolConfig TestSafeBrowsingService::GetProtocolConfig() const { | 25 SafeBrowsingProtocolConfig TestSafeBrowsingService::GetProtocolConfig() const { |
| 24 if (protocol_config_) | 26 if (protocol_config_) |
| 25 return *protocol_config_; | 27 return *protocol_config_; |
| 26 return SafeBrowsingService::GetProtocolConfig(); | 28 return SafeBrowsingService::GetProtocolConfig(); |
| 27 } | 29 } |
| 28 | 30 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 SafeBrowsingProtocolConfig* protocol_config) { | 85 SafeBrowsingProtocolConfig* protocol_config) { |
| 84 protocol_config_.reset(protocol_config); | 86 protocol_config_.reset(protocol_config); |
| 85 } | 87 } |
| 86 | 88 |
| 87 void TestSafeBrowsingService::SetV4ProtocolConfig( | 89 void TestSafeBrowsingService::SetV4ProtocolConfig( |
| 88 V4ProtocolConfig* v4_protocol_config) { | 90 V4ProtocolConfig* v4_protocol_config) { |
| 89 v4_protocol_config_.reset(v4_protocol_config); | 91 v4_protocol_config_.reset(v4_protocol_config); |
| 90 } | 92 } |
| 91 | 93 |
| 92 // TestSafeBrowsingServiceFactory functions: | 94 // TestSafeBrowsingServiceFactory functions: |
| 93 TestSafeBrowsingServiceFactory::TestSafeBrowsingServiceFactory() | 95 TestSafeBrowsingServiceFactory::TestSafeBrowsingServiceFactory(bool v4_enabled, |
| 94 : test_safe_browsing_service_(nullptr), test_protocol_config_(nullptr) {} | 96 bool use_v4_only) |
| 97 : test_safe_browsing_service_(nullptr), |
| 98 test_protocol_config_(nullptr), |
| 99 use_v4_only_(use_v4_only), |
| 100 v4_enabled_(v4_enabled) {} |
| 95 | 101 |
| 96 TestSafeBrowsingServiceFactory::~TestSafeBrowsingServiceFactory() {} | 102 TestSafeBrowsingServiceFactory::~TestSafeBrowsingServiceFactory() {} |
| 97 | 103 |
| 98 SafeBrowsingService* | 104 SafeBrowsingService* |
| 99 TestSafeBrowsingServiceFactory::CreateSafeBrowsingService() { | 105 TestSafeBrowsingServiceFactory::CreateSafeBrowsingService() { |
| 100 // Instantiate TestSafeBrowsingService. | 106 // Instantiate TestSafeBrowsingService. |
| 101 test_safe_browsing_service_ = new TestSafeBrowsingService(); | 107 test_safe_browsing_service_ = |
| 108 new TestSafeBrowsingService(v4_enabled_, use_v4_only_); |
| 102 // Plug-in test member clases accordingly. | 109 // Plug-in test member clases accordingly. |
| 103 if (test_ui_manager_) | 110 if (test_ui_manager_) |
| 104 test_safe_browsing_service_->SetUIManager(test_ui_manager_.get()); | 111 test_safe_browsing_service_->SetUIManager(test_ui_manager_.get()); |
| 105 if (test_database_manager_) { | 112 if (test_database_manager_) { |
| 106 test_safe_browsing_service_->SetDatabaseManager( | 113 test_safe_browsing_service_->SetDatabaseManager( |
| 107 test_database_manager_.get()); | 114 test_database_manager_.get()); |
| 108 } | 115 } |
| 109 if (test_protocol_config_) | 116 if (test_protocol_config_) |
| 110 test_safe_browsing_service_->SetProtocolConfig(test_protocol_config_); | 117 test_safe_browsing_service_->SetProtocolConfig(test_protocol_config_); |
| 111 return test_safe_browsing_service_; | 118 return test_safe_browsing_service_; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 const std::string& serialized) { | 155 const std::string& serialized) { |
| 149 details_.push_back(serialized); | 156 details_.push_back(serialized); |
| 150 } | 157 } |
| 151 | 158 |
| 152 std::list<std::string>* TestSafeBrowsingUIManager::GetThreatDetails() { | 159 std::list<std::string>* TestSafeBrowsingUIManager::GetThreatDetails() { |
| 153 return &details_; | 160 return &details_; |
| 154 } | 161 } |
| 155 | 162 |
| 156 TestSafeBrowsingUIManager::~TestSafeBrowsingUIManager() {} | 163 TestSafeBrowsingUIManager::~TestSafeBrowsingUIManager() {} |
| 157 } // namespace safe_browsing | 164 } // namespace safe_browsing |
| OLD | NEW |