void V8Geolocation::watchPositionMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info) { bool succeeded = false; ExceptionState exceptionState(ExceptionState::ExecutionContext, "watchCurrentPosition", "Geolocation", info.Holder(), info.GetIsolate()); OwnPtr<PositionCallback> positionCallback = createFunctionOnlyCallback<V8PositionCallback>(info[0], 1, succeeded, info.GetIsolate(), exceptionState); if (!succeeded) return; ASSERT(positionCallback); // Argument is optional (hence undefined is allowed), and null is allowed. OwnPtr<PositionErrorCallback> positionErrorCallback = createFunctionOnlyCallback<V8PositionErrorCallback>(info[1], 2, succeeded, info.GetIsolate(), exceptionState, CallbackAllowUndefined | CallbackAllowNull); if (!succeeded) return; RefPtrWillBeRawPtr<PositionOptions> positionOptions = createPositionOptions(info[2], info.GetIsolate(), succeeded); if (!succeeded) return; ASSERT(positionOptions); Geolocation* geolocation = V8Geolocation::toNative(info.Holder()); int watchId = geolocation->watchPosition(positionCallback.release(), positionErrorCallback.release(), positionOptions.release()); v8SetReturnValue(info, watchId); }
static v8::Handle<v8::Value> clearWatchCallback(const v8::Arguments& args) { INC_STATS("DOM.Geolocation.clearWatch"); Geolocation* imp = V8Geolocation::toNative(args.Holder()); EXCEPTION_BLOCK(int, watchId, toInt32(args[0])); imp->clearWatch(watchId); return v8::Handle<v8::Value>(); }
void GeolocationPermissionRequestManager::didReceiveGeolocationPermissionDecision(uint64_t geolocationID, bool allowed) { IDToGeolocationMap::iterator it = m_idToGeolocationMap.find(geolocationID); if (it == m_idToGeolocationMap.end()) return; Geolocation* geolocation = it->value; geolocation->setIsAllowed(allowed); m_idToGeolocationMap.remove(it); m_geolocationToIDMap.remove(geolocation); }
EncodedJSValue JSC_HOST_CALL jsGeolocationPrototypeFunctionClearWatch(ExecState* exec) { JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSGeolocation::s_info)) return throwVMTypeError(exec); JSGeolocation* castedThis = static_cast<JSGeolocation*>(asObject(thisValue)); Geolocation* imp = static_cast<Geolocation*>(castedThis->impl()); int watchId = exec->argument(0).toInt32(exec); imp->clearWatch(watchId); return JSValue::encode(jsUndefined()); }
void GeolocationPermissionClientQt::setPermission(QWebFrame* webFrame, QWebPage::PermissionPolicy permission) { if (!m_pendingPermissionRequests.contains(webFrame)) return; Geolocation* listener = m_pendingPermissionRequests.value(webFrame); if (permission == QWebPage::PermissionGrantedByUser) listener->setIsAllowed(true); else if (permission == QWebPage::PermissionDeniedByUser) listener->setIsAllowed(false); else return; m_pendingPermissionRequests.remove(webFrame); }
void GeolocationPermissions::maybeCallbackFrames(String origin, bool allow) { // We can't track which frame issued the request, as frames can be deleted // or have their contents replaced. Even uniqueChildName is not unique when // frames are dynamically deleted and created. Instead, we simply call back // to the Geolocation object in all frames from the correct origin. for (Frame* frame = m_mainFrame; frame; frame = frame->tree()->traverseNext()) { if (origin == frame->document()->securityOrigin()->toString()) { // If the page has changed, it may no longer have a Geolocation // object. Geolocation* geolocation = frame->domWindow()->navigator()->optionalGeolocation(); if (geolocation) geolocation->setIsAllowed(allow); } } }
v8::Handle<v8::Value> V8Geolocation::watchPositionCallback(const v8::Arguments& args) { 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); }
v8::Handle<v8::Value> V8Geolocation::getCurrentPositionCallback(const v8::Arguments& args) { 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 = V8Geolocation::toNative(args.Holder()); geolocation->getCurrentPosition(positionCallback.release(), positionErrorCallback.release(), positionOptions.release()); return v8::Undefined(); }
Geolocation* Geolocation::create(ExecutionContext* context) { Geolocation* geolocation = new Geolocation(context); geolocation->suspendIfNeeded(); return geolocation; }
void GeolocationControllerClientBlackBerry::onPermission(void* context, bool isAllowed) { Geolocation* position = static_cast<Geolocation*>(context); position->setIsAllowed(isAllowed); }