| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 3 * Copyright (C) 2011, 2012 Apple Inc. All rights reserved. | 3 * Copyright (C) 2011, 2012 Apple Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 #include "wtf/RefCounted.h" | 48 #include "wtf/RefCounted.h" |
| 49 #include "wtf/RefPtr.h" | 49 #include "wtf/RefPtr.h" |
| 50 | 50 |
| 51 namespace WebCore { | 51 namespace WebCore { |
| 52 | 52 |
| 53 class NotificationClient; | 53 class NotificationClient; |
| 54 class VoidCallback; | 54 class VoidCallback; |
| 55 | 55 |
| 56 // FIXME: oilpan: Change this to GarbageCollectedFinalized once we move ActiveDO
MObject to oilpan. | 56 // FIXME: oilpan: Change this to GarbageCollectedFinalized once we move ActiveDO
MObject to oilpan. |
| 57 class NotificationCenter FINAL : public RefCountedWillBeGarbageCollectedFinalize
d<NotificationCenter>, public ScriptWrappable, public ActiveDOMObject { | 57 class NotificationCenter FINAL : public RefCountedWillBeGarbageCollectedFinalize
d<NotificationCenter>, public ScriptWrappable, public ActiveDOMObject { |
| 58 DECLARE_GC_INFO; | |
| 59 public: | 58 public: |
| 60 static PassRefPtrWillBeRawPtr<NotificationCenter> create(ExecutionContext*,
NotificationClient*); | 59 static PassRefPtrWillBeRawPtr<NotificationCenter> create(ExecutionContext*,
NotificationClient*); |
| 61 | 60 |
| 62 PassRefPtrWillBeRawPtr<WebKitNotification> createNotification(const String&
iconUrl, const String& title, const String& body, ExceptionState& exceptionState
) | 61 PassRefPtrWillBeRawPtr<WebKitNotification> createNotification(const String&
iconUrl, const String& title, const String& body, ExceptionState& exceptionState
) |
| 63 { | 62 { |
| 64 if (!client()) { | 63 if (!client()) { |
| 65 exceptionState.throwDOMException(InvalidStateError, "The notificatio
n client is null."); | 64 exceptionState.throwDOMException(InvalidStateError, "The notificatio
n client is null."); |
| 66 return nullptr; | 65 return nullptr; |
| 67 } | 66 } |
| 68 return WebKitNotification::create(title, body, iconUrl, executionContext
(), exceptionState, this); | 67 return WebKitNotification::create(title, body, iconUrl, executionContext
(), exceptionState, this); |
| 69 } | 68 } |
| 70 | 69 |
| 71 NotificationClient* client() const { return m_client; } | 70 NotificationClient* client() const { return m_client; } |
| 72 | 71 |
| 73 int checkPermission(); | 72 int checkPermission(); |
| 74 void requestPermission(PassOwnPtr<VoidCallback> = nullptr); | 73 void requestPermission(PassOwnPtr<VoidCallback> = nullptr); |
| 75 | 74 |
| 76 virtual void stop() OVERRIDE; | 75 virtual void stop() OVERRIDE; |
| 77 | 76 |
| 78 void trace(Visitor*); | 77 void trace(Visitor*); |
| 79 | 78 |
| 80 private: | 79 private: |
| 81 NotificationCenter(ExecutionContext*, NotificationClient*); | 80 NotificationCenter(ExecutionContext*, NotificationClient*); |
| 82 | 81 |
| 83 class NotificationRequestCallback : public RefCountedWillBeGarbageCollectedF
inalized<NotificationRequestCallback> { | 82 class NotificationRequestCallback : public RefCountedWillBeGarbageCollectedF
inalized<NotificationRequestCallback> { |
| 84 DECLARE_GC_INFO; | |
| 85 public: | 83 public: |
| 86 static PassRefPtrWillBeRawPtr<NotificationRequestCallback> createAndStar
tTimer(NotificationCenter*, PassOwnPtr<VoidCallback>); | 84 static PassRefPtrWillBeRawPtr<NotificationRequestCallback> createAndStar
tTimer(NotificationCenter*, PassOwnPtr<VoidCallback>); |
| 87 void startTimer(); | 85 void startTimer(); |
| 88 void timerFired(Timer<NotificationRequestCallback>*); | 86 void timerFired(Timer<NotificationRequestCallback>*); |
| 89 | 87 |
| 90 void trace(Visitor*); | 88 void trace(Visitor*); |
| 91 | 89 |
| 92 private: | 90 private: |
| 93 NotificationRequestCallback(NotificationCenter*, PassOwnPtr<VoidCallback
>); | 91 NotificationRequestCallback(NotificationCenter*, PassOwnPtr<VoidCallback
>); |
| 94 | 92 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 106 // FIXME: oilpan: Move this to ThreadState.h. | 104 // FIXME: oilpan: Move this to ThreadState.h. |
| 107 template<> struct ThreadingTrait<NotificationCenter::NotificationRequestCallback
> { | 105 template<> struct ThreadingTrait<NotificationCenter::NotificationRequestCallback
> { |
| 108 static const ThreadAffinity Affinity = AnyThread; | 106 static const ThreadAffinity Affinity = AnyThread; |
| 109 }; | 107 }; |
| 110 | 108 |
| 111 } // namespace WebCore | 109 } // namespace WebCore |
| 112 | 110 |
| 113 #endif // ENABLE(LEGACY_NOTIFICATIONS) | 111 #endif // ENABLE(LEGACY_NOTIFICATIONS) |
| 114 | 112 |
| 115 #endif // NotificationCenter_h | 113 #endif // NotificationCenter_h |
| OLD | NEW |