| 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 #ifndef CHROME_BROWSER_DOWNLOAD_NOTIFICATION_DOWNLOAD_ITEM_NOTIFICATION_H_ | 5 #ifndef CHROME_BROWSER_DOWNLOAD_NOTIFICATION_DOWNLOAD_ITEM_NOTIFICATION_H_ |
| 6 #define CHROME_BROWSER_DOWNLOAD_NOTIFICATION_DOWNLOAD_ITEM_NOTIFICATION_H_ | 6 #define CHROME_BROWSER_DOWNLOAD_NOTIFICATION_DOWNLOAD_ITEM_NOTIFICATION_H_ |
| 7 | 7 |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "chrome/browser/download/download_commands.h" | 9 #include "chrome/browser/download/download_commands.h" |
| 10 #include "chrome/browser/download/notification/download_notification.h" | 10 #include "chrome/browser/download/notification/download_notification.h" |
| 11 #include "chrome/browser/image_decoder.h" | 11 #include "chrome/browser/image_decoder.h" |
| 12 #include "chrome/browser/notifications/notification.h" | 12 #include "chrome/browser/notifications/notification.h" |
| 13 #include "chrome/browser/notifications/notification_delegate.h" | 13 #include "chrome/browser/notifications/notification_delegate.h" |
| 14 #include "chrome/browser/notifications/notification_test_util.h" | 14 #include "chrome/browser/notifications/notification_test_util.h" |
| 15 #include "content/public/browser/download_item.h" | 15 #include "content/public/browser/download_item.h" |
| 16 #include "grit/theme_resources.h" | 16 #include "grit/theme_resources.h" |
| 17 #include "third_party/skia/include/core/SkBitmap.h" | 17 #include "third_party/skia/include/core/SkBitmap.h" |
| 18 #include "third_party/skia/include/core/SkColor.h" | 18 #include "third_party/skia/include/core/SkColor.h" |
| 19 #include "ui/message_center/message_center.h" | 19 #include "ui/message_center/message_center.h" |
| 20 #include "ui/message_center/message_center_observer.h" | 20 #include "ui/message_center/message_center_observer.h" |
| 21 | |
| 22 #if !defined(OS_MACOSX) | |
| 23 #include "ui/native_theme/native_theme.h" | 21 #include "ui/native_theme/native_theme.h" |
| 24 #endif | |
| 25 | 22 |
| 26 namespace test { | 23 namespace test { |
| 27 class DownloadItemNotificationTest; | 24 class DownloadItemNotificationTest; |
| 28 } | 25 } |
| 29 | 26 |
| 30 namespace gfx { | 27 namespace gfx { |
| 31 enum class VectorIconId; | 28 enum class VectorIconId; |
| 32 } | 29 } |
| 33 | 30 |
| 34 class DownloadItemNotification : public DownloadNotification, | 31 class DownloadItemNotification : public DownloadNotification, |
| (...skipping 25 matching lines...) Expand all Loading... |
| 60 }; | 57 }; |
| 61 | 58 |
| 62 void CloseNotificationByUser(); | 59 void CloseNotificationByUser(); |
| 63 void CloseNotificationByNonUser(); | 60 void CloseNotificationByNonUser(); |
| 64 void Update(); | 61 void Update(); |
| 65 void UpdateNotificationData(NotificationUpdateType type); | 62 void UpdateNotificationData(NotificationUpdateType type); |
| 66 void UpdateNotificationIcon(); | 63 void UpdateNotificationIcon(); |
| 67 | 64 |
| 68 // Set icon of the notification. | 65 // Set icon of the notification. |
| 69 void SetNotificationIcon(int resource_id); | 66 void SetNotificationIcon(int resource_id); |
| 70 | |
| 71 #if !defined(OS_MACOSX) | |
| 72 void SetNotificationVectorIcon(gfx::VectorIconId id, SkColor color); | 67 void SetNotificationVectorIcon(gfx::VectorIconId id, SkColor color); |
| 73 #endif | |
| 74 | 68 |
| 75 // Set preview image of the notification. Must be called on IO thread. | 69 // Set preview image of the notification. Must be called on IO thread. |
| 76 void OnImageLoaded(const std::string& image_data); | 70 void OnImageLoaded(const std::string& image_data); |
| 77 void OnImageCropped(const SkBitmap& image); | 71 void OnImageCropped(const SkBitmap& image); |
| 78 | 72 |
| 79 // ImageDecoder::ImageRequest overrides: | 73 // ImageDecoder::ImageRequest overrides: |
| 80 void OnImageDecoded(const SkBitmap& decoded_image) override; | 74 void OnImageDecoded(const SkBitmap& decoded_image) override; |
| 81 void OnDecodeImageFailed() override; | 75 void OnDecodeImageFailed() override; |
| 82 | 76 |
| 83 // Returns a short one-line status string for the download. | 77 // Returns a short one-line status string for the download. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 105 // Returns the list of possible extra (all except the default) actions. | 99 // Returns the list of possible extra (all except the default) actions. |
| 106 scoped_ptr<std::vector<DownloadCommands::Command>> GetExtraActions() const; | 100 scoped_ptr<std::vector<DownloadCommands::Command>> GetExtraActions() const; |
| 107 | 101 |
| 108 // Flag to show the notification on next update. If true, the notification | 102 // Flag to show the notification on next update. If true, the notification |
| 109 // goes visible. The initial value is true so it gets shown on initial update. | 103 // goes visible. The initial value is true so it gets shown on initial update. |
| 110 bool show_next_ = true; | 104 bool show_next_ = true; |
| 111 // Current vilibility status of the notification. | 105 // Current vilibility status of the notification. |
| 112 bool visible_ = false; | 106 bool visible_ = false; |
| 113 | 107 |
| 114 int image_resource_id_ = 0; | 108 int image_resource_id_ = 0; |
| 115 #if !defined(OS_MACOSX) | |
| 116 std::pair<gfx::VectorIconId, SkColor> vector_icon_params_; | 109 std::pair<gfx::VectorIconId, SkColor> vector_icon_params_; |
| 117 #endif | |
| 118 content::DownloadItem::DownloadState previous_download_state_ = | 110 content::DownloadItem::DownloadState previous_download_state_ = |
| 119 content::DownloadItem::MAX_DOWNLOAD_STATE; // As uninitialized state | 111 content::DownloadItem::MAX_DOWNLOAD_STATE; // As uninitialized state |
| 120 bool previous_dangerous_state_ = false; | 112 bool previous_dangerous_state_ = false; |
| 121 scoped_ptr<Notification> notification_; | 113 scoped_ptr<Notification> notification_; |
| 122 content::DownloadItem* item_; | 114 content::DownloadItem* item_; |
| 123 scoped_ptr<std::vector<DownloadCommands::Command>> button_actions_; | 115 scoped_ptr<std::vector<DownloadCommands::Command>> button_actions_; |
| 124 | 116 |
| 125 // Status of the preview image decode. | 117 // Status of the preview image decode. |
| 126 ImageDecodeStatus image_decode_status_ = NOT_STARTED; | 118 ImageDecodeStatus image_decode_status_ = NOT_STARTED; |
| 127 | 119 |
| 128 base::WeakPtrFactory<DownloadItemNotification> weak_factory_; | 120 base::WeakPtrFactory<DownloadItemNotification> weak_factory_; |
| 129 | 121 |
| 130 DISALLOW_COPY_AND_ASSIGN(DownloadItemNotification); | 122 DISALLOW_COPY_AND_ASSIGN(DownloadItemNotification); |
| 131 }; | 123 }; |
| 132 | 124 |
| 133 #endif // CHROME_BROWSER_DOWNLOAD_NOTIFICATION_DOWNLOAD_ITEM_NOTIFICATION_H_ | 125 #endif // CHROME_BROWSER_DOWNLOAD_NOTIFICATION_DOWNLOAD_ITEM_NOTIFICATION_H_ |
| OLD | NEW |