[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/2php/cefpython/master/src/subprocess/v8function_handler.cpp [Back]  [Original]

// Copyright (c) 2012 CEF Python, see the Authors file.
// All rights reserved. Licensed under BSD 3-clause license.
// Project website: https://github.com/cztomczak/cefpython

#include "cefpython_app.h"
#include "v8utils.h"
#include "include/base/cef_logging.h"

bool V8FunctionHandler::Execute(const CefString& functionName,
                        CefRefPtr thisObject,
                        const CefV8ValueList& v8Arguments,
                        CefRefPtr& returnValue,
                        CefString& exception) {
    if (!CefV8Context::InContext()) {
        // CefV8Context::GetCurrentContext may not be called when
        // not in a V8 context.
        LOG(ERROR) GetBrowser();
    CefRefPtr frame = context.get()->GetFrame();
    if (pythonCallbackId_) {
        LOG(INFO) GetArgumentList();
        messageArguments->SetInt(0, pythonCallbackId_);
        messageArguments->SetList(1, functionArguments);
        browser->SendProcessMessage(PID_BROWSER, processMessage);
        returnValue = CefV8Value::CreateNull();
        return true;
    } else {
        LOG(INFO) BindedFunctionExists( \
                        browser, functionName))) {
            exception = std::string("[CEF Python] " \
                    "V8FunctionHandler::Execute() FAILED: " \
                    "function does not exist: ").append(functionName) \
                    .append("()");
            // Must return true for the exception to be thrown.
            return true;
        }
        CefRefPtr functionArguments = V8ValueListToCefListValue(
                v8Arguments);
        // TODO: losing int64 precision here.
        int frameId = (int)frame->GetIdentifier();
        CefRefPtr processMessage = \
                CefProcessMessage::Create("V8FunctionHandler::Execute");
        CefRefPtr messageArguments = \
                processMessage->GetArgumentList();
        messageArguments->SetInt(0, frameId);
        messageArguments->SetString(1, functionName);
        messageArguments->SetList(2, functionArguments);
        browser->SendProcessMessage(PID_BROWSER, processMessage);
        returnValue = CefV8Value::CreateNull();
        return true;
    }
}

Web Proxy Viewer  |  New URL  |  Original Page