| 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 <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 14 #include "build/build_config.h" | 14 #include "build/build_config.h" |
| 15 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
| 16 #include "chrome/browser/download/download_crx_util.h" | 16 #include "chrome/browser/download/download_crx_util.h" |
| 17 #include "chrome/browser/download/download_extensions.h" | |
| 18 #include "chrome/browser/download/download_item_model.h" | 17 #include "chrome/browser/download/download_item_model.h" |
| 19 #include "chrome/browser/download/download_prefs.h" | 18 #include "chrome/browser/download/download_prefs.h" |
| 20 #include "chrome/browser/image_decoder.h" | 19 #include "chrome/browser/image_decoder.h" |
| 21 #include "chrome/browser/profiles/profile_manager.h" | 20 #include "chrome/browser/profiles/profile_manager.h" |
| 22 #include "chrome/browser/safe_browsing/download_protection_service.h" | 21 #include "chrome/browser/safe_browsing/download_protection_service.h" |
| 23 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 22 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 24 #include "chrome/browser/ui/browser_finder.h" | 23 #include "chrome/browser/ui/browser_finder.h" |
| 25 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" | 24 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" |
| 26 #include "chrome/common/safe_browsing/csd.pb.h" | 25 #include "chrome/common/safe_browsing/csd.pb.h" |
| 26 #include "chrome/common/safe_browsing/file_type_policies.h" |
| 27 #include "chrome/common/url_constants.h" | 27 #include "chrome/common/url_constants.h" |
| 28 #include "chrome/grit/generated_resources.h" | 28 #include "chrome/grit/generated_resources.h" |
| 29 #include "components/google/core/browser/google_util.h" | 29 #include "components/google/core/browser/google_util.h" |
| 30 #include "components/mime_util/mime_util.h" | 30 #include "components/mime_util/mime_util.h" |
| 31 #include "grit/theme_resources.h" | 31 #include "grit/theme_resources.h" |
| 32 #include "net/base/url_util.h" | 32 #include "net/base/url_util.h" |
| 33 #include "ui/base/clipboard/scoped_clipboard_writer.h" | 33 #include "ui/base/clipboard/scoped_clipboard_writer.h" |
| 34 #include "ui/base/l10n/l10n_util.h" | 34 #include "ui/base/l10n/l10n_util.h" |
| 35 #include "ui/base/resource/resource_bundle.h" | 35 #include "ui/base/resource/resource_bundle.h" |
| 36 | 36 |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 return download_item_->CanShowInFolder(); | 173 return download_item_->CanShowInFolder(); |
| 174 case OPEN_WHEN_COMPLETE: | 174 case OPEN_WHEN_COMPLETE: |
| 175 case PLATFORM_OPEN: | 175 case PLATFORM_OPEN: |
| 176 return download_item_->CanOpenDownload() && | 176 return download_item_->CanOpenDownload() && |
| 177 !download_crx_util::IsExtensionDownload(*download_item_); | 177 !download_crx_util::IsExtensionDownload(*download_item_); |
| 178 case ALWAYS_OPEN_TYPE: | 178 case ALWAYS_OPEN_TYPE: |
| 179 // For temporary downloads, the target filename might be a temporary | 179 // For temporary downloads, the target filename might be a temporary |
| 180 // filename. Don't base an "Always open" decision based on it. Also | 180 // filename. Don't base an "Always open" decision based on it. Also |
| 181 // exclude extensions. | 181 // exclude extensions. |
| 182 return download_item_->CanOpenDownload() && | 182 return download_item_->CanOpenDownload() && |
| 183 download_util::IsAllowedToOpenAutomatically( | 183 safe_browsing::FileTypePolicies::GetInstance() |
| 184 download_item_->GetTargetFilePath()) && | 184 ->IsAllowedToOpenAutomatically( |
| 185 download_item_->GetTargetFilePath()) && |
| 185 !download_crx_util::IsExtensionDownload(*download_item_); | 186 !download_crx_util::IsExtensionDownload(*download_item_); |
| 186 case CANCEL: | 187 case CANCEL: |
| 187 return !download_item_->IsDone(); | 188 return !download_item_->IsDone(); |
| 188 case PAUSE: | 189 case PAUSE: |
| 189 return !download_item_->IsDone() && !download_item_->IsPaused() && | 190 return !download_item_->IsDone() && !download_item_->IsPaused() && |
| 190 download_item_->GetState() == content::DownloadItem::IN_PROGRESS; | 191 download_item_->GetState() == content::DownloadItem::IN_PROGRESS; |
| 191 case RESUME: | 192 case RESUME: |
| 192 return download_item_->CanResume() && | 193 return download_item_->CanResume() && |
| 193 (download_item_->IsPaused() || | 194 (download_item_->IsPaused() || |
| 194 download_item_->GetState() != content::DownloadItem::IN_PROGRESS); | 195 download_item_->GetState() != content::DownloadItem::IN_PROGRESS); |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 &mime) || | 392 &mime) || |
| 392 !mime_util::IsSupportedImageMimeType(mime)) { | 393 !mime_util::IsSupportedImageMimeType(mime)) { |
| 393 // It seems a non-image file. | 394 // It seems a non-image file. |
| 394 return; | 395 return; |
| 395 } | 396 } |
| 396 } | 397 } |
| 397 | 398 |
| 398 base::FilePath file_path = download_item_->GetFullPath(); | 399 base::FilePath file_path = download_item_->GetFullPath(); |
| 399 ImageClipboardCopyManager::Start(file_path); | 400 ImageClipboardCopyManager::Start(file_path); |
| 400 } | 401 } |
| OLD | NEW |