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

Side by Side Diff: chrome/browser/notifications/persistent_notification_delegate.cc

Issue 2300093002: Make //content responsible for generating notification Ids (Closed)
Patch Set: rebase + comments Created 4 years, 3 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/notifications/persistent_notification_delegate.h" 5 #include "chrome/browser/notifications/persistent_notification_delegate.h"
6 6
7 #include "base/bind.h"
8 #include "base/guid.h"
9 #include "chrome/browser/notifications/notification_common.h"
10 #include "chrome/browser/notifications/platform_notification_service_impl.h" 7 #include "chrome/browser/notifications/platform_notification_service_impl.h"
11 #include "content/public/common/persistent_notification_status.h"
12 8
13 PersistentNotificationDelegate::PersistentNotificationDelegate( 9 PersistentNotificationDelegate::PersistentNotificationDelegate(
14 content::BrowserContext* browser_context, 10 content::BrowserContext* browser_context,
15 int64_t persistent_notification_id, 11 const std::string& notification_id,
16 const GURL& origin, 12 const GURL& origin,
17 int notification_settings_index) 13 int notification_settings_index)
18 : browser_context_(browser_context), 14 : browser_context_(browser_context),
19 persistent_notification_id_(persistent_notification_id), 15 notification_id_(notification_id),
20 origin_(origin), 16 origin_(origin),
21 id_(base::GenerateGUID()),
22 notification_settings_index_(notification_settings_index) {} 17 notification_settings_index_(notification_settings_index) {}
23 18
24 PersistentNotificationDelegate::~PersistentNotificationDelegate() {} 19 PersistentNotificationDelegate::~PersistentNotificationDelegate() {}
25 20
26 void PersistentNotificationDelegate::Display() {} 21 void PersistentNotificationDelegate::Display() {}
27 22
28 void PersistentNotificationDelegate::Close(bool by_user) { 23 void PersistentNotificationDelegate::Close(bool by_user) {
29 PlatformNotificationServiceImpl::GetInstance()->OnPersistentNotificationClose( 24 PlatformNotificationServiceImpl::GetInstance()->OnPersistentNotificationClose(
30 browser_context_, 25 browser_context_, notification_id_, origin_, by_user);
31 persistent_notification_id_,
32 origin_,
33 by_user);
34 } 26 }
35 27
36 void PersistentNotificationDelegate::Click() { 28 void PersistentNotificationDelegate::Click() {
37 PlatformNotificationServiceImpl::GetInstance()->OnPersistentNotificationClick( 29 PlatformNotificationServiceImpl::GetInstance()->OnPersistentNotificationClick(
38 browser_context_, 30 browser_context_, notification_id_, origin_, -1 /* action_index */);
39 persistent_notification_id_,
40 origin_,
41 -1 /* action_index */);
42 } 31 }
43 32
44 void PersistentNotificationDelegate::ButtonClick(int button_index) { 33 void PersistentNotificationDelegate::ButtonClick(int button_index) {
45 DCHECK_GE(button_index, 0); 34 DCHECK_GE(button_index, 0);
46 if (button_index == notification_settings_index_) { 35 if (button_index == notification_settings_index_) {
47 NotificationCommon::OpenNotificationSettings(browser_context_); 36 NotificationCommon::OpenNotificationSettings(browser_context_);
48 return; 37 return;
49 } 38 }
50 39
51 PlatformNotificationServiceImpl::GetInstance()->OnPersistentNotificationClick( 40 PlatformNotificationServiceImpl::GetInstance()->OnPersistentNotificationClick(
52 browser_context_, 41 browser_context_, notification_id_, origin_, button_index);
53 persistent_notification_id_,
54 origin_,
55 button_index);
56 } 42 }
57 43
58 void PersistentNotificationDelegate::SettingsClick() { 44 void PersistentNotificationDelegate::SettingsClick() {
59 NotificationCommon::OpenNotificationSettings(browser_context_); 45 NotificationCommon::OpenNotificationSettings(browser_context_);
60 return;
61 } 46 }
62 47
63 bool PersistentNotificationDelegate::ShouldDisplaySettingsButton() { 48 bool PersistentNotificationDelegate::ShouldDisplaySettingsButton() {
64 return true; 49 return true;
65 } 50 }
66 51
67 std::string PersistentNotificationDelegate::id() const { 52 std::string PersistentNotificationDelegate::id() const {
68 return id_; 53 return notification_id_;
69 } 54 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698