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

Side by Side Diff: chrome/browser/android/download/download_controller.cc

Issue 2609113004: Fix a crash when downloading a dangerous download (Closed)
Patch Set: Created 3 years, 11 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
« no previous file with comments | « chrome/browser/android/download/chrome_download_delegate.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/android/download/download_controller.h" 5 #include "chrome/browser/android/download/download_controller.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/android/context_utils.h" 10 #include "base/android/context_utils.h"
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 DCHECK_CURRENTLY_ON(BrowserThread::UI); 236 DCHECK_CURRENTLY_ON(BrowserThread::UI);
237 WebContents* web_contents = download_item->GetWebContents(); 237 WebContents* web_contents = download_item->GetWebContents();
238 if (!web_contents) 238 if (!web_contents)
239 return; 239 return;
240 240
241 // Register for updates to the DownloadItem. 241 // Register for updates to the DownloadItem.
242 download_item->AddObserver(this); 242 download_item->AddObserver(this);
243 243
244 ChromeDownloadDelegate* delegate = 244 ChromeDownloadDelegate* delegate =
245 ChromeDownloadDelegate::FromWebContents(web_contents); 245 ChromeDownloadDelegate::FromWebContents(web_contents);
246 if (delegate) { 246 // For dangerous item, we need to show the dangerous infobar before the
247 // download can start.
248 if (!download_item->IsDangerous() && delegate) {
247 delegate->OnDownloadStarted( 249 delegate->OnDownloadStarted(
248 download_item->GetTargetFilePath().BaseName().value()); 250 download_item->GetTargetFilePath().BaseName().value());
249 } 251 }
250 OnDownloadUpdated(download_item); 252 OnDownloadUpdated(download_item);
251 } 253 }
252 254
253 void DownloadController::OnDownloadUpdated(DownloadItem* item) { 255 void DownloadController::OnDownloadUpdated(DownloadItem* item) {
254 DCHECK_CURRENTLY_ON(BrowserThread::UI); 256 DCHECK_CURRENTLY_ON(BrowserThread::UI);
255 if (item->IsDangerous() && (item->GetState() != DownloadItem::CANCELLED)) { 257 if (item->IsDangerous() && (item->GetState() != DownloadItem::CANCELLED)) {
256 // Dont't show notification for a dangerous download, as user can resume 258 // Dont't show notification for a dangerous download, as user can resume
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 void DownloadController::StartContextMenuDownload( 329 void DownloadController::StartContextMenuDownload(
328 const ContextMenuParams& params, WebContents* web_contents, bool is_link, 330 const ContextMenuParams& params, WebContents* web_contents, bool is_link,
329 const std::string& extra_headers) { 331 const std::string& extra_headers) {
330 int process_id = web_contents->GetRenderProcessHost()->GetID(); 332 int process_id = web_contents->GetRenderProcessHost()->GetID();
331 int routing_id = web_contents->GetRenderViewHost()->GetRoutingID(); 333 int routing_id = web_contents->GetRenderViewHost()->GetRoutingID();
332 AcquireFileAccessPermission( 334 AcquireFileAccessPermission(
333 web_contents, base::Bind(&CreateContextMenuDownload, process_id, 335 web_contents, base::Bind(&CreateContextMenuDownload, process_id,
334 routing_id, params, is_link, extra_headers)); 336 routing_id, params, is_link, extra_headers));
335 } 337 }
336 338
OLDNEW
« no previous file with comments | « chrome/browser/android/download/chrome_download_delegate.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698