mirror of
https://github.com/atom/atom.git
synced 2026-01-24 14:28:14 -05:00
Upgrade to cef3
This commit is contained in:
@@ -12,15 +12,19 @@ CXXFLAGS := -Werror \
|
||||
-fPIC \
|
||||
-pthread \
|
||||
-D_REENTRANT \
|
||||
-I/usr/include/glib-2.0 \
|
||||
-I/usr/lib/i386-linux-gnu/glib-2.0/include \
|
||||
-I/usr/include/gtk-2.0 \
|
||||
-I/usr/lib/gtk-2.0/include \
|
||||
-I/usr/lib/i386-linux-gnu/gtk-2.0/include \
|
||||
-I/usr/include/atk-1.0 \
|
||||
-I/usr/include/cairo \
|
||||
-I/usr/include/gdk-pixbuf-2.0 \
|
||||
-I/usr/include/pango-1.0 \
|
||||
-I/usr/include/gio-unix-2.0/ \
|
||||
-I/usr/include/glib-2.0 \
|
||||
-I/usr/include/pixman-1 \
|
||||
-I/usr/include/freetype2 \
|
||||
-I/usr/include/libpng12 \
|
||||
-I/usr/include/openssl \
|
||||
-I/usr/lib/glib-2.0/include \
|
||||
-I../cef \
|
||||
-O2 \
|
||||
-fno-ident \
|
||||
@@ -85,7 +89,6 @@ install:
|
||||
cp -R ../vendor $(INSTALLDIR)
|
||||
cp -R ../bundles $(INSTALLDIR)
|
||||
cp -R ../themes $(INSTALLDIR)
|
||||
cp ../index.html $(INSTALLDIR)
|
||||
coffee -c -o $(INSTALLDIR)/src/stdlib ../src/stdlib/require.coffee
|
||||
ln -sf $(INSTALLDIR)/atom /usr/local/bin/atom
|
||||
|
||||
|
||||
@@ -31,8 +31,6 @@ void AppGetSettings(CefSettings& settings, CefRefPtr<CefApp>& app) {
|
||||
CefString(&settings.javascript_flags) = "";
|
||||
|
||||
settings.log_severity = LOGSEVERITY_ERROR;
|
||||
settings.local_storage_quota = 0;
|
||||
settings.session_storage_quota = 0;
|
||||
}
|
||||
|
||||
void destroy(void) {
|
||||
@@ -47,13 +45,14 @@ void TerminationSignalHandler(int signatl) {
|
||||
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);
|
||||
g_handler->GetBrowser()->GetHost()->SetFocus(true);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
CefMainArgs main_args(argc, argv);
|
||||
szWorkingDir = get_current_dir_name();
|
||||
if (szWorkingDir == NULL)
|
||||
return -1;
|
||||
@@ -84,7 +83,7 @@ int main(int argc, char *argv[]) {
|
||||
CefRefPtr<CefApp> app;
|
||||
|
||||
AppGetSettings(settings, app);
|
||||
CefInitialize(settings, app);
|
||||
CefInitialize(main_args, settings, app.get());
|
||||
|
||||
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_title(GTK_WINDOW(window), "atom");
|
||||
@@ -112,15 +111,16 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
window_info.SetAsChild(vbox);
|
||||
|
||||
std::string path = io_utils_real_app_path("/index.html");
|
||||
std::string path = io_utils_real_app_path("/static/index.html");
|
||||
if (path.empty())
|
||||
return -1;
|
||||
|
||||
std::string resolved("file://");
|
||||
resolved.append(path);
|
||||
|
||||
CefBrowser::CreateBrowserSync(window_info,
|
||||
static_cast<CefRefPtr<CefClient> >(g_handler), resolved, browserSettings);
|
||||
CefBrowserHost::CreateBrowserSync(
|
||||
window_info, g_handler.get(),
|
||||
resolved, browserSettings);
|
||||
|
||||
gtk_container_add(GTK_CONTAINER(window), vbox);
|
||||
gtk_widget_show_all(GTK_WIDGET(window));
|
||||
|
||||
@@ -27,17 +27,17 @@ void ClientHandler::OnAfterCreated(CefRefPtr<CefBrowser> browser) {
|
||||
REQUIRE_UI_THREAD();
|
||||
|
||||
AutoLock lock_scope(this);
|
||||
if (!m_Browser.get()) {
|
||||
if (!m_Browser.get()) {
|
||||
// We need to keep the main child window, but not popup windows
|
||||
m_Browser = browser;
|
||||
m_BrowserHwnd = browser->GetWindowHandle();
|
||||
m_BrowserId = browser->GetIdentifier();
|
||||
}
|
||||
}
|
||||
|
||||
bool ClientHandler::DoClose(CefRefPtr<CefBrowser> browser) {
|
||||
REQUIRE_UI_THREAD();
|
||||
|
||||
if (m_BrowserHwnd == browser->GetWindowHandle()) {
|
||||
if (m_BrowserId == browser->GetIdentifier()) {
|
||||
// Since the main window contains the browser window, we need to close
|
||||
// the parent window instead of the browser window.
|
||||
CloseMainWindow();
|
||||
@@ -56,9 +56,15 @@ bool ClientHandler::DoClose(CefRefPtr<CefBrowser> browser) {
|
||||
void ClientHandler::OnBeforeClose(CefRefPtr<CefBrowser> browser) {
|
||||
REQUIRE_UI_THREAD();
|
||||
|
||||
if (m_BrowserHwnd == browser->GetWindowHandle()) {
|
||||
if (m_BrowserId == browser->GetIdentifier()) {
|
||||
// Free the browser pointer so that the browser can be destroyed
|
||||
m_Browser = NULL;
|
||||
} else if (browser->IsPopup()) {
|
||||
// Remove the record for DevTools popup windows.
|
||||
//std::set<std::string>::iterator it =
|
||||
// m_OpenDevToolsURLs.find(browser->GetMainFrame()->GetURL());
|
||||
//if (it != m_OpenDevToolsURLs.end())
|
||||
// m_OpenDevToolsURLs.erase(it);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,7 +72,7 @@ void ClientHandler::OnLoadStart(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame) {
|
||||
REQUIRE_UI_THREAD();
|
||||
|
||||
if (m_BrowserHwnd == browser->GetWindowHandle() && frame->IsMain()) {
|
||||
if (m_BrowserId == browser->GetIdentifier() && frame->IsMain()) {
|
||||
CefRefPtr<CefV8Context> context = frame->GetV8Context();
|
||||
CefRefPtr<CefV8Value> global = context->GetGlobal();
|
||||
context->Enter();
|
||||
@@ -86,7 +92,7 @@ void ClientHandler::OnLoadStart(CefRefPtr<CefBrowser> browser,
|
||||
m_nativeHandler->window = window;
|
||||
m_nativeHandler->path = path;
|
||||
|
||||
CefRefPtr<CefV8Value> atom = CefV8Value::CreateObject(NULL, NULL);
|
||||
CefRefPtr<CefV8Value> atom = CefV8Value::CreateObject(NULL);
|
||||
global->SetValue("atom", atom, V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
|
||||
CefRefPtr<CefV8Value> loadPath = CefV8Value::CreateString(AppPath());
|
||||
@@ -152,52 +158,6 @@ void ClientHandler::OnFocusedNodeChanged(CefRefPtr<CefBrowser> browser,
|
||||
REQUIRE_UI_THREAD();
|
||||
}
|
||||
|
||||
bool ClientHandler::OnKeyEvent(CefRefPtr<CefBrowser> browser, KeyEventType type,
|
||||
int code, int modifiers, bool isSystemKey, bool isAfterJavaScript) {
|
||||
REQUIRE_UI_THREAD();
|
||||
|
||||
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();
|
||||
|
||||
// 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();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void ClientHandler::OnContextCreated(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame, CefRefPtr<CefV8Context> context) {
|
||||
REQUIRE_UI_THREAD();
|
||||
}
|
||||
|
||||
bool ClientHandler::OnDragStart(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefDragData> dragData, DragOperationsMask mask) {
|
||||
REQUIRE_UI_THREAD();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ClientHandler::OnDragEnter(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefDragData> dragData, DragOperationsMask mask) {
|
||||
REQUIRE_UI_THREAD();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void ClientHandler::SetWindow(GtkWidget* widget) {
|
||||
window = widget;
|
||||
}
|
||||
@@ -250,7 +210,7 @@ void ClientHandler::OnTitleChange(CefRefPtr<CefBrowser> browser,
|
||||
formatted.append(" - atom");
|
||||
|
||||
GtkWidget* window = gtk_widget_get_ancestor(
|
||||
GTK_WIDGET(browser->GetWindowHandle()), GTK_TYPE_WINDOW);
|
||||
GTK_WIDGET(browser->GetHost()->GetWindowHandle()), GTK_TYPE_WINDOW);
|
||||
gtk_window_set_title(GTK_WINDOW(window), formatted.c_str());
|
||||
}
|
||||
|
||||
|
||||
@@ -13,11 +13,7 @@ class ClientHandler: public CefClient,
|
||||
public CefLifeSpanHandler,
|
||||
public CefLoadHandler,
|
||||
public CefDisplayHandler,
|
||||
public CefFocusHandler,
|
||||
public CefKeyboardHandler,
|
||||
public CefPrintHandler,
|
||||
public CefV8ContextHandler,
|
||||
public CefDragHandler {
|
||||
public CefFocusHandler {
|
||||
public:
|
||||
ClientHandler();
|
||||
virtual ~ClientHandler();
|
||||
@@ -35,18 +31,6 @@ public:
|
||||
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,
|
||||
@@ -80,29 +64,6 @@ public:
|
||||
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;
|
||||
|
||||
// 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;
|
||||
|
||||
// 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() {
|
||||
@@ -141,6 +102,9 @@ protected:
|
||||
// The edit window handle
|
||||
CefWindowHandle m_EditHwnd;
|
||||
|
||||
// The child browser id
|
||||
int m_BrowserId;
|
||||
|
||||
// Support for logging.
|
||||
std::string m_LogFile;
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -43,7 +43,7 @@ void ExecuteWatchCallback(NotifyContext notifyContext) {
|
||||
CefRefPtr<CefV8Value> retval;
|
||||
CefRefPtr<CefV8Exception> e;
|
||||
args.push_back(callbackContext.eventTypes);
|
||||
function->ExecuteFunction(function, args, retval, e, true);
|
||||
function->ExecuteFunction(retval, args);
|
||||
|
||||
context->Exit();
|
||||
}
|
||||
@@ -206,7 +206,7 @@ void NativeHandler::List(const CefString& name, CefRefPtr<CefV8Value> object,
|
||||
vector < string > *paths = new vector<string>;
|
||||
ListDirectory(path, paths, recursive);
|
||||
|
||||
retval = CefV8Value::CreateArray();
|
||||
retval = CefV8Value::CreateArray(paths->size());
|
||||
for (uint i = 0; i < paths->size(); i++)
|
||||
retval->SetValue(i, CefV8Value::CreateString(paths->at(i)));
|
||||
free (paths);
|
||||
@@ -294,13 +294,13 @@ void NativeHandler::AsyncList(const CefString& name,
|
||||
vector < string > *paths = new vector<string>;
|
||||
ListDirectory(path, paths, recursive);
|
||||
|
||||
CefRefPtr<CefV8Value> callbackPaths = CefV8Value::CreateArray();
|
||||
CefRefPtr<CefV8Value> callbackPaths = CefV8Value::CreateArray(paths->size());
|
||||
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);
|
||||
arguments[2]->ExecuteFunction(retval, args);
|
||||
if (e)
|
||||
exception = e->GetMessage();
|
||||
free (paths);
|
||||
@@ -342,7 +342,7 @@ void NativeHandler::Alert(const CefString& name, CefRefPtr<CefV8Value> object,
|
||||
CefString& exception) {
|
||||
CefRefPtr<CefV8Value> buttonNamesAndCallbacks;
|
||||
if (arguments.size() < 3)
|
||||
buttonNamesAndCallbacks = CefV8Value::CreateArray();
|
||||
buttonNamesAndCallbacks = CefV8Value::CreateArray(0);
|
||||
else
|
||||
buttonNamesAndCallbacks = arguments[2];
|
||||
|
||||
@@ -373,7 +373,7 @@ void NativeHandler::Alert(const CefString& name, CefRefPtr<CefV8Value> object,
|
||||
buttonNamesAndCallbacks->GetValue(result)->GetValue(1);
|
||||
CefV8ValueList args;
|
||||
CefRefPtr<CefV8Exception> e;
|
||||
callback->ExecuteFunction(callback, args, retval, e, true);
|
||||
callback->ExecuteFunction(retval, args);
|
||||
if (e)
|
||||
exception = e->GetMessage();
|
||||
}
|
||||
@@ -392,7 +392,7 @@ void NativeHandler::WatchPath(const CefString& name,
|
||||
CallbackContext callbackContext;
|
||||
callbackContext.context = CefV8Context::GetCurrentContext();
|
||||
callbackContext.function = arguments[1];
|
||||
CefRefPtr<CefV8Value> eventTypes = CefV8Value::CreateObject(NULL, NULL);
|
||||
CefRefPtr<CefV8Value> eventTypes = CefV8Value::CreateObject(NULL);
|
||||
eventTypes->SetValue("modified", CefV8Value::CreateBool(true),
|
||||
V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
callbackContext.eventTypes = eventTypes;
|
||||
@@ -488,8 +488,8 @@ bool NativeHandler::Execute(const CefString& name, CefRefPtr<CefV8Value> object,
|
||||
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 == "showDevTools")
|
||||
// CefV8Context::GetCurrentContext()->GetBrowser()->ShowDevTools();
|
||||
else if (name == "openDialog")
|
||||
OpenDialog(name, object, arguments, retval, exception);
|
||||
else if (name == "open")
|
||||
|
||||
@@ -55,8 +55,8 @@ public:
|
||||
return CefV8Value::CreateNull();
|
||||
|
||||
CefRefPtr<CefV8Value> indices;
|
||||
CefRefPtr<CefV8Value> resultArray = CefV8Value::CreateArray();
|
||||
CefRefPtr<CefV8Value> indicesArray = CefV8Value::CreateArray();
|
||||
CefRefPtr<CefV8Value> resultArray = CefV8Value::CreateArray(region->num_regs);
|
||||
CefRefPtr<CefV8Value> indicesArray = CefV8Value::CreateArray(region->num_regs);
|
||||
for (int i = 0; i < region->num_regs; i++) {
|
||||
int begin = region->beg[i];
|
||||
int end = region->end[i];
|
||||
@@ -95,7 +95,7 @@ public:
|
||||
}
|
||||
|
||||
CefRefPtr<CefV8Value> BuildCaptureIndices(OnigRegion *region) {
|
||||
CefRefPtr<CefV8Value> array = CefV8Value::CreateArray();
|
||||
CefRefPtr<CefV8Value> array = CefV8Value::CreateArray(region->num_regs);
|
||||
int i = 0;
|
||||
for (int index = 0; index < region->num_regs; index++) {
|
||||
int begin = region->beg[index];
|
||||
@@ -170,7 +170,8 @@ bool OnigRegexpExtension::Execute(const CefString& name,
|
||||
|
||||
if (name == "buildOnigRegExp") {
|
||||
CefRefPtr<CefBase> userData = new OnigRegexpUserData(arguments[0]);
|
||||
retval = CefV8Value::CreateObject(userData, NULL);
|
||||
retval = CefV8Value::CreateObject(NULL);
|
||||
retval->SetUserData(userData);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user