void DeviceMotionController::didRemoveEventListener(DOMWindow*, const AtomicString& eventType) { if (eventType == eventNames().devicemotionEvent) { stopUpdating(); m_hasEventListener = false; } }
void Geolocation::makeSuccessCallbacks() { ASSERT(lastPosition()); ASSERT(isAllowed()); GeoNotifierVector oneShotsCopy; copyToVector(m_oneShots, oneShotsCopy); GeoNotifierVector watchersCopy; m_watchers.getNotifiersVector(watchersCopy); // Clear the lists before we make the callbacks, to avoid clearing notifiers // added by calls to Geolocation methods from the callbacks, and to prevent // further callbacks to these notifiers. m_oneShots.clear(); // Also clear the set of notifiers waiting for a cached position. All the // oneshots and watchers will receive a position now, and if they happen to // be lingering in that set, avoid this bug: http://crbug.com/311876 . m_requestsAwaitingCachedPosition.clear(); sendPosition(oneShotsCopy, lastPosition()); sendPosition(watchersCopy, lastPosition()); if (!hasListeners()) stopUpdating(); }
void Geolocation::clearWatch(int watchId) { m_watchers.remove(watchId); if (!hasListeners()) stopUpdating(); }
void Geolocation::handleError(PositionError& error) { auto oneShotsCopy = copyToVector(m_oneShots); GeoNotifierVector watchersCopy; m_watchers.getNotifiersVector(watchersCopy); // Clear the lists before we make the callbacks, to avoid clearing notifiers // added by calls to Geolocation methods from the callbacks, and to prevent // further callbacks to these notifiers. GeoNotifierVector oneShotsWithCachedPosition; m_oneShots.clear(); if (error.isFatal()) m_watchers.clear(); else { // Don't send non-fatal errors to notifiers due to receive a cached position. extractNotifiersWithCachedPosition(oneShotsCopy, &oneShotsWithCachedPosition); extractNotifiersWithCachedPosition(watchersCopy, 0); } sendError(oneShotsCopy, error); sendError(watchersCopy, error); // hasListeners() doesn't distinguish between notifiers due to receive a // cached position and those requiring a fresh position. Perform the check // before restoring the notifiers below. if (!hasListeners()) stopUpdating(); // Maintain a reference to the cached notifiers until their timer fires. copyToSet(oneShotsWithCachedPosition, m_oneShots); }
void Geolocation::makeCachedPositionCallbacks() { // All modifications to m_requestsAwaitingCachedPosition are done // asynchronously, so we don't need to worry about it being modified from // the callbacks. for (auto& notifier : m_requestsAwaitingCachedPosition) { // FIXME: This seems wrong, since makeCachedPositionCallbacks() is called in a branch where // lastPosition() is known to be null in Geolocation::setIsAllowed(). notifier->runSuccessCallback(lastPosition()); // If this is a one-shot request, stop it. Otherwise, if the watch still // exists, start the service to get updates. if (!m_oneShots.remove(notifier.get()) && m_watchers.contains(notifier.get())) { if (notifier->hasZeroTimeout() || startUpdating(notifier.get())) notifier->startTimerIfNeeded(); else notifier->setFatalError(PositionError::create(PositionError::POSITION_UNAVAILABLE, failedToStartServiceErrorMessage)); } } m_requestsAwaitingCachedPosition.clear(); if (!hasListeners()) stopUpdating(); }
QDroneDesktop::QDroneDesktop() { setupUi(this); _dctrl = new DeviceController(); _pDashboard = new QDroneDashboard(_dctrl, this->wCtrlContainer); _pDriveCtrl = new QDriveControl(_dctrl, this->wCtrlContainer); _pAnimCtrl = new QAnimationControl(_dctrl, this->wCtrlContainer); this->wCtrlContainer->layout()->addWidget(_pDashboard); this->wCtrlContainer->layout()->addWidget(_pDriveCtrl); this->wCtrlContainer->layout()->addWidget(_pAnimCtrl); QGridLayout* videoLayout = new QGridLayout(); videoLayout->setContentsMargins(0, 0, 0, 0); videoLayout->setObjectName(QString::fromUtf8("videoLayout")); wVideoContainer->setLayout(videoLayout); connect(actionConnect, SIGNAL(triggered()), this, SLOT(connectDrone())); connect(actionDisonnect, SIGNAL(triggered()), this, SLOT(disconnectDrone())); connect(actionStart_Video, SIGNAL(triggered()), this, SLOT(startVideo())); connect(actionStop_Video, SIGNAL(triggered()), this, SLOT(stopVideo())); connect(actionStart_Updating, SIGNAL(triggered()), _pDashboard, SLOT(startUpdating())); connect(actionStop_Updating, SIGNAL(triggered()), _pDashboard, SLOT(stopUpdating())); }
void ScreenOrientationController::notifyDispatcher() { if (m_orientation && page()->visibilityState() == PageVisibilityStateVisible) startUpdating(); else stopUpdating(); }
void Geolocation::makeCachedPositionCallbacks() { // All modifications to m_requestsAwaitingCachedPosition are done // asynchronously, so we don't need to worry about it being modified from // the callbacks. GeoNotifierSet::const_iterator end = m_requestsAwaitingCachedPosition.end(); for (GeoNotifierSet::const_iterator iter = m_requestsAwaitingCachedPosition.begin(); iter != end; ++iter) { GeoNotifier* notifier = iter->get(); notifier->runSuccessCallback(lastPosition()); // If this is a one-shot request, stop it. Otherwise, if the watch still // exists, start the service to get updates. if (m_oneShots.contains(notifier)) m_oneShots.remove(notifier); else if (m_watchers.contains(notifier)) { if (notifier->hasZeroTimeout() || startUpdating(notifier)) notifier->startTimerIfNeeded(); else notifier->setFatalError(PositionError::create(PositionError::POSITION_UNAVAILABLE, failedToStartServiceErrorMessage)); } } m_requestsAwaitingCachedPosition.clear(); if (!hasListeners()) stopUpdating(); }
void ScreenOrientationController::notifyDispatcher() { if (m_orientation && page()->isPageVisible()) startUpdating(); else stopUpdating(); }
void Geolocation::resetAllGeolocationPermission() { if (m_isSuspended) { m_resetOnResume = true; return; } if (m_allowGeolocation == InProgress) { Page* page = this->page(); if (page) GeolocationController::from(page)->cancelPermissionRequest(*this); // This return is not technically correct as GeolocationController::cancelPermissionRequest() should have cleared the active request. // Neither iOS nor OS X supports cancelPermissionRequest() (https://bugs.webkit.org/show_bug.cgi?id=89524), so we workaround that and let ongoing requests complete. :( return; } // 1) Reset our own state. stopUpdating(); m_allowGeolocation = Unknown; m_hasChangedPosition = false; m_errorWaitingForResume = nullptr; // 2) Request new permission for the active notifiers. stopTimers(); // Go over the one shot and re-request permission. for (auto& notifier : m_oneShots) startRequest(notifier.get()); // Go over the watchers and re-request permission. GeoNotifierVector watcherCopy; m_watchers.getNotifiersVector(watcherCopy); for (auto& watcher : watcherCopy) startRequest(watcher.get()); }
void Geolocation::requestTimedOut(GeoNotifier* notifier) { // If this is a one-shot request, stop it. m_oneShots.remove(notifier); if (!hasListeners()) stopUpdating(); }
void DeviceOrientationController::didRemoveEventListener(DOMWindow* window, const AtomicString& eventType) { if (eventType == EventTypeNames::deviceorientation) { stopUpdating(); m_hasEventListener = false; } }
void DeviceSingleWindowEventController::didRemoveEventListener(LocalDOMWindow* window, const AtomicString& eventType) { if (eventType != eventTypeName() || window->hasEventListeners(eventTypeName())) return; stopUpdating(); m_hasEventListener = false; }
void Geolocation::fatalErrorOccurred(GeoNotifier* notifier) { // This request has failed fatally. Remove it from our lists. m_oneShots.remove(notifier); m_watchers.remove(notifier); if (!hasListeners()) stopUpdating(); }
void PlatformEventController::pageVisibilityChanged() { if (!m_hasEventListener) return; if (page()->isPageVisible()) startUpdating(); else stopUpdating(); }
void Geolocation::disconnectFrame() { if (m_frame && m_frame->page() && m_allowGeolocation == InProgress) m_frame->page()->chrome()->cancelGeolocationPermissionRequestForFrame(m_frame, this); stopTimers(); stopUpdating(); if (m_frame && m_frame->document()) m_frame->document()->setUsingGeolocation(false); m_frame = 0; }
void Geolocation::contextDestroyed() { m_permissionService.reset(); cancelAllRequests(); stopUpdating(); m_geolocationPermission = PermissionDenied; m_pendingForPermissionNotifiers.clear(); m_lastPosition = nullptr; ContextLifecycleObserver::clearContext(); PageVisibilityObserver::clearContext(); }
void DeviceEventControllerBase::pageVisibilityChanged() { if (!m_hasEventListener) return; if (page()->visibilityState() == PageVisibilityStateVisible) startUpdating(); else stopUpdating(); }
void Geolocation::stop() { Page* page = this->page(); if (page && m_allowGeolocation == InProgress) GeolocationController::from(page)->cancelPermissionRequest(this); // The frame may be moving to a new page and we want to get the permissions from the new page's client. m_allowGeolocation = Unknown; cancelAllRequests(); stopUpdating(); m_pendingForPermissionNotifiers.clear(); }
void Geolocation::clearWatch(int watchID) { if (watchID <= 0) return; if (GeoNotifier* notifier = m_watchers.find(watchID)) m_pendingForPermissionNotifiers.remove(notifier); m_watchers.remove(watchID); if (!hasListeners()) stopUpdating(); }
void Geolocation::stop() { LocalFrame* frame = this->frame(); if (frame && m_geolocationPermission == PermissionRequested) GeolocationController::from(frame)->cancelPermissionRequest(this); // The frame may be moving to a new page and we want to get the permissions from the new page's client. m_geolocationPermission = PermissionUnknown; cancelAllRequests(); stopUpdating(); m_pendingForPermissionNotifiers.clear(); }
void Geolocation::clearWatch(int watchId) { if (watchId < firstAvailableWatchId) return; #if USE(PREEMPT_GEOLOCATION_PERMISSION) if (GeoNotifier* notifier = m_watchers.find(watchId)) m_pendingForPermissionNotifiers.remove(notifier); #endif m_watchers.remove(watchId); if (!hasListeners()) stopUpdating(); }
void DeviceSingleWindowEventController::dispatchDeviceEvent(RawPtr<Event> prpEvent) { if (!document().domWindow() || document().activeDOMObjectsAreSuspended() || document().activeDOMObjectsAreStopped()) return; RawPtr<Event> event = prpEvent; document().domWindow()->dispatchEvent(event); if (m_needsCheckingNullEvents) { if (isNullEvent(event.get())) stopUpdating(); else m_needsCheckingNullEvents = false; } }
void GeolocationClient::setEnableHighAccuracy(bool enable) { m_enableHighAccuracy = enable; // If we're already updating we should report the new requirements in order // to change to a more suitable provider if needed. If not, return. if (!m_isUpdating) return; GOwnPtr<GError> error; GeoclueAccuracyLevel accuracyLevel = m_enableHighAccuracy ? GEOCLUE_ACCURACY_LEVEL_DETAILED : GEOCLUE_ACCURACY_LEVEL_LOCALITY; if (!geoclue_master_client_set_requirements(m_geoclueClient.get(), accuracyLevel, 0, false, GEOCLUE_RESOURCE_ALL, &error.outPtr())) { errorOccured(error->message); stopUpdating(); } }
void DeviceSensorEventController::dispatchDeviceEvent(PassRefPtrWillBeRawPtr<Event> prpEvent) { Document* targetDocument = document(); if (!targetDocument || !targetDocument->domWindow() || targetDocument->activeDOMObjectsAreSuspended() || targetDocument->activeDOMObjectsAreStopped()) return; RefPtrWillBeRawPtr<Event> event = prpEvent; targetDocument->domWindow()->dispatchEvent(event); if (m_needsCheckingNullEvents) { if (isNullEvent(event.get())) stopUpdating(); else m_needsCheckingNullEvents = false; } }
void Geolocation::requestUsesCachedPosition(GeoNotifier* notifier) { DCHECK(isAllowed()); notifier->runSuccessCallback(m_lastPosition); // If this is a one-shot request, stop it. Otherwise, if the watch still // exists, start the service to get updates. if (m_oneShots.contains(notifier)) { m_oneShots.remove(notifier); } else if (m_watchers.contains(notifier)) { if (notifier->options().timeout()) startUpdating(notifier); notifier->startTimer(); } if (!hasListeners()) stopUpdating(); }
void Geolocation::reset() { Page* page = this->page(); if (page && m_allowGeolocation == InProgress) { #if ENABLE(CLIENT_BASED_GEOLOCATION) page->geolocationController()->cancelPermissionRequest(this); #else page->chrome()->client()->cancelGeolocationPermissionRequestForFrame(m_frame, this); #endif } // The frame may be moving to a new page and we want to get the permissions from the new page's client. m_allowGeolocation = Unknown; cancelAllRequests(); stopUpdating(); #if USE(PREEMPT_GEOLOCATION_PERMISSION) m_pendingForPermissionNotifiers.clear(); #endif }
void Geolocation::makeSuccessCallbacks(Geoposition& position) { ASSERT(lastPosition()); ASSERT(isAllowed()); auto oneShotsCopy = copyToVector(m_oneShots); GeoNotifierVector watchersCopy; m_watchers.getNotifiersVector(watchersCopy); // Clear the lists before we make the callbacks, to avoid clearing notifiers // added by calls to Geolocation methods from the callbacks, and to prevent // further callbacks to these notifiers. m_oneShots.clear(); sendPosition(oneShotsCopy, position); sendPosition(watchersCopy, position); if (!hasListeners()) stopUpdating(); }
void Geolocation::handleError(PositionError* error) { ASSERT(error); Vector<RefPtr<GeoNotifier> > oneShotsCopy; copyToVector(m_oneShots, oneShotsCopy); Vector<RefPtr<GeoNotifier> > watchersCopy; m_watchers.getNotifiersVector(watchersCopy); // Clear the lists before we make the callbacks, to avoid clearing notifiers // added by calls to Geolocation methods from the callbacks, and to prevent // further callbacks to these notifiers. m_oneShots.clear(); if (error->isFatal()) m_watchers.clear(); sendError(oneShotsCopy, error); sendError(watchersCopy, error); if (!hasListeners()) stopUpdating(); }
void NavigatorGamepad::pageVisibilityChanged() { // Inform the embedder whether it needs to provide gamepad data for us. bool visible = page()->visibilityState() == PageVisibilityStateVisible; if (visible && (m_hasEventListener || m_gamepads)) startUpdating(); else stopUpdating(); if (!visible || !m_hasEventListener) return; // Tell the page what has changed. m_gamepads contains the state before we became hidden. // We create a new snapshot and compare them. GamepadList* oldGamepads = m_gamepads.release(); gamepads(); GamepadList* newGamepads = m_gamepads.get(); ASSERT(newGamepads); for (unsigned i = 0; i < WebGamepads::itemsLengthCap; ++i) { Gamepad* oldGamepad = oldGamepads ? oldGamepads->item(i) : 0; Gamepad* newGamepad = newGamepads->item(i); bool oldWasConnected = oldGamepad && oldGamepad->connected(); bool newIsConnected = newGamepad && newGamepad->connected(); bool connectedGamepadChanged = oldWasConnected && newIsConnected && oldGamepad->id() != newGamepad->id(); if (connectedGamepadChanged || (oldWasConnected && !newIsConnected)) { oldGamepad->setConnected(false); m_pendingEvents.append(oldGamepad); } if (connectedGamepadChanged || (!oldWasConnected && newIsConnected)) { m_pendingEvents.append(newGamepad); } } if (!m_pendingEvents.isEmpty()) m_dispatchOneEventRunner.runAsync(); }