void MockWebSpeechInputController::stopRecording(int requestId)
{
    BLINK_ASSERT(requestId == m_requestId);
    if (m_speechTask && m_recording) {
        m_speechTask->stop();
        speechTaskFired();
    }
}
Example #2
0
bool CppVariant::invokeDefault(const CppVariant* arguments, uint32_t argumentCount,
                               CppVariant& result) const
{
    BLINK_ASSERT(isObject());
    NPObject* npObject = value.objectValue;
    NPVariant r;
    bool status = WebBindings::invokeDefault(0, npObject, arguments, argumentCount, &r);
    result.set(r);
    return status;
}
Example #3
0
void TestPlugin::drawPrimitive()
{
    BLINK_ASSERT(m_scene.primitive == PrimitiveTriangle);
    BLINK_ASSERT(m_scene.vbo);
    BLINK_ASSERT(m_scene.program);

    m_context->useProgram(m_scene.program);

    // Bind primitive color.
    float color[4];
    premultiplyAlpha(m_scene.primitiveColor, m_scene.opacity, color);
    m_context->uniform4f(m_scene.colorLocation, color[0], color[1], color[2], color[3]);

    // Bind primitive vertices.
    m_context->bindBuffer(GL_ARRAY_BUFFER, m_scene.vbo);
    m_context->enableVertexAttribArray(m_scene.positionLocation);
    m_context->vertexAttribPointer(m_scene.positionLocation, 3, GL_FLOAT, GL_FALSE, 0, 0);
    m_context->drawArrays(GL_TRIANGLES, 0, 3);
}
void MockWebSpeechInputController::cancelRecognition(int requestId)
{
    if (m_speechTask) {
        BLINK_ASSERT(requestId == m_requestId);

        m_speechTask->stop();
        m_recording = false;
        m_listener->didCompleteRecognition(m_requestId);
        m_requestId = 0;
    }
}
Example #5
0
bool CppVariant::invoke(const string& method, const CppVariant* arguments,
                        uint32_t argumentCount, CppVariant& result) const
{
    BLINK_ASSERT(isObject());
    NPIdentifier methodName = WebBindings::getStringIdentifier(method.c_str());
    NPObject* npObject = value.objectValue;
    if (!WebBindings::hasMethod(0, npObject, methodName))
        return false;
    NPVariant r;
    bool status = WebBindings::invoke(0, npObject, methodName, arguments, argumentCount, &r);
    result.set(r);
    return status;
}
Example #6
0
TestPlugin::TestPlugin(WebFrame* frame, const WebPluginParams& params, WebTestDelegate* delegate)
    : m_frame(frame)
    , m_delegate(delegate)
    , m_container(0)
    , m_context(0)
    , m_colorTexture(0)
    , m_mailboxChanged(false)
    , m_framebuffer(0)
    , m_touchEventRequest(WebPluginContainer::TouchEventRequestTypeNone)
    , m_reRequestTouchEvents(false)
    , m_printEventDetails(false)
    , m_printUserGestureStatus(false)
    , m_canProcessDrag(false)
{
    static const WebString kAttributePrimitive = WebString::fromUTF8("primitive");
    static const WebString kAttributeBackgroundColor = WebString::fromUTF8("background-color");
    static const WebString kAttributePrimitiveColor = WebString::fromUTF8("primitive-color");
    static const WebString kAttributeOpacity = WebString::fromUTF8("opacity");
    static const WebString kAttributeAcceptsTouch = WebString::fromUTF8("accepts-touch");
    static const WebString kAttributeReRequestTouchEvents = WebString::fromUTF8("re-request-touch");
    static const WebString kAttributePrintEventDetails = WebString::fromUTF8("print-event-details");
    static const WebString kAttributeCanProcessDrag = WebString::fromUTF8("can-process-drag");
    static const WebString kAttributePrintUserGestureStatus = WebString::fromUTF8("print-user-gesture-status");

    BLINK_ASSERT(params.attributeNames.size() == params.attributeValues.size());
    size_t size = params.attributeNames.size();
    for (size_t i = 0; i < size; ++i) {
        const WebString& attributeName = params.attributeNames[i];
        const WebString& attributeValue = params.attributeValues[i];

        if (attributeName == kAttributePrimitive)
            m_scene.primitive = parsePrimitive(attributeValue);
        else if (attributeName == kAttributeBackgroundColor)
            parseColor(attributeValue, m_scene.backgroundColor);
        else if (attributeName == kAttributePrimitiveColor)
            parseColor(attributeValue, m_scene.primitiveColor);
        else if (attributeName == kAttributeOpacity)
            m_scene.opacity = parseOpacity(attributeValue);
        else if (attributeName == kAttributeAcceptsTouch)
            m_touchEventRequest = parseTouchEventRequestType(attributeValue);
        else if (attributeName == kAttributeReRequestTouchEvents)
            m_reRequestTouchEvents = parseBoolean(attributeValue);
        else if (attributeName == kAttributePrintEventDetails)
            m_printEventDetails = parseBoolean(attributeValue);
        else if (attributeName == kAttributeCanProcessDrag)
            m_canProcessDrag = parseBoolean(attributeValue);
        else if (attributeName == kAttributePrintUserGestureStatus)
            m_printUserGestureStatus = parseBoolean(attributeValue);
    }
}
Example #7
0
CppVariant* CppBoundClass::getAsCppVariant()
{
    if (!m_selfVariant.isObject()) {
        // Create an NPObject using our static NPClass. The first argument (a
        // plugin's instance handle) is passed through to the allocate function
        // directly, and we don't use it, so it's ok to be 0.
        NPObject* npObj = WebBindings::createObject(0, &CppNPObject::npClass);
        CppNPObject* obj = reinterpret_cast<CppNPObject*>(npObj);
        obj->boundClass = this;
        m_selfVariant.set(npObj);
        WebBindings::releaseObject(npObj); // CppVariant takes the reference.
    }
    BLINK_ASSERT(m_selfVariant.isObject());
    return &m_selfVariant;
}
Example #8
0
bool TestPlugin::initPrimitive()
{
    BLINK_ASSERT(m_scene.primitive == PrimitiveTriangle);

    m_scene.vbo = m_context->createBuffer();
    if (!m_scene.vbo)
        return false;

    const float vertices[] = {
        0.0f,  0.8f, 0.0f,
        -0.8f, -0.8f, 0.0f,
        0.8f, -0.8f, 0.0f };
    m_context->bindBuffer(GL_ARRAY_BUFFER, m_scene.vbo);
    m_context->bufferData(GL_ARRAY_BUFFER, sizeof(vertices), 0, GL_STATIC_DRAW);
    m_context->bufferSubData(GL_ARRAY_BUFFER, 0, sizeof(vertices), vertices);
    return true;
}
Example #9
0
vector<string> CppVariant::toStringVector() const
{

    BLINK_ASSERT(isObject());
    vector<string> stringVector;
    NPObject* npValue = value.objectValue;
    NPIdentifier lengthId = WebBindings::getStringIdentifier("length");

    if (!WebBindings::hasProperty(0, npValue, lengthId))
        return stringVector;

    NPVariant lengthValue;
    if (!WebBindings::getProperty(0, npValue, lengthId, &lengthValue))
        return stringVector;

    int length = 0;
    // The length is a double in some cases.
    if (NPVARIANT_IS_DOUBLE(lengthValue))
        length = static_cast<int>(NPVARIANT_TO_DOUBLE(lengthValue));
    else if (NPVARIANT_IS_INT32(lengthValue))
        length = NPVARIANT_TO_INT32(lengthValue);
    WebBindings::releaseVariantValue(&lengthValue);

    // For sanity, only allow 100 items.
    length = min(100, length);
    for (int i = 0; i < length; ++i) {
        // Get each of the items.
        char indexInChar[20]; // Enough size to store 32-bit integer
        snprintf(indexInChar, 20, "%d", i);
        string index(indexInChar);
        NPIdentifier indexId = WebBindings::getStringIdentifier(index.c_str());
        if (!WebBindings::hasProperty(0, npValue, indexId))
            continue;
        NPVariant indexValue;
        if (!WebBindings::getProperty(0, npValue, indexId, &indexValue))
            continue;
        if (NPVARIANT_IS_STRING(indexValue)) {
            string item(NPVARIANT_TO_STRING(indexValue).UTF8Characters,
                        NPVARIANT_TO_STRING(indexValue).UTF8Length);
            stringVector.push_back(item);
        }
        WebBindings::releaseVariantValue(&indexValue);
    }
    return stringVector;
}
Example #10
0
float WebSpeechGrammar::weight() const
{
    BLINK_ASSERT(m_private.get());
    return m_private->weight();
}
Example #11
0
WebURL WebSpeechGrammar::src() const
{
    BLINK_ASSERT(m_private.get());
    return m_private->src();
}
Example #12
0
bool CppVariant::toBoolean() const
{
    BLINK_ASSERT(isBool());
    return value.boolValue;
}
Example #13
0
string CppVariant::toString() const
{
    BLINK_ASSERT(isString());
    return string(value.stringValue.UTF8Characters,
                  value.stringValue.UTF8Length);
}