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

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

Issue 2392673002: perform a null check in case WebContents doesn't have a ChromeDownloadDelegate (Closed)
Patch Set: Created 4 years, 2 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 | « no previous file | 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 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 void DownloadController::OnDownloadStarted( 237 void DownloadController::OnDownloadStarted(
238 DownloadItem* download_item) { 238 DownloadItem* download_item) {
239 DCHECK_CURRENTLY_ON(BrowserThread::UI); 239 DCHECK_CURRENTLY_ON(BrowserThread::UI);
240 WebContents* web_contents = download_item->GetWebContents(); 240 WebContents* web_contents = download_item->GetWebContents();
241 if (!web_contents) 241 if (!web_contents)
242 return; 242 return;
243 243
244 // Register for updates to the DownloadItem. 244 // Register for updates to the DownloadItem.
245 download_item->AddObserver(this); 245 download_item->AddObserver(this);
246 246
247 ChromeDownloadDelegate::FromWebContents(web_contents)->OnDownloadStarted( 247 ChromeDownloadDelegate* delegate =
248 download_item->GetTargetFilePath().BaseName().value()); 248 ChromeDownloadDelegate::FromWebContents(web_contents);
249 if (delegate) {
250 delegate->OnDownloadStarted(
251 download_item->GetTargetFilePath().BaseName().value());
252 }
249 } 253 }
250 254
251 void DownloadController::OnDownloadUpdated(DownloadItem* item) { 255 void DownloadController::OnDownloadUpdated(DownloadItem* item) {
252 DCHECK_CURRENTLY_ON(BrowserThread::UI); 256 DCHECK_CURRENTLY_ON(BrowserThread::UI);
253 if (item->IsDangerous() && (item->GetState() != DownloadItem::CANCELLED)) 257 if (item->IsDangerous() && (item->GetState() != DownloadItem::CANCELLED))
254 OnDangerousDownload(item); 258 OnDangerousDownload(item);
255 259
256 JNIEnv* env = base::android::AttachCurrentThread(); 260 JNIEnv* env = base::android::AttachCurrentThread();
257 ScopedJavaLocalRef<jstring> jguid = 261 ScopedJavaLocalRef<jstring> jguid =
258 ConvertUTF8ToJavaString(env, item->GetGuid()); 262 ConvertUTF8ToJavaString(env, item->GetGuid());
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 if (!item) 371 if (!item)
368 return; 372 return;
369 if (accept) { 373 if (accept) {
370 item->ValidateDangerousDownload(); 374 item->ValidateDangerousDownload();
371 } else { 375 } else {
372 DownloadController::RecordDownloadCancelReason( 376 DownloadController::RecordDownloadCancelReason(
373 DownloadController::CANCEL_REASON_DANGEROUS_DOWNLOAD_INFOBAR_DISMISSED); 377 DownloadController::CANCEL_REASON_DANGEROUS_DOWNLOAD_INFOBAR_DISMISSED);
374 item->Remove(); 378 item->Remove();
375 } 379 }
376 } 380 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698