Пример #1
0
void Geolocation::startRequest(GeoNotifier* notifier)
{
    if (shouldBlockGeolocationRequests()) {
        notifier->setFatalError(PositionError::create(PositionError::POSITION_UNAVAILABLE, originCannotRequestGeolocationErrorMessage));
        return;
    }
    document()->setGeolocationAccessed();

    // Check whether permissions have already been denied. Note that if this is the case,
    // the permission state can not change again in the lifetime of this page.
    if (isDenied())
        notifier->setFatalError(PositionError::create(PositionError::PERMISSION_DENIED, permissionDeniedErrorMessage));
    else if (haveSuitableCachedPosition(notifier->options()))
        notifier->setUseCachedPosition();
    else if (notifier->hasZeroTimeout())
        notifier->startTimerIfNeeded();
    else if (!isAllowed()) {
        // if we don't yet have permission, request for permission before calling startUpdating()
        m_pendingForPermissionNotifiers.add(notifier);
        requestPermission();
    } else if (startUpdating(notifier))
        notifier->startTimerIfNeeded();
    else
        notifier->setFatalError(PositionError::create(PositionError::POSITION_UNAVAILABLE, failedToStartServiceErrorMessage));
}
Пример #2
0
PassRefPtr<Geolocation::GeoNotifier> Geolocation::startRequest(PassRefPtr<PositionCallback> successCallback, PassRefPtr<PositionErrorCallback> errorCallback, PassRefPtr<PositionOptions> options)
{
    RefPtr<GeoNotifier> notifier = GeoNotifier::create(this, successCallback, errorCallback, options);

    // Check whether permissions have already been denied. Note that if this is the case,
    // the permission state can not change again in the lifetime of this page.
    if (isDenied())
        notifier->setFatalError(PositionError::create(PositionError::PERMISSION_DENIED, permissionDeniedErrorMessage));
    else if (haveSuitableCachedPosition(notifier->m_options.get()))
        notifier->setUseCachedPosition();
    else if (notifier->hasZeroTimeout())
        notifier->startTimerIfNeeded();
#if USE(PREEMPT_GEOLOCATION_PERMISSION)
    else if (!isAllowed()) {
        // if we don't yet have permission, request for permission before calling startUpdating()
        m_pendingForPermissionNotifiers.add(notifier);
        requestPermission();
    }
#endif
    else if (startUpdating(notifier.get()))
        notifier->startTimerIfNeeded();
    else
        notifier->setFatalError(PositionError::create(PositionError::POSITION_UNAVAILABLE, failedToStartServiceErrorMessage));

    return notifier.release();
}
Пример #3
0
void Geolocation::startRequest(GeoNotifier *notifier)
{
    if (frame()->settings()->strictPowerfulFeatureRestrictions()) {
        String errorMessage;
        if (!executionContext()->securityOrigin()->canAccessFeatureRequiringSecureOrigin(errorMessage)) {
            notifier->setFatalError(PositionError::create(PositionError::POSITION_UNAVAILABLE, errorMessage));
            return;
        }
    }

    // Check whether permissions have already been denied. Note that if this is the case,
    // the permission state can not change again in the lifetime of this page.
    if (isDenied())
        notifier->setFatalError(PositionError::create(PositionError::PERMISSION_DENIED, permissionDeniedErrorMessage));
    else if (haveSuitableCachedPosition(notifier->options()))
        notifier->setUseCachedPosition();
    else if (!notifier->options().timeout())
        notifier->startTimer();
    else if (!isAllowed()) {
        // if we don't yet have permission, request for permission before calling startUpdating()
        m_pendingForPermissionNotifiers.add(notifier);
        requestPermission();
    } else if (startUpdating(notifier))
        notifier->startTimer();
    else
        notifier->setFatalError(PositionError::create(PositionError::POSITION_UNAVAILABLE, failedToStartServiceErrorMessage));
}
Пример #4
0
void Geolocation::startRequest(GeoNotifier* notifier) {
  recordOriginTypeAccess();
  String errorMessage;
  if (!frame()->settings()->allowGeolocationOnInsecureOrigins() &&
      !getExecutionContext()->isSecureContext(errorMessage)) {
    notifier->setFatalError(
        PositionError::create(PositionError::kPermissionDenied, errorMessage));
    return;
  }

  // Check whether permissions have already been denied. Note that if this is
  // the case, the permission state can not change again in the lifetime of
  // this page.
  if (isDenied())
    notifier->setFatalError(PositionError::create(
        PositionError::kPermissionDenied, permissionDeniedErrorMessage));
  else if (haveSuitableCachedPosition(notifier->options()))
    notifier->setUseCachedPosition();
  else if (!notifier->options().timeout())
    notifier->startTimer();
  else if (!isAllowed()) {
    // If we don't yet have permission, request for permission before calling
    // startUpdating()
    m_pendingForPermissionNotifiers.add(notifier);
    requestPermission();
  } else {
    startUpdating(notifier);
    notifier->startTimer();
  }
}
void PushRegistrationManager::startRequest(PushNotifier* notifier, ExecutionContext* executionContext)
{
    switch (m_pushPermission) {
    case PushPermission::Denied :
        notifier->permissionDenied();
        return;
    case PushPermission::Granted :
        notifier->permissionGranted();
        return;
    case PushPermission::InProgress :
    case PushPermission::Default :
        m_pendingForPermissionNotifiers.add(notifier);
        requestPermission(executionContext);
    }
}
Пример #6
0
void Geolocation::positionChanged(PassRefPtr<Geoposition> newPosition)
{
    m_positionCache->setCachedPosition(newPosition.get());

    // Stop all currently running timers.
    stopTimers();
    
    if (!isAllowed()) {
        // requestPermission() will ask the chrome for permission. This may be
        // implemented synchronously or asynchronously. In both cases,
        // makeSuccessCallbacks() will be called if permission is granted, so
        // there's nothing more to do here.
        requestPermission();
        return;
    }

    makeSuccessCallbacks();
}
Пример #7
0
void Geolocation::requestUsesCachedPosition(GeoNotifier* notifier)
{
    // This is called asynchronously, so the permissions could have been denied
    // since we last checked in startRequest.
    if (isDenied()) {
        notifier->setFatalError(PositionError::create(PositionError::PERMISSION_DENIED, permissionDeniedErrorMessage));
        return;
    }

    m_requestsAwaitingCachedPosition.add(notifier);

    // If permissions are allowed, make the callback
    if (isAllowed()) {
        makeCachedPositionCallbacks();
        return;
    }

    // Request permissions, which may be synchronous or asynchronous.
    requestPermission();
}
Пример #8
0
void Geolocation::startRequest(GeoNotifier *notifier)
{
    if (frame()->settings()->strictPowerfulFeatureRestrictions()) {
        String errorMessage;
        if (!executionContext()->isSecureContext(errorMessage)) {
            notifier->setFatalError(PositionError::create(PositionError::POSITION_UNAVAILABLE, errorMessage));
            return;
        }
    }

    if (RuntimeEnabledFeatures::restrictIFramePermissionsEnabled()) {
        // TODO(keenanb): kill the request if the parent is blocking the requester
        Element* owner = document()->ownerElement();
        if (owner && owner->hasAttribute(HTMLNames::permissionsAttr)) {
            String errorMessage = "A cross-origin iframe needs its permissions attribute properly set in order to use the geolocation API.";
            notifier->setFatalError(PositionError::create(PositionError::POSITION_UNAVAILABLE, errorMessage));
            return;
        }
    }

    // Check whether permissions have already been denied. Note that if this is the case,
    // the permission state can not change again in the lifetime of this page.
    if (isDenied())
        notifier->setFatalError(PositionError::create(PositionError::PERMISSION_DENIED, permissionDeniedErrorMessage));
    else if (haveSuitableCachedPosition(notifier->options()))
        notifier->setUseCachedPosition();
    else if (!notifier->options().timeout())
        notifier->startTimer();
    else if (!isAllowed()) {
        // if we don't yet have permission, request for permission before calling startUpdating()
        m_pendingForPermissionNotifiers.add(notifier);
        requestPermission();
    } else if (startUpdating(notifier))
        notifier->startTimer();
    else
        notifier->setFatalError(PositionError::create(PositionError::POSITION_UNAVAILABLE, failedToStartServiceErrorMessage));
}
Пример #9
0
bool Geolocation::startUpdating(GeoNotifier* notifier)
{
#if ENABLE(CLIENT_BASED_GEOLOCATION)
    // FIXME: Pass options to client.

    if (!isAllowed()) {
        m_startRequestPermissionNotifier = notifier;
        requestPermission();
        return true;
    }
    
    if (!m_frame)
        return false;

    Page* page = m_frame->page();
    if (!page)
        return false;

    page->geolocationController()->addObserver(this);
    return true;
#else
    return m_service->startUpdating(notifier->m_options.get());
#endif
}