| 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/notification/download_item_notification.h" | 5 #include "chrome/browser/download/notification/download_item_notification.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 463 if (item_->IsDone() && image_decode_status_ == NOT_STARTED) { | 463 if (item_->IsDone() && image_decode_status_ == NOT_STARTED) { |
| 464 // TODO(yoshiki): Add an UMA to collect statistics of image file sizes. | 464 // TODO(yoshiki): Add an UMA to collect statistics of image file sizes. |
| 465 | 465 |
| 466 if (item_->GetReceivedBytes() > kMaxImagePreviewSize) | 466 if (item_->GetReceivedBytes() > kMaxImagePreviewSize) |
| 467 return; | 467 return; |
| 468 | 468 |
| 469 DCHECK(notification_->image().IsEmpty()); | 469 DCHECK(notification_->image().IsEmpty()); |
| 470 | 470 |
| 471 image_decode_status_ = IN_PROGRESS; | 471 image_decode_status_ = IN_PROGRESS; |
| 472 | 472 |
| 473 bool maybe_image = false; | 473 if (model.HasSupportedImageMimeType()) { |
| 474 if (mime_util::IsSupportedImageMimeType(item_->GetMimeType())) { | |
| 475 maybe_image = true; | |
| 476 } else { | |
| 477 std::string mime; | |
| 478 base::FilePath::StringType extension_with_dot = | |
| 479 item_->GetTargetFilePath().FinalExtension(); | |
| 480 if (!extension_with_dot.empty() && | |
| 481 net::GetWellKnownMimeTypeFromExtension(extension_with_dot.substr(1), | |
| 482 &mime) && | |
| 483 mime_util::IsSupportedImageMimeType(mime)) { | |
| 484 maybe_image = true; | |
| 485 } | |
| 486 } | |
| 487 | |
| 488 if (maybe_image) { | |
| 489 base::FilePath file_path = item_->GetFullPath(); | 474 base::FilePath file_path = item_->GetFullPath(); |
| 490 base::PostTaskAndReplyWithResult( | 475 base::PostTaskAndReplyWithResult( |
| 491 content::BrowserThread::GetBlockingPool(), FROM_HERE, | 476 content::BrowserThread::GetBlockingPool(), FROM_HERE, |
| 492 base::Bind(&ReadNotificationImage, file_path), | 477 base::Bind(&ReadNotificationImage, file_path), |
| 493 base::Bind(&DownloadItemNotification::OnImageLoaded, | 478 base::Bind(&DownloadItemNotification::OnImageLoaded, |
| 494 weak_factory_.GetWeakPtr())); | 479 weak_factory_.GetWeakPtr())); |
| 495 } | 480 } |
| 496 } | 481 } |
| 497 } | 482 } |
| 498 | 483 |
| (...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 934 const std::string notification_id_in_message_center = notification->id(); | 919 const std::string notification_id_in_message_center = notification->id(); |
| 935 | 920 |
| 936 message_center::NotificationList::Notifications visible_notifications = | 921 message_center::NotificationList::Notifications visible_notifications = |
| 937 message_center_->GetVisibleNotifications(); | 922 message_center_->GetVisibleNotifications(); |
| 938 for (const auto& notification : visible_notifications) { | 923 for (const auto& notification : visible_notifications) { |
| 939 if (notification->id() == notification_id_in_message_center) | 924 if (notification->id() == notification_id_in_message_center) |
| 940 return true; | 925 return true; |
| 941 } | 926 } |
| 942 return false; | 927 return false; |
| 943 } | 928 } |
| OLD | NEW |