void GeolocationPermissions::providePermissionState(String origin, bool allow, bool remember)
{
    ASSERT(s_permanentPermissionsLoaded);

    // It's possible that this method is called with an origin that doesn't
    // match m_originInProgress. This can occur if this object is reset
    // while a permission result is in the process of being marshalled back to
    // the WebCore thread from the browser. In this case, we simply ignore the
    // call.
    if (origin != m_originInProgress)
        return;

    maybeCallbackFrames(m_originInProgress, allow);
    recordPermissionState(origin, allow, remember);

    // If the permissions are set to be remembered, cancel any queued requests
    // for this domain in other tabs.
    if (remember)
        cancelPendingRequestsInOtherTabs(m_originInProgress);

    // Clear the origin in progress to signal that this request is done.
    m_originInProgress = "";

    // If there are other requests queued, start the next one.
    if (!m_queuedOrigins.isEmpty()) {
        m_originInProgress = m_queuedOrigins.first();
        m_queuedOrigins.remove(0);
        m_webViewCore->geolocationPermissionsShowPrompt(m_originInProgress);
    }
}
void GeolocationPermissions::cancelPendingRequests(String origin)
{
    size_t index = m_queuedOrigins.find(origin);
    if (index != WTF::notFound) {
        // Get the permission from the permanent list.
        PermissionsMap::const_iterator iter = s_permanentPermissions.find(origin);
#ifndef NDEBUG
        PermissionsMap::const_iterator end = s_permanentPermissions.end();
        ASSERT(iter != end);
#endif
        bool allow = iter->second;

        maybeCallbackFrames(origin, allow);

        m_queuedOrigins.remove(index);
    }
}
void GeolocationPermissions::cancelPendingRequests(String origin)
{
    size_t index = m_queuedOrigins.find(origin);

    // Don't cancel the request if it's currently being shown, in which case
    // it's at index 0.
    if (index == WTF::notFound || !index)
        return;

    // Get the permission from the permanent list.
    ASSERT(s_permanentPermissions.contains(origin));
    PermissionsMap::const_iterator iter = s_permanentPermissions.find(origin);
    bool allow = iter->second;

    maybeCallbackFrames(origin, allow);

    m_queuedOrigins.remove(index);
    ASSERT(m_queuedOriginsToFramesMap.contains(origin));
    m_queuedOriginsToFramesMap.remove(origin);
}
void GeolocationPermissions::timerFired(Timer<GeolocationPermissions>* timer)
{
    ASSERT_UNUSED(timer, timer == &m_timer);
    maybeCallbackFrames(m_callbackData.origin, m_callbackData.allow);
}