| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008, 2009 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008, 2009 Apple 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 | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| 11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
| 12 * | 12 * |
| 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY | 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY |
| 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR | 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR |
| 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #include "config.h" | 26 #include "config.h" |
| 27 #include "core/loader/appcache/DOMApplicationCache.h" | 27 #include "core/loader/appcache/ApplicationCache.h" |
| 28 | 28 |
| 29 #include "bindings/v8/ExceptionMessages.h" | 29 #include "bindings/v8/ExceptionMessages.h" |
| 30 #include "bindings/v8/ExceptionState.h" | 30 #include "bindings/v8/ExceptionState.h" |
| 31 #include "core/dom/Document.h" | 31 #include "core/dom/Document.h" |
| 32 #include "core/dom/EventListener.h" | 32 #include "core/dom/EventListener.h" |
| 33 #include "core/dom/EventNames.h" | 33 #include "core/dom/EventNames.h" |
| 34 #include "core/dom/ExceptionCode.h" | 34 #include "core/dom/ExceptionCode.h" |
| 35 #include "core/loader/DocumentLoader.h" | 35 #include "core/loader/DocumentLoader.h" |
| 36 #include "core/loader/FrameLoader.h" | 36 #include "core/loader/FrameLoader.h" |
| 37 #include "core/loader/appcache/ApplicationCacheHost.h" | 37 #include "core/loader/appcache/ApplicationCacheHost.h" |
| 38 #include "core/page/Frame.h" | 38 #include "core/page/Frame.h" |
| 39 | 39 |
| 40 namespace WebCore { | 40 namespace WebCore { |
| 41 | 41 |
| 42 DOMApplicationCache::DOMApplicationCache(Frame* frame) | 42 ApplicationCache::ApplicationCache(Frame* frame) |
| 43 : DOMWindowProperty(frame) | 43 : DOMWindowProperty(frame) |
| 44 { | 44 { |
| 45 ScriptWrappable::init(this); | 45 ScriptWrappable::init(this); |
| 46 ApplicationCacheHost* cacheHost = applicationCacheHost(); | 46 ApplicationCacheHost* cacheHost = applicationCacheHost(); |
| 47 if (cacheHost) | 47 if (cacheHost) |
| 48 cacheHost->setDOMApplicationCache(this); | 48 cacheHost->setApplicationCache(this); |
| 49 } | 49 } |
| 50 | 50 |
| 51 void DOMApplicationCache::willDestroyGlobalObjectInFrame() | 51 void ApplicationCache::willDestroyGlobalObjectInFrame() |
| 52 { | 52 { |
| 53 if (ApplicationCacheHost* cacheHost = applicationCacheHost()) | 53 if (ApplicationCacheHost* cacheHost = applicationCacheHost()) |
| 54 cacheHost->setDOMApplicationCache(0); | 54 cacheHost->setApplicationCache(0); |
| 55 DOMWindowProperty::willDestroyGlobalObjectInFrame(); | 55 DOMWindowProperty::willDestroyGlobalObjectInFrame(); |
| 56 } | 56 } |
| 57 | 57 |
| 58 ApplicationCacheHost* DOMApplicationCache::applicationCacheHost() const | 58 ApplicationCacheHost* ApplicationCache::applicationCacheHost() const |
| 59 { | 59 { |
| 60 if (!m_frame || !m_frame->loader()->documentLoader()) | 60 if (!m_frame || !m_frame->loader()->documentLoader()) |
| 61 return 0; | 61 return 0; |
| 62 return m_frame->loader()->documentLoader()->applicationCacheHost(); | 62 return m_frame->loader()->documentLoader()->applicationCacheHost(); |
| 63 } | 63 } |
| 64 | 64 |
| 65 unsigned short DOMApplicationCache::status() const | 65 unsigned short ApplicationCache::status() const |
| 66 { | 66 { |
| 67 ApplicationCacheHost* cacheHost = applicationCacheHost(); | 67 ApplicationCacheHost* cacheHost = applicationCacheHost(); |
| 68 if (!cacheHost) | 68 if (!cacheHost) |
| 69 return ApplicationCacheHost::UNCACHED; | 69 return ApplicationCacheHost::UNCACHED; |
| 70 return cacheHost->status(); | 70 return cacheHost->status(); |
| 71 } | 71 } |
| 72 | 72 |
| 73 void DOMApplicationCache::update(ExceptionState& es) | 73 void ApplicationCache::update(ExceptionState& es) |
| 74 { | 74 { |
| 75 ApplicationCacheHost* cacheHost = applicationCacheHost(); | 75 ApplicationCacheHost* cacheHost = applicationCacheHost(); |
| 76 if (!cacheHost || !cacheHost->update()) | 76 if (!cacheHost || !cacheHost->update()) |
| 77 es.throwDOMException(InvalidStateError, ExceptionMessages::failedToExecu
te("update", "ApplicationCache", "there is no application cache to update.")); | 77 es.throwDOMException(InvalidStateError, ExceptionMessages::failedToExecu
te("update", "ApplicationCache", "there is no application cache to update.")); |
| 78 } | 78 } |
| 79 | 79 |
| 80 void DOMApplicationCache::swapCache(ExceptionState& es) | 80 void ApplicationCache::swapCache(ExceptionState& es) |
| 81 { | 81 { |
| 82 ApplicationCacheHost* cacheHost = applicationCacheHost(); | 82 ApplicationCacheHost* cacheHost = applicationCacheHost(); |
| 83 if (!cacheHost || !cacheHost->swapCache()) | 83 if (!cacheHost || !cacheHost->swapCache()) |
| 84 es.throwDOMException(InvalidStateError, ExceptionMessages::failedToExecu
te("swapCache", "ApplicationCache", "there is no newer application cache to swap
to.")); | 84 es.throwDOMException(InvalidStateError, ExceptionMessages::failedToExecu
te("swapCache", "ApplicationCache", "there is no newer application cache to swap
to.")); |
| 85 } | 85 } |
| 86 | 86 |
| 87 void DOMApplicationCache::abort() | 87 void ApplicationCache::abort() |
| 88 { | 88 { |
| 89 ApplicationCacheHost* cacheHost = applicationCacheHost(); | 89 ApplicationCacheHost* cacheHost = applicationCacheHost(); |
| 90 if (cacheHost) | 90 if (cacheHost) |
| 91 cacheHost->abort(); | 91 cacheHost->abort(); |
| 92 } | 92 } |
| 93 | 93 |
| 94 const AtomicString& DOMApplicationCache::interfaceName() const | 94 const AtomicString& ApplicationCache::interfaceName() const |
| 95 { | 95 { |
| 96 return eventNames().interfaceForDOMApplicationCache; | 96 return eventNames().interfaceForApplicationCache; |
| 97 } | 97 } |
| 98 | 98 |
| 99 ScriptExecutionContext* DOMApplicationCache::scriptExecutionContext() const | 99 ScriptExecutionContext* ApplicationCache::scriptExecutionContext() const |
| 100 { | 100 { |
| 101 if (m_frame) | 101 if (m_frame) |
| 102 return m_frame->document(); | 102 return m_frame->document(); |
| 103 return 0; | 103 return 0; |
| 104 } | 104 } |
| 105 | 105 |
| 106 const AtomicString& DOMApplicationCache::toEventType(ApplicationCacheHost::Event
ID id) | 106 const AtomicString& ApplicationCache::toEventType(ApplicationCacheHost::EventID
id) |
| 107 { | 107 { |
| 108 switch (id) { | 108 switch (id) { |
| 109 case ApplicationCacheHost::CHECKING_EVENT: | 109 case ApplicationCacheHost::CHECKING_EVENT: |
| 110 return eventNames().checkingEvent; | 110 return eventNames().checkingEvent; |
| 111 case ApplicationCacheHost::ERROR_EVENT: | 111 case ApplicationCacheHost::ERROR_EVENT: |
| 112 return eventNames().errorEvent; | 112 return eventNames().errorEvent; |
| 113 case ApplicationCacheHost::NOUPDATE_EVENT: | 113 case ApplicationCacheHost::NOUPDATE_EVENT: |
| 114 return eventNames().noupdateEvent; | 114 return eventNames().noupdateEvent; |
| 115 case ApplicationCacheHost::DOWNLOADING_EVENT: | 115 case ApplicationCacheHost::DOWNLOADING_EVENT: |
| 116 return eventNames().downloadingEvent; | 116 return eventNames().downloadingEvent; |
| 117 case ApplicationCacheHost::PROGRESS_EVENT: | 117 case ApplicationCacheHost::PROGRESS_EVENT: |
| 118 return eventNames().progressEvent; | 118 return eventNames().progressEvent; |
| 119 case ApplicationCacheHost::UPDATEREADY_EVENT: | 119 case ApplicationCacheHost::UPDATEREADY_EVENT: |
| 120 return eventNames().updatereadyEvent; | 120 return eventNames().updatereadyEvent; |
| 121 case ApplicationCacheHost::CACHED_EVENT: | 121 case ApplicationCacheHost::CACHED_EVENT: |
| 122 return eventNames().cachedEvent; | 122 return eventNames().cachedEvent; |
| 123 case ApplicationCacheHost::OBSOLETE_EVENT: | 123 case ApplicationCacheHost::OBSOLETE_EVENT: |
| 124 return eventNames().obsoleteEvent; | 124 return eventNames().obsoleteEvent; |
| 125 } | 125 } |
| 126 ASSERT_NOT_REACHED(); | 126 ASSERT_NOT_REACHED(); |
| 127 return eventNames().errorEvent; | 127 return eventNames().errorEvent; |
| 128 } | 128 } |
| 129 | 129 |
| 130 EventTargetData* DOMApplicationCache::eventTargetData() | 130 EventTargetData* ApplicationCache::eventTargetData() |
| 131 { | 131 { |
| 132 return &m_eventTargetData; | 132 return &m_eventTargetData; |
| 133 } | 133 } |
| 134 | 134 |
| 135 EventTargetData* DOMApplicationCache::ensureEventTargetData() | 135 EventTargetData* ApplicationCache::ensureEventTargetData() |
| 136 { | 136 { |
| 137 return &m_eventTargetData; | 137 return &m_eventTargetData; |
| 138 } | 138 } |
| 139 | 139 |
| 140 } // namespace WebCore | 140 } // namespace WebCore |
| OLD | NEW |