| 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 if (model.HasSupportedImageMimeType()) { | 473 bool maybe_image = false; |
| 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) { |
| 474 base::FilePath file_path = item_->GetFullPath(); | 489 base::FilePath file_path = item_->GetFullPath(); |
| 475 base::PostTaskAndReplyWithResult( | 490 base::PostTaskAndReplyWithResult( |
| 476 content::BrowserThread::GetBlockingPool(), FROM_HERE, | 491 content::BrowserThread::GetBlockingPool(), FROM_HERE, |
| 477 base::Bind(&ReadNotificationImage, file_path), | 492 base::Bind(&ReadNotificationImage, file_path), |
| 478 base::Bind(&DownloadItemNotification::OnImageLoaded, | 493 base::Bind(&DownloadItemNotification::OnImageLoaded, |
| 479 weak_factory_.GetWeakPtr())); | 494 weak_factory_.GetWeakPtr())); |
| 480 } | 495 } |
| 481 } | 496 } |
| 482 } | 497 } |
| 483 | 498 |
| (...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 919 const std::string notification_id_in_message_center = notification->id(); | 934 const std::string notification_id_in_message_center = notification->id(); |
| 920 | 935 |
| 921 message_center::NotificationList::Notifications visible_notifications = | 936 message_center::NotificationList::Notifications visible_notifications = |
| 922 message_center_->GetVisibleNotifications(); | 937 message_center_->GetVisibleNotifications(); |
| 923 for (const auto& notification : visible_notifications) { | 938 for (const auto& notification : visible_notifications) { |
| 924 if (notification->id() == notification_id_in_message_center) | 939 if (notification->id() == notification_id_in_message_center) |
| 925 return true; | 940 return true; |
| 926 } | 941 } |
| 927 return false; | 942 return false; |
| 928 } | 943 } |
| OLD | NEW |