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

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

Issue 1318293002: Only expose Notification.requestPermission() on the Window global. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: handle detached contexts Created 5 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 | Annotate | Revision Log
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 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 { 304 {
305 SecurityOrigin* origin = context->securityOrigin(); 305 SecurityOrigin* origin = context->securityOrigin();
306 ASSERT(origin); 306 ASSERT(origin);
307 307
308 return notificationManager()->checkPermission(WebSecurityOrigin(origin)); 308 return notificationManager()->checkPermission(WebSecurityOrigin(origin));
309 } 309 }
310 310
311 ScriptPromise Notification::requestPermission(ScriptState* scriptState, Notifica tionPermissionCallback* deprecatedCallback) 311 ScriptPromise Notification::requestPermission(ScriptState* scriptState, Notifica tionPermissionCallback* deprecatedCallback)
312 { 312 {
313 ExecutionContext* context = scriptState->executionContext(); 313 ExecutionContext* context = scriptState->executionContext();
314 NotificationPermissionClient* permissionClient = NotificationPermissionClien t::from(context); 314 if (NotificationPermissionClient* permissionClient = NotificationPermissionC lient::from(context))
315 if (!permissionClient) { 315 return permissionClient->requestPermission(scriptState, deprecatedCallba ck);
316 // TODO(peter): Assert that this code-path will only be reached for Docu ment environments when Blink
317 // supports [Exposed] annotations on class members in IDL definitions. S ee https://crbug.com/442139.
318 return ScriptPromise::cast(scriptState, v8String(scriptState->isolate(), permission(context)));
319 }
320 316
321 return permissionClient->requestPermission(scriptState, deprecatedCallback); 317 // The context has been detached. Return a promise that will never settle.
318 ASSERT(context->activeDOMObjectsAreStopped());
319 return ScriptPromise();
322 } 320 }
323 321
324 size_t Notification::maxActions() 322 size_t Notification::maxActions()
325 { 323 {
326 // Returns a fixed number for unit tests, which run without the availability of the Platform object. 324 // Returns a fixed number for unit tests, which run without the availability of the Platform object.
327 if (!notificationManager()) 325 if (!notificationManager())
328 return 2; 326 return 2;
329 327
330 return notificationManager()->maxActions(); 328 return notificationManager()->maxActions();
331 } 329 }
(...skipping 23 matching lines...) Expand all
355 return m_state == NotificationStateShowing || m_asyncRunner.isActive(); 353 return m_state == NotificationStateShowing || m_asyncRunner.isActive();
356 } 354 }
357 355
358 DEFINE_TRACE(Notification) 356 DEFINE_TRACE(Notification)
359 { 357 {
360 RefCountedGarbageCollectedEventTargetWithInlineData<Notification>::trace(vis itor); 358 RefCountedGarbageCollectedEventTargetWithInlineData<Notification>::trace(vis itor);
361 ActiveDOMObject::trace(visitor); 359 ActiveDOMObject::trace(visitor);
362 } 360 }
363 361
364 } // namespace blink 362 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698