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.
5 #include "chrome/browser/download/notification/download_notification.h"
7 #include "chrome/browser/download/notification/download_notification_manager.h"
11 ///////////////////////////////////////////////////////////////////////////////
12 // NotificationWatcher class:
13 ///////////////////////////////////////////////////////////////////////////////
15 class NotificationWatcher
: public NotificationDelegate
{
17 explicit NotificationWatcher(DownloadNotification
* item
) : item_(item
) {}
19 // NotificationDelegate overrides:
20 void Close(bool by_user
) override
{
21 item_
->OnNotificationClose();
24 void Click() override
{
25 item_
->OnNotificationClick();
28 bool HasClickedListener() override
{
32 void ButtonClick(int button_index
) override
{
33 item_
->OnNotificationButtonClick(button_index
);
36 std::string
id() const override
{
37 return item_
->GetNotificationId();
41 ~NotificationWatcher() override
{}
43 DownloadNotification
* item_
;
45 DISALLOW_COPY_AND_ASSIGN(NotificationWatcher
);
48 } // anonymous namespace
50 ///////////////////////////////////////////////////////////////////////////////
51 // DownloadNotification implementation:
52 ///////////////////////////////////////////////////////////////////////////////
55 const char DownloadNotification::kDownloadNotificationOrigin
[] =
58 DownloadNotification::DownloadNotification()
59 : watcher_(new NotificationWatcher(this)) {}
61 DownloadNotification::~DownloadNotification() {}
63 NotificationDelegate
* DownloadNotification::watcher() const {
64 return watcher_
.get();