| 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 22 matching lines...) Expand all Loading... |
| 33 | 33 |
| 34 #include "bindings/v8/Dictionary.h" | 34 #include "bindings/v8/Dictionary.h" |
| 35 #include "bindings/v8/ScriptWrappable.h" | 35 #include "bindings/v8/ScriptWrappable.h" |
| 36 #include "core/dom/Document.h" | 36 #include "core/dom/Document.h" |
| 37 #include "core/page/WindowFocusAllowedIndicator.h" | 37 #include "core/page/WindowFocusAllowedIndicator.h" |
| 38 #include "modules/notifications/NotificationClient.h" | 38 #include "modules/notifications/NotificationClient.h" |
| 39 #include "modules/notifications/NotificationController.h" | 39 #include "modules/notifications/NotificationController.h" |
| 40 | 40 |
| 41 namespace WebCore { | 41 namespace WebCore { |
| 42 | 42 |
| 43 PassRefPtrWillBeRawPtr<Notification> Notification::create(ExecutionContext* cont
ext, const String& title, const Dictionary& options) | 43 Notification* Notification::create(ExecutionContext* context, const String& titl
e, const Dictionary& options) |
| 44 { | 44 { |
| 45 NotificationClient* client = NotificationController::clientFrom(toDocument(c
ontext)->page()); | 45 NotificationClient* client = NotificationController::clientFrom(toDocument(c
ontext)->page()); |
| 46 RefPtrWillBeRawPtr<Notification> notification = adoptRefWillBeRefCountedGarb
ageCollected(new Notification(title, context, client)); | 46 Notification* notification = adoptRefCountedGarbageCollected(new Notificatio
n(title, context, client)); |
| 47 | 47 |
| 48 String argument; | 48 String argument; |
| 49 if (options.get("body", argument)) | 49 if (options.get("body", argument)) |
| 50 notification->setBody(argument); | 50 notification->setBody(argument); |
| 51 if (options.get("tag", argument)) | 51 if (options.get("tag", argument)) |
| 52 notification->setTag(argument); | 52 notification->setTag(argument); |
| 53 if (options.get("lang", argument)) | 53 if (options.get("lang", argument)) |
| 54 notification->setLang(argument); | 54 notification->setLang(argument); |
| 55 if (options.get("dir", argument)) | 55 if (options.get("dir", argument)) |
| 56 notification->setDir(argument); | 56 notification->setDir(argument); |
| 57 if (options.get("icon", argument)) { | 57 if (options.get("icon", argument)) { |
| 58 KURL iconUrl = argument.isEmpty() ? KURL() : context->completeURL(argume
nt); | 58 KURL iconUrl = argument.isEmpty() ? KURL() : context->completeURL(argume
nt); |
| 59 if (!iconUrl.isEmpty() && iconUrl.isValid()) | 59 if (!iconUrl.isEmpty() && iconUrl.isValid()) |
| 60 notification->setIconUrl(iconUrl); | 60 notification->setIconUrl(iconUrl); |
| 61 } | 61 } |
| 62 | 62 |
| 63 notification->suspendIfNeeded(); | 63 notification->suspendIfNeeded(); |
| 64 return notification.release(); | 64 return notification; |
| 65 } | 65 } |
| 66 | 66 |
| 67 Notification::Notification(const String& title, ExecutionContext* context, Notif
icationClient* client) | 67 Notification::Notification(const String& title, ExecutionContext* context, Notif
icationClient* client) |
| 68 : ActiveDOMObject(context) | 68 : ActiveDOMObject(context) |
| 69 , m_title(title) | 69 , m_title(title) |
| 70 , m_dir("auto") | 70 , m_dir("auto") |
| 71 , m_state(Idle) | 71 , m_state(Idle) |
| 72 , m_client(client) | 72 , m_client(client) |
| 73 , m_asyncRunner(adoptPtr(new AsyncMethodRunner<Notification>(this, &Notifica
tion::show))) | 73 , m_asyncRunner(adoptPtr(new AsyncMethodRunner<Notification>(this, &Notifica
tion::show))) |
| 74 { | 74 { |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 m_client = 0; | 193 m_client = 0; |
| 194 m_state = Closed; | 194 m_state = Closed; |
| 195 } | 195 } |
| 196 | 196 |
| 197 bool Notification::hasPendingActivity() const | 197 bool Notification::hasPendingActivity() const |
| 198 { | 198 { |
| 199 return m_state == Showing || (m_asyncRunner && m_asyncRunner->isActive()); | 199 return m_state == Showing || (m_asyncRunner && m_asyncRunner->isActive()); |
| 200 } | 200 } |
| 201 | 201 |
| 202 } // namespace WebCore | 202 } // namespace WebCore |
| OLD | NEW |