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 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 notification_->set_progress(0); | 407 notification_->set_progress(0); |
408 notification_->set_priority(message_center::DEFAULT_PRIORITY); | 408 notification_->set_priority(message_center::DEFAULT_PRIORITY); |
409 break; | 409 break; |
410 case content::DownloadItem::MAX_DOWNLOAD_STATE: // sentinel | 410 case content::DownloadItem::MAX_DOWNLOAD_STATE: // sentinel |
411 NOTREACHED(); | 411 NOTREACHED(); |
412 } | 412 } |
413 } | 413 } |
414 UpdateNotificationIcon(); | 414 UpdateNotificationIcon(); |
415 | 415 |
416 std::vector<message_center::ButtonInfo> notification_actions; | 416 std::vector<message_center::ButtonInfo> notification_actions; |
417 scoped_ptr<std::vector<DownloadCommands::Command>> actions( | 417 scoped_ptr<std::vector<DownloadCommands::Command>> actions(GetExtraActions()); |
418 GetExtraActions().Pass()); | |
419 | 418 |
420 button_actions_.reset(new std::vector<DownloadCommands::Command>); | 419 button_actions_.reset(new std::vector<DownloadCommands::Command>); |
421 for (auto it = actions->begin(); it != actions->end(); it++) { | 420 for (auto it = actions->begin(); it != actions->end(); it++) { |
422 button_actions_->push_back(*it); | 421 button_actions_->push_back(*it); |
423 message_center::ButtonInfo button_info = | 422 message_center::ButtonInfo button_info = |
424 message_center::ButtonInfo(GetCommandLabel(*it)); | 423 message_center::ButtonInfo(GetCommandLabel(*it)); |
425 button_info.icon = command.GetCommandIcon(*it); | 424 button_info.icon = command.GetCommandIcon(*it); |
426 notification_actions.push_back(button_info); | 425 notification_actions.push_back(button_info); |
427 } | 426 } |
428 notification_->set_buttons(notification_actions); | 427 notification_->set_buttons(notification_actions); |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
636 new std::vector<DownloadCommands::Command>()); | 635 new std::vector<DownloadCommands::Command>()); |
637 | 636 |
638 if (item_->IsDangerous()) { | 637 if (item_->IsDangerous()) { |
639 DownloadItemModel model(item_); | 638 DownloadItemModel model(item_); |
640 if (model.MightBeMalicious()) { | 639 if (model.MightBeMalicious()) { |
641 actions->push_back(DownloadCommands::LEARN_MORE_SCANNING); | 640 actions->push_back(DownloadCommands::LEARN_MORE_SCANNING); |
642 } else { | 641 } else { |
643 actions->push_back(DownloadCommands::DISCARD); | 642 actions->push_back(DownloadCommands::DISCARD); |
644 actions->push_back(DownloadCommands::KEEP); | 643 actions->push_back(DownloadCommands::KEEP); |
645 } | 644 } |
646 return actions.Pass(); | 645 return actions; |
647 } | 646 } |
648 | 647 |
649 switch (item_->GetState()) { | 648 switch (item_->GetState()) { |
650 case content::DownloadItem::IN_PROGRESS: | 649 case content::DownloadItem::IN_PROGRESS: |
651 if (!item_->IsPaused()) | 650 if (!item_->IsPaused()) |
652 actions->push_back(DownloadCommands::PAUSE); | 651 actions->push_back(DownloadCommands::PAUSE); |
653 else | 652 else |
654 actions->push_back(DownloadCommands::RESUME); | 653 actions->push_back(DownloadCommands::RESUME); |
655 actions->push_back(DownloadCommands::CANCEL); | 654 actions->push_back(DownloadCommands::CANCEL); |
656 break; | 655 break; |
657 case content::DownloadItem::CANCELLED: | 656 case content::DownloadItem::CANCELLED: |
658 case content::DownloadItem::INTERRUPTED: | 657 case content::DownloadItem::INTERRUPTED: |
659 if (item_->CanResume()) | 658 if (item_->CanResume()) |
660 actions->push_back(DownloadCommands::RESUME); | 659 actions->push_back(DownloadCommands::RESUME); |
661 break; | 660 break; |
662 case content::DownloadItem::COMPLETE: | 661 case content::DownloadItem::COMPLETE: |
663 actions->push_back(DownloadCommands::SHOW_IN_FOLDER); | 662 actions->push_back(DownloadCommands::SHOW_IN_FOLDER); |
664 if (!notification_->image().IsEmpty()) | 663 if (!notification_->image().IsEmpty()) |
665 actions->push_back(DownloadCommands::COPY_TO_CLIPBOARD); | 664 actions->push_back(DownloadCommands::COPY_TO_CLIPBOARD); |
666 break; | 665 break; |
667 case content::DownloadItem::MAX_DOWNLOAD_STATE: | 666 case content::DownloadItem::MAX_DOWNLOAD_STATE: |
668 NOTREACHED(); | 667 NOTREACHED(); |
669 } | 668 } |
670 return actions.Pass(); | 669 return actions; |
671 } | 670 } |
672 | 671 |
673 base::string16 DownloadItemNotification::GetTitle() const { | 672 base::string16 DownloadItemNotification::GetTitle() const { |
674 base::string16 title_text; | 673 base::string16 title_text; |
675 DownloadItemModel model(item_); | 674 DownloadItemModel model(item_); |
676 | 675 |
677 if (item_->IsDangerous()) { | 676 if (item_->IsDangerous()) { |
678 if (model.MightBeMalicious()) { | 677 if (model.MightBeMalicious()) { |
679 return l10n_util::GetStringUTF16( | 678 return l10n_util::GetStringUTF16( |
680 IDS_PROMPT_BLOCKED_MALICIOUS_DOWNLOAD_TITLE); | 679 IDS_PROMPT_BLOCKED_MALICIOUS_DOWNLOAD_TITLE); |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
940 const std::string notification_id_in_message_center = notification->id(); | 939 const std::string notification_id_in_message_center = notification->id(); |
941 | 940 |
942 message_center::NotificationList::Notifications visible_notifications = | 941 message_center::NotificationList::Notifications visible_notifications = |
943 message_center_->GetVisibleNotifications(); | 942 message_center_->GetVisibleNotifications(); |
944 for (const auto& notification : visible_notifications) { | 943 for (const auto& notification : visible_notifications) { |
945 if (notification->id() == notification_id_in_message_center) | 944 if (notification->id() == notification_id_in_message_center) |
946 return true; | 945 return true; |
947 } | 946 } |
948 return false; | 947 return false; |
949 } | 948 } |
OLD | NEW |