| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/download_commands.h" | 5 #include "chrome/browser/download/download_commands.h" |
| 6 | 6 |
| 7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
| 8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
| 9 #include "chrome/browser/download/download_crx_util.h" | 9 #include "chrome/browser/download/download_crx_util.h" |
| 10 #include "chrome/browser/download/download_extensions.h" |
| 10 #include "chrome/browser/download/download_item_model.h" | 11 #include "chrome/browser/download/download_item_model.h" |
| 11 #include "chrome/browser/download/download_prefs.h" | 12 #include "chrome/browser/download/download_prefs.h" |
| 12 #include "chrome/browser/profiles/profile_manager.h" | 13 #include "chrome/browser/profiles/profile_manager.h" |
| 13 #include "chrome/browser/safe_browsing/download_protection_service.h" | 14 #include "chrome/browser/safe_browsing/download_protection_service.h" |
| 14 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 15 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 15 #include "chrome/browser/ui/browser_finder.h" | 16 #include "chrome/browser/ui/browser_finder.h" |
| 16 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" | 17 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" |
| 17 #include "chrome/common/url_constants.h" | 18 #include "chrome/common/url_constants.h" |
| 18 #include "chrome/grit/generated_resources.h" | 19 #include "chrome/grit/generated_resources.h" |
| 19 #include "components/google/core/browser/google_util.h" | 20 #include "components/google/core/browser/google_util.h" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 return download_item_->CanShowInFolder(); | 82 return download_item_->CanShowInFolder(); |
| 82 case OPEN_WHEN_COMPLETE: | 83 case OPEN_WHEN_COMPLETE: |
| 83 case PLATFORM_OPEN: | 84 case PLATFORM_OPEN: |
| 84 return download_item_->CanOpenDownload() && | 85 return download_item_->CanOpenDownload() && |
| 85 !download_crx_util::IsExtensionDownload(*download_item_); | 86 !download_crx_util::IsExtensionDownload(*download_item_); |
| 86 case ALWAYS_OPEN_TYPE: | 87 case ALWAYS_OPEN_TYPE: |
| 87 // For temporary downloads, the target filename might be a temporary | 88 // For temporary downloads, the target filename might be a temporary |
| 88 // filename. Don't base an "Always open" decision based on it. Also | 89 // filename. Don't base an "Always open" decision based on it. Also |
| 89 // exclude extensions. | 90 // exclude extensions. |
| 90 return download_item_->CanOpenDownload() && | 91 return download_item_->CanOpenDownload() && |
| 92 download_util::IsAllowedToOpenAutomatically( |
| 93 download_item_->GetTargetFilePath()) && |
| 91 !download_crx_util::IsExtensionDownload(*download_item_); | 94 !download_crx_util::IsExtensionDownload(*download_item_); |
| 92 case CANCEL: | 95 case CANCEL: |
| 93 return !download_item_->IsDone(); | 96 return !download_item_->IsDone(); |
| 94 case PAUSE: | 97 case PAUSE: |
| 95 return !download_item_->IsDone() && !download_item_->IsPaused() && | 98 return !download_item_->IsDone() && !download_item_->IsPaused() && |
| 96 download_item_->GetState() == content::DownloadItem::IN_PROGRESS; | 99 download_item_->GetState() == content::DownloadItem::IN_PROGRESS; |
| 97 case RESUME: | 100 case RESUME: |
| 98 return download_item_->CanResume() && | 101 return download_item_->CanResume() && |
| 99 (download_item_->IsPaused() || | 102 (download_item_->IsPaused() || |
| 100 download_item_->GetState() != content::DownloadItem::IN_PROGRESS); | 103 download_item_->GetState() != content::DownloadItem::IN_PROGRESS); |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 is_adobe_pdf_reader_up_to_date = | 242 is_adobe_pdf_reader_up_to_date = |
| 240 DownloadTargetDeterminer::IsAdobeReaderUpToDate(); | 243 DownloadTargetDeterminer::IsAdobeReaderUpToDate(); |
| 241 } | 244 } |
| 242 return IsDownloadPdf() && | 245 return IsDownloadPdf() && |
| 243 (IsAdobeReaderDefaultPDFViewer() ? is_adobe_pdf_reader_up_to_date | 246 (IsAdobeReaderDefaultPDFViewer() ? is_adobe_pdf_reader_up_to_date |
| 244 : true); | 247 : true); |
| 245 #elif defined(OS_MACOSX) || defined(OS_LINUX) | 248 #elif defined(OS_MACOSX) || defined(OS_LINUX) |
| 246 return IsDownloadPdf(); | 249 return IsDownloadPdf(); |
| 247 #endif | 250 #endif |
| 248 } | 251 } |
| OLD | NEW |