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

Side by Side Diff: content/browser/notifications/notification_event_dispatcher_impl.cc

Issue 1619703002: Implement notificationclose event (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed some logging statements Created 4 years, 11 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 "content/browser/notifications/notification_event_dispatcher_impl.h" 5 #include "content/browser/notifications/notification_event_dispatcher_impl.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 #include "content/browser/notifications/platform_notification_context_impl.h" 9 #include "content/browser/notifications/platform_notification_context_impl.h"
10 #include "content/browser/service_worker/service_worker_context_wrapper.h" 10 #include "content/browser/service_worker/service_worker_context_wrapper.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 // the user clicking on them. It should be removed once that's fixed. 88 // the user clicking on them. It should be removed once that's fixed.
89 LOG(INFO) << "Trying to dispatch notification for SW with status: " 89 LOG(INFO) << "Trying to dispatch notification for SW with status: "
90 << service_worker_status << " action_index: " << action_index; 90 << service_worker_status << " action_index: " << action_index;
91 #endif 91 #endif
92 if (service_worker_status == SERVICE_WORKER_OK) { 92 if (service_worker_status == SERVICE_WORKER_OK) {
93 base::Callback<void(ServiceWorkerStatusCode)> dispatch_event_callback = 93 base::Callback<void(ServiceWorkerStatusCode)> dispatch_event_callback =
94 base::Bind(&NotificationClickEventFinished, dispatch_complete_callback, 94 base::Bind(&NotificationClickEventFinished, dispatch_complete_callback,
95 service_worker_registration); 95 service_worker_registration);
96 96
97 DCHECK(service_worker_registration->active_version()); 97 DCHECK(service_worker_registration->active_version());
98 service_worker_registration->active_version() 98 // TODO(nsatragno): refactor this class to avoid passing whether it's a
99 ->DispatchNotificationClickEvent( 99 // close or click notification through the action_index.
100 dispatch_event_callback, notification_database_data.notification_id, 100 if (action_index == -2) {
Nina 2016/01/21 13:55:36 This is the thing I like the least about my CL. Th
101 notification_database_data.notification_data, action_index); 101 service_worker_registration->active_version()
102 ->DispatchNotificationCloseEvent(
103 dispatch_event_callback,
104 notification_database_data.notification_id,
105 notification_database_data.notification_data);
106 } else {
107 service_worker_registration->active_version()
108 ->DispatchNotificationClickEvent(
109 dispatch_event_callback,
110 notification_database_data.notification_id,
111 notification_database_data.notification_data, action_index);
112 }
102 return; 113 return;
103 } 114 }
104 115
105 PersistentNotificationStatus status = PERSISTENT_NOTIFICATION_STATUS_SUCCESS; 116 PersistentNotificationStatus status = PERSISTENT_NOTIFICATION_STATUS_SUCCESS;
106 switch (service_worker_status) { 117 switch (service_worker_status) {
107 case SERVICE_WORKER_ERROR_NOT_FOUND: 118 case SERVICE_WORKER_ERROR_NOT_FOUND:
108 status = PERSISTENT_NOTIFICATION_STATUS_NO_SERVICE_WORKER; 119 status = PERSISTENT_NOTIFICATION_STATUS_NO_SERVICE_WORKER;
109 break; 120 break;
110 case SERVICE_WORKER_ERROR_FAILED: 121 case SERVICE_WORKER_ERROR_FAILED:
111 case SERVICE_WORKER_ERROR_ABORT: 122 case SERVICE_WORKER_ERROR_ABORT:
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 static_cast<PlatformNotificationContextImpl*>( 234 static_cast<PlatformNotificationContextImpl*>(
224 partition->GetPlatformNotificationContext()); 235 partition->GetPlatformNotificationContext());
225 236
226 BrowserThread::PostTask( 237 BrowserThread::PostTask(
227 BrowserThread::IO, FROM_HERE, 238 BrowserThread::IO, FROM_HERE,
228 base::Bind(&ReadNotificationDatabaseData, persistent_notification_id, 239 base::Bind(&ReadNotificationDatabaseData, persistent_notification_id,
229 origin, action_index, dispatch_complete_callback, 240 origin, action_index, dispatch_complete_callback,
230 service_worker_context, notification_context)); 241 service_worker_context, notification_context));
231 } 242 }
232 243
244 void NotificationEventDispatcherImpl::DispatchNotificationCloseEvent(
245 BrowserContext* browser_context,
246 int64_t persistent_notification_id,
247 const GURL& origin,
248 const NotificationClickDispatchCompleteCallback&
249 dispatch_complete_callback) {
250 DispatchNotificationClickEvent(browser_context, persistent_notification_id,
251 origin, -2, dispatch_complete_callback);
252 }
253
233 } // namespace content 254 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698