Example #1
0
void ChromeClientImpl::loadIconForFiles(const Vector<String>& filenames, FileIconLoader* loader)
{
    if (!m_webView->client())
        return;
    WebIconLoadingCompletionImpl* iconCompletion = new WebIconLoadingCompletionImpl(loader);
    if (!m_webView->client()->queryIconForFiles(filenames, iconCompletion))
        iconCompletion->didLoadIcon(WebData());
}
Example #2
0
void WebSocketImpl::didReceiveBinaryData(PassOwnPtr<Vector<char> > binaryData)
{
#if ENABLE(WEB_SOCKETS)
    switch (m_binaryType) {
    case BinaryTypeData:
    case BinaryTypeBlob: // FIXME: Handle Blob after supporting WebBlob.
        m_client->didReceiveBinaryData(WebData(binaryData->data(), binaryData->size()));
        break;
    case BinaryTypeArrayBuffer:
        m_client->didReceiveArrayBuffer(WebArrayBuffer(ArrayBuffer::create(binaryData->data(), binaryData->size())));
        break;
    }
#else
    ASSERT_NOT_REACHED();
#endif
}
WebData TestingPlatformSupport::loadResource(const char* name) {
  return m_oldPlatform ? m_oldPlatform->loadResource(name) : WebData();
}
IDBRequest* IDBObjectStore::put(ScriptState* scriptState, WebIDBPutMode putMode, IDBAny* source, const ScriptValue& value, IDBKey* key, ExceptionState& exceptionState)
{
    if (isDeleted()) {
        exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectStoreDeletedErrorMessage);
        return nullptr;
    }
    if (m_transaction->isFinished() || m_transaction->isFinishing()) {
        exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::transactionFinishedErrorMessage);
        return nullptr;
    }
    if (!m_transaction->isActive()) {
        exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::transactionInactiveErrorMessage);
        return nullptr;
    }
    if (m_transaction->isReadOnly()) {
        exceptionState.throwDOMException(ReadOnlyError, IDBDatabase::transactionReadOnlyErrorMessage);
        return nullptr;
    }

    Vector<WebBlobInfo> blobInfo;
    RefPtr<SerializedScriptValue> serializedValue = SerializedScriptValueFactory::instance().create(scriptState->isolate(), value, &blobInfo, exceptionState);
    if (exceptionState.hadException())
        return nullptr;

    // Keys that need to be extracted must be taken from a clone so that
    // side effects (i.e. getters) are not triggered. Construct the
    // clone lazily since the operation may be expensive.
    ScriptValue clone;

    const IDBKeyPath& keyPath = m_metadata.keyPath;
    const bool usesInLineKeys = !keyPath.isNull();
    const bool hasKeyGenerator = autoIncrement();

    if (putMode != WebIDBPutModeCursorUpdate && usesInLineKeys && key) {
        exceptionState.throwDOMException(DataError, "The object store uses in-line keys and the key parameter was provided.");
        return nullptr;
    }

    // This test logically belongs in IDBCursor, but must operate on the cloned value.
    if (putMode == WebIDBPutModeCursorUpdate && usesInLineKeys) {
        ASSERT(key);
        if (clone.isEmpty())
            clone = deserializeScriptValue(scriptState, serializedValue.get(), &blobInfo);
        IDBKey* keyPathKey = ScriptValue::to<IDBKey*>(scriptState->isolate(), clone, exceptionState, keyPath);
        if (exceptionState.hadException())
            return nullptr;
        if (!keyPathKey || !keyPathKey->isEqual(key)) {
            exceptionState.throwDOMException(DataError, "The effective object store of this cursor uses in-line keys and evaluating the key path of the value parameter results in a different value than the cursor's effective key.");
            return nullptr;
        }
    }

    if (!usesInLineKeys && !hasKeyGenerator && !key) {
        exceptionState.throwDOMException(DataError, "The object store uses out-of-line keys and has no key generator and the key parameter was not provided.");
        return nullptr;
    }
    if (usesInLineKeys) {
        if (clone.isEmpty())
            clone = deserializeScriptValue(scriptState, serializedValue.get(), &blobInfo);
        IDBKey* keyPathKey = ScriptValue::to<IDBKey*>(scriptState->isolate(), clone, exceptionState, keyPath);
        if (exceptionState.hadException())
            return nullptr;
        if (keyPathKey && !keyPathKey->isValid()) {
            exceptionState.throwDOMException(DataError, "Evaluating the object store's key path yielded a value that is not a valid key.");
            return nullptr;
        }
        if (!hasKeyGenerator && !keyPathKey) {
            exceptionState.throwDOMException(DataError, "Evaluating the object store's key path did not yield a value.");
            return nullptr;
        }
        if (hasKeyGenerator && !keyPathKey) {
            if (!canInjectIDBKeyIntoScriptValue(scriptState->isolate(), clone, keyPath)) {
                exceptionState.throwDOMException(DataError, "A generated key could not be inserted into the value.");
                return nullptr;
            }
        }
        if (keyPathKey)
            key = keyPathKey;
    }
    if (key && !key->isValid()) {
        exceptionState.throwDOMException(DataError, IDBDatabase::notValidKeyErrorMessage);
        return nullptr;
    }

    if (!backendDB()) {
        exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databaseClosedErrorMessage);
        return nullptr;
    }

    Vector<int64_t> indexIds;
    HeapVector<IndexKeys> indexKeys;
    for (const auto& it : m_metadata.indexes) {
        if (clone.isEmpty())
            clone = deserializeScriptValue(scriptState, serializedValue.get(), &blobInfo);
        IndexKeys keys;
        generateIndexKeysForValue(scriptState->isolate(), it.value, clone, &keys);
        indexIds.append(it.key);
        indexKeys.append(keys);
    }

    IDBRequest* request = IDBRequest::create(scriptState, source, m_transaction.get());
    Vector<char> wireBytes;
    serializedValue->toWireBytes(wireBytes);
    RefPtr<SharedBuffer> valueBuffer = SharedBuffer::adoptVector(wireBytes);

    backendDB()->put(m_transaction->id(), id(), WebData(valueBuffer), blobInfo, key, static_cast<WebIDBPutMode>(putMode), WebIDBCallbacksImpl::create(request).leakPtr(), indexIds, indexKeys);
    return request;
}
WebData WebDragData::fileContent() const
{
    ASSERT(!isNull());
    return WebData(m_private->fileContent());
}
Example #6
0
void loadHTMLString(WebFrame* frame,
                    const std::string& html,
                    const WebURL& baseURL) {
  frame->loadHTMLString(WebData(html.data(), html.size()), baseURL);
  pumpPendingRequestsForFrameToLoad(frame);
}