Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 61 WebNotificationManager* notificationManager() { | 61 WebNotificationManager* notificationManager() { |
| 62 return Platform::current()->notificationManager(); | 62 return Platform::current()->notificationManager(); |
| 63 } | 63 } |
| 64 | 64 |
| 65 } // namespace | 65 } // namespace |
| 66 | 66 |
| 67 Notification* Notification::create(ExecutionContext* context, | 67 Notification* Notification::create(ExecutionContext* context, |
| 68 const String& title, | 68 const String& title, |
| 69 const NotificationOptions& options, | 69 const NotificationOptions& options, |
| 70 ExceptionState& exceptionState) { | 70 ExceptionState& exceptionState) { |
| 71 // The Web Notification constructor may be disabled through a runtime feature. The | 71 // The Notification constructor may be disabled through a runtime feature when |
| 72 // behavior of the constructor is changing, but not completely agreed upon yet . | 72 // the platform does not support non-persistent notifications. |
| 73 if (!RuntimeEnabledFeatures::notificationConstructorEnabled()) { | 73 if (!RuntimeEnabledFeatures::notificationConstructorEnabled()) { |
| 74 exceptionState.throwTypeError( | 74 exceptionState.throwTypeError( |
| 75 "Illegal constructor. Use ServiceWorkerRegistration.showNotification() " | 75 "Illegal constructor. Use ServiceWorkerRegistration.showNotification() " |
| 76 "instead."); | 76 "instead."); |
| 77 return nullptr; | 77 return nullptr; |
| 78 } | 78 } |
| 79 | 79 |
| 80 // The Web Notification constructor may not be used in Service Worker contexts . | 80 // The Notification constructor may not be used in Service Worker contexts. |
| 81 if (context->isServiceWorkerGlobalScope()) { | 81 if (context->isServiceWorkerGlobalScope()) { |
| 82 exceptionState.throwTypeError("Illegal constructor."); | 82 exceptionState.throwTypeError("Illegal constructor."); |
| 83 return nullptr; | 83 return nullptr; |
| 84 } | 84 } |
| 85 | 85 |
| 86 if (!options.actions().isEmpty()) { | 86 if (!options.actions().isEmpty()) { |
| 87 exceptionState.throwTypeError( | 87 exceptionState.throwTypeError( |
| 88 "Actions are only supported for persistent notifications shown using " | 88 "Actions are only supported for persistent notifications shown using " |
| 89 "ServiceWorkerRegistration.showNotification()."); | 89 "ServiceWorkerRegistration.showNotification()."); |
| 90 return nullptr; | 90 return nullptr; |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 211 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture); | 211 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture); |
| 212 ScopedWindowFocusAllowedIndicator windowFocusAllowed(getExecutionContext()); | 212 ScopedWindowFocusAllowedIndicator windowFocusAllowed(getExecutionContext()); |
| 213 dispatchEvent(Event::create(EventTypeNames::click)); | 213 dispatchEvent(Event::create(EventTypeNames::click)); |
| 214 } | 214 } |
| 215 | 215 |
| 216 void Notification::dispatchErrorEvent() { | 216 void Notification::dispatchErrorEvent() { |
| 217 dispatchEvent(Event::create(EventTypeNames::error)); | 217 dispatchEvent(Event::create(EventTypeNames::error)); |
| 218 } | 218 } |
| 219 | 219 |
| 220 void Notification::dispatchCloseEvent() { | 220 void Notification::dispatchCloseEvent() { |
| 221 // The notification will be showing when the user initiated the close, or it w ill be | 221 // The notification should be Showing when the user initiated the close, or it |
|
harkness
2016/10/04 14:31:16
How about "if a" instead of "when the"?
Peter Beverloo
2016/10/04 14:38:04
Done ("if the")
| |
| 222 // closing if the developer initiated the close. | 222 // should be Closing when the developer initiated the close. |
| 223 if (m_state != State::Showing && m_state != State::Closing) | 223 if (m_state != State::Showing && m_state != State::Closing) |
| 224 return; | 224 return; |
| 225 | 225 |
| 226 m_state = State::Closed; | 226 m_state = State::Closed; |
| 227 dispatchEvent(Event::create(EventTypeNames::close)); | 227 dispatchEvent(Event::create(EventTypeNames::close)); |
| 228 } | 228 } |
| 229 | 229 |
| 230 String Notification::title() const { | 230 String Notification::title() const { |
| 231 return m_data.title; | 231 return m_data.title; |
| 232 } | 232 } |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 318 break; | 318 break; |
| 319 default: | 319 default: |
| 320 NOTREACHED() << "Unknown action type: " << m_data.actions[i].type; | 320 NOTREACHED() << "Unknown action type: " << m_data.actions[i].type; |
| 321 } | 321 } |
| 322 | 322 |
| 323 action.setAction(m_data.actions[i].action); | 323 action.setAction(m_data.actions[i].action); |
| 324 action.setTitle(m_data.actions[i].title); | 324 action.setTitle(m_data.actions[i].title); |
| 325 action.setIcon(m_data.actions[i].icon.string()); | 325 action.setIcon(m_data.actions[i].icon.string()); |
| 326 action.setPlaceholder(m_data.actions[i].placeholder); | 326 action.setPlaceholder(m_data.actions[i].placeholder); |
| 327 | 327 |
| 328 // Not just the sequence of actions itself, but also the actions contained w ithin the | 328 // Both the Action dictionaries themselves and the sequence they'll be |
| 329 // sequence should be frozen per the Web Notification specification. | 329 // returned in are expected to the frozen. This cannot be done with WebIDL. |
| 330 actions[i] = | 330 actions[i] = |
| 331 freezeV8Object(toV8(action, scriptState), scriptState->isolate()); | 331 freezeV8Object(toV8(action, scriptState), scriptState->isolate()); |
| 332 } | 332 } |
| 333 | 333 |
| 334 return actions; | 334 return actions; |
| 335 } | 335 } |
| 336 | 336 |
| 337 String Notification::permissionString( | 337 String Notification::permissionString( |
| 338 mojom::blink::PermissionStatus permission) { | 338 mojom::blink::PermissionStatus permission) { |
| 339 switch (permission) { | 339 switch (permission) { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 396 } | 396 } |
| 397 | 397 |
| 398 DEFINE_TRACE(Notification) { | 398 DEFINE_TRACE(Notification) { |
| 399 visitor->trace(m_prepareShowMethodRunner); | 399 visitor->trace(m_prepareShowMethodRunner); |
| 400 visitor->trace(m_loader); | 400 visitor->trace(m_loader); |
| 401 EventTargetWithInlineData::trace(visitor); | 401 EventTargetWithInlineData::trace(visitor); |
| 402 ActiveDOMObject::trace(visitor); | 402 ActiveDOMObject::trace(visitor); |
| 403 } | 403 } |
| 404 | 404 |
| 405 } // namespace blink | 405 } // namespace blink |
| OLD | NEW |