1595f429f16d56891f697a15c3ec2fd2ec9647c5fAndrei Popescu/* 20bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5Ben Murdoch * Copyright (C) 2009 Google Inc. All rights reserved. 3595f429f16d56891f697a15c3ec2fd2ec9647c5fAndrei Popescu * 4595f429f16d56891f697a15c3ec2fd2ec9647c5fAndrei Popescu * Redistribution and use in source and binary forms, with or without 5595f429f16d56891f697a15c3ec2fd2ec9647c5fAndrei Popescu * modification, are permitted provided that the following conditions are 6595f429f16d56891f697a15c3ec2fd2ec9647c5fAndrei Popescu * met: 7595f429f16d56891f697a15c3ec2fd2ec9647c5fAndrei Popescu * 8595f429f16d56891f697a15c3ec2fd2ec9647c5fAndrei Popescu * * Redistributions of source code must retain the above copyright 9595f429f16d56891f697a15c3ec2fd2ec9647c5fAndrei Popescu * notice, this list of conditions and the following disclaimer. 10595f429f16d56891f697a15c3ec2fd2ec9647c5fAndrei Popescu * * Redistributions in binary form must reproduce the above 11595f429f16d56891f697a15c3ec2fd2ec9647c5fAndrei Popescu * copyright notice, this list of conditions and the following disclaimer 12595f429f16d56891f697a15c3ec2fd2ec9647c5fAndrei Popescu * in the documentation and/or other materials provided with the 13595f429f16d56891f697a15c3ec2fd2ec9647c5fAndrei Popescu * distribution. 14595f429f16d56891f697a15c3ec2fd2ec9647c5fAndrei Popescu * * Neither the name of Google Inc. nor the names of its 15595f429f16d56891f697a15c3ec2fd2ec9647c5fAndrei Popescu * contributors may be used to endorse or promote products derived from 16595f429f16d56891f697a15c3ec2fd2ec9647c5fAndrei Popescu * this software without specific prior written permission. 17595f429f16d56891f697a15c3ec2fd2ec9647c5fAndrei Popescu * 18595f429f16d56891f697a15c3ec2fd2ec9647c5fAndrei Popescu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19595f429f16d56891f697a15c3ec2fd2ec9647c5fAndrei Popescu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20595f429f16d56891f697a15c3ec2fd2ec9647c5fAndrei Popescu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21595f429f16d56891f697a15c3ec2fd2ec9647c5fAndrei Popescu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22595f429f16d56891f697a15c3ec2fd2ec9647c5fAndrei Popescu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23595f429f16d56891f697a15c3ec2fd2ec9647c5fAndrei Popescu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24595f429f16d56891f697a15c3ec2fd2ec9647c5fAndrei Popescu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25595f429f16d56891f697a15c3ec2fd2ec9647c5fAndrei Popescu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26595f429f16d56891f697a15c3ec2fd2ec9647c5fAndrei Popescu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27595f429f16d56891f697a15c3ec2fd2ec9647c5fAndrei Popescu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28595f429f16d56891f697a15c3ec2fd2ec9647c5fAndrei Popescu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29595f429f16d56891f697a15c3ec2fd2ec9647c5fAndrei Popescu */ 30595f429f16d56891f697a15c3ec2fd2ec9647c5fAndrei Popescu 31595f429f16d56891f697a15c3ec2fd2ec9647c5fAndrei Popescu#include "config.h" 32d0825bca7fe65beaee391d30da42e937db621564Steve Block#include "V8DOMApplicationCache.h" 33595f429f16d56891f697a15c3ec2fd2ec9647c5fAndrei Popescu 34595f429f16d56891f697a15c3ec2fd2ec9647c5fAndrei Popescu#if ENABLE(OFFLINE_WEB_APPLICATIONS) 35595f429f16d56891f697a15c3ec2fd2ec9647c5fAndrei Popescu 360bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5Ben Murdoch#include "ApplicationCacheHost.h" 37d0825bca7fe65beaee391d30da42e937db621564Steve Block#include "DOMApplicationCache.h" 38595f429f16d56891f697a15c3ec2fd2ec9647c5fAndrei Popescu#include "V8Binding.h" 390bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5Ben Murdoch#include "V8Document.h" 40595f429f16d56891f697a15c3ec2fd2ec9647c5fAndrei Popescu#include "V8Proxy.h" 41595f429f16d56891f697a15c3ec2fd2ec9647c5fAndrei Popescu#include "V8Utilities.h" 42595f429f16d56891f697a15c3ec2fd2ec9647c5fAndrei Popescu#include "WorkerContextExecutionProxy.h" 43595f429f16d56891f697a15c3ec2fd2ec9647c5fAndrei Popescu 44595f429f16d56891f697a15c3ec2fd2ec9647c5fAndrei Popescunamespace WebCore { 45595f429f16d56891f697a15c3ec2fd2ec9647c5fAndrei Popescu 46595f429f16d56891f697a15c3ec2fd2ec9647c5fAndrei Popescu// Handles appcache.addEventListner(name, func, capture) method calls 47d0825bca7fe65beaee391d30da42e937db621564Steve Blockv8::Handle<v8::Value> V8DOMApplicationCache::addEventListenerCallback(const v8::Arguments& args) 48595f429f16d56891f697a15c3ec2fd2ec9647c5fAndrei Popescu{ 49595f429f16d56891f697a15c3ec2fd2ec9647c5fAndrei Popescu INC_STATS("DOMApplicationCache.addEventListener()"); 50d0825bca7fe65beaee391d30da42e937db621564Steve Block DOMApplicationCache* appcache = V8DOMApplicationCache::toNative(args.Holder()); 51595f429f16d56891f697a15c3ec2fd2ec9647c5fAndrei Popescu 52231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block RefPtr<EventListener> listener = V8DOMWrapper::getEventListener(appcache, args[1], false, ListenerFindOrCreate); 53595f429f16d56891f697a15c3ec2fd2ec9647c5fAndrei Popescu if (listener) { 54d0825bca7fe65beaee391d30da42e937db621564Steve Block createHiddenDependency(args.Holder(), args[1], cacheIndex); 55595f429f16d56891f697a15c3ec2fd2ec9647c5fAndrei Popescu String eventType = toWebCoreString(args[0]); 56595f429f16d56891f697a15c3ec2fd2ec9647c5fAndrei Popescu bool useCapture = args[2]->BooleanValue(); 57595f429f16d56891f697a15c3ec2fd2ec9647c5fAndrei Popescu appcache->addEventListener(eventType, listener, useCapture); 58595f429f16d56891f697a15c3ec2fd2ec9647c5fAndrei Popescu } 59595f429f16d56891f697a15c3ec2fd2ec9647c5fAndrei Popescu return v8::Undefined(); 60595f429f16d56891f697a15c3ec2fd2ec9647c5fAndrei Popescu} 61595f429f16d56891f697a15c3ec2fd2ec9647c5fAndrei Popescu 62595f429f16d56891f697a15c3ec2fd2ec9647c5fAndrei Popescu// Handles appcache.removeEventListner(name, func, capture) method calls 63d0825bca7fe65beaee391d30da42e937db621564Steve Blockv8::Handle<v8::Value> V8DOMApplicationCache::removeEventListenerCallback(const v8::Arguments& args) 64595f429f16d56891f697a15c3ec2fd2ec9647c5fAndrei Popescu{ 65595f429f16d56891f697a15c3ec2fd2ec9647c5fAndrei Popescu INC_STATS("DOMApplicationCache.removeEventListener()"); 66d0825bca7fe65beaee391d30da42e937db621564Steve Block DOMApplicationCache* appcache = V8DOMApplicationCache::toNative(args.Holder()); 67595f429f16d56891f697a15c3ec2fd2ec9647c5fAndrei Popescu 68231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block RefPtr<EventListener> listener = V8DOMWrapper::getEventListener(appcache, args[1], false, ListenerFindOnly); 69595f429f16d56891f697a15c3ec2fd2ec9647c5fAndrei Popescu if (listener) { 70d0825bca7fe65beaee391d30da42e937db621564Steve Block removeHiddenDependency(args.Holder(), args[1], cacheIndex); 71595f429f16d56891f697a15c3ec2fd2ec9647c5fAndrei Popescu String eventType = toWebCoreString(args[0]); 72595f429f16d56891f697a15c3ec2fd2ec9647c5fAndrei Popescu bool useCapture = args[2]->BooleanValue(); 73595f429f16d56891f697a15c3ec2fd2ec9647c5fAndrei Popescu appcache->removeEventListener(eventType, listener.get(), useCapture); 74595f429f16d56891f697a15c3ec2fd2ec9647c5fAndrei Popescu } 75595f429f16d56891f697a15c3ec2fd2ec9647c5fAndrei Popescu return v8::Undefined(); 76595f429f16d56891f697a15c3ec2fd2ec9647c5fAndrei Popescu} 77595f429f16d56891f697a15c3ec2fd2ec9647c5fAndrei Popescu 78595f429f16d56891f697a15c3ec2fd2ec9647c5fAndrei Popescu} // namespace WebCore 79595f429f16d56891f697a15c3ec2fd2ec9647c5fAndrei Popescu 80595f429f16d56891f697a15c3ec2fd2ec9647c5fAndrei Popescu#endif // ENABLE(OFFLINE_WEB_APPLICATIONS) 81