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 898 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
909 base::string16 size = | 909 base::string16 size = |
910 show_size_ratio ? model.GetProgressSizesString() : | 910 show_size_ratio ? model.GetProgressSizesString() : |
911 ui::FormatBytes(item_->GetReceivedBytes()); | 911 ui::FormatBytes(item_->GetReceivedBytes()); |
912 | 912 |
913 // Download is not completed yet: "3.4/5.6 MB, <SUB STATUS>\nFrom example.com" | 913 // Download is not completed yet: "3.4/5.6 MB, <SUB STATUS>\nFrom example.com" |
914 return l10n_util::GetStringFUTF16( | 914 return l10n_util::GetStringFUTF16( |
915 IDS_DOWNLOAD_NOTIFICATION_STATUS, size, sub_status_text, host_name); | 915 IDS_DOWNLOAD_NOTIFICATION_STATUS, size, sub_status_text, host_name); |
916 } | 916 } |
917 | 917 |
918 Browser* DownloadItemNotification::GetBrowser() const { | 918 Browser* DownloadItemNotification::GetBrowser() const { |
919 chrome::ScopedTabbedBrowserDisplayer browser_displayer( | 919 chrome::ScopedTabbedBrowserDisplayer browser_displayer(profile()); |
920 profile(), chrome::GetActiveDesktop()); | |
921 DCHECK(browser_displayer.browser()); | 920 DCHECK(browser_displayer.browser()); |
922 return browser_displayer.browser(); | 921 return browser_displayer.browser(); |
923 } | 922 } |
924 | 923 |
925 Profile* DownloadItemNotification::profile() const { | 924 Profile* DownloadItemNotification::profile() const { |
926 return Profile::FromBrowserContext(item_->GetBrowserContext()); | 925 return Profile::FromBrowserContext(item_->GetBrowserContext()); |
927 } | 926 } |
928 | 927 |
929 bool DownloadItemNotification::IsNotificationVisible() const { | 928 bool DownloadItemNotification::IsNotificationVisible() const { |
930 const std::string& notification_id = watcher()->id(); | 929 const std::string& notification_id = watcher()->id(); |
931 const ProfileID profile_id = NotificationUIManager::GetProfileID(profile()); | 930 const ProfileID profile_id = NotificationUIManager::GetProfileID(profile()); |
932 if (!g_browser_process->notification_ui_manager()) | 931 if (!g_browser_process->notification_ui_manager()) |
933 return false; | 932 return false; |
934 const Notification* notification = g_browser_process-> | 933 const Notification* notification = g_browser_process-> |
935 notification_ui_manager()->FindById(notification_id, profile_id); | 934 notification_ui_manager()->FindById(notification_id, profile_id); |
936 if (!notification) | 935 if (!notification) |
937 return false; | 936 return false; |
938 | 937 |
939 const std::string notification_id_in_message_center = notification->id(); | 938 const std::string notification_id_in_message_center = notification->id(); |
940 | 939 |
941 message_center::NotificationList::Notifications visible_notifications = | 940 message_center::NotificationList::Notifications visible_notifications = |
942 message_center_->GetVisibleNotifications(); | 941 message_center_->GetVisibleNotifications(); |
943 for (const auto& notification : visible_notifications) { | 942 for (const auto& notification : visible_notifications) { |
944 if (notification->id() == notification_id_in_message_center) | 943 if (notification->id() == notification_id_in_message_center) |
945 return true; | 944 return true; |
946 } | 945 } |
947 return false; | 946 return false; |
948 } | 947 } |
OLD | NEW |