mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
De-tab .cpp and .h files
This commit is contained in:
@@ -23,141 +23,140 @@ const char* szPathToOpen; // The file to open
|
||||
CefRefPtr<ClientHandler> g_handler;
|
||||
|
||||
void AppGetSettings(CefSettings& settings, CefRefPtr<CefApp>& app) {
|
||||
CefString(&settings.cache_path) = "";
|
||||
CefString(&settings.user_agent) = "";
|
||||
CefString(&settings.product_version) = "";
|
||||
CefString(&settings.locale) = "";
|
||||
CefString(&settings.log_file) = "";
|
||||
CefString(&settings.javascript_flags) = "";
|
||||
CefString(&settings.cache_path) = "";
|
||||
CefString(&settings.user_agent) = "";
|
||||
CefString(&settings.product_version) = "";
|
||||
CefString(&settings.locale) = "";
|
||||
CefString(&settings.log_file) = "";
|
||||
CefString(&settings.javascript_flags) = "";
|
||||
|
||||
settings.log_severity = LOGSEVERITY_ERROR;
|
||||
settings.local_storage_quota = 0;
|
||||
settings.session_storage_quota = 0;
|
||||
settings.log_severity = LOGSEVERITY_ERROR;
|
||||
settings.local_storage_quota = 0;
|
||||
settings.session_storage_quota = 0;
|
||||
}
|
||||
|
||||
void destroy(void) {
|
||||
CefQuitMessageLoop();
|
||||
CefQuitMessageLoop();
|
||||
}
|
||||
|
||||
void TerminationSignalHandler(int signatl) {
|
||||
destroy();
|
||||
destroy();
|
||||
}
|
||||
|
||||
// WebViewDelegate::TakeFocus in the test webview delegate.
|
||||
static gboolean HandleFocus(GtkWidget* widget, GdkEventFocus* focus) {
|
||||
if (g_handler.get() && g_handler->GetBrowserHwnd()) {
|
||||
// Give focus to the browser window.
|
||||
g_handler->GetBrowser()->SetFocus(true);
|
||||
}
|
||||
if (g_handler.get() && g_handler->GetBrowserHwnd()) {
|
||||
// Give focus to the browser window.
|
||||
g_handler->GetBrowser()->SetFocus(true);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
szWorkingDir = get_current_dir_name();
|
||||
if (szWorkingDir == NULL)
|
||||
return -1;
|
||||
szWorkingDir = get_current_dir_name();
|
||||
if (szWorkingDir == NULL)
|
||||
return -1;
|
||||
|
||||
std::string fullPath = argv[0];
|
||||
fullPath = fullPath.substr(0, fullPath.length() - 5);
|
||||
szPath = fullPath.c_str();
|
||||
std::string fullPath = argv[0];
|
||||
fullPath = fullPath.substr(0, fullPath.length() - 5);
|
||||
szPath = fullPath.c_str();
|
||||
|
||||
std::string pathToOpen;
|
||||
if (argc >= 2) {
|
||||
if (argv[1][0] != '/') {
|
||||
pathToOpen.append(szWorkingDir);
|
||||
pathToOpen.append("/");
|
||||
pathToOpen.append(argv[1]);
|
||||
} else
|
||||
pathToOpen.append(argv[1]);
|
||||
} else
|
||||
pathToOpen.append(szWorkingDir);
|
||||
szPathToOpen = pathToOpen.c_str();
|
||||
std::string pathToOpen;
|
||||
if (argc >= 2) {
|
||||
if (argv[1][0] != '/') {
|
||||
pathToOpen.append(szWorkingDir);
|
||||
pathToOpen.append("/");
|
||||
pathToOpen.append(argv[1]);
|
||||
} else
|
||||
pathToOpen.append(argv[1]);
|
||||
} else
|
||||
pathToOpen.append(szWorkingDir);
|
||||
szPathToOpen = pathToOpen.c_str();
|
||||
|
||||
GtkWidget* window;
|
||||
GtkWidget* window;
|
||||
|
||||
gtk_init(&argc, &argv);
|
||||
gtk_init(&argc, &argv);
|
||||
|
||||
CefSettings settings;
|
||||
CefRefPtr<CefApp> app;
|
||||
CefSettings settings;
|
||||
CefRefPtr<CefApp> app;
|
||||
|
||||
AppGetSettings(settings, app);
|
||||
CefInitialize(settings, app);
|
||||
AppGetSettings(settings, app);
|
||||
CefInitialize(settings, app);
|
||||
|
||||
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_title(GTK_WINDOW(window), "atom");
|
||||
gtk_window_set_default_size(GTK_WINDOW(window), 800, 600);
|
||||
gtk_window_maximize(GTK_WINDOW(window));
|
||||
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_title(GTK_WINDOW(window), "atom");
|
||||
gtk_window_set_default_size(GTK_WINDOW(window), 800, 600);
|
||||
gtk_window_maximize(GTK_WINDOW(window));
|
||||
|
||||
g_signal_connect(window, "focus", G_CALLBACK(&HandleFocus), NULL);
|
||||
g_signal_connect(window, "focus", G_CALLBACK(&HandleFocus), NULL);
|
||||
|
||||
GtkWidget* vbox = gtk_vbox_new(FALSE, 0);
|
||||
GtkWidget* vbox = gtk_vbox_new(FALSE, 0);
|
||||
|
||||
g_signal_connect(G_OBJECT(window), "destroy",
|
||||
G_CALLBACK(gtk_widget_destroyed), &window);
|
||||
g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(destroy), NULL);
|
||||
g_signal_connect(G_OBJECT(window), "destroy",
|
||||
G_CALLBACK(gtk_widget_destroyed), &window);
|
||||
g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(destroy), NULL);
|
||||
|
||||
// Create the handler.
|
||||
g_handler = new ClientHandler();
|
||||
g_handler->SetMainHwnd(vbox);
|
||||
g_handler->SetWindow(window);
|
||||
// Create the handler.
|
||||
g_handler = new ClientHandler();
|
||||
g_handler->SetMainHwnd(vbox);
|
||||
g_handler->SetWindow(window);
|
||||
|
||||
// Create the browser view.
|
||||
CefWindowInfo window_info;
|
||||
CefBrowserSettings browserSettings;
|
||||
// Create the browser view.
|
||||
CefWindowInfo window_info;
|
||||
CefBrowserSettings browserSettings;
|
||||
|
||||
window_info.SetAsChild(vbox);
|
||||
window_info.SetAsChild(vbox);
|
||||
|
||||
std::string path;
|
||||
path.append(szPath);
|
||||
path.append("/../index.html");
|
||||
char* realPath;
|
||||
realPath = realpath(path.c_str(), NULL);
|
||||
if (realPath == NULL)
|
||||
return -1;
|
||||
std::string path;
|
||||
path.append(szPath);
|
||||
path.append("/../index.html");
|
||||
char* realPath;
|
||||
realPath = realpath(path.c_str(), NULL);
|
||||
if (realPath == NULL)
|
||||
return -1;
|
||||
|
||||
std::string resolved("file://");
|
||||
resolved.append(realPath);
|
||||
free(realPath);
|
||||
std::string resolved("file://");
|
||||
resolved.append(realPath);
|
||||
free(realPath);
|
||||
|
||||
CefBrowser::CreateBrowserSync(window_info,
|
||||
static_cast<CefRefPtr<CefClient> >(g_handler), resolved,
|
||||
browserSettings);
|
||||
CefBrowser::CreateBrowserSync(window_info,
|
||||
static_cast<CefRefPtr<CefClient> >(g_handler), resolved, browserSettings);
|
||||
|
||||
gtk_container_add(GTK_CONTAINER(window), vbox);
|
||||
gtk_widget_show_all(GTK_WIDGET(window));
|
||||
gtk_container_add(GTK_CONTAINER(window), vbox);
|
||||
gtk_widget_show_all(GTK_WIDGET(window));
|
||||
|
||||
GdkPixbuf *pixbuf;
|
||||
GError *error = NULL;
|
||||
std::string iconPath;
|
||||
iconPath.append(szPath);
|
||||
iconPath.append("/atom.png");
|
||||
pixbuf = gdk_pixbuf_new_from_file(iconPath.c_str(), &error);
|
||||
if (pixbuf)
|
||||
gtk_window_set_icon(GTK_WINDOW(window), pixbuf);
|
||||
GdkPixbuf *pixbuf;
|
||||
GError *error = NULL;
|
||||
std::string iconPath;
|
||||
iconPath.append(szPath);
|
||||
iconPath.append("/atom.png");
|
||||
pixbuf = gdk_pixbuf_new_from_file(iconPath.c_str(), &error);
|
||||
if (pixbuf)
|
||||
gtk_window_set_icon(GTK_WINDOW(window), pixbuf);
|
||||
|
||||
// Install an signal handler so we clean up after ourselves.
|
||||
signal(SIGINT, TerminationSignalHandler);
|
||||
signal(SIGTERM, TerminationSignalHandler);
|
||||
// Install an signal handler so we clean up after ourselves.
|
||||
signal(SIGINT, TerminationSignalHandler);
|
||||
signal(SIGTERM, TerminationSignalHandler);
|
||||
|
||||
CefRunMessageLoop();
|
||||
CefRunMessageLoop();
|
||||
|
||||
CefShutdown();
|
||||
CefShutdown();
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Global functions
|
||||
|
||||
std::string AppGetWorkingDirectory() {
|
||||
return szWorkingDir;
|
||||
return szWorkingDir;
|
||||
}
|
||||
|
||||
std::string AppPath() {
|
||||
return szPath;
|
||||
return szPath;
|
||||
}
|
||||
|
||||
std::string PathToOpen() {
|
||||
return szPathToOpen;
|
||||
return szPathToOpen;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,264 +15,261 @@
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
ClientHandler::ClientHandler() :
|
||||
m_MainHwnd(NULL), m_BrowserHwnd(NULL) {
|
||||
m_MainHwnd(NULL), m_BrowserHwnd(NULL) {
|
||||
}
|
||||
|
||||
ClientHandler::~ClientHandler() {
|
||||
}
|
||||
|
||||
void ClientHandler::OnAfterCreated(CefRefPtr<CefBrowser> browser) {
|
||||
REQUIRE_UI_THREAD();
|
||||
REQUIRE_UI_THREAD();
|
||||
|
||||
AutoLock lock_scope(this);
|
||||
if (!m_Browser.get()) {
|
||||
// We need to keep the main child window, but not popup windows
|
||||
m_Browser = browser;
|
||||
m_BrowserHwnd = browser->GetWindowHandle();
|
||||
}
|
||||
AutoLock lock_scope(this);
|
||||
if (!m_Browser.get()) {
|
||||
// We need to keep the main child window, but not popup windows
|
||||
m_Browser = browser;
|
||||
m_BrowserHwnd = browser->GetWindowHandle();
|
||||
}
|
||||
}
|
||||
|
||||
bool ClientHandler::DoClose(CefRefPtr<CefBrowser> browser) {
|
||||
REQUIRE_UI_THREAD();
|
||||
REQUIRE_UI_THREAD();
|
||||
|
||||
if (m_BrowserHwnd == browser->GetWindowHandle()) {
|
||||
// Since the main window contains the browser window, we need to close
|
||||
// the parent window instead of the browser window.
|
||||
CloseMainWindow();
|
||||
if (m_BrowserHwnd == browser->GetWindowHandle()) {
|
||||
// Since the main window contains the browser window, we need to close
|
||||
// the parent window instead of the browser window.
|
||||
CloseMainWindow();
|
||||
|
||||
// Return true here so that we can skip closing the browser window
|
||||
// in this pass. (It will be destroyed due to the call to close
|
||||
// the parent above.)
|
||||
return true;
|
||||
}
|
||||
// Return true here so that we can skip closing the browser window
|
||||
// in this pass. (It will be destroyed due to the call to close
|
||||
// the parent above.)
|
||||
return true;
|
||||
}
|
||||
|
||||
// A popup browser window is not contained in another window, so we can let
|
||||
// these windows close by themselves.
|
||||
return false;
|
||||
// A popup browser window is not contained in another window, so we can let
|
||||
// these windows close by themselves.
|
||||
return false;
|
||||
}
|
||||
|
||||
void ClientHandler::OnBeforeClose(CefRefPtr<CefBrowser> browser) {
|
||||
REQUIRE_UI_THREAD();
|
||||
REQUIRE_UI_THREAD();
|
||||
|
||||
if (m_BrowserHwnd == browser->GetWindowHandle()) {
|
||||
// Free the browser pointer so that the browser can be destroyed
|
||||
m_Browser = NULL;
|
||||
}
|
||||
if (m_BrowserHwnd == browser->GetWindowHandle()) {
|
||||
// Free the browser pointer so that the browser can be destroyed
|
||||
m_Browser = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void ClientHandler::OnLoadStart(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame) {
|
||||
REQUIRE_UI_THREAD();
|
||||
CefRefPtr<CefFrame> frame) {
|
||||
REQUIRE_UI_THREAD();
|
||||
|
||||
if (m_BrowserHwnd == browser->GetWindowHandle() && frame->IsMain()) {
|
||||
CefRefPtr<CefV8Context> context = frame->GetV8Context();
|
||||
CefRefPtr<CefV8Value> global = context->GetGlobal();
|
||||
context->Enter();
|
||||
if (m_BrowserHwnd == browser->GetWindowHandle() && frame->IsMain()) {
|
||||
CefRefPtr<CefV8Context> context = frame->GetV8Context();
|
||||
CefRefPtr<CefV8Value> global = context->GetGlobal();
|
||||
context->Enter();
|
||||
|
||||
CefRefPtr<CefV8Value> windowNumber = CefV8Value::CreateInt(0);
|
||||
global->SetValue("$windowNumber", windowNumber,
|
||||
V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
CefRefPtr<CefV8Value> windowNumber = CefV8Value::CreateInt(0);
|
||||
global->SetValue("$windowNumber", windowNumber, V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
|
||||
std::string path;
|
||||
if (m_nativeHandler)
|
||||
path = m_nativeHandler->path;
|
||||
else
|
||||
path.append(PathToOpen());
|
||||
std::string path;
|
||||
if (m_nativeHandler)
|
||||
path = m_nativeHandler->path;
|
||||
else
|
||||
path.append(PathToOpen());
|
||||
|
||||
CefRefPtr<CefV8Value> pathToOpen = CefV8Value::CreateString(path);
|
||||
global->SetValue("$pathToOpen", pathToOpen, V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
CefRefPtr<CefV8Value> pathToOpen = CefV8Value::CreateString(path);
|
||||
global->SetValue("$pathToOpen", pathToOpen, V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
|
||||
CefRefPtr<NativeHandler> nativeHandler = new NativeHandler();
|
||||
nativeHandler->window = window;
|
||||
nativeHandler->path = path;
|
||||
global->SetValue("$native", nativeHandler->object,
|
||||
V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
m_nativeHandler = nativeHandler;
|
||||
CefRefPtr<NativeHandler> nativeHandler = new NativeHandler();
|
||||
nativeHandler->window = window;
|
||||
nativeHandler->path = path;
|
||||
global->SetValue("$native", nativeHandler->object,
|
||||
V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
m_nativeHandler = nativeHandler;
|
||||
|
||||
CefRefPtr<CefV8Value> atom = CefV8Value::CreateObject(NULL, NULL);
|
||||
global->SetValue("atom", atom, V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
CefRefPtr<CefV8Value> atom = CefV8Value::CreateObject(NULL, NULL);
|
||||
global->SetValue("atom", atom, V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
|
||||
std::string relativePath(AppPath());
|
||||
relativePath.append("/..");
|
||||
char* realLoadPath;
|
||||
realLoadPath = realpath(relativePath.c_str(), NULL);
|
||||
if (realLoadPath != NULL) {
|
||||
std::string resolvedLoadPath(realLoadPath);
|
||||
free(realLoadPath);
|
||||
std::string relativePath(AppPath());
|
||||
relativePath.append("/..");
|
||||
char* realLoadPath;
|
||||
realLoadPath = realpath(relativePath.c_str(), NULL);
|
||||
if (realLoadPath != NULL) {
|
||||
std::string resolvedLoadPath(realLoadPath);
|
||||
free(realLoadPath);
|
||||
|
||||
CefRefPtr<CefV8Value> loadPath = CefV8Value::CreateString(
|
||||
resolvedLoadPath);
|
||||
atom->SetValue("loadPath", loadPath, V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
}
|
||||
CefRefPtr<CefV8Value> loadPath = CefV8Value::CreateString(
|
||||
resolvedLoadPath);
|
||||
atom->SetValue("loadPath", loadPath, V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
}
|
||||
|
||||
CefRefPtr<CefV8Value> bootstrapScript = CefV8Value::CreateString(
|
||||
"single-window-bootstrap");
|
||||
global->SetValue("$bootstrapScript", bootstrapScript,
|
||||
V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
CefRefPtr<CefV8Value> bootstrapScript = CefV8Value::CreateString(
|
||||
"single-window-bootstrap");
|
||||
global->SetValue("$bootstrapScript", bootstrapScript,
|
||||
V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
|
||||
context->Exit();
|
||||
}
|
||||
context->Exit();
|
||||
}
|
||||
}
|
||||
|
||||
void ClientHandler::OnLoadEnd(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame, int httpStatusCode) {
|
||||
REQUIRE_UI_THREAD();
|
||||
CefRefPtr<CefFrame> frame, int httpStatusCode) {
|
||||
REQUIRE_UI_THREAD();
|
||||
|
||||
}
|
||||
|
||||
bool ClientHandler::OnLoadError(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame, ErrorCode errorCode,
|
||||
const CefString& failedUrl, CefString& errorText) {
|
||||
REQUIRE_UI_THREAD();
|
||||
CefRefPtr<CefFrame> frame, ErrorCode errorCode, const CefString& failedUrl,
|
||||
CefString& errorText) {
|
||||
REQUIRE_UI_THREAD();
|
||||
|
||||
if (errorCode == ERR_CACHE_MISS) {
|
||||
// Usually caused by navigating to a page with POST data via back or
|
||||
// forward buttons.
|
||||
errorText = "<html><head><title>Expired Form Data</title></head>"
|
||||
"<body><h1>Expired Form Data</h1>"
|
||||
"<h2>Your form request has expired. "
|
||||
"Click reload to re-submit the form data.</h2></body>"
|
||||
"</html>";
|
||||
} else {
|
||||
// All other messages.
|
||||
std::stringstream ss;
|
||||
ss << "<html><head><title>Load Failed</title></head>"
|
||||
"<body><h1>Load Failed</h1>"
|
||||
"<h2>Load of URL " << std::string(failedUrl)
|
||||
<< " failed with error code " << static_cast<int>(errorCode)
|
||||
<< ".</h2></body>"
|
||||
"</html>";
|
||||
errorText = ss.str();
|
||||
}
|
||||
if (errorCode == ERR_CACHE_MISS) {
|
||||
// Usually caused by navigating to a page with POST data via back or
|
||||
// forward buttons.
|
||||
errorText = "<html><head><title>Expired Form Data</title></head>"
|
||||
"<body><h1>Expired Form Data</h1>"
|
||||
"<h2>Your form request has expired. "
|
||||
"Click reload to re-submit the form data.</h2></body>"
|
||||
"</html>";
|
||||
} else {
|
||||
// All other messages.
|
||||
std::stringstream ss;
|
||||
ss << "<html><head><title>Load Failed</title></head>"
|
||||
"<body><h1>Load Failed</h1>"
|
||||
"<h2>Load of URL " << std::string(failedUrl)
|
||||
<< " failed with error code " << static_cast<int>(errorCode)
|
||||
<< ".</h2></body>"
|
||||
"</html>";
|
||||
errorText = ss.str();
|
||||
}
|
||||
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
void ClientHandler::OnNavStateChange(CefRefPtr<CefBrowser> browser,
|
||||
bool canGoBack, bool canGoForward) {
|
||||
//Intentionally left blank
|
||||
bool canGoBack, bool canGoForward) {
|
||||
//Intentionally left blank
|
||||
}
|
||||
|
||||
bool ClientHandler::OnConsoleMessage(CefRefPtr<CefBrowser> browser,
|
||||
const CefString& message, const CefString& source, int line) {
|
||||
REQUIRE_UI_THREAD();
|
||||
std::cout << std::string(message) << std::endl;
|
||||
return false;
|
||||
const CefString& message, const CefString& source, int line) {
|
||||
REQUIRE_UI_THREAD();
|
||||
std::cout << std::string(message) << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
void ClientHandler::OnFocusedNodeChanged(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame, CefRefPtr<CefDOMNode> node) {
|
||||
REQUIRE_UI_THREAD();
|
||||
CefRefPtr<CefFrame> frame, CefRefPtr<CefDOMNode> node) {
|
||||
REQUIRE_UI_THREAD();
|
||||
}
|
||||
|
||||
bool ClientHandler::OnKeyEvent(CefRefPtr<CefBrowser> browser, KeyEventType type,
|
||||
int code, int modifiers, bool isSystemKey, bool isAfterJavaScript) {
|
||||
REQUIRE_UI_THREAD();
|
||||
int code, int modifiers, bool isSystemKey, bool isAfterJavaScript) {
|
||||
REQUIRE_UI_THREAD();
|
||||
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ClientHandler::GetPrintHeaderFooter(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame, const CefPrintInfo& printInfo,
|
||||
const CefString& url, const CefString& title, int currentPage,
|
||||
int maxPages, CefString& topLeft, CefString& topCenter,
|
||||
CefString& topRight, CefString& bottomLeft, CefString& bottomCenter,
|
||||
CefString& bottomRight) {
|
||||
REQUIRE_UI_THREAD();
|
||||
CefRefPtr<CefFrame> frame, const CefPrintInfo& printInfo,
|
||||
const CefString& url, const CefString& title, int currentPage, int maxPages,
|
||||
CefString& topLeft, CefString& topCenter, CefString& topRight,
|
||||
CefString& bottomLeft, CefString& bottomCenter, CefString& bottomRight) {
|
||||
REQUIRE_UI_THREAD();
|
||||
|
||||
// Place the page title at top left
|
||||
topLeft = title;
|
||||
// Place the page URL at top right
|
||||
topRight = url;
|
||||
// Place the page title at top left
|
||||
topLeft = title;
|
||||
// Place the page URL at top right
|
||||
topRight = url;
|
||||
|
||||
// Place "Page X of Y" at bottom center
|
||||
std::stringstream strstream;
|
||||
strstream << "Page " << currentPage << " of " << maxPages;
|
||||
bottomCenter = strstream.str();
|
||||
// Place "Page X of Y" at bottom center
|
||||
std::stringstream strstream;
|
||||
strstream << "Page " << currentPage << " of " << maxPages;
|
||||
bottomCenter = strstream.str();
|
||||
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
void ClientHandler::OnContextCreated(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame, CefRefPtr<CefV8Context> context) {
|
||||
REQUIRE_UI_THREAD();
|
||||
CefRefPtr<CefFrame> frame, CefRefPtr<CefV8Context> context) {
|
||||
REQUIRE_UI_THREAD();
|
||||
}
|
||||
|
||||
bool ClientHandler::OnDragStart(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefDragData> dragData, DragOperationsMask mask) {
|
||||
REQUIRE_UI_THREAD();
|
||||
CefRefPtr<CefDragData> dragData, DragOperationsMask mask) {
|
||||
REQUIRE_UI_THREAD();
|
||||
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ClientHandler::OnDragEnter(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefDragData> dragData, DragOperationsMask mask) {
|
||||
REQUIRE_UI_THREAD();
|
||||
CefRefPtr<CefDragData> dragData, DragOperationsMask mask) {
|
||||
REQUIRE_UI_THREAD();
|
||||
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
void ClientHandler::SetWindow(GtkWidget* widget) {
|
||||
window = widget;
|
||||
window = widget;
|
||||
}
|
||||
|
||||
void ClientHandler::SetMainHwnd(CefWindowHandle hwnd) {
|
||||
AutoLock lock_scope(this);
|
||||
m_MainHwnd = hwnd;
|
||||
AutoLock lock_scope(this);
|
||||
m_MainHwnd = hwnd;
|
||||
}
|
||||
|
||||
// ClientHandler::ClientLifeSpanHandler implementation
|
||||
bool ClientHandler::OnBeforePopup(CefRefPtr<CefBrowser> parentBrowser,
|
||||
const CefPopupFeatures& popupFeatures, CefWindowInfo& windowInfo,
|
||||
const CefString& url, CefRefPtr<CefClient>& client,
|
||||
CefBrowserSettings& settings) {
|
||||
REQUIRE_UI_THREAD();
|
||||
const CefPopupFeatures& popupFeatures, CefWindowInfo& windowInfo,
|
||||
const CefString& url, CefRefPtr<CefClient>& client,
|
||||
CefBrowserSettings& settings) {
|
||||
REQUIRE_UI_THREAD();
|
||||
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
void ClientHandler::OnAddressChange(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame, const CefString& url) {
|
||||
//Intentionally left blank
|
||||
CefRefPtr<CefFrame> frame, const CefString& url) {
|
||||
//Intentionally left blank
|
||||
}
|
||||
|
||||
void ClientHandler::OnTitleChange(CefRefPtr<CefBrowser> browser,
|
||||
const CefString& title) {
|
||||
REQUIRE_UI_THREAD();
|
||||
const CefString& title) {
|
||||
REQUIRE_UI_THREAD();
|
||||
|
||||
std::string titleStr(title);
|
||||
std::string titleStr(title);
|
||||
|
||||
size_t inHomeDir;
|
||||
std::string home = getenv("HOME");
|
||||
inHomeDir = titleStr.find(home);
|
||||
if (inHomeDir == 0) {
|
||||
titleStr = titleStr.substr(home.length());
|
||||
titleStr.insert(0, "~");
|
||||
}
|
||||
size_t inHomeDir;
|
||||
std::string home = getenv("HOME");
|
||||
inHomeDir = titleStr.find(home);
|
||||
if (inHomeDir == 0) {
|
||||
titleStr = titleStr.substr(home.length());
|
||||
titleStr.insert(0, "~");
|
||||
}
|
||||
|
||||
size_t lastSlash;
|
||||
lastSlash = titleStr.rfind("/");
|
||||
size_t lastSlash;
|
||||
lastSlash = titleStr.rfind("/");
|
||||
|
||||
std::string formatted;
|
||||
if (lastSlash != std::string::npos && lastSlash + 1 < titleStr.length()) {
|
||||
formatted.append(titleStr, lastSlash + 1,
|
||||
titleStr.length() - lastSlash);
|
||||
formatted.append(" (");
|
||||
formatted.append(titleStr, 0, lastSlash);
|
||||
formatted.append(")");
|
||||
} else
|
||||
formatted.append(titleStr);
|
||||
formatted.append(" - atom");
|
||||
std::string formatted;
|
||||
if (lastSlash != std::string::npos && lastSlash + 1 < titleStr.length()) {
|
||||
formatted.append(titleStr, lastSlash + 1, titleStr.length() - lastSlash);
|
||||
formatted.append(" (");
|
||||
formatted.append(titleStr, 0, lastSlash);
|
||||
formatted.append(")");
|
||||
} else
|
||||
formatted.append(titleStr);
|
||||
formatted.append(" - atom");
|
||||
|
||||
GtkWidget* window = gtk_widget_get_ancestor(
|
||||
GTK_WIDGET(browser->GetWindowHandle()), GTK_TYPE_WINDOW);
|
||||
gtk_window_set_title(GTK_WINDOW(window), formatted.c_str());
|
||||
GtkWidget* window = gtk_widget_get_ancestor(
|
||||
GTK_WIDGET(browser->GetWindowHandle()), GTK_TYPE_WINDOW);
|
||||
gtk_window_set_title(GTK_WINDOW(window), formatted.c_str());
|
||||
}
|
||||
|
||||
void ClientHandler::SendNotification(NotificationType type) {
|
||||
// TODO(port): Implement this method.
|
||||
// TODO(port): Implement this method.
|
||||
}
|
||||
|
||||
void ClientHandler::CloseMainWindow() {
|
||||
// TODO(port): Close main window.
|
||||
// TODO(port): Close main window.
|
||||
}
|
||||
|
||||
@@ -14,148 +14,146 @@
|
||||
|
||||
// ClientHandler implementation.
|
||||
class ClientHandler: public CefClient,
|
||||
public CefLifeSpanHandler,
|
||||
public CefLoadHandler,
|
||||
public CefDisplayHandler,
|
||||
public CefFocusHandler,
|
||||
public CefKeyboardHandler,
|
||||
public CefPrintHandler,
|
||||
public CefV8ContextHandler,
|
||||
public CefDragHandler {
|
||||
public CefLifeSpanHandler,
|
||||
public CefLoadHandler,
|
||||
public CefDisplayHandler,
|
||||
public CefFocusHandler,
|
||||
public CefKeyboardHandler,
|
||||
public CefPrintHandler,
|
||||
public CefV8ContextHandler,
|
||||
public CefDragHandler {
|
||||
public:
|
||||
ClientHandler();
|
||||
virtual ~ClientHandler();
|
||||
ClientHandler();
|
||||
virtual ~ClientHandler();
|
||||
|
||||
// CefClient methods
|
||||
virtual CefRefPtr<CefLifeSpanHandler> GetLifeSpanHandler() OVERRIDE {
|
||||
return this;
|
||||
}
|
||||
virtual CefRefPtr<CefLoadHandler> GetLoadHandler() OVERRIDE {
|
||||
return this;
|
||||
}
|
||||
virtual CefRefPtr<CefDisplayHandler> GetDisplayHandler() OVERRIDE {
|
||||
return this;
|
||||
}
|
||||
virtual CefRefPtr<CefFocusHandler> GetFocusHandler() OVERRIDE {
|
||||
return this;
|
||||
}
|
||||
virtual CefRefPtr<CefKeyboardHandler> GetKeyboardHandler() OVERRIDE {
|
||||
return this;
|
||||
}
|
||||
virtual CefRefPtr<CefPrintHandler> GetPrintHandler() OVERRIDE {
|
||||
return this;
|
||||
}
|
||||
virtual CefRefPtr<CefV8ContextHandler> GetV8ContextHandler() OVERRIDE {
|
||||
return this;
|
||||
}
|
||||
virtual CefRefPtr<CefDragHandler> GetDragHandler() OVERRIDE {
|
||||
return this;
|
||||
}
|
||||
// CefClient methods
|
||||
virtual CefRefPtr<CefLifeSpanHandler> GetLifeSpanHandler() OVERRIDE {
|
||||
return this;
|
||||
}
|
||||
virtual CefRefPtr<CefLoadHandler> GetLoadHandler() OVERRIDE {
|
||||
return this;
|
||||
}
|
||||
virtual CefRefPtr<CefDisplayHandler> GetDisplayHandler() OVERRIDE {
|
||||
return this;
|
||||
}
|
||||
virtual CefRefPtr<CefFocusHandler> GetFocusHandler() OVERRIDE {
|
||||
return this;
|
||||
}
|
||||
virtual CefRefPtr<CefKeyboardHandler> GetKeyboardHandler() OVERRIDE {
|
||||
return this;
|
||||
}
|
||||
virtual CefRefPtr<CefPrintHandler> GetPrintHandler() OVERRIDE {
|
||||
return this;
|
||||
}
|
||||
virtual CefRefPtr<CefV8ContextHandler> GetV8ContextHandler() OVERRIDE {
|
||||
return this;
|
||||
}
|
||||
virtual CefRefPtr<CefDragHandler> GetDragHandler() OVERRIDE {
|
||||
return this;
|
||||
}
|
||||
|
||||
// CefLifeSpanHandler methods
|
||||
virtual bool OnBeforePopup(CefRefPtr<CefBrowser> parentBrowser,
|
||||
const CefPopupFeatures& popupFeatures, CefWindowInfo& windowInfo,
|
||||
const CefString& url, CefRefPtr<CefClient>& client,
|
||||
CefBrowserSettings& settings) OVERRIDE;
|
||||
virtual void OnAfterCreated(CefRefPtr<CefBrowser> browser) OVERRIDE;
|
||||
virtual bool DoClose(CefRefPtr<CefBrowser> browser) OVERRIDE;
|
||||
virtual void OnBeforeClose(CefRefPtr<CefBrowser> browser) OVERRIDE;
|
||||
// CefLifeSpanHandler methods
|
||||
virtual bool OnBeforePopup(CefRefPtr<CefBrowser> parentBrowser,
|
||||
const CefPopupFeatures& popupFeatures, CefWindowInfo& windowInfo,
|
||||
const CefString& url, CefRefPtr<CefClient>& client,
|
||||
CefBrowserSettings& settings) OVERRIDE;
|
||||
virtual void OnAfterCreated(CefRefPtr<CefBrowser> browser) OVERRIDE;
|
||||
virtual bool DoClose(CefRefPtr<CefBrowser> browser) OVERRIDE;
|
||||
virtual void OnBeforeClose(CefRefPtr<CefBrowser> browser) OVERRIDE;
|
||||
|
||||
// CefLoadHandler methods
|
||||
virtual void OnLoadStart(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame) OVERRIDE;
|
||||
virtual void OnLoadEnd(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame, int httpStatusCode) OVERRIDE;
|
||||
virtual bool OnLoadError(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame, ErrorCode errorCode,
|
||||
const CefString& failedUrl, CefString& errorText) OVERRIDE;
|
||||
// CefLoadHandler methods
|
||||
virtual void OnLoadStart(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame) OVERRIDE;
|
||||
virtual void OnLoadEnd(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame, int httpStatusCode) OVERRIDE;
|
||||
virtual bool OnLoadError(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame, ErrorCode errorCode,
|
||||
const CefString& failedUrl, CefString& errorText) OVERRIDE;
|
||||
|
||||
// CefDisplayHandler methods
|
||||
virtual void OnNavStateChange(CefRefPtr<CefBrowser> browser, bool canGoBack,
|
||||
bool canGoForward) OVERRIDE;
|
||||
virtual void OnAddressChange(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame, const CefString& url) OVERRIDE;
|
||||
virtual void OnTitleChange(CefRefPtr<CefBrowser> browser,
|
||||
const CefString& title) OVERRIDE;
|
||||
virtual bool OnConsoleMessage(CefRefPtr<CefBrowser> browser,
|
||||
const CefString& message, const CefString& source, int line)
|
||||
OVERRIDE;
|
||||
// CefDisplayHandler methods
|
||||
virtual void OnNavStateChange(CefRefPtr<CefBrowser> browser, bool canGoBack,
|
||||
bool canGoForward) OVERRIDE;
|
||||
virtual void OnAddressChange(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame, const CefString& url) OVERRIDE;
|
||||
virtual void OnTitleChange(CefRefPtr<CefBrowser> browser,
|
||||
const CefString& title) OVERRIDE;
|
||||
virtual bool OnConsoleMessage(CefRefPtr<CefBrowser> browser,
|
||||
const CefString& message, const CefString& source, int line) OVERRIDE;
|
||||
|
||||
// CefFocusHandler methods.
|
||||
virtual void OnFocusedNodeChanged(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame, CefRefPtr<CefDOMNode> node) OVERRIDE;
|
||||
// CefFocusHandler methods.
|
||||
virtual void OnFocusedNodeChanged(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame, CefRefPtr<CefDOMNode> node) OVERRIDE;
|
||||
|
||||
// CefKeyboardHandler methods.
|
||||
virtual bool OnKeyEvent(CefRefPtr<CefBrowser> browser, KeyEventType type,
|
||||
int code, int modifiers, bool isSystemKey, bool isAfterJavaScript)
|
||||
OVERRIDE;
|
||||
// CefKeyboardHandler methods.
|
||||
virtual bool OnKeyEvent(CefRefPtr<CefBrowser> browser, KeyEventType type,
|
||||
int code, int modifiers, bool isSystemKey, bool isAfterJavaScript)
|
||||
OVERRIDE;
|
||||
|
||||
// CefPrintHandler methods.
|
||||
virtual bool GetPrintHeaderFooter(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame, const CefPrintInfo& printInfo,
|
||||
const CefString& url, const CefString& title, int currentPage,
|
||||
int maxPages, CefString& topLeft, CefString& topCenter,
|
||||
CefString& topRight, CefString& bottomLeft, CefString& bottomCenter,
|
||||
CefString& bottomRight) OVERRIDE;
|
||||
// CefPrintHandler methods.
|
||||
virtual bool GetPrintHeaderFooter(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame, const CefPrintInfo& printInfo,
|
||||
const CefString& url, const CefString& title, int currentPage,
|
||||
int maxPages, CefString& topLeft, CefString& topCenter,
|
||||
CefString& topRight, CefString& bottomLeft, CefString& bottomCenter,
|
||||
CefString& bottomRight) OVERRIDE;
|
||||
|
||||
// CefV8ContextHandler methods
|
||||
virtual void OnContextCreated(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame, CefRefPtr<CefV8Context> context)
|
||||
OVERRIDE;
|
||||
// CefV8ContextHandler methods
|
||||
virtual void OnContextCreated(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame, CefRefPtr<CefV8Context> context) OVERRIDE;
|
||||
|
||||
// CefDragHandler methods.
|
||||
virtual bool OnDragStart(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefDragData> dragData, DragOperationsMask mask) OVERRIDE;
|
||||
virtual bool OnDragEnter(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefDragData> dragData, DragOperationsMask mask) OVERRIDE;
|
||||
// CefDragHandler methods.
|
||||
virtual bool OnDragStart(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefDragData> dragData, DragOperationsMask mask) OVERRIDE;
|
||||
virtual bool OnDragEnter(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefDragData> dragData, DragOperationsMask mask) OVERRIDE;
|
||||
|
||||
void SetWindow(GtkWidget* window);
|
||||
void SetMainHwnd(CefWindowHandle hwnd);
|
||||
CefWindowHandle GetMainHwnd() {
|
||||
return m_MainHwnd;
|
||||
}
|
||||
void SetEditHwnd(CefWindowHandle hwnd);
|
||||
void SetWindow(GtkWidget* window);
|
||||
void SetMainHwnd(CefWindowHandle hwnd);
|
||||
CefWindowHandle GetMainHwnd() {
|
||||
return m_MainHwnd;
|
||||
}
|
||||
void SetEditHwnd(CefWindowHandle hwnd);
|
||||
|
||||
CefRefPtr<CefBrowser> GetBrowser() {
|
||||
return m_Browser;
|
||||
}
|
||||
CefWindowHandle GetBrowserHwnd() {
|
||||
return m_BrowserHwnd;
|
||||
}
|
||||
CefRefPtr<CefBrowser> GetBrowser() {
|
||||
return m_Browser;
|
||||
}
|
||||
CefWindowHandle GetBrowserHwnd() {
|
||||
return m_BrowserHwnd;
|
||||
}
|
||||
|
||||
enum NotificationType {
|
||||
NOTIFY_CONSOLE_MESSAGE
|
||||
};
|
||||
void SendNotification(NotificationType type);
|
||||
void CloseMainWindow();
|
||||
enum NotificationType {
|
||||
NOTIFY_CONSOLE_MESSAGE
|
||||
};
|
||||
void SendNotification(NotificationType type);
|
||||
void CloseMainWindow();
|
||||
|
||||
protected:
|
||||
|
||||
GtkWidget* window;
|
||||
GtkWidget* window;
|
||||
|
||||
CefRefPtr<NativeHandler> m_nativeHandler;
|
||||
CefRefPtr<NativeHandler> m_nativeHandler;
|
||||
|
||||
// The child browser window
|
||||
CefRefPtr<CefBrowser> m_Browser;
|
||||
// The child browser window
|
||||
CefRefPtr<CefBrowser> m_Browser;
|
||||
|
||||
// The main frame window handle
|
||||
CefWindowHandle m_MainHwnd;
|
||||
// The main frame window handle
|
||||
CefWindowHandle m_MainHwnd;
|
||||
|
||||
// The child browser window handle
|
||||
CefWindowHandle m_BrowserHwnd;
|
||||
// The child browser window handle
|
||||
CefWindowHandle m_BrowserHwnd;
|
||||
|
||||
// The edit window handle
|
||||
CefWindowHandle m_EditHwnd;
|
||||
// The edit window handle
|
||||
CefWindowHandle m_EditHwnd;
|
||||
|
||||
// Support for logging.
|
||||
std::string m_LogFile;
|
||||
// Support for logging.
|
||||
std::string m_LogFile;
|
||||
|
||||
// Include the default reference counting implementation.
|
||||
// Include the default reference counting implementation.
|
||||
IMPLEMENT_REFCOUNTING(ClientHandler)
|
||||
;
|
||||
// Include the default locking implementation.
|
||||
;
|
||||
// Include the default locking implementation.
|
||||
IMPLEMENT_LOCKING(ClientHandler)
|
||||
;
|
||||
;
|
||||
};
|
||||
|
||||
#endif // CEF_TESTS_CEFCLIENT_CLIENT_HANDLER_H_
|
||||
|
||||
@@ -21,467 +21,465 @@
|
||||
using namespace std;
|
||||
|
||||
void *NotifyWatchersCallback(void* pointer) {
|
||||
NativeHandler* handler = (NativeHandler*) pointer;
|
||||
handler->NotifyWatchers();
|
||||
return NULL;
|
||||
NativeHandler* handler = (NativeHandler*) pointer;
|
||||
handler->NotifyWatchers();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void ExecuteWatchCallback(NotifyContext notifyContext) {
|
||||
map<string, CallbackContext> callbacks =
|
||||
notifyContext.callbacks[notifyContext.descriptor];
|
||||
map<string, CallbackContext>::iterator callback;
|
||||
for (callback = callbacks.begin(); callback != callbacks.end();
|
||||
callback++) {
|
||||
CallbackContext callbackContext = callback->second;
|
||||
CefRefPtr<CefV8Context> context = callbackContext.context;
|
||||
CefRefPtr<CefV8Value> function = callbackContext.function;
|
||||
map<string, CallbackContext> callbacks =
|
||||
notifyContext.callbacks[notifyContext.descriptor];
|
||||
map<string, CallbackContext>::iterator callback;
|
||||
for (callback = callbacks.begin(); callback != callbacks.end(); callback++) {
|
||||
CallbackContext callbackContext = callback->second;
|
||||
CefRefPtr<CefV8Context> context = callbackContext.context;
|
||||
CefRefPtr<CefV8Value> function = callbackContext.function;
|
||||
|
||||
context->Enter();
|
||||
context->Enter();
|
||||
|
||||
CefV8ValueList args;
|
||||
CefRefPtr<CefV8Value> retval;
|
||||
CefRefPtr<CefV8Exception> e;
|
||||
args.push_back(callbackContext.eventTypes);
|
||||
function->ExecuteFunction(function, args, retval, e, true);
|
||||
CefV8ValueList args;
|
||||
CefRefPtr<CefV8Value> retval;
|
||||
CefRefPtr<CefV8Exception> e;
|
||||
args.push_back(callbackContext.eventTypes);
|
||||
function->ExecuteFunction(function, args, retval, e, true);
|
||||
|
||||
context->Exit();
|
||||
}
|
||||
context->Exit();
|
||||
}
|
||||
}
|
||||
|
||||
NativeHandler::NativeHandler() :
|
||||
CefV8Handler() {
|
||||
object = CefV8Value::CreateObject(NULL, NULL);
|
||||
CefV8Handler() {
|
||||
object = CefV8Value::CreateObject(NULL, NULL);
|
||||
|
||||
const char *functionNames[] = { "exists", "alert", "read", "write",
|
||||
"absolute", "list", "isFile", "isDirectory", "remove", "asyncList",
|
||||
"open", "openDialog", "quit", "writeToPasteboard",
|
||||
"readFromPasteboard", "showDevTools", "newWindow", "saveDialog",
|
||||
"exit", "watchPath", "unwatchPath", "makeDirectory", "move",
|
||||
"moveToTrash" };
|
||||
int arrayLength = sizeof(functionNames) / sizeof(const char *);
|
||||
for (int i = 0; i < arrayLength; i++) {
|
||||
const char *functionName = functionNames[i];
|
||||
CefRefPtr<CefV8Value> function = CefV8Value::CreateFunction(
|
||||
functionName, this);
|
||||
object->SetValue(functionName, function, V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
}
|
||||
const char *functionNames[] = { "exists", "alert", "read", "write",
|
||||
"absolute", "list", "isFile", "isDirectory", "remove", "asyncList",
|
||||
"open", "openDialog", "quit", "writeToPasteboard", "readFromPasteboard",
|
||||
"showDevTools", "newWindow", "saveDialog", "exit", "watchPath",
|
||||
"unwatchPath", "makeDirectory", "move", "moveToTrash" };
|
||||
int arrayLength = sizeof(functionNames) / sizeof(const char *);
|
||||
for (int i = 0; i < arrayLength; i++) {
|
||||
const char *functionName = functionNames[i];
|
||||
CefRefPtr<CefV8Value> function = CefV8Value::CreateFunction(functionName,
|
||||
this);
|
||||
object->SetValue(functionName, function, V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
}
|
||||
|
||||
notifyFd = inotify_init();
|
||||
if (notifyFd != -1)
|
||||
g_thread_create_full(NotifyWatchersCallback, this, 0, true, false,
|
||||
G_THREAD_PRIORITY_NORMAL, NULL);
|
||||
notifyFd = inotify_init();
|
||||
if (notifyFd != -1)
|
||||
g_thread_create_full(NotifyWatchersCallback, this, 0, true, false,
|
||||
G_THREAD_PRIORITY_NORMAL, NULL);
|
||||
}
|
||||
|
||||
void NativeHandler::NotifyWatchers() {
|
||||
char buffer[BUFFER_SIZE];
|
||||
ssize_t bufferRead;
|
||||
size_t eventSize;
|
||||
ssize_t bufferIndex;
|
||||
struct inotify_event *event;
|
||||
bufferRead = read(notifyFd, buffer, BUFFER_SIZE);
|
||||
while (bufferRead > 0) {
|
||||
bufferIndex = 0;
|
||||
while (bufferIndex < bufferRead) {
|
||||
event = (struct inotify_event *) &buffer[bufferIndex];
|
||||
eventSize = offsetof (struct inotify_event, name) + event->len;
|
||||
char buffer[BUFFER_SIZE];
|
||||
ssize_t bufferRead;
|
||||
size_t eventSize;
|
||||
ssize_t bufferIndex;
|
||||
struct inotify_event *event;
|
||||
bufferRead = read(notifyFd, buffer, BUFFER_SIZE);
|
||||
while (bufferRead > 0) {
|
||||
bufferIndex = 0;
|
||||
while (bufferIndex < bufferRead) {
|
||||
event = (struct inotify_event *) &buffer[bufferIndex];
|
||||
eventSize = offsetof (struct inotify_event, name) + event->len;
|
||||
|
||||
NotifyContext context;
|
||||
context.descriptor = event->wd;
|
||||
context.callbacks = pathCallbacks;
|
||||
CefPostTask(TID_UI,
|
||||
NewCefRunnableFunction(&ExecuteWatchCallback, context));
|
||||
NotifyContext context;
|
||||
context.descriptor = event->wd;
|
||||
context.callbacks = pathCallbacks;
|
||||
CefPostTask(TID_UI,
|
||||
NewCefRunnableFunction(&ExecuteWatchCallback, context));
|
||||
|
||||
bufferIndex += eventSize;
|
||||
}
|
||||
bufferRead = read(notifyFd, buffer, BUFFER_SIZE);
|
||||
}
|
||||
bufferIndex += eventSize;
|
||||
}
|
||||
bufferRead = read(notifyFd, buffer, BUFFER_SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
void NativeHandler::Exists(const CefString& name, CefRefPtr<CefV8Value> object,
|
||||
const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval,
|
||||
CefString& exception) {
|
||||
string path = arguments[0]->GetStringValue().ToString();
|
||||
struct stat statInfo;
|
||||
int result = stat(path.c_str(), &statInfo);
|
||||
retval = CefV8Value::CreateBool(result == 0);
|
||||
const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval,
|
||||
CefString& exception) {
|
||||
string path = arguments[0]->GetStringValue().ToString();
|
||||
struct stat statInfo;
|
||||
int result = stat(path.c_str(), &statInfo);
|
||||
retval = CefV8Value::CreateBool(result == 0);
|
||||
}
|
||||
|
||||
void NativeHandler::Read(const CefString& name, CefRefPtr<CefV8Value> object,
|
||||
const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval,
|
||||
CefString& exception) {
|
||||
string path = arguments[0]->GetStringValue().ToString();
|
||||
int fd = open(path.c_str(), O_RDONLY);
|
||||
if (fd < 0)
|
||||
return;
|
||||
const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval,
|
||||
CefString& exception) {
|
||||
string path = arguments[0]->GetStringValue().ToString();
|
||||
int fd = open(path.c_str(), O_RDONLY);
|
||||
if (fd < 0)
|
||||
return;
|
||||
|
||||
char buffer[8192];
|
||||
int r;
|
||||
string value;
|
||||
while ((r = read(fd, buffer, sizeof buffer)) > 0)
|
||||
value.append(buffer, 0, r);
|
||||
close(fd);
|
||||
retval = CefV8Value::CreateString(value);
|
||||
char buffer[8192];
|
||||
int r;
|
||||
string value;
|
||||
while ((r = read(fd, buffer, sizeof buffer)) > 0)
|
||||
value.append(buffer, 0, r);
|
||||
close(fd);
|
||||
retval = CefV8Value::CreateString(value);
|
||||
}
|
||||
|
||||
void NativeHandler::Absolute(const CefString& name,
|
||||
CefRefPtr<CefV8Value> object, const CefV8ValueList& arguments,
|
||||
CefRefPtr<CefV8Value>& retval, CefString& exception) {
|
||||
string path = arguments[0]->GetStringValue().ToString();
|
||||
string relativePath;
|
||||
if (path[0] != '~')
|
||||
relativePath.append(path);
|
||||
else {
|
||||
relativePath.append(getenv("HOME"));
|
||||
relativePath.append(path, 1, path.length() - 1);
|
||||
}
|
||||
CefRefPtr<CefV8Value> object, const CefV8ValueList& arguments,
|
||||
CefRefPtr<CefV8Value>& retval, CefString& exception) {
|
||||
string path = arguments[0]->GetStringValue().ToString();
|
||||
string relativePath;
|
||||
if (path[0] != '~')
|
||||
relativePath.append(path);
|
||||
else {
|
||||
relativePath.append(getenv("HOME"));
|
||||
relativePath.append(path, 1, path.length() - 1);
|
||||
}
|
||||
|
||||
vector < string > segments;
|
||||
char allSegments[relativePath.length() + 1];
|
||||
strcpy(allSegments, relativePath.c_str());
|
||||
const char* segment;
|
||||
for (segment = strtok(allSegments, "/"); segment;
|
||||
segment = strtok(NULL, "/")) {
|
||||
if (strcmp(segment, ".") == 0)
|
||||
continue;
|
||||
if (strcmp(segment, "..") == 0) {
|
||||
if (segments.empty()) {
|
||||
retval = CefV8Value::CreateString("/");
|
||||
return;
|
||||
}
|
||||
segments.pop_back();
|
||||
} else
|
||||
segments.push_back(segment);
|
||||
}
|
||||
vector < string > segments;
|
||||
char allSegments[relativePath.length() + 1];
|
||||
strcpy(allSegments, relativePath.c_str());
|
||||
const char* segment;
|
||||
for (segment = strtok(allSegments, "/"); segment;
|
||||
segment = strtok(NULL, "/")) {
|
||||
if (strcmp(segment, ".") == 0)
|
||||
continue;
|
||||
if (strcmp(segment, "..") == 0) {
|
||||
if (segments.empty()) {
|
||||
retval = CefV8Value::CreateString("/");
|
||||
return;
|
||||
}
|
||||
segments.pop_back();
|
||||
} else
|
||||
segments.push_back(segment);
|
||||
}
|
||||
|
||||
string absolutePath;
|
||||
unsigned int i;
|
||||
for (i = 0; i < segments.size(); i++) {
|
||||
absolutePath.append("/");
|
||||
absolutePath.append(segments.at(i));
|
||||
}
|
||||
retval = CefV8Value::CreateString(absolutePath);
|
||||
string absolutePath;
|
||||
unsigned int i;
|
||||
for (i = 0; i < segments.size(); i++) {
|
||||
absolutePath.append("/");
|
||||
absolutePath.append(segments.at(i));
|
||||
}
|
||||
retval = CefV8Value::CreateString(absolutePath);
|
||||
}
|
||||
|
||||
void ListDirectory(string path, vector<string>* paths, bool recursive) {
|
||||
dirent **children;
|
||||
int childrenCount = scandir(path.c_str(), &children, 0, alphasort);
|
||||
struct stat statInfo;
|
||||
int result;
|
||||
dirent **children;
|
||||
int childrenCount = scandir(path.c_str(), &children, 0, alphasort);
|
||||
struct stat statInfo;
|
||||
int result;
|
||||
|
||||
for (int i = 0; i < childrenCount; i++) {
|
||||
if (strcmp(children[i]->d_name, ".") == 0
|
||||
|| strcmp(children[i]->d_name, "..") == 0) {
|
||||
free(children[i]);
|
||||
continue;
|
||||
}
|
||||
string entryPath(path + "/" + children[i]->d_name);
|
||||
paths->push_back(entryPath);
|
||||
if (recursive) {
|
||||
result = stat(entryPath.c_str(), &statInfo);
|
||||
if (result == 0 && S_ISDIR(statInfo.st_mode))
|
||||
ListDirectory(entryPath, paths, recursive);
|
||||
}
|
||||
free(children[i]);
|
||||
}
|
||||
free(children);
|
||||
for (int i = 0; i < childrenCount; i++) {
|
||||
if (strcmp(children[i]->d_name, ".") == 0
|
||||
|| strcmp(children[i]->d_name, "..") == 0) {
|
||||
free(children[i]);
|
||||
continue;
|
||||
}
|
||||
string entryPath(path + "/" + children[i]->d_name);
|
||||
paths->push_back(entryPath);
|
||||
if (recursive) {
|
||||
result = stat(entryPath.c_str(), &statInfo);
|
||||
if (result == 0 && S_ISDIR(statInfo.st_mode))
|
||||
ListDirectory(entryPath, paths, recursive);
|
||||
}
|
||||
free(children[i]);
|
||||
}
|
||||
free(children);
|
||||
}
|
||||
|
||||
void DeleteContents(string path) {
|
||||
dirent **children;
|
||||
const char* dirPath = path.c_str();
|
||||
int childrenCount = scandir(dirPath, &children, 0, alphasort);
|
||||
struct stat statInfo;
|
||||
dirent **children;
|
||||
const char* dirPath = path.c_str();
|
||||
int childrenCount = scandir(dirPath, &children, 0, alphasort);
|
||||
struct stat statInfo;
|
||||
|
||||
for (int i = 0; i < childrenCount; i++) {
|
||||
if (strcmp(children[i]->d_name, ".") == 0
|
||||
|| strcmp(children[i]->d_name, "..") == 0) {
|
||||
free(children[i]);
|
||||
continue;
|
||||
}
|
||||
for (int i = 0; i < childrenCount; i++) {
|
||||
if (strcmp(children[i]->d_name, ".") == 0
|
||||
|| strcmp(children[i]->d_name, "..") == 0) {
|
||||
free(children[i]);
|
||||
continue;
|
||||
}
|
||||
|
||||
string entryPath(path + "/" + children[i]->d_name);
|
||||
if (stat(entryPath.c_str(), &statInfo) != 0) {
|
||||
free(children[i]);
|
||||
continue;
|
||||
}
|
||||
string entryPath(path + "/" + children[i]->d_name);
|
||||
if (stat(entryPath.c_str(), &statInfo) != 0) {
|
||||
free(children[i]);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (S_ISDIR(statInfo.st_mode))
|
||||
DeleteContents(entryPath);
|
||||
else if (S_ISREG(statInfo.st_mode))
|
||||
remove(entryPath.c_str());
|
||||
}
|
||||
free(children);
|
||||
rmdir(dirPath);
|
||||
if (S_ISDIR(statInfo.st_mode))
|
||||
DeleteContents(entryPath);
|
||||
else if (S_ISREG(statInfo.st_mode))
|
||||
remove(entryPath.c_str());
|
||||
}
|
||||
free(children);
|
||||
rmdir(dirPath);
|
||||
}
|
||||
|
||||
void NativeHandler::List(const CefString& name, CefRefPtr<CefV8Value> object,
|
||||
const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval,
|
||||
CefString& exception) {
|
||||
string path = arguments[0]->GetStringValue().ToString();
|
||||
bool recursive = arguments[1]->GetBoolValue();
|
||||
vector < string > *paths = new vector<string>;
|
||||
ListDirectory(path, paths, recursive);
|
||||
const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval,
|
||||
CefString& exception) {
|
||||
string path = arguments[0]->GetStringValue().ToString();
|
||||
bool recursive = arguments[1]->GetBoolValue();
|
||||
vector < string > *paths = new vector<string>;
|
||||
ListDirectory(path, paths, recursive);
|
||||
|
||||
retval = CefV8Value::CreateArray();
|
||||
for (uint i = 0; i < paths->size(); i++)
|
||||
retval->SetValue(i, CefV8Value::CreateString(paths->at(i)));
|
||||
free (paths);
|
||||
retval = CefV8Value::CreateArray();
|
||||
for (uint i = 0; i < paths->size(); i++)
|
||||
retval->SetValue(i, CefV8Value::CreateString(paths->at(i)));
|
||||
free (paths);
|
||||
}
|
||||
|
||||
void NativeHandler::IsFile(const CefString& name, CefRefPtr<CefV8Value> object,
|
||||
const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval,
|
||||
CefString& exception) {
|
||||
string path = arguments[0]->GetStringValue().ToString();
|
||||
struct stat statInfo;
|
||||
int result = stat(path.c_str(), &statInfo);
|
||||
retval = CefV8Value::CreateBool(result == 0 && S_ISREG(statInfo.st_mode));
|
||||
const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval,
|
||||
CefString& exception) {
|
||||
string path = arguments[0]->GetStringValue().ToString();
|
||||
struct stat statInfo;
|
||||
int result = stat(path.c_str(), &statInfo);
|
||||
retval = CefV8Value::CreateBool(result == 0 && S_ISREG(statInfo.st_mode));
|
||||
}
|
||||
|
||||
void NativeHandler::IsDirectory(const CefString& name,
|
||||
CefRefPtr<CefV8Value> object, const CefV8ValueList& arguments,
|
||||
CefRefPtr<CefV8Value>& retval, CefString& exception) {
|
||||
string path = arguments[0]->GetStringValue().ToString();
|
||||
struct stat statInfo;
|
||||
int result = stat(path.c_str(), &statInfo);
|
||||
retval = CefV8Value::CreateBool(result == 0 && S_ISDIR(statInfo.st_mode));
|
||||
CefRefPtr<CefV8Value> object, const CefV8ValueList& arguments,
|
||||
CefRefPtr<CefV8Value>& retval, CefString& exception) {
|
||||
string path = arguments[0]->GetStringValue().ToString();
|
||||
struct stat statInfo;
|
||||
int result = stat(path.c_str(), &statInfo);
|
||||
retval = CefV8Value::CreateBool(result == 0 && S_ISDIR(statInfo.st_mode));
|
||||
}
|
||||
|
||||
void NativeHandler::OpenDialog(const CefString& name,
|
||||
CefRefPtr<CefV8Value> object, const CefV8ValueList& arguments,
|
||||
CefRefPtr<CefV8Value>& retval, CefString& exception) {
|
||||
GtkWidget *dialog;
|
||||
dialog = gtk_file_chooser_dialog_new("Open File", GTK_WINDOW(window),
|
||||
GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
||||
GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL);
|
||||
if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
|
||||
char *filename;
|
||||
filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
|
||||
retval = CefV8Value::CreateString(filename);
|
||||
g_free(filename);
|
||||
} else
|
||||
retval = CefV8Value::CreateNull();
|
||||
CefRefPtr<CefV8Value> object, const CefV8ValueList& arguments,
|
||||
CefRefPtr<CefV8Value>& retval, CefString& exception) {
|
||||
GtkWidget *dialog;
|
||||
dialog = gtk_file_chooser_dialog_new("Open File", GTK_WINDOW(window),
|
||||
GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
||||
GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL);
|
||||
if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
|
||||
char *filename;
|
||||
filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
|
||||
retval = CefV8Value::CreateString(filename);
|
||||
g_free(filename);
|
||||
} else
|
||||
retval = CefV8Value::CreateNull();
|
||||
|
||||
gtk_widget_destroy(dialog);
|
||||
gtk_widget_destroy(dialog);
|
||||
}
|
||||
|
||||
void NativeHandler::Open(const CefString& name, CefRefPtr<CefV8Value> object,
|
||||
const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval,
|
||||
CefString& exception) {
|
||||
path = arguments[0]->GetStringValue().ToString();
|
||||
CefV8Context::GetCurrentContext()->GetBrowser()->Reload();
|
||||
const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval,
|
||||
CefString& exception) {
|
||||
path = arguments[0]->GetStringValue().ToString();
|
||||
CefV8Context::GetCurrentContext()->GetBrowser()->Reload();
|
||||
}
|
||||
|
||||
void NativeHandler::Write(const CefString& name, CefRefPtr<CefV8Value> object,
|
||||
const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval,
|
||||
CefString& exception) {
|
||||
string path = arguments[0]->GetStringValue().ToString();
|
||||
string content = arguments[1]->GetStringValue().ToString();
|
||||
const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval,
|
||||
CefString& exception) {
|
||||
string path = arguments[0]->GetStringValue().ToString();
|
||||
string content = arguments[1]->GetStringValue().ToString();
|
||||
|
||||
ofstream myfile;
|
||||
myfile.open(path.c_str());
|
||||
myfile << content;
|
||||
myfile.close();
|
||||
ofstream myfile;
|
||||
myfile.open(path.c_str());
|
||||
myfile << content;
|
||||
myfile.close();
|
||||
}
|
||||
|
||||
void NativeHandler::WriteToPasteboard(const CefString& name,
|
||||
CefRefPtr<CefV8Value> object, const CefV8ValueList& arguments,
|
||||
CefRefPtr<CefV8Value>& retval, CefString& exception) {
|
||||
string content = arguments[0]->GetStringValue().ToString();
|
||||
GtkClipboard* clipboard = gtk_clipboard_get_for_display(
|
||||
gdk_display_get_default(), GDK_NONE);
|
||||
gtk_clipboard_set_text(clipboard, content.c_str(), content.length());
|
||||
gtk_clipboard_store(clipboard);
|
||||
CefRefPtr<CefV8Value> object, const CefV8ValueList& arguments,
|
||||
CefRefPtr<CefV8Value>& retval, CefString& exception) {
|
||||
string content = arguments[0]->GetStringValue().ToString();
|
||||
GtkClipboard* clipboard = gtk_clipboard_get_for_display(
|
||||
gdk_display_get_default(), GDK_NONE);
|
||||
gtk_clipboard_set_text(clipboard, content.c_str(), content.length());
|
||||
gtk_clipboard_store(clipboard);
|
||||
}
|
||||
|
||||
void NativeHandler::ReadFromPasteboard(const CefString& name,
|
||||
CefRefPtr<CefV8Value> object, const CefV8ValueList& arguments,
|
||||
CefRefPtr<CefV8Value>& retval, CefString& exception) {
|
||||
GtkClipboard* clipboard = gtk_clipboard_get_for_display(
|
||||
gdk_display_get_default(), GDK_NONE);
|
||||
char* content = gtk_clipboard_wait_for_text(clipboard);
|
||||
retval = CefV8Value::CreateString(content);
|
||||
CefRefPtr<CefV8Value> object, const CefV8ValueList& arguments,
|
||||
CefRefPtr<CefV8Value>& retval, CefString& exception) {
|
||||
GtkClipboard* clipboard = gtk_clipboard_get_for_display(
|
||||
gdk_display_get_default(), GDK_NONE);
|
||||
char* content = gtk_clipboard_wait_for_text(clipboard);
|
||||
retval = CefV8Value::CreateString(content);
|
||||
}
|
||||
|
||||
void NativeHandler::AsyncList(const CefString& name,
|
||||
CefRefPtr<CefV8Value> object, const CefV8ValueList& arguments,
|
||||
CefRefPtr<CefV8Value>& retval, CefString& exception) {
|
||||
string path = arguments[0]->GetStringValue().ToString();
|
||||
bool recursive = arguments[1]->GetBoolValue();
|
||||
vector < string > *paths = new vector<string>;
|
||||
ListDirectory(path, paths, recursive);
|
||||
CefRefPtr<CefV8Value> object, const CefV8ValueList& arguments,
|
||||
CefRefPtr<CefV8Value>& retval, CefString& exception) {
|
||||
string path = arguments[0]->GetStringValue().ToString();
|
||||
bool recursive = arguments[1]->GetBoolValue();
|
||||
vector < string > *paths = new vector<string>;
|
||||
ListDirectory(path, paths, recursive);
|
||||
|
||||
CefRefPtr<CefV8Value> callbackPaths = CefV8Value::CreateArray();
|
||||
for (uint i = 0; i < paths->size(); i++)
|
||||
callbackPaths->SetValue(i, CefV8Value::CreateString(paths->at(i)));
|
||||
CefV8ValueList args;
|
||||
args.push_back(callbackPaths);
|
||||
CefRefPtr<CefV8Exception> e;
|
||||
arguments[2]->ExecuteFunction(arguments[2], args, retval, e, true);
|
||||
if (e)
|
||||
exception = e->GetMessage();
|
||||
free (paths);
|
||||
CefRefPtr<CefV8Value> callbackPaths = CefV8Value::CreateArray();
|
||||
for (uint i = 0; i < paths->size(); i++)
|
||||
callbackPaths->SetValue(i, CefV8Value::CreateString(paths->at(i)));
|
||||
CefV8ValueList args;
|
||||
args.push_back(callbackPaths);
|
||||
CefRefPtr<CefV8Exception> e;
|
||||
arguments[2]->ExecuteFunction(arguments[2], args, retval, e, true);
|
||||
if (e)
|
||||
exception = e->GetMessage();
|
||||
free (paths);
|
||||
}
|
||||
|
||||
void NativeHandler::MakeDirectory(const CefString& name,
|
||||
CefRefPtr<CefV8Value> object, const CefV8ValueList& arguments,
|
||||
CefRefPtr<CefV8Value>& retval, CefString& exception) {
|
||||
string content = arguments[0]->GetStringValue().ToString();
|
||||
mkdir(content.c_str(), S_IRWXU);
|
||||
CefRefPtr<CefV8Value> object, const CefV8ValueList& arguments,
|
||||
CefRefPtr<CefV8Value>& retval, CefString& exception) {
|
||||
string content = arguments[0]->GetStringValue().ToString();
|
||||
mkdir(content.c_str(), S_IRWXU);
|
||||
}
|
||||
|
||||
void NativeHandler::Move(const CefString& name, CefRefPtr<CefV8Value> object,
|
||||
const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval,
|
||||
CefString& exception) {
|
||||
string from = arguments[0]->GetStringValue().ToString();
|
||||
string to = arguments[1]->GetStringValue().ToString();
|
||||
rename(from.c_str(), to.c_str());
|
||||
const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval,
|
||||
CefString& exception) {
|
||||
string from = arguments[0]->GetStringValue().ToString();
|
||||
string to = arguments[1]->GetStringValue().ToString();
|
||||
rename(from.c_str(), to.c_str());
|
||||
}
|
||||
|
||||
void NativeHandler::Remove(const CefString& name, CefRefPtr<CefV8Value> object,
|
||||
const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval,
|
||||
CefString& exception) {
|
||||
string pathArgument = arguments[0]->GetStringValue().ToString();
|
||||
const char* path = pathArgument.c_str();
|
||||
const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval,
|
||||
CefString& exception) {
|
||||
string pathArgument = arguments[0]->GetStringValue().ToString();
|
||||
const char* path = pathArgument.c_str();
|
||||
|
||||
struct stat statInfo;
|
||||
if (stat(path, &statInfo) != 0)
|
||||
return;
|
||||
struct stat statInfo;
|
||||
if (stat(path, &statInfo) != 0)
|
||||
return;
|
||||
|
||||
if (S_ISREG(statInfo.st_mode))
|
||||
remove(path);
|
||||
else if (S_ISDIR(statInfo.st_mode))
|
||||
DeleteContents(pathArgument);
|
||||
if (S_ISREG(statInfo.st_mode))
|
||||
remove(path);
|
||||
else if (S_ISDIR(statInfo.st_mode))
|
||||
DeleteContents(pathArgument);
|
||||
}
|
||||
|
||||
void NativeHandler::Alert(const CefString& name, CefRefPtr<CefV8Value> object,
|
||||
const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval,
|
||||
CefString& exception) {
|
||||
CefRefPtr<CefV8Value> buttonNamesAndCallbacks;
|
||||
if (arguments.size() < 3)
|
||||
buttonNamesAndCallbacks = CefV8Value::CreateArray();
|
||||
else
|
||||
buttonNamesAndCallbacks = arguments[2];
|
||||
const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval,
|
||||
CefString& exception) {
|
||||
CefRefPtr<CefV8Value> buttonNamesAndCallbacks;
|
||||
if (arguments.size() < 3)
|
||||
buttonNamesAndCallbacks = CefV8Value::CreateArray();
|
||||
else
|
||||
buttonNamesAndCallbacks = arguments[2];
|
||||
|
||||
GtkWidget *dialog;
|
||||
dialog = gtk_dialog_new_with_buttons("atom", GTK_WINDOW(window),
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT, NULL);
|
||||
for (int i = 0; i < buttonNamesAndCallbacks->GetArrayLength(); i++) {
|
||||
string title =
|
||||
buttonNamesAndCallbacks->GetValue(i)->GetValue(0)->GetStringValue().ToString();
|
||||
gtk_dialog_add_button(GTK_DIALOG(dialog), title.c_str(), i);
|
||||
}
|
||||
gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
|
||||
GtkWidget *dialog;
|
||||
dialog = gtk_dialog_new_with_buttons("atom", GTK_WINDOW(window),
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT, NULL);
|
||||
for (int i = 0; i < buttonNamesAndCallbacks->GetArrayLength(); i++) {
|
||||
string title =
|
||||
buttonNamesAndCallbacks->GetValue(i)->GetValue(0)->GetStringValue().ToString();
|
||||
gtk_dialog_add_button(GTK_DIALOG(dialog), title.c_str(), i);
|
||||
}
|
||||
gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
|
||||
|
||||
string dialogMessage(arguments[0]->GetStringValue().ToString());
|
||||
dialogMessage.append("\n\n");
|
||||
dialogMessage.append(arguments[1]->GetStringValue().ToString());
|
||||
GtkWidget *label;
|
||||
label = gtk_label_new(dialogMessage.c_str());
|
||||
string dialogMessage(arguments[0]->GetStringValue().ToString());
|
||||
dialogMessage.append("\n\n");
|
||||
dialogMessage.append(arguments[1]->GetStringValue().ToString());
|
||||
GtkWidget *label;
|
||||
label = gtk_label_new(dialogMessage.c_str());
|
||||
|
||||
GtkWidget *contentArea;
|
||||
contentArea = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
|
||||
gtk_container_add(GTK_CONTAINER(contentArea), label);
|
||||
GtkWidget *contentArea;
|
||||
contentArea = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
|
||||
gtk_container_add(GTK_CONTAINER(contentArea), label);
|
||||
|
||||
gtk_widget_show_all(dialog);
|
||||
int result = gtk_dialog_run(GTK_DIALOG(dialog));
|
||||
if (result >= 0) {
|
||||
CefRefPtr<CefV8Value> callback = buttonNamesAndCallbacks->GetValue(
|
||||
result)->GetValue(1);
|
||||
CefV8ValueList args;
|
||||
CefRefPtr<CefV8Exception> e;
|
||||
callback->ExecuteFunction(callback, args, retval, e, true);
|
||||
if (e)
|
||||
exception = e->GetMessage();
|
||||
}
|
||||
gtk_widget_destroy(dialog);
|
||||
gtk_widget_show_all(dialog);
|
||||
int result = gtk_dialog_run(GTK_DIALOG(dialog));
|
||||
if (result >= 0) {
|
||||
CefRefPtr<CefV8Value> callback =
|
||||
buttonNamesAndCallbacks->GetValue(result)->GetValue(1);
|
||||
CefV8ValueList args;
|
||||
CefRefPtr<CefV8Exception> e;
|
||||
callback->ExecuteFunction(callback, args, retval, e, true);
|
||||
if (e)
|
||||
exception = e->GetMessage();
|
||||
}
|
||||
gtk_widget_destroy(dialog);
|
||||
}
|
||||
|
||||
void NativeHandler::WatchPath(const CefString& name,
|
||||
CefRefPtr<CefV8Value> object, const CefV8ValueList& arguments,
|
||||
CefRefPtr<CefV8Value>& retval, CefString& exception) {
|
||||
string path = arguments[0]->GetStringValue().ToString();
|
||||
int descriptor = inotify_add_watch(notifyFd, path.c_str(),
|
||||
IN_ALL_EVENTS & ~(IN_CLOSE | IN_OPEN | IN_ACCESS));
|
||||
if (descriptor == -1)
|
||||
return;
|
||||
CefRefPtr<CefV8Value> object, const CefV8ValueList& arguments,
|
||||
CefRefPtr<CefV8Value>& retval, CefString& exception) {
|
||||
string path = arguments[0]->GetStringValue().ToString();
|
||||
int descriptor = inotify_add_watch(notifyFd, path.c_str(),
|
||||
IN_ALL_EVENTS & ~(IN_CLOSE | IN_OPEN | IN_ACCESS));
|
||||
if (descriptor == -1)
|
||||
return;
|
||||
|
||||
CallbackContext callbackContext;
|
||||
callbackContext.context = CefV8Context::GetCurrentContext();
|
||||
callbackContext.function = arguments[1];
|
||||
CefRefPtr<CefV8Value> eventTypes = CefV8Value::CreateObject(NULL, NULL);
|
||||
eventTypes->SetValue("modified", CefV8Value::CreateBool(true),
|
||||
V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
callbackContext.eventTypes = eventTypes;
|
||||
CallbackContext callbackContext;
|
||||
callbackContext.context = CefV8Context::GetCurrentContext();
|
||||
callbackContext.function = arguments[1];
|
||||
CefRefPtr<CefV8Value> eventTypes = CefV8Value::CreateObject(NULL, NULL);
|
||||
eventTypes->SetValue("modified", CefV8Value::CreateBool(true),
|
||||
V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
callbackContext.eventTypes = eventTypes;
|
||||
|
||||
stringstream idStream;
|
||||
idStream << "counter";
|
||||
idStream << idCounter;
|
||||
string id = idStream.str();
|
||||
idCounter++;
|
||||
pathDescriptors[path] = descriptor;
|
||||
pathCallbacks[descriptor][id] = callbackContext;
|
||||
retval = CefV8Value::CreateString(id);
|
||||
stringstream idStream;
|
||||
idStream << "counter";
|
||||
idStream << idCounter;
|
||||
string id = idStream.str();
|
||||
idCounter++;
|
||||
pathDescriptors[path] = descriptor;
|
||||
pathCallbacks[descriptor][id] = callbackContext;
|
||||
retval = CefV8Value::CreateString(id);
|
||||
}
|
||||
|
||||
void NativeHandler::UnwatchPath(const CefString& name,
|
||||
CefRefPtr<CefV8Value> object, const CefV8ValueList& arguments,
|
||||
CefRefPtr<CefV8Value>& retval, CefString& exception) {
|
||||
string path = arguments[0]->GetStringValue().ToString();
|
||||
CefRefPtr<CefV8Value> object, const CefV8ValueList& arguments,
|
||||
CefRefPtr<CefV8Value>& retval, CefString& exception) {
|
||||
string path = arguments[0]->GetStringValue().ToString();
|
||||
|
||||
int descriptor = pathDescriptors[path];
|
||||
if (descriptor == -1)
|
||||
return;
|
||||
int descriptor = pathDescriptors[path];
|
||||
if (descriptor == -1)
|
||||
return;
|
||||
|
||||
map<string, CallbackContext> callbacks = pathCallbacks[descriptor];
|
||||
string id = arguments[1]->GetStringValue().ToString();
|
||||
callbacks.erase(id);
|
||||
if (callbacks.empty())
|
||||
inotify_rm_watch(notifyFd, descriptor);
|
||||
map<string, CallbackContext> callbacks = pathCallbacks[descriptor];
|
||||
string id = arguments[1]->GetStringValue().ToString();
|
||||
callbacks.erase(id);
|
||||
if (callbacks.empty())
|
||||
inotify_rm_watch(notifyFd, descriptor);
|
||||
}
|
||||
|
||||
bool NativeHandler::Execute(const CefString& name, CefRefPtr<CefV8Value> object,
|
||||
const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval,
|
||||
CefString& exception) {
|
||||
if (name == "exists")
|
||||
Exists(name, object, arguments, retval, exception);
|
||||
else if (name == "read")
|
||||
Read(name, object, arguments, retval, exception);
|
||||
else if (name == "absolute")
|
||||
Absolute(name, object, arguments, retval, exception);
|
||||
else if (name == "list")
|
||||
List(name, object, arguments, retval, exception);
|
||||
else if (name == "isFile")
|
||||
IsFile(name, object, arguments, retval, exception);
|
||||
else if (name == "isDirectory")
|
||||
IsDirectory(name, object, arguments, retval, exception);
|
||||
else if (name == "showDevTools")
|
||||
CefV8Context::GetCurrentContext()->GetBrowser()->ShowDevTools();
|
||||
else if (name == "openDialog")
|
||||
OpenDialog(name, object, arguments, retval, exception);
|
||||
else if (name == "open")
|
||||
Open(name, object, arguments, retval, exception);
|
||||
else if (name == "write")
|
||||
Write(name, object, arguments, retval, exception);
|
||||
else if (name == "writeToPasteboard")
|
||||
WriteToPasteboard(name, object, arguments, retval, exception);
|
||||
else if (name == "readFromPasteboard")
|
||||
ReadFromPasteboard(name, object, arguments, retval, exception);
|
||||
else if (name == "asyncList")
|
||||
AsyncList(name, object, arguments, retval, exception);
|
||||
else if (name == "makeDirectory")
|
||||
MakeDirectory(name, object, arguments, retval, exception);
|
||||
else if (name == "move")
|
||||
Move(name, object, arguments, retval, exception);
|
||||
else if (name == "remove")
|
||||
Remove(name, object, arguments, retval, exception);
|
||||
else if (name == "alert")
|
||||
Alert(name, object, arguments, retval, exception);
|
||||
else if (name == "watchPath")
|
||||
WatchPath(name, object, arguments, retval, exception);
|
||||
else if (name == "unwatchPath")
|
||||
UnwatchPath(name, object, arguments, retval, exception);
|
||||
else
|
||||
cout << "Unhandled -> " + name.ToString() << " : "
|
||||
<< arguments[0]->GetStringValue().ToString() << endl;
|
||||
return true;
|
||||
const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval,
|
||||
CefString& exception) {
|
||||
if (name == "exists")
|
||||
Exists(name, object, arguments, retval, exception);
|
||||
else if (name == "read")
|
||||
Read(name, object, arguments, retval, exception);
|
||||
else if (name == "absolute")
|
||||
Absolute(name, object, arguments, retval, exception);
|
||||
else if (name == "list")
|
||||
List(name, object, arguments, retval, exception);
|
||||
else if (name == "isFile")
|
||||
IsFile(name, object, arguments, retval, exception);
|
||||
else if (name == "isDirectory")
|
||||
IsDirectory(name, object, arguments, retval, exception);
|
||||
else if (name == "showDevTools")
|
||||
CefV8Context::GetCurrentContext()->GetBrowser()->ShowDevTools();
|
||||
else if (name == "openDialog")
|
||||
OpenDialog(name, object, arguments, retval, exception);
|
||||
else if (name == "open")
|
||||
Open(name, object, arguments, retval, exception);
|
||||
else if (name == "write")
|
||||
Write(name, object, arguments, retval, exception);
|
||||
else if (name == "writeToPasteboard")
|
||||
WriteToPasteboard(name, object, arguments, retval, exception);
|
||||
else if (name == "readFromPasteboard")
|
||||
ReadFromPasteboard(name, object, arguments, retval, exception);
|
||||
else if (name == "asyncList")
|
||||
AsyncList(name, object, arguments, retval, exception);
|
||||
else if (name == "makeDirectory")
|
||||
MakeDirectory(name, object, arguments, retval, exception);
|
||||
else if (name == "move")
|
||||
Move(name, object, arguments, retval, exception);
|
||||
else if (name == "remove")
|
||||
Remove(name, object, arguments, retval, exception);
|
||||
else if (name == "alert")
|
||||
Alert(name, object, arguments, retval, exception);
|
||||
else if (name == "watchPath")
|
||||
WatchPath(name, object, arguments, retval, exception);
|
||||
else if (name == "unwatchPath")
|
||||
UnwatchPath(name, object, arguments, retval, exception);
|
||||
else
|
||||
cout << "Unhandled -> " + name.ToString() << " : "
|
||||
<< arguments[0]->GetStringValue().ToString() << endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -7,116 +7,116 @@
|
||||
#include <map>
|
||||
|
||||
struct CallbackContext {
|
||||
CefRefPtr<CefV8Context> context;
|
||||
CefRefPtr<CefV8Value> function;
|
||||
CefRefPtr<CefV8Value> eventTypes;
|
||||
CefRefPtr<CefV8Context> context;
|
||||
CefRefPtr<CefV8Value> function;
|
||||
CefRefPtr<CefV8Value> eventTypes;
|
||||
};
|
||||
|
||||
struct NotifyContext {
|
||||
int descriptor;
|
||||
std::map<int, std::map<std::string, CallbackContext> > callbacks;
|
||||
int descriptor;
|
||||
std::map<int, std::map<std::string, CallbackContext> > callbacks;
|
||||
};
|
||||
|
||||
class NativeHandler: public CefV8Handler {
|
||||
public:
|
||||
NativeHandler();
|
||||
NativeHandler();
|
||||
|
||||
CefRefPtr<CefV8Value> object;
|
||||
CefRefPtr<CefV8Value> object;
|
||||
|
||||
GtkWidget* window;
|
||||
GtkWidget* window;
|
||||
|
||||
std::string path;
|
||||
std::string path;
|
||||
|
||||
virtual bool Execute(const CefString& name, CefRefPtr<CefV8Value> object,
|
||||
const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval,
|
||||
CefString& exception);
|
||||
virtual bool Execute(const CefString& name, CefRefPtr<CefV8Value> object,
|
||||
const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval,
|
||||
CefString& exception);
|
||||
|
||||
void NotifyWatchers();
|
||||
void NotifyWatchers();
|
||||
|
||||
IMPLEMENT_REFCOUNTING(NativeHandler)
|
||||
;
|
||||
;
|
||||
|
||||
private:
|
||||
|
||||
int notifyFd;
|
||||
int notifyFd;
|
||||
|
||||
unsigned long int idCounter;
|
||||
unsigned long int idCounter;
|
||||
|
||||
std::map<int, std::map<std::string, CallbackContext> > pathCallbacks;
|
||||
std::map<int, std::map<std::string, CallbackContext> > pathCallbacks;
|
||||
|
||||
std::map<std::string, int> pathDescriptors;
|
||||
std::map<std::string, int> pathDescriptors;
|
||||
|
||||
void Exists(const CefString& name, CefRefPtr<CefV8Value> object,
|
||||
const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval,
|
||||
CefString& exception);
|
||||
void Exists(const CefString& name, CefRefPtr<CefV8Value> object,
|
||||
const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval,
|
||||
CefString& exception);
|
||||
|
||||
void Read(const CefString& name, CefRefPtr<CefV8Value> object,
|
||||
const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval,
|
||||
CefString& exception);
|
||||
void Read(const CefString& name, CefRefPtr<CefV8Value> object,
|
||||
const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval,
|
||||
CefString& exception);
|
||||
|
||||
void Absolute(const CefString& name, CefRefPtr<CefV8Value> object,
|
||||
const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval,
|
||||
CefString& exception);
|
||||
void Absolute(const CefString& name, CefRefPtr<CefV8Value> object,
|
||||
const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval,
|
||||
CefString& exception);
|
||||
|
||||
void List(const CefString& name, CefRefPtr<CefV8Value> object,
|
||||
const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval,
|
||||
CefString& exception);
|
||||
void List(const CefString& name, CefRefPtr<CefV8Value> object,
|
||||
const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval,
|
||||
CefString& exception);
|
||||
|
||||
void AsyncList(const CefString& name, CefRefPtr<CefV8Value> object,
|
||||
const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval,
|
||||
CefString& exception);
|
||||
void AsyncList(const CefString& name, CefRefPtr<CefV8Value> object,
|
||||
const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval,
|
||||
CefString& exception);
|
||||
|
||||
void IsFile(const CefString& name, CefRefPtr<CefV8Value> object,
|
||||
const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval,
|
||||
CefString& exception);
|
||||
void IsFile(const CefString& name, CefRefPtr<CefV8Value> object,
|
||||
const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval,
|
||||
CefString& exception);
|
||||
|
||||
void IsDirectory(const CefString& name, CefRefPtr<CefV8Value> object,
|
||||
const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval,
|
||||
CefString& exception);
|
||||
void IsDirectory(const CefString& name, CefRefPtr<CefV8Value> object,
|
||||
const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval,
|
||||
CefString& exception);
|
||||
|
||||
void OpenDialog(const CefString& name, CefRefPtr<CefV8Value> object,
|
||||
const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval,
|
||||
CefString& exception);
|
||||
void OpenDialog(const CefString& name, CefRefPtr<CefV8Value> object,
|
||||
const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval,
|
||||
CefString& exception);
|
||||
|
||||
void Open(const CefString& name, CefRefPtr<CefV8Value> object,
|
||||
const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval,
|
||||
CefString& exception);
|
||||
void Open(const CefString& name, CefRefPtr<CefV8Value> object,
|
||||
const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval,
|
||||
CefString& exception);
|
||||
|
||||
void Write(const CefString& name, CefRefPtr<CefV8Value> object,
|
||||
const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval,
|
||||
CefString& exception);
|
||||
void Write(const CefString& name, CefRefPtr<CefV8Value> object,
|
||||
const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval,
|
||||
CefString& exception);
|
||||
|
||||
void WriteToPasteboard(const CefString& name, CefRefPtr<CefV8Value> object,
|
||||
const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval,
|
||||
CefString& exception);
|
||||
void WriteToPasteboard(const CefString& name, CefRefPtr<CefV8Value> object,
|
||||
const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval,
|
||||
CefString& exception);
|
||||
|
||||
void ReadFromPasteboard(const CefString& name, CefRefPtr<CefV8Value> object,
|
||||
const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval,
|
||||
CefString& exception);
|
||||
void ReadFromPasteboard(const CefString& name, CefRefPtr<CefV8Value> object,
|
||||
const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval,
|
||||
CefString& exception);
|
||||
|
||||
void MakeDirectory(const CefString& name, CefRefPtr<CefV8Value> object,
|
||||
const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval,
|
||||
CefString& exception);
|
||||
void MakeDirectory(const CefString& name, CefRefPtr<CefV8Value> object,
|
||||
const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval,
|
||||
CefString& exception);
|
||||
|
||||
void Move(const CefString& name, CefRefPtr<CefV8Value> object,
|
||||
const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval,
|
||||
CefString& exception);
|
||||
void Move(const CefString& name, CefRefPtr<CefV8Value> object,
|
||||
const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval,
|
||||
CefString& exception);
|
||||
|
||||
void Remove(const CefString& name, CefRefPtr<CefV8Value> object,
|
||||
const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval,
|
||||
CefString& exception);
|
||||
void Remove(const CefString& name, CefRefPtr<CefV8Value> object,
|
||||
const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval,
|
||||
CefString& exception);
|
||||
|
||||
void Alert(const CefString& name, CefRefPtr<CefV8Value> object,
|
||||
const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval,
|
||||
CefString& exception);
|
||||
void Alert(const CefString& name, CefRefPtr<CefV8Value> object,
|
||||
const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval,
|
||||
CefString& exception);
|
||||
|
||||
void WatchPath(const CefString& name, CefRefPtr<CefV8Value> object,
|
||||
const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval,
|
||||
CefString& exception);
|
||||
void WatchPath(const CefString& name, CefRefPtr<CefV8Value> object,
|
||||
const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval,
|
||||
CefString& exception);
|
||||
|
||||
void UnwatchPath(const CefString& name, CefRefPtr<CefV8Value> object,
|
||||
const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval,
|
||||
CefString& exception);
|
||||
void UnwatchPath(const CefString& name, CefRefPtr<CefV8Value> object,
|
||||
const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval,
|
||||
CefString& exception);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#include "include/cef_task.h"
|
||||
|
||||
#include <assert.h> // NOLINT(build/include_order)
|
||||
|
||||
#ifndef NDEBUG
|
||||
#define ASSERT(condition) if (!(condition)) { assert(false); }
|
||||
#else
|
||||
|
||||
Reference in New Issue
Block a user