mirror of
https://github.com/atom/atom.git
synced 2026-01-24 22:38:20 -05:00
Update cef3 artifacts
This commit is contained in:
44
Atom-Linux/atom_handler.cpp
Normal file
44
Atom-Linux/atom_handler.cpp
Normal file
@@ -0,0 +1,44 @@
|
||||
#include "atom_handler.h"
|
||||
#include "include/cef_base.h"
|
||||
#include "include/cef_runnable.h"
|
||||
#include <iostream>
|
||||
#include <stdlib.h>
|
||||
#include "io_utils.h"
|
||||
#include "message_translation.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
AtomHandler::AtomHandler() :
|
||||
CefV8Handler() {
|
||||
string realFilePath = io_utils_real_app_path("/native/v8_extensions/atom.js");
|
||||
if (!realFilePath.empty()) {
|
||||
string extensionCode;
|
||||
if (io_utils_read(realFilePath, &extensionCode) > 0)
|
||||
CefRegisterExtension("v8/atom", extensionCode, this);
|
||||
}
|
||||
}
|
||||
|
||||
bool AtomHandler::Execute(const CefString& name, CefRefPtr<CefV8Value> object,
|
||||
const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval,
|
||||
CefString& exception) {
|
||||
CefRefPtr<CefBrowser> browser =
|
||||
CefV8Context::GetCurrentContext()->GetBrowser();
|
||||
|
||||
if (name == "sendMessageToBrowserProcess") {
|
||||
if (arguments.size() == 0 || !arguments[0]->IsString()) {
|
||||
exception = "You must supply a message name";
|
||||
return false;
|
||||
}
|
||||
|
||||
CefString name = arguments[0]->GetStringValue();
|
||||
CefRefPtr<CefProcessMessage> message = CefProcessMessage::Create(name);
|
||||
|
||||
if (arguments.size() > 1 && arguments[1]->IsArray()) {
|
||||
TranslateList(arguments[1], message->GetArgumentList());
|
||||
}
|
||||
|
||||
browser->SendProcessMessage(PID_BROWSER, message);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
Reference in New Issue
Block a user