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

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

Issue 1578263006: Add metrics for usage of permission features from iframes in blink (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 exceptionState.throwTypeError("Illegal constructor."); 77 exceptionState.throwTypeError("Illegal constructor.");
78 return nullptr; 78 return nullptr;
79 } 79 }
80 80
81 if (!options.actions().isEmpty()) { 81 if (!options.actions().isEmpty()) {
82 exceptionState.throwTypeError("Actions are only supported for persistent notifications shown using ServiceWorkerRegistration.showNotification()."); 82 exceptionState.throwTypeError("Actions are only supported for persistent notifications shown using ServiceWorkerRegistration.showNotification().");
83 return nullptr; 83 return nullptr;
84 } 84 }
85 85
86 String insecureOriginMessage; 86 String insecureOriginMessage;
87 UseCounter::Feature feature = context->isSecureContext(insecureOriginMessage ) 87 if (context->isSecureContext(insecureOriginMessage)) {
88 ? UseCounter::NotificationSecureOrigin 88 UseCounter::count(context, UseCounter::NotificationSecureOrigin);
89 : UseCounter::NotificationInsecureOrigin; 89 if (context->isDocument())
90 90 UseCounter::countCrossOriginIframe(*toDocument(context), UseCounter ::NotificationAPISecureOriginIframe);
91 UseCounter::count(context, feature); 91 } else {
92 UseCounter::count(context, UseCounter::NotificationInsecureOrigin);
93 if (context->isDocument())
94 UseCounter::countCrossOriginIframe(*toDocument(context), UseCounter ::NotificationAPIInsecureOriginIframe);
95 }
92 96
93 WebNotificationData data = createWebNotificationData(context, title, options , exceptionState); 97 WebNotificationData data = createWebNotificationData(context, title, options , exceptionState);
94 if (exceptionState.hadException()) 98 if (exceptionState.hadException())
95 return nullptr; 99 return nullptr;
96 100
97 Notification* notification = new Notification(context, data); 101 Notification* notification = new Notification(context, data);
98 notification->scheduleShow(); 102 notification->scheduleShow();
99 notification->suspendIfNeeded(); 103 notification->suspendIfNeeded();
100 104
101 return notification; 105 return notification;
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 { 317 {
314 SecurityOrigin* origin = context->securityOrigin(); 318 SecurityOrigin* origin = context->securityOrigin();
315 ASSERT(origin); 319 ASSERT(origin);
316 320
317 return notificationManager()->checkPermission(WebSecurityOrigin(origin)); 321 return notificationManager()->checkPermission(WebSecurityOrigin(origin));
318 } 322 }
319 323
320 ScriptPromise Notification::requestPermission(ScriptState* scriptState, Notifica tionPermissionCallback* deprecatedCallback) 324 ScriptPromise Notification::requestPermission(ScriptState* scriptState, Notifica tionPermissionCallback* deprecatedCallback)
321 { 325 {
322 ExecutionContext* context = scriptState->executionContext(); 326 ExecutionContext* context = scriptState->executionContext();
327
328 // Measure usage in cross-origin iframes.
mlamouri (slow - plz ping) 2016/01/19 17:54:48 Why do we need to know that? If we want to know us
raymes 2016/01/20 00:13:12 I tried to make what we're counting consistent acr
329 if (context->isDocument()) {
330 String insecureOriginMessage;
331 if (context->isSecureContext(insecureOriginMessage)) {
332 UseCounter::countCrossOriginIframe(*toDocument(context), UseCounter: :NotificationAPISecureOriginIframe);
333 } else {
334 UseCounter::countCrossOriginIframe(*toDocument(context), UseCounter: :NotificationAPIInsecureOriginIframe);
335 }
336 }
337
323 if (NotificationPermissionClient* permissionClient = NotificationPermissionC lient::from(context)) 338 if (NotificationPermissionClient* permissionClient = NotificationPermissionC lient::from(context))
324 return permissionClient->requestPermission(scriptState, deprecatedCallba ck); 339 return permissionClient->requestPermission(scriptState, deprecatedCallba ck);
325 340
326 // The context has been detached. Return a promise that will never settle. 341 // The context has been detached. Return a promise that will never settle.
327 ASSERT(context->activeDOMObjectsAreStopped()); 342 ASSERT(context->activeDOMObjectsAreStopped());
328 return ScriptPromise(); 343 return ScriptPromise();
329 } 344 }
330 345
331 size_t Notification::maxActions() 346 size_t Notification::maxActions()
332 { 347 {
(...skipping 30 matching lines...) Expand all
363 } 378 }
364 379
365 DEFINE_TRACE(Notification) 380 DEFINE_TRACE(Notification)
366 { 381 {
367 visitor->trace(m_asyncRunner); 382 visitor->trace(m_asyncRunner);
368 RefCountedGarbageCollectedEventTargetWithInlineData<Notification>::trace(vis itor); 383 RefCountedGarbageCollectedEventTargetWithInlineData<Notification>::trace(vis itor);
369 ActiveDOMObject::trace(visitor); 384 ActiveDOMObject::trace(visitor);
370 } 385 }
371 386
372 } // namespace blink 387 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698