| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/safe_browsing_service.h" | 5 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 void ServiceShuttingDown(); | 122 void ServiceShuttingDown(); |
| 123 | 123 |
| 124 protected: | 124 protected: |
| 125 ~SafeBrowsingURLRequestContextGetter() override; | 125 ~SafeBrowsingURLRequestContextGetter() override; |
| 126 | 126 |
| 127 private: | 127 private: |
| 128 bool shut_down_; | 128 bool shut_down_; |
| 129 | 129 |
| 130 scoped_refptr<net::URLRequestContextGetter> system_context_getter_; | 130 scoped_refptr<net::URLRequestContextGetter> system_context_getter_; |
| 131 | 131 |
| 132 scoped_ptr<net::CookieStore> safe_browsing_cookie_store_; |
| 133 |
| 132 scoped_ptr<net::URLRequestContext> safe_browsing_request_context_; | 134 scoped_ptr<net::URLRequestContext> safe_browsing_request_context_; |
| 133 | 135 |
| 134 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; | 136 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; |
| 135 }; | 137 }; |
| 136 | 138 |
| 137 SafeBrowsingURLRequestContextGetter::SafeBrowsingURLRequestContextGetter( | 139 SafeBrowsingURLRequestContextGetter::SafeBrowsingURLRequestContextGetter( |
| 138 scoped_refptr<net::URLRequestContextGetter> system_context_getter) | 140 scoped_refptr<net::URLRequestContextGetter> system_context_getter) |
| 139 : shut_down_(false), | 141 : shut_down_(false), |
| 140 system_context_getter_(system_context_getter), | 142 system_context_getter_(system_context_getter), |
| 141 network_task_runner_( | 143 network_task_runner_( |
| 142 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)) {} | 144 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)) {} |
| 143 | 145 |
| 144 net::URLRequestContext* | 146 net::URLRequestContext* |
| 145 SafeBrowsingURLRequestContextGetter::GetURLRequestContext() { | 147 SafeBrowsingURLRequestContextGetter::GetURLRequestContext() { |
| 146 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 148 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 147 | 149 |
| 148 // Check if the service has been shut down. | 150 // Check if the service has been shut down. |
| 149 if (shut_down_) | 151 if (shut_down_) |
| 150 return nullptr; | 152 return nullptr; |
| 151 | 153 |
| 152 if (!safe_browsing_request_context_) { | 154 if (!safe_browsing_request_context_) { |
| 153 safe_browsing_request_context_.reset(new net::URLRequestContext()); | 155 safe_browsing_request_context_.reset(new net::URLRequestContext()); |
| 154 // May be NULL in unit tests. | 156 // May be NULL in unit tests. |
| 155 if (system_context_getter_) { | 157 if (system_context_getter_) { |
| 156 safe_browsing_request_context_->CopyFrom( | 158 safe_browsing_request_context_->CopyFrom( |
| 157 system_context_getter_->GetURLRequestContext()); | 159 system_context_getter_->GetURLRequestContext()); |
| 158 } | 160 } |
| 159 safe_browsing_request_context_->set_cookie_store( | 161 safe_browsing_cookie_store_ = |
| 160 content::CreateCookieStore(content::CookieStoreConfig( | 162 content::CreateCookieStore(content::CookieStoreConfig( |
| 161 CookieFilePath(), | 163 CookieFilePath(), |
| 162 content::CookieStoreConfig::EPHEMERAL_SESSION_COOKIES, nullptr, | 164 content::CookieStoreConfig::EPHEMERAL_SESSION_COOKIES, nullptr, |
| 163 nullptr))); | 165 nullptr)); |
| 166 safe_browsing_request_context_->set_cookie_store( |
| 167 safe_browsing_cookie_store_.get()); |
| 164 } | 168 } |
| 165 | 169 |
| 166 return safe_browsing_request_context_.get(); | 170 return safe_browsing_request_context_.get(); |
| 167 } | 171 } |
| 168 | 172 |
| 169 scoped_refptr<base::SingleThreadTaskRunner> | 173 scoped_refptr<base::SingleThreadTaskRunner> |
| 170 SafeBrowsingURLRequestContextGetter::GetNetworkTaskRunner() const { | 174 SafeBrowsingURLRequestContextGetter::GetNetworkTaskRunner() const { |
| 171 return network_task_runner_; | 175 return network_task_runner_; |
| 172 } | 176 } |
| 173 | 177 |
| (...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 673 } | 677 } |
| 674 | 678 |
| 675 void SafeBrowsingService::OnSendDownloadRecoveryReport( | 679 void SafeBrowsingService::OnSendDownloadRecoveryReport( |
| 676 const std::string& report) { | 680 const std::string& report) { |
| 677 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 681 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 678 if (ping_manager()) | 682 if (ping_manager()) |
| 679 ping_manager()->ReportThreatDetails(report); | 683 ping_manager()->ReportThreatDetails(report); |
| 680 } | 684 } |
| 681 | 685 |
| 682 } // namespace safe_browsing | 686 } // namespace safe_browsing |
| OLD | NEW |