Ejemplo n.º 1
0
bool StorageArea::canAccessStorage(LocalFrame* frame)
{
    if (!frame || !frame->page())
        return false;

    // LocalFrameLifecycleObserver is used to safely keep the cached
    // reference to the LocalFrame. Should the LocalFrame die before
    // this StorageArea does, that cached reference will be cleared.
    if (this->frame() == frame)
        return m_canAccessStorageCachedResult;
    StorageNamespaceController* controller = StorageNamespaceController::from(frame->page());
    if (!controller)
        return false;
    bool result = controller->storageClient()->canAccessStorage(frame, m_storageType);
    // Move attention to the new LocalFrame.
    LocalFrameLifecycleObserver::setContext(frame);
    m_canAccessStorageCachedResult = result;
    return result;
}