Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Side by Side Diff: content/browser/download/download_manager_impl.cc

Issue 2901563003: PDF: Add UMA to track embedded PDF triggered drive-by downloads. (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "content/browser/download/download_manager_impl.h" 5 #include "content/browser/download/download_manager_impl.h"
6 6
7 #include <iterator> 7 #include <iterator>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 const base::FilePath& path, 167 const base::FilePath& path,
168 const GURL& url, 168 const GURL& url,
169 const std::string& mime_type, 169 const std::string& mime_type,
170 std::unique_ptr<DownloadRequestHandleInterface> request_handle, 170 std::unique_ptr<DownloadRequestHandleInterface> request_handle,
171 const net::NetLogWithSource& net_log) override { 171 const net::NetLogWithSource& net_log) override {
172 return new DownloadItemImpl(delegate, download_id, path, url, mime_type, 172 return new DownloadItemImpl(delegate, download_id, path, url, mime_type,
173 std::move(request_handle), net_log); 173 std::move(request_handle), net_log);
174 } 174 }
175 }; 175 };
176 176
177 constexpr char kPDFMimeType[] = "application/pdf";
178
177 } // namespace 179 } // namespace
178 180
179 DownloadManagerImpl::DownloadManagerImpl(net::NetLog* net_log, 181 DownloadManagerImpl::DownloadManagerImpl(net::NetLog* net_log,
180 BrowserContext* browser_context) 182 BrowserContext* browser_context)
181 : item_factory_(new DownloadItemFactoryImpl()), 183 : item_factory_(new DownloadItemFactoryImpl()),
182 file_factory_(new DownloadFileFactory()), 184 file_factory_(new DownloadFileFactory()),
183 shutdown_needed_(true), 185 shutdown_needed_(true),
184 browser_context_(browser_context), 186 browser_context_(browser_context),
185 delegate_(nullptr), 187 delegate_(nullptr),
186 net_log_(net_log), 188 net_log_(net_log),
187 weak_factory_(this) { 189 weak_factory_(this) {
188 DCHECK(browser_context); 190 DCHECK(browser_context);
189 } 191 }
190 192
191 DownloadManagerImpl::~DownloadManagerImpl() { 193 DownloadManagerImpl::~DownloadManagerImpl() {
192 DCHECK(!shutdown_needed_); 194 DCHECK(!shutdown_needed_);
193 } 195 }
194 196
195 DownloadItemImpl* DownloadManagerImpl::CreateActiveItem( 197 DownloadItemImpl* DownloadManagerImpl::CreateActiveItem(
196 uint32_t id, 198 uint32_t id,
197 const DownloadCreateInfo& info) { 199 const DownloadCreateInfo& info) {
198 DCHECK_CURRENTLY_ON(BrowserThread::UI); 200 DCHECK_CURRENTLY_ON(BrowserThread::UI);
199 DCHECK(!base::ContainsKey(downloads_, id)); 201 DCHECK(!base::ContainsKey(downloads_, id));
200 net::NetLogWithSource net_log = 202 net::NetLogWithSource net_log =
201 net::NetLogWithSource::Make(net_log_, net::NetLogSourceType::DOWNLOAD); 203 net::NetLogWithSource::Make(net_log_, net::NetLogSourceType::DOWNLOAD);
202 DownloadItemImpl* download = 204 DownloadItemImpl* download =
203 item_factory_->CreateActiveItem(this, id, info, net_log); 205 item_factory_->CreateActiveItem(this, id, info, net_log);
204 downloads_[id] = base::WrapUnique(download); 206 downloads_[id] = base::WrapUnique(download);
205 downloads_by_guid_[download->GetGuid()] = download; 207 downloads_by_guid_[download->GetGuid()] = download;
208
209 if (info.mime_type == kPDFMimeType && !info.has_user_gesture)
210 delegate_->RecordDriveByPDFDownload();
211
206 return download; 212 return download;
207 } 213 }
208 214
209 void DownloadManagerImpl::GetNextId(const DownloadIdCallback& callback) { 215 void DownloadManagerImpl::GetNextId(const DownloadIdCallback& callback) {
210 DCHECK_CURRENTLY_ON(BrowserThread::UI); 216 DCHECK_CURRENTLY_ON(BrowserThread::UI);
211 if (delegate_) { 217 if (delegate_) {
212 delegate_->GetNextId(callback); 218 delegate_->GetNextId(callback);
213 return; 219 return;
214 } 220 }
215 static uint32_t next_id = content::DownloadItem::kInvalidId + 1; 221 static uint32_t next_id = content::DownloadItem::kInvalidId + 1;
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 if (delegate_) 753 if (delegate_)
748 delegate_->OpenDownload(download); 754 delegate_->OpenDownload(download);
749 } 755 }
750 756
751 void DownloadManagerImpl::ShowDownloadInShell(DownloadItemImpl* download) { 757 void DownloadManagerImpl::ShowDownloadInShell(DownloadItemImpl* download) {
752 if (delegate_) 758 if (delegate_)
753 delegate_->ShowDownloadInShell(download); 759 delegate_->ShowDownloadInShell(download);
754 } 760 }
755 761
756 } // namespace content 762 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698