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