Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3821)

Unified Diff: chrome/browser/download/notification/download_notification_manager.cc

Issue 852043002: Initial Implementation of Download Notification (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments & added tests. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/download/notification/download_notification_manager.cc
diff --git a/chrome/browser/download/notification/download_notification_manager.cc b/chrome/browser/download/notification/download_notification_manager.cc
new file mode 100644
index 0000000000000000000000000000000000000000..2542a2700bf2b2090f339fff5f3e54cacd450aa5
--- /dev/null
+++ b/chrome/browser/download/notification/download_notification_manager.cc
@@ -0,0 +1,68 @@
+// 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.
+
+#include "chrome/browser/download/notification/download_notification_manager.h"
+
+#include "base/strings/string_number_conversions.h"
+#include "chrome/browser/download/download_item_model.h"
+#include "chrome/browser/download/notification/download_notification_item.h"
+#include "chrome/grit/chromium_strings.h"
+#include "content/public/browser/download_item.h"
+#include "grit/theme_resources.h"
+#include "ui/base/l10n/l10n_util.h"
+#include "ui/base/resource/resource_bundle.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;
+
+DownloadNotificationManager::DownloadNotificationManager(Profile* profile)
+ : is_downloading_multiple_files_(false) {
+}
+
+DownloadNotificationManager::~DownloadNotificationManager() {
+}
+
+void DownloadNotificationManager::UpdateDownloadingMultipleFiles() {
asanka 2015/02/20 23:34:40 Might be worth leaving this out until it's ready t
yoshiki 2015/02/24 21:30:57 Removed.
+ bool is_downloading_multiple_files = (downloading_items_.size() > 1);
+
+ if (is_downloading_multiple_files != is_downloading_multiple_files_)
+ is_downloading_multiple_files_ = is_downloading_multiple_files;
+
+ if (is_downloading_multiple_files) {
+ // TODO(yoshiki): Hides the single progress and shows the multiple one.
+ } else {
+ // TODO(yoshiki): Hides the multiple progress and shows the single one.
+ }
+}
+
+void DownloadNotificationManager::OnDownloadStarted(
+ DownloadNotificationItem* item) {
+ downloading_items_.insert(item);
+ UpdateDownloadingMultipleFiles();
+}
+
+void DownloadNotificationManager::OnDownloadStopped(
+ DownloadNotificationItem* item) {
+ downloading_items_.erase(item);
+ UpdateDownloadingMultipleFiles();
+}
+
+void DownloadNotificationManager::OnDownloadRemoved(
+ DownloadNotificationItem* item) {
+ CHECK(items_.find(item) != items_.end());
+
+ items_.erase(item);
+ downloading_items_.erase(item);
+ item->Release();
+}
+
+void DownloadNotificationManager::OnNewDownloadReady(
+ content::DownloadItem* download) {
+ DownloadNotificationItem* item = new DownloadNotificationItem(download, this);
+ item->AddRef();
asanka 2015/02/20 23:34:40 Rather than manually refcounting, you can make the
asanka 2015/02/20 23:34:40 Rather than manually refcounting, you can make the
yoshiki 2015/02/24 21:30:57 Done.
+ items_.insert(item);
+ UpdateDownloadingMultipleFiles();
+}

Powered by Google App Engine
This is Rietveld 408576698