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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/download/notification/download_notification_manager.h"
6
7 #include "base/strings/string_number_conversions.h"
8 #include "chrome/browser/download/download_item_model.h"
9 #include "chrome/browser/download/notification/download_notification_item.h"
10 #include "chrome/grit/chromium_strings.h"
11 #include "content/public/browser/download_item.h"
12 #include "grit/theme_resources.h"
13 #include "ui/base/l10n/l10n_util.h"
14 #include "ui/base/resource/resource_bundle.h"
15 #include "ui/message_center/message_center.h"
16 #include "ui/message_center/notification.h"
17 #include "ui/message_center/notification_delegate.h"
18
19 using message_center::Notification;
20
21 DownloadNotificationManager::DownloadNotificationManager(Profile* profile)
22 : is_downloading_multiple_files_(false) {
23 }
24
25 DownloadNotificationManager::~DownloadNotificationManager() {
26 }
27
28 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.
29 bool is_downloading_multiple_files = (downloading_items_.size() > 1);
30
31 if (is_downloading_multiple_files != is_downloading_multiple_files_)
32 is_downloading_multiple_files_ = is_downloading_multiple_files;
33
34 if (is_downloading_multiple_files) {
35 // TODO(yoshiki): Hides the single progress and shows the multiple one.
36 } else {
37 // TODO(yoshiki): Hides the multiple progress and shows the single one.
38 }
39 }
40
41 void DownloadNotificationManager::OnDownloadStarted(
42 DownloadNotificationItem* item) {
43 downloading_items_.insert(item);
44 UpdateDownloadingMultipleFiles();
45 }
46
47 void DownloadNotificationManager::OnDownloadStopped(
48 DownloadNotificationItem* item) {
49 downloading_items_.erase(item);
50 UpdateDownloadingMultipleFiles();
51 }
52
53 void DownloadNotificationManager::OnDownloadRemoved(
54 DownloadNotificationItem* item) {
55 CHECK(items_.find(item) != items_.end());
56
57 items_.erase(item);
58 downloading_items_.erase(item);
59 item->Release();
60 }
61
62 void DownloadNotificationManager::OnNewDownloadReady(
63 content::DownloadItem* download) {
64 DownloadNotificationItem* item = new DownloadNotificationItem(download, this);
65 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.
66 items_.insert(item);
67 UpdateDownloadingMultipleFiles();
68 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698