| 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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 { | 136 { |
| 137 ASSERT(m_state == NotificationStateIdle); | 137 ASSERT(m_state == NotificationStateIdle); |
| 138 ASSERT(!m_prepareShowMethodRunner->isActive()); | 138 ASSERT(!m_prepareShowMethodRunner->isActive()); |
| 139 | 139 |
| 140 m_prepareShowMethodRunner->runAsync(); | 140 m_prepareShowMethodRunner->runAsync(); |
| 141 } | 141 } |
| 142 | 142 |
| 143 void Notification::prepareShow() | 143 void Notification::prepareShow() |
| 144 { | 144 { |
| 145 ASSERT(m_state == NotificationStateIdle); | 145 ASSERT(m_state == NotificationStateIdle); |
| 146 if (Notification::checkPermission(getExecutionContext()) != WebNotificationP
ermissionAllowed) { | 146 if (Notification::checkPermission(getExecutionContext()) != mojom::Permissio
nStatus::GRANTED) { |
| 147 dispatchErrorEvent(); | 147 dispatchErrorEvent(); |
| 148 return; | 148 return; |
| 149 } | 149 } |
| 150 | 150 |
| 151 m_loader = new NotificationResourcesLoader(bind<NotificationResourcesLoader*
>(&Notification::didLoadResources, WeakPersistentThisPointer<Notification>(this)
)); | 151 m_loader = new NotificationResourcesLoader(bind<NotificationResourcesLoader*
>(&Notification::didLoadResources, WeakPersistentThisPointer<Notification>(this)
)); |
| 152 m_loader->start(getExecutionContext(), m_data); | 152 m_loader->start(getExecutionContext(), m_data); |
| 153 } | 153 } |
| 154 | 154 |
| 155 void Notification::didLoadResources(NotificationResourcesLoader* loader) | 155 void Notification::didLoadResources(NotificationResourcesLoader* loader) |
| 156 { | 156 { |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 } | 325 } |
| 326 actions[i].setAction(m_data.actions[i].action); | 326 actions[i].setAction(m_data.actions[i].action); |
| 327 actions[i].setTitle(m_data.actions[i].title); | 327 actions[i].setTitle(m_data.actions[i].title); |
| 328 actions[i].setIcon(m_data.actions[i].icon.string()); | 328 actions[i].setIcon(m_data.actions[i].icon.string()); |
| 329 actions[i].setPlaceholder(m_data.actions[i].placeholder); | 329 actions[i].setPlaceholder(m_data.actions[i].placeholder); |
| 330 } | 330 } |
| 331 | 331 |
| 332 return actions; | 332 return actions; |
| 333 } | 333 } |
| 334 | 334 |
| 335 String Notification::permissionString(WebNotificationPermission permission) | 335 String Notification::permissionString(mojom::PermissionStatus permission) |
| 336 { | 336 { |
| 337 switch (permission) { | 337 switch (permission) { |
| 338 case WebNotificationPermissionAllowed: | 338 case mojom::PermissionStatus::GRANTED: |
| 339 return "granted"; | 339 return "granted"; |
| 340 case WebNotificationPermissionDenied: | 340 case mojom::PermissionStatus::DENIED: |
| 341 return "denied"; | 341 return "denied"; |
| 342 case WebNotificationPermissionDefault: | 342 case mojom::PermissionStatus::ASK: |
| 343 return "default"; | 343 return "default"; |
| 344 } | 344 } |
| 345 | 345 |
| 346 ASSERT_NOT_REACHED(); | 346 ASSERT_NOT_REACHED(); |
| 347 return "denied"; | 347 return "denied"; |
| 348 } | 348 } |
| 349 | 349 |
| 350 String Notification::permission(ExecutionContext* context) | 350 String Notification::permission(ExecutionContext* context) |
| 351 { | 351 { |
| 352 return permissionString(checkPermission(context)); | 352 return permissionString(checkPermission(context)); |
| 353 } | 353 } |
| 354 | 354 |
| 355 WebNotificationPermission Notification::checkPermission(ExecutionContext* contex
t) | 355 mojom::PermissionStatus Notification::checkPermission(ExecutionContext* context) |
| 356 { | 356 { |
| 357 SecurityOrigin* origin = context->getSecurityOrigin(); | 357 SecurityOrigin* origin = context->getSecurityOrigin(); |
| 358 ASSERT(origin); | 358 ASSERT(origin); |
| 359 | 359 |
| 360 return notificationManager()->checkPermission(WebSecurityOrigin(origin)); | 360 return notificationManager()->checkPermission(WebSecurityOrigin(origin)); |
| 361 } | 361 } |
| 362 | 362 |
| 363 ScriptPromise Notification::requestPermission(ScriptState* scriptState, Notifica
tionPermissionCallback* deprecatedCallback) | 363 ScriptPromise Notification::requestPermission(ScriptState* scriptState, Notifica
tionPermissionCallback* deprecatedCallback) |
| 364 { | 364 { |
| 365 ExecutionContext* context = scriptState->getExecutionContext(); | 365 ExecutionContext* context = scriptState->getExecutionContext(); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 410 | 410 |
| 411 DEFINE_TRACE(Notification) | 411 DEFINE_TRACE(Notification) |
| 412 { | 412 { |
| 413 visitor->trace(m_prepareShowMethodRunner); | 413 visitor->trace(m_prepareShowMethodRunner); |
| 414 visitor->trace(m_loader); | 414 visitor->trace(m_loader); |
| 415 EventTargetWithInlineData::trace(visitor); | 415 EventTargetWithInlineData::trace(visitor); |
| 416 ActiveDOMObject::trace(visitor); | 416 ActiveDOMObject::trace(visitor); |
| 417 } | 417 } |
| 418 | 418 |
| 419 } // namespace blink | 419 } // namespace blink |
| OLD | NEW |