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)
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.
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.
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
24 #include "JSNavigator.h"
26 #include "CallbackFunction.h"
27 #include "ExceptionCode.h"
28 #include "JSNavigatorUserMediaErrorCallback.h"
29 #include "JSNavigatorUserMediaSuccessCallback.h"
30 #include "Navigator.h"
36 #if ENABLE(MEDIA_STREAM)
37 JSValue JSNavigator::webkitGetUserMedia(ExecState* exec)
39 // Arguments: Options, successCallback, (optional)errorCallback
41 String options = ustringToString(exec->argument(0).toString(exec));
42 if (exec->hadException())
45 RefPtr<NavigatorUserMediaSuccessCallback> successCallback = createFunctionOnlyCallback<JSNavigatorUserMediaSuccessCallback>(exec, static_cast<JSDOMGlobalObject*>(exec->lexicalGlobalObject()), exec->argument(1));
46 if (exec->hadException())
49 RefPtr<NavigatorUserMediaErrorCallback> errorCallback = createFunctionOnlyCallback<JSNavigatorUserMediaErrorCallback>(exec, static_cast<JSDOMGlobalObject*>(exec->lexicalGlobalObject()), exec->argument(2), CallbackAllowUndefined);
50 if (exec->hadException())
54 m_impl->webkitGetUserMedia(options, successCallback.release(), errorCallback.release(), ec);
57 setDOMException(exec, ec);
61 #endif // ENABLE(MEDIA_STREAM)