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(V4UsageStatus v4_usage_status) |
18 : protocol_manager_delegate_disabled_(false), | 18 : SafeBrowsingService(v4_usage_status), |
| 19 protocol_manager_delegate_disabled_(false), |
19 serialized_download_report_(base::EmptyString()) {} | 20 serialized_download_report_(base::EmptyString()) {} |
20 | 21 |
21 TestSafeBrowsingService::~TestSafeBrowsingService() {} | 22 TestSafeBrowsingService::~TestSafeBrowsingService() {} |
22 | 23 |
23 SafeBrowsingProtocolConfig TestSafeBrowsingService::GetProtocolConfig() const { | 24 SafeBrowsingProtocolConfig TestSafeBrowsingService::GetProtocolConfig() const { |
24 if (protocol_config_) | 25 if (protocol_config_) |
25 return *protocol_config_; | 26 return *protocol_config_; |
26 return SafeBrowsingService::GetProtocolConfig(); | 27 return SafeBrowsingService::GetProtocolConfig(); |
27 } | 28 } |
28 | 29 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 SafeBrowsingProtocolConfig* protocol_config) { | 84 SafeBrowsingProtocolConfig* protocol_config) { |
84 protocol_config_.reset(protocol_config); | 85 protocol_config_.reset(protocol_config); |
85 } | 86 } |
86 | 87 |
87 void TestSafeBrowsingService::SetV4ProtocolConfig( | 88 void TestSafeBrowsingService::SetV4ProtocolConfig( |
88 V4ProtocolConfig* v4_protocol_config) { | 89 V4ProtocolConfig* v4_protocol_config) { |
89 v4_protocol_config_.reset(v4_protocol_config); | 90 v4_protocol_config_.reset(v4_protocol_config); |
90 } | 91 } |
91 | 92 |
92 // TestSafeBrowsingServiceFactory functions: | 93 // TestSafeBrowsingServiceFactory functions: |
93 TestSafeBrowsingServiceFactory::TestSafeBrowsingServiceFactory() | 94 TestSafeBrowsingServiceFactory::TestSafeBrowsingServiceFactory( |
94 : test_safe_browsing_service_(nullptr), test_protocol_config_(nullptr) {} | 95 V4UsageStatus v4_usage_status) |
| 96 : test_safe_browsing_service_(nullptr), |
| 97 test_protocol_config_(nullptr), |
| 98 v4_usage_status_(v4_usage_status) {} |
95 | 99 |
96 TestSafeBrowsingServiceFactory::~TestSafeBrowsingServiceFactory() {} | 100 TestSafeBrowsingServiceFactory::~TestSafeBrowsingServiceFactory() {} |
97 | 101 |
98 SafeBrowsingService* | 102 SafeBrowsingService* |
99 TestSafeBrowsingServiceFactory::CreateSafeBrowsingService() { | 103 TestSafeBrowsingServiceFactory::CreateSafeBrowsingService() { |
100 // Instantiate TestSafeBrowsingService. | 104 // Instantiate TestSafeBrowsingService. |
101 test_safe_browsing_service_ = new TestSafeBrowsingService(); | 105 test_safe_browsing_service_ = new TestSafeBrowsingService(v4_usage_status_); |
102 // Plug-in test member clases accordingly. | 106 // Plug-in test member clases accordingly. |
103 if (test_ui_manager_) | 107 if (test_ui_manager_) |
104 test_safe_browsing_service_->SetUIManager(test_ui_manager_.get()); | 108 test_safe_browsing_service_->SetUIManager(test_ui_manager_.get()); |
105 if (test_database_manager_) { | 109 if (test_database_manager_) { |
106 test_safe_browsing_service_->SetDatabaseManager( | 110 test_safe_browsing_service_->SetDatabaseManager( |
107 test_database_manager_.get()); | 111 test_database_manager_.get()); |
108 } | 112 } |
109 if (test_protocol_config_) | 113 if (test_protocol_config_) |
110 test_safe_browsing_service_->SetProtocolConfig(test_protocol_config_); | 114 test_safe_browsing_service_->SetProtocolConfig(test_protocol_config_); |
111 return test_safe_browsing_service_; | 115 return test_safe_browsing_service_; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 const std::string& serialized) { | 152 const std::string& serialized) { |
149 details_.push_back(serialized); | 153 details_.push_back(serialized); |
150 } | 154 } |
151 | 155 |
152 std::list<std::string>* TestSafeBrowsingUIManager::GetThreatDetails() { | 156 std::list<std::string>* TestSafeBrowsingUIManager::GetThreatDetails() { |
153 return &details_; | 157 return &details_; |
154 } | 158 } |
155 | 159 |
156 TestSafeBrowsingUIManager::~TestSafeBrowsingUIManager() {} | 160 TestSafeBrowsingUIManager::~TestSafeBrowsingUIManager() {} |
157 } // namespace safe_browsing | 161 } // namespace safe_browsing |
OLD | NEW |