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

Side by Side Diff: third_party/WebKit/Source/modules/notifications/ServiceWorkerRegistrationNotifications.cpp

Issue 1422193003: UMA for Notification action buttons (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address nit Created 5 years, 1 month 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 "config.h" 5 #include "config.h"
6 #include "modules/notifications/ServiceWorkerRegistrationNotifications.h" 6 #include "modules/notifications/ServiceWorkerRegistrationNotifications.h"
7 7
8 #include "bindings/core/v8/CallbackPromiseAdapter.h" 8 #include "bindings/core/v8/CallbackPromiseAdapter.h"
9 #include "bindings/core/v8/ExceptionState.h" 9 #include "bindings/core/v8/ExceptionState.h"
10 #include "bindings/core/v8/ScriptPromiseResolver.h" 10 #include "bindings/core/v8/ScriptPromiseResolver.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 53
54 // If permission for notification's origin is not "granted", reject promise with a TypeError exception, and terminate these substeps. 54 // If permission for notification's origin is not "granted", reject promise with a TypeError exception, and terminate these substeps.
55 if (Notification::checkPermission(executionContext) != WebNotificationPermis sionAllowed) 55 if (Notification::checkPermission(executionContext) != WebNotificationPermis sionAllowed)
56 return ScriptPromise::reject(scriptState, V8ThrowException::createTypeEr ror(scriptState->isolate(), "No notification permission has been granted for thi s origin.")); 56 return ScriptPromise::reject(scriptState, V8ThrowException::createTypeEr ror(scriptState->isolate(), "No notification permission has been granted for thi s origin."));
57 57
58 // Validate the developer-provided values to get a WebNotificationData objec t. 58 // Validate the developer-provided values to get a WebNotificationData objec t.
59 WebNotificationData data = createWebNotificationData(executionContext, title , options, exceptionState); 59 WebNotificationData data = createWebNotificationData(executionContext, title , options, exceptionState);
60 if (exceptionState.hadException()) 60 if (exceptionState.hadException())
61 return exceptionState.reject(scriptState); 61 return exceptionState.reject(scriptState);
62 62
63 // Log number of actions developer provided, even if it's more than we curre ntly support.
64 Platform::current()->histogramCustomCounts("Notifications.PersistentNotifica tionActionCount", options.actions().size(), 0, 10, 12 /* one extra bucket for > 10 */);
Alexei Svitkine (slow) 2015/10/28 19:09:09 If you want a single bucket for each distinct coun
johnme 2015/10/29 14:24:41 We don't strictly care about having distinct bucke
Alexei Svitkine (slow) 2015/10/29 19:24:05 Well, the way you're using counts() right now is e
johnme 2015/11/23 15:06:09 Gotcha. I've switched to histogramEnumeration/Line
65
63 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ; 66 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ;
64 ScriptPromise promise = resolver->promise(); 67 ScriptPromise promise = resolver->promise();
65 68
66 WebNotificationShowCallbacks* callbacks = new CallbackPromiseAdapter<void, v oid>(resolver); 69 WebNotificationShowCallbacks* callbacks = new CallbackPromiseAdapter<void, v oid>(resolver);
67 70
68 SecurityOrigin* origin = executionContext->securityOrigin(); 71 SecurityOrigin* origin = executionContext->securityOrigin();
69 WebNotificationManager* notificationManager = Platform::current()->notificat ionManager(); 72 WebNotificationManager* notificationManager = Platform::current()->notificat ionManager();
70 ASSERT(notificationManager); 73 ASSERT(notificationManager);
71 74
72 notificationManager->showPersistent(WebSecurityOrigin(origin), data, service WorkerRegistration.webRegistration(), callbacks); 75 notificationManager->showPersistent(WebSecurityOrigin(origin), data, service WorkerRegistration.webRegistration(), callbacks);
73 return promise; 76 return promise;
74 } 77 }
75 78
76 ScriptPromise ServiceWorkerRegistrationNotifications::getNotifications(ScriptSta te* scriptState, ServiceWorkerRegistration& serviceWorkerRegistration, const Get NotificationOptions& options) 79 ScriptPromise ServiceWorkerRegistrationNotifications::getNotifications(ScriptSta te* scriptState, ServiceWorkerRegistration& serviceWorkerRegistration, const Get NotificationOptions& options)
77 { 80 {
78 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ; 81 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ;
79 ScriptPromise promise = resolver->promise(); 82 ScriptPromise promise = resolver->promise();
80 83
81 WebNotificationGetCallbacks* callbacks = new CallbackPromiseAdapter<Notifica tionArray, void>(resolver); 84 WebNotificationGetCallbacks* callbacks = new CallbackPromiseAdapter<Notifica tionArray, void>(resolver);
82 85
83 WebNotificationManager* notificationManager = Platform::current()->notificat ionManager(); 86 WebNotificationManager* notificationManager = Platform::current()->notificat ionManager();
84 ASSERT(notificationManager); 87 ASSERT(notificationManager);
85 88
86 notificationManager->getNotifications(options.tag(), serviceWorkerRegistrati on.webRegistration(), callbacks); 89 notificationManager->getNotifications(options.tag(), serviceWorkerRegistrati on.webRegistration(), callbacks);
87 return promise; 90 return promise;
88 } 91 }
89 92
90 } // namespace blink 93 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698