OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 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/services_delegate_impl.h" | 5 #include "chrome/browser/safe_browsing/services_delegate_impl.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 void ServicesDelegateImpl::ShutdownServices() { | 95 void ServicesDelegateImpl::ShutdownServices() { |
96 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 96 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
97 // The IO thread is going away, so make sure the ClientSideDetectionService | 97 // The IO thread is going away, so make sure the ClientSideDetectionService |
98 // dtor executes now since it may call the dtor of URLFetcher which relies | 98 // dtor executes now since it may call the dtor of URLFetcher which relies |
99 // on it. | 99 // on it. |
100 csd_service_.reset(); | 100 csd_service_.reset(); |
101 | 101 |
102 resource_request_detector_.reset(); | 102 resource_request_detector_.reset(); |
103 incident_service_.reset(); | 103 incident_service_.reset(); |
104 | 104 |
| 105 // Delete the ChromePasswordProtectionService instances. |
| 106 password_protection_service_map_.clear(); |
| 107 |
105 // Must shut down last. | 108 // Must shut down last. |
106 download_service_.reset(); | 109 download_service_.reset(); |
107 } | 110 } |
108 | 111 |
109 void ServicesDelegateImpl::RefreshState(bool enable) { | 112 void ServicesDelegateImpl::RefreshState(bool enable) { |
110 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 113 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
111 if (csd_service_) | 114 if (csd_service_) |
112 csd_service_->SetEnabledAndRefreshState(enable); | 115 csd_service_->SetEnabledAndRefreshState(enable); |
113 if (download_service_) | 116 if (download_service_) |
114 download_service_->SetEnabled(enable); | 117 download_service_->SetEnabled(enable); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 v4_config); | 175 v4_config); |
173 } | 176 } |
174 } | 177 } |
175 | 178 |
176 void ServicesDelegateImpl::StopOnIOThread(bool shutdown) { | 179 void ServicesDelegateImpl::StopOnIOThread(bool shutdown) { |
177 if (v4_local_database_manager_.get()) { | 180 if (v4_local_database_manager_.get()) { |
178 v4_local_database_manager_->StopOnIOThread(shutdown); | 181 v4_local_database_manager_->StopOnIOThread(shutdown); |
179 } | 182 } |
180 } | 183 } |
181 | 184 |
| 185 void ServicesDelegateImpl::CreatePasswordProtectionService(Profile* profile) { |
| 186 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 187 DCHECK(profile); |
| 188 auto it = password_protection_service_map_.find(profile); |
| 189 DCHECK(it == password_protection_service_map_.end()); |
| 190 std::unique_ptr<ChromePasswordProtectionService> service = |
| 191 base::MakeUnique<ChromePasswordProtectionService>(safe_browsing_service_, |
| 192 profile); |
| 193 password_protection_service_map_[profile] = std::move(service); |
| 194 } |
| 195 |
| 196 void ServicesDelegateImpl::RemovePasswordProtectionService(Profile* profile) { |
| 197 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 198 DCHECK(profile); |
| 199 auto it = password_protection_service_map_.find(profile); |
| 200 if (it != password_protection_service_map_.end()) |
| 201 password_protection_service_map_.erase(it); |
| 202 } |
| 203 |
| 204 PasswordProtectionService* ServicesDelegateImpl::GetPasswordProtectionService( |
| 205 Profile* profile) const { |
| 206 DCHECK(profile); |
| 207 auto it = password_protection_service_map_.find(profile); |
| 208 DCHECK(it != password_protection_service_map_.end()); |
| 209 return it->second.get(); |
| 210 } |
| 211 |
182 } // namespace safe_browsing | 212 } // namespace safe_browsing |
OLD | NEW |