Index: chrome/browser/download/notification/download_notification_item.h |
diff --git a/chrome/browser/download/notification/download_notification_item.h b/chrome/browser/download/notification/download_notification_item.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..8a9c505098bac2e36a3e67f52341b2762a8ec955 |
--- /dev/null |
+++ b/chrome/browser/download/notification/download_notification_item.h |
@@ -0,0 +1,83 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CHROME_BROWSER_DOWNLOAD_NOTIFICATION_DOWNLOAD_NOTIFICATION_ITEM_H_ |
+#define CHROME_BROWSER_DOWNLOAD_NOTIFICATION_DOWNLOAD_NOTIFICATION_ITEM_H_ |
+ |
+#include "chrome/browser/download/notification/download_notification_item.h" |
+ |
+#include "base/strings/string_number_conversions.h" |
+#include "chrome/browser/download/download_command.h" |
+#include "content/public/browser/download_item.h" |
+#include "grit/theme_resources.h" |
+#include "ui/message_center/message_center.h" |
+#include "ui/message_center/notification.h" |
+#include "ui/message_center/notification_delegate.h" |
+ |
+using message_center::Notification; |
+ |
+class DownloadNotificationItem |
+ : public message_center::NotificationDelegate, |
+ public content::DownloadItem::Observer { |
+ |
+ public: |
+ class Delegate { |
+ public: |
+ virtual void OnDownloadNotificationItemDestroying( |
+ DownloadNotificationItem* item) = 0; |
+ virtual void OnDownloadStarted(DownloadNotificationItem* item) = 0; |
+ virtual void OnDownloadStopped(DownloadNotificationItem* item) = 0; |
+ }; |
+ |
+ DownloadNotificationItem( |
+ content::DownloadItem* item, |
+ Delegate* delegate); |
+ |
+ protected: |
+ ~DownloadNotificationItem()override; |
+ |
+ private: |
+ // message_center::NotificationDelegate overrides: |
+ void Close(bool by_user) override; |
+ void Click() override; |
+ bool HasClickedListener() override; |
+ void ButtonClick(int button_index) override; |
+ |
+ // DownloadItem::Observer methods |
+ void OnDownloadUpdated(content::DownloadItem* item) override; |
+ void OnDownloadOpened(content::DownloadItem* item) override; |
+ void OnDownloadDestroyed(content::DownloadItem* item) override; |
+ |
+ void ShowNotificationAgainSoon(); |
+ void ShowNotificationAgain(); |
+ |
+ void SetNotificationData(); |
+ void SetImageToNotification(int resource_id); |
+ |
+ // Returns a short one-line status string for the download. |
+ base::string16 GetTitle() const; |
+ |
+ // Get the warning test to notify a dangerous download. Should only be called |
+ // if IsDangerous() is true. |
+ base::string16 GetWarningTextLong() const; |
+ |
+ scoped_ptr<std::vector<DownloadCommand::Commands> > |
+ GetPossibleActions() const; |
+ |
+ scoped_ptr<Notification> notification_; |
+ scoped_ptr<std::vector<DownloadCommand::Commands> > button_actions_; |
+ |
+ bool has_timeout_; |
+ bool openable_; |
+ bool downloading_; |
+ int image_resource_id_; |
+ message_center::MessageCenter* message_center_; |
+ content::DownloadItem* item_; |
+ |
+ Delegate* const delegate_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(DownloadNotificationItem); |
+}; |
+ |
+#endif // CHROME_BROWSER_DOWNLOAD_NOTIFICATION_DOWNLOAD_NOTIFICATION_ITEM_H_ |