summaryrefslogtreecommitdiffstats
path: root/WebCore/bindings
diff options
context:
space:
mode:
authorAndroid (Google) Code Review <android-gerrit@google.com>2009-09-01 10:55:34 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2009-09-01 10:55:34 -0700
commitb5212d4b660006d4989f9483e5f0be74de67f609 (patch)
tree564535b8eaa1be5b8c4a7aec69c36a6f6013f7d3 /WebCore/bindings
parenta0fbdfc89332428c139d4d1ee62748d6d03c66c5 (diff)
parent1389fc4eef6f5f6ea906895e668bf9f92c1d4447 (diff)
downloadexternal_webkit-b5212d4b660006d4989f9483e5f0be74de67f609.zip
external_webkit-b5212d4b660006d4989f9483e5f0be74de67f609.tar.gz
external_webkit-b5212d4b660006d4989f9483e5f0be74de67f609.tar.bz2
Merge change 22913 into eclair
* changes: Adds V8 bindings for Geolocation.
Diffstat (limited to 'WebCore/bindings')
-rw-r--r--WebCore/bindings/v8/DerivedSourcesAllInOne.cpp1
-rw-r--r--WebCore/bindings/v8/custom/V8CustomBinding.h3
-rw-r--r--WebCore/bindings/v8/custom/V8CustomPositionCallback.cpp72
-rw-r--r--WebCore/bindings/v8/custom/V8CustomPositionCallback.h64
-rw-r--r--WebCore/bindings/v8/custom/V8CustomPositionErrorCallback.cpp72
-rw-r--r--WebCore/bindings/v8/custom/V8CustomPositionErrorCallback.h64
-rw-r--r--WebCore/bindings/v8/custom/V8GeolocationCustom.cpp203
7 files changed, 479 insertions, 0 deletions
diff --git a/WebCore/bindings/v8/DerivedSourcesAllInOne.cpp b/WebCore/bindings/v8/DerivedSourcesAllInOne.cpp
index e2d4fd1..e52a505 100644
--- a/WebCore/bindings/v8/DerivedSourcesAllInOne.cpp
+++ b/WebCore/bindings/v8/DerivedSourcesAllInOne.cpp
@@ -79,6 +79,7 @@
#include "bindings/V8File.cpp"
#include "bindings/V8FileList.cpp"
#include "bindings/V8History.cpp"
+#include "bindings/V8Geolocation.cpp"
#include "bindings/V8HTMLAllCollection.cpp"
#include "bindings/V8HTMLAnchorElement.cpp"
#include "bindings/V8HTMLAppletElement.cpp"
diff --git a/WebCore/bindings/v8/custom/V8CustomBinding.h b/WebCore/bindings/v8/custom/V8CustomBinding.h
index 80fed1d..60f0d82 100644
--- a/WebCore/bindings/v8/custom/V8CustomBinding.h
+++ b/WebCore/bindings/v8/custom/V8CustomBinding.h
@@ -521,6 +521,9 @@ namespace WebCore {
DECLARE_CALLBACK(SharedWorkerConstructor);
#endif
+ DECLARE_CALLBACK(GeolocationGetCurrentPosition);
+ DECLARE_CALLBACK(GeolocationWatchPosition);
+
#undef DECLARE_INDEXED_ACCESS_CHECK
#undef DECLARE_NAMED_ACCESS_CHECK
diff --git a/WebCore/bindings/v8/custom/V8CustomPositionCallback.cpp b/WebCore/bindings/v8/custom/V8CustomPositionCallback.cpp
new file mode 100644
index 0000000..4f2fe0e
--- /dev/null
+++ b/WebCore/bindings/v8/custom/V8CustomPositionCallback.cpp
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2009, Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "V8CustomPositionCallback.h"
+
+#include "Frame.h"
+#include "V8CustomVoidCallback.h" // For invokeCallback
+
+namespace WebCore {
+
+V8CustomPositionCallback::V8CustomPositionCallback(v8::Local<v8::Object> callback, Frame* frame)
+ : m_callback(v8::Persistent<v8::Object>::New(callback))
+ , m_frame(frame)
+{
+}
+
+V8CustomPositionCallback::~V8CustomPositionCallback()
+{
+ m_callback.Dispose();
+}
+
+void V8CustomPositionCallback::handleEvent(Geoposition* position)
+{
+ LOCK_V8;
+ v8::HandleScope handleScope;
+
+ v8::Handle<v8::Context> context = V8Proxy::context(m_frame.get());
+ if (context.IsEmpty())
+ return;
+
+ v8::Context::Scope scope(context);
+
+ v8::Handle<v8::Value> argv[] = {
+ V8DOMWrapper::convertToV8Object(V8ClassIndex::GEOPOSITION, position)
+ };
+
+ // Protect the frame until the callback returns.
+ RefPtr<Frame> protector(m_frame);
+
+ bool callbackReturnValue = false;
+ invokeCallback(m_callback, 1, argv, callbackReturnValue);
+}
+
+} // namespace WebCore
diff --git a/WebCore/bindings/v8/custom/V8CustomPositionCallback.h b/WebCore/bindings/v8/custom/V8CustomPositionCallback.h
new file mode 100644
index 0000000..06be83b
--- /dev/null
+++ b/WebCore/bindings/v8/custom/V8CustomPositionCallback.h
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef V8CustomPositionCallback_h
+#define V8CustomPositionCallback_h
+
+#include "PositionCallback.h"
+#include <v8.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefPtr.h>
+
+namespace WebCore {
+
+class Frame;
+class Geoposition;
+
+class V8CustomPositionCallback : public PositionCallback {
+public:
+ static PassRefPtr<V8CustomPositionCallback> create(v8::Local<v8::Value> value, Frame* frame)
+ {
+ ASSERT(value->IsObject());
+ return adoptRef(new V8CustomPositionCallback(value->ToObject(), frame));
+ }
+ virtual ~V8CustomPositionCallback();
+
+ virtual void handleEvent(Geoposition*);
+
+private:
+ V8CustomPositionCallback(v8::Local<v8::Object>, Frame*);
+
+ v8::Persistent<v8::Object> m_callback;
+ RefPtr<Frame> m_frame;
+};
+
+} // namespace WebCore
+
+#endif // V8CustomPositionCallback_h
diff --git a/WebCore/bindings/v8/custom/V8CustomPositionErrorCallback.cpp b/WebCore/bindings/v8/custom/V8CustomPositionErrorCallback.cpp
new file mode 100644
index 0000000..e446d85
--- /dev/null
+++ b/WebCore/bindings/v8/custom/V8CustomPositionErrorCallback.cpp
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2009, Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "V8CustomPositionErrorCallback.h"
+
+#include "Frame.h"
+#include "V8CustomVoidCallback.h" // For invokeCallback
+
+namespace WebCore {
+
+V8CustomPositionErrorCallback::V8CustomPositionErrorCallback(v8::Local<v8::Object> callback, Frame* frame)
+ : m_callback(v8::Persistent<v8::Object>::New(callback))
+ , m_frame(frame)
+{
+}
+
+V8CustomPositionErrorCallback::~V8CustomPositionErrorCallback()
+{
+ m_callback.Dispose();
+}
+
+void V8CustomPositionErrorCallback::handleEvent(PositionError* error)
+{
+ LOCK_V8;
+ v8::HandleScope handleScope;
+
+ v8::Handle<v8::Context> context = V8Proxy::context(m_frame.get());
+ if (context.IsEmpty())
+ return;
+
+ v8::Context::Scope scope(context);
+
+ v8::Handle<v8::Value> argv[] = {
+ V8DOMWrapper::convertToV8Object(V8ClassIndex::POSITIONERROR, error)
+ };
+
+ // Protect the frame until the callback returns.
+ RefPtr<Frame> protector(m_frame);
+
+ bool callbackReturnValue = false;
+ invokeCallback(m_callback, 1, argv, callbackReturnValue);
+}
+
+} // namespace WebCore
diff --git a/WebCore/bindings/v8/custom/V8CustomPositionErrorCallback.h b/WebCore/bindings/v8/custom/V8CustomPositionErrorCallback.h
new file mode 100644
index 0000000..703b7b2
--- /dev/null
+++ b/WebCore/bindings/v8/custom/V8CustomPositionErrorCallback.h
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef V8CustomPositionErrorCallback_h
+#define V8CustomPositionErrorCallback_h
+
+#include "PositionErrorCallback.h"
+#include <v8.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefPtr.h>
+
+namespace WebCore {
+
+class Frame;
+class PositionError;
+
+class V8CustomPositionErrorCallback : public PositionErrorCallback {
+public:
+ static PassRefPtr<V8CustomPositionErrorCallback> create(v8::Local<v8::Value> value, Frame* frame)
+ {
+ ASSERT(value->IsObject());
+ return adoptRef(new V8CustomPositionErrorCallback(value->ToObject(), frame));
+ }
+ virtual ~V8CustomPositionErrorCallback();
+
+ virtual void handleEvent(PositionError*);
+
+private:
+ V8CustomPositionErrorCallback(v8::Local<v8::Object>, Frame*);
+
+ v8::Persistent<v8::Object> m_callback;
+ RefPtr<Frame> m_frame;
+};
+
+} // namespace WebCore
+
+#endif // V8CustomPositionErrorCallback_h
diff --git a/WebCore/bindings/v8/custom/V8GeolocationCustom.cpp b/WebCore/bindings/v8/custom/V8GeolocationCustom.cpp
new file mode 100644
index 0000000..5373626
--- /dev/null
+++ b/WebCore/bindings/v8/custom/V8GeolocationCustom.cpp
@@ -0,0 +1,203 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#include "Geolocation.h"
+#include "V8Binding.h"
+#include "V8CustomBinding.h"
+#include "V8CustomPositionCallback.h"
+#include "V8CustomPositionErrorCallback.h"
+#include "V8Proxy.h"
+
+
+using namespace WTF;
+
+namespace WebCore {
+
+static const char* typeMismatchError = "TYPE_MISMATCH_ERR: DOM Exception 17";
+
+static void throwTypeMismatchException()
+{
+ V8Proxy::throwError(V8Proxy::GeneralError, typeMismatchError);
+}
+
+static PassRefPtr<PositionCallback> createPositionCallback(v8::Local<v8::Value> value, bool& succeeded)
+{
+ succeeded = true;
+
+ // The spec specifies 'FunctionOnly' for this object.
+ if (!value->IsFunction()) {
+ succeeded = false;
+ throwTypeMismatchException();
+ return 0;
+ }
+
+ Frame* frame = V8Proxy::retrieveFrameForCurrentContext();
+ return V8CustomPositionCallback::create(value, frame);
+}
+
+static PassRefPtr<PositionErrorCallback> createPositionErrorCallback(v8::Local<v8::Value> value, bool& succeeded)
+{
+ succeeded = true;
+
+ // Argument is optional (hence undefined is allowed), and null is allowed.
+ if (isUndefinedOrNull(value))
+ return 0;
+
+ // The spec specifies 'FunctionOnly' for this object.
+ if (!value->IsFunction()) {
+ succeeded = false;
+ throwTypeMismatchException();
+ return 0;
+ }
+
+ Frame* frame = V8Proxy::retrieveFrameForCurrentContext();
+ return V8CustomPositionErrorCallback::create(value, frame);
+}
+
+static PassRefPtr<PositionOptions> createPositionOptions(v8::Local<v8::Value> value, bool& succeeded)
+{
+ succeeded = true;
+
+ // Create default options.
+ RefPtr<PositionOptions> options = PositionOptions::create();
+
+ // Argument is optional (hence undefined is allowed), and null is allowed.
+ if (isUndefinedOrNull(value)) {
+ // Use default options.
+ return options.release();
+ }
+
+ // Given the above test, this will always yield an object.
+ v8::Local<v8::Object> object = value->ToObject();
+
+ // For all three properties, we apply the following ...
+ // - If the getter or the property's valueOf method throws an exception, we
+ // quit so as not to risk overwriting the exception.
+ // - If the value is absent or undefined, we don't override the default.
+ v8::Local<v8::Value> enableHighAccuracyValue = object->Get(v8::String::New("enableHighAccuracy"));
+ if (enableHighAccuracyValue.IsEmpty()) {
+ succeeded = false;
+ return 0;
+ }
+ if (!enableHighAccuracyValue->IsUndefined()) {
+ v8::Local<v8::Boolean> enableHighAccuracyBoolean = enableHighAccuracyValue->ToBoolean();
+ if (enableHighAccuracyBoolean.IsEmpty()) {
+ succeeded = false;
+ return 0;
+ }
+ options->setEnableHighAccuracy(enableHighAccuracyBoolean->Value());
+ }
+
+ v8::Local<v8::Value> timeoutValue = object->Get(v8::String::New("timeout"));
+ if (timeoutValue.IsEmpty()) {
+ succeeded = false;
+ return 0;
+ }
+ if (!timeoutValue->IsUndefined()) {
+ v8::Local<v8::Int32> timeoutInt32 = timeoutValue->ToInt32();
+ if (timeoutInt32.IsEmpty()) {
+ succeeded = false;
+ return 0;
+ }
+ // Wrap to int32 and force non-negative to match behavior of window.setTimeout.
+ options->setTimeout(max(0, timeoutInt32->Value()));
+ }
+
+ v8::Local<v8::Value> maximumAgeValue = object->Get(v8::String::New("maximumAge"));
+ if (maximumAgeValue.IsEmpty()) {
+ succeeded = false;
+ return 0;
+ }
+ if (!maximumAgeValue->IsUndefined()) {
+ v8::Local<v8::Int32> maximumAgeInt32 = maximumAgeValue->ToInt32();
+ if (maximumAgeInt32.IsEmpty()) {
+ succeeded = false;
+ return 0;
+ }
+ // Wrap to int32 and force non-negative to match behavior of window.setTimeout.
+ options->setMaximumAge(max(0, maximumAgeInt32->Value()));
+ }
+
+ return options.release();
+}
+
+CALLBACK_FUNC_DECL(GeolocationGetCurrentPosition)
+{
+ INC_STATS("DOM.Geolocation.getCurrentPosition()");
+
+ bool succeeded = false;
+
+ RefPtr<PositionCallback> positionCallback = createPositionCallback(args[0], succeeded);
+ if (!succeeded)
+ return v8::Undefined();
+ ASSERT(positionCallback);
+
+ RefPtr<PositionErrorCallback> positionErrorCallback = createPositionErrorCallback(args[1], succeeded);
+ if (!succeeded)
+ return v8::Undefined();
+
+ RefPtr<PositionOptions> positionOptions = createPositionOptions(args[2], succeeded);
+ if (!succeeded)
+ return v8::Undefined();
+ ASSERT(positionOptions);
+
+ Geolocation* geolocation = V8DOMWrapper::convertToNativeObject<Geolocation>(V8ClassIndex::GEOLOCATION, args.Holder());
+ geolocation->getCurrentPosition(positionCallback.release(), positionErrorCallback.release(), positionOptions.release());
+ return v8::Undefined();
+}
+
+CALLBACK_FUNC_DECL(GeolocationWatchPosition)
+{
+ INC_STATS("DOM.Geolocation.watchPosition()");
+
+ bool succeeded = false;
+
+ RefPtr<PositionCallback> positionCallback = createPositionCallback(args[0], succeeded);
+ if (!succeeded)
+ return v8::Undefined();
+ ASSERT(positionCallback);
+
+ RefPtr<PositionErrorCallback> positionErrorCallback = createPositionErrorCallback(args[1], succeeded);
+ if (!succeeded)
+ return v8::Undefined();
+
+ RefPtr<PositionOptions> positionOptions = createPositionOptions(args[2], succeeded);
+ if (!succeeded)
+ return v8::Undefined();
+ ASSERT(positionOptions);
+
+ Geolocation* geolocation = V8DOMWrapper::convertToNativeObject<Geolocation>(V8ClassIndex::GEOLOCATION, args.Holder());
+ int watchId = geolocation->watchPosition(positionCallback.release(), positionErrorCallback.release(), positionOptions.release());
+ return v8::Number::New(watchId);
+}
+
+} // namespace WebCore