From 86b68e661213dee98749d77cb98bdf4fac18ddda Mon Sep 17 00:00:00 2001 From: Jason San Jose Date: Wed, 3 Dec 2014 16:43:19 -0800 Subject: [PATCH 01/15] fix some linux compile issues with CEF 2171 --- appshell/appshell_extensions_platform.h | 30 ++++++++++++--------- appshell/cefclient.cpp | 4 +-- appshell/cefclient.h | 3 ++- appshell/cefclient_gtk.cpp | 26 +++++++++--------- appshell/client_handler.cpp | 36 ++++++++++++------------- appshell/client_handler.h | 36 ++++++++++++++----------- 6 files changed, 74 insertions(+), 61 deletions(-) diff --git a/appshell/appshell_extensions_platform.h b/appshell/appshell_extensions_platform.h index 518755399..068d83c9d 100644 --- a/appshell/appshell_extensions_platform.h +++ b/appshell/appshell_extensions_platform.h @@ -1,25 +1,25 @@ /* * Copyright (c) 2012 Adobe Systems Incorporated. All rights reserved. - * + * * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. - * - */ + * + */ #pragma once @@ -28,6 +28,10 @@ #include +#ifdef OS_LINUX +#include +#endif + // Extension error codes. These MUST be in sync with the error // codes in appshell_extensions.js #if !defined(OS_WIN) // NO_ERROR is defined on windows diff --git a/appshell/cefclient.cpp b/appshell/cefclient.cpp index 4058b297b..1598ab642 100644 --- a/appshell/cefclient.cpp +++ b/appshell/cefclient.cpp @@ -28,9 +28,9 @@ CefRefPtr AppGetBrowser() { return g_handler->GetBrowser(); } -CefWindowHandle AppGetMainHwnd() { +ClientWindowHandle AppGetMainHwnd() { if (!g_handler.get()) - return NULL; + return kNullWindowHandle; return g_handler->GetMainHwnd(); } diff --git a/appshell/cefclient.h b/appshell/cefclient.h index 67120d066..23ec798cb 100644 --- a/appshell/cefclient.h +++ b/appshell/cefclient.h @@ -9,6 +9,7 @@ #include #include "include/cef_base.h" #include "client_app.h" +#include "client_handler.h" class CefApp; class CefBrowser; @@ -18,7 +19,7 @@ class CefCommandLine; CefRefPtr AppGetBrowser(); // Returns the main application window handle. -CefWindowHandle AppGetMainHwnd(); +ClientWindowHandle AppGetMainHwnd(); // Returns the application working directory. std::string AppGetWorkingDirectory(); diff --git a/appshell/cefclient_gtk.cpp b/appshell/cefclient_gtk.cpp index ca8630dd9..2aa6aa54c 100644 --- a/appshell/cefclient_gtk.cpp +++ b/appshell/cefclient_gtk.cpp @@ -2,6 +2,8 @@ // reserved. Use of this source code is governed by a BSD-style license that // can be found in the LICENSE file. +#include + #include "cefclient.h" #include #include @@ -54,7 +56,7 @@ void HandleAdd(GtkContainer *container, static gboolean HandleQuit(int signatl) { if (!isReallyClosing && g_handler.get() && g_handler->GetBrowserId()) { CefRefPtr callback = new CloseWindowCommandCallback(g_handler->GetBrowser()); - + g_handler->SendJSCommand(g_handler->GetBrowser(), FILE_CLOSE_WINDOW, callback); return TRUE; } @@ -76,7 +78,7 @@ int GetInitialUrl() { GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL); - + if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) { szInitialUrl = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); @@ -171,19 +173,19 @@ int main(int argc, char* argv[]) { if (CefString(&settings.cache_path).length() == 0) { CefString(&settings.cache_path) = AppGetCachePath(); } - + CefRefPtr cmdLine = AppGetCommandLine(); - + if (cmdLine->HasSwitch(cefclient::kStartupPath)) { szInitialUrl = cmdLine->GetSwitchValue(cefclient::kStartupPath); } else { szInitialUrl = AppGetRunningDirectory(); szInitialUrl.append("/dev/src/index.html"); - + if (!FileExists(szInitialUrl)) { szInitialUrl = AppGetRunningDirectory(); szInitialUrl.append("/www/index.html"); - + if (!FileExists(szInitialUrl)) { if (GetInitialUrl() < 0) return 0; @@ -193,17 +195,17 @@ int main(int argc, char* argv[]) { // Initialize CEF. CefInitialize(main_args, settings, app.get(), NULL); - + // Set window icon std::vector icons(APPICONS, APPICONS + sizeof(APPICONS) / sizeof(APPICONS[0]) ); GList *list = NULL; for (int i = 0; i < icons.size(); ++i) { std::string path = icons[i]; - + GdkPixbuf *icon = gdk_pixbuf_new_from_file(path.c_str(), NULL); if (!icon) continue; - + list = g_list_append(list, icon); } @@ -211,7 +213,7 @@ int main(int argc, char* argv[]) { gtk_window_set_default_size(GTK_WINDOW(window), 800, 600); gtk_window_set_icon_list(GTK_WINDOW(window), list); - + // Free icon list g_list_foreach(list, (GFunc) g_object_unref, NULL); g_list_free(list); @@ -244,7 +246,7 @@ int main(int argc, char* argv[]) { browserSettings.web_security = STATE_DISABLED; - window_info.SetAsChild(vbox); + window_info.SetAsChild(GDK_WINDOW_XID(gtk_widget_get_window(vbox)), CefRect(0, 0, 800, 600)); CefBrowserHost::CreateBrowser( window_info, @@ -257,7 +259,7 @@ int main(int argc, char* argv[]) { // Install an signal handler so we clean up after ourselves. signal(SIGINT, TerminationSignalHandler); signal(SIGTERM, TerminationSignalHandler); - + // Start the node server process startNodeProcess(); diff --git a/appshell/client_handler.cpp b/appshell/client_handler.cpp index 50a0fe231..3f2199f24 100644 --- a/appshell/client_handler.cpp +++ b/appshell/client_handler.cpp @@ -46,26 +46,26 @@ bool ClientHandler::OnProcessMessageReceived( CefProcessId source_process, CefRefPtr message) { bool handled = false; - + // Check for callbacks first if (message->GetName() == "executeCommandCallback") { int32 commandId = message->GetArgumentList()->GetInt(0); bool result = message->GetArgumentList()->GetBool(1); - + CefRefPtr callback = command_callback_map_[commandId]; callback->CommandComplete(result); command_callback_map_.erase(commandId); - + handled = true; } - + // Execute delegate callbacks. ProcessMessageDelegateSet::iterator it = process_message_delegates_.begin(); for (; it != process_message_delegates_.end() && !handled; ++it) { handled = (*it)->OnProcessMessageReceived(this, browser, source_process, message); } - + return handled; } @@ -159,7 +159,7 @@ void ClientHandler::OnAfterCreated(CefRefPtr browser) { PopupCreated(browser); } - browser_window_map_[browser->GetHost()->GetWindowHandle()] = browser; + browser_window_map_[(ClientWindowHandle)browser->GetHost()->GetWindowHandle()] = browser; } void ClientHandler::OnBeforeClose(CefRefPtr browser) { @@ -171,9 +171,9 @@ void ClientHandler::OnBeforeClose(CefRefPtr browser) { m_Browser = NULL; } - browser_window_map_.erase(browser->GetHost()->GetWindowHandle()); + browser_window_map_.erase((ClientWindowHandle)browser->GetHost()->GetWindowHandle()); } - + if (m_quitting) { // Changed the logic to call CefQuitMesaageLoop() // for windows as it was crashing with 2171 CEF. @@ -190,7 +190,7 @@ bool ClientHandler::OnDragEnter(CefRefPtr browser, CefRefPtr dragData, DragOperationsMask mask) { REQUIRE_UI_THREAD(); - + if (dragData->IsFile()) { gDroppedFiles.clear(); // Store the dragged files in a vector for later use @@ -229,7 +229,7 @@ void ClientHandler::OnLoadError(CefRefPtr browser, // Display a load error message. std::stringstream ss; - + ss << "" << "" << "