From 7a91ff899fb8d18521fcdf2d610e159c40dece94 Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Mon, 24 Oct 2011 20:20:52 +0000 Subject: [PATCH] Add initial Linux support (issue #40). git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@338 5089003a-bbd8-11dd-ad1f-f1f9622dbc98 --- cef.gyp | 80 +++++ cef_paths.gypi | 2 + include/cef_capi.h | 2 +- libcef/browser_impl.cc | 2 + libcef/browser_impl_gtk.cc | 83 ++++- libcef/browser_request_context.cc | 16 +- libcef/browser_webkit_glue_gtk.cc | 22 ++ libcef/browser_webview_delegate.h | 4 + libcef/browser_webview_delegate_gtk.cc | 170 +++++++++- libcef/cef_process_ui_thread_gtk.cc | 2 +- libcef/cef_string_map.cc | 6 +- libcef/scheme_impl.cc | 2 +- libcef/webwidget_host.cc | 2 +- libcef/webwidget_host_gtk.cc | 6 +- libcef_dll/cpptoc/domdocument_cpptoc.cc | 6 +- tests/cefclient/cefclient_gtk.cpp | 419 ++++++++++++++++++++++++ tests/cefclient/client_handler_gtk.cpp | 120 +++++++ tests/cefclient/resource_util.h | 2 +- tests/cefclient/resource_util_linux.cpp | 39 +++ tests/cefclient/scheme_test.cpp | 4 +- tests/unittests/navigation_unittest.cc | 2 +- tests/unittests/v8_unittest.cc | 2 +- tools/build_projects.sh | 11 +- tools/make_capi_header.py | 2 +- tools/make_distrib.py | 31 +- 25 files changed, 986 insertions(+), 51 deletions(-) create mode 100644 libcef/browser_webkit_glue_gtk.cc create mode 100644 tests/cefclient/cefclient_gtk.cpp create mode 100644 tests/cefclient/client_handler_gtk.cpp create mode 100644 tests/cefclient/resource_util_linux.cpp diff --git a/cef.gyp b/cef.gyp index a05fbd235..f79ad89cc 100644 --- a/cef.gyp +++ b/cef.gyp @@ -4,6 +4,7 @@ { 'variables': { + 'pkg-config': 'pkg-config', 'chromium_code': 1, 'repack_locales_cmd': ['python', 'tools/repack_locales.py'], 'grit_out_dir': '<(SHARED_INTERMEDIATE_DIR)/cef', @@ -211,6 +212,67 @@ '<@(includes_linux)', '<@(cefclient_sources_linux)', ], + 'variables': { + 'repack_path': '../tools/grit/grit/format/repack.py', + }, + 'actions': [ + { + 'action_name': 'repack_locales', + 'inputs': [ + 'tools/repack_locales.py', + # NOTE: Ideally the common command args would be shared + # amongst inputs/outputs/action, but the args include shell + # variables which need to be passed intact, and command + # expansion wants to expand the shell variables. Adding the + # explicit quoting here was the only way it seemed to work. + '>!@(<(repack_locales_cmd) -i -g \'<(grit_out_dir)\' -s \'<(SHARED_INTERMEDIATE_DIR)\' -x \'<(INTERMEDIATE_DIR)\' <(locales))', + ], + 'outputs': [ + '>!@(<(repack_locales_cmd) -o -g \'<(grit_out_dir)\' -s \'<(SHARED_INTERMEDIATE_DIR)\' -x \'<(INTERMEDIATE_DIR)\' <(locales))', + ], + 'action': [ + '<@(repack_locales_cmd)', + '-g', '<(grit_out_dir)', + '-s', '<(SHARED_INTERMEDIATE_DIR)', + '-x', '<(INTERMEDIATE_DIR)', + '<@(locales)', + ], + }, + { + 'action_name': 'repack_resources', + 'variables': { + 'pak_inputs': [ + '<(grit_out_dir)/devtools_resources.pak', + '<(SHARED_INTERMEDIATE_DIR)/net/net_resources.pak', + '<(SHARED_INTERMEDIATE_DIR)/ui/gfx/gfx_resources.pak', + '<(SHARED_INTERMEDIATE_DIR)/webkit/webkit_chromium_resources.pak', + '<(SHARED_INTERMEDIATE_DIR)/webkit/webkit_resources.pak', + ], + }, + 'inputs': [ + '<(repack_path)', + '<@(pak_inputs)', + ], + 'outputs': [ + '<(INTERMEDIATE_DIR)/repack/chrome.pak', + ], + 'action': ['python', '<(repack_path)', '<@(_outputs)', '<@(pak_inputs)'], + }, + ], + 'copies': [ + { + 'destination': '<(PRODUCT_DIR)/locales', + 'files': [ + 'f) - (int)(s) + sizeof((s)->f) <= (s)->base.size) + ((intptr_t)&((s)->f) - (intptr_t)(s) + sizeof((s)->f) <= (s)->base.size) #define CEF_MEMBER_MISSING(s, f) (!CEF_MEMBER_EXISTS(s, f) || !((s)->f)) diff --git a/libcef/browser_impl.cc b/libcef/browser_impl.cc index d27222cc3..4db65d875 100644 --- a/libcef/browser_impl.cc +++ b/libcef/browser_impl.cc @@ -1111,6 +1111,7 @@ CefRefPtr CefBrowserImpl::UIT_CreatePopupWindow( info.SetAsPopup(NULL, CefString()); #endif +#if (defined(OS_WIN) || defined(OS_MACOSX)) // Default to the size from the popup features. if(features.xSet) info.m_x = features.x; @@ -1120,6 +1121,7 @@ CefRefPtr CefBrowserImpl::UIT_CreatePopupWindow( info.m_nWidth = features.width; if(features.heightSet) info.m_nHeight = features.height; +#endif CefRefPtr client = client_; diff --git a/libcef/browser_impl_gtk.cc b/libcef/browser_impl_gtk.cc index ca4bdc878..3900687ba 100644 --- a/libcef/browser_impl_gtk.cc +++ b/libcef/browser_impl_gtk.cc @@ -35,11 +35,9 @@ bool CefBrowserImpl::IsWindowRenderingDisabled() return false; } -gfx::NativeWindow CefBrowserImpl::UIT_GetMainWndHandle() { +gfx::NativeView CefBrowserImpl::UIT_GetMainWndHandle() { REQUIRE_UIT(); - GtkWidget* toplevel = gtk_widget_get_ancestor(window_info_.m_Widget, - GTK_TYPE_WINDOW); - return GTK_IS_WINDOW(toplevel) ? GTK_WINDOW(toplevel) : NULL; + return window_info_.m_Widget; } bool CefBrowserImpl::UIT_CreateBrowser(const CefString& url) @@ -56,6 +54,23 @@ bool CefBrowserImpl::UIT_CreateBrowser(const CefString& url) if (!settings_.developer_tools_disabled) dev_tools_agent_.reset(new BrowserDevToolsAgent()); + GtkWidget *window; + GtkWidget* parentView = window_info_.m_ParentWidget; + + if(parentView == NULL) { + // Create a new window. + window = gtk_window_new(GTK_WINDOW_TOPLEVEL); + gtk_window_set_default_size(GTK_WINDOW(window), 800, 600); + + parentView = gtk_vbox_new(FALSE, 0); + + gtk_container_add(GTK_CONTAINER(window), parentView); + gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); + gtk_widget_show_all(GTK_WIDGET(window)); + + window_info_.m_ParentWidget = parentView; + } + WebPreferences prefs; BrowserToWebSettings(settings_, prefs); @@ -72,9 +87,12 @@ bool CefBrowserImpl::UIT_CreateBrowser(const CefString& url) Unlock(); - if(handler_.get()) { - // Notify the handler that we're done creating the new window - handler_->HandleAfterCreated(this); + if (client_.get()) { + CefRefPtr handler = client_->GetLifeSpanHandler(); + if(handler.get()) { + // Notify the handler that we're done creating the new window + handler->OnAfterCreated(this); + } } if(url.size() > 0) @@ -97,9 +115,37 @@ bool CefBrowserImpl::UIT_ViewDocumentString(WebKit::WebFrame *frame) { REQUIRE_UIT(); - // TODO(port): Add implementation. - NOTIMPLEMENTED(); - return false; + char buff[] = "/tmp/CEFSourceXXXXXX"; + int fd = mkstemp(buff); + + if (fd == -1) + return false; + + FILE* srcOutput; + srcOutput = fdopen(fd, "w+"); + + if (!srcOutput) + return false; + + std::string markup = frame->contentAsMarkup().utf8(); + if (fputs(markup.c_str(), srcOutput) < 0) { + fclose(srcOutput); + return false; + } + + fclose(srcOutput); + std::string newName(buff); + newName.append(".txt"); + if (rename(buff, newName.c_str()) != 0) + return false; + + std::string openCommand("xdg-open "); + openCommand += newName; + + if (system(openCommand.c_str()) != 0) + return false; + + return true; } void CefBrowserImpl::UIT_PrintPage(int page_number, int total_pages, @@ -130,6 +176,21 @@ int CefBrowserImpl::UIT_GetPagesCount(WebKit::WebFrame* frame) // static void CefBrowserImpl::UIT_CloseView(gfx::NativeView view) { + GtkWidget* window = + gtk_widget_get_parent(gtk_widget_get_parent(GTK_WIDGET(view))); + MessageLoop::current()->PostTask(FROM_HERE, NewRunnableFunction( - >k_widget_destroy, GTK_WIDGET(view))); + >k_widget_destroy, GTK_WIDGET(window))); +} + +// static +bool CefBrowserImpl::UIT_IsViewVisible(gfx::NativeView view) +{ + if (!view) + return false; + + if (view->window) + return (bool)gdk_window_is_visible(view->window); + else + return false; } diff --git a/libcef/browser_request_context.cc b/libcef/browser_request_context.cc index b6e47eeb0..9bd5ab0fe 100644 --- a/libcef/browser_request_context.cc +++ b/libcef/browser_request_context.cc @@ -129,10 +129,24 @@ void BrowserRequestContext::Init( #endif // defined(OS_WIN) if (!proxy_service()) { - // Use the system proxy resolver. +#if defined(OS_POSIX) && !defined(OS_MACOSX) + // Use no proxy to avoid ProxyConfigServiceLinux. + // Enabling use of the ProxyConfigServiceLinux requires: + // -Calling from a thread with a TYPE_UI MessageLoop, + // -If at all possible, passing in a pointer to the IO thread's MessageLoop, + // -Keep in mind that proxy auto configuration is also + // non-functional on linux in this context because of v8 threading + // issues. + // TODO(port): rename "linux" to some nonspecific unix. + scoped_ptr proxy_config_service( + new net::ProxyConfigServiceFixed(net::ProxyConfig())); +#else + // Use the system proxy settings. scoped_ptr proxy_config_service( net::ProxyService::CreateSystemProxyConfigService( MessageLoop::current(), NULL)); +#endif + storage_.set_proxy_service(net::ProxyService::CreateUsingSystemProxyResolver( proxy_config_service.release(), 0, NULL)); } diff --git a/libcef/browser_webkit_glue_gtk.cc b/libcef/browser_webkit_glue_gtk.cc new file mode 100644 index 000000000..360e6dd41 --- /dev/null +++ b/libcef/browser_webkit_glue_gtk.cc @@ -0,0 +1,22 @@ +// Copyright (c) 2008-2009 The Chromium Embedded Framework Authors. +// Portions copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "browser_webkit_glue.h" +#include "cef_context.h" +#include "ui/base/resource/resource_bundle.h" + +namespace webkit_glue { + +base::StringPiece GetDataResource(int resource_id) { + base::StringPiece piece; + // Try to load the resource from the resource pack. + if (piece.empty()) + piece = ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id); + + DCHECK(!piece.empty()) << "Resource "< #include "base/message_loop.h" +#include "base/string_util.h" +#include "net/base/net_errors.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebContextMenuData.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupMenu.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebDragData.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebImage.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebPoint.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebRect.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" +#include "ui/gfx/native_widget_types.h" #include "ui/gfx/gtk_util.h" #include "ui/gfx/point.h" -#include "webkit/glue/webcursor.h" #include "webkit/glue/webdropdata.h" #include "webkit/glue/webpreferences.h" +#include "webkit/glue/webkit_glue.h" #include "webkit/glue/window_open_disposition.h" -#include "webkit/plugins/npapi/gtk_plugin_container_manager.h" #include "webkit/plugins/npapi/plugin_list.h" #include "webkit/plugins/npapi/webplugin.h" #include "webkit/plugins/npapi/webplugin_delegate_impl.h" +#include "include/internal/cef_types.h" + +using webkit::npapi::WebPluginDelegateImpl; +using WebKit::WebContextMenuData; using WebKit::WebCursorInfo; +using WebKit::WebDragData; +using WebKit::WebDragOperationsMask; +using WebKit::WebExternalPopupMenu; +using WebKit::WebExternalPopupMenuClient; using WebKit::WebFrame; +using WebKit::WebImage; using WebKit::WebNavigationPolicy; +using WebKit::WebPoint; using WebKit::WebPopupMenuInfo; using WebKit::WebRect; using WebKit::WebWidget; @@ -59,11 +75,11 @@ void SelectionClipboardGetContents(GtkClipboard* clipboard, DCHECK(frame); std::string selection; - if (TEXT_HTML == info) { + if (TEXT_HTML == info) selection = frame->selectionAsMarkup().utf8(); - } else { + else selection = frame->selectionAsText().utf8(); - } + if (TEXT_HTML == info) { gtk_selection_data_set(selection_data, GetTextHtmlAtom(), @@ -78,17 +94,112 @@ void SelectionClipboardGetContents(GtkClipboard* clipboard, } // namespace -// WebViewClient -------------------------------------------------------------- +// WebViewClient ----------------------------------s---------------------------- -WebWidget* BrowserWebViewDelegate::createPopupMenu( - const WebPopupMenuInfo& info) { - NOTREACHED(); +WebKit::WebExternalPopupMenu* BrowserWebViewDelegate::createExternalPopupMenu( + const WebKit::WebPopupMenuInfo& info, + WebKit::WebExternalPopupMenuClient* client) { + NOTIMPLEMENTED(); return NULL; } -void BrowserWebViewDelegate::showContextMenu( - WebKit::WebFrame* frame, const WebKit::WebContextMenuData& data) { - NOTIMPLEMENTED(); +static gboolean MenuItemHandle(GtkWidget* menu_item, gpointer data) +{ + if (!data) + return FALSE; + + BrowserWebViewDelegate* webViewDelegate = (BrowserWebViewDelegate*)data; + int id = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(menu_item), "menu_id")); + + webViewDelegate->HandleContextMenu(id); + + return FALSE; +} + +static GtkWidget* MenuItemCreate(GtkWidget* parent_menu, const char* name, + int id, bool is_enabled, BrowserWebViewDelegate* webViewDelegate) +{ + GtkWidget* menu_item = gtk_menu_item_new_with_label(name); + + g_object_set_data(G_OBJECT(menu_item), "menu_id", (gpointer)id); + g_signal_connect(G_OBJECT(menu_item), "activate", G_CALLBACK(MenuItemHandle), + (gpointer)webViewDelegate); + gtk_menu_shell_append(GTK_MENU_SHELL(parent_menu), menu_item); + gtk_widget_set_sensitive(menu_item, is_enabled); + + gtk_widget_show(menu_item); + + return menu_item; +} + +static GtkWidget* MenuItemCreateSeperator(GtkWidget* parent_menu) +{ + GtkWidget* menu_item = gtk_menu_item_new(); + + gtk_menu_shell_append(GTK_MENU_SHELL(parent_menu), menu_item); + gtk_widget_show(menu_item); + + return menu_item; +} + +void BrowserWebViewDelegate::showContextMenu(WebKit::WebFrame* frame, + const WebKit::WebContextMenuData& data) { + GtkWidget* menu = NULL; + GdkPoint mouse_pt = { data.mousePosition.x, data.mousePosition.y }; + + int edit_flags = 0; + int type_flags = 0; + + // Make sure events can be pumped while the menu is up. + MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current()); + + // Give the client a chance to handle the menu. + if (OnBeforeMenu(data, mouse_pt.x, mouse_pt.y, edit_flags, type_flags)) + return; + + CefRefPtr client = browser_->GetClient(); + CefRefPtr handler; + if (client.get()) + handler = client->GetMenuHandler(); + + // Build the correct default context menu + if (type_flags & MENUTYPE_EDITABLE) { + menu = gtk_menu_new(); + MenuItemCreate(menu, "Undo", MENU_ID_UNDO, + !!(edit_flags & MENU_CAN_UNDO), this); + MenuItemCreate(menu, "Redo", MENU_ID_REDO, + !!(edit_flags & MENU_CAN_REDO), this); + MenuItemCreate(menu, "Cut", MENU_ID_CUT, + !!(edit_flags & MENU_CAN_CUT), this); + MenuItemCreate(menu, "Copy", MENU_ID_COPY, + !!(edit_flags & MENU_CAN_COPY), this); + MenuItemCreate(menu, "Paste", MENU_ID_PASTE, + !!(edit_flags & MENU_CAN_PASTE), this); + MenuItemCreate(menu, "Delete", MENU_ID_DELETE, + !!(edit_flags & MENU_CAN_DELETE), this); + MenuItemCreateSeperator(menu); + MenuItemCreate(menu, "Select All", MENU_ID_SELECTALL, + !!(edit_flags & MENU_CAN_SELECT_ALL), this); + } else if(type_flags & MENUTYPE_SELECTION) { + menu = gtk_menu_new(); + MenuItemCreate(menu, "Copy", MENU_ID_COPY, + !!(edit_flags & MENU_CAN_COPY), this); + } else if(type_flags & (MENUTYPE_PAGE | MENUTYPE_FRAME)) { + menu = gtk_menu_new(); + MenuItemCreate(menu, "Back", MENU_ID_NAV_BACK, + !!(edit_flags & MENU_CAN_GO_BACK), this); + MenuItemCreate(menu, "Forward", MENU_ID_NAV_FORWARD, + !!(edit_flags & MENU_CAN_GO_FORWARD), this); + MenuItemCreateSeperator(menu); + // TODO(port): Enable the print item when supported. + // MenuItemCreate(menu, "Print", MENU_ID_PRINT, true, this); + MenuItemCreate(menu, "View Source", MENU_ID_VIEWSOURCE, true, this); + } + + if (menu) { + gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, 3, + gtk_get_current_event_time()); + } } // WebWidgetClient ------------------------------------------------------------ @@ -123,7 +234,8 @@ void BrowserWebViewDelegate::didChangeCursor(const WebCursorInfo& cursor_info) { gdk_cursor = gfx::GetCursor(cursor_type); } cursor_type_ = cursor_type; - gdk_window_set_cursor(browser_->UIT_GetWebViewWndHandle()->window, gdk_cursor); + gdk_window_set_cursor(browser_->UIT_GetWebViewWndHandle()->window, + gdk_cursor); } WebRect BrowserWebViewDelegate::windowRect() { @@ -161,9 +273,9 @@ WebRect BrowserWebViewDelegate::rootWindowRect() { // window. This means the x/y is the distance from the corner of the // screen, and the width/height is the size of the entire browser window. // For example, this is used to implement window.screenX and window.screenY. - GtkWidget* drawing_area = host->view_handle(); - GtkWidget* window = - gtk_widget_get_parent(gtk_widget_get_parent(drawing_area)); + GtkWidget* window = gtk_widget_get_ancestor(GTK_WIDGET(host->view_handle()), + GTK_TYPE_WINDOW); + gint x, y, width, height; gtk_window_get_position(GTK_WINDOW(window), &x, &y); gtk_window_get_size(GTK_WINDOW(window), &width, &height); @@ -222,6 +334,30 @@ void BrowserWebViewDelegate::DidMovePlugin( plugin_container_manager->MovePluginContainer(move); } +void BrowserWebViewDelegate::HandleContextMenu(int selected_id) +{ + if (selected_id != 0) { + CefRefPtr client = browser_->GetClient(); + CefRefPtr handler; + if (client.get()) + handler = client->GetMenuHandler(); + + // An action was chosen + cef_handler_menuid_t menuId = + static_cast(selected_id); + bool handled = false; + if (handler.get()) { + // Ask the handler if it wants to handle the action + handled = handler->OnMenuAction(browser_, menuId); + } + + if(!handled) { + // Execute the action + browser_->UIT_HandleAction(menuId, browser_->GetFocusedFrame()); + } + } +} + // Protected methods ---------------------------------------------------------- void BrowserWebViewDelegate::ShowJavaScriptAlert( diff --git a/libcef/cef_process_ui_thread_gtk.cc b/libcef/cef_process_ui_thread_gtk.cc index 19d6ee201..2048d8a35 100644 --- a/libcef/cef_process_ui_thread_gtk.cc +++ b/libcef/cef_process_ui_thread_gtk.cc @@ -6,7 +6,7 @@ #include "browser_impl.h" void CefProcessUIThread::PlatformInit() { - + } void CefProcessUIThread::PlatformCleanUp() { diff --git a/libcef/cef_string_map.cc b/libcef/cef_string_map.cc index 3b59b8ea8..cd30e5368 100644 --- a/libcef/cef_string_map.cc +++ b/libcef/cef_string_map.cc @@ -30,7 +30,7 @@ CEF_EXPORT int cef_string_map_find(cef_string_map_t map, StringMap* impl = (StringMap*)map; StringMap::const_iterator it = impl->find(CefString(key)); if(it == impl->end()) - return NULL; + return 0; const CefString& val = it->second; return cef_string_set(val.c_str(), val.length(), value, true); } @@ -43,7 +43,7 @@ CEF_EXPORT int cef_string_map_key(cef_string_map_t map, int index, StringMap* impl = (StringMap*)map; DCHECK(index >= 0 && index < (int)impl->size()); if(index < 0 || index >= (int)impl->size()) - return NULL; + return 0; StringMap::const_iterator it = impl->begin(); for(int ct = 0; it != impl->end(); ++it, ct++) { if(ct == index) @@ -60,7 +60,7 @@ CEF_EXPORT int cef_string_map_value(cef_string_map_t map, int index, StringMap* impl = (StringMap*)map; DCHECK(index >= 0 && index < (int)impl->size()); if(index < 0 || index >= (int)impl->size()) - return NULL; + return 0; StringMap::const_iterator it = impl->begin(); for(int ct = 0; it != impl->end(); ++it, ct++) { if(ct == index) { diff --git a/libcef/scheme_impl.cc b/libcef/scheme_impl.cc index 147061959..6e33fec52 100644 --- a/libcef/scheme_impl.cc +++ b/libcef/scheme_impl.cc @@ -303,7 +303,7 @@ private: job_->NotifyReadComplete(bytes_read); dest_ = NULL; - dest_size_ = NULL; + dest_size_ = 0; } } else { // All done. diff --git a/libcef/webwidget_host.cc b/libcef/webwidget_host.cc index ce54ab469..9c9e44fdb 100644 --- a/libcef/webwidget_host.cc +++ b/libcef/webwidget_host.cc @@ -73,7 +73,7 @@ gfx::PluginWindowHandle WebWidgetHost::GetWindowedPluginAt(int x, int y) } } - return NULL; + return gfx::kNullPluginWindow; } void WebWidgetHost::DoPaint() { diff --git a/libcef/webwidget_host_gtk.cc b/libcef/webwidget_host_gtk.cc index 15acc92f4..fb55e3b49 100644 --- a/libcef/webwidget_host_gtk.cc +++ b/libcef/webwidget_host_gtk.cc @@ -227,6 +227,9 @@ class WebWidgetHostGtkWidget { return FALSE; // We do not forward any other buttons to the renderer. if (event->type == GDK_2BUTTON_PRESS || event->type == GDK_3BUTTON_PRESS) return FALSE; + + gtk_widget_grab_focus(widget); + host->webwidget()->handleInputEvent( WebInputEventFactory::mouseEvent(event)); return FALSE; @@ -346,7 +349,8 @@ WebWidgetHost::~WebWidgetHost() { g_object_set_data(G_OBJECT(view_), kWebWidgetHostKey, NULL); g_signal_handlers_disconnect_matched(view_, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, this); - webwidget_->close(); + // TODO(port): Figure out why we can't do this without crashing. + // webwidget_->close(); } void WebWidgetHost::Resize(const gfx::Size &newsize) { diff --git a/libcef_dll/cpptoc/domdocument_cpptoc.cc b/libcef_dll/cpptoc/domdocument_cpptoc.cc index c6b982aef..8bdd1c9f2 100644 --- a/libcef_dll/cpptoc/domdocument_cpptoc.cc +++ b/libcef_dll/cpptoc/domdocument_cpptoc.cc @@ -110,7 +110,7 @@ int CEF_CALLBACK domdocument_has_selection(struct _cef_domdocument_t* self) { DCHECK(self); if(!self) - return NULL; + return 0; return CefDOMDocumentCppToC::Get(self)->HasSelection(); } @@ -134,7 +134,7 @@ int CEF_CALLBACK domdocument_get_selection_start_offset( { DCHECK(self); if(!self) - return NULL; + return 0; return CefDOMDocumentCppToC::Get(self)->GetSelectionStartOffset(); } @@ -158,7 +158,7 @@ int CEF_CALLBACK domdocument_get_selection_end_offset( { DCHECK(self); if(!self) - return NULL; + return 0; return CefDOMDocumentCppToC::Get(self)->GetSelectionEndOffset(); } diff --git a/tests/cefclient/cefclient_gtk.cpp b/tests/cefclient/cefclient_gtk.cpp new file mode 100644 index 000000000..7b948068d --- /dev/null +++ b/tests/cefclient/cefclient_gtk.cpp @@ -0,0 +1,419 @@ +#include "include/cef.h" +#include "cefclient.h" +#include "client_handler.h" + +#include "binding_test.h" +#include "extension_test.h" +#include "scheme_test.h" + +#include +#include +#include +#include "string_util.h" +#include + +using namespace std; + +char szWorkingDir[512]; // The current working directory + +// The global ClientHandler reference. +extern CefRefPtr g_handler; + +void destroy(void) { + CefShutdown(); + exit(0); +} + +void TerminationSignalHandler(int signatl) { + CefShutdown(); + exit(0); +} + +// Callback for Debug > Get Source... menu item. +gboolean GetSourceActivated(GtkWidget* widget) { + if(g_handler.get() && g_handler->GetBrowserHwnd()) + RunGetSourceTest(g_handler->GetBrowser()); + + return FALSE; // Don't stop this message. +} + +// Callback for Debug > Get Source... menu item. +gboolean GetTextActivated(GtkWidget* widget) { + if(g_handler.get() && g_handler->GetBrowserHwnd()) + RunGetTextTest(g_handler->GetBrowser()); + + return FALSE; // Don't stop this message. +} + +// Callback for Debug > JS Binding... menu item. +gboolean JSBindngActivated(GtkWidget* widget) { + if(g_handler.get() && g_handler->GetBrowserHwnd()) + RunBindingTest(g_handler->GetBrowser()); + + return FALSE; // Don't stop this message. +} + +// Callback for Debug > JS Extension... menu item. +gboolean JSExtensionActivated(GtkWidget* widget) { + if(g_handler.get() && g_handler->GetBrowserHwnd()) + RunExtensionTest(g_handler->GetBrowser()); + + return FALSE; // Don't stop this message. +} + +// Callback for Debug > JS Execute... menu item. +gboolean JSExecuteActivated(GtkWidget* widget) { + if(g_handler.get() && g_handler->GetBrowserHwnd()) + RunJavaScriptExecuteTest(g_handler->GetBrowser()); + + return FALSE; // Don't stop this message. +} + +// Callback for Debug > Request... menu item. +gboolean RequestActivated(GtkWidget* widget) { + if(g_handler.get() && g_handler->GetBrowserHwnd()) + RunRequestTest(g_handler->GetBrowser()); + + return FALSE; // Don't stop this message. +} + +// Callback for Debug > Local Storage... menu item. +gboolean LocalStorageActivated(GtkWidget* widget) { + if(g_handler.get() && g_handler->GetBrowserHwnd()) + RunLocalStorageTest(g_handler->GetBrowser()); + + return FALSE; // Don't stop this message. +} + +// Callback for Debug > XMLHttpRequest... menu item. +gboolean XMLHttpRequestActivated(GtkWidget* widget) { + if(g_handler.get() && g_handler->GetBrowserHwnd()) + RunXMLHTTPRequestTest(g_handler->GetBrowser()); + + return FALSE; // Don't stop this message. +} + +// Callback for Debug > WebURLRequest... menu item. +gboolean WebURLRequestActivated(GtkWidget* widget) { + if(g_handler.get() && g_handler->GetBrowserHwnd()) + RunWebURLRequestTest(g_handler->GetBrowser()); + + return FALSE; // Don't stop this message. +} + +// Callback for Debug > DOM Access... menu item. +gboolean DOMAccessActivated(GtkWidget* widget) { + if(g_handler.get() && g_handler->GetBrowserHwnd()) + RunDOMAccessTest(g_handler->GetBrowser()); + + return FALSE; // Don't stop this message. +} + +// Callback for Debug > Scheme Handler... menu item. +gboolean SchemeHandlerActivated(GtkWidget* widget) { + if(g_handler.get() && g_handler->GetBrowserHwnd()) + RunSchemeTest(g_handler->GetBrowser()); + + return FALSE; // Don't stop this message. +} + +// Callback for Debug > Popup Window... menu item. +gboolean PopupWindowActivated(GtkWidget* widget) { + if(g_handler.get() && g_handler->GetBrowserHwnd()) + RunPopupTest(g_handler->GetBrowser()); + + return FALSE; // Don't stop this message. +} + +// Callback for Debug > Accelerated 2D Canvas:... menu item. +gboolean Accelerated2DCanvasActivated(GtkWidget* widget) { + if(g_handler.get() && g_handler->GetBrowserHwnd()) + RunAccelerated2DCanvasTest(g_handler->GetBrowser()); + + return FALSE; // Don't stop this message. +} + +// Callback for Debug > Accelerated Layers:... menu item. +gboolean AcceleratedLayersActivated(GtkWidget* widget) { + if(g_handler.get() && g_handler->GetBrowserHwnd()) + RunAcceleratedLayersTest(g_handler->GetBrowser()); + + return FALSE; // Don't stop this message. +} + +// Callback for Debug > WebGL:... menu item. +gboolean WebGLActivated(GtkWidget* widget) { + if(g_handler.get() && g_handler->GetBrowserHwnd()) + RunWebGLTest(g_handler->GetBrowser()); + + return FALSE; // Don't stop this message. +} + +// Callback for Debug > HTML5 Video... menu item. +gboolean HTML5VideoActivated(GtkWidget* widget) { + if(g_handler.get() && g_handler->GetBrowserHwnd()) + RunHTML5VideoTest(g_handler->GetBrowser()); + + return FALSE; // Don't stop this message. +} + +// Callback for Debug > Zoom In... menu item. +gboolean ZoomInActivated(GtkWidget* widget) { + if(g_handler.get() && g_handler->GetBrowserHwnd()) { + CefRefPtr browser = g_handler->GetBrowser(); + browser->SetZoomLevel(browser->GetZoomLevel() + 0.5); + } + + return FALSE; // Don't stop this message. +} + +// Callback for Debug > Zoom Out... menu item. +gboolean ZoomOutActivated(GtkWidget* widget) { + if(g_handler.get() && g_handler->GetBrowserHwnd()) { + CefRefPtr browser = g_handler->GetBrowser(); + browser->SetZoomLevel(browser->GetZoomLevel() - 0.5); + } + + return FALSE; // Don't stop this message. +} + +// Callback for Debug > Zoom Reset... menu item. +gboolean ZoomResetActivated(GtkWidget* widget) { + if(g_handler.get() && g_handler->GetBrowserHwnd()) { + CefRefPtr browser = g_handler->GetBrowser(); + browser->SetZoomLevel(0.0); + } + + return FALSE; // Don't stop this message. +} + +gboolean DragDropActivated(GtkWidget* widget) { + if(g_handler.get() && g_handler->GetBrowserHwnd()) { + CefRefPtr browser = g_handler->GetBrowser(); + RunDragDropTest(browser); + } + + return FALSE; // Don't stop this message. +} + +gboolean ShowDevtoolsActivated(GtkWidget* widget) { + if(g_handler.get() && g_handler->GetBrowserHwnd()) { + CefRefPtr browser = g_handler->GetBrowser(); + browser->ShowDevTools(); + } + + return FALSE; // Don't stop this message. +} + +// Callback for when you click the back button. +void BackButtonClicked(GtkButton* button) { + if (g_handler.get() && g_handler->GetBrowserHwnd()) + g_handler->GetBrowser()->GoBack(); +} + +// Callback for when you click the forward button. +void ForwardButtonClicked(GtkButton* button) { + if (g_handler.get() && g_handler->GetBrowserHwnd()) + g_handler->GetBrowser()->GoForward(); +} + +// Callback for when you click the stop button. +void StopButtonClicked(GtkButton* button) { + if (g_handler.get() && g_handler->GetBrowserHwnd()) + g_handler->GetBrowser()->StopLoad(); +} + +// Callback for when you click the reload button. +void ReloadButtonClicked(GtkButton* button) { + if (g_handler.get() && g_handler->GetBrowserHwnd()) + g_handler->GetBrowser()->Reload(); +} + +// Callback for when you press enter in the URL box. +void URLEntryActivate(GtkEntry* entry) { + if (!g_handler.get() || !g_handler->GetBrowserHwnd()) + return; + + const gchar* url = gtk_entry_get_text(entry); + g_handler->GetBrowser()->GetMainFrame()->LoadURL(std::string(url).c_str()); +} + +// GTK utility functions ---------------------------------------------- + +GtkWidget* AddMenuEntry(GtkWidget* menu_widget, const char* text, + GCallback callback) { + GtkWidget* entry = gtk_menu_item_new_with_label(text); + g_signal_connect(entry, "activate", callback, NULL); + gtk_menu_shell_append(GTK_MENU_SHELL(menu_widget), entry); + return entry; +} + +GtkWidget* CreateMenu(GtkWidget* menu_bar, const char* text) { + GtkWidget* menu_widget = gtk_menu_new(); + GtkWidget* menu_header = gtk_menu_item_new_with_label(text); + gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_header), menu_widget); + gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), menu_header); + return menu_widget; +} + +GtkWidget* CreateMenuBar() { + GtkWidget* menu_bar = gtk_menu_bar_new(); + GtkWidget* debug_menu = CreateMenu(menu_bar, "Tests"); + + AddMenuEntry(debug_menu, "Get Source", + G_CALLBACK(GetSourceActivated)); + AddMenuEntry(debug_menu, "Get Text", + G_CALLBACK(GetTextActivated)); + AddMenuEntry(debug_menu, "JS Binding", + G_CALLBACK(JSBindngActivated)); + AddMenuEntry(debug_menu, "JS Extension", + G_CALLBACK(JSExtensionActivated)); + AddMenuEntry(debug_menu, "JS Execute", + G_CALLBACK(JSExecuteActivated)); + AddMenuEntry(debug_menu, "Request", + G_CALLBACK(RequestActivated)); + AddMenuEntry(debug_menu, "Local Storage", + G_CALLBACK(LocalStorageActivated)); + AddMenuEntry(debug_menu, "XMLHttpRequest", + G_CALLBACK(XMLHttpRequestActivated)); + AddMenuEntry(debug_menu, "DOM Access", + G_CALLBACK(DOMAccessActivated)); + AddMenuEntry(debug_menu, "Scheme Handler", + G_CALLBACK(SchemeHandlerActivated)); + AddMenuEntry(debug_menu, "Popup Window", + G_CALLBACK(PopupWindowActivated)); + AddMenuEntry(debug_menu, "Accelerated 2D Canvas", + G_CALLBACK(Accelerated2DCanvasActivated)); + AddMenuEntry(debug_menu, "Accelerated Layers", + G_CALLBACK(AcceleratedLayersActivated)); + AddMenuEntry(debug_menu, "WebGL", + G_CALLBACK(WebGLActivated)); + AddMenuEntry(debug_menu, "HTML5 Video", + G_CALLBACK(HTML5VideoActivated)); + AddMenuEntry(debug_menu, "Zoom In", + G_CALLBACK(ZoomInActivated)); + AddMenuEntry(debug_menu, "Zoom Out", + G_CALLBACK(ZoomOutActivated)); + AddMenuEntry(debug_menu, "Zoom Reset", + G_CALLBACK(ZoomResetActivated)); + AddMenuEntry(debug_menu, "Test DragDrop", + G_CALLBACK(DragDropActivated)); + AddMenuEntry(debug_menu, "Show DevTools", + G_CALLBACK(ShowDevtoolsActivated)); + + return menu_bar; +} + +// 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); + } + + return TRUE; +} + +int main(int argc, char *argv[]) { + if(!getcwd(szWorkingDir, sizeof (szWorkingDir))) + return -1; + + GtkWidget *window; + + gtk_init(&argc, &argv); + + CefSettings settings; + CefInitialize(settings); + + // Register the V8 extension handler. + InitExtensionTest(); + + // Register the scheme handler. + InitSchemeTest(); + + window = gtk_window_new(GTK_WINDOW_TOPLEVEL); + gtk_window_set_default_size(GTK_WINDOW(window), 800, 600); + + g_signal_connect(window, "focus", G_CALLBACK(&HandleFocus), NULL); + + GtkWidget* vbox = gtk_vbox_new(FALSE, 0); + + GtkWidget* menu_bar = CreateMenuBar(); + + gtk_box_pack_start(GTK_BOX(vbox), menu_bar, FALSE, FALSE, 0); + + GtkWidget* toolbar = gtk_toolbar_new(); + // Turn off the labels on the toolbar buttons. + gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_ICONS); + + GtkToolItem* back = gtk_tool_button_new_from_stock(GTK_STOCK_GO_BACK); + g_signal_connect(back, "clicked", + G_CALLBACK(BackButtonClicked), NULL); + gtk_toolbar_insert(GTK_TOOLBAR(toolbar), back, -1 /* append */); + + GtkToolItem* forward = gtk_tool_button_new_from_stock(GTK_STOCK_GO_FORWARD); + g_signal_connect(forward, "clicked", + G_CALLBACK(ForwardButtonClicked), NULL); + gtk_toolbar_insert(GTK_TOOLBAR(toolbar), forward, -1 /* append */); + + GtkToolItem* reload = gtk_tool_button_new_from_stock(GTK_STOCK_REFRESH); + g_signal_connect(reload, "clicked", + G_CALLBACK(ReloadButtonClicked), NULL); + gtk_toolbar_insert(GTK_TOOLBAR(toolbar), reload, -1 /* append */); + + GtkToolItem* stop = gtk_tool_button_new_from_stock(GTK_STOCK_STOP); + g_signal_connect(stop, "clicked", + G_CALLBACK(StopButtonClicked), NULL); + gtk_toolbar_insert(GTK_TOOLBAR(toolbar), stop, -1 /* append */); + + GtkWidget* m_editWnd = gtk_entry_new(); + g_signal_connect(G_OBJECT(m_editWnd), "activate", + G_CALLBACK(URLEntryActivate), NULL); + + GtkToolItem* tool_item = gtk_tool_item_new(); + gtk_container_add(GTK_CONTAINER(tool_item), m_editWnd); + gtk_tool_item_set_expand(tool_item, TRUE); + gtk_toolbar_insert(GTK_TOOLBAR(toolbar), tool_item, -1); //append + + gtk_box_pack_start(GTK_BOX(vbox), toolbar, FALSE, 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); + + // Create the handler. + g_handler = new ClientHandler(); + g_handler->SetMainHwnd(vbox); + g_handler->SetEditHwnd(m_editWnd); + g_handler->SetButtonHwnds(GTK_WIDGET(back), GTK_WIDGET(forward), + GTK_WIDGET(reload), GTK_WIDGET(stop)); + + // Create the browser view. + CefWindowInfo window_info; + CefBrowserSettings browserSettings; + + window_info.SetAsChild(vbox); + + CefBrowser::CreateBrowserSync(window_info, + static_cast >(g_handler), + "http://www.google.com", browserSettings); + + gtk_container_add(GTK_CONTAINER(window), vbox); + gtk_widget_show_all(GTK_WIDGET(window)); + + // Install an signal handler so we clean up after ourselves. + signal(SIGINT, TerminationSignalHandler); + signal(SIGTERM, TerminationSignalHandler); + + CefRunMessageLoop(); + + return 0; +} + +// Global functions + +std::string AppGetWorkingDirectory() { + return szWorkingDir; +} diff --git a/tests/cefclient/client_handler_gtk.cpp b/tests/cefclient/client_handler_gtk.cpp new file mode 100644 index 000000000..433bcd7c0 --- /dev/null +++ b/tests/cefclient/client_handler_gtk.cpp @@ -0,0 +1,120 @@ +#include "include/cef.h" +#include "include/cef_wrapper.h" +#include "cefclient.h" +#include "client_handler.h" +#include "resource_util.h" +#include "string_util.h" +#include + +// ClientHandler::ClientLifeSpanHandler implementation +bool ClientHandler::OnBeforePopup(CefRefPtr parentBrowser, + const CefPopupFeatures& popupFeatures, + CefWindowInfo& windowInfo, + const CefString& url, + CefRefPtr& client, + CefBrowserSettings& settings) +{ + REQUIRE_UI_THREAD(); + + return false; +} + +bool ClientHandler::OnBeforeResourceLoad(CefRefPtr browser, + CefRefPtr request, + CefString& redirectUrl, + CefRefPtr& resourceStream, + CefRefPtr response, + int loadFlags) +{ + REQUIRE_IO_THREAD(); + + std::string url = request->GetURL(); + + if(url == "http://tests/request") { + // Show the request contents + std::string dump; + DumpRequestContents(request, dump); + resourceStream = CefStreamReader::CreateForData( + (void*)dump.c_str(), dump.size()); + response->SetMimeType("text/plain"); + response->SetStatus(200); + } else if (strstr(url.c_str(), "/ps_logo2.png") != NULL) { + // Any time we find "ps_logo2.png" in the URL substitute in our own image + resourceStream = GetBinaryResourceReader("logo.png"); + response->SetMimeType("image/png"); + response->SetStatus(200); + } else if(url == "http://tests/localstorage") { + // Show the localstorage contents + resourceStream = GetBinaryResourceReader("localstorage.html"); + response->SetMimeType("text/html"); + response->SetStatus(200); + } else if(url == "http://tests/xmlhttprequest") { + // Show the xmlhttprequest HTML contents + resourceStream = GetBinaryResourceReader("xmlhttprequest.html"); + response->SetMimeType("text/html"); + response->SetStatus(200); + } else if(url == "http://tests/domaccess") { + // Show the domaccess HTML contents + resourceStream = GetBinaryResourceReader("domaccess.html"); + response->SetMimeType("text/html"); + response->SetStatus(200); + } + + return false; +} + +void ClientHandler::OnAddressChange(CefRefPtr browser, + CefRefPtr frame, + const CefString& url) +{ + REQUIRE_UI_THREAD(); + + if(m_BrowserHwnd == browser->GetWindowHandle() && frame->IsMain()) { + // Set the edit window text + std::string urlStr(url); + gtk_entry_set_text(GTK_ENTRY(m_EditHwnd), urlStr.c_str()); + } +} + +void ClientHandler::OnTitleChange(CefRefPtr browser, + const CefString& title) +{ + REQUIRE_UI_THREAD(); + + GtkWidget* window = + gtk_widget_get_ancestor(GTK_WIDGET(browser->GetWindowHandle()), + GTK_TYPE_WINDOW); + std::string titleStr(title); + gtk_window_set_title(GTK_WINDOW(window), titleStr.c_str()); +} + +void ClientHandler::SendNotification(NotificationType type) +{ + // TODO(port): Implement this method. +} + +void ClientHandler::SetLoading(bool isLoading) +{ + if(isLoading) + gtk_widget_set_sensitive(GTK_WIDGET(m_StopHwnd), true); + else + gtk_widget_set_sensitive(GTK_WIDGET(m_StopHwnd), false); +} + +void ClientHandler::SetNavState(bool canGoBack, bool canGoForward) +{ + if(canGoBack) + gtk_widget_set_sensitive(GTK_WIDGET(m_BackHwnd), true); + else + gtk_widget_set_sensitive(GTK_WIDGET(m_BackHwnd), false); + + if(canGoForward) + gtk_widget_set_sensitive(GTK_WIDGET(m_ForwardHwnd), true); + else + gtk_widget_set_sensitive(GTK_WIDGET(m_ForwardHwnd), false); +} + +void ClientHandler::CloseMainWindow() +{ + // TODO(port): Close main window. +} diff --git a/tests/cefclient/resource_util.h b/tests/cefclient/resource_util.h index dbdbacdaa..e1fe9c246 100644 --- a/tests/cefclient/resource_util.h +++ b/tests/cefclient/resource_util.h @@ -15,7 +15,7 @@ bool LoadBinaryResource(int binaryId, DWORD &dwSize, LPBYTE &pBytes); CefRefPtr GetBinaryResourceReader(int binaryId); -#elif defined(OS_MACOSX) +#elif (defined(OS_MACOSX) || defined(OS_POSIX)) // Load the resource with the specified name. bool LoadBinaryResource(const char* resource_name, std::string& resource_data); diff --git a/tests/cefclient/resource_util_linux.cpp b/tests/cefclient/resource_util_linux.cpp new file mode 100644 index 000000000..45a573a73 --- /dev/null +++ b/tests/cefclient/resource_util_linux.cpp @@ -0,0 +1,39 @@ +// Copyright (c) 2011 The Chromium Embedded Framework Authors. +// Portions copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "resource_util.h" +#include "util.h" +#include + +#include "base/file_util.h" + +bool GetResourceDir(std::string& dir) { + char buff[1024]; + ssize_t len = ::readlink("/proc/self/exe", buff, sizeof(buff)-1); + + if (len != -1) { + buff[len] = '\0'; + dir = std::string(buff); + return true; + } else { + /* handle error condition */ + return false; + } +} + +bool LoadBinaryResource(const char* resource_name, std::string& resource_data) { + return false; +} + +CefRefPtr GetBinaryResourceReader(const char* resource_name) { + std::string path; + if (!GetResourceDir(path)) + return NULL; + + path.append("/"); + path.append(resource_name); + + return CefStreamReader::CreateForFile(path); +} diff --git a/tests/cefclient/scheme_test.cpp b/tests/cefclient/scheme_test.cpp index dac915bb6..d02117b98 100644 --- a/tests/cefclient/scheme_test.cpp +++ b/tests/cefclient/scheme_test.cpp @@ -67,12 +67,14 @@ public: // Set the resulting mime type mime_type_ = "image/jpg"; } -#elif defined(OS_MACOSX) +#elif (defined(OS_MACOSX) || defined(OS_LINUX)) if(LoadBinaryResource("logo.png", data_)) { handled = true; // Set the resulting mime type mime_type_ = "image/png"; } +#else +#error "Unsupported platform" #endif } diff --git a/tests/unittests/navigation_unittest.cc b/tests/unittests/navigation_unittest.cc index a9aef8fc6..94f2b124f 100644 --- a/tests/unittests/navigation_unittest.cc +++ b/tests/unittests/navigation_unittest.cc @@ -174,7 +174,7 @@ TEST(NavigationTest, History) new HistoryNavTestHandler(); handler->ExecuteTest(); - for (int i = 0; i < NAV_LIST_SIZE(); ++i) { + for (size_t i = 0; i < NAV_LIST_SIZE(); ++i) { if (kNavList[i].action != NA_CLEAR) { ASSERT_TRUE(handler->got_before_browse_[i]) << "i = " << i; ASSERT_TRUE(handler->got_correct_target_[i]) << "i = " << i; diff --git a/tests/unittests/v8_unittest.cc b/tests/unittests/v8_unittest.cc index 8b235e2f4..a44335d7d 100644 --- a/tests/unittests/v8_unittest.cc +++ b/tests/unittests/v8_unittest.cc @@ -90,7 +90,7 @@ public: value = arguments[argct]->GetValue(subargct); ASSERT_TRUE(value.get() != NULL); ASSERT_TRUE(value->IsBool()); - ASSERT_EQ(false, value->GetBoolValue()); + ASSERT_FALSE(value->GetBoolValue()); subargct++; value = arguments[argct]->GetValue(subargct); diff --git a/tools/build_projects.sh b/tools/build_projects.sh index 080e02f11..7aa0022fa 100755 --- a/tools/build_projects.sh +++ b/tools/build_projects.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash if [ -z "$1" ]; then echo "ERROR: Please specify a build target: Debug or Release" @@ -8,6 +8,11 @@ else else PROJECT_NAME=$2 fi - - xcodebuild -project ../cef.xcodeproj -configuration $1 -target $PROJECT_NAME + if [ `uname` = "Linux" ]; then + pushd ../../ + make BUILDTYPE=$1 -j 16 + popd + else + xcodebuild -project ../cef.xcodeproj -configuration $1 -target $PROJECT_NAME + fi fi diff --git a/tools/make_capi_header.py b/tools/make_capi_header.py index 78d99c527..4bd645cae 100644 --- a/tools/make_capi_header.py +++ b/tools/make_capi_header.py @@ -122,7 +122,7 @@ typedef struct _cef_base_t // Check that the structure |s|, which is defined with a cef_base_t member named // |base|, is large enough to contain the specified member |f|. #define CEF_MEMBER_EXISTS(s, f) \\ - ((int)&((s)->f) - (int)(s) + sizeof((s)->f) <= (s)->base.size) + ((intptr_t)&((s)->f) - (intptr_t)(s) + sizeof((s)->f) <= (s)->base.size) #define CEF_MEMBER_MISSING(s, f) (!CEF_MEMBER_EXISTS(s, f) || !((s)->f)) diff --git a/tools/make_distrib.py b/tools/make_distrib.py index fc69b241c..44ffcb325 100644 --- a/tools/make_distrib.py +++ b/tools/make_distrib.py @@ -140,7 +140,7 @@ if sys.platform == 'win32': platform = 'windows' elif sys.platform == 'darwin': platform = 'macosx' -elif sys.platform == 'linux2': +elif sys.platform.startswith('linux'): platform = 'linux' # output directory @@ -149,8 +149,8 @@ output_dir = os.path.abspath(os.path.join(options.outputdir, \ remove_dir(output_dir, options.quiet) make_dir(output_dir, options.quiet) -# transfer the LICENSE.TXT file -copy_file(os.path.join(cef_dir, 'LICENSE.TXT'), output_dir, options.quiet) +# transfer the LICENSE.txt file +copy_file(os.path.join(cef_dir, 'LICENSE.txt'), output_dir, options.quiet) # read the variables list from cef_paths.gypi cef_paths = eval_file(os.path.join(cef_dir, 'cef_paths.gypi')) @@ -314,6 +314,31 @@ elif platform == 'macosx': write_file(src_file, data) elif platform == 'linux': + linux_build_dir = os.path.join(cef_dir, os.pardir, 'out') + # transfer build/Debug files + if not options.allowpartial or path_exists(os.path.join(linux_build_dir, 'Debug')): + dst_dir = os.path.join(output_dir, 'Debug') + make_dir(dst_dir, options.quiet) + copy_files(os.path.join(linux_build_dir, 'Debug/lib.target/*'), dst_dir, options.quiet) + copy_file(os.path.join(linux_build_dir, 'Debug/cefclient'), dst_dir, options.quiet) + copy_file(os.path.join(linux_build_dir, 'Debug/chrome.pak'), dst_dir, options.quiet) + copy_dir(os.path.join(linux_build_dir, 'Debug/locales'), os.path.join(dst_dir, 'locales'), options.quiet) + + else: + sys.stderr.write("No Debug build files.\n") + + # transfer build/Release files + if not options.allowpartial or path_exists(os.path.join(linux_build_dir, 'Release')): + dst_dir = os.path.join(output_dir, 'Release') + make_dir(dst_dir, options.quiet) + copy_files(os.path.join(linux_build_dir, 'Release/lib.target/*'), dst_dir, options.quiet) + copy_file(os.path.join(linux_build_dir, 'Release/cefclient'), dst_dir, options.quiet) + copy_file(os.path.join(linux_build_dir, 'Release/chrome.pak'), dst_dir, options.quiet) + copy_dir(os.path.join(linux_build_dir, 'Release/locales'), os.path.join(dst_dir, 'locales'), options.quiet) + + else: + sys.stderr.write("No Release build files.\n") + # transfer include files transfer_gypi_files(cef_dir, cef_paths['includes_linux'], \ 'include/', include_dir, options.quiet)