diff --git a/Atom-Linux/.gitignore b/Atom-Linux/.gitignore new file mode 100644 index 000000000..8c73eb79f --- /dev/null +++ b/Atom-Linux/.gitignore @@ -0,0 +1,4 @@ +*.o +atom +chrome.pak +locales/ diff --git a/Atom-Linux/Makefile b/Atom-Linux/Makefile new file mode 100644 index 000000000..498205c98 --- /dev/null +++ b/Atom-Linux/Makefile @@ -0,0 +1,79 @@ +CFLAGS_Release := -Werror \ + -pthread \ + -fno-exceptions \ + -fno-strict-aliasing \ + -Wall \ + -Wno-unused-parameter \ + -Wno-missing-field-initializers \ + -fvisibility=hidden \ + -pipe \ + -fPIC \ + -pthread \ + -D_REENTRANT \ + -I/usr/include/gtk-2.0 \ + -I/usr/lib/gtk-2.0/include \ + -I/usr/include/atk-1.0 \ + -I/usr/include/cairo \ + -I/usr/include/pango-1.0 \ + -I/usr/include/gio-unix-2.0/ \ + -I/usr/include/glib-2.0 \ + -I/usr/lib/glib-2.0/include \ + -I/usr/include/pixman-1 \ + -I/usr/include/freetype2 \ + -I/usr/include/directfb \ + -I/usr/include/libpng12 \ + -Icefclient \ + -I../cef \ + -O2 \ + -fno-ident \ + -fdata-sections \ + -ffunction-sections + +CFLAGS_CC_Release := -fno-rtti \ + -fno-threadsafe-statics \ + -fvisibility-inlines-hidden \ + -Wsign-compare + +LDFLAGS_Release := -pthread \ + -Wl,-z,noexecstack \ + -fPIC \ + -Lobj/cef \ + -Wl,-O1 \ + -Wl,--as-needed \ + -Wl,--gc-sections \ + -Wl,-rpath=obj/cef \ + -Wl,-rpath-link=obj/cef + +LIBS := -lX11 \ + -lgtk-x11-2.0 \ + -lgdk-x11-2.0 \ + -latk-1.0 \ + -lgio-2.0 \ + -lpangoft2-1.0 \ + -lgdk_pixbuf-2.0 \ + -lm \ + -lpangocairo-1.0 \ + -lcairo \ + -lpango-1.0 \ + -lfreetype \ + -lfontconfig \ + -lgobject-2.0 \ + -lgmodule-2.0 \ + -lgthread-2.0 \ + -lrt \ + -lglib-2.0 \ + -lcef \ + -lcef_dll_wrapper + +SOURCES=atom.cpp cefclient.cpp string_util.cpp native_handler.cpp cefclient_switches.cpp client_handler.cpp client_handler_gtk.cpp +OBJECTS=$(SOURCES:.cpp=.o) + +all: + g++ $(CFLAGS_Release) $(CFLAGS_CC_Release) -c $(SOURCES) + g++ -o atom $(OBJECTS) $(LDFLAGS_Release) $(LIBS) + cp ../Atom/Resources/chrome.pak . + mkdir -p locales/ + cp ../Atom/Resources/en.lproj/locale.pak locales/en-US.pak + +clean: + rm -rf *.o atom chrome.pak locales diff --git a/Atom-Linux/atom.cpp b/Atom-Linux/atom.cpp new file mode 100644 index 000000000..dbb8d21be --- /dev/null +++ b/Atom-Linux/atom.cpp @@ -0,0 +1,129 @@ +// Copyright (c) 2011 The Chromium Embedded Framework 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 +#include +#include +#include +#include "cefclient.h" +#include "include/cef_app.h" +#include "include/cef_browser.h" +#include "include/cef_frame.h" +#include "include/cef_runnable.h" +#include "client_handler.h" + +char szWorkingDir[512]; // The current working directory + +// The global ClientHandler reference. +extern CefRefPtr g_handler; + +void destroy(void) { + CefQuitMessageLoop(); +} + +void TerminationSignalHandler(int signatl) { + destroy(); +} + +// 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; +} + +// 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; + CefRefPtr app; + + // Initialize CEF. + CefInitialize(settings, app); + + window = gtk_window_new(GTK_WINDOW_TOPLEVEL); + gtk_window_set_title(GTK_WINDOW(window), "Atom"); + gtk_window_set_default_size(GTK_WINDOW(window), 800, 600); + + g_signal_connect(window, "focus", G_CALLBACK(&HandleFocus), NULL); + + GtkWidget* vbox = gtk_vbox_new(FALSE, 0); + + gtk_box_pack_start(GTK_BOX(vbox), NULL, 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); + + // Create the browser view. + CefWindowInfo window_info; + CefBrowserSettings browserSettings; + + window_info.SetAsChild(vbox); + + CefBrowser::CreateBrowserSync(window_info, + static_cast >(g_handler), + "", 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(); + + CefShutdown(); + + return 0; +} + +// Global functions + +std::string AppGetWorkingDirectory() { + return szWorkingDir; +} + diff --git a/Atom-Linux/cefclient.cpp b/Atom-Linux/cefclient.cpp new file mode 100644 index 000000000..e0d14780c --- /dev/null +++ b/Atom-Linux/cefclient.cpp @@ -0,0 +1,653 @@ +// Copyright (c) 2010 The Chromium Embedded Framework 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 "cefclient.h" +#include +#include +#include +#include +#include "include/cef_app.h" +#include "include/cef_browser.h" +#include "include/cef_command_line.h" +#include "include/cef_frame.h" +#include "include/cef_runnable.h" +#include "include/cef_web_plugin.h" +#include "include/cef_web_urlrequest.h" +#include "cefclient_switches.h" +#include "client_handler.h" +#include "string_util.h" +#include "util.h" + +namespace { + +void UIT_InvokeScript(CefRefPtr browser) { + REQUIRE_UI_THREAD(); + + CefRefPtr frame = browser->GetMainFrame(); + CefRefPtr v8Context = frame->GetV8Context(); + CefString url = frame->GetURL(); + + if (!v8Context.get()) { + frame->ExecuteJavaScript("alert('Failed to get V8 context!');", url, 0); + } else if (v8Context->Enter()) { + CefRefPtr globalObj = v8Context->GetGlobal(); + CefRefPtr evalFunc = globalObj->GetValue("eval"); + + CefRefPtr arg0 = CefV8Value::CreateString("1+2"); + + CefV8ValueList args; + args.push_back(arg0); + + CefRefPtr retVal; + CefRefPtr exception; + if (evalFunc->ExecuteFunctionWithContext(v8Context, globalObj, args, retVal, + exception, false)) { + if (retVal.get()) { + frame->ExecuteJavaScript( + std::string("alert('InvokeScript returns ") + + retVal->GetStringValue().ToString() + "!');", + url, 0); + } else { + frame->ExecuteJavaScript( + std::string("alert('InvokeScript returns exception: ") + + exception->GetMessage().ToString() + "!');", + url, 0); + } + } else { + frame->ExecuteJavaScript("alert('Failed to execute function!');", url, 0); + } + + v8Context->Exit(); + } else { + frame->ExecuteJavaScript("alert('Failed to enter into V8 context!');", + url, 0); + } +} + +void UIT_RunPluginInfoTest(CefRefPtr browser) { + std::string html = "Plugin Info Test"; + + // Find the flash plugin first to test that get by name works. + std::string flash_name; + CefRefPtr info = CefGetWebPluginInfo("Shockwave Flash"); + if (info.get()) { + flash_name = info->GetName(); + html += "\nFlash is installed!" + "
Name: " + flash_name + + "\n
Description: " + info->GetDescription().ToString() + + "\n
Version: " + info->GetVersion().ToString() + + "\n
Path: " + info->GetPath().ToString(); + } + + if (!flash_name.empty()) { + html += "\n

Other installed plugins:"; + } else { + html += "\nInstalled plugins:"; + } + + // Display all other plugins. + size_t count = CefGetWebPluginCount(); + for (size_t i = 0; i < count; ++i) { + CefRefPtr info = CefGetWebPluginInfo(i); + ASSERT(info.get()); + if (!flash_name.empty() && info->GetName() == flash_name) + continue; + + html += "\n

Name: " + info->GetName().ToString() + + "\n
Description: " + info->GetDescription().ToString() + + "\n
Version: " + info->GetVersion().ToString() + + "\n
Path: " + info->GetPath().ToString(); + } + + html += ""; + + browser->GetMainFrame()->LoadString(html, "http://tests/plugin_info"); +} + +// Return the int representation of the specified string. +int GetIntValue(const CefString& str) { + if (str.empty()) + return 0; + + std::string stdStr = str; + return atoi(stdStr.c_str()); +} + + +// ClientApp implementation. +class ClientApp : public CefApp, + public CefProxyHandler { + public: + ClientApp(cef_proxy_type_t proxy_type, const CefString& proxy_config) + : proxy_type_(proxy_type), + proxy_config_(proxy_config) { + } + + // CefApp methods + virtual CefRefPtr GetProxyHandler() OVERRIDE { return this; } + + // CefProxyHandler methods + virtual void GetProxyForUrl(const CefString& url, + CefProxyInfo& proxy_info) OVERRIDE { + proxy_info.proxyType = proxy_type_; + if (!proxy_config_.empty()) + CefString(&proxy_info.proxyList) = proxy_config_; + } + + protected: + cef_proxy_type_t proxy_type_; + CefString proxy_config_; + + IMPLEMENT_REFCOUNTING(ClientApp); +}; + +} // namespace + +CefRefPtr g_handler; +CefRefPtr g_command_line; + +CefRefPtr AppGetBrowser() { + if (!g_handler.get()) + return NULL; + return g_handler->GetBrowser(); +} + +CefWindowHandle AppGetMainHwnd() { + if (!g_handler.get()) + return NULL; + return g_handler->GetMainHwnd(); +} + +void AppInitCommandLine(int argc, const char* const* argv) { + g_command_line = CefCommandLine::CreateCommandLine(); +#if defined(OS_WIN) + g_command_line->InitFromString(::GetCommandLineW()); +#else + g_command_line->InitFromArgv(argc, argv); +#endif +} + +// Returns the application command line object. +CefRefPtr AppGetCommandLine() { + return g_command_line; +} + +// Returns the application settings based on command line arguments. +void AppGetSettings(CefSettings& settings, CefRefPtr& app) { + ASSERT(g_command_line.get()); + if (!g_command_line.get()) + return; + + CefString str; + +#if defined(OS_WIN) + settings.multi_threaded_message_loop = + g_command_line->HasSwitch(cefclient::kMultiThreadedMessageLoop); +#endif + + CefString(&settings.cache_path) = + g_command_line->GetSwitchValue(cefclient::kCachePath); + CefString(&settings.user_agent) = + g_command_line->GetSwitchValue(cefclient::kUserAgent); + CefString(&settings.product_version) = + g_command_line->GetSwitchValue(cefclient::kProductVersion); + CefString(&settings.locale) = + g_command_line->GetSwitchValue(cefclient::kLocale); + CefString(&settings.log_file) = + g_command_line->GetSwitchValue(cefclient::kLogFile); + + { + std::string str = g_command_line->GetSwitchValue(cefclient::kLogSeverity); + bool invalid = false; + if (!str.empty()) { + if (str == cefclient::kLogSeverity_Verbose) + settings.log_severity = LOGSEVERITY_VERBOSE; + else if (str == cefclient::kLogSeverity_Info) + settings.log_severity = LOGSEVERITY_INFO; + else if (str == cefclient::kLogSeverity_Warning) + settings.log_severity = LOGSEVERITY_WARNING; + else if (str == cefclient::kLogSeverity_Error) + settings.log_severity = LOGSEVERITY_ERROR; + else if (str == cefclient::kLogSeverity_ErrorReport) + settings.log_severity = LOGSEVERITY_ERROR_REPORT; + else if (str == cefclient::kLogSeverity_Disable) + settings.log_severity = LOGSEVERITY_DISABLE; + else + invalid = true; + } + if (str.empty() || invalid) { +#ifdef NDEBUG + // Only log error messages and higher in release build. + settings.log_severity = LOGSEVERITY_ERROR; +#endif + } + } + + { + std::string str = g_command_line->GetSwitchValue(cefclient::kGraphicsImpl); + if (!str.empty()) { +#if defined(OS_WIN) + if (str == cefclient::kGraphicsImpl_Angle) + settings.graphics_implementation = ANGLE_IN_PROCESS; + else if (str == cefclient::kGraphicsImpl_AngleCmdBuffer) + settings.graphics_implementation = ANGLE_IN_PROCESS_COMMAND_BUFFER; + else +#endif + if (str == cefclient::kGraphicsImpl_Desktop) + settings.graphics_implementation = DESKTOP_IN_PROCESS; + else if (str == cefclient::kGraphicsImpl_DesktopCmdBuffer) + settings.graphics_implementation = DESKTOP_IN_PROCESS_COMMAND_BUFFER; + } + } + + settings.local_storage_quota = GetIntValue( + g_command_line->GetSwitchValue(cefclient::kLocalStorageQuota)); + settings.session_storage_quota = GetIntValue( + g_command_line->GetSwitchValue(cefclient::kSessionStorageQuota)); + + CefString(&settings.javascript_flags) = + g_command_line->GetSwitchValue(cefclient::kJavascriptFlags); + + CefString(&settings.pack_file_path) = + g_command_line->GetSwitchValue(cefclient::kPackFilePath); + CefString(&settings.locales_dir_path) = + g_command_line->GetSwitchValue(cefclient::kLocalesDirPath); + + settings.pack_loading_disabled = + g_command_line->HasSwitch(cefclient::kPackLoadingDisabled); + + // Retrieve command-line proxy configuration, if any. + bool has_proxy = false; + cef_proxy_type_t proxy_type = PROXY_TYPE_DIRECT; + CefString proxy_config; + + if (g_command_line->HasSwitch(cefclient::kProxyType)) { + std::string str = g_command_line->GetSwitchValue(cefclient::kProxyType); + if (str == cefclient::kProxyType_Direct) { + has_proxy = true; + proxy_type = PROXY_TYPE_DIRECT; + } else if (str == cefclient::kProxyType_Named || + str == cefclient::kProxyType_Pac) { + proxy_config = g_command_line->GetSwitchValue(cefclient::kProxyConfig); + if (!proxy_config.empty()) { + has_proxy = true; + proxy_type = (str == cefclient::kProxyType_Named? + PROXY_TYPE_NAMED:PROXY_TYPE_PAC_STRING); + } + } + } + + if (has_proxy) { + // Provide a ClientApp instance to handle proxy resolution. + app = new ClientApp(proxy_type, proxy_config); + } +} + +// Returns the application browser settings based on command line arguments. +void AppGetBrowserSettings(CefBrowserSettings& settings) { + ASSERT(g_command_line.get()); + if (!g_command_line.get()) + return; + + settings.drag_drop_disabled = + g_command_line->HasSwitch(cefclient::kDragDropDisabled); + settings.load_drops_disabled = + g_command_line->HasSwitch(cefclient::kLoadDropsDisabled); + settings.history_disabled = + g_command_line->HasSwitch(cefclient::kHistoryDisabled); + settings.remote_fonts_disabled = + g_command_line->HasSwitch(cefclient::kRemoteFontsDisabled); + + CefString(&settings.default_encoding) = + g_command_line->GetSwitchValue(cefclient::kDefaultEncoding); + + settings.encoding_detector_enabled = + g_command_line->HasSwitch(cefclient::kEncodingDetectorEnabled); + settings.javascript_disabled = + g_command_line->HasSwitch(cefclient::kJavascriptDisabled); + settings.javascript_open_windows_disallowed = + g_command_line->HasSwitch(cefclient::kJavascriptOpenWindowsDisallowed); + settings.javascript_close_windows_disallowed = + g_command_line->HasSwitch(cefclient::kJavascriptCloseWindowsDisallowed); + settings.javascript_access_clipboard_disallowed = + g_command_line->HasSwitch( + cefclient::kJavascriptAccessClipboardDisallowed); + settings.dom_paste_disabled = + g_command_line->HasSwitch(cefclient::kDomPasteDisabled); + settings.caret_browsing_enabled = + g_command_line->HasSwitch(cefclient::kCaretBrowsingDisabled); + settings.java_disabled = + g_command_line->HasSwitch(cefclient::kJavaDisabled); + settings.plugins_disabled = + g_command_line->HasSwitch(cefclient::kPluginsDisabled); + settings.universal_access_from_file_urls_allowed = + g_command_line->HasSwitch(cefclient::kUniversalAccessFromFileUrlsAllowed); + settings.file_access_from_file_urls_allowed = + g_command_line->HasSwitch(cefclient::kFileAccessFromFileUrlsAllowed); + settings.web_security_disabled = + g_command_line->HasSwitch(cefclient::kWebSecurityDisabled); + settings.xss_auditor_enabled = + g_command_line->HasSwitch(cefclient::kXssAuditorEnabled); + settings.image_load_disabled = + g_command_line->HasSwitch(cefclient::kImageLoadingDisabled); + settings.shrink_standalone_images_to_fit = + g_command_line->HasSwitch(cefclient::kShrinkStandaloneImagesToFit); + settings.site_specific_quirks_disabled = + g_command_line->HasSwitch(cefclient::kSiteSpecificQuirksDisabled); + settings.text_area_resize_disabled = + g_command_line->HasSwitch(cefclient::kTextAreaResizeDisabled); + settings.page_cache_disabled = + g_command_line->HasSwitch(cefclient::kPageCacheDisabled); + settings.tab_to_links_disabled = + g_command_line->HasSwitch(cefclient::kTabToLinksDisabled); + settings.hyperlink_auditing_disabled = + g_command_line->HasSwitch(cefclient::kHyperlinkAuditingDisabled); + settings.user_style_sheet_enabled = + g_command_line->HasSwitch(cefclient::kUserStyleSheetEnabled); + + CefString(&settings.user_style_sheet_location) = + g_command_line->GetSwitchValue(cefclient::kUserStyleSheetLocation); + + settings.author_and_user_styles_disabled = + g_command_line->HasSwitch(cefclient::kAuthorAndUserStylesDisabled); + settings.local_storage_disabled = + g_command_line->HasSwitch(cefclient::kLocalStorageDisabled); + settings.databases_disabled = + g_command_line->HasSwitch(cefclient::kDatabasesDisabled); + settings.application_cache_disabled = + g_command_line->HasSwitch(cefclient::kApplicationCacheDisabled); + settings.webgl_disabled = + g_command_line->HasSwitch(cefclient::kWebglDisabled); + settings.accelerated_compositing_enabled = + g_command_line->HasSwitch(cefclient::kAcceleratedCompositingEnabled); + settings.threaded_compositing_enabled = + g_command_line->HasSwitch(cefclient::kThreadedCompositingEnabled); + settings.accelerated_layers_disabled = + g_command_line->HasSwitch(cefclient::kAcceleratedLayersDisabled); + settings.accelerated_video_disabled = + g_command_line->HasSwitch(cefclient::kAcceleratedVideoDisabled); + settings.accelerated_2d_canvas_disabled = + g_command_line->HasSwitch(cefclient::kAcceledated2dCanvasDisabled); + settings.accelerated_painting_disabled = + g_command_line->HasSwitch(cefclient::kAcceleratedPaintingDisabled); + settings.accelerated_filters_disabled = + g_command_line->HasSwitch(cefclient::kAcceleratedFiltersDisabled); + settings.accelerated_plugins_disabled = + g_command_line->HasSwitch(cefclient::kAcceleratedPluginsDisabled); + settings.developer_tools_disabled = + g_command_line->HasSwitch(cefclient::kDeveloperToolsDisabled); + settings.fullscreen_enabled = + g_command_line->HasSwitch(cefclient::kFullscreenEnabled); +} + +static void ExecuteGetSource(CefRefPtr frame) { + // Retrieve the current page source and display. + std::string source = frame->GetSource(); + source = StringReplace(source, "<", "<"); + source = StringReplace(source, ">", ">"); + std::stringstream ss; + ss << "Source:
" << source << "
"; + frame->LoadString(ss.str(), "http://tests/getsource"); +} + +void RunGetSourceTest(CefRefPtr browser) { + // Execute the GetSource() call on the UI thread. + CefPostTask(TID_UI, + NewCefRunnableFunction(&ExecuteGetSource, browser->GetMainFrame())); +} + +static void ExecuteGetText(CefRefPtr frame) { + std::string text = frame->GetText(); + text = StringReplace(text, "<", "<"); + text = StringReplace(text, ">", ">"); + std::stringstream ss; + ss << "Text:
" << text << "
"; + frame->LoadString(ss.str(), "http://tests/gettext"); +} + +void RunGetTextTest(CefRefPtr browser) { + // Execute the GetText() call on the UI thread. + CefPostTask(TID_UI, + NewCefRunnableFunction(&ExecuteGetText, browser->GetMainFrame())); +} + +void RunRequestTest(CefRefPtr browser) { + // Create a new request + CefRefPtr request(CefRequest::CreateRequest()); + + // Set the request URL + request->SetURL("http://tests/request"); + + // Add post data to the request. The correct method and content- + // type headers will be set by CEF. + CefRefPtr postDataElement( + CefPostDataElement::CreatePostDataElement()); + std::string data = "arg1=val1&arg2=val2"; + postDataElement->SetToBytes(data.length(), data.c_str()); + CefRefPtr postData(CefPostData::CreatePostData()); + postData->AddElement(postDataElement); + request->SetPostData(postData); + + // Add a custom header + CefRequest::HeaderMap headerMap; + headerMap.insert( + std::make_pair("X-My-Header", "My Header Value")); + request->SetHeaderMap(headerMap); + + // Load the request + browser->GetMainFrame()->LoadRequest(request); +} + +void RunJavaScriptExecuteTest(CefRefPtr browser) { + browser->GetMainFrame()->ExecuteJavaScript( + "alert('JavaScript execute works!');", "about:blank", 0); +} + +void RunJavaScriptInvokeTest(CefRefPtr browser) { + if (CefCurrentlyOn(TID_UI)) { + UIT_InvokeScript(browser); + } else { + // Execute on the UI thread. + CefPostTask(TID_UI, NewCefRunnableFunction(&UIT_InvokeScript, browser)); + } +} + +void RunPopupTest(CefRefPtr browser) { + browser->GetMainFrame()->ExecuteJavaScript( + "window.open('http://www.google.com');", "about:blank", 0); +} + +void RunLocalStorageTest(CefRefPtr browser) { + browser->GetMainFrame()->LoadURL("http://tests/localstorage"); +} + +void RunAccelerated2DCanvasTest(CefRefPtr browser) { + browser->GetMainFrame()->LoadURL( + "http://mudcu.be/labs/JS1k/BreathingGalaxies.html"); +} + +void RunAcceleratedLayersTest(CefRefPtr browser) { + browser->GetMainFrame()->LoadURL( + "http://webkit.org/blog-files/3d-transforms/poster-circle.html"); +} + +void RunWebGLTest(CefRefPtr browser) { + browser->GetMainFrame()->LoadURL( + "http://webglsamples.googlecode.com/hg/field/field.html"); +} + +void RunHTML5VideoTest(CefRefPtr browser) { + browser->GetMainFrame()->LoadURL( + "http://www.youtube.com/watch?v=siOHh0uzcuY&html5=True"); +} + +void RunXMLHTTPRequestTest(CefRefPtr browser) { + browser->GetMainFrame()->LoadURL("http://tests/xmlhttprequest"); +} + +void RunWebURLRequestTest(CefRefPtr browser) { + class RequestClient : public CefWebURLRequestClient { + public: + explicit RequestClient(CefRefPtr browser) : browser_(browser) {} + + virtual void OnStateChange(CefRefPtr requester, + RequestState state) { + REQUIRE_UI_THREAD(); + if (state == WUR_STATE_DONE) { + buffer_ = StringReplace(buffer_, "<", "<"); + buffer_ = StringReplace(buffer_, ">", ">"); + std::stringstream ss; + ss << "Source:
" << buffer_ << "
"; + + browser_->GetMainFrame()->LoadString(ss.str(), + "http://tests/weburlrequest"); + } + } + + virtual void OnRedirect(CefRefPtr requester, + CefRefPtr request, + CefRefPtr response) { + REQUIRE_UI_THREAD(); + } + + virtual void OnHeadersReceived(CefRefPtr requester, + CefRefPtr response) { + REQUIRE_UI_THREAD(); + } + + virtual void OnProgress(CefRefPtr requester, + uint64 bytesSent, uint64 totalBytesToBeSent) { + REQUIRE_UI_THREAD(); + } + + virtual void OnData(CefRefPtr requester, + const void* data, int dataLength) { + REQUIRE_UI_THREAD(); + buffer_.append(static_cast(data), dataLength); + } + + virtual void OnError(CefRefPtr requester, + ErrorCode errorCode) { + REQUIRE_UI_THREAD(); + std::stringstream ss; + ss << "Load failed with error code " << errorCode; + browser_->GetMainFrame()->LoadString(ss.str(), + "http://tests/weburlrequest"); + } + + protected: + CefRefPtr browser_; + std::string buffer_; + + IMPLEMENT_REFCOUNTING(CefWebURLRequestClient); + }; + + CefRefPtr request(CefRequest::CreateRequest()); + request->SetURL("http://www.google.com"); + + CefRefPtr client(new RequestClient(browser)); + CefRefPtr requester( + CefWebURLRequest::CreateWebURLRequest(request, client)); +} + +void RunDOMAccessTest(CefRefPtr browser) { + class Listener : public CefDOMEventListener { + public: + Listener() {} + virtual void HandleEvent(CefRefPtr event) { + CefRefPtr document = event->GetDocument(); + ASSERT(document.get()); + + std::stringstream ss; + + CefRefPtr button = event->GetTarget(); + ASSERT(button.get()); + std::string buttonValue = button->GetElementAttribute("value"); + ss << "You clicked the " << buttonValue.c_str() << " button. "; + + if (document->HasSelection()) { + std::string startName, endName; + + // Determine the start name by first trying to locate the "id" attribute + // and then defaulting to the tag name. + { + CefRefPtr node = document->GetSelectionStartNode(); + if (!node->IsElement()) + node = node->GetParent(); + if (node->IsElement() && node->HasElementAttribute("id")) + startName = node->GetElementAttribute("id"); + else + startName = node->GetName(); + } + + // Determine the end name by first trying to locate the "id" attribute + // and then defaulting to the tag name. + { + CefRefPtr node = document->GetSelectionEndNode(); + if (!node->IsElement()) + node = node->GetParent(); + if (node->IsElement() && node->HasElementAttribute("id")) + endName = node->GetElementAttribute("id"); + else + endName = node->GetName(); + } + + ss << "The selection is from " << + startName.c_str() << ":" << document->GetSelectionStartOffset() << + " to " << + endName.c_str() << ":" << document->GetSelectionEndOffset(); + } else { + ss << "Nothing is selected."; + } + + // Update the description. + CefRefPtr desc = document->GetElementById("description"); + ASSERT(desc.get()); + CefRefPtr text = desc->GetFirstChild(); + ASSERT(text.get()); + ASSERT(text->IsText()); + text->SetValue(ss.str()); + } + + IMPLEMENT_REFCOUNTING(Listener); + }; + + class Visitor : public CefDOMVisitor { + public: + Visitor() {} + virtual void Visit(CefRefPtr document) { + // Register an click listener for the button. + CefRefPtr button = document->GetElementById("button"); + ASSERT(button.get()); + button->AddEventListener("click", new Listener(), false); + } + + IMPLEMENT_REFCOUNTING(Visitor); + }; + + // The DOM visitor will be called after the path is loaded. + CefRefPtr client = browser->GetClient(); + static_cast(client.get())->AddDOMVisitor( + "http://tests/domaccess", new Visitor()); + + browser->GetMainFrame()->LoadURL("http://tests/domaccess"); +} + +void RunDragDropTest(CefRefPtr browser) { + browser->GetMainFrame()->LoadURL("http://html5demos.com/drag"); +} + +void RunModalDialogTest(CefRefPtr browser) { + browser->GetMainFrame()->LoadURL("http://tests/modalmain"); +} + +void RunPluginInfoTest(CefRefPtr browser) { + if (CefCurrentlyOn(TID_UI)) { + UIT_RunPluginInfoTest(browser); + } else { + // Execute on the UI thread. + CefPostTask(TID_UI, + NewCefRunnableFunction(&UIT_RunPluginInfoTest, browser)); + } +} diff --git a/Atom-Linux/cefclient.h b/Atom-Linux/cefclient.h new file mode 100644 index 000000000..27ba93576 --- /dev/null +++ b/Atom-Linux/cefclient.h @@ -0,0 +1,61 @@ +// Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights +// reserved. Use of this source code is governed by a BSD-style license that +// can be found in the LICENSE file. + +#ifndef CEF_TESTS_CEFCLIENT_CEFCLIENT_H_ +#define CEF_TESTS_CEFCLIENT_CEFCLIENT_H_ +#pragma once + +#include +#include "include/cef_base.h" + +class CefApp; +class CefBrowser; +class CefCommandLine; + +// Returns the main browser window instance. +CefRefPtr AppGetBrowser(); + +// Returns the main application window handle. +CefWindowHandle AppGetMainHwnd(); + +// Returns the application working directory. +std::string AppGetWorkingDirectory(); + +// Initialize the application command line. +void AppInitCommandLine(int argc, const char* const* argv); + +// Returns the application command line object. +CefRefPtr AppGetCommandLine(); + +// Returns the application settings based on command line arguments. +void AppGetSettings(CefSettings& settings, CefRefPtr& app); + +// Returns the application browser settings based on command line arguments. +void AppGetBrowserSettings(CefBrowserSettings& settings); + +// Implementations for various tests. +void RunGetSourceTest(CefRefPtr browser); +void RunGetTextTest(CefRefPtr browser); +void RunRequestTest(CefRefPtr browser); +void RunJavaScriptExecuteTest(CefRefPtr browser); +void RunJavaScriptInvokeTest(CefRefPtr browser); +void RunPopupTest(CefRefPtr browser); +void RunLocalStorageTest(CefRefPtr browser); +void RunAccelerated2DCanvasTest(CefRefPtr browser); +void RunAcceleratedLayersTest(CefRefPtr browser); +void RunWebGLTest(CefRefPtr browser); +void RunHTML5VideoTest(CefRefPtr browser); +void RunXMLHTTPRequestTest(CefRefPtr browser); +void RunWebURLRequestTest(CefRefPtr browser); +void RunDOMAccessTest(CefRefPtr browser); +void RunDragDropTest(CefRefPtr browser); +void RunModalDialogTest(CefRefPtr browser); +void RunPluginInfoTest(CefRefPtr browser); + +#if defined(OS_WIN) +void RunTransparentPopupTest(CefRefPtr browser); +void RunGetImageTest(CefRefPtr browser); +#endif + +#endif // CEF_TESTS_CEFCLIENT_CEFCLIENT_H_ diff --git a/Atom-Linux/cefclient_switches.cpp b/Atom-Linux/cefclient_switches.cpp new file mode 100644 index 000000000..40c420e55 --- /dev/null +++ b/Atom-Linux/cefclient_switches.cpp @@ -0,0 +1,93 @@ +// Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights +// reserved. Use of this source code is governed by a BSD-style license that +// can be found in the LICENSE file. + +// This file is shared by cefclient and cef_unittests so don't include using +// a qualified path. +#include "cefclient_switches.h" // NOLINT(build/include) + +namespace cefclient { + +// CefSettings attributes. +const char kMultiThreadedMessageLoop[] = "multi-threaded-message-loop"; +const char kCachePath[] = "cache-path"; +const char kUserAgent[] = "user-agent"; +const char kProductVersion[] = "product-version"; +const char kLocale[] = "locale"; +const char kLogFile[] = "log-file"; +const char kLogSeverity[] = "log-severity"; +const char kLogSeverity_Verbose[] = "verbose"; +const char kLogSeverity_Info[] = "info"; +const char kLogSeverity_Warning[] = "warning"; +const char kLogSeverity_Error[] = "error"; +const char kLogSeverity_ErrorReport[] = "error-report"; +const char kLogSeverity_Disable[] = "disable"; +const char kGraphicsImpl[] = "graphics-implementation"; +const char kGraphicsImpl_Angle[] = "angle"; +const char kGraphicsImpl_AngleCmdBuffer[] = "angle-command-buffer"; +const char kGraphicsImpl_Desktop[] = "desktop"; +const char kGraphicsImpl_DesktopCmdBuffer[] = "desktop-command-buffer"; +const char kLocalStorageQuota[] = "local-storage-quota"; +const char kSessionStorageQuota[] = "session-storage-quota"; +const char kJavascriptFlags[] = "javascript-flags"; +const char kPackFilePath[] = "pack-file-path"; +const char kLocalesDirPath[] = "locales-dir-path"; +const char kPackLoadingDisabled[] = "pack-loading-disabled"; + +// CefBrowserSettings attributes. +const char kDragDropDisabled[] = "drag-drop-disabled"; +const char kLoadDropsDisabled[] = "load-drops-disabled"; +const char kHistoryDisabled[] = "history-disabled"; +const char kRemoteFontsDisabled[] = "remote-fonts-disabled"; +const char kDefaultEncoding[] = "default-encoding"; +const char kEncodingDetectorEnabled[] = "encoding-detector-enabled"; +const char kJavascriptDisabled[] = "javascript-disabled"; +const char kJavascriptOpenWindowsDisallowed[] = + "javascript-open-windows-disallowed"; +const char kJavascriptCloseWindowsDisallowed[] = + "javascript-close-windows-disallowed"; +const char kJavascriptAccessClipboardDisallowed[] = + "javascript-access-clipboard-disallowed"; +const char kDomPasteDisabled[] = "dom-paste-disabled"; +const char kCaretBrowsingDisabled[] = "caret-browsing-enabled"; +const char kJavaDisabled[] = "java-disabled"; +const char kPluginsDisabled[] = "plugins-disabled"; +const char kUniversalAccessFromFileUrlsAllowed[] = + "universal-access-from-file-urls-allowed"; +const char kFileAccessFromFileUrlsAllowed[] = + "file-access-from-file-urls-allowed"; +const char kWebSecurityDisabled[] = "web-security-disabled"; +const char kXssAuditorEnabled[] = "xss-auditor-enabled"; +const char kImageLoadingDisabled[] = "image-load-disabled"; +const char kShrinkStandaloneImagesToFit[] = "shrink-standalone-images-to-fit"; +const char kSiteSpecificQuirksDisabled[] = "site-specific-quirks-disabled"; +const char kTextAreaResizeDisabled[] = "text-area-resize-disabled"; +const char kPageCacheDisabled[] = "page-cache-disabled"; +const char kTabToLinksDisabled[] = "tab-to-links-disabled"; +const char kHyperlinkAuditingDisabled[] = "hyperlink-auditing-disabled"; +const char kUserStyleSheetEnabled[] = "user-style-sheet-enabled"; +const char kUserStyleSheetLocation[] = "user-style-sheet-location"; +const char kAuthorAndUserStylesDisabled[] = "author-and-user-styles-disabled"; +const char kLocalStorageDisabled[] = "local-storage-disabled"; +const char kDatabasesDisabled[] = "databases-disabled"; +const char kApplicationCacheDisabled[] = "application-cache-disabled"; +const char kWebglDisabled[] = "webgl-disabled"; +const char kAcceleratedCompositingEnabled[] = "accelerated-compositing-enabled"; +const char kThreadedCompositingEnabled[] = "threaded-compositing-enabled"; +const char kAcceleratedLayersDisabled[] = "accelerated-layers-disabled"; +const char kAcceleratedVideoDisabled[] = "accelerated-video-disabled"; +const char kAcceledated2dCanvasDisabled[] = "accelerated-2d-canvas-disabled"; +const char kAcceleratedPaintingDisabled[] = "accelerated-painting-disabled"; +const char kAcceleratedFiltersDisabled[] = "accelerated-filters-disabled"; +const char kAcceleratedPluginsDisabled[] = "accelerated-plugins-disabled"; +const char kDeveloperToolsDisabled[] = "developer-tools-disabled"; +const char kFullscreenEnabled[] = "fullscreen-enabled"; + +// Other attributes. +const char kProxyType[] = "proxy-type"; +const char kProxyType_Direct[] = "direct"; +const char kProxyType_Named[] = "named"; +const char kProxyType_Pac[] = "pac"; +const char kProxyConfig[] = "proxy-config"; + +} // namespace cefclient diff --git a/Atom-Linux/cefclient_switches.h b/Atom-Linux/cefclient_switches.h new file mode 100644 index 000000000..da1edeb81 --- /dev/null +++ b/Atom-Linux/cefclient_switches.h @@ -0,0 +1,92 @@ +// Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights +// reserved. Use of this source code is governed by a BSD-style license that +// can be found in the LICENSE file. + +// Defines all of the command line switches used by cefclient. + +#ifndef CEF_TESTS_CEFCLIENT_CEFCLIENT_SWITCHES_H_ +#define CEF_TESTS_CEFCLIENT_CEFCLIENT_SWITCHES_H_ +#pragma once + +namespace cefclient { + +// CefSettings attributes. +extern const char kMultiThreadedMessageLoop[]; +extern const char kCachePath[]; +extern const char kUserAgent[]; +extern const char kProductVersion[]; +extern const char kLocale[]; +extern const char kLogFile[]; +extern const char kLogSeverity[]; +extern const char kLogSeverity_Verbose[]; +extern const char kLogSeverity_Info[]; +extern const char kLogSeverity_Warning[]; +extern const char kLogSeverity_Error[]; +extern const char kLogSeverity_ErrorReport[]; +extern const char kLogSeverity_Disable[]; +extern const char kGraphicsImpl[]; +extern const char kGraphicsImpl_Angle[]; +extern const char kGraphicsImpl_AngleCmdBuffer[]; +extern const char kGraphicsImpl_Desktop[]; +extern const char kGraphicsImpl_DesktopCmdBuffer[]; +extern const char kLocalStorageQuota[]; +extern const char kSessionStorageQuota[]; +extern const char kJavascriptFlags[]; +extern const char kPackFilePath[]; +extern const char kLocalesDirPath[]; +extern const char kPackLoadingDisabled[]; + +// CefBrowserSettings attributes. +extern const char kDragDropDisabled[]; +extern const char kLoadDropsDisabled[]; +extern const char kHistoryDisabled[]; +extern const char kRemoteFontsDisabled[]; +extern const char kDefaultEncoding[]; +extern const char kEncodingDetectorEnabled[]; +extern const char kJavascriptDisabled[]; +extern const char kJavascriptOpenWindowsDisallowed[]; +extern const char kJavascriptCloseWindowsDisallowed[]; +extern const char kJavascriptAccessClipboardDisallowed[]; +extern const char kDomPasteDisabled[]; +extern const char kCaretBrowsingDisabled[]; +extern const char kJavaDisabled[]; +extern const char kPluginsDisabled[]; +extern const char kUniversalAccessFromFileUrlsAllowed[]; +extern const char kFileAccessFromFileUrlsAllowed[]; +extern const char kWebSecurityDisabled[]; +extern const char kXssAuditorEnabled[]; +extern const char kImageLoadingDisabled[]; +extern const char kShrinkStandaloneImagesToFit[]; +extern const char kSiteSpecificQuirksDisabled[]; +extern const char kTextAreaResizeDisabled[]; +extern const char kPageCacheDisabled[]; +extern const char kTabToLinksDisabled[]; +extern const char kHyperlinkAuditingDisabled[]; +extern const char kUserStyleSheetEnabled[]; +extern const char kUserStyleSheetLocation[]; +extern const char kAuthorAndUserStylesDisabled[]; +extern const char kLocalStorageDisabled[]; +extern const char kDatabasesDisabled[]; +extern const char kApplicationCacheDisabled[]; +extern const char kWebglDisabled[]; +extern const char kAcceleratedCompositingEnabled[]; +extern const char kThreadedCompositingEnabled[]; +extern const char kAcceleratedLayersDisabled[]; +extern const char kAcceleratedVideoDisabled[]; +extern const char kAcceledated2dCanvasDisabled[]; +extern const char kAcceleratedPaintingDisabled[]; +extern const char kAcceleratedFiltersDisabled[]; +extern const char kAcceleratedPluginsDisabled[]; +extern const char kDeveloperToolsDisabled[]; +extern const char kFullscreenEnabled[]; + +// Other attributes. +extern const char kProxyType[]; +extern const char kProxyType_Direct[]; +extern const char kProxyType_Named[]; +extern const char kProxyType_Pac[]; +extern const char kProxyConfig[]; + +} // namespace cefclient + +#endif // CEF_TESTS_CEFCLIENT_CEFCLIENT_SWITCHES_H_ diff --git a/Atom-Linux/client_handler.cpp b/Atom-Linux/client_handler.cpp new file mode 100644 index 000000000..2609f8f11 --- /dev/null +++ b/Atom-Linux/client_handler.cpp @@ -0,0 +1,340 @@ +// Copyright (c) 2011 The Chromium Embedded Framework 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 "client_handler.h" +#include +#include +#include +#include "include/cef_browser.h" +#include "include/cef_frame.h" +#include "cefclient.h" +#include "string_util.h" +#include "native_handler.h" + + +ClientHandler::ClientHandler() + : m_MainHwnd(NULL), + m_BrowserHwnd(NULL), + m_EditHwnd(NULL), + m_BackHwnd(NULL), + m_ForwardHwnd(NULL), + m_StopHwnd(NULL), + m_ReloadHwnd(NULL), + m_bFormElementHasFocus(false) { +} + +ClientHandler::~ClientHandler() { +} + + +void ClientHandler::OnAfterCreated(CefRefPtr browser) { + REQUIRE_UI_THREAD(); + + AutoLock lock_scope(this); + if (!m_Browser.get()) { + // We need to keep the main child window, but not popup windows + m_Browser = browser; + m_BrowserHwnd = browser->GetWindowHandle(); + } +} + +bool ClientHandler::DoClose(CefRefPtr browser) { + REQUIRE_UI_THREAD(); + + if (m_BrowserHwnd == browser->GetWindowHandle()) { + // Since the main window contains the browser window, we need to close + // the parent window instead of the browser window. + CloseMainWindow(); + + // Return true here so that we can skip closing the browser window + // in this pass. (It will be destroyed due to the call to close + // the parent above.) + return true; + } + + // A popup browser window is not contained in another window, so we can let + // these windows close by themselves. + return false; +} + +void ClientHandler::OnBeforeClose(CefRefPtr browser) { + REQUIRE_UI_THREAD(); + + if (m_BrowserHwnd == browser->GetWindowHandle()) { + // Free the browser pointer so that the browser can be destroyed + m_Browser = NULL; + } +} + +void ClientHandler::OnLoadStart(CefRefPtr browser, + CefRefPtr frame) { + REQUIRE_UI_THREAD(); + + if (m_BrowserHwnd == browser->GetWindowHandle() && frame->IsMain()) { + // We've just started loading a page + SetLoading(true); + + CefRefPtr context = frame->GetV8Context(); + CefRefPtr global = context->GetGlobal(); + context->Enter(); + + CefRefPtr windowNumber = CefV8Value::CreateInt(0); + global->SetValue("$windowNumber", windowNumber, V8_PROPERTY_ATTRIBUTE_NONE); + + CefRefPtr nativeHandler = new NativeHandler(); + global->SetValue("$native", nativeHandler->object, V8_PROPERTY_ATTRIBUTE_NONE); + + CefRefPtr atom = CefV8Value::CreateObject(NULL, NULL); + global->SetValue("atom", atom, V8_PROPERTY_ATTRIBUTE_NONE); + + CefRefPtr loadPath = CefV8Value::CreateString("/home/kevin/repositories/atom"); + atom->SetValue("loadPath", loadPath, V8_PROPERTY_ATTRIBUTE_NONE); + + CefRefPtr bootstrapScript = CefV8Value::CreateString("window-bootstrap"); + global->SetValue("$bootstrapScript", bootstrapScript, V8_PROPERTY_ATTRIBUTE_NONE); + + CefRefPtr pathToOpen = CefV8Value::CreateString("/home/kevin/repositories/atom/index.html"); + global->SetValue("$pathToOpen", pathToOpen, V8_PROPERTY_ATTRIBUTE_NONE); + + context->Exit(); + } +} + +void ClientHandler::OnLoadEnd(CefRefPtr browser, + CefRefPtr frame, + int httpStatusCode) { + REQUIRE_UI_THREAD(); + + if (m_BrowserHwnd == browser->GetWindowHandle() && frame->IsMain()) { + // We've just finished loading a page + SetLoading(false); + + CefRefPtr visitor = GetDOMVisitor(frame->GetURL()); + if (visitor.get()) + frame->VisitDOM(visitor); + } +} + +bool ClientHandler::OnLoadError(CefRefPtr browser, + CefRefPtr frame, + ErrorCode errorCode, + const CefString& failedUrl, + CefString& errorText) { + REQUIRE_UI_THREAD(); + + if (errorCode == ERR_CACHE_MISS) { + // Usually caused by navigating to a page with POST data via back or + // forward buttons. + errorText = "Expired Form Data" + "

Expired Form Data

" + "

Your form request has expired. " + "Click reload to re-submit the form data.

" + ""; + } else { + // All other messages. + std::stringstream ss; + ss << "Load Failed" + "

Load Failed

" + "

Load of URL " << std::string(failedUrl) << + " failed with error code " << static_cast(errorCode) << + ".

" + ""; + errorText = ss.str(); + } + + return false; +} + +void ClientHandler::OnNavStateChange(CefRefPtr browser, + bool canGoBack, + bool canGoForward) { + REQUIRE_UI_THREAD(); + + SetNavState(canGoBack, canGoForward); +} + +bool ClientHandler::OnConsoleMessage(CefRefPtr browser, + const CefString& message, + const CefString& source, + int line) { + REQUIRE_UI_THREAD(); + + bool first_message; + std::string logFile; + + { + AutoLock lock_scope(this); + + first_message = m_LogFile.empty(); + if (first_message) { + std::stringstream ss; + ss << AppGetWorkingDirectory(); +#if defined(OS_WIN) + ss << "\\"; +#else + ss << "/"; +#endif + ss << "console.log"; + m_LogFile = ss.str(); + } + logFile = m_LogFile; + } + + FILE* file = fopen(logFile.c_str(), "a"); + if (file) { + std::stringstream ss; + ss << "Message: " << std::string(message) << "\r\nSource: " << + std::string(source) << "\r\nLine: " << line << + "\r\n-----------------------\r\n"; + fputs(ss.str().c_str(), file); + fclose(file); + + if (first_message) + SendNotification(NOTIFY_CONSOLE_MESSAGE); + } + + return false; +} + +void ClientHandler::OnFocusedNodeChanged(CefRefPtr browser, + CefRefPtr frame, + CefRefPtr node) { + REQUIRE_UI_THREAD(); + + // Set to true if a form element has focus. + m_bFormElementHasFocus = (node.get() && node->IsFormControlElement()); +} + +bool ClientHandler::OnKeyEvent(CefRefPtr browser, + KeyEventType type, + int code, + int modifiers, + bool isSystemKey, + bool isAfterJavaScript) { + REQUIRE_UI_THREAD(); + + if (isAfterJavaScript && !m_bFormElementHasFocus && code == 0x20) { + // Special handling for the space character if a form element does not have + // focus. + if (type == KEYEVENT_RAWKEYDOWN) { + browser->GetMainFrame()->ExecuteJavaScript( + "alert('You pressed the space bar!');", "", 0); + } + return true; + } + + return false; +} + +bool ClientHandler::GetPrintHeaderFooter(CefRefPtr browser, + CefRefPtr frame, + const CefPrintInfo& printInfo, + const CefString& url, + const CefString& title, + int currentPage, + int maxPages, + CefString& topLeft, + CefString& topCenter, + CefString& topRight, + CefString& bottomLeft, + CefString& bottomCenter, + CefString& bottomRight) { + REQUIRE_UI_THREAD(); + + // Place the page title at top left + topLeft = title; + // Place the page URL at top right + topRight = url; + + // Place "Page X of Y" at bottom center + std::stringstream strstream; + strstream << "Page " << currentPage << " of " << maxPages; + bottomCenter = strstream.str(); + + return false; +} + +void ClientHandler::OnContextCreated(CefRefPtr browser, + CefRefPtr frame, + CefRefPtr context) { + REQUIRE_UI_THREAD(); +} + +bool ClientHandler::OnDragStart(CefRefPtr browser, + CefRefPtr dragData, + DragOperationsMask mask) { + REQUIRE_UI_THREAD(); + + // Forbid dragging of image files. + if (dragData->IsFile()) { + std::string fileExt = dragData->GetFileExtension(); + if (fileExt == ".png" || fileExt == ".jpg" || fileExt == ".gif") + return true; + } + + return false; +} + +bool ClientHandler::OnDragEnter(CefRefPtr browser, + CefRefPtr dragData, + DragOperationsMask mask) { + REQUIRE_UI_THREAD(); + + // Forbid dragging of link URLs. + if (dragData->IsLink()) + return true; + + return false; +} + +bool ClientHandler::OnBeforeScriptExtensionLoad( + CefRefPtr browser, + CefRefPtr frame, + const CefString& extensionName) { + return false; +} + +void ClientHandler::SetMainHwnd(CefWindowHandle hwnd) { + AutoLock lock_scope(this); + m_MainHwnd = hwnd; +} + +void ClientHandler::SetEditHwnd(CefWindowHandle hwnd) { + AutoLock lock_scope(this); + m_EditHwnd = hwnd; +} + +void ClientHandler::SetButtonHwnds(CefWindowHandle backHwnd, + CefWindowHandle forwardHwnd, + CefWindowHandle reloadHwnd, + CefWindowHandle stopHwnd) { + AutoLock lock_scope(this); + m_BackHwnd = backHwnd; + m_ForwardHwnd = forwardHwnd; + m_ReloadHwnd = reloadHwnd; + m_StopHwnd = stopHwnd; +} + +std::string ClientHandler::GetLogFile() { + AutoLock lock_scope(this); + return m_LogFile; +} + +void ClientHandler::AddDOMVisitor(const std::string& path, + CefRefPtr visitor) { + AutoLock lock_scope(this); + DOMVisitorMap::iterator it = m_DOMVisitors.find(path); + if (it == m_DOMVisitors.end()) + m_DOMVisitors.insert(std::make_pair(path, visitor)); + else + it->second = visitor; +} + +CefRefPtr ClientHandler::GetDOMVisitor(const std::string& path) { + AutoLock lock_scope(this); + DOMVisitorMap::iterator it = m_DOMVisitors.find(path); + if (it != m_DOMVisitors.end()) + return it->second; + return NULL; +} diff --git a/Atom-Linux/client_handler.h b/Atom-Linux/client_handler.h new file mode 100644 index 000000000..61c5a6012 --- /dev/null +++ b/Atom-Linux/client_handler.h @@ -0,0 +1,208 @@ +// Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights +// reserved. Use of this source code is governed by a BSD-style license that +// can be found in the LICENSE file. + +#ifndef CEF_TESTS_CEFCLIENT_CLIENT_HANDLER_H_ +#define CEF_TESTS_CEFCLIENT_CLIENT_HANDLER_H_ +#pragma once + +#include +#include +#include "include/cef_client.h" +#include "util.h" + + +// Define this value to redirect all popup URLs to the main application browser +// window. +// #define TEST_REDIRECT_POPUP_URLS + + +// ClientHandler implementation. +class ClientHandler : public CefClient, + public CefLifeSpanHandler, + public CefLoadHandler, + public CefDisplayHandler, + public CefFocusHandler, + public CefKeyboardHandler, + public CefPrintHandler, + public CefV8ContextHandler, + public CefDragHandler, + public CefPermissionHandler { + public: + ClientHandler(); + virtual ~ClientHandler(); + + // CefClient methods + virtual CefRefPtr GetLifeSpanHandler() OVERRIDE { + return this; + } + virtual CefRefPtr GetLoadHandler() OVERRIDE { + return this; + } + virtual CefRefPtr GetDisplayHandler() OVERRIDE { + return this; + } + virtual CefRefPtr GetFocusHandler() OVERRIDE { + return this; + } + virtual CefRefPtr GetKeyboardHandler() OVERRIDE { + return this; + } + virtual CefRefPtr GetPrintHandler() OVERRIDE { + return this; + } + virtual CefRefPtr GetV8ContextHandler() OVERRIDE { + return this; + } + virtual CefRefPtr GetDragHandler() OVERRIDE { + return this; + } + virtual CefRefPtr GetPermissionHandler() OVERRIDE { + return this; + } + + // CefLifeSpanHandler methods + virtual bool OnBeforePopup(CefRefPtr parentBrowser, + const CefPopupFeatures& popupFeatures, + CefWindowInfo& windowInfo, + const CefString& url, + CefRefPtr& client, + CefBrowserSettings& settings) OVERRIDE; + virtual void OnAfterCreated(CefRefPtr browser) OVERRIDE; + virtual bool DoClose(CefRefPtr browser) OVERRIDE; + virtual void OnBeforeClose(CefRefPtr browser) OVERRIDE; + + // CefLoadHandler methods + virtual void OnLoadStart(CefRefPtr browser, + CefRefPtr frame) OVERRIDE; + virtual void OnLoadEnd(CefRefPtr browser, + CefRefPtr frame, + int httpStatusCode) OVERRIDE; + virtual bool OnLoadError(CefRefPtr browser, + CefRefPtr frame, + ErrorCode errorCode, + const CefString& failedUrl, + CefString& errorText) OVERRIDE; + + // CefDisplayHandler methods + virtual void OnNavStateChange(CefRefPtr browser, + bool canGoBack, + bool canGoForward) OVERRIDE; + virtual void OnAddressChange(CefRefPtr browser, + CefRefPtr frame, + const CefString& url) OVERRIDE; + virtual void OnTitleChange(CefRefPtr browser, + const CefString& title) OVERRIDE; + virtual bool OnConsoleMessage(CefRefPtr browser, + const CefString& message, + const CefString& source, + int line) OVERRIDE; + + // CefFocusHandler methods. + virtual void OnFocusedNodeChanged(CefRefPtr browser, + CefRefPtr frame, + CefRefPtr node) OVERRIDE; + + // CefKeyboardHandler methods. + virtual bool OnKeyEvent(CefRefPtr browser, + KeyEventType type, + int code, + int modifiers, + bool isSystemKey, + bool isAfterJavaScript) OVERRIDE; + + // CefPrintHandler methods. + virtual bool GetPrintHeaderFooter(CefRefPtr browser, + CefRefPtr frame, + const CefPrintInfo& printInfo, + const CefString& url, + const CefString& title, + int currentPage, + int maxPages, + CefString& topLeft, + CefString& topCenter, + CefString& topRight, + CefString& bottomLeft, + CefString& bottomCenter, + CefString& bottomRight) OVERRIDE; + + // CefV8ContextHandler methods + virtual void OnContextCreated(CefRefPtr browser, + CefRefPtr frame, + CefRefPtr context) OVERRIDE; + + // CefDragHandler methods. + virtual bool OnDragStart(CefRefPtr browser, + CefRefPtr dragData, + DragOperationsMask mask) OVERRIDE; + virtual bool OnDragEnter(CefRefPtr browser, + CefRefPtr dragData, + DragOperationsMask mask) OVERRIDE; + + // CefPermissionHandler methods. + virtual bool OnBeforeScriptExtensionLoad(CefRefPtr browser, + CefRefPtr frame, + const CefString& extensionName) OVERRIDE; + + void SetMainHwnd(CefWindowHandle hwnd); + CefWindowHandle GetMainHwnd() { return m_MainHwnd; } + void SetEditHwnd(CefWindowHandle hwnd); + void SetButtonHwnds(CefWindowHandle backHwnd, + CefWindowHandle forwardHwnd, + CefWindowHandle reloadHwnd, + CefWindowHandle stopHwnd); + + CefRefPtr GetBrowser() { return m_Browser; } + CefWindowHandle GetBrowserHwnd() { return m_BrowserHwnd; } + + std::string GetLogFile(); + + // DOM visitors will be called after the associated path is loaded. + void AddDOMVisitor(const std::string& path, CefRefPtr visitor); + CefRefPtr GetDOMVisitor(const std::string& path); + + enum NotificationType { + NOTIFY_CONSOLE_MESSAGE + }; + void SendNotification(NotificationType type); + void CloseMainWindow(); + + protected: + void SetLoading(bool isLoading); + void SetNavState(bool canGoBack, bool canGoForward); + + // The child browser window + CefRefPtr m_Browser; + + // The main frame window handle + CefWindowHandle m_MainHwnd; + + // The child browser window handle + CefWindowHandle m_BrowserHwnd; + + // The edit window handle + CefWindowHandle m_EditHwnd; + + // The button window handles + CefWindowHandle m_BackHwnd; + CefWindowHandle m_ForwardHwnd; + CefWindowHandle m_StopHwnd; + CefWindowHandle m_ReloadHwnd; + + // Support for logging. + std::string m_LogFile; + + // Support for DOM visitors. + typedef std::map > DOMVisitorMap; + DOMVisitorMap m_DOMVisitors; + + // True if a form element currently has focus + bool m_bFormElementHasFocus; + + // Include the default reference counting implementation. + IMPLEMENT_REFCOUNTING(ClientHandler); + // Include the default locking implementation. + IMPLEMENT_LOCKING(ClientHandler); +}; + +#endif // CEF_TESTS_CEFCLIENT_CLIENT_HANDLER_H_ \ No newline at end of file diff --git a/Atom-Linux/client_handler_gtk.cpp b/Atom-Linux/client_handler_gtk.cpp new file mode 100644 index 000000000..99629fa91 --- /dev/null +++ b/Atom-Linux/client_handler_gtk.cpp @@ -0,0 +1,72 @@ +// Copyright (c) 2011 The Chromium Embedded Framework 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 +#include +#include "client_handler.h" +#include "include/cef_browser.h" +#include "include/cef_frame.h" +#include "string_util.h" + +// 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; +} + +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/Atom-Linux/native_handler.cpp b/Atom-Linux/native_handler.cpp new file mode 100644 index 000000000..63b71b7a0 --- /dev/null +++ b/Atom-Linux/native_handler.cpp @@ -0,0 +1,138 @@ +#include "native_handler.h" +#include "include/cef_base.h" +#include "client_handler.h" +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace std; + +NativeHandler::NativeHandler() : + CefV8Handler() { + object = CefV8Value::CreateObject(NULL, NULL); + + const char *functionNames[] = { "exists", "alert", "read", "write", + "absolute", "list", "isFile", "isDirectory", "remove", "asyncList", + "open", "openDialog", "quit", "writeToPasteboard", + "readFromPasteboard", "showDevTools", "newWindow", "saveDialog", + "exit", "watchPath", "unwatchPath", "makeDirectory", "move", + "moveToTrash" }; + int arrayLength = sizeof(functionNames) / sizeof(const char *); + for (int i = 0; i < arrayLength; i++) { + const char *functionName = functionNames[i]; + CefRefPtr function = CefV8Value::CreateFunction( + functionName, this); + object->SetValue(functionName, function, V8_PROPERTY_ATTRIBUTE_NONE); + } +} + +void Exists(const CefString& name, CefRefPtr object, + const CefV8ValueList& arguments, CefRefPtr& retval, + CefString& exception) { + string path = arguments[0]->GetStringValue().ToString(); + struct stat sbuf; + int result = stat(path.c_str(), &sbuf); + retval = CefV8Value::CreateBool(result == 0); +} + +void Read(const CefString& name, CefRefPtr object, + const CefV8ValueList& arguments, CefRefPtr& retval, + CefString& exception) { + string path = arguments[0]->GetStringValue().ToString(); + int fd = open(path.c_str(), O_RDONLY); + if (fd < 0) + return; + + char buffer[8192]; + int r; + string value; + while ((r = read(fd, buffer, sizeof buffer)) > 0) + value.append(buffer, 0, r); + close(fd); + retval = CefV8Value::CreateString(value); +} + +void Absolute(const CefString& name, CefRefPtr object, + const CefV8ValueList& arguments, CefRefPtr& retval, + CefString& exception) { + string path = arguments[0]->GetStringValue().ToString(); + if (path[0] == '~') { + string resolved = getenv("HOME"); + resolved.append(path.substr(1)); + retval = CefV8Value::CreateString(resolved); + } else + retval = CefV8Value::CreateString(path); +} + +void List(const CefString& name, CefRefPtr object, + const CefV8ValueList& arguments, CefRefPtr& retval, + CefString& exception) { + string path = arguments[0]->GetStringValue().ToString(); + DIR *dir; + if ((dir = opendir(path.c_str())) == NULL) + return; + + vector < string > paths; + dirent *entry; + + while ((entry = readdir(dir)) != NULL) { + if (strcmp(entry->d_name, ".") == 0) + continue; + if (strcmp(entry->d_name, "..") == 0) + continue; + paths.push_back(entry->d_name); + } + + closedir(dir); + + retval = CefV8Value::CreateArray(); + for (uint i = 0; i < paths.size(); i++) + retval->SetValue(i, CefV8Value::CreateString(path + "/" + paths[i])); +} + +void IsFile(const CefString& name, CefRefPtr object, + const CefV8ValueList& arguments, CefRefPtr& retval, + CefString& exception) { + string path = arguments[0]->GetStringValue().ToString(); + struct stat sbuf; + int result = stat(path.c_str(), &sbuf); + retval = CefV8Value::CreateBool(result == 0 && S_ISREG(sbuf.st_mode)); +} + +void IsDirectory(const CefString& name, CefRefPtr object, + const CefV8ValueList& arguments, CefRefPtr& retval, + CefString& exception) { + string path = arguments[0]->GetStringValue().ToString(); + struct stat sbuf; + int result = stat(path.c_str(), &sbuf); + retval = CefV8Value::CreateBool(result == 0 && S_ISDIR(sbuf.st_mode)); +} + +bool NativeHandler::Execute(const CefString& name, CefRefPtr object, + const CefV8ValueList& arguments, CefRefPtr& retval, + CefString& exception) { + + if (name == "exists") + Exists(name, object, arguments, retval, exception); + else if (name == "read") + Read(name, object, arguments, retval, exception); + else if (name == "absolute") + Absolute(name, object, arguments, retval, exception); + else if (name == "list") + List(name, object, arguments, retval, exception); + else if (name == "isFile") + IsFile(name, object, arguments, retval, exception); + else if (name == "isDirectory") + IsDirectory(name, object, arguments, retval, exception); + else if (name == "showDevTools") + CefV8Context::GetCurrentContext()->GetBrowser()->ShowDevTools(); + else + cout << "Unhandled -> " + name.ToString() << " : " + << arguments[0]->GetStringValue().ToString() << endl; + return true; +} diff --git a/Atom-Linux/native_handler.h b/Atom-Linux/native_handler.h new file mode 100644 index 000000000..23b50d8ca --- /dev/null +++ b/Atom-Linux/native_handler.h @@ -0,0 +1,22 @@ +#ifndef CEF_TESTS_CEFCLIENT_NATIVE_HANDLER_H_ +#define CEF_TESTS_CEFCLIENT_NATIVE_HANDLER_H_ + +#include "include/cef_base.h" +#include "include/cef_v8.h" + +class NativeHandler : public CefV8Handler { +public: + NativeHandler(); + + CefRefPtr object; + + virtual bool Execute(const CefString& name, + CefRefPtr object, + const CefV8ValueList& arguments, + CefRefPtr& retval, + CefString& exception); + + IMPLEMENT_REFCOUNTING(NativeHandler); +}; + +#endif \ No newline at end of file diff --git a/Atom-Linux/obj/cef/libcef.so b/Atom-Linux/obj/cef/libcef.so new file mode 100755 index 000000000..f6e77b31f Binary files /dev/null and b/Atom-Linux/obj/cef/libcef.so differ diff --git a/Atom-Linux/obj/cef/libcef_dll_wrapper.a b/Atom-Linux/obj/cef/libcef_dll_wrapper.a new file mode 100644 index 000000000..f4d48338b Binary files /dev/null and b/Atom-Linux/obj/cef/libcef_dll_wrapper.a differ diff --git a/Atom-Linux/obj/cef/libcef_static.a b/Atom-Linux/obj/cef/libcef_static.a new file mode 100644 index 000000000..157fb0cf4 Binary files /dev/null and b/Atom-Linux/obj/cef/libcef_static.a differ diff --git a/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/app_cpptoc.o b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/app_cpptoc.o new file mode 100644 index 000000000..ff4a4075f Binary files /dev/null and b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/app_cpptoc.o differ diff --git a/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/client_cpptoc.o b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/client_cpptoc.o new file mode 100644 index 000000000..d60fc888b Binary files /dev/null and b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/client_cpptoc.o differ diff --git a/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/content_filter_cpptoc.o b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/content_filter_cpptoc.o new file mode 100644 index 000000000..d2373ed2f Binary files /dev/null and b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/content_filter_cpptoc.o differ diff --git a/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/cookie_visitor_cpptoc.o b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/cookie_visitor_cpptoc.o new file mode 100644 index 000000000..cffc31927 Binary files /dev/null and b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/cookie_visitor_cpptoc.o differ diff --git a/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/display_handler_cpptoc.o b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/display_handler_cpptoc.o new file mode 100644 index 000000000..482ab03b4 Binary files /dev/null and b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/display_handler_cpptoc.o differ diff --git a/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/domevent_listener_cpptoc.o b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/domevent_listener_cpptoc.o new file mode 100644 index 000000000..8318abd10 Binary files /dev/null and b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/domevent_listener_cpptoc.o differ diff --git a/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/domvisitor_cpptoc.o b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/domvisitor_cpptoc.o new file mode 100644 index 000000000..1301bc4f9 Binary files /dev/null and b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/domvisitor_cpptoc.o differ diff --git a/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/download_handler_cpptoc.o b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/download_handler_cpptoc.o new file mode 100644 index 000000000..634b75745 Binary files /dev/null and b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/download_handler_cpptoc.o differ diff --git a/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/drag_handler_cpptoc.o b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/drag_handler_cpptoc.o new file mode 100644 index 000000000..a984b3ac9 Binary files /dev/null and b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/drag_handler_cpptoc.o differ diff --git a/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/find_handler_cpptoc.o b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/find_handler_cpptoc.o new file mode 100644 index 000000000..356863b2a Binary files /dev/null and b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/find_handler_cpptoc.o differ diff --git a/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/focus_handler_cpptoc.o b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/focus_handler_cpptoc.o new file mode 100644 index 000000000..8859d55ba Binary files /dev/null and b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/focus_handler_cpptoc.o differ diff --git a/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/jsdialog_handler_cpptoc.o b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/jsdialog_handler_cpptoc.o new file mode 100644 index 000000000..477defb28 Binary files /dev/null and b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/jsdialog_handler_cpptoc.o differ diff --git a/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/keyboard_handler_cpptoc.o b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/keyboard_handler_cpptoc.o new file mode 100644 index 000000000..2b4e2dca2 Binary files /dev/null and b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/keyboard_handler_cpptoc.o differ diff --git a/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/life_span_handler_cpptoc.o b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/life_span_handler_cpptoc.o new file mode 100644 index 000000000..399439d7e Binary files /dev/null and b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/life_span_handler_cpptoc.o differ diff --git a/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/load_handler_cpptoc.o b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/load_handler_cpptoc.o new file mode 100644 index 000000000..519407477 Binary files /dev/null and b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/load_handler_cpptoc.o differ diff --git a/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/menu_handler_cpptoc.o b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/menu_handler_cpptoc.o new file mode 100644 index 000000000..c3e9c482b Binary files /dev/null and b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/menu_handler_cpptoc.o differ diff --git a/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/permission_handler_cpptoc.o b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/permission_handler_cpptoc.o new file mode 100644 index 000000000..bcbb18533 Binary files /dev/null and b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/permission_handler_cpptoc.o differ diff --git a/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/print_handler_cpptoc.o b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/print_handler_cpptoc.o new file mode 100644 index 000000000..3b58f2e91 Binary files /dev/null and b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/print_handler_cpptoc.o differ diff --git a/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/proxy_handler_cpptoc.o b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/proxy_handler_cpptoc.o new file mode 100644 index 000000000..ec1000e5b Binary files /dev/null and b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/proxy_handler_cpptoc.o differ diff --git a/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/read_handler_cpptoc.o b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/read_handler_cpptoc.o new file mode 100644 index 000000000..039c6941c Binary files /dev/null and b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/read_handler_cpptoc.o differ diff --git a/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/render_handler_cpptoc.o b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/render_handler_cpptoc.o new file mode 100644 index 000000000..04ab32072 Binary files /dev/null and b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/render_handler_cpptoc.o differ diff --git a/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/request_handler_cpptoc.o b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/request_handler_cpptoc.o new file mode 100644 index 000000000..02398457f Binary files /dev/null and b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/request_handler_cpptoc.o differ diff --git a/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/resource_bundle_handler_cpptoc.o b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/resource_bundle_handler_cpptoc.o new file mode 100644 index 000000000..2541ddad6 Binary files /dev/null and b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/resource_bundle_handler_cpptoc.o differ diff --git a/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/scheme_handler_cpptoc.o b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/scheme_handler_cpptoc.o new file mode 100644 index 000000000..f5d819c1a Binary files /dev/null and b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/scheme_handler_cpptoc.o differ diff --git a/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/scheme_handler_factory_cpptoc.o b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/scheme_handler_factory_cpptoc.o new file mode 100644 index 000000000..9647755b5 Binary files /dev/null and b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/scheme_handler_factory_cpptoc.o differ diff --git a/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/storage_visitor_cpptoc.o b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/storage_visitor_cpptoc.o new file mode 100644 index 000000000..0d7a3daf5 Binary files /dev/null and b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/storage_visitor_cpptoc.o differ diff --git a/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/task_cpptoc.o b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/task_cpptoc.o new file mode 100644 index 000000000..319822d72 Binary files /dev/null and b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/task_cpptoc.o differ diff --git a/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/v8accessor_cpptoc.o b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/v8accessor_cpptoc.o new file mode 100644 index 000000000..b13422e92 Binary files /dev/null and b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/v8accessor_cpptoc.o differ diff --git a/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/v8context_handler_cpptoc.o b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/v8context_handler_cpptoc.o new file mode 100644 index 000000000..d74a2e285 Binary files /dev/null and b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/v8context_handler_cpptoc.o differ diff --git a/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/v8handler_cpptoc.o b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/v8handler_cpptoc.o new file mode 100644 index 000000000..a7cb83927 Binary files /dev/null and b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/v8handler_cpptoc.o differ diff --git a/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/web_urlrequest_client_cpptoc.o b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/web_urlrequest_client_cpptoc.o new file mode 100644 index 000000000..a8f9df0c1 Binary files /dev/null and b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/web_urlrequest_client_cpptoc.o differ diff --git a/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/write_handler_cpptoc.o b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/write_handler_cpptoc.o new file mode 100644 index 000000000..5e5a10001 Binary files /dev/null and b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/cpptoc/write_handler_cpptoc.o differ diff --git a/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/ctocpp/browser_ctocpp.o b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/ctocpp/browser_ctocpp.o new file mode 100644 index 000000000..bb37fd730 Binary files /dev/null and b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/ctocpp/browser_ctocpp.o differ diff --git a/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/ctocpp/command_line_ctocpp.o b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/ctocpp/command_line_ctocpp.o new file mode 100644 index 000000000..70ded2ddf Binary files /dev/null and b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/ctocpp/command_line_ctocpp.o differ diff --git a/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/ctocpp/cookie_manager_ctocpp.o b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/ctocpp/cookie_manager_ctocpp.o new file mode 100644 index 000000000..d567fbca1 Binary files /dev/null and b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/ctocpp/cookie_manager_ctocpp.o differ diff --git a/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/ctocpp/domdocument_ctocpp.o b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/ctocpp/domdocument_ctocpp.o new file mode 100644 index 000000000..19f1058c4 Binary files /dev/null and b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/ctocpp/domdocument_ctocpp.o differ diff --git a/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/ctocpp/domevent_ctocpp.o b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/ctocpp/domevent_ctocpp.o new file mode 100644 index 000000000..9c5b18abc Binary files /dev/null and b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/ctocpp/domevent_ctocpp.o differ diff --git a/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/ctocpp/domnode_ctocpp.o b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/ctocpp/domnode_ctocpp.o new file mode 100644 index 000000000..7fbed4fae Binary files /dev/null and b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/ctocpp/domnode_ctocpp.o differ diff --git a/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/ctocpp/drag_data_ctocpp.o b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/ctocpp/drag_data_ctocpp.o new file mode 100644 index 000000000..c7da3bc05 Binary files /dev/null and b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/ctocpp/drag_data_ctocpp.o differ diff --git a/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/ctocpp/frame_ctocpp.o b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/ctocpp/frame_ctocpp.o new file mode 100644 index 000000000..44ebc0f64 Binary files /dev/null and b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/ctocpp/frame_ctocpp.o differ diff --git a/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/ctocpp/post_data_ctocpp.o b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/ctocpp/post_data_ctocpp.o new file mode 100644 index 000000000..82654bb1a Binary files /dev/null and b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/ctocpp/post_data_ctocpp.o differ diff --git a/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/ctocpp/post_data_element_ctocpp.o b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/ctocpp/post_data_element_ctocpp.o new file mode 100644 index 000000000..de9b2e09b Binary files /dev/null and b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/ctocpp/post_data_element_ctocpp.o differ diff --git a/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/ctocpp/request_ctocpp.o b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/ctocpp/request_ctocpp.o new file mode 100644 index 000000000..22e086ccc Binary files /dev/null and b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/ctocpp/request_ctocpp.o differ diff --git a/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/ctocpp/response_ctocpp.o b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/ctocpp/response_ctocpp.o new file mode 100644 index 000000000..1922fd013 Binary files /dev/null and b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/ctocpp/response_ctocpp.o differ diff --git a/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/ctocpp/scheme_handler_callback_ctocpp.o b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/ctocpp/scheme_handler_callback_ctocpp.o new file mode 100644 index 000000000..b2bac45b7 Binary files /dev/null and b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/ctocpp/scheme_handler_callback_ctocpp.o differ diff --git a/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/ctocpp/stream_reader_ctocpp.o b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/ctocpp/stream_reader_ctocpp.o new file mode 100644 index 000000000..2078faba5 Binary files /dev/null and b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/ctocpp/stream_reader_ctocpp.o differ diff --git a/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/ctocpp/stream_writer_ctocpp.o b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/ctocpp/stream_writer_ctocpp.o new file mode 100644 index 000000000..3c88532e1 Binary files /dev/null and b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/ctocpp/stream_writer_ctocpp.o differ diff --git a/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/ctocpp/v8context_ctocpp.o b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/ctocpp/v8context_ctocpp.o new file mode 100644 index 000000000..e09b63788 Binary files /dev/null and b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/ctocpp/v8context_ctocpp.o differ diff --git a/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/ctocpp/v8exception_ctocpp.o b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/ctocpp/v8exception_ctocpp.o new file mode 100644 index 000000000..831a6d63b Binary files /dev/null and b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/ctocpp/v8exception_ctocpp.o differ diff --git a/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/ctocpp/v8value_ctocpp.o b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/ctocpp/v8value_ctocpp.o new file mode 100644 index 000000000..34c0b9c46 Binary files /dev/null and b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/ctocpp/v8value_ctocpp.o differ diff --git a/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/ctocpp/web_plugin_info_ctocpp.o b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/ctocpp/web_plugin_info_ctocpp.o new file mode 100644 index 000000000..4c0e2a459 Binary files /dev/null and b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/ctocpp/web_plugin_info_ctocpp.o differ diff --git a/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/ctocpp/web_urlrequest_ctocpp.o b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/ctocpp/web_urlrequest_ctocpp.o new file mode 100644 index 000000000..9eb411177 Binary files /dev/null and b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/ctocpp/web_urlrequest_ctocpp.o differ diff --git a/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/ctocpp/xml_reader_ctocpp.o b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/ctocpp/xml_reader_ctocpp.o new file mode 100644 index 000000000..4a693cfae Binary files /dev/null and b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/ctocpp/xml_reader_ctocpp.o differ diff --git a/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/ctocpp/zip_reader_ctocpp.o b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/ctocpp/zip_reader_ctocpp.o new file mode 100644 index 000000000..0d1920f1e Binary files /dev/null and b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/ctocpp/zip_reader_ctocpp.o differ diff --git a/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/transfer_util.o b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/transfer_util.o new file mode 100644 index 000000000..8d7c61929 Binary files /dev/null and b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/transfer_util.o differ diff --git a/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/wrapper/cef_byte_read_handler.o b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/wrapper/cef_byte_read_handler.o new file mode 100644 index 000000000..6c2c2896d Binary files /dev/null and b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/wrapper/cef_byte_read_handler.o differ diff --git a/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/wrapper/cef_xml_object.o b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/wrapper/cef_xml_object.o new file mode 100644 index 000000000..9efdec3d2 Binary files /dev/null and b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/wrapper/cef_xml_object.o differ diff --git a/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/wrapper/cef_zip_archive.o b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/wrapper/cef_zip_archive.o new file mode 100644 index 000000000..dda876972 Binary files /dev/null and b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/wrapper/cef_zip_archive.o differ diff --git a/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/wrapper/libcef_dll_wrapper.o b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/wrapper/libcef_dll_wrapper.o new file mode 100644 index 000000000..d133dc019 Binary files /dev/null and b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/wrapper/libcef_dll_wrapper.o differ diff --git a/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/wrapper/libcef_dll_wrapper2.o b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/wrapper/libcef_dll_wrapper2.o new file mode 100644 index 000000000..900f5a30b Binary files /dev/null and b/Atom-Linux/obj/libcef_dll_wrapper/cef/libcef_dll/wrapper/libcef_dll_wrapper2.o differ diff --git a/Atom-Linux/string_util.cpp b/Atom-Linux/string_util.cpp new file mode 100644 index 000000000..8952d1bf3 --- /dev/null +++ b/Atom-Linux/string_util.cpp @@ -0,0 +1,74 @@ +// Copyright (c) 2010 The Chromium Embedded Framework 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 "string_util.h" +#include +#include +#include "include/cef_request.h" + +void DumpRequestContents(CefRefPtr request, std::string& str) { + std::stringstream ss; + + ss << "URL: " << std::string(request->GetURL()); + ss << "\nMethod: " << std::string(request->GetMethod()); + + CefRequest::HeaderMap headerMap; + request->GetHeaderMap(headerMap); + if (headerMap.size() > 0) { + ss << "\nHeaders:"; + CefRequest::HeaderMap::const_iterator it = headerMap.begin(); + for (; it != headerMap.end(); ++it) { + ss << "\n\t" << std::string((*it).first) << ": " << + std::string((*it).second); + } + } + + CefRefPtr postData = request->GetPostData(); + if (postData.get()) { + CefPostData::ElementVector elements; + postData->GetElements(elements); + if (elements.size() > 0) { + ss << "\nPost Data:"; + CefRefPtr element; + CefPostData::ElementVector::const_iterator it = elements.begin(); + for (; it != elements.end(); ++it) { + element = (*it); + if (element->GetType() == PDE_TYPE_BYTES) { + // the element is composed of bytes + ss << "\n\tBytes: "; + if (element->GetBytesCount() == 0) { + ss << "(empty)"; + } else { + // retrieve the data. + size_t size = element->GetBytesCount(); + char* bytes = new char[size]; + element->GetBytes(size, bytes); + ss << std::string(bytes, size); + delete [] bytes; + } + } else if (element->GetType() == PDE_TYPE_FILE) { + ss << "\n\tFile: " << std::string(element->GetFile()); + } + } + } + } + + str = ss.str(); +} + +std::string StringReplace(const std::string& str, const std::string& from, + const std::string& to) { + std::string result = str; + std::string::size_type pos = 0; + std::string::size_type from_len = from.length(); + std::string::size_type to_len = to.length(); + do { + pos = result.find(from, pos); + if (pos != std::string::npos) { + result.replace(pos, from_len, to); + pos += to_len; + } + } while (pos != std::string::npos); + return result; +} diff --git a/Atom-Linux/string_util.h b/Atom-Linux/string_util.h new file mode 100644 index 000000000..c43e6f210 --- /dev/null +++ b/Atom-Linux/string_util.h @@ -0,0 +1,21 @@ +// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// reserved. Use of this source code is governed by a BSD-style license that +// can be found in the LICENSE file. + +#ifndef CEF_TESTS_CEFCLIENT_STRING_UTIL_H_ +#define CEF_TESTS_CEFCLIENT_STRING_UTIL_H_ +#pragma once + +#include +#include "include/cef_base.h" + +class CefRequest; + +// Dump the contents of the request into a string. +void DumpRequestContents(CefRefPtr request, std::string& str); + +// Replace all instances of |from| with |to| in |str|. +std::string StringReplace(const std::string& str, const std::string& from, + const std::string& to); + +#endif // CEF_TESTS_CEFCLIENT_STRING_UTIL_H_ diff --git a/Atom-Linux/util.h b/Atom-Linux/util.h new file mode 100644 index 000000000..ba0305c1c --- /dev/null +++ b/Atom-Linux/util.h @@ -0,0 +1,37 @@ +// Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights +// reserved. Use of this source code is governed by a BSD-style license that +// can be found in the LICENSE file. + +#ifndef CEF_TESTS_CEFCLIENT_UTIL_H_ +#define CEF_TESTS_CEFCLIENT_UTIL_H_ +#pragma once + +#include "include/cef_task.h" + +#if defined(OS_WIN) + +#include // NOLINT(build/include_order) + +#ifndef NDEBUG +#define ASSERT(condition) if (!(condition)) { DebugBreak(); } +#else +#define ASSERT(condition) ((void)0) +#endif + +#else // !OS_WIN + +#include // NOLINT(build/include_order) + +#ifndef NDEBUG +#define ASSERT(condition) if (!(condition)) { assert(false); } +#else +#define ASSERT(condition) ((void)0) +#endif + +#endif // !OS_WIN + +#define REQUIRE_UI_THREAD() ASSERT(CefCurrentlyOn(TID_UI)); +#define REQUIRE_IO_THREAD() ASSERT(CefCurrentlyOn(TID_IO)); +#define REQUIRE_FILE_THREAD() ASSERT(CefCurrentlyOn(TID_FILE)); + +#endif // CEF_TESTS_CEFCLIENT_UTIL_H_