Add a Notification Settings Button to all web notifications behind the web platform...
[chromium-blink-merge.git] / chrome / browser / notifications / persistent_notification_delegate.cc
blob4acd06a47de0fdba4116610c08ebeb35fd458c7d
1 // Copyright 2014 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/notifications/persistent_notification_delegate.h"
7 #include "base/bind.h"
8 #include "base/guid.h"
9 #include "chrome/browser/notifications/platform_notification_service_impl.h"
10 #include "content/public/common/persistent_notification_status.h"
12 PersistentNotificationDelegate::PersistentNotificationDelegate(
13 content::BrowserContext* browser_context,
14 int64_t persistent_notification_id,
15 const GURL& origin,
16 int notification_settings_index)
17 : browser_context_(browser_context),
18 persistent_notification_id_(persistent_notification_id),
19 origin_(origin),
20 id_(base::GenerateGUID()),
21 notification_settings_index_(notification_settings_index) {}
23 PersistentNotificationDelegate::~PersistentNotificationDelegate() {}
25 void PersistentNotificationDelegate::Display() {}
27 void PersistentNotificationDelegate::Close(bool by_user) {
28 PlatformNotificationServiceImpl::GetInstance()->OnPersistentNotificationClose(
29 browser_context_,
30 persistent_notification_id_,
31 origin_);
34 void PersistentNotificationDelegate::Click() {
35 PlatformNotificationServiceImpl::GetInstance()->OnPersistentNotificationClick(
36 browser_context_,
37 persistent_notification_id_,
38 origin_,
39 -1 /* action_index */);
42 void PersistentNotificationDelegate::ButtonClick(int button_index) {
43 DCHECK_GE(button_index, 0);
44 if (button_index == notification_settings_index_) {
45 PlatformNotificationServiceImpl::GetInstance()->OpenNotificationSettings(
46 browser_context_);
47 return;
50 PlatformNotificationServiceImpl::GetInstance()->OnPersistentNotificationClick(
51 browser_context_,
52 persistent_notification_id_,
53 origin_,
54 button_index);
57 std::string PersistentNotificationDelegate::id() const {
58 return id_;