| 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" |
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
| 13 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
| 14 #include "chrome/browser/download/download_crx_util.h" | 14 #include "chrome/browser/download/download_crx_util.h" |
| 15 #include "chrome/browser/download/download_item_model.h" | 15 #include "chrome/browser/download/download_item_model.h" |
| 16 #include "chrome/browser/download/notification/download_notification_manager.h" | 16 #include "chrome/browser/download/notification/download_notification_manager.h" |
| 17 #include "chrome/browser/notifications/notification.h" | 17 #include "chrome/browser/notifications/notification.h" |
| 18 #include "chrome/browser/notifications/notification_ui_manager.h" | 18 #include "chrome/browser/notifications/notification_ui_manager.h" |
| 19 #include "chrome/browser/notifications/profile_notification.h" | 19 #include "chrome/browser/notifications/profile_notification.h" |
| 20 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" | 20 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" |
| 21 #include "chrome/common/pref_names.h" | |
| 22 #include "chrome/common/url_constants.h" | 21 #include "chrome/common/url_constants.h" |
| 23 #include "chrome/grit/chromium_strings.h" | 22 #include "chrome/grit/chromium_strings.h" |
| 24 #include "chrome/grit/generated_resources.h" | 23 #include "chrome/grit/generated_resources.h" |
| 25 #include "components/mime_util/mime_util.h" | 24 #include "components/mime_util/mime_util.h" |
| 26 #include "components/prefs/pref_service.h" | |
| 27 #include "components/url_formatter/elide_url.h" | 25 #include "components/url_formatter/elide_url.h" |
| 28 #include "content/public/browser/browser_context.h" | 26 #include "content/public/browser/browser_context.h" |
| 29 #include "content/public/browser/browser_thread.h" | 27 #include "content/public/browser/browser_thread.h" |
| 30 #include "content/public/browser/download_interrupt_reasons.h" | 28 #include "content/public/browser/download_interrupt_reasons.h" |
| 31 #include "content/public/browser/download_item.h" | 29 #include "content/public/browser/download_item.h" |
| 32 #include "content/public/browser/page_navigator.h" | 30 #include "content/public/browser/page_navigator.h" |
| 33 #include "content/public/browser/user_metrics.h" | 31 #include "content/public/browser/user_metrics.h" |
| 34 #include "content/public/browser/web_contents.h" | 32 #include "content/public/browser/web_contents.h" |
| 35 #include "grit/theme_resources.h" | 33 #include "grit/theme_resources.h" |
| 36 #include "net/base/mime_util.h" | 34 #include "net/base/mime_util.h" |
| (...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 839 // "Starting..." | 837 // "Starting..." |
| 840 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_STATUS_STARTING); | 838 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_STATUS_STARTING); |
| 841 } | 839 } |
| 842 | 840 |
| 843 base::string16 DownloadItemNotification::GetStatusString() const { | 841 base::string16 DownloadItemNotification::GetStatusString() const { |
| 844 if (item_->IsDangerous()) | 842 if (item_->IsDangerous()) |
| 845 return GetWarningStatusString(); | 843 return GetWarningStatusString(); |
| 846 | 844 |
| 847 // The hostname. (E.g.:"example.com" or "127.0.0.1") | 845 // The hostname. (E.g.:"example.com" or "127.0.0.1") |
| 848 base::string16 host_name = | 846 base::string16 host_name = |
| 849 url_formatter::FormatUrlForSecurityDisplayOmitScheme( | 847 url_formatter::FormatUrlForSecurityDisplayOmitScheme(item_->GetURL()); |
| 850 item_->GetURL(), | |
| 851 profile()->GetPrefs()->GetString(prefs::kAcceptLanguages)); | |
| 852 | 848 |
| 853 DownloadItemModel model(item_); | 849 DownloadItemModel model(item_); |
| 854 base::string16 sub_status_text; | 850 base::string16 sub_status_text; |
| 855 bool show_size_ratio = true; | 851 bool show_size_ratio = true; |
| 856 switch (item_->GetState()) { | 852 switch (item_->GetState()) { |
| 857 case content::DownloadItem::IN_PROGRESS: | 853 case content::DownloadItem::IN_PROGRESS: |
| 858 // The download is a CRX (app, extension, theme, ...) and it is being | 854 // The download is a CRX (app, extension, theme, ...) and it is being |
| 859 // unpacked and validated. | 855 // unpacked and validated. |
| 860 if (item_->AllDataSaved() && | 856 if (item_->AllDataSaved() && |
| 861 download_crx_util::IsExtensionDownload(*item_)) { | 857 download_crx_util::IsExtensionDownload(*item_)) { |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 938 const std::string notification_id_in_message_center = notification->id(); | 934 const std::string notification_id_in_message_center = notification->id(); |
| 939 | 935 |
| 940 message_center::NotificationList::Notifications visible_notifications = | 936 message_center::NotificationList::Notifications visible_notifications = |
| 941 message_center_->GetVisibleNotifications(); | 937 message_center_->GetVisibleNotifications(); |
| 942 for (const auto& notification : visible_notifications) { | 938 for (const auto& notification : visible_notifications) { |
| 943 if (notification->id() == notification_id_in_message_center) | 939 if (notification->id() == notification_id_in_message_center) |
| 944 return true; | 940 return true; |
| 945 } | 941 } |
| 946 return false; | 942 return false; |
| 947 } | 943 } |
| OLD | NEW |