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