| 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/download/chrome_download_manager_delegate.h" | 5 #include "chrome/browser/download/chrome_download_manager_delegate.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 download_manager_ = NULL; | 206 download_manager_ = NULL; |
| 207 } | 207 } |
| 208 | 208 |
| 209 content::DownloadIdCallback | 209 content::DownloadIdCallback |
| 210 ChromeDownloadManagerDelegate::GetDownloadIdReceiverCallback() { | 210 ChromeDownloadManagerDelegate::GetDownloadIdReceiverCallback() { |
| 211 return base::Bind(&ChromeDownloadManagerDelegate::SetNextId, | 211 return base::Bind(&ChromeDownloadManagerDelegate::SetNextId, |
| 212 weak_ptr_factory_.GetWeakPtr()); | 212 weak_ptr_factory_.GetWeakPtr()); |
| 213 } | 213 } |
| 214 | 214 |
| 215 void ChromeDownloadManagerDelegate::SetNextId(uint32 next_id) { | 215 void ChromeDownloadManagerDelegate::SetNextId(uint32 next_id) { |
| 216 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 216 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 217 DCHECK(!profile_->IsOffTheRecord()); | 217 DCHECK(!profile_->IsOffTheRecord()); |
| 218 DCHECK_NE(content::DownloadItem::kInvalidId, next_id); | 218 DCHECK_NE(content::DownloadItem::kInvalidId, next_id); |
| 219 next_download_id_ = next_id; | 219 next_download_id_ = next_id; |
| 220 | 220 |
| 221 IdCallbackVector callbacks; | 221 IdCallbackVector callbacks; |
| 222 id_callbacks_.swap(callbacks); | 222 id_callbacks_.swap(callbacks); |
| 223 for (IdCallbackVector::const_iterator it = callbacks.begin(); | 223 for (IdCallbackVector::const_iterator it = callbacks.begin(); |
| 224 it != callbacks.end(); ++it) { | 224 it != callbacks.end(); ++it) { |
| 225 ReturnNextId(*it); | 225 ReturnNextId(*it); |
| 226 } | 226 } |
| 227 } | 227 } |
| 228 | 228 |
| 229 void ChromeDownloadManagerDelegate::GetNextId( | 229 void ChromeDownloadManagerDelegate::GetNextId( |
| 230 const content::DownloadIdCallback& callback) { | 230 const content::DownloadIdCallback& callback) { |
| 231 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 231 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 232 if (profile_->IsOffTheRecord()) { | 232 if (profile_->IsOffTheRecord()) { |
| 233 content::BrowserContext::GetDownloadManager( | 233 content::BrowserContext::GetDownloadManager( |
| 234 profile_->GetOriginalProfile())->GetDelegate()->GetNextId(callback); | 234 profile_->GetOriginalProfile())->GetDelegate()->GetNextId(callback); |
| 235 return; | 235 return; |
| 236 } | 236 } |
| 237 if (next_download_id_ == content::DownloadItem::kInvalidId) { | 237 if (next_download_id_ == content::DownloadItem::kInvalidId) { |
| 238 id_callbacks_.push_back(callback); | 238 id_callbacks_.push_back(callback); |
| 239 return; | 239 return; |
| 240 } | 240 } |
| 241 ReturnNextId(callback); | 241 ReturnNextId(callback); |
| 242 } | 242 } |
| 243 | 243 |
| 244 void ChromeDownloadManagerDelegate::ReturnNextId( | 244 void ChromeDownloadManagerDelegate::ReturnNextId( |
| 245 const content::DownloadIdCallback& callback) { | 245 const content::DownloadIdCallback& callback) { |
| 246 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 246 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 247 DCHECK(!profile_->IsOffTheRecord()); | 247 DCHECK(!profile_->IsOffTheRecord()); |
| 248 DCHECK_NE(content::DownloadItem::kInvalidId, next_download_id_); | 248 DCHECK_NE(content::DownloadItem::kInvalidId, next_download_id_); |
| 249 callback.Run(next_download_id_++); | 249 callback.Run(next_download_id_++); |
| 250 } | 250 } |
| 251 | 251 |
| 252 bool ChromeDownloadManagerDelegate::DetermineDownloadTarget( | 252 bool ChromeDownloadManagerDelegate::DetermineDownloadTarget( |
| 253 DownloadItem* download, | 253 DownloadItem* download, |
| 254 const content::DownloadTargetCallback& callback) { | 254 const content::DownloadTargetCallback& callback) { |
| 255 DownloadTargetDeterminer::CompletionCallback target_determined_callback = | 255 DownloadTargetDeterminer::CompletionCallback target_determined_callback = |
| 256 base::Bind(&ChromeDownloadManagerDelegate::OnDownloadTargetDetermined, | 256 base::Bind(&ChromeDownloadManagerDelegate::OnDownloadTargetDetermined, |
| 257 weak_ptr_factory_.GetWeakPtr(), | 257 weak_ptr_factory_.GetWeakPtr(), |
| 258 download->GetId(), | 258 download->GetId(), |
| 259 callback); | 259 callback); |
| 260 DownloadTargetDeterminer::Start( | 260 DownloadTargetDeterminer::Start( |
| 261 download, | 261 download, |
| 262 GetPlatformDownloadPath(profile_, download, PLATFORM_TARGET_PATH), | 262 GetPlatformDownloadPath(profile_, download, PLATFORM_TARGET_PATH), |
| 263 download_prefs_.get(), | 263 download_prefs_.get(), |
| 264 this, | 264 this, |
| 265 target_determined_callback); | 265 target_determined_callback); |
| 266 return true; | 266 return true; |
| 267 } | 267 } |
| 268 | 268 |
| 269 bool ChromeDownloadManagerDelegate::ShouldOpenFileBasedOnExtension( | 269 bool ChromeDownloadManagerDelegate::ShouldOpenFileBasedOnExtension( |
| 270 const base::FilePath& path) { | 270 const base::FilePath& path) { |
| 271 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 271 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 272 if (path.Extension().empty()) | 272 if (path.Extension().empty()) |
| 273 return false; | 273 return false; |
| 274 #if defined(ENABLE_EXTENSIONS) | 274 #if defined(ENABLE_EXTENSIONS) |
| 275 // TODO(asanka): This determination is done based on |path|, while | 275 // TODO(asanka): This determination is done based on |path|, while |
| 276 // ShouldOpenDownload() detects extension downloads based on the | 276 // ShouldOpenDownload() detects extension downloads based on the |
| 277 // characteristics of the download. Reconcile this. http://crbug.com/167702 | 277 // characteristics of the download. Reconcile this. http://crbug.com/167702 |
| 278 if (path.MatchesExtension(extensions::kExtensionFileExtension)) | 278 if (path.MatchesExtension(extensions::kExtensionFileExtension)) |
| 279 return false; | 279 return false; |
| 280 #endif | 280 #endif |
| 281 return download_prefs_->IsAutoOpenEnabledBasedOnExtension(path); | 281 return download_prefs_->IsAutoOpenEnabledBasedOnExtension(path); |
| 282 } | 282 } |
| 283 | 283 |
| 284 // static | 284 // static |
| 285 void ChromeDownloadManagerDelegate::DisableSafeBrowsing(DownloadItem* item) { | 285 void ChromeDownloadManagerDelegate::DisableSafeBrowsing(DownloadItem* item) { |
| 286 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 286 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 287 #if defined(FULL_SAFE_BROWSING) | 287 #if defined(FULL_SAFE_BROWSING) |
| 288 SafeBrowsingState* state = static_cast<SafeBrowsingState*>( | 288 SafeBrowsingState* state = static_cast<SafeBrowsingState*>( |
| 289 item->GetUserData(&kSafeBrowsingUserDataKey)); | 289 item->GetUserData(&kSafeBrowsingUserDataKey)); |
| 290 if (!state) { | 290 if (!state) { |
| 291 state = new SafeBrowsingState(); | 291 state = new SafeBrowsingState(); |
| 292 item->SetUserData(&kSafeBrowsingUserDataKey, state); | 292 item->SetUserData(&kSafeBrowsingUserDataKey, state); |
| 293 } | 293 } |
| 294 state->CompleteDownload(); | 294 state->CompleteDownload(); |
| 295 #endif | 295 #endif |
| 296 } | 296 } |
| 297 | 297 |
| 298 bool ChromeDownloadManagerDelegate::IsDownloadReadyForCompletion( | 298 bool ChromeDownloadManagerDelegate::IsDownloadReadyForCompletion( |
| 299 DownloadItem* item, | 299 DownloadItem* item, |
| 300 const base::Closure& internal_complete_callback) { | 300 const base::Closure& internal_complete_callback) { |
| 301 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 301 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 302 #if defined(FULL_SAFE_BROWSING) | 302 #if defined(FULL_SAFE_BROWSING) |
| 303 SafeBrowsingState* state = static_cast<SafeBrowsingState*>( | 303 SafeBrowsingState* state = static_cast<SafeBrowsingState*>( |
| 304 item->GetUserData(&kSafeBrowsingUserDataKey)); | 304 item->GetUserData(&kSafeBrowsingUserDataKey)); |
| 305 if (!state) { | 305 if (!state) { |
| 306 // Begin the safe browsing download protection check. | 306 // Begin the safe browsing download protection check. |
| 307 DownloadProtectionService* service = GetDownloadProtectionService(); | 307 DownloadProtectionService* service = GetDownloadProtectionService(); |
| 308 if (service) { | 308 if (service) { |
| 309 DVLOG(2) << __FUNCTION__ << "() Start SB download check for download = " | 309 DVLOG(2) << __FUNCTION__ << "() Start SB download check for download = " |
| 310 << item->DebugString(false); | 310 << item->DebugString(false); |
| 311 state = new SafeBrowsingState(); | 311 state = new SafeBrowsingState(); |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 callback); | 509 callback); |
| 510 } | 510 } |
| 511 | 511 |
| 512 std::string | 512 std::string |
| 513 ChromeDownloadManagerDelegate::ApplicationClientIdForFileScanning() const { | 513 ChromeDownloadManagerDelegate::ApplicationClientIdForFileScanning() const { |
| 514 return std::string(chrome::kApplicationClientIDStringForAVScanning); | 514 return std::string(chrome::kApplicationClientIDStringForAVScanning); |
| 515 } | 515 } |
| 516 | 516 |
| 517 DownloadProtectionService* | 517 DownloadProtectionService* |
| 518 ChromeDownloadManagerDelegate::GetDownloadProtectionService() { | 518 ChromeDownloadManagerDelegate::GetDownloadProtectionService() { |
| 519 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 519 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 520 #if defined(FULL_SAFE_BROWSING) | 520 #if defined(FULL_SAFE_BROWSING) |
| 521 SafeBrowsingService* sb_service = g_browser_process->safe_browsing_service(); | 521 SafeBrowsingService* sb_service = g_browser_process->safe_browsing_service(); |
| 522 if (sb_service && sb_service->download_protection_service() && | 522 if (sb_service && sb_service->download_protection_service() && |
| 523 profile_->GetPrefs()->GetBoolean(prefs::kSafeBrowsingEnabled)) { | 523 profile_->GetPrefs()->GetBoolean(prefs::kSafeBrowsingEnabled)) { |
| 524 return sb_service->download_protection_service(); | 524 return sb_service->download_protection_service(); |
| 525 } | 525 } |
| 526 #endif | 526 #endif |
| 527 return NULL; | 527 return NULL; |
| 528 } | 528 } |
| 529 | 529 |
| 530 void ChromeDownloadManagerDelegate::NotifyExtensions( | 530 void ChromeDownloadManagerDelegate::NotifyExtensions( |
| 531 DownloadItem* download, | 531 DownloadItem* download, |
| 532 const base::FilePath& virtual_path, | 532 const base::FilePath& virtual_path, |
| 533 const NotifyExtensionsCallback& callback) { | 533 const NotifyExtensionsCallback& callback) { |
| 534 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 534 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 535 #if defined(ENABLE_EXTENSIONS) | 535 #if defined(ENABLE_EXTENSIONS) |
| 536 extensions::ExtensionDownloadsEventRouter* router = | 536 extensions::ExtensionDownloadsEventRouter* router = |
| 537 DownloadServiceFactory::GetForBrowserContext(profile_) | 537 DownloadServiceFactory::GetForBrowserContext(profile_) |
| 538 ->GetExtensionEventRouter(); | 538 ->GetExtensionEventRouter(); |
| 539 if (router) { | 539 if (router) { |
| 540 base::Closure original_path_callback = | 540 base::Closure original_path_callback = |
| 541 base::Bind(callback, base::FilePath(), | 541 base::Bind(callback, base::FilePath(), |
| 542 DownloadPathReservationTracker::UNIQUIFY); | 542 DownloadPathReservationTracker::UNIQUIFY); |
| 543 router->OnDeterminingFilename(download, virtual_path.BaseName(), | 543 router->OnDeterminingFilename(download, virtual_path.BaseName(), |
| 544 original_path_callback, | 544 original_path_callback, |
| 545 callback); | 545 callback); |
| 546 return; | 546 return; |
| 547 } | 547 } |
| 548 #endif | 548 #endif |
| 549 callback.Run(base::FilePath(), DownloadPathReservationTracker::UNIQUIFY); | 549 callback.Run(base::FilePath(), DownloadPathReservationTracker::UNIQUIFY); |
| 550 } | 550 } |
| 551 | 551 |
| 552 void ChromeDownloadManagerDelegate::ReserveVirtualPath( | 552 void ChromeDownloadManagerDelegate::ReserveVirtualPath( |
| 553 content::DownloadItem* download, | 553 content::DownloadItem* download, |
| 554 const base::FilePath& virtual_path, | 554 const base::FilePath& virtual_path, |
| 555 bool create_directory, | 555 bool create_directory, |
| 556 DownloadPathReservationTracker::FilenameConflictAction conflict_action, | 556 DownloadPathReservationTracker::FilenameConflictAction conflict_action, |
| 557 const DownloadTargetDeterminerDelegate::ReservedPathCallback& callback) { | 557 const DownloadTargetDeterminerDelegate::ReservedPathCallback& callback) { |
| 558 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 558 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 559 DCHECK(!virtual_path.empty()); | 559 DCHECK(!virtual_path.empty()); |
| 560 #if defined(OS_CHROMEOS) | 560 #if defined(OS_CHROMEOS) |
| 561 // TODO(asanka): Handle path reservations for virtual paths as well. | 561 // TODO(asanka): Handle path reservations for virtual paths as well. |
| 562 // http://crbug.com/151618 | 562 // http://crbug.com/151618 |
| 563 if (drive::util::IsUnderDriveMountPoint(virtual_path)) { | 563 if (drive::util::IsUnderDriveMountPoint(virtual_path)) { |
| 564 callback.Run(virtual_path, true); | 564 callback.Run(virtual_path, true); |
| 565 return; | 565 return; |
| 566 } | 566 } |
| 567 #endif | 567 #endif |
| 568 DownloadPathReservationTracker::GetReservedPath( | 568 DownloadPathReservationTracker::GetReservedPath( |
| 569 download, | 569 download, |
| 570 virtual_path, | 570 virtual_path, |
| 571 download_prefs_->DownloadPath(), | 571 download_prefs_->DownloadPath(), |
| 572 create_directory, | 572 create_directory, |
| 573 conflict_action, | 573 conflict_action, |
| 574 callback); | 574 callback); |
| 575 } | 575 } |
| 576 | 576 |
| 577 void ChromeDownloadManagerDelegate::PromptUserForDownloadPath( | 577 void ChromeDownloadManagerDelegate::PromptUserForDownloadPath( |
| 578 DownloadItem* download, | 578 DownloadItem* download, |
| 579 const base::FilePath& suggested_path, | 579 const base::FilePath& suggested_path, |
| 580 const DownloadTargetDeterminerDelegate::FileSelectedCallback& callback) { | 580 const DownloadTargetDeterminerDelegate::FileSelectedCallback& callback) { |
| 581 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 581 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 582 #if defined(OS_ANDROID) | 582 #if defined(OS_ANDROID) |
| 583 chrome::android::ChromeDownloadManagerOverwriteInfoBarDelegate::Create( | 583 chrome::android::ChromeDownloadManagerOverwriteInfoBarDelegate::Create( |
| 584 InfoBarService::FromWebContents(download->GetWebContents()), | 584 InfoBarService::FromWebContents(download->GetWebContents()), |
| 585 suggested_path, callback); | 585 suggested_path, callback); |
| 586 #else | 586 #else |
| 587 DownloadFilePicker::ShowFilePicker(download, suggested_path, callback); | 587 DownloadFilePicker::ShowFilePicker(download, suggested_path, callback); |
| 588 #endif | 588 #endif |
| 589 } | 589 } |
| 590 | 590 |
| 591 void ChromeDownloadManagerDelegate::DetermineLocalPath( | 591 void ChromeDownloadManagerDelegate::DetermineLocalPath( |
| 592 DownloadItem* download, | 592 DownloadItem* download, |
| 593 const base::FilePath& virtual_path, | 593 const base::FilePath& virtual_path, |
| 594 const DownloadTargetDeterminerDelegate::LocalPathCallback& callback) { | 594 const DownloadTargetDeterminerDelegate::LocalPathCallback& callback) { |
| 595 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 595 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 596 #if defined(OS_CHROMEOS) | 596 #if defined(OS_CHROMEOS) |
| 597 drive::DownloadHandler* drive_download_handler = | 597 drive::DownloadHandler* drive_download_handler = |
| 598 drive::DownloadHandler::GetForProfile(profile_); | 598 drive::DownloadHandler::GetForProfile(profile_); |
| 599 if (drive_download_handler) { | 599 if (drive_download_handler) { |
| 600 drive_download_handler->SubstituteDriveDownloadPath( | 600 drive_download_handler->SubstituteDriveDownloadPath( |
| 601 virtual_path, download, callback); | 601 virtual_path, download, callback); |
| 602 return; | 602 return; |
| 603 } | 603 } |
| 604 #endif | 604 #endif |
| 605 callback.Run(virtual_path); | 605 callback.Run(virtual_path); |
| 606 } | 606 } |
| 607 | 607 |
| 608 void ChromeDownloadManagerDelegate::CheckDownloadUrl( | 608 void ChromeDownloadManagerDelegate::CheckDownloadUrl( |
| 609 DownloadItem* download, | 609 DownloadItem* download, |
| 610 const base::FilePath& suggested_path, | 610 const base::FilePath& suggested_path, |
| 611 const CheckDownloadUrlCallback& callback) { | 611 const CheckDownloadUrlCallback& callback) { |
| 612 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 612 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 613 | 613 |
| 614 #if defined(FULL_SAFE_BROWSING) | 614 #if defined(FULL_SAFE_BROWSING) |
| 615 safe_browsing::DownloadProtectionService* service = | 615 safe_browsing::DownloadProtectionService* service = |
| 616 GetDownloadProtectionService(); | 616 GetDownloadProtectionService(); |
| 617 if (service) { | 617 if (service) { |
| 618 bool is_content_check_supported = | 618 bool is_content_check_supported = |
| 619 service->IsSupportedDownload(*download, suggested_path); | 619 service->IsSupportedDownload(*download, suggested_path); |
| 620 DVLOG(2) << __FUNCTION__ << "() Start SB URL check for download = " | 620 DVLOG(2) << __FUNCTION__ << "() Start SB URL check for download = " |
| 621 << download->DebugString(false); | 621 << download->DebugString(false); |
| 622 service->CheckDownloadUrl(*download, | 622 service->CheckDownloadUrl(*download, |
| 623 base::Bind(&CheckDownloadUrlDone, | 623 base::Bind(&CheckDownloadUrlDone, |
| 624 callback, | 624 callback, |
| 625 is_content_check_supported)); | 625 is_content_check_supported)); |
| 626 return; | 626 return; |
| 627 } | 627 } |
| 628 #endif | 628 #endif |
| 629 callback.Run(content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS); | 629 callback.Run(content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS); |
| 630 } | 630 } |
| 631 | 631 |
| 632 void ChromeDownloadManagerDelegate::GetFileMimeType( | 632 void ChromeDownloadManagerDelegate::GetFileMimeType( |
| 633 const base::FilePath& path, | 633 const base::FilePath& path, |
| 634 const GetFileMimeTypeCallback& callback) { | 634 const GetFileMimeTypeCallback& callback) { |
| 635 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 635 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 636 base::PostTaskAndReplyWithResult(BrowserThread::GetBlockingPool(), | 636 base::PostTaskAndReplyWithResult(BrowserThread::GetBlockingPool(), |
| 637 FROM_HERE, | 637 FROM_HERE, |
| 638 base::Bind(&GetMimeType, path), | 638 base::Bind(&GetMimeType, path), |
| 639 callback); | 639 callback); |
| 640 } | 640 } |
| 641 | 641 |
| 642 #if defined(FULL_SAFE_BROWSING) | 642 #if defined(FULL_SAFE_BROWSING) |
| 643 void ChromeDownloadManagerDelegate::CheckClientDownloadDone( | 643 void ChromeDownloadManagerDelegate::CheckClientDownloadDone( |
| 644 uint32 download_id, | 644 uint32 download_id, |
| 645 DownloadProtectionService::DownloadCheckResult result) { | 645 DownloadProtectionService::DownloadCheckResult result) { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 705 crx_installers_[installer.get()]; | 705 crx_installers_[installer.get()]; |
| 706 crx_installers_.erase(installer.get()); | 706 crx_installers_.erase(installer.get()); |
| 707 callback.Run(installer->did_handle_successfully()); | 707 callback.Run(installer->did_handle_successfully()); |
| 708 #endif | 708 #endif |
| 709 } | 709 } |
| 710 | 710 |
| 711 void ChromeDownloadManagerDelegate::OnDownloadTargetDetermined( | 711 void ChromeDownloadManagerDelegate::OnDownloadTargetDetermined( |
| 712 int32 download_id, | 712 int32 download_id, |
| 713 const content::DownloadTargetCallback& callback, | 713 const content::DownloadTargetCallback& callback, |
| 714 scoped_ptr<DownloadTargetInfo> target_info) { | 714 scoped_ptr<DownloadTargetInfo> target_info) { |
| 715 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 715 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 716 DownloadItem* item = download_manager_->GetDownload(download_id); | 716 DownloadItem* item = download_manager_->GetDownload(download_id); |
| 717 if (item) { | 717 if (item) { |
| 718 if (!target_info->target_path.empty() && | 718 if (!target_info->target_path.empty() && |
| 719 IsOpenInBrowserPreferreredForFile(target_info->target_path) && | 719 IsOpenInBrowserPreferreredForFile(target_info->target_path) && |
| 720 target_info->is_filetype_handled_safely) | 720 target_info->is_filetype_handled_safely) |
| 721 DownloadItemModel(item).SetShouldPreferOpeningInBrowser(true); | 721 DownloadItemModel(item).SetShouldPreferOpeningInBrowser(true); |
| 722 | 722 |
| 723 if (target_info->is_dangerous_file) | 723 if (target_info->is_dangerous_file) |
| 724 DownloadItemModel(item).SetIsDangerousFileBasedOnType(true); | 724 DownloadItemModel(item).SetIsDangerousFileBasedOnType(true); |
| 725 } | 725 } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 752 path.MatchesExtension(FILE_PATH_LITERAL(".xht")) || | 752 path.MatchesExtension(FILE_PATH_LITERAL(".xht")) || |
| 753 path.MatchesExtension(FILE_PATH_LITERAL(".xhtm")) || | 753 path.MatchesExtension(FILE_PATH_LITERAL(".xhtm")) || |
| 754 path.MatchesExtension(FILE_PATH_LITERAL(".xhtml")) || | 754 path.MatchesExtension(FILE_PATH_LITERAL(".xhtml")) || |
| 755 path.MatchesExtension(FILE_PATH_LITERAL(".xsl")) || | 755 path.MatchesExtension(FILE_PATH_LITERAL(".xsl")) || |
| 756 path.MatchesExtension(FILE_PATH_LITERAL(".xslt"))) { | 756 path.MatchesExtension(FILE_PATH_LITERAL(".xslt"))) { |
| 757 return true; | 757 return true; |
| 758 } | 758 } |
| 759 #endif | 759 #endif |
| 760 return false; | 760 return false; |
| 761 } | 761 } |
| OLD | NEW |