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

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

Issue 2093953002: Introduce a new API to handle native notification clicks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 2016 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/notifications/persistent_notification_handler.h"
6
7 #include "base/logging.h"
8 #include "base/strings/string_number_conversions.h"
9 #include "chrome/browser/notifications/platform_notification_service_impl.h"
10 #include "chrome/browser/profiles/profile.h"
11
12 PersistentNotificationHandler::PersistentNotificationHandler() {}
13 PersistentNotificationHandler::~PersistentNotificationHandler() {}
14
15 void PersistentNotificationHandler::HandleNotificationOperation(
16 notification_operation_common::NotificationOperation operation,
17 Profile* profile,
18 const std::string& origin,
19 const std::string& notification_id,
20 int action_index) {
21 GURL notification_origin(origin);
22 int64_t persistent_notification_id;
23 if (!base::StringToInt64(notification_id, &persistent_notification_id)) {
24 LOG(ERROR) << "Unable to convert notification ID: " << notification_id
25 << " to integer.";
26 return;
27 }
28
29 switch (operation) {
30 case notification_operation_common::NOTIFICATION_CLICK:
31 PlatformNotificationServiceImpl::GetInstance()
32 ->OnPersistentNotificationClick(profile, persistent_notification_id,
33 notification_origin, action_index);
34 break;
35 case notification_operation_common::NOTIFICATION_CLOSE:
36 PlatformNotificationServiceImpl::GetInstance()
37 ->OnPersistentNotificationClose(profile, persistent_notification_id,
38 notification_origin, true);
39 break;
40 case notification_operation_common::NOTIFICATION_SETTINGS:
41 notification_operation_common::OpenNotificationSettings(profile);
42 break;
43 }
44 }
45
46 void PersistentNotificationHandler::CloseNotification(
47 Profile* profile,
48 const std::string& notification_id) {
49 // Nothing to do here since there is no state kept.
50 }
51
52 void PersistentNotificationHandler::RegisterNotification(
53 const std::string& notification_id,
54 std::unique_ptr<Notification> notification) {
55 // Nothing to do here since there is no state kept.
56 }
57
58 notification_operation_common::NotificationHandlerType
59 PersistentNotificationHandler::NotificationType() {
60 return notification_operation_common::PERSISTENT_NOTIFICATION;
61 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698