Add initial Linux support (issue #40).

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@338 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt 2011-10-24 20:20:52 +00:00
parent becadcfd16
commit 7a91ff899f
25 changed files with 986 additions and 51 deletions

80
cef.gyp
View File

@ -4,6 +4,7 @@
{ {
'variables': { 'variables': {
'pkg-config': 'pkg-config',
'chromium_code': 1, 'chromium_code': 1,
'repack_locales_cmd': ['python', 'tools/repack_locales.py'], 'repack_locales_cmd': ['python', 'tools/repack_locales.py'],
'grit_out_dir': '<(SHARED_INTERMEDIATE_DIR)/cef', 'grit_out_dir': '<(SHARED_INTERMEDIATE_DIR)/cef',
@ -211,6 +212,67 @@
'<@(includes_linux)', '<@(includes_linux)',
'<@(cefclient_sources_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': [
'<!@pymod_do_main(repack_locales -o -g <(grit_out_dir) -s <(SHARED_INTERMEDIATE_DIR) -x <(INTERMEDIATE_DIR) <(locales))'
],
},
{
'destination': '<(PRODUCT_DIR)',
'files': [
'<(INTERMEDIATE_DIR)/repack/chrome.pak'
],
},
],
}], }],
], ],
}, },
@ -437,6 +499,24 @@
], ],
}, },
}], }],
[ 'OS=="linux" or OS=="freebsd" or OS=="openbsd"', {
'dependencies':[
'../base/allocator/allocator.gyp:allocator',
],
'direct_dependent_settings': {
'cflags': [
'<!@(<(pkg-config) --cflags gtk+-2.0 gthread-2.0)',
],
},
'link_settings': {
'ldflags': [
'<!@(<(pkg-config) --libs-only-L --libs-only-other gtk+-2.0 gthread-2.0)',
],
'libraries': [
'<!@(<(pkg-config) --libs-only-l gtk+-2.0 gthread-2.0)',
],
},
}],
], ],
}, },
{ {

View File

@ -110,6 +110,8 @@
], ],
'cefclient_sources_linux': [ 'cefclient_sources_linux': [
'tests/cefclient/cefclient_gtk.cpp', 'tests/cefclient/cefclient_gtk.cpp',
'tests/cefclient/client_handler_gtk.cpp',
'tests/cefclient/resource_util_linux.cpp',
], ],
'libcef_dll_wrapper_sources_common': [ 'libcef_dll_wrapper_sources_common': [
'libcef_dll/cef_logging.h', 'libcef_dll/cef_logging.h',

View File

@ -373,7 +373,7 @@ typedef struct _cef_base_t
// Check that the structure |s|, which is defined with a cef_base_t member named // 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|. // |base|, is large enough to contain the specified member |f|.
#define CEF_MEMBER_EXISTS(s, 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)) #define CEF_MEMBER_MISSING(s, f) (!CEF_MEMBER_EXISTS(s, f) || !((s)->f))

View File

@ -1111,6 +1111,7 @@ CefRefPtr<CefBrowserImpl> CefBrowserImpl::UIT_CreatePopupWindow(
info.SetAsPopup(NULL, CefString()); info.SetAsPopup(NULL, CefString());
#endif #endif
#if (defined(OS_WIN) || defined(OS_MACOSX))
// Default to the size from the popup features. // Default to the size from the popup features.
if(features.xSet) if(features.xSet)
info.m_x = features.x; info.m_x = features.x;
@ -1120,6 +1121,7 @@ CefRefPtr<CefBrowserImpl> CefBrowserImpl::UIT_CreatePopupWindow(
info.m_nWidth = features.width; info.m_nWidth = features.width;
if(features.heightSet) if(features.heightSet)
info.m_nHeight = features.height; info.m_nHeight = features.height;
#endif
CefRefPtr<CefClient> client = client_; CefRefPtr<CefClient> client = client_;

View File

@ -35,11 +35,9 @@ bool CefBrowserImpl::IsWindowRenderingDisabled()
return false; return false;
} }
gfx::NativeWindow CefBrowserImpl::UIT_GetMainWndHandle() { gfx::NativeView CefBrowserImpl::UIT_GetMainWndHandle() {
REQUIRE_UIT(); REQUIRE_UIT();
GtkWidget* toplevel = gtk_widget_get_ancestor(window_info_.m_Widget, return window_info_.m_Widget;
GTK_TYPE_WINDOW);
return GTK_IS_WINDOW(toplevel) ? GTK_WINDOW(toplevel) : NULL;
} }
bool CefBrowserImpl::UIT_CreateBrowser(const CefString& url) bool CefBrowserImpl::UIT_CreateBrowser(const CefString& url)
@ -56,6 +54,23 @@ bool CefBrowserImpl::UIT_CreateBrowser(const CefString& url)
if (!settings_.developer_tools_disabled) if (!settings_.developer_tools_disabled)
dev_tools_agent_.reset(new BrowserDevToolsAgent()); 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; WebPreferences prefs;
BrowserToWebSettings(settings_, prefs); BrowserToWebSettings(settings_, prefs);
@ -72,9 +87,12 @@ bool CefBrowserImpl::UIT_CreateBrowser(const CefString& url)
Unlock(); Unlock();
if(handler_.get()) { if (client_.get()) {
CefRefPtr<CefLifeSpanHandler> handler = client_->GetLifeSpanHandler();
if(handler.get()) {
// Notify the handler that we're done creating the new window // Notify the handler that we're done creating the new window
handler_->HandleAfterCreated(this); handler->OnAfterCreated(this);
}
} }
if(url.size() > 0) if(url.size() > 0)
@ -97,9 +115,37 @@ bool CefBrowserImpl::UIT_ViewDocumentString(WebKit::WebFrame *frame)
{ {
REQUIRE_UIT(); REQUIRE_UIT();
// TODO(port): Add implementation. char buff[] = "/tmp/CEFSourceXXXXXX";
NOTIMPLEMENTED(); int fd = mkstemp(buff);
if (fd == -1)
return false; 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, void CefBrowserImpl::UIT_PrintPage(int page_number, int total_pages,
@ -130,6 +176,21 @@ int CefBrowserImpl::UIT_GetPagesCount(WebKit::WebFrame* frame)
// static // static
void CefBrowserImpl::UIT_CloseView(gfx::NativeView view) 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( MessageLoop::current()->PostTask(FROM_HERE, NewRunnableFunction(
&gtk_widget_destroy, GTK_WIDGET(view))); &gtk_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;
} }

View File

@ -129,10 +129,24 @@ void BrowserRequestContext::Init(
#endif // defined(OS_WIN) #endif // defined(OS_WIN)
if (!proxy_service()) { 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<net::ProxyConfigService> proxy_config_service(
new net::ProxyConfigServiceFixed(net::ProxyConfig()));
#else
// Use the system proxy settings.
scoped_ptr<net::ProxyConfigService> proxy_config_service( scoped_ptr<net::ProxyConfigService> proxy_config_service(
net::ProxyService::CreateSystemProxyConfigService( net::ProxyService::CreateSystemProxyConfigService(
MessageLoop::current(), NULL)); MessageLoop::current(), NULL));
#endif
storage_.set_proxy_service(net::ProxyService::CreateUsingSystemProxyResolver( storage_.set_proxy_service(net::ProxyService::CreateUsingSystemProxyResolver(
proxy_config_service.release(), 0, NULL)); proxy_config_service.release(), 0, NULL));
} }

View File

@ -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 "<<resource_id<<" could not be loaded";
return piece;
}
}

View File

@ -259,6 +259,10 @@ class BrowserWebViewDelegate : public WebKit::WebViewClient,
void ClosePopupMenu(); void ClosePopupMenu();
#endif #endif
#ifdef OS_LINUX
void HandleContextMenu(int selected_id);
#endif
protected: protected:
// Default handling of JavaScript messages. // Default handling of JavaScript messages.
void ShowJavaScriptAlert(WebKit::WebFrame* webframe, void ShowJavaScriptAlert(WebKit::WebFrame* webframe,

View File

@ -10,25 +10,41 @@
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include "base/message_loop.h" #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/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/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/WebRect.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.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/gtk_util.h"
#include "ui/gfx/point.h" #include "ui/gfx/point.h"
#include "webkit/glue/webcursor.h"
#include "webkit/glue/webdropdata.h" #include "webkit/glue/webdropdata.h"
#include "webkit/glue/webpreferences.h" #include "webkit/glue/webpreferences.h"
#include "webkit/glue/webkit_glue.h"
#include "webkit/glue/window_open_disposition.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/plugin_list.h"
#include "webkit/plugins/npapi/webplugin.h" #include "webkit/plugins/npapi/webplugin.h"
#include "webkit/plugins/npapi/webplugin_delegate_impl.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::WebCursorInfo;
using WebKit::WebDragData;
using WebKit::WebDragOperationsMask;
using WebKit::WebExternalPopupMenu;
using WebKit::WebExternalPopupMenuClient;
using WebKit::WebFrame; using WebKit::WebFrame;
using WebKit::WebImage;
using WebKit::WebNavigationPolicy; using WebKit::WebNavigationPolicy;
using WebKit::WebPoint;
using WebKit::WebPopupMenuInfo; using WebKit::WebPopupMenuInfo;
using WebKit::WebRect; using WebKit::WebRect;
using WebKit::WebWidget; using WebKit::WebWidget;
@ -59,11 +75,11 @@ void SelectionClipboardGetContents(GtkClipboard* clipboard,
DCHECK(frame); DCHECK(frame);
std::string selection; std::string selection;
if (TEXT_HTML == info) { if (TEXT_HTML == info)
selection = frame->selectionAsMarkup().utf8(); selection = frame->selectionAsMarkup().utf8();
} else { else
selection = frame->selectionAsText().utf8(); selection = frame->selectionAsText().utf8();
}
if (TEXT_HTML == info) { if (TEXT_HTML == info) {
gtk_selection_data_set(selection_data, gtk_selection_data_set(selection_data,
GetTextHtmlAtom(), GetTextHtmlAtom(),
@ -78,17 +94,112 @@ void SelectionClipboardGetContents(GtkClipboard* clipboard,
} // namespace } // namespace
// WebViewClient -------------------------------------------------------------- // WebViewClient ----------------------------------s----------------------------
WebWidget* BrowserWebViewDelegate::createPopupMenu( WebKit::WebExternalPopupMenu* BrowserWebViewDelegate::createExternalPopupMenu(
const WebPopupMenuInfo& info) { const WebKit::WebPopupMenuInfo& info,
NOTREACHED(); WebKit::WebExternalPopupMenuClient* client) {
NOTIMPLEMENTED();
return NULL; return NULL;
} }
void BrowserWebViewDelegate::showContextMenu( static gboolean MenuItemHandle(GtkWidget* menu_item, gpointer data)
WebKit::WebFrame* frame, const WebKit::WebContextMenuData& data) { {
NOTIMPLEMENTED(); 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<CefClient> client = browser_->GetClient();
CefRefPtr<CefMenuHandler> 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 ------------------------------------------------------------ // WebWidgetClient ------------------------------------------------------------
@ -123,7 +234,8 @@ void BrowserWebViewDelegate::didChangeCursor(const WebCursorInfo& cursor_info) {
gdk_cursor = gfx::GetCursor(cursor_type); gdk_cursor = gfx::GetCursor(cursor_type);
} }
cursor_type_ = 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() { WebRect BrowserWebViewDelegate::windowRect() {
@ -161,9 +273,9 @@ WebRect BrowserWebViewDelegate::rootWindowRect() {
// window. This means the x/y is the distance from the corner of the // 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. // 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. // For example, this is used to implement window.screenX and window.screenY.
GtkWidget* drawing_area = host->view_handle(); GtkWidget* window = gtk_widget_get_ancestor(GTK_WIDGET(host->view_handle()),
GtkWidget* window = GTK_TYPE_WINDOW);
gtk_widget_get_parent(gtk_widget_get_parent(drawing_area));
gint x, y, width, height; gint x, y, width, height;
gtk_window_get_position(GTK_WINDOW(window), &x, &y); gtk_window_get_position(GTK_WINDOW(window), &x, &y);
gtk_window_get_size(GTK_WINDOW(window), &width, &height); gtk_window_get_size(GTK_WINDOW(window), &width, &height);
@ -222,6 +334,30 @@ void BrowserWebViewDelegate::DidMovePlugin(
plugin_container_manager->MovePluginContainer(move); plugin_container_manager->MovePluginContainer(move);
} }
void BrowserWebViewDelegate::HandleContextMenu(int selected_id)
{
if (selected_id != 0) {
CefRefPtr<CefClient> client = browser_->GetClient();
CefRefPtr<CefMenuHandler> handler;
if (client.get())
handler = client->GetMenuHandler();
// An action was chosen
cef_handler_menuid_t menuId =
static_cast<cef_handler_menuid_t>(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 ---------------------------------------------------------- // Protected methods ----------------------------------------------------------
void BrowserWebViewDelegate::ShowJavaScriptAlert( void BrowserWebViewDelegate::ShowJavaScriptAlert(

View File

@ -30,7 +30,7 @@ CEF_EXPORT int cef_string_map_find(cef_string_map_t map,
StringMap* impl = (StringMap*)map; StringMap* impl = (StringMap*)map;
StringMap::const_iterator it = impl->find(CefString(key)); StringMap::const_iterator it = impl->find(CefString(key));
if(it == impl->end()) if(it == impl->end())
return NULL; return 0;
const CefString& val = it->second; const CefString& val = it->second;
return cef_string_set(val.c_str(), val.length(), value, true); 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; StringMap* impl = (StringMap*)map;
DCHECK(index >= 0 && index < (int)impl->size()); DCHECK(index >= 0 && index < (int)impl->size());
if(index < 0 || index >= (int)impl->size()) if(index < 0 || index >= (int)impl->size())
return NULL; return 0;
StringMap::const_iterator it = impl->begin(); StringMap::const_iterator it = impl->begin();
for(int ct = 0; it != impl->end(); ++it, ct++) { for(int ct = 0; it != impl->end(); ++it, ct++) {
if(ct == index) 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; StringMap* impl = (StringMap*)map;
DCHECK(index >= 0 && index < (int)impl->size()); DCHECK(index >= 0 && index < (int)impl->size());
if(index < 0 || index >= (int)impl->size()) if(index < 0 || index >= (int)impl->size())
return NULL; return 0;
StringMap::const_iterator it = impl->begin(); StringMap::const_iterator it = impl->begin();
for(int ct = 0; it != impl->end(); ++it, ct++) { for(int ct = 0; it != impl->end(); ++it, ct++) {
if(ct == index) { if(ct == index) {

View File

@ -303,7 +303,7 @@ private:
job_->NotifyReadComplete(bytes_read); job_->NotifyReadComplete(bytes_read);
dest_ = NULL; dest_ = NULL;
dest_size_ = NULL; dest_size_ = 0;
} }
} else { } else {
// All done. // All done.

View File

@ -73,7 +73,7 @@ gfx::PluginWindowHandle WebWidgetHost::GetWindowedPluginAt(int x, int y)
} }
} }
return NULL; return gfx::kNullPluginWindow;
} }
void WebWidgetHost::DoPaint() { void WebWidgetHost::DoPaint() {

View File

@ -227,6 +227,9 @@ class WebWidgetHostGtkWidget {
return FALSE; // We do not forward any other buttons to the renderer. return FALSE; // We do not forward any other buttons to the renderer.
if (event->type == GDK_2BUTTON_PRESS || event->type == GDK_3BUTTON_PRESS) if (event->type == GDK_2BUTTON_PRESS || event->type == GDK_3BUTTON_PRESS)
return FALSE; return FALSE;
gtk_widget_grab_focus(widget);
host->webwidget()->handleInputEvent( host->webwidget()->handleInputEvent(
WebInputEventFactory::mouseEvent(event)); WebInputEventFactory::mouseEvent(event));
return FALSE; return FALSE;
@ -346,7 +349,8 @@ WebWidgetHost::~WebWidgetHost() {
g_object_set_data(G_OBJECT(view_), kWebWidgetHostKey, NULL); g_object_set_data(G_OBJECT(view_), kWebWidgetHostKey, NULL);
g_signal_handlers_disconnect_matched(view_, g_signal_handlers_disconnect_matched(view_,
G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, this); 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) { void WebWidgetHost::Resize(const gfx::Size &newsize) {

View File

@ -110,7 +110,7 @@ int CEF_CALLBACK domdocument_has_selection(struct _cef_domdocument_t* self)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return NULL; return 0;
return CefDOMDocumentCppToC::Get(self)->HasSelection(); return CefDOMDocumentCppToC::Get(self)->HasSelection();
} }
@ -134,7 +134,7 @@ int CEF_CALLBACK domdocument_get_selection_start_offset(
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return NULL; return 0;
return CefDOMDocumentCppToC::Get(self)->GetSelectionStartOffset(); return CefDOMDocumentCppToC::Get(self)->GetSelectionStartOffset();
} }
@ -158,7 +158,7 @@ int CEF_CALLBACK domdocument_get_selection_end_offset(
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return NULL; return 0;
return CefDOMDocumentCppToC::Get(self)->GetSelectionEndOffset(); return CefDOMDocumentCppToC::Get(self)->GetSelectionEndOffset();
} }

View File

@ -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 <gtk/gtk.h>
#include <stdlib.h>
#include <unistd.h>
#include "string_util.h"
#include <iostream>
using namespace std;
char szWorkingDir[512]; // The current working directory
// The global ClientHandler reference.
extern CefRefPtr<ClientHandler> 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<CefBrowser> 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<CefBrowser> 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<CefBrowser> 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<CefBrowser> 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<CefBrowser> 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<CefRefPtr<CefClient> >(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;
}

View File

@ -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 <gtk/gtk.h>
// 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();
return false;
}
bool ClientHandler::OnBeforeResourceLoad(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefRequest> request,
CefString& redirectUrl,
CefRefPtr<CefStreamReader>& resourceStream,
CefRefPtr<CefResponse> 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<CefBrowser> browser,
CefRefPtr<CefFrame> 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<CefBrowser> 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.
}

View File

@ -15,7 +15,7 @@
bool LoadBinaryResource(int binaryId, DWORD &dwSize, LPBYTE &pBytes); bool LoadBinaryResource(int binaryId, DWORD &dwSize, LPBYTE &pBytes);
CefRefPtr<CefStreamReader> GetBinaryResourceReader(int binaryId); CefRefPtr<CefStreamReader> GetBinaryResourceReader(int binaryId);
#elif defined(OS_MACOSX) #elif (defined(OS_MACOSX) || defined(OS_POSIX))
// Load the resource with the specified name. // Load the resource with the specified name.
bool LoadBinaryResource(const char* resource_name, std::string& resource_data); bool LoadBinaryResource(const char* resource_name, std::string& resource_data);

View File

@ -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 <stdio.h>
#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<CefStreamReader> GetBinaryResourceReader(const char* resource_name) {
std::string path;
if (!GetResourceDir(path))
return NULL;
path.append("/");
path.append(resource_name);
return CefStreamReader::CreateForFile(path);
}

View File

@ -67,12 +67,14 @@ public:
// Set the resulting mime type // Set the resulting mime type
mime_type_ = "image/jpg"; mime_type_ = "image/jpg";
} }
#elif defined(OS_MACOSX) #elif (defined(OS_MACOSX) || defined(OS_LINUX))
if(LoadBinaryResource("logo.png", data_)) { if(LoadBinaryResource("logo.png", data_)) {
handled = true; handled = true;
// Set the resulting mime type // Set the resulting mime type
mime_type_ = "image/png"; mime_type_ = "image/png";
} }
#else
#error "Unsupported platform"
#endif #endif
} }

View File

@ -174,7 +174,7 @@ TEST(NavigationTest, History)
new HistoryNavTestHandler(); new HistoryNavTestHandler();
handler->ExecuteTest(); 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) { if (kNavList[i].action != NA_CLEAR) {
ASSERT_TRUE(handler->got_before_browse_[i]) << "i = " << i; ASSERT_TRUE(handler->got_before_browse_[i]) << "i = " << i;
ASSERT_TRUE(handler->got_correct_target_[i]) << "i = " << i; ASSERT_TRUE(handler->got_correct_target_[i]) << "i = " << i;

View File

@ -90,7 +90,7 @@ public:
value = arguments[argct]->GetValue(subargct); value = arguments[argct]->GetValue(subargct);
ASSERT_TRUE(value.get() != NULL); ASSERT_TRUE(value.get() != NULL);
ASSERT_TRUE(value->IsBool()); ASSERT_TRUE(value->IsBool());
ASSERT_EQ(false, value->GetBoolValue()); ASSERT_FALSE(value->GetBoolValue());
subargct++; subargct++;
value = arguments[argct]->GetValue(subargct); value = arguments[argct]->GetValue(subargct);

View File

@ -1,4 +1,4 @@
#!/bin/sh #!/bin/bash
if [ -z "$1" ]; then if [ -z "$1" ]; then
echo "ERROR: Please specify a build target: Debug or Release" echo "ERROR: Please specify a build target: Debug or Release"
@ -8,6 +8,11 @@ else
else else
PROJECT_NAME=$2 PROJECT_NAME=$2
fi fi
if [ `uname` = "Linux" ]; then
pushd ../../
make BUILDTYPE=$1 -j 16
popd
else
xcodebuild -project ../cef.xcodeproj -configuration $1 -target $PROJECT_NAME xcodebuild -project ../cef.xcodeproj -configuration $1 -target $PROJECT_NAME
fi
fi fi

View File

@ -122,7 +122,7 @@ typedef struct _cef_base_t
// Check that the structure |s|, which is defined with a cef_base_t member named // 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|. // |base|, is large enough to contain the specified member |f|.
#define CEF_MEMBER_EXISTS(s, 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)) #define CEF_MEMBER_MISSING(s, f) (!CEF_MEMBER_EXISTS(s, f) || !((s)->f))

View File

@ -140,7 +140,7 @@ if sys.platform == 'win32':
platform = 'windows' platform = 'windows'
elif sys.platform == 'darwin': elif sys.platform == 'darwin':
platform = 'macosx' platform = 'macosx'
elif sys.platform == 'linux2': elif sys.platform.startswith('linux'):
platform = 'linux' platform = 'linux'
# output directory # output directory
@ -149,8 +149,8 @@ output_dir = os.path.abspath(os.path.join(options.outputdir, \
remove_dir(output_dir, options.quiet) remove_dir(output_dir, options.quiet)
make_dir(output_dir, options.quiet) make_dir(output_dir, options.quiet)
# transfer the LICENSE.TXT file # transfer the LICENSE.txt file
copy_file(os.path.join(cef_dir, 'LICENSE.TXT'), output_dir, options.quiet) copy_file(os.path.join(cef_dir, 'LICENSE.txt'), output_dir, options.quiet)
# read the variables list from cef_paths.gypi # read the variables list from cef_paths.gypi
cef_paths = eval_file(os.path.join(cef_dir, '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) write_file(src_file, data)
elif platform == 'linux': 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 include files
transfer_gypi_files(cef_dir, cef_paths['includes_linux'], \ transfer_gypi_files(cef_dir, cef_paths['includes_linux'], \
'include/', include_dir, options.quiet) 'include/', include_dir, options.quiet)