void InspectorFrontend::DOM::documentUpdated()
{
    RefPtr<InspectorObject> jsonMessage = InspectorObject::create();
    jsonMessage->setString("method", "DOM.documentUpdated");
    if (m_inspectorFrontendChannel)
        m_inspectorFrontendChannel->sendMessageToFrontend(jsonMessage->toJSONString());
}
void InspectorFrontend::Profiler::resetProfiles()
{
    RefPtr<InspectorObject> jsonMessage = InspectorObject::create();
    jsonMessage->setString("method", "Profiler.resetProfiles");
    if (m_inspectorFrontendChannel)
        m_inspectorFrontendChannel->sendMessageToFrontend(jsonMessage->toJSONString());
}
void InspectorFrontend::Debugger::resumed()
{
    RefPtr<InspectorObject> jsonMessage = InspectorObject::create();
    jsonMessage->setString("method", "Debugger.resumed");
    if (m_inspectorFrontendChannel)
        m_inspectorFrontendChannel->sendMessageToFrontend(jsonMessage->toJSONString());
}
void InspectorFrontend::LayerTree::layerTreeDidChange()
{
    RefPtr<InspectorObject> jsonMessage = InspectorObject::create();
    jsonMessage->setString("method", "LayerTree.layerTreeDidChange");
    if (m_inspectorFrontendChannel)
        m_inspectorFrontendChannel->sendMessageToFrontend(jsonMessage->toJSONString());
}
void InspectorFrontend::Worker::disconnectedFromWorker()
{
    RefPtr<InspectorObject> jsonMessage = InspectorObject::create();
    jsonMessage->setString("method", "Worker.disconnectedFromWorker");
    if (m_inspectorFrontendChannel)
        m_inspectorFrontendChannel->sendMessageToFrontend(jsonMessage->toJSONString());
}
void InspectorFrontend::Console::messagesCleared()
{
    RefPtr<InspectorObject> jsonMessage = InspectorObject::create();
    jsonMessage->setString("method", "Console.messagesCleared");
    if (m_inspectorFrontendChannel)
        m_inspectorFrontendChannel->sendMessageToFrontend(jsonMessage->toJSONString());
}
Example #7
0
void InspectorState::updateCookie()
{
    RefPtr<InspectorObject> cookieObject = InspectorObject::create();
    for (PropertyMap::iterator i = m_properties.begin(); i != m_properties.end(); ++i)
        cookieObject->setValue(String::number(i->first), i->second.m_value);
    m_client->updateInspectorStateCookie(cookieObject->toJSONString());
}
Example #8
0
// FIXME: At the time of writing this is not a part of the spec. It is based an
// an unpublished editor's draft for:
//   https://www.w3.org/Bugs/Public/show_bug.cgi?id=24963
// See http://crbug.com/373917.
static bool copyJwkDictionaryToJson(const Dictionary& dict, CString& jsonUtf8, CryptoResult* result)
{
    RefPtr<JSONObject> jsonObject = JSONObject::create();

    if (!copyStringProperty("kty", dict, jsonObject.get())) {
        result->completeWithError(blink::WebCryptoErrorTypeData, "The required JWK property \"kty\" was missing");
        return false;
    }

    copyStringProperty("use", dict, jsonObject.get());
    copySequenceOfStringProperty("key_ops", dict, jsonObject.get());
    copyStringProperty("alg", dict, jsonObject.get());

    bool ext;
    if (dict.get("ext", ext))
        jsonObject->setBoolean("ext", ext);

    const char* const propertyNames[] = { "d", "n", "e", "p", "q", "dp", "dq", "qi", "k" };
    for (unsigned i = 0; i < WTF_ARRAY_LENGTH(propertyNames); ++i)
        copyStringProperty(propertyNames[i], dict, jsonObject.get());

    String json = jsonObject->toJSONString();
    jsonUtf8 = json.utf8();
    return true;
}
void InspectorBackendDispatcher::reportProtocolError(const long* const callId, CommonErrorCode errorCode, const String& errorMessage, PassRefPtr<InspectorArray> data) const
{
    static const int errorCodes[] = {
        -32700, // ParseError
        -32600, // InvalidRequest
        -32601, // MethodNotFound
        -32602, // InvalidParams
        -32603, // InternalError
        -32000, // ServerError
    };

    ASSERT(errorCode >= 0);
    ASSERT((unsigned)errorCode < WTF_ARRAY_LENGTH(errorCodes));
    ASSERT(errorCodes[errorCode]);

    if (!m_inspectorFrontendChannel)
        return;

    RefPtr<InspectorObject> error = InspectorObject::create();
    error->setNumber(ASCIILiteral("code"), errorCodes[errorCode]);
    error->setString(ASCIILiteral("message"), errorMessage);
    if (data)
        error->setArray(ASCIILiteral("data"), data);

    RefPtr<InspectorObject> message = InspectorObject::create();
    message->setObject(ASCIILiteral("error"), error.release());
    if (callId)
        message->setNumber(ASCIILiteral("id"), *callId);
    else
        message->setValue(ASCIILiteral("id"), InspectorValue::null());

    m_inspectorFrontendChannel->sendMessageToFrontend(message->toJSONString());
}
Example #10
0
void InspectorFrontend::Debugger::globalObjectCleared()
{
    RefPtr<InspectorObject> globalObjectClearedMessage = InspectorObject::create();
    globalObjectClearedMessage->setString("method", "Debugger.globalObjectCleared");
    if (m_inspectorFrontendChannel)
        m_inspectorFrontendChannel->sendMessageToFrontend(globalObjectClearedMessage->toJSONString());
}
void InspectorFrontend::CSS::mediaQueryResultChanged()
{
    RefPtr<InspectorObject> jsonMessage = InspectorObject::create();
    jsonMessage->setString("method", "CSS.mediaQueryResultChanged");
    if (m_inspectorFrontendChannel)
        m_inspectorFrontendChannel->sendMessageToFrontend(jsonMessage->toJSONString());
}
void InspectorDebuggerAgent::setVariableValue(ErrorString* errorString, int scopeNumber, const String& variableName, const RefPtr<JSONObject>& newValue, const String* callFrameId, const String* functionObjectId)
{
    InjectedScript injectedScript;
    if (callFrameId) {
        if (!isPaused() || m_currentCallStack.isNull()) {
            *errorString = "Attempt to access callframe when debugger is not on pause";
            return;
        }
        injectedScript = m_injectedScriptManager->injectedScriptForObjectId(*callFrameId);
        if (injectedScript.hasNoValue()) {
            *errorString = "Inspected frame has gone";
            return;
        }
    } else if (functionObjectId) {
        injectedScript = m_injectedScriptManager->injectedScriptForObjectId(*functionObjectId);
        if (injectedScript.hasNoValue()) {
            *errorString = "Function object id cannot be resolved";
            return;
        }
    } else {
        *errorString = "Either call frame or function object must be specified";
        return;
    }
    String newValueString = newValue->toJSONString();

    injectedScript.setVariableValue(errorString, m_currentCallStack, callFrameId, functionObjectId, scopeNumber, variableName, newValueString);
}
void InspectorWorkerAgent::sendMessageToWorker(ErrorString* error, int workerId, const RefPtr<InspectorObject>& message)
{
    WorkerFrontendChannel* channel = m_idToChannel.get(workerId);
    if (channel)
        channel->proxy()->sendMessageToInspector(message->toJSONString());
    else
        *error = "Worker is gone";
}
Example #14
0
void LayoutEditor::evaluateInOverlay(const String& method, PassRefPtr<JSONValue> argument) const
{
    ScriptForbiddenScope::AllowUserAgentScript allowScript;
    RefPtr<JSONArray> command = JSONArray::create();
    command->pushString(method);
    command->pushValue(argument);
    m_scriptController->executeScriptInMainWorld("dispatch(" + command->toJSONString() + ")", ScriptController::ExecuteScriptWhenScriptsDisabled);
}
void InspectorFrontend::Network::requestServedFromCache(const TypeBuilder::Network::RequestId& requestId)
{
    RefPtr<InspectorObject> jsonMessage = InspectorObject::create();
    jsonMessage->setString("method", "Network.requestServedFromCache");
    RefPtr<InspectorObject> paramsObject = InspectorObject::create();
    paramsObject->setString("requestId", requestId);
    jsonMessage->setObject("params", paramsObject);
    if (m_inspectorFrontendChannel)
        m_inspectorFrontendChannel->sendMessageToFrontend(jsonMessage->toJSONString());
}
void InspectorFrontend::Page::domContentEventFired(double timestamp)
{
    RefPtr<InspectorObject> jsonMessage = InspectorObject::create();
    jsonMessage->setString("method", "Page.domContentEventFired");
    RefPtr<InspectorObject> paramsObject = InspectorObject::create();
    paramsObject->setNumber("timestamp", timestamp);
    jsonMessage->setObject("params", paramsObject);
    if (m_inspectorFrontendChannel)
        m_inspectorFrontendChannel->sendMessageToFrontend(jsonMessage->toJSONString());
}
void InspectorFrontend::Database::addDatabase(PassRefPtr<TypeBuilder::Database::Database> database)
{
    RefPtr<InspectorObject> jsonMessage = InspectorObject::create();
    jsonMessage->setString("method", "Database.addDatabase");
    RefPtr<InspectorObject> paramsObject = InspectorObject::create();
    paramsObject->setValue("database", database);
    jsonMessage->setObject("params", paramsObject);
    if (m_inspectorFrontendChannel)
        m_inspectorFrontendChannel->sendMessageToFrontend(jsonMessage->toJSONString());
}
void InspectorFrontend::Inspector::detached(const String& reason)
{
    RefPtr<InspectorObject> jsonMessage = InspectorObject::create();
    jsonMessage->setString("method", "Inspector.detached");
    RefPtr<InspectorObject> paramsObject = InspectorObject::create();
    paramsObject->setString("reason", reason);
    jsonMessage->setObject("params", paramsObject);
    if (m_inspectorFrontendChannel)
        m_inspectorFrontendChannel->sendMessageToFrontend(jsonMessage->toJSONString());
}
void InspectorFrontend::DOMStorage::addDOMStorage(PassRefPtr<TypeBuilder::DOMStorage::Entry> storage)
{
    RefPtr<InspectorObject> jsonMessage = InspectorObject::create();
    jsonMessage->setString("method", "DOMStorage.addDOMStorage");
    RefPtr<InspectorObject> paramsObject = InspectorObject::create();
    paramsObject->setValue("storage", storage);
    jsonMessage->setObject("params", paramsObject);
    if (m_inspectorFrontendChannel)
        m_inspectorFrontendChannel->sendMessageToFrontend(jsonMessage->toJSONString());
}
void InspectorFrontend::Worker::workerTerminated(int workerId)
{
    RefPtr<InspectorObject> jsonMessage = InspectorObject::create();
    jsonMessage->setString("method", "Worker.workerTerminated");
    RefPtr<InspectorObject> paramsObject = InspectorObject::create();
    paramsObject->setNumber("workerId", workerId);
    jsonMessage->setObject("params", paramsObject);
    if (m_inspectorFrontendChannel)
        m_inspectorFrontendChannel->sendMessageToFrontend(jsonMessage->toJSONString());
}
void InspectorFrontend::CSS::styleSheetChanged(const TypeBuilder::CSS::StyleSheetId& styleSheetId)
{
    RefPtr<InspectorObject> jsonMessage = InspectorObject::create();
    jsonMessage->setString("method", "CSS.styleSheetChanged");
    RefPtr<InspectorObject> paramsObject = InspectorObject::create();
    paramsObject->setString("styleSheetId", styleSheetId);
    jsonMessage->setObject("params", paramsObject);
    if (m_inspectorFrontendChannel)
        m_inspectorFrontendChannel->sendMessageToFrontend(jsonMessage->toJSONString());
}
void InspectorFrontend::Profiler::setRecordingProfile(bool isProfiling)
{
    RefPtr<InspectorObject> jsonMessage = InspectorObject::create();
    jsonMessage->setString("method", "Profiler.setRecordingProfile");
    RefPtr<InspectorObject> paramsObject = InspectorObject::create();
    paramsObject->setBoolean("isProfiling", isProfiling);
    jsonMessage->setObject("params", paramsObject);
    if (m_inspectorFrontendChannel)
        m_inspectorFrontendChannel->sendMessageToFrontend(jsonMessage->toJSONString());
}
void InspectorFrontend::Profiler::finishHeapSnapshot(int uid)
{
    RefPtr<InspectorObject> jsonMessage = InspectorObject::create();
    jsonMessage->setString("method", "Profiler.finishHeapSnapshot");
    RefPtr<InspectorObject> paramsObject = InspectorObject::create();
    paramsObject->setNumber("uid", uid);
    jsonMessage->setObject("params", paramsObject);
    if (m_inspectorFrontendChannel)
        m_inspectorFrontendChannel->sendMessageToFrontend(jsonMessage->toJSONString());
}
void InspectorFrontend::Profiler::addProfileHeader(PassRefPtr<TypeBuilder::Profiler::ProfileHeader> header)
{
    RefPtr<InspectorObject> jsonMessage = InspectorObject::create();
    jsonMessage->setString("method", "Profiler.addProfileHeader");
    RefPtr<InspectorObject> paramsObject = InspectorObject::create();
    paramsObject->setValue("header", header);
    jsonMessage->setObject("params", paramsObject);
    if (m_inspectorFrontendChannel)
        m_inspectorFrontendChannel->sendMessageToFrontend(jsonMessage->toJSONString());
}
void InspectorFrontend::ApplicationCache::networkStateUpdated(bool isNowOnline)
{
    RefPtr<InspectorObject> jsonMessage = InspectorObject::create();
    jsonMessage->setString("method", "ApplicationCache.networkStateUpdated");
    RefPtr<InspectorObject> paramsObject = InspectorObject::create();
    paramsObject->setBoolean("isNowOnline", isNowOnline);
    jsonMessage->setObject("params", paramsObject);
    if (m_inspectorFrontendChannel)
        m_inspectorFrontendChannel->sendMessageToFrontend(jsonMessage->toJSONString());
}
void InspectorFrontend::Timeline::eventRecorded(PassRefPtr<TypeBuilder::Timeline::TimelineEvent> record)
{
    RefPtr<InspectorObject> jsonMessage = InspectorObject::create();
    jsonMessage->setString("method", "Timeline.eventRecorded");
    RefPtr<InspectorObject> paramsObject = InspectorObject::create();
    paramsObject->setValue("record", record);
    jsonMessage->setObject("params", paramsObject);
    if (m_inspectorFrontendChannel)
        m_inspectorFrontendChannel->sendMessageToFrontend(jsonMessage->toJSONString());
}
void InspectorFrontend::Console::messageRepeatCountUpdated(int count)
{
    RefPtr<InspectorObject> jsonMessage = InspectorObject::create();
    jsonMessage->setString("method", "Console.messageRepeatCountUpdated");
    RefPtr<InspectorObject> paramsObject = InspectorObject::create();
    paramsObject->setNumber("count", count);
    jsonMessage->setObject("params", paramsObject);
    if (m_inspectorFrontendChannel)
        m_inspectorFrontendChannel->sendMessageToFrontend(jsonMessage->toJSONString());
}
void InspectorFrontend::DOMStorage::domStorageUpdated(const TypeBuilder::DOMStorage::StorageId& storageId)
{
    RefPtr<InspectorObject> jsonMessage = InspectorObject::create();
    jsonMessage->setString("method", "DOMStorage.domStorageUpdated");
    RefPtr<InspectorObject> paramsObject = InspectorObject::create();
    paramsObject->setString("storageId", storageId);
    jsonMessage->setObject("params", paramsObject);
    if (m_inspectorFrontendChannel)
        m_inspectorFrontendChannel->sendMessageToFrontend(jsonMessage->toJSONString());
}
void InspectorFrontend::CSS::regionLayoutUpdated(PassRefPtr<TypeBuilder::CSS::NamedFlow> namedFlow)
{
    RefPtr<InspectorObject> jsonMessage = InspectorObject::create();
    jsonMessage->setString("method", "CSS.regionLayoutUpdated");
    RefPtr<InspectorObject> paramsObject = InspectorObject::create();
    paramsObject->setValue("namedFlow", namedFlow);
    jsonMessage->setObject("params", paramsObject);
    if (m_inspectorFrontendChannel)
        m_inspectorFrontendChannel->sendMessageToFrontend(jsonMessage->toJSONString());
}
void InspectorFrontend::DOM::inlineStyleInvalidated(PassRefPtr<TypeBuilder::Array<int> > nodeIds)
{
    RefPtr<InspectorObject> jsonMessage = InspectorObject::create();
    jsonMessage->setString("method", "DOM.inlineStyleInvalidated");
    RefPtr<InspectorObject> paramsObject = InspectorObject::create();
    paramsObject->setValue("nodeIds", nodeIds);
    jsonMessage->setObject("params", paramsObject);
    if (m_inspectorFrontendChannel)
        m_inspectorFrontendChannel->sendMessageToFrontend(jsonMessage->toJSONString());
}