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

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

Issue 2300093002: Make //content responsible for generating notification Ids (Closed)
Patch Set: Make //content responsible for generating notification Ids 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_handler.h" 5 #include "chrome/browser/notifications/persistent_notification_handler.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/strings/string_number_conversions.h"
9 #include "chrome/browser/notifications/platform_notification_service_impl.h" 8 #include "chrome/browser/notifications/platform_notification_service_impl.h"
10 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
11 10
12 PersistentNotificationHandler::PersistentNotificationHandler() {} 11 PersistentNotificationHandler::PersistentNotificationHandler() {}
13 PersistentNotificationHandler::~PersistentNotificationHandler() {} 12 PersistentNotificationHandler::~PersistentNotificationHandler() {}
14 13
15 void PersistentNotificationHandler::OnClose(Profile* profile, 14 void PersistentNotificationHandler::OnClose(Profile* profile,
16 const std::string& origin, 15 const std::string& origin,
17 const std::string& notification_id, 16 const std::string& notification_id,
18 bool by_user) { 17 bool by_user) {
19 // No need to propage back Close events from JS.
20 if (!by_user) 18 if (!by_user)
21 return; 19 return; // no need to propagate programmatic close events
Miguel Garcia 2016/09/07 17:32:33 nit: I think propagate back was better.
Peter Beverloo 2016/09/08 13:18:56 Done.
22 20
23 int64_t persistent_notification_id; 21 const GURL notification_origin(origin);
24 GURL notification_origin(origin);
25 DCHECK(notification_origin.is_valid()); 22 DCHECK(notification_origin.is_valid());
26 if (!base::StringToInt64(notification_id, &persistent_notification_id)) { 23
27 LOG(ERROR) << "Unable to convert notification ID: " << notification_id
28 << " to integer.";
29 return;
30 }
31 PlatformNotificationServiceImpl::GetInstance()->OnPersistentNotificationClose( 24 PlatformNotificationServiceImpl::GetInstance()->OnPersistentNotificationClose(
32 profile, persistent_notification_id, notification_origin, by_user); 25 profile, notification_id, notification_origin, by_user);
33 } 26 }
34 27
35 void PersistentNotificationHandler::OnClick(Profile* profile, 28 void PersistentNotificationHandler::OnClick(Profile* profile,
36 const std::string& origin, 29 const std::string& origin,
37 const std::string& notification_id, 30 const std::string& notification_id,
38 int action_index) { 31 int action_index) {
39 int64_t persistent_notification_id; 32 const GURL notification_origin(origin);
40 if (!base::StringToInt64(notification_id, &persistent_notification_id)) {
41 LOG(ERROR) << "Unable to convert notification ID: " << notification_id
42 << " to integer.";
43 return;
44 }
45 GURL notification_origin(origin);
46 DCHECK(notification_origin.is_valid()); 33 DCHECK(notification_origin.is_valid());
34
47 PlatformNotificationServiceImpl::GetInstance()->OnPersistentNotificationClick( 35 PlatformNotificationServiceImpl::GetInstance()->OnPersistentNotificationClick(
48 profile, persistent_notification_id, notification_origin, action_index); 36 profile, notification_id, notification_origin, action_index);
49 } 37 }
50 38
51 void PersistentNotificationHandler::OpenSettings(Profile* profile) { 39 void PersistentNotificationHandler::OpenSettings(Profile* profile) {
52 NotificationCommon::OpenNotificationSettings(profile); 40 NotificationCommon::OpenNotificationSettings(profile);
53 } 41 }
54 42
55 void PersistentNotificationHandler::RegisterNotification( 43 void PersistentNotificationHandler::RegisterNotification(
56 const std::string& notification_id, 44 const std::string& notification_id,
57 NotificationDelegate* delegate) { 45 NotificationDelegate* delegate) {
58 // Nothing to do here since there is no state kept. 46 // Nothing to do here since there is no state kept.
59 } 47 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698