1 /*
2 * Copyright (C) 2000 Harri Porten (porten@kde.org)
3 * Copyright (c) 2000 Daniel Molkentin (molkentin@kde.org)
4 * Copyright (c) 2000 Stefan Schimanski (schimmi@kde.org)
5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All Rights Reserved.
6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23 #include "config.h"
24 #include "JSNavigator.h"
25
26 #include "ExceptionCode.h"
27 #include "Navigator.h"
28 #include <runtime/InternalFunction.h>
29
30 #if PLATFORM(ANDROID)
31 #include "JSCustomApplicationInstalledCallback.h"
32 #endif
33
34 namespace WebCore {
35
36 using namespace JSC;
37
markChildren(MarkStack & markStack)38 void JSNavigator::markChildren(MarkStack& markStack)
39 {
40 Base::markChildren(markStack);
41
42 JSGlobalData& globalData = *Heap::heap(this)->globalData();
43
44 markDOMObjectWrapper(markStack, globalData, impl()->optionalGeolocation());
45 }
46
47 #if PLATFORM(ANDROID) && ENABLE(APPLICATION_INSTALLED)
48
isApplicationInstalled(JSC::ExecState * exec,JSC::ArgList const & args)49 JSC::JSValue WebCore::JSNavigator::isApplicationInstalled(JSC::ExecState* exec, JSC::ArgList const& args)
50 {
51 if (args.size() < 2) {
52 setDOMException(exec, SYNTAX_ERR);
53 return jsUndefined();
54 }
55
56 if (!args.at(1).inherits(&InternalFunction::info)) {
57 setDOMException(exec, TYPE_MISMATCH_ERR);
58 return jsUndefined();
59 }
60
61 String appName = args.at(0).toString(exec);
62
63 JSObject* object;
64 if (!(object = args.at(1).getObject())) {
65 setDOMException(exec, TYPE_MISMATCH_ERR);
66 return jsUndefined();
67 }
68
69 RefPtr<ApplicationInstalledCallback> callback(JSCustomApplicationInstalledCallback::create(
70 object, static_cast<JSDOMGlobalObject*>(exec->dynamicGlobalObject())));
71
72 if (!m_impl->isApplicationInstalled(appName, callback.release()))
73 setDOMException(exec, INVALID_STATE_ERR);
74 return jsUndefined();
75 }
76
77 #endif
78
79 }
80