From dbe8de277f0677330e83419a1f068785b584e44f Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Fri, 20 May 2011 14:42:25 +0000 Subject: [PATCH] Significant API changes for issue #218: - Replace CefHandler with a new CefClient interface and separate handler interfaces. - Add support for virtual inheritance to allow multiple CefBase parented interfaces to be implemented in the same class. - Replace CefThreadSafeBase with IMPLEMENT_* macros to support virtual inheritance and to only provide locking implementations when needed. - Move the CefBrowserSettings parameter from CefInitialize to CreateBrowser. - Add a new cef_build.h header that provides platform-specific and OS_* defines. - Introduce the use of OVERRIDE to generate compiler errors on Windows if a child virtual method declaration doesn't match the parent declaration. - Use NDEBUG instead of _DEBUG because _DEBUG is not defined on Mac. (issue #240). git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@235 5089003a-bbd8-11dd-ad1f-f1f9622dbc98 --- cef.gyp | 64 +- include/cef.h | 1003 +++++++++-------- include/cef_build.h | 112 ++ include/cef_capi.h | 673 ++++++----- include/cef_export.h | 16 +- include/cef_runnable.h | 8 +- include/cef_string_types.h | 7 +- include/cef_types.h | 19 +- include/cef_types_linux.h | 4 +- include/cef_types_mac.h | 4 +- include/cef_types_win.h | 4 +- include/cef_wrapper.h | 15 +- libcef/browser_impl.cc | 154 +-- libcef/browser_impl.h | 132 +-- libcef/browser_impl_win.cc | 32 +- libcef/browser_resource_loader_bridge.cc | 123 +- libcef/browser_webkit_init.h | 55 +- libcef/browser_webview_delegate.cc | 320 ++++-- libcef/browser_webview_delegate.h | 171 +-- libcef/browser_webview_delegate_win.cc | 92 +- libcef/cef_context.cc | 69 +- libcef/cef_context.h | 11 +- libcef/dom_document_impl.h | 36 +- libcef/dom_event_impl.h | 20 +- libcef/dom_node_impl.h | 50 +- libcef/request_impl.h | 63 +- libcef/response_impl.h | 5 +- libcef/scheme_impl.cc | 18 +- libcef/stream_impl.cc | 102 +- libcef/stream_impl.h | 77 +- libcef/tracker.h | 5 +- libcef/v8_impl.cc | 24 +- libcef/v8_impl.h | 81 +- libcef/web_urlrequest_impl.h | 10 +- libcef/xml_reader_impl.h | 4 +- libcef/zip_reader_impl.h | 4 +- libcef_dll/cpptoc/base_cpptoc.h | 15 +- libcef_dll/cpptoc/browser_cpptoc.cc | 65 +- libcef_dll/cpptoc/browser_cpptoc.h | 2 +- libcef_dll/cpptoc/client_cpptoc.cc | 234 ++++ .../{handler_cpptoc.h => client_cpptoc.h} | 16 +- libcef_dll/cpptoc/cookie_visitor_cpptoc.cc | 4 +- libcef_dll/cpptoc/cookie_visitor_cpptoc.h | 2 +- libcef_dll/cpptoc/cpptoc.h | 21 +- libcef_dll/cpptoc/display_handler_cpptoc.cc | 123 ++ libcef_dll/cpptoc/display_handler_cpptoc.h | 35 + libcef_dll/cpptoc/domdocument_cpptoc.cc | 4 +- libcef_dll/cpptoc/domdocument_cpptoc.h | 2 +- libcef_dll/cpptoc/domevent_cpptoc.cc | 4 +- libcef_dll/cpptoc/domevent_cpptoc.h | 2 +- libcef_dll/cpptoc/domevent_listener_cpptoc.cc | 4 +- libcef_dll/cpptoc/domevent_listener_cpptoc.h | 2 +- libcef_dll/cpptoc/domnode_cpptoc.cc | 4 +- libcef_dll/cpptoc/domnode_cpptoc.h | 2 +- libcef_dll/cpptoc/domvisitor_cpptoc.cc | 4 +- libcef_dll/cpptoc/domvisitor_cpptoc.h | 2 +- libcef_dll/cpptoc/download_handler_cpptoc.cc | 4 +- libcef_dll/cpptoc/download_handler_cpptoc.h | 2 +- libcef_dll/cpptoc/find_handler_cpptoc.cc | 48 + libcef_dll/cpptoc/find_handler_cpptoc.h | 34 + libcef_dll/cpptoc/focus_handler_cpptoc.cc | 58 + libcef_dll/cpptoc/focus_handler_cpptoc.h | 35 + libcef_dll/cpptoc/frame_cpptoc.cc | 4 +- libcef_dll/cpptoc/frame_cpptoc.h | 2 +- libcef_dll/cpptoc/handler_cpptoc.cc | 681 ----------- libcef_dll/cpptoc/jsbinding_handler_cpptoc.cc | 51 + libcef_dll/cpptoc/jsbinding_handler_cpptoc.h | 35 + libcef_dll/cpptoc/jsdialog_handler_cpptoc.cc | 99 ++ libcef_dll/cpptoc/jsdialog_handler_cpptoc.h | 35 + libcef_dll/cpptoc/keyboard_handler_cpptoc.cc | 48 + libcef_dll/cpptoc/keyboard_handler_cpptoc.h | 35 + libcef_dll/cpptoc/life_span_handler_cpptoc.cc | 117 ++ libcef_dll/cpptoc/life_span_handler_cpptoc.h | 35 + libcef_dll/cpptoc/load_handler_cpptoc.cc | 81 ++ libcef_dll/cpptoc/load_handler_cpptoc.h | 34 + libcef_dll/cpptoc/menu_handler_cpptoc.cc | 74 ++ libcef_dll/cpptoc/menu_handler_cpptoc.h | 34 + libcef_dll/cpptoc/post_data_cpptoc.cc | 4 +- libcef_dll/cpptoc/post_data_cpptoc.h | 2 +- libcef_dll/cpptoc/post_data_element_cpptoc.cc | 4 +- libcef_dll/cpptoc/post_data_element_cpptoc.h | 2 +- libcef_dll/cpptoc/print_handler_cpptoc.cc | 87 ++ libcef_dll/cpptoc/print_handler_cpptoc.h | 35 + libcef_dll/cpptoc/read_handler_cpptoc.cc | 4 +- libcef_dll/cpptoc/read_handler_cpptoc.h | 2 +- libcef_dll/cpptoc/render_handler_cpptoc.cc | 144 +++ libcef_dll/cpptoc/render_handler_cpptoc.h | 35 + libcef_dll/cpptoc/request_cpptoc.cc | 4 +- libcef_dll/cpptoc/request_cpptoc.h | 2 +- libcef_dll/cpptoc/request_handler_cpptoc.cc | 157 +++ libcef_dll/cpptoc/request_handler_cpptoc.h | 35 + libcef_dll/cpptoc/response_cpptoc.cc | 4 +- libcef_dll/cpptoc/response_cpptoc.h | 2 +- libcef_dll/cpptoc/scheme_handler_cpptoc.cc | 4 +- libcef_dll/cpptoc/scheme_handler_cpptoc.h | 2 +- .../cpptoc/scheme_handler_factory_cpptoc.cc | 4 +- .../cpptoc/scheme_handler_factory_cpptoc.h | 2 +- libcef_dll/cpptoc/stream_reader_cpptoc.cc | 4 +- libcef_dll/cpptoc/stream_reader_cpptoc.h | 2 +- libcef_dll/cpptoc/stream_writer_cpptoc.cc | 4 +- libcef_dll/cpptoc/stream_writer_cpptoc.h | 2 +- libcef_dll/cpptoc/task_cpptoc.cc | 4 +- libcef_dll/cpptoc/task_cpptoc.h | 2 +- libcef_dll/cpptoc/v8accessor_cpptoc.cc | 4 +- libcef_dll/cpptoc/v8accessor_cpptoc.h | 2 +- libcef_dll/cpptoc/v8context_cpptoc.cc | 4 +- libcef_dll/cpptoc/v8context_cpptoc.h | 2 +- libcef_dll/cpptoc/v8handler_cpptoc.cc | 6 +- libcef_dll/cpptoc/v8handler_cpptoc.h | 2 +- libcef_dll/cpptoc/v8value_cpptoc.cc | 4 +- libcef_dll/cpptoc/v8value_cpptoc.h | 2 +- .../cpptoc/web_urlrequest_client_cpptoc.cc | 4 +- .../cpptoc/web_urlrequest_client_cpptoc.h | 2 +- libcef_dll/cpptoc/web_urlrequest_cpptoc.cc | 4 +- libcef_dll/cpptoc/web_urlrequest_cpptoc.h | 2 +- libcef_dll/cpptoc/write_handler_cpptoc.cc | 4 +- libcef_dll/cpptoc/write_handler_cpptoc.h | 2 +- libcef_dll/cpptoc/xml_reader_cpptoc.cc | 4 +- libcef_dll/cpptoc/xml_reader_cpptoc.h | 2 +- libcef_dll/cpptoc/zip_reader_cpptoc.cc | 4 +- libcef_dll/cpptoc/zip_reader_cpptoc.h | 2 +- libcef_dll/ctocpp/base_ctocpp.h | 15 +- libcef_dll/ctocpp/browser_ctocpp.cc | 32 +- libcef_dll/ctocpp/browser_ctocpp.h | 72 +- libcef_dll/ctocpp/client_ctocpp.cc | 183 +++ libcef_dll/ctocpp/client_ctocpp.h | 50 + libcef_dll/ctocpp/cookie_visitor_ctocpp.cc | 4 +- libcef_dll/ctocpp/cookie_visitor_ctocpp.h | 4 +- libcef_dll/ctocpp/ctocpp.h | 21 +- libcef_dll/ctocpp/display_handler_ctocpp.cc | 85 ++ libcef_dll/ctocpp/display_handler_ctocpp.h | 52 + libcef_dll/ctocpp/domdocument_ctocpp.cc | 4 +- libcef_dll/ctocpp/domdocument_ctocpp.h | 34 +- libcef_dll/ctocpp/domevent_ctocpp.cc | 4 +- libcef_dll/ctocpp/domevent_ctocpp.h | 18 +- libcef_dll/ctocpp/domevent_listener_ctocpp.cc | 4 +- libcef_dll/ctocpp/domevent_listener_ctocpp.h | 4 +- libcef_dll/ctocpp/domnode_ctocpp.cc | 4 +- libcef_dll/ctocpp/domnode_ctocpp.h | 48 +- libcef_dll/ctocpp/domvisitor_ctocpp.cc | 4 +- libcef_dll/ctocpp/domvisitor_ctocpp.h | 4 +- libcef_dll/ctocpp/download_handler_ctocpp.cc | 4 +- libcef_dll/ctocpp/download_handler_ctocpp.h | 6 +- libcef_dll/ctocpp/find_handler_ctocpp.cc | 35 + libcef_dll/ctocpp/find_handler_ctocpp.h | 42 + libcef_dll/ctocpp/focus_handler_ctocpp.cc | 43 + libcef_dll/ctocpp/focus_handler_ctocpp.h | 43 + libcef_dll/ctocpp/frame_ctocpp.cc | 4 +- libcef_dll/ctocpp/frame_ctocpp.h | 47 +- libcef_dll/ctocpp/handler_ctocpp.cc | 474 -------- libcef_dll/ctocpp/handler_ctocpp.h | 115 -- libcef_dll/ctocpp/jsbinding_handler_ctocpp.cc | 36 + libcef_dll/ctocpp/jsbinding_handler_ctocpp.h | 42 + libcef_dll/ctocpp/jsdialog_handler_ctocpp.cc | 63 ++ libcef_dll/ctocpp/jsdialog_handler_ctocpp.h | 49 + libcef_dll/ctocpp/keyboard_handler_ctocpp.cc | 34 + libcef_dll/ctocpp/keyboard_handler_ctocpp.h | 42 + libcef_dll/ctocpp/life_span_handler_ctocpp.cc | 71 ++ libcef_dll/ctocpp/life_span_handler_ctocpp.h | 46 + libcef_dll/ctocpp/load_handler_ctocpp.cc | 57 + libcef_dll/ctocpp/load_handler_ctocpp.h | 46 + libcef_dll/ctocpp/menu_handler_ctocpp.cc | 54 + libcef_dll/ctocpp/menu_handler_ctocpp.h | 45 + libcef_dll/ctocpp/post_data_ctocpp.cc | 4 +- libcef_dll/ctocpp/post_data_ctocpp.h | 12 +- libcef_dll/ctocpp/post_data_element_ctocpp.cc | 4 +- libcef_dll/ctocpp/post_data_element_ctocpp.h | 16 +- libcef_dll/ctocpp/print_handler_ctocpp.cc | 54 + libcef_dll/ctocpp/print_handler_ctocpp.h | 48 + libcef_dll/ctocpp/read_handler_ctocpp.cc | 4 +- libcef_dll/ctocpp/read_handler_ctocpp.h | 10 +- libcef_dll/ctocpp/render_handler_ctocpp.cc | 93 ++ libcef_dll/ctocpp/render_handler_ctocpp.h | 53 + libcef_dll/ctocpp/request_ctocpp.cc | 4 +- libcef_dll/ctocpp/request_ctocpp.h | 28 +- libcef_dll/ctocpp/request_handler_ctocpp.cc | 107 ++ libcef_dll/ctocpp/request_handler_ctocpp.h | 55 + libcef_dll/ctocpp/response_ctocpp.cc | 4 +- libcef_dll/ctocpp/response_ctocpp.h | 20 +- libcef_dll/ctocpp/scheme_handler_ctocpp.cc | 4 +- libcef_dll/ctocpp/scheme_handler_ctocpp.h | 9 +- .../ctocpp/scheme_handler_factory_ctocpp.cc | 4 +- .../ctocpp/scheme_handler_factory_ctocpp.h | 4 +- libcef_dll/ctocpp/stream_reader_ctocpp.cc | 4 +- libcef_dll/ctocpp/stream_reader_ctocpp.h | 10 +- libcef_dll/ctocpp/stream_writer_ctocpp.cc | 4 +- libcef_dll/ctocpp/stream_writer_ctocpp.h | 10 +- libcef_dll/ctocpp/task_ctocpp.cc | 4 +- libcef_dll/ctocpp/task_ctocpp.h | 4 +- libcef_dll/ctocpp/v8accessor_ctocpp.cc | 4 +- libcef_dll/ctocpp/v8accessor_ctocpp.h | 6 +- libcef_dll/ctocpp/v8context_ctocpp.cc | 4 +- libcef_dll/ctocpp/v8context_ctocpp.h | 12 +- libcef_dll/ctocpp/v8handler_ctocpp.cc | 6 +- libcef_dll/ctocpp/v8handler_ctocpp.h | 4 +- libcef_dll/ctocpp/v8value_ctocpp.cc | 4 +- libcef_dll/ctocpp/v8value_ctocpp.h | 63 +- .../ctocpp/web_urlrequest_client_ctocpp.cc | 4 +- .../ctocpp/web_urlrequest_client_ctocpp.h | 15 +- libcef_dll/ctocpp/web_urlrequest_ctocpp.cc | 4 +- libcef_dll/ctocpp/web_urlrequest_ctocpp.h | 6 +- libcef_dll/ctocpp/write_handler_ctocpp.cc | 4 +- libcef_dll/ctocpp/write_handler_ctocpp.h | 10 +- libcef_dll/ctocpp/xml_reader_ctocpp.cc | 4 +- libcef_dll/ctocpp/xml_reader_ctocpp.h | 60 +- libcef_dll/ctocpp/zip_reader_ctocpp.cc | 4 +- libcef_dll/ctocpp/zip_reader_ctocpp.h | 27 +- libcef_dll/libcef_dll.cc | 18 +- libcef_dll/wrapper/cef_byte_read_handler.cc | 18 +- libcef_dll/wrapper/cef_zip_archive.cc | 4 +- libcef_dll/wrapper/libcef_dll_wrapper.cc | 15 +- tests/cefclient/binding_test.cpp | 4 +- tests/cefclient/cefclient.cpp | 312 +---- tests/cefclient/cefclient.h | 527 +-------- tests/cefclient/cefclient_mac.mm | 139 +-- tests/cefclient/cefclient_win.cpp | 160 +-- tests/cefclient/client_handler.cpp | 290 +++++ tests/cefclient/client_handler.h | 188 +++ tests/cefclient/client_handler_mac.mm | 142 +++ tests/cefclient/client_handler_win.cpp | 156 +++ tests/cefclient/client_popup_handler.cpp | 34 + tests/cefclient/client_popup_handler.h | 36 + tests/cefclient/clientplugin.cpp | 4 +- tests/cefclient/clientplugin.h | 7 +- tests/cefclient/download_handler.cpp | 36 +- tests/cefclient/extension_test.cpp | 4 +- tests/cefclient/osrplugin.cpp | 210 ++-- tests/cefclient/osrplugin.h | 4 +- tests/cefclient/osrplugin_test.cpp | 13 +- tests/cefclient/resource_util.h | 6 +- tests/cefclient/resource_util_win.cpp | 4 +- tests/cefclient/scheme_test.cpp | 31 +- tests/cefclient/uiplugin.cpp | 4 +- tests/cefclient/uiplugin.h | 4 +- tests/cefclient/uiplugin_test.cpp | 4 +- tests/cefclient/util.h | 45 +- tests/unittests/cookie_unittest.cc | 4 +- tests/unittests/dom_unittest.cc | 14 +- tests/unittests/request_unittest.cc | 39 +- tests/unittests/scheme_handler_unittest.cc | 35 +- tests/unittests/stream_unittest.cc | 8 +- tests/unittests/test_handler.h | 307 +---- tests/unittests/test_suite.h | 3 +- tests/unittests/v8_unittest.cc | 49 +- tests/unittests/web_urlrequest_unittest.cc | 14 +- tools/cef_parser.py | 7 +- tools/make_capi_header.py | 4 +- tools/make_cpptoc_header.py | 4 +- tools/make_cpptoc_impl.py | 6 +- tools/make_ctocpp_header.py | 6 +- tools/make_ctocpp_impl.py | 6 +- 251 files changed, 7127 insertions(+), 4945 deletions(-) create mode 100644 include/cef_build.h create mode 100644 libcef_dll/cpptoc/client_cpptoc.cc rename libcef_dll/cpptoc/{handler_cpptoc.h => client_cpptoc.h} (71%) create mode 100644 libcef_dll/cpptoc/display_handler_cpptoc.cc create mode 100644 libcef_dll/cpptoc/display_handler_cpptoc.h create mode 100644 libcef_dll/cpptoc/find_handler_cpptoc.cc create mode 100644 libcef_dll/cpptoc/find_handler_cpptoc.h create mode 100644 libcef_dll/cpptoc/focus_handler_cpptoc.cc create mode 100644 libcef_dll/cpptoc/focus_handler_cpptoc.h delete mode 100644 libcef_dll/cpptoc/handler_cpptoc.cc create mode 100644 libcef_dll/cpptoc/jsbinding_handler_cpptoc.cc create mode 100644 libcef_dll/cpptoc/jsbinding_handler_cpptoc.h create mode 100644 libcef_dll/cpptoc/jsdialog_handler_cpptoc.cc create mode 100644 libcef_dll/cpptoc/jsdialog_handler_cpptoc.h create mode 100644 libcef_dll/cpptoc/keyboard_handler_cpptoc.cc create mode 100644 libcef_dll/cpptoc/keyboard_handler_cpptoc.h create mode 100644 libcef_dll/cpptoc/life_span_handler_cpptoc.cc create mode 100644 libcef_dll/cpptoc/life_span_handler_cpptoc.h create mode 100644 libcef_dll/cpptoc/load_handler_cpptoc.cc create mode 100644 libcef_dll/cpptoc/load_handler_cpptoc.h create mode 100644 libcef_dll/cpptoc/menu_handler_cpptoc.cc create mode 100644 libcef_dll/cpptoc/menu_handler_cpptoc.h create mode 100644 libcef_dll/cpptoc/print_handler_cpptoc.cc create mode 100644 libcef_dll/cpptoc/print_handler_cpptoc.h create mode 100644 libcef_dll/cpptoc/render_handler_cpptoc.cc create mode 100644 libcef_dll/cpptoc/render_handler_cpptoc.h create mode 100644 libcef_dll/cpptoc/request_handler_cpptoc.cc create mode 100644 libcef_dll/cpptoc/request_handler_cpptoc.h create mode 100644 libcef_dll/ctocpp/client_ctocpp.cc create mode 100644 libcef_dll/ctocpp/client_ctocpp.h create mode 100644 libcef_dll/ctocpp/display_handler_ctocpp.cc create mode 100644 libcef_dll/ctocpp/display_handler_ctocpp.h create mode 100644 libcef_dll/ctocpp/find_handler_ctocpp.cc create mode 100644 libcef_dll/ctocpp/find_handler_ctocpp.h create mode 100644 libcef_dll/ctocpp/focus_handler_ctocpp.cc create mode 100644 libcef_dll/ctocpp/focus_handler_ctocpp.h delete mode 100644 libcef_dll/ctocpp/handler_ctocpp.cc delete mode 100644 libcef_dll/ctocpp/handler_ctocpp.h create mode 100644 libcef_dll/ctocpp/jsbinding_handler_ctocpp.cc create mode 100644 libcef_dll/ctocpp/jsbinding_handler_ctocpp.h create mode 100644 libcef_dll/ctocpp/jsdialog_handler_ctocpp.cc create mode 100644 libcef_dll/ctocpp/jsdialog_handler_ctocpp.h create mode 100644 libcef_dll/ctocpp/keyboard_handler_ctocpp.cc create mode 100644 libcef_dll/ctocpp/keyboard_handler_ctocpp.h create mode 100644 libcef_dll/ctocpp/life_span_handler_ctocpp.cc create mode 100644 libcef_dll/ctocpp/life_span_handler_ctocpp.h create mode 100644 libcef_dll/ctocpp/load_handler_ctocpp.cc create mode 100644 libcef_dll/ctocpp/load_handler_ctocpp.h create mode 100644 libcef_dll/ctocpp/menu_handler_ctocpp.cc create mode 100644 libcef_dll/ctocpp/menu_handler_ctocpp.h create mode 100644 libcef_dll/ctocpp/print_handler_ctocpp.cc create mode 100644 libcef_dll/ctocpp/print_handler_ctocpp.h create mode 100644 libcef_dll/ctocpp/render_handler_ctocpp.cc create mode 100644 libcef_dll/ctocpp/render_handler_ctocpp.h create mode 100644 libcef_dll/ctocpp/request_handler_ctocpp.cc create mode 100644 libcef_dll/ctocpp/request_handler_ctocpp.h create mode 100644 tests/cefclient/client_handler.cpp create mode 100644 tests/cefclient/client_handler.h create mode 100644 tests/cefclient/client_handler_mac.mm create mode 100644 tests/cefclient/client_handler_win.cpp create mode 100644 tests/cefclient/client_popup_handler.cpp create mode 100644 tests/cefclient/client_popup_handler.h diff --git a/cef.gyp b/cef.gyp index 633a42d9e..35ce582a8 100644 --- a/cef.gyp +++ b/cef.gyp @@ -34,6 +34,10 @@ 'tests/cefclient/binding_test.h', 'tests/cefclient/cefclient.cpp', 'tests/cefclient/cefclient.h', + 'tests/cefclient/client_handler.cpp', + 'tests/cefclient/client_handler.h', + 'tests/cefclient/client_popup_handler.cpp', + 'tests/cefclient/client_popup_handler.h', 'tests/cefclient/download_handler.cpp', 'tests/cefclient/download_handler.h', 'tests/cefclient/extension_test.cpp', @@ -87,6 +91,7 @@ 'tests/cefclient/cefclient.ico', 'tests/cefclient/cefclient.rc', 'tests/cefclient/cefclient_win.cpp', + 'tests/cefclient/client_handler_win.cpp', 'tests/cefclient/clientplugin.cpp', 'tests/cefclient/clientplugin.h', 'tests/cefclient/osrplugin.cpp', @@ -162,6 +167,7 @@ }, 'sources': [ 'tests/cefclient/cefclient_mac.mm', + 'tests/cefclient/client_handler_mac.mm', 'tests/cefclient/resource_util_mac.mm', ], }], @@ -310,6 +316,7 @@ ], 'sources': [ 'include/cef.h', + 'include/cef_build.h', 'include/cef_capi.h', 'include/cef_export.h', 'include/cef_nplugin.h', @@ -357,19 +364,43 @@ 'libcef_dll/cpptoc/xml_reader_cpptoc.h', 'libcef_dll/cpptoc/zip_reader_cpptoc.cc', 'libcef_dll/cpptoc/zip_reader_cpptoc.h', + 'libcef_dll/ctocpp/client_ctocpp.cc', + 'libcef_dll/ctocpp/client_ctocpp.h', 'libcef_dll/ctocpp/cookie_visitor_ctocpp.cc', 'libcef_dll/ctocpp/cookie_visitor_ctocpp.h', 'libcef_dll/ctocpp/ctocpp.h', + 'libcef_dll/ctocpp/display_handler_ctocpp.cc', + 'libcef_dll/ctocpp/display_handler_ctocpp.h', 'libcef_dll/ctocpp/domevent_listener_ctocpp.cc', 'libcef_dll/ctocpp/domevent_listener_ctocpp.h', 'libcef_dll/ctocpp/domvisitor_ctocpp.cc', 'libcef_dll/ctocpp/domvisitor_ctocpp.h', 'libcef_dll/ctocpp/download_handler_ctocpp.cc', 'libcef_dll/ctocpp/download_handler_ctocpp.h', - 'libcef_dll/ctocpp/handler_ctocpp.cc', - 'libcef_dll/ctocpp/handler_ctocpp.h', + 'libcef_dll/ctocpp/find_handler_ctocpp.cc', + 'libcef_dll/ctocpp/find_handler_ctocpp.h', + 'libcef_dll/ctocpp/focus_handler_ctocpp.cc', + 'libcef_dll/ctocpp/focus_handler_ctocpp.h', + 'libcef_dll/ctocpp/jsbinding_handler_ctocpp.cc', + 'libcef_dll/ctocpp/jsbinding_handler_ctocpp.h', + 'libcef_dll/ctocpp/jsdialog_handler_ctocpp.cc', + 'libcef_dll/ctocpp/jsdialog_handler_ctocpp.h', + 'libcef_dll/ctocpp/keyboard_handler_ctocpp.cc', + 'libcef_dll/ctocpp/keyboard_handler_ctocpp.h', + 'libcef_dll/ctocpp/life_span_handler_ctocpp.cc', + 'libcef_dll/ctocpp/life_span_handler_ctocpp.h', + 'libcef_dll/ctocpp/load_handler_ctocpp.cc', + 'libcef_dll/ctocpp/load_handler_ctocpp.h', + 'libcef_dll/ctocpp/menu_handler_ctocpp.cc', + 'libcef_dll/ctocpp/menu_handler_ctocpp.h', + 'libcef_dll/ctocpp/print_handler_ctocpp.cc', + 'libcef_dll/ctocpp/print_handler_ctocpp.h', 'libcef_dll/ctocpp/read_handler_ctocpp.cc', 'libcef_dll/ctocpp/read_handler_ctocpp.h', + 'libcef_dll/ctocpp/render_handler_ctocpp.cc', + 'libcef_dll/ctocpp/render_handler_ctocpp.h', + 'libcef_dll/ctocpp/request_handler_ctocpp.cc', + 'libcef_dll/ctocpp/request_handler_ctocpp.h', 'libcef_dll/ctocpp/scheme_handler_ctocpp.cc', 'libcef_dll/ctocpp/scheme_handler_ctocpp.h', 'libcef_dll/ctocpp/scheme_handler_factory_ctocpp.cc', @@ -434,19 +465,43 @@ 'sources': [ 'include/cef_wrapper.h', 'libcef_dll/cef_logging.h', + 'libcef_dll/cpptoc/client_cpptoc.cc', + 'libcef_dll/cpptoc/client_cpptoc.h', 'libcef_dll/cpptoc/cookie_visitor_cpptoc.cc', 'libcef_dll/cpptoc/cookie_visitor_cpptoc.h', 'libcef_dll/cpptoc/cpptoc.h', + 'libcef_dll/cpptoc/display_handler_cpptoc.cc', + 'libcef_dll/cpptoc/display_handler_cpptoc.h', 'libcef_dll/cpptoc/domevent_listener_cpptoc.cc', 'libcef_dll/cpptoc/domevent_listener_cpptoc.h', 'libcef_dll/cpptoc/domvisitor_cpptoc.cc', 'libcef_dll/cpptoc/domvisitor_cpptoc.h', 'libcef_dll/cpptoc/download_handler_cpptoc.cc', 'libcef_dll/cpptoc/download_handler_cpptoc.h', - 'libcef_dll/cpptoc/handler_cpptoc.cc', - 'libcef_dll/cpptoc/handler_cpptoc.h', + 'libcef_dll/cpptoc/find_handler_cpptoc.cc', + 'libcef_dll/cpptoc/find_handler_cpptoc.h', + 'libcef_dll/cpptoc/focus_handler_cpptoc.cc', + 'libcef_dll/cpptoc/focus_handler_cpptoc.h', + 'libcef_dll/cpptoc/jsbinding_handler_cpptoc.cc', + 'libcef_dll/cpptoc/jsbinding_handler_cpptoc.h', + 'libcef_dll/cpptoc/jsdialog_handler_cpptoc.cc', + 'libcef_dll/cpptoc/jsdialog_handler_cpptoc.h', + 'libcef_dll/cpptoc/keyboard_handler_cpptoc.cc', + 'libcef_dll/cpptoc/keyboard_handler_cpptoc.h', + 'libcef_dll/cpptoc/life_span_handler_cpptoc.cc', + 'libcef_dll/cpptoc/life_span_handler_cpptoc.h', + 'libcef_dll/cpptoc/load_handler_cpptoc.cc', + 'libcef_dll/cpptoc/load_handler_cpptoc.h', + 'libcef_dll/cpptoc/menu_handler_cpptoc.cc', + 'libcef_dll/cpptoc/menu_handler_cpptoc.h', + 'libcef_dll/cpptoc/print_handler_cpptoc.cc', + 'libcef_dll/cpptoc/print_handler_cpptoc.h', 'libcef_dll/cpptoc/read_handler_cpptoc.cc', 'libcef_dll/cpptoc/read_handler_cpptoc.h', + 'libcef_dll/cpptoc/render_handler_cpptoc.cc', + 'libcef_dll/cpptoc/render_handler_cpptoc.h', + 'libcef_dll/cpptoc/request_handler_cpptoc.cc', + 'libcef_dll/cpptoc/request_handler_cpptoc.h', 'libcef_dll/cpptoc/scheme_handler_cpptoc.cc', 'libcef_dll/cpptoc/scheme_handler_cpptoc.h', 'libcef_dll/cpptoc/scheme_handler_factory_cpptoc.cc', @@ -553,6 +608,7 @@ ], 'sources': [ 'include/cef.h', + 'include/cef_build.h', 'include/cef_export.h', 'include/cef_nplugin.h', 'include/cef_ptr.h', diff --git a/include/cef.h b/include/cef.h index 8a1504ceb..2b9bbe2d2 100644 --- a/include/cef.h +++ b/include/cef.h @@ -1,4 +1,4 @@ -// Copyright (c) 2008-2009 Marshall A. Greenblatt. All rights reserved. +// Copyright (c) 2011 Marshall A. Greenblatt. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -41,10 +41,21 @@ #include #include #include +#include "cef_build.h" #include "cef_ptr.h" #include "cef_types_wrappers.h" +// Bring in platform-specific definitions. +#if defined(OS_WIN) +#include "cef_win.h" +#elif defined(OS_MACOSX) +#include "cef_mac.h" +#elif defined(OS_LINUX) +#include "cef_linux.h" +#endif + class CefBrowser; +class CefClient; class CefCookieVisitor; class CefDOMDocument; class CefDOMEvent; @@ -53,7 +64,6 @@ class CefDOMNode; class CefDOMVisitor; class CefDownloadHandler; class CefFrame; -class CefHandler; class CefPostData; class CefPostDataElement; class CefRequest; @@ -74,8 +84,7 @@ class CefWebURLRequestClient; // CEF when the application is started. A return value of true indicates that // it succeeded and false indicates that it failed. /*--cef()--*/ -bool CefInitialize(const CefSettings& settings, - const CefBrowserSettings& browser_defaults); +bool CefInitialize(const CefSettings& settings); // This function should be called on the main application thread to shut down // CEF before the application exits. @@ -266,8 +275,8 @@ bool CefSetCookie(const CefString& url, const CefCookie& cookie); bool CefDeleteCookies(const CefString& url, const CefString& cookie_name); -// Interface defining the the reference count implementation methods. All -// framework classes must implement the CefBase class. +// Interface defining the reference count implementation methods. All framework +// classes must extend the CefBase class. class CefBase { public: @@ -288,99 +297,67 @@ public: }; -// Bring in platform-specific definitions. -#if defined(_WIN32) -#include "cef_win.h" -#elif defined(__APPLE__) -#include "cef_mac.h" -#elif defined(__linux__) -#include "cef_linux.h" -#endif - - -// Template that provides atomic implementations of AddRef() and Release() -// along with Lock() and Unlock() methods to protect critical sections of -// code from simultaneous access by multiple threads. -// -// The below example demonstrates how to use the CefThreadSafeBase template. -// -// class MyHandler : public CefThreadSafeBase -// { -// CefString m_title; -// -// virtual RetVal HandleTitleChange(const CefString& title) -// { -// Lock(); // Begin protecting code -// m_title = title; -// Unlock(); // Done protecting code -// return RV_HANDLED; -// } -// ... -// } -// -template -class CefThreadSafeBase : public ClassName +// Class that implements atomic reference counting. +class CefRefCount { public: - CefThreadSafeBase() - { - m_dwRef = 0L; - } - virtual ~CefThreadSafeBase() - { - } - + CefRefCount() : refct_(0) {} + // Atomic reference increment. - virtual int AddRef() - { - return CefAtomicIncrement(&m_dwRef); + int AddRef() { + return CefAtomicIncrement(&refct_); } - // Atomic reference decrement. Delete this object when no references remain. - virtual int Release() - { - int retval = CefAtomicDecrement(&m_dwRef); - if(retval == 0) - delete this; - return retval; + // Atomic reference decrement. Delete the object when no references remain. + int Release() { + return CefAtomicDecrement(&refct_); } // Return the current number of references. - virtual int GetRefCt() { return m_dwRef; } + int GetRefCt() { return refct_; } - // Use the Lock() and Unlock() methods to protect a section of code from - // simultaneous access by multiple threads. - void Lock() { m_critsec.Lock(); } - void Unlock() { m_critsec.Unlock(); } - - // A helper class that acquires the lock for the given CefThreadSafeBase while - // the CefAutoLock is in scope. - class AutoLock - { - public: - AutoLock(CefThreadSafeBase* base) : base_(base) - { - base_->Lock(); - } - ~AutoLock() - { - base_->Unlock(); - } - - private: - CefThreadSafeBase* base_; - }; - -protected: - long m_dwRef; - CefCriticalSection m_critsec; +private: + long refct_; }; +// Macro that provides a reference counting implementation for classes extending +// CefBase. +#define IMPLEMENT_REFCOUNTING(ClassName) \ + public: \ + int AddRef() { return refct_.AddRef(); } \ + int Release() { \ + int retval = refct_.Release(); \ + if(retval == 0) \ + delete this; \ + return retval; \ + } \ + int GetRefCt() { return refct_.GetRefCt(); } \ + private: \ + CefRefCount refct_; + +// Macro that provides a locking implementation. Use the Lock() and Unlock() +// methods to protect a section of code from simultaneous access by multiple +// threads. The AutoLock class is a helper that will hold the lock while in +// scope. +#define IMPLEMENT_LOCKING(ClassName) \ + public: \ + class AutoLock { \ + public: \ + AutoLock(ClassName* base) : base_(base) { base_->Lock(); } \ + ~AutoLock() { base_->Unlock(); } \ + private: \ + ClassName* base_; \ + }; \ + void Lock() { critsec_.Lock(); } \ + void Unlock() { critsec_.Unlock(); } \ + private: \ + CefCriticalSection critsec_; + // Implement this interface for task execution. The methods of this class may // be called on any thread. /*--cef(source=client)--*/ -class CefTask : public CefBase +class CefTask : public virtual CefBase { public: // Method that will be executed. |threadId| is the thread executing the call. @@ -392,7 +369,7 @@ public: // Interface to implement for visiting cookie values. The methods of this class // will always be called on the IO thread. /*--cef(source=client)--*/ -class CefCookieVisitor : public CefBase +class CefCookieVisitor : public virtual CefBase { public: // Method that will be called once for each cookie. |count| is the 0-based @@ -409,7 +386,7 @@ public: // Class used to represent a browser window. The methods of this class may be // called on any thread unless otherwise indicated in the comments. /*--cef(source=library)--*/ -class CefBrowser : public CefBase +class CefBrowser : public virtual CefBase { public: typedef cef_key_type_t KeyType; @@ -418,21 +395,20 @@ public: // Create a new browser window using the window parameters specified by // |windowInfo|. All values will be copied internally and the actual window - // will be created on the UI thread. The |popup| parameter should be true if - // the new window is a popup window. This method call will not block. + // will be created on the UI thread. This method call will not block. /*--cef()--*/ - static bool CreateBrowser(CefWindowInfo& windowInfo, bool popup, - CefRefPtr handler, - const CefString& url); + static bool CreateBrowser(CefWindowInfo& windowInfo, + CefRefPtr client, + const CefString& url, + const CefBrowserSettings& settings); // Create a new browser window using the window parameters specified by - // |windowInfo|. The |popup| parameter should be true if the new window is a - // popup window. This method should only be called on the UI thread. + // |windowInfo|. This method should only be called on the UI thread. /*--cef()--*/ static CefRefPtr CreateBrowserSync(CefWindowInfo& windowInfo, - bool popup, - CefRefPtr handler, - const CefString& url); + CefRefPtr client, + const CefString& url, + const CefBrowserSettings& settings); // Closes this browser window. /*--cef()--*/ @@ -473,9 +449,9 @@ public: /*--cef()--*/ virtual bool IsPopup() =0; - // Returns the handler for this browser. + // Returns the client for this browser. /*--cef()--*/ - virtual CefRefPtr GetHandler() =0; + virtual CefRefPtr GetClient() =0; // Returns the main (top-level) frame for the browser window. /*--cef()--*/ @@ -598,7 +574,7 @@ public: // Class used to represent a frame in the browser window. The methods of this // class may be called on any thread unless otherwise indicated in the comments. /*--cef(source=library)--*/ -class CefFrame : public CefBase +class CefFrame : public virtual CefBase { public: // Execute undo in this frame. @@ -699,142 +675,129 @@ public: }; -// Interface that should be implemented to handle events generated by the -// browser window. The methods of this class will be called on the thread -// indicated in the method comments. +// Implement this interface to handle events related to browser life span. The +// methods of this class will be called on the UI thread. /*--cef(source=client)--*/ -class CefHandler : public CefBase +class CefLifeSpanHandler : public virtual CefBase { public: - // Define handler return value types. Returning RV_HANDLED indicates - // that the implementation completely handled the method and that no further - // processing is required. Returning RV_CONTINUE indicates that the - // implementation did not handle the method and that the default handler - // should be called. - typedef cef_retval_t RetVal; - - // Called on the UI thread before a new window is created. The |parentBrowser| - // parameter will point to the parent browser window, if any. The |popup| - // parameter will be true if the new window is a popup window, in which case - // |popupFeatures| will contain information about the style of popup window - // requested. If you create the window yourself you should populate the window - // handle member of |createInfo| and return RV_HANDLED. Otherwise, return - // RV_CONTINUE and the framework will create the window. By default, a newly - // created window will recieve the same handler as the parent window. To - // change the handler for the new window modify the object that |handler| - // points to. + // Called before a new popup window is created. The |parentBrowser| parameter + // will point to the parent browser window. The |popupFeatures| parameter will + // contain information about the style of popup window requested. Return false + // to have the framework create the new popup window based on the parameters + // in |windowInfo|. Return true to cancel creation of the popup window. By + // default, a newly created popup window will have the same client and + // settings as the parent window. To change the client for the new window + // modify the object that |client| points to. To change the settings for the + // new window modify the |settings| structure. /*--cef()--*/ - virtual RetVal HandleBeforeCreated(CefRefPtr parentBrowser, - CefWindowInfo& windowInfo, bool popup, - const CefPopupFeatures& popupFeatures, - CefRefPtr& handler, - const CefString& url, - CefBrowserSettings& settings) =0; + virtual bool OnBeforePopup(CefRefPtr parentBrowser, + const CefPopupFeatures& popupFeatures, + CefWindowInfo& windowInfo, + const CefString& url, + CefRefPtr& client, + CefBrowserSettings& settings) { return false; } - // Called on the UI thread after a new window is created. The return value is - // currently ignored. + // Called after a new window is created. /*--cef()--*/ - virtual RetVal HandleAfterCreated(CefRefPtr browser) =0; + virtual void OnAfterCreated(CefRefPtr browser) {} - // Called on the UI thread when a frame's address has changed. The return - // value is currently ignored. + // Called just before a window is closed. /*--cef()--*/ - virtual RetVal HandleAddressChange(CefRefPtr browser, - CefRefPtr frame, - const CefString& url) =0; + virtual void OnBeforeClose(CefRefPtr browser) {} +}; - // Called on the UI thread when the page title changes. The return value is - // currently ignored. + +// Implement this interface to handle events related to browser load status. The +// methods of this class will be called on the UI thread. +/*--cef(source=client)--*/ +class CefLoadHandler : public virtual CefBase +{ +public: + typedef cef_handler_errorcode_t ErrorCode; + + // Called when the browser begins loading a frame. The |frame| value will + // never be empty -- call the IsMain() method to check if this frame is the + // main frame. Multiple frames may be loading at the same time. Sub-frames may + // start or continue loading after the main frame load has ended. This method + // may not be called for a particular frame if the load request for that frame + // fails. /*--cef()--*/ - virtual RetVal HandleTitleChange(CefRefPtr browser, - const CefString& title) =0; + virtual void OnLoadStart(CefRefPtr browser, + CefRefPtr frame) {} - // Called on the UI thread when the navigation state has changed. The return - // value is currently ignored. + // Called when the browser is done loading a frame. The |frame| value will + // never be empty -- call the IsMain() method to check if this frame is the + // main frame. Multiple frames may be loading at the same time. Sub-frames may + // start or continue loading after the main frame load has ended. This method + // will always be called for all frames irrespective of whether the request + // completes successfully. /*--cef()--*/ - virtual RetVal HandleNavStateChange(CefRefPtr browser, - bool canGoBack, bool canGoForward) =0; + virtual void OnLoadEnd(CefRefPtr browser, + CefRefPtr frame, + int httpStatusCode) {} - // Various browser navigation types supported by chrome. + // Called when the browser fails to load a resource. |errorCode| is the error + // code number and |failedUrl| is the URL that failed to load. To provide + // custom error text assign the text to |errorText| and return true. + // Otherwise, return false for the default error text. See + // net\base\net_error_list.h for complete descriptions of the error codes. + /*--cef()--*/ + virtual bool OnLoadError(CefRefPtr browser, + CefRefPtr frame, + ErrorCode errorCode, + const CefString& failedUrl, + CefString& errorText) { return false; } +}; + + +// Implement this interface to handle events related to browser requests. The +// methods of this class will be called on the thread indicated. +/*--cef(source=client)--*/ +class CefRequestHandler : public virtual CefBase +{ +public: typedef cef_handler_navtype_t NavType; // Called on the UI thread before browser navigation. The client has an - // opportunity to modify the |request| object if desired. Return RV_HANDLED - // to cancel navigation. + // opportunity to modify the |request| object if desired. Return true to + // cancel the navigation or false to allow the navigation to proceed. /*--cef()--*/ - virtual RetVal HandleBeforeBrowse(CefRefPtr browser, - CefRefPtr frame, - CefRefPtr request, - NavType navType, bool isRedirect) =0; - - // Called on the UI thread when the browser begins loading a frame. The - // |frame| value will never be empty -- call the IsMain() method to check if - // this frame is the main frame. Multiple frames may be loading at the same - // time. Sub-frames may start or continue loading after the main frame load - // has ended. This method may not be called for a particular frame if the load - // request for that frame fails. The return value is currently ignored. - /*--cef()--*/ - virtual RetVal HandleLoadStart(CefRefPtr browser, - CefRefPtr frame) =0; - - // Called on the UI thread when the browser is done loading a frame. The - // |frame| value will never be empty -- call the IsMain() method to check if - // this frame is the main frame. Multiple frames may be loading at the same - // time. Sub-frames may start or continue loading after the main frame load - // has ended. This method will always be called for all frames irrespective of - // whether the request completes successfully. The return value is currently - // ignored. - /*--cef()--*/ - virtual RetVal HandleLoadEnd(CefRefPtr browser, - CefRefPtr frame, - int httpStatusCode) =0; - - // Supported error code values. See net\base\net_error_list.h for complete - // descriptions of the error codes. - typedef cef_handler_errorcode_t ErrorCode; - - // Called on the UI thread when the browser fails to load a resource. - // |errorCode| is the error code number and |failedUrl| is the URL that failed - // to load. To provide custom error text assign the text to |errorText| and - // return RV_HANDLED. Otherwise, return RV_CONTINUE for the default error - // text. - /*--cef()--*/ - virtual RetVal HandleLoadError(CefRefPtr browser, - CefRefPtr frame, - ErrorCode errorCode, - const CefString& failedUrl, - CefString& errorText) =0; + virtual bool OnBeforeBrowse(CefRefPtr browser, + CefRefPtr frame, + CefRefPtr request, + NavType navType, + bool isRedirect) { return false; } // Called on the IO thread before a resource is loaded. To allow the resource - // to load normally return RV_CONTINUE. To redirect the resource to a new url - // populate the |redirectUrl| value and return RV_CONTINUE. To specify data - // for the resource return a CefStream object in |resourceStream|, use the - // |response| object to set mime type, HTTP status code and optional header - // values, and return RV_CONTINUE. To cancel loading of the resource return - // RV_HANDLED. Any modifications to |request| will be observed. If the URL in - // |request| is changed and |redirectUrl| is also set, the URL in |request| - // will be used. + // to load normally return false. To redirect the resource to a new url + // populate the |redirectUrl| value and return false. To specify data for the + // resource return a CefStream object in |resourceStream|, use the |response| + // object to set mime type, HTTP status code and optional header values, and + // return false. To cancel loading of the resource return true. Any + // modifications to |request| will be observed. If the URL in |request| is + // changed and |redirectUrl| is also set, the URL in |request| will be used. /*--cef()--*/ - virtual RetVal HandleBeforeResourceLoad(CefRefPtr browser, - CefRefPtr request, - CefString& redirectUrl, - CefRefPtr& resourceStream, - CefRefPtr response, - int loadFlags) =0; + virtual bool OnBeforeResourceLoad(CefRefPtr browser, + CefRefPtr request, + CefString& redirectUrl, + CefRefPtr& resourceStream, + CefRefPtr response, + int loadFlags) { return false; } // Called on the IO thread to handle requests for URLs with an unknown - // protocol component. Return RV_HANDLED to indicate that the request should - // succeed because it was externally handled. Set |allow_os_execution| to true - // and return RV_CONTINUE to attempt execution via the registered OS protocol - // handler, if any. If RV_CONTINUE is returned and either |allow_os_execution| + // protocol component. Return true to indicate that the request should + // succeed because it was handled externally. Set |allowOSExecution| to true + // and return false to attempt execution via the registered OS protocol + // handler, if any. If false is returned and either |allow_os_execution| // is false or OS protocol handler execution fails then the request will fail // with an error condition. // SECURITY WARNING: YOU SHOULD USE THIS METHOD TO ENFORCE RESTRICTIONS BASED // ON SCHEME, HOST OR OTHER URL ANALYSIS BEFORE ALLOWING OS EXECUTION. /*--cef()--*/ - virtual RetVal HandleProtocolExecution(CefRefPtr browser, - const CefString& url, - bool& allow_os_execution) =0; + virtual bool OnProtocolExecution(CefRefPtr browser, + const CefString& url, + bool& allowOSExecution) { return false; } // Called on the UI thread when a server indicates via the // 'Content-Disposition' header that a response represents a file to download. @@ -842,256 +805,394 @@ public: // target file name and |contentLength| is either the value of the // 'Content-Size' header or -1 if no size was provided. Set |handler| to the // CefDownloadHandler instance that will recieve the file contents. Return - // RV_CONTINUE to download the file or RV_HANDLED to cancel the file download. + // true to download the file or false to cancel the file download. /*--cef()--*/ - virtual RetVal HandleDownloadResponse(CefRefPtr browser, - const CefString& mimeType, - const CefString& fileName, - int64 contentLength, - CefRefPtr& handler) =0; + virtual bool GetDownloadHandler(CefRefPtr browser, + const CefString& mimeType, + const CefString& fileName, + int64 contentLength, + CefRefPtr& handler) + { return false; } // Called on the IO thread when the browser needs credentials from the user. // |isProxy| indicates whether the host is a proxy server. |host| contains the // hostname and port number. Set |username| and |password| and return - // RV_HANDLED to handle the request. Return RV_CONTINUE to cancel the request. + // true to handle the request. Return false to cancel the request. /*--cef()--*/ - virtual RetVal HandleAuthenticationRequest(CefRefPtr browser, - bool isProxy, - const CefString& host, - const CefString& realm, - const CefString& scheme, - CefString& username, - CefString& password) =0; + virtual bool GetAuthCredentials(CefRefPtr browser, + bool isProxy, + const CefString& host, + const CefString& realm, + const CefString& scheme, + CefString& username, + CefString& password) { return false; } +}; - // Structure representing menu information. - typedef cef_handler_menuinfo_t MenuInfo; - // Called on the UI thread before a context menu is displayed. To cancel - // display of the default context menu return RV_HANDLED. - /*--cef()--*/ - virtual RetVal HandleBeforeMenu(CefRefPtr browser, - const MenuInfo& menuInfo) =0; - - // Supported menu ID values. - typedef cef_handler_menuid_t MenuId; - - // Called on the UI thread to optionally override the default text for a - // context menu item. |label| contains the default text and may be modified to - // substitute alternate text. The return value is currently ignored. - /*--cef()--*/ - virtual RetVal HandleGetMenuLabel(CefRefPtr browser, - MenuId menuId, CefString& label) =0; - - // Called on the UI thread when an option is selected from the default context - // menu. Return RV_HANDLED to cancel default handling of the action. - /*--cef()--*/ - virtual RetVal HandleMenuAction(CefRefPtr browser, - MenuId menuId) =0; - - // Structure representing print options. - typedef cef_print_options_t CefPrintOptions; - - // Called on the UI thread to allow customization of standard print options - // before the print dialog is displayed. |printOptions| allows specification - // of paper size, orientation and margins. Note that the specified margins may - // be adjusted if they are outside the range supported by the printer. All - // units are in inches. Return RV_CONTINUE to display the default print - // options or RV_HANDLED to display the modified |printOptions|. - /*--cef()--*/ - virtual RetVal HandlePrintOptions(CefRefPtr browser, - CefPrintOptions& printOptions) =0; - - // Called on the UI thread to format print headers and footers. |printInfo| - // contains platform-specific information about the printer context. |url| is - // the URL if the currently printing page, |title| is the title of the - // currently printing page, |currentPage| is the current page number and - // |maxPages| is the total number of pages. Six default header locations are - // provided by the implementation: top left, top center, top right, bottom - // left, bottom center and bottom right. To use one of these default locations - // just assign a string to the appropriate variable. To draw the header and - // footer yourself return RV_HANDLED. Otherwise, populate the approprate - // variables and return RV_CONTINUE. - /*--cef()--*/ - virtual RetVal HandlePrintHeaderFooter(CefRefPtr browser, - CefRefPtr frame, - CefPrintInfo& printInfo, - const CefString& url, - const CefString& title, - int currentPage, int maxPages, - CefString& topLeft, - CefString& topCenter, - CefString& topRight, - CefString& bottomLeft, - CefString& bottomCenter, - CefString& bottomRight) =0; - - // Called on the UI thread to run a JS alert message. Return RV_CONTINUE to - // display the default alert or RV_HANDLED if you displayed a custom alert. - /*--cef()--*/ - virtual RetVal HandleJSAlert(CefRefPtr browser, - CefRefPtr frame, - const CefString& message) =0; - - // Called on the UI thread to run a JS confirm request. Return RV_CONTINUE to - // display the default alert or RV_HANDLED if you displayed a custom alert. If - // you handled the alert set |retval| to true if the user accepted the - // confirmation. - /*--cef()--*/ - virtual RetVal HandleJSConfirm(CefRefPtr browser, - CefRefPtr frame, - const CefString& message, bool& retval) =0; - - // Called on the UI thread to run a JS prompt request. Return RV_CONTINUE to - // display the default prompt or RV_HANDLED if you displayed a custom prompt. - // If you handled the prompt set |retval| to true if the user accepted the - // prompt and request and |result| to the resulting value. - /*--cef()--*/ - virtual RetVal HandleJSPrompt(CefRefPtr browser, - CefRefPtr frame, - const CefString& message, - const CefString& defaultValue, - bool& retval, - CefString& result) =0; - - // Called on the UI thread for adding values to a frame's JavaScript 'window' - // object. The return value is currently ignored. - /*--cef()--*/ - virtual RetVal HandleJSBinding(CefRefPtr browser, - CefRefPtr frame, - CefRefPtr object) =0; - - // Called on the UI thread just before a window is closed. The return value is - // currently ignored. - /*--cef()--*/ - virtual RetVal HandleBeforeWindowClose(CefRefPtr browser) =0; - - // Called on the UI thread when the browser component is about to loose focus. - // For instance, if focus was on the last HTML element and the user pressed - // the TAB key. The return value is currently ignored. - /*--cef()--*/ - virtual RetVal HandleTakeFocus(CefRefPtr browser, - bool reverse) =0; - - // Called on the UI thread when the browser component is requesting focus. - // |isWidget| will be true if the focus is requested for a child widget of the - // browser window. Return RV_CONTINUE to allow the focus to be set or - // RV_HANDLED to cancel setting the focus. - /*--cef()--*/ - virtual RetVal HandleSetFocus(CefRefPtr browser, - bool isWidget) =0; - - // Supported keyboard event types. - typedef cef_handler_keyevent_type_t KeyEventType; - - // Called on the UI thread when the browser component receives a keyboard - // event. |type| is the type of keyboard event, |code| is the windows scan- - // code for the event, |modifiers| is a set of bit-flags describing any - // pressed modifier keys and |isSystemKey| is true if Windows considers this a - // 'system key' message (see - // http://msdn.microsoft.com/en-us/library/ms646286(VS.85).aspx). Return - // RV_HANDLED if the keyboard event was handled or RV_CONTINUE to allow the - // browser component to handle the event. - /*--cef()--*/ - virtual RetVal HandleKeyEvent(CefRefPtr browser, - KeyEventType type, - int code, - int modifiers, - bool isSystemKey) =0; - - // Called on the UI thread when the browser is about to display a tooltip. - // |text| contains the text that will be displayed in the tooltip. To handle - // the display of the tooltip yourself return RV_HANDLED. Otherwise, you can - // optionally modify |text| and then return RV_CONTINUE to allow the browser - // to display the tooltip. - /*--cef()--*/ - virtual RetVal HandleTooltip(CefRefPtr browser, - CefString& text) =0; - - // Status message types. +// Implement this interface to handle events related to browser display state. +// The methods of this class will be called on the UI thread. +/*--cef(source=client)--*/ +class CefDisplayHandler : public virtual CefBase +{ +public: typedef cef_handler_statustype_t StatusType; - // Called on the UI thread when the browser has a status message. |text| - // contains the text that will be displayed in the status message and |type| - // indicates the status message type. The return value is currently ignored. + // Called when the navigation state has changed. /*--cef()--*/ - virtual RetVal HandleStatus(CefRefPtr browser, - const CefString& value, - StatusType type) =0; + virtual void OnNavStateChange(CefRefPtr browser, + bool canGoBack, + bool canGoForward) {} - // Called on the UI thread to display a console message. Return RV_HANDLED to - // stop the message from being output to the console. + // Called when a frame's address has changed. /*--cef()--*/ - virtual RetVal HandleConsoleMessage(CefRefPtr browser, - const CefString& message, - const CefString& source, int line) =0; + virtual void OnAddressChange(CefRefPtr browser, + CefRefPtr frame, + const CefString& url) {} - // Called on the UI thread to report find results returned by - // CefBrowser::Find(). |identifer| is the identifier passed to - // CefBrowser::Find(), |count| is the number of matches currently identified, - // |selectionRect| is the location of where the match was found (in window - // coordinates), |activeMatchOrdinal| is the current position in the search - // results, and |finalUpdate| is true if this is the last find notification. - // The return value is currently ignored. + // Called when the page title changes. /*--cef()--*/ - virtual RetVal HandleFindResult(CefRefPtr browser, - int identifier, int count, - const CefRect& selectionRect, - int activeMatchOrdinal, bool finalUpdate) =0; + virtual void OnTitleChange(CefRefPtr browser, + const CefString& title) {} - // Called on the UI thread to retrieve either the simulated screen rectangle - // if |screen| is true or the view rectangle if |screen| is false. The view - // rectangle is relative to the screen coordinates. This method is only called - // if window rendering has been disabled. Return RV_CONTINUE if the rectangle - // was provided. + // Called when the browser is about to display a tooltip. |text| contains the + // text that will be displayed in the tooltip. To handle the display of the + // tooltip yourself return true. Otherwise, you can optionally modify |text| + // and then return false to allow the browser to display the tooltip. /*--cef()--*/ - virtual RetVal HandleGetRect(CefRefPtr browser, bool screen, - CefRect& rect) =0; - - // Called on the UI thread retrieve the translation from view coordinates to - // actual screen coordinates. This method is only called if window rendering - // has been disabled. Return RV_CONTINUE if the screen coordinates were - // provided. + virtual bool OnTooltip(CefRefPtr browser, + CefString& text) { return false; } + + // Called when the browser receives a status message. |text| contains the text + // that will be displayed in the status message and |type| indicates the + // status message type. /*--cef()--*/ - virtual RetVal HandleGetScreenPoint(CefRefPtr browser, - int viewX, int viewY, int& screenX, - int& screenY) =0; + virtual void OnStatusMessage(CefRefPtr browser, + const CefString& value, + StatusType type) {} - // Called on the UI thread when the browser wants to show, hide, resize or - // move the popup. If |show| is true and |rect| is zero size then the popup - // should be shown. If |show| is true and |rect| is non-zero size then |rect| - // represents the popup location in view coordinates. If |show| is false - // then the popup should be hidden. This method is only called if window - // rendering has been disabled. The return value is currently ignored. + // Called to display a console message. Return true to stop the message from + // being output to the console. /*--cef()--*/ - virtual RetVal HandlePopupChange(CefRefPtr browser, bool show, - const CefRect& rect) =0; + virtual bool OnConsoleMessage(CefRefPtr browser, + const CefString& message, + const CefString& source, + int line) { return false; } +}; + +// Implement this interface to handle events related to focus. The methods of +// this class will be called on the UI thread. +/*--cef(source=client)--*/ +class CefFocusHandler : public virtual CefBase +{ +public: + // Called when the browser component is about to loose focus. For instance, if + // focus was on the last HTML element and the user pressed the TAB key. |next| + // will be true if the browser is giving focus to the next component and false + // if the browser is giving focus to the previous component. + /*--cef()--*/ + virtual void OnTakeFocus(CefRefPtr browser, + bool next) {} + + // Called when the browser component is requesting focus. |isWidget| will be + // true if the focus is requested for a child widget of the browser window. + // Return false to allow the focus to be set or true to cancel setting the + // focus. + /*--cef()--*/ + virtual bool OnSetFocus(CefRefPtr browser, + bool isWidget) { return false; } +}; + + +// Implement this interface to handle events related to keyboard input. The +// methods of this class will be called on the UI thread. +/*--cef(source=client)--*/ +class CefKeyboardHandler : public virtual CefBase +{ +public: + typedef cef_handler_keyevent_type_t KeyEventType; + + // Called when the browser component receives a keyboard event. |type| is the + // type of keyboard event, |code| is the windows scan-code for the event, + // |modifiers| is a set of bit-flags describing any pressed modifier keys and + // |isSystemKey| is true if Windows considers this a 'system key' message (see + // http://msdn.microsoft.com/en-us/library/ms646286(VS.85).aspx). Return + // true if the keyboard event was handled or false to allow the browser + // component to handle the event. + /*--cef()--*/ + virtual bool OnKeyEvent(CefRefPtr browser, + KeyEventType type, + int code, + int modifiers, + bool isSystemKey) { return false; } +}; + + +// Implement this interface to handle events related to browser context menus. +// The methods of this class will be called on the UI thread. +/*--cef(source=client)--*/ +class CefMenuHandler : public virtual CefBase +{ +public: + typedef cef_handler_menuid_t MenuId; + typedef cef_handler_menuinfo_t MenuInfo; + + // Called before a context menu is displayed. Return false to display the + // default context menu or true to cancel the display. + /*--cef()--*/ + virtual bool OnBeforeMenu(CefRefPtr browser, + const MenuInfo& menuInfo) { return false; } + + // Called to optionally override the default text for a context menu item. + // |label| contains the default text and may be modified to substitute + // alternate text. + /*--cef()--*/ + virtual void GetMenuLabel(CefRefPtr browser, + MenuId menuId, + CefString& label) {} + + // Called when an option is selected from the default context menu. Return + // false to execute the default action or true to cancel the action. + /*--cef()--*/ + virtual bool OnMenuAction(CefRefPtr browser, + MenuId menuId) { return false; } +}; + + +// Implement this interface to handle events related to printing. The methods of +// this class will be called on the UI thread. +/*--cef(source=client)--*/ +class CefPrintHandler : public virtual CefBase +{ +public: + typedef cef_print_options_t CefPrintOptions; + + // Called to allow customization of standard print options before the print + // dialog is displayed. |printOptions| allows specification of paper size, + // orientation and margins. Note that the specified margins may be adjusted if + // they are outside the range supported by the printer. All units are in + // inches. Return false to display the default print options or true to + // display the modified |printOptions|. + /*--cef()--*/ + virtual bool GetPrintOptions(CefRefPtr browser, + CefPrintOptions& printOptions) { return false; } + + // Called to format print headers and footers. |printInfo| contains platform- + // specific information about the printer context. |url| is the URL if the + // currently printing page, |title| is the title of the currently printing + // page, |currentPage| is the current page number and |maxPages| is the total + // number of pages. Six default header locations are provided by the + // implementation: top left, top center, top right, bottom left, bottom center + // and bottom right. To use one of these default locations just assign a + // string to the appropriate variable. To draw the header and footer yourself + // return true. Otherwise, populate the approprate variables and return false. + /*--cef()--*/ + 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) { return false; } +}; + + +// Implement this interface to handle events related to find results. The +// methods of this class will be called on the UI thread. +/*--cef(source=client)--*/ +class CefFindHandler : public virtual CefBase +{ +public: + // Called to report find results returned by CefBrowser::Find(). |identifer| + // is the identifier passed to CefBrowser::Find(), |count| is the number of + // matches currently identified, |selectionRect| is the location of where the + // match was found (in window coordinates), |activeMatchOrdinal| is the + // current position in the search results, and |finalUpdate| is true if this + // is the last find notification. + /*--cef()--*/ + virtual void OnFindResult(CefRefPtr browser, + int identifier, + int count, + const CefRect& selectionRect, + int activeMatchOrdinal, + bool finalUpdate) {} +}; + + +// Implement this interface to handle events related to JavaScript dialogs. The +// methods of this class will be called on the UI thread. +/*--cef(source=client)--*/ +class CefJSDialogHandler : public virtual CefBase +{ +public: + // Called to run a JavaScript alert message. Return false to display the + // default alert or true if you displayed a custom alert. + /*--cef()--*/ + virtual bool OnJSAlert(CefRefPtr browser, + CefRefPtr frame, + const CefString& message) { return false; } + + // Called to run a JavaScript confirm request. Return false to display the + // default alert or true if you displayed a custom alert. If you handled the + // alert set |retval| to true if the user accepted the confirmation. + /*--cef()--*/ + virtual bool OnJSConfirm(CefRefPtr browser, + CefRefPtr frame, + const CefString& message, + bool& retval) { return false; } + + // Called to run a JavaScript prompt request. Return false to display the + // default prompt or true if you displayed a custom prompt. If you handled + // the prompt set |retval| to true if the user accepted the prompt and request + // and |result| to the resulting value. + /*--cef()--*/ + virtual bool OnJSPrompt(CefRefPtr browser, + CefRefPtr frame, + const CefString& message, + const CefString& defaultValue, + bool& retval, + CefString& result) { return false; } +}; + + +// Implement this interface to handle JavaScript binding. The methods of this +// class will be called on the UI thread. +/*--cef(source=client)--*/ +class CefJSBindingHandler : public virtual CefBase +{ +public: + // Called for adding values to a frame's JavaScript 'window' object. + /*--cef()--*/ + virtual void OnJSBinding(CefRefPtr browser, + CefRefPtr frame, + CefRefPtr object) {} +}; + + +// Implement this interface to handle events when window rendering is disabled. +// The methods of this class will be called on the UI thread. +/*--cef(source=client)--*/ +class CefRenderHandler : public virtual CefBase +{ +public: typedef cef_paint_element_type_t PaintElementType; - // Called when an element should be painted. |type| indicates whether the - // element is the view or the popup. |buffer| contains the pixel data for the - // whole image. |dirtyRect| indicates the portion of the image that has been - // repainted. On Windows |buffer| will be width*height*4 bytes in size and - // represents a BGRA image with an upper-left origin. This method is only - // called if window rendering has been disabled. The return value is currently - // ignored. + // Called to retrieve the view rectangle which is relative to screen + // coordinates. Return true if the rectangle was provided. /*--cef()--*/ - virtual RetVal HandlePaint(CefRefPtr browser, - PaintElementType type, const CefRect& dirtyRect, - const void* buffer) =0; + virtual bool GetViewRect(CefRefPtr browser, + CefRect& rect) { return false; } - // Called when the browser window's cursor has changed. This method is only - // called if window rendering has been disabled. The return value is currently - // ignored. + // Called to retrieve the simulated screen rectangle. Return true if the + // rectangle was provided. /*--cef()--*/ - virtual RetVal HandleCursorChange(CefRefPtr browser, - CefCursorHandle cursor) =0; + virtual bool GetScreenRect(CefRefPtr browser, + CefRect& rect) { return false; } + + // Called to retrieve the translation from view coordinates to actual screen + // coordinates. Return true if the screen coordinates were provided. + /*--cef()--*/ + virtual bool GetScreenPoint(CefRefPtr browser, + int viewX, + int viewY, + int& screenX, + int& screenY) { return false; } + + // Called when the browser wants to show or hide the popup widget. The popup + // should be shown if |show| is true and hidden if |show| is false. + /*--cef()--*/ + virtual void OnPopupShow(CefRefPtr browser, + bool show) {} + + // Called when the browser wants to move or resize the popup widget. |rect| + // contains the new location and size. + /*--cef()--*/ + virtual void OnPopupSize(CefRefPtr browser, + const CefRect& rect) {} + + // Called when an element should be painted. |type| indicates whether the + // element is the view or the popup widget. |buffer| contains the pixel data + // for the whole image. |dirtyRect| indicates the portion of the image that + // has been repainted. On Windows |buffer| will be width*height*4 bytes in + // size and represents a BGRA image with an upper-left origin. + /*--cef()--*/ + virtual void OnPaint(CefRefPtr browser, + PaintElementType type, + const CefRect& dirtyRect, + const void* buffer) {} + + // Called when the browser window's cursor has changed. + /*--cef()--*/ + virtual void OnCursorChange(CefRefPtr browser, + CefCursorHandle cursor) {} }; + +// Implement this interface to provide handler implementations. +/*--cef(source=client)--*/ +class CefClient : public virtual CefBase +{ +public: + // Return the handler for browser life span events. + /*--cef()--*/ + virtual CefRefPtr GetLifeSpanHandler() { return NULL; } + + // Return the handler for browser load status events. + /*--cef()--*/ + virtual CefRefPtr GetLoadHandler() { return NULL; } + + // Return the handler for browser request events. + /*--cef()--*/ + virtual CefRefPtr GetRequestHandler() { return NULL; } + + // Return the handler for browser display state events. + /*--cef()--*/ + virtual CefRefPtr GetDisplayHandler() { return NULL; } + + // Return the handler for focus events. + /*--cef()--*/ + virtual CefRefPtr GetFocusHandler() { return NULL; } + + // Return the handler for keyboard events. + /*--cef()--*/ + virtual CefRefPtr GetKeyboardHandler() { return NULL; } + + // Return the handler for context menu events. + /*--cef()--*/ + virtual CefRefPtr GetMenuHandler() { return NULL; } + + // Return the handler for printing events. + /*--cef()--*/ + virtual CefRefPtr GetPrintHandler() { return NULL; } + + // Return the handler for find result events. + /*--cef()--*/ + virtual CefRefPtr GetFindHandler() { return NULL; } + + // Return the handler for JavaScript dialog events. + /*--cef()--*/ + virtual CefRefPtr GetJSDialogHandler() { return NULL; } + + // Return the handler for JavaScript binding events. + /*--cef()--*/ + virtual CefRefPtr GetJSBindingHandler() { return NULL; } + + // Return the handler for off-screen rendering events. + /*--cef()--*/ + virtual CefRefPtr GetRenderHandler() { return NULL; } +}; + + // Class used to represent a web request. The methods of this class may be // called on any thread. /*--cef(source=library)--*/ -class CefRequest : public CefBase +class CefRequest : public virtual CefBase { public: typedef std::map HeaderMap; @@ -1151,7 +1252,7 @@ public: // Class used to represent post data for a web request. The methods of this // class may be called on any thread. /*--cef(source=library)--*/ -class CefPostData : public CefBase +class CefPostData : public virtual CefBase { public: typedef std::vector > ElementVector; @@ -1186,7 +1287,7 @@ public: // Class used to represent a single element in the request post data. The // methods of this class may be called on any thread. /*--cef(source=library)--*/ -class CefPostDataElement : public CefBase +class CefPostDataElement : public virtual CefBase { public: // Post data elements may represent either bytes or files. @@ -1231,7 +1332,7 @@ public: // Class used to represent a web response. The methods of this class may be // called on any thread. /*--cef(source=library)--*/ -class CefResponse : public CefBase +class CefResponse : public virtual CefBase { public: typedef std::map HeaderMap; @@ -1269,7 +1370,7 @@ public: // Interface the client can implement to provide a custom stream reader. The // methods of this class may be called on any thread. /*--cef(source=client)--*/ -class CefReadHandler : public CefBase +class CefReadHandler : public virtual CefBase { public: // Read raw binary data. @@ -1294,7 +1395,7 @@ public: // Class used to read data from a stream. The methods of this class may be // called on any thread. /*--cef(source=library)--*/ -class CefStreamReader : public CefBase +class CefStreamReader : public virtual CefBase { public: // Create a new CefStreamReader object. @@ -1329,7 +1430,7 @@ public: // Interface the client can implement to provide a custom stream writer. The // methods of this class may be called on any thread. /*--cef(source=client)--*/ -class CefWriteHandler : public CefBase +class CefWriteHandler : public virtual CefBase { public: // Write raw binary data. @@ -1354,7 +1455,7 @@ public: // Class used to write data to a stream. The methods of this class may be called // on any thread. /*--cef(source=library)--*/ -class CefStreamWriter : public CefBase +class CefStreamWriter : public virtual CefBase { public: // Create a new CefStreamWriter object. @@ -1385,7 +1486,7 @@ public: // Class that encapsulates a V8 context handle. /*--cef(source=library)--*/ -class CefV8Context : public CefBase +class CefV8Context : public virtual CefBase { public: // Returns the current (top) context object in the V8 context stack. @@ -1428,7 +1529,7 @@ typedef std::vector > CefV8ValueList; // Interface that should be implemented to handle V8 function calls. The methods // of this class will always be called on the UI thread. /*--cef(source=client)--*/ -class CefV8Handler : public CefBase +class CefV8Handler : public virtual CefBase { public: // Execute with the specified argument list and return value. Return true if @@ -1447,7 +1548,7 @@ public: // identifiers are registered by calling CefV8Value::SetValue(). The methods // of this class will always be called on the UI thread. /*--cef(source=client)--*/ -class CefV8Accessor : public CefBase +class CefV8Accessor : public virtual CefBase { public: // Called to get an accessor value. |name| is the name of the property being @@ -1472,7 +1573,7 @@ public: // Class representing a V8 value. The methods of this class should only be // called on the UI thread. /*--cef(source=library)--*/ -class CefV8Value : public CefBase +class CefV8Value : public virtual CefBase { public: typedef cef_v8_accesscontrol_t AccessControl; @@ -1622,7 +1723,7 @@ public: // Class that creates CefSchemeHandler instances. The methods of this class will // always be called on the IO thread. /*--cef(source=client)--*/ -class CefSchemeHandlerFactory : public CefBase +class CefSchemeHandlerFactory : public virtual CefBase { public: // Return a new scheme handler instance to handle the request. @@ -1634,7 +1735,7 @@ public: // Class used to represent a custom scheme handler interface. The methods of // this class will always be called on the IO thread. /*--cef(source=client)--*/ -class CefSchemeHandler : public CefBase +class CefSchemeHandler : public virtual CefBase { public: // Process the request. All response generation should take place in this @@ -1670,7 +1771,7 @@ public: // Class used to handle file downloads. The methods of this class will always be // called on the UI thread. /*--cef(source=client)--*/ -class CefDownloadHandler : public CefBase +class CefDownloadHandler : public virtual CefBase { public: // A portion of the file contents have been received. This method will be @@ -1686,10 +1787,10 @@ public: // Class used to make a Web URL request. Web URL requests are not associated -// with a browser instance so no CefHandler callbacks will be executed. The +// with a browser instance so no CefClient callbacks will be executed. The // methods of this class may be called on any thread. /*--cef(source=library)--*/ -class CefWebURLRequest : public CefBase +class CefWebURLRequest : public virtual CefBase { public: typedef cef_weburlrequest_state_t RequestState; @@ -1712,7 +1813,7 @@ public: // Interface that should be implemented by the CefWebURLRequest client. The // methods of this class will always be called on the UI thread. /*--cef(source=client)--*/ -class CefWebURLRequestClient : public CefBase +class CefWebURLRequestClient : public virtual CefBase { public: typedef cef_weburlrequest_state_t RequestState; @@ -1761,7 +1862,7 @@ public: // The methods of this class should only be called on the thread that creates // the object. /*--cef(source=library)--*/ -class CefXmlReader : public CefBase +class CefXmlReader : public virtual CefBase { public: typedef cef_xml_encoding_type_t EncodingType; @@ -1925,7 +2026,7 @@ public: // The methods of this class should only be called on the thread that creates // the object. /*--cef(source=library)--*/ -class CefZipReader : public CefBase +class CefZipReader : public virtual CefBase { public: // Create a new CefZipReader object. The returned object's methods can only @@ -1996,7 +2097,7 @@ public: // Interface to implement for visiting the DOM. The methods of this class will // be called on the UI thread. /*--cef(source=client)--*/ -class CefDOMVisitor : public CefBase +class CefDOMVisitor : public virtual CefBase { public: // Method executed for visiting the DOM. The document object passed to this @@ -2012,7 +2113,7 @@ public: // Class used to represent a DOM document. The methods of this class should only // be called on the UI thread. /*--cef(source=library)--*/ -class CefDOMDocument : public CefBase +class CefDOMDocument : public virtual CefBase { public: typedef cef_dom_document_type_t Type; @@ -2087,7 +2188,7 @@ public: // Class used to represent a DOM node. The methods of this class should only be // called on the UI thread. /*--cef(source=library)--*/ -class CefDOMNode : public CefBase +class CefDOMNode : public virtual CefBase { public: typedef std::map AttributeMap; @@ -2204,7 +2305,7 @@ public: // Class used to represent a DOM event. The methods of this class should only // be called on the UI thread. /*--cef(source=library)--*/ -class CefDOMEvent : public CefBase +class CefDOMEvent : public virtual CefBase { public: typedef cef_dom_event_category_t Category; @@ -2247,7 +2348,7 @@ public: // Interface to implement for handling DOM events. The methods of this class // will be called on the UI thread. /*--cef(source=client)--*/ -class CefDOMEventListener : public CefBase +class CefDOMEventListener : public virtual CefBase { public: // Called when an event is received. The event object passed to this method diff --git a/include/cef_build.h b/include/cef_build.h new file mode 100644 index 000000000..150751c96 --- /dev/null +++ b/include/cef_build.h @@ -0,0 +1,112 @@ +// Copyright (c) 2011 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +#ifndef _CEF_BUILD_H +#define _CEF_BUILD_H + +#if defined(BUILDING_CEF_SHARED) + +#include "base/compiler_specific.h" + +#else // !BUILDING_CEF_SHARED + +#if defined(_WIN32) +#define OS_WIN 1 +#elif defined(__APPLE__) +#define OS_MACOSX 1 +#elif defined(__linux__) +#define OS_LINUX 1 +#else +#error Please add support for your platform in cef_build.h +#endif + +// For access to standard POSIXish features, use OS_POSIX instead of a +// more specific macro. +#if defined(OS_MACOSX) || defined(OS_LINUX) +#define OS_POSIX 1 +#endif + +// Compiler detection. +#if defined(__GNUC__) +#define COMPILER_GCC 1 +#elif defined(_MSC_VER) +#define COMPILER_MSVC 1 +#else +#error Please add support for your compiler in cef_build.h +#endif + +// Annotate a virtual method indicating it must be overriding a virtual +// method in the parent class. +// Use like: +// virtual void foo() OVERRIDE; +#if defined(COMPILER_MSVC) +#define OVERRIDE override +#elif defined(__clang__) +#define OVERRIDE override +#else +#define OVERRIDE +#endif + +#if defined(COMPILER_MSVC) + +// MSVC_PUSH_DISABLE_WARNING pushes |n| onto a stack of warnings to be disabled. +// The warning remains disabled until popped by MSVC_POP_WARNING. +#define MSVC_PUSH_DISABLE_WARNING(n) __pragma(warning(push)) \ + __pragma(warning(disable:n)) + +// MSVC_PUSH_WARNING_LEVEL pushes |n| as the global warning level. The level +// remains in effect until popped by MSVC_POP_WARNING(). Use 0 to disable all +// warnings. +#define MSVC_PUSH_WARNING_LEVEL(n) __pragma(warning(push, n)) + +// Pop effects of innermost MSVC_PUSH_* macro. +#define MSVC_POP_WARNING() __pragma(warning(pop)) + +// Allows |this| to be passed as an argument in constructor initializer lists. +// This uses push/pop instead of the seemingly simpler suppress feature to avoid +// having the warning be disabled for more than just |code|. +// +// Example usage: +// Foo::Foo() : x(NULL), ALLOW_THIS_IN_INITIALIZER_LIST(y(this)), z(3) {} +// +// Compiler warning C4355: 'this': used in base member initializer list: +// http://msdn.microsoft.com/en-us/library/3c594ae3(VS.80).aspx +#define ALLOW_THIS_IN_INITIALIZER_LIST(code) MSVC_PUSH_DISABLE_WARNING(4355) \ + code \ + MSVC_POP_WARNING() +#else // !COMPILER_MSVC + +#define ALLOW_THIS_IN_INITIALIZER_LIST(code) code + +#endif // !COMPILER_MSVC + +#endif // !BUILDING_CEF_SHARED + +#endif // _CEF_BUILD_H diff --git a/include/cef_capi.h b/include/cef_capi.h index a363d5e4c..e191289e5 100644 --- a/include/cef_capi.h +++ b/include/cef_capi.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 Marshall A. Greenblatt. All rights reserved. +// Copyright (c) 2011 Marshall A. Greenblatt. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -51,8 +51,7 @@ extern "C" { // This function should be called on the main application thread to initialize // CEF when the application is started. A return value of true (1) indicates // that it succeeded and false (0) indicates that it failed. -CEF_EXPORT int cef_initialize(const struct _cef_settings_t* settings, - const struct _cef_browser_settings_t* browser_defaults); +CEF_EXPORT int cef_initialize(const struct _cef_settings_t* settings); // This function should be called on the main application thread to shut down // CEF before the application exits. @@ -326,9 +325,8 @@ typedef struct _cef_browser_t // Returns true (1) if the window is a popup window. int (CEF_CALLBACK *is_popup)(struct _cef_browser_t* self); - // Returns the handler for this browser. - struct _cef_handler_t* (CEF_CALLBACK *get_handler)( - struct _cef_browser_t* self); + // Returns the client for this browser. + struct _cef_client_t* (CEF_CALLBACK *get_client)(struct _cef_browser_t* self); // Returns the main (top-level) frame for the browser window. struct _cef_frame_t* (CEF_CALLBACK *get_main_frame)( @@ -398,7 +396,7 @@ typedef struct _cef_browser_t // Invalidate the |dirtyRect| region of the view. This function is only used // when window rendering is disabled and will result in a call to - // handle_paint(). + // HandlePaint(). void (CEF_CALLBACK *invalidate)(struct _cef_browser_t* self, const cef_rect_t* dirtyRect); @@ -444,16 +442,16 @@ typedef struct _cef_browser_t // Create a new browser window using the window parameters specified by // |windowInfo|. All values will be copied internally and the actual window will -// be created on the UI thread. The |popup| parameter should be true (1) if the -// new window is a popup window. This function call will not block. -CEF_EXPORT int cef_browser_create(cef_window_info_t* windowInfo, int popup, - struct _cef_handler_t* handler, const cef_string_t* url); +// be created on the UI thread. This function call will not block. +CEF_EXPORT int cef_browser_create(cef_window_info_t* windowInfo, + struct _cef_client_t* client, const cef_string_t* url, + const struct _cef_browser_settings_t* settings); // Create a new browser window using the window parameters specified by -// |windowInfo|. The |popup| parameter should be true (1) if the new window is a -// popup window. This function should only be called on the UI thread. +// |windowInfo|. This function should only be called on the UI thread. CEF_EXPORT cef_browser_t* cef_browser_create_sync(cef_window_info_t* windowInfo, - int popup, struct _cef_handler_t* handler, const cef_string_t* url); + struct _cef_client_t* client, const cef_string_t* url, + const struct _cef_browser_settings_t* settings); // Structure used to represent a frame in the browser window. The functions of @@ -554,120 +552,121 @@ typedef struct _cef_frame_t } cef_frame_t; -// Structure that should be implemented to handle events generated by the -// browser window. The functions of this structure will be called on the thread -// indicated in the function comments. -typedef struct _cef_handler_t +// Implement this structure to handle events related to browser life span. The +// functions of this structure will be called on the UI thread. +typedef struct _cef_life_span_handler_t { // Base structure. cef_base_t base; - // Called on the UI thread before a new window is created. The |parentBrowser| - // parameter will point to the parent browser window, if any. The |popup| - // parameter will be true (1) if the new window is a popup window, in which - // case |popupFeatures| will contain information about the style of popup - // window requested. If you create the window yourself you should populate the - // window handle member of |createInfo| and return RV_HANDLED. Otherwise, - // return RV_CONTINUE and the framework will create the window. By default, a - // newly created window will recieve the same handler as the parent window. - // To change the handler for the new window modify the object that |handler| - // points to. - enum cef_retval_t (CEF_CALLBACK *handle_before_created)( - struct _cef_handler_t* self, struct _cef_browser_t* parentBrowser, - struct _cef_window_info_t* windowInfo, int popup, + // Called before a new popup window is created. The |parentBrowser| parameter + // will point to the parent browser window. The |popupFeatures| parameter will + // contain information about the style of popup window requested. Return false + // (0) to have the framework create the new popup window based on the + // parameters in |windowInfo|. Return true (1) to cancel creation of the popup + // window. By default, a newly created popup window will have the same client + // and settings as the parent window. To change the client for the new window + // modify the object that |client| points to. To change the settings for the + // new window modify the |settings| structure. + int (CEF_CALLBACK *on_before_popup)(struct _cef_life_span_handler_t* self, + struct _cef_browser_t* parentBrowser, const struct _cef_popup_features_t* popupFeatures, - struct _cef_handler_t** handler, const cef_string_t* url, + struct _cef_window_info_t* windowInfo, const cef_string_t* url, + struct _cef_client_t** client, struct _cef_browser_settings_t* settings); - // Called on the UI thread after a new window is created. The return value is - // currently ignored. - enum cef_retval_t (CEF_CALLBACK *handle_after_created)( - struct _cef_handler_t* self, struct _cef_browser_t* browser); + // Called after a new window is created. + void (CEF_CALLBACK *on_after_created)(struct _cef_life_span_handler_t* self, + struct _cef_browser_t* browser); - // Called on the UI thread when a frame's address has changed. The return - // value is currently ignored. - enum cef_retval_t (CEF_CALLBACK *handle_address_change)( - struct _cef_handler_t* self, struct _cef_browser_t* browser, - struct _cef_frame_t* frame, const cef_string_t* url); + // Called just before a window is closed. + void (CEF_CALLBACK *on_before_close)(struct _cef_life_span_handler_t* self, + struct _cef_browser_t* browser); - // Called on the UI thread when the page title changes. The return value is - // currently ignored. - enum cef_retval_t (CEF_CALLBACK *handle_title_change)( - struct _cef_handler_t* self, struct _cef_browser_t* browser, - const cef_string_t* title); +} cef_life_span_handler_t; - // Called on the UI thread when the navigation state has changed. The return - // value is currently ignored. - enum cef_retval_t (CEF_CALLBACK *handle_nav_state_change)( - struct _cef_handler_t* self, struct _cef_browser_t* browser, - int canGoBack, int canGoForward); - // Called on the UI thread before browser navigation. The client has an - // opportunity to modify the |request| object if desired. Return RV_HANDLED - // to cancel navigation. - enum cef_retval_t (CEF_CALLBACK *handle_before_browse)( - struct _cef_handler_t* self, struct _cef_browser_t* browser, - struct _cef_frame_t* frame, struct _cef_request_t* request, - enum cef_handler_navtype_t navType, int isRedirect); +// Implement this structure to handle events related to browser load status. The +// functions of this structure will be called on the UI thread. +typedef struct _cef_load_handler_t +{ + // Base structure. + cef_base_t base; - // Called on the UI thread when the browser begins loading a frame. The - // |frame| value will never be NULL -- call the is_main() function to check if - // this frame is the main frame. Multiple frames may be loading at the same - // time. Sub-frames may start or continue loading after the main frame load - // has ended. This function may not be called for a particular frame if the - // load request for that frame fails. The return value is currently ignored. - enum cef_retval_t (CEF_CALLBACK *handle_load_start)( - struct _cef_handler_t* self, struct _cef_browser_t* browser, - struct _cef_frame_t* frame); + // Called when the browser begins loading a frame. The |frame| value will + // never be NULL -- call the is_main() function to check if this frame is the + // main frame. Multiple frames may be loading at the same time. Sub-frames may + // start or continue loading after the main frame load has ended. This + // function may not be called for a particular frame if the load request for + // that frame fails. + void (CEF_CALLBACK *on_load_start)(struct _cef_load_handler_t* self, + struct _cef_browser_t* browser, struct _cef_frame_t* frame); - // Called on the UI thread when the browser is done loading a frame. The - // |frame| value will never be NULL -- call the is_main() function to check if - // this frame is the main frame. Multiple frames may be loading at the same - // time. Sub-frames may start or continue loading after the main frame load - // has ended. This function will always be called for all frames irrespective - // of whether the request completes successfully. The return value is - // currently ignored. - enum cef_retval_t (CEF_CALLBACK *handle_load_end)(struct _cef_handler_t* self, + // Called when the browser is done loading a frame. The |frame| value will + // never be NULL -- call the is_main() function to check if this frame is the + // main frame. Multiple frames may be loading at the same time. Sub-frames may + // start or continue loading after the main frame load has ended. This + // function will always be called for all frames irrespective of whether the + // request completes successfully. + void (CEF_CALLBACK *on_load_end)(struct _cef_load_handler_t* self, struct _cef_browser_t* browser, struct _cef_frame_t* frame, int httpStatusCode); - // Called on the UI thread when the browser fails to load a resource. - // |errorCode| is the error code number and |failedUrl| is the URL that failed - // to load. To provide custom error text assign the text to |errorText| and - // return RV_HANDLED. Otherwise, return RV_CONTINUE for the default error - // text. - enum cef_retval_t (CEF_CALLBACK *handle_load_error)( - struct _cef_handler_t* self, struct _cef_browser_t* browser, - struct _cef_frame_t* frame, enum cef_handler_errorcode_t errorCode, - const cef_string_t* failedUrl, cef_string_t* errorText); + // Called when the browser fails to load a resource. |errorCode| is the error + // code number and |failedUrl| is the URL that failed to load. To provide + // custom error text assign the text to |errorText| and return true (1). + // Otherwise, return false (0) for the default error text. See + // net\base\net_error_list.h for complete descriptions of the error codes. + int (CEF_CALLBACK *on_load_error)(struct _cef_load_handler_t* self, + struct _cef_browser_t* browser, struct _cef_frame_t* frame, + enum cef_handler_errorcode_t errorCode, const cef_string_t* failedUrl, + cef_string_t* errorText); + +} cef_load_handler_t; + + +// Implement this structure to handle events related to browser requests. The +// functions of this structure will be called on the thread indicated. +typedef struct _cef_request_handler_t +{ + // Base structure. + cef_base_t base; + + // Called on the UI thread before browser navigation. The client has an + // opportunity to modify the |request| object if desired. Return true (1) to + // cancel the navigation or false (0) to allow the navigation to proceed. + int (CEF_CALLBACK *on_before_browse)(struct _cef_request_handler_t* self, + struct _cef_browser_t* browser, struct _cef_frame_t* frame, + struct _cef_request_t* request, enum cef_handler_navtype_t navType, + int isRedirect); // Called on the IO thread before a resource is loaded. To allow the resource - // to load normally return RV_CONTINUE. To redirect the resource to a new url - // populate the |redirectUrl| value and return RV_CONTINUE. To specify data - // for the resource return a CefStream object in |resourceStream|, use the + // to load normally return false (0). To redirect the resource to a new url + // populate the |redirectUrl| value and return false (0). To specify data for + // the resource return a CefStream object in |resourceStream|, use the // |response| object to set mime type, HTTP status code and optional header - // values, and return RV_CONTINUE. To cancel loading of the resource return - // RV_HANDLED. Any modifications to |request| will be observed. If the URL in + // values, and return false (0). To cancel loading of the resource return true + // (1). Any modifications to |request| will be observed. If the URL in // |request| is changed and |redirectUrl| is also set, the URL in |request| // will be used. - enum cef_retval_t (CEF_CALLBACK *handle_before_resource_load)( - struct _cef_handler_t* self, struct _cef_browser_t* browser, + int (CEF_CALLBACK *on_before_resource_load)( + struct _cef_request_handler_t* self, struct _cef_browser_t* browser, struct _cef_request_t* request, cef_string_t* redirectUrl, struct _cef_stream_reader_t** resourceStream, struct _cef_response_t* response, int loadFlags); // Called on the IO thread to handle requests for URLs with an unknown - // protocol component. Return RV_HANDLED to indicate that the request should - // succeed because it was externally handled. Set |allow_os_execution| to true - // (1) and return RV_CONTINUE to attempt execution via the registered OS - // protocol handler, if any. If RV_CONTINUE is returned and either + // protocol component. Return true (1) to indicate that the request should + // succeed because it was handled externally. Set |allowOSExecution| to true + // (1) and return false (0) to attempt execution via the registered OS + // protocol handler, if any. If false (0) is returned and either // |allow_os_execution| is false (0) or OS protocol handler execution fails // then the request will fail with an error condition. SECURITY WARNING: YOU // SHOULD USE THIS METHOD TO ENFORCE RESTRICTIONS BASED ON SCHEME, HOST OR // OTHER URL ANALYSIS BEFORE ALLOWING OS EXECUTION. - enum cef_retval_t (CEF_CALLBACK *handle_protocol_execution)( - struct _cef_handler_t* self, struct _cef_browser_t* browser, - const cef_string_t* url, int* allow_os_execution); + int (CEF_CALLBACK *on_protocol_execution)(struct _cef_request_handler_t* self, + struct _cef_browser_t* browser, const cef_string_t* url, + int* allowOSExecution); // Called on the UI thread when a server indicates via the 'Content- // Disposition' header that a response represents a file to download. @@ -675,209 +674,351 @@ typedef struct _cef_handler_t // target file name and |contentLength| is either the value of the 'Content- // Size' header or -1 if no size was provided. Set |handler| to the // cef_download_handler_t instance that will recieve the file contents. Return - // RV_CONTINUE to download the file or RV_HANDLED to cancel the file download. - enum cef_retval_t (CEF_CALLBACK *handle_download_response)( - struct _cef_handler_t* self, struct _cef_browser_t* browser, - const cef_string_t* mimeType, const cef_string_t* fileName, - int64 contentLength, struct _cef_download_handler_t** handler); + // true (1) to download the file or false (0) to cancel the file download. + int (CEF_CALLBACK *get_download_handler)(struct _cef_request_handler_t* self, + struct _cef_browser_t* browser, const cef_string_t* mimeType, + const cef_string_t* fileName, int64 contentLength, + struct _cef_download_handler_t** handler); // Called on the IO thread when the browser needs credentials from the user. // |isProxy| indicates whether the host is a proxy server. |host| contains the - // hostname and port number. Set |username| and |password| and return - // RV_HANDLED to handle the request. Return RV_CONTINUE to cancel the request. - enum cef_retval_t (CEF_CALLBACK *handle_authentication_request)( - struct _cef_handler_t* self, struct _cef_browser_t* browser, int isProxy, - const cef_string_t* host, const cef_string_t* realm, - const cef_string_t* scheme, cef_string_t* username, - cef_string_t* password); + // hostname and port number. Set |username| and |password| and return true (1) + // to handle the request. Return false (0) to cancel the request. + int (CEF_CALLBACK *get_auth_credentials)(struct _cef_request_handler_t* self, + struct _cef_browser_t* browser, int isProxy, const cef_string_t* host, + const cef_string_t* realm, const cef_string_t* scheme, + cef_string_t* username, cef_string_t* password); - // Called on the UI thread before a context menu is displayed. To cancel - // display of the default context menu return RV_HANDLED. - enum cef_retval_t (CEF_CALLBACK *handle_before_menu)( - struct _cef_handler_t* self, struct _cef_browser_t* browser, +} cef_request_handler_t; + + +// Implement this structure to handle events related to browser display state. +// The functions of this structure will be called on the UI thread. +typedef struct _cef_display_handler_t +{ + // Base structure. + cef_base_t base; + + // Called when the navigation state has changed. + void (CEF_CALLBACK *on_nav_state_change)(struct _cef_display_handler_t* self, + struct _cef_browser_t* browser, int canGoBack, int canGoForward); + + // Called when a frame's address has changed. + void (CEF_CALLBACK *on_address_change)(struct _cef_display_handler_t* self, + struct _cef_browser_t* browser, struct _cef_frame_t* frame, + const cef_string_t* url); + + // Called when the page title changes. + void (CEF_CALLBACK *on_title_change)(struct _cef_display_handler_t* self, + struct _cef_browser_t* browser, const cef_string_t* title); + + // Called when the browser is about to display a tooltip. |text| contains the + // text that will be displayed in the tooltip. To handle the display of the + // tooltip yourself return true (1). Otherwise, you can optionally modify + // |text| and then return false (0) to allow the browser to display the + // tooltip. + int (CEF_CALLBACK *on_tooltip)(struct _cef_display_handler_t* self, + struct _cef_browser_t* browser, cef_string_t* text); + + // Called when the browser receives a status message. |text| contains the text + // that will be displayed in the status message and |type| indicates the + // status message type. + void (CEF_CALLBACK *on_status_message)(struct _cef_display_handler_t* self, + struct _cef_browser_t* browser, const cef_string_t* value, + enum cef_handler_statustype_t type); + + // Called to display a console message. Return true (1) to stop the message + // from being output to the console. + int (CEF_CALLBACK *on_console_message)(struct _cef_display_handler_t* self, + struct _cef_browser_t* browser, const cef_string_t* message, + const cef_string_t* source, int line); + +} cef_display_handler_t; + + +// Implement this structure to handle events related to focus. The functions of +// this structure will be called on the UI thread. +typedef struct _cef_focus_handler_t +{ + // Base structure. + cef_base_t base; + + // Called when the browser component is about to loose focus. For instance, if + // focus was on the last HTML element and the user pressed the TAB key. |next| + // will be true (1) if the browser is giving focus to the next component and + // false (0) if the browser is giving focus to the previous component. + void (CEF_CALLBACK *on_take_focus)(struct _cef_focus_handler_t* self, + struct _cef_browser_t* browser, int next); + + // Called when the browser component is requesting focus. |isWidget| will be + // true (1) if the focus is requested for a child widget of the browser + // window. Return false (0) to allow the focus to be set or true (1) to cancel + // setting the focus. + int (CEF_CALLBACK *on_set_focus)(struct _cef_focus_handler_t* self, + struct _cef_browser_t* browser, int isWidget); + +} cef_focus_handler_t; + + +// Implement this structure to handle events related to keyboard input. The +// functions of this structure will be called on the UI thread. +typedef struct _cef_keyboard_handler_t +{ + // Base structure. + cef_base_t base; + + // Called when the browser component receives a keyboard event. |type| is the + // type of keyboard event, |code| is the windows scan-code for the event, + // |modifiers| is a set of bit-flags describing any pressed modifier keys and + // |isSystemKey| is true (1) if Windows considers this a 'system key' message + // (see http://msdn.microsoft.com/en-us/library/ms646286(VS.85).aspx). Return + // true (1) if the keyboard event was handled or false (0) to allow the + // browser component to handle the event. + int (CEF_CALLBACK *on_key_event)(struct _cef_keyboard_handler_t* self, + struct _cef_browser_t* browser, enum cef_handler_keyevent_type_t type, + int code, int modifiers, int isSystemKey); + +} cef_keyboard_handler_t; + + +// Implement this structure to handle events related to browser context menus. +// The functions of this structure will be called on the UI thread. +typedef struct _cef_menu_handler_t +{ + // Base structure. + cef_base_t base; + + // Called before a context menu is displayed. Return false (0) to display the + // default context menu or true (1) to cancel the display. + int (CEF_CALLBACK *on_before_menu)(struct _cef_menu_handler_t* self, + struct _cef_browser_t* browser, const struct _cef_handler_menuinfo_t* menuInfo); - // Called on the UI thread to optionally override the default text for a - // context menu item. |label| contains the default text and may be modified to - // substitute alternate text. The return value is currently ignored. - enum cef_retval_t (CEF_CALLBACK *handle_get_menu_label)( - struct _cef_handler_t* self, struct _cef_browser_t* browser, - enum cef_handler_menuid_t menuId, cef_string_t* label); + // Called to optionally override the default text for a context menu item. + // |label| contains the default text and may be modified to substitute + // alternate text. + void (CEF_CALLBACK *get_menu_label)(struct _cef_menu_handler_t* self, + struct _cef_browser_t* browser, enum cef_handler_menuid_t menuId, + cef_string_t* label); - // Called on the UI thread when an option is selected from the default context - // menu. Return RV_HANDLED to cancel default handling of the action. - enum cef_retval_t (CEF_CALLBACK *handle_menu_action)( - struct _cef_handler_t* self, struct _cef_browser_t* browser, - enum cef_handler_menuid_t menuId); + // Called when an option is selected from the default context menu. Return + // false (0) to execute the default action or true (1) to cancel the action. + int (CEF_CALLBACK *on_menu_action)(struct _cef_menu_handler_t* self, + struct _cef_browser_t* browser, enum cef_handler_menuid_t menuId); - // Called on the UI thread to allow customization of standard print options - // before the print dialog is displayed. |printOptions| allows specification - // of paper size, orientation and margins. Note that the specified margins may - // be adjusted if they are outside the range supported by the printer. All - // units are in inches. Return RV_CONTINUE to display the default print - // options or RV_HANDLED to display the modified |printOptions|. - enum cef_retval_t (CEF_CALLBACK *handle_print_options)( - struct _cef_handler_t* self, struct _cef_browser_t* browser, +} cef_menu_handler_t; + + +// Implement this structure to handle events related to printing. The functions +// of this structure will be called on the UI thread. +typedef struct _cef_print_handler_t +{ + // Base structure. + cef_base_t base; + + // Called to allow customization of standard print options before the print + // dialog is displayed. |printOptions| allows specification of paper size, + // orientation and margins. Note that the specified margins may be adjusted if + // they are outside the range supported by the printer. All units are in + // inches. Return false (0) to display the default print options or true (1) + // to display the modified |printOptions|. + int (CEF_CALLBACK *get_print_options)(struct _cef_print_handler_t* self, + struct _cef_browser_t* browser, struct _cef_print_options_t* printOptions); - // Called on the UI thread to format print headers and footers. |printInfo| - // contains platform-specific information about the printer context. |url| is - // the URL if the currently printing page, |title| is the title of the - // currently printing page, |currentPage| is the current page number and - // |maxPages| is the total number of pages. Six default header locations are - // provided by the implementation: top left, top center, top right, bottom - // left, bottom center and bottom right. To use one of these default locations - // just assign a string to the appropriate variable. To draw the header and - // footer yourself return RV_HANDLED. Otherwise, populate the approprate - // variables and return RV_CONTINUE. - enum cef_retval_t (CEF_CALLBACK *handle_print_header_footer)( - struct _cef_handler_t* self, struct _cef_browser_t* browser, - struct _cef_frame_t* frame, struct _cef_print_info_t* printInfo, - const cef_string_t* url, const cef_string_t* title, int currentPage, - int maxPages, cef_string_t* topLeft, cef_string_t* topCenter, - cef_string_t* topRight, cef_string_t* bottomLeft, - cef_string_t* bottomCenter, cef_string_t* bottomRight); + // Called to format print headers and footers. |printInfo| contains platform- + // specific information about the printer context. |url| is the URL if the + // currently printing page, |title| is the title of the currently printing + // page, |currentPage| is the current page number and |maxPages| is the total + // number of pages. Six default header locations are provided by the + // implementation: top left, top center, top right, bottom left, bottom center + // and bottom right. To use one of these default locations just assign a + // string to the appropriate variable. To draw the header and footer yourself + // return true (1). Otherwise, populate the approprate variables and return + // false (0). + int (CEF_CALLBACK *get_print_header_footer)(struct _cef_print_handler_t* self, + struct _cef_browser_t* browser, struct _cef_frame_t* frame, + const struct _cef_print_info_t* printInfo, const cef_string_t* url, + const cef_string_t* title, int currentPage, int maxPages, + cef_string_t* topLeft, cef_string_t* topCenter, cef_string_t* topRight, + cef_string_t* bottomLeft, cef_string_t* bottomCenter, + cef_string_t* bottomRight); - // Called on the UI thread to run a JS alert message. Return RV_CONTINUE to - // display the default alert or RV_HANDLED if you displayed a custom alert. - enum cef_retval_t (CEF_CALLBACK *handle_jsalert)(struct _cef_handler_t* self, +} cef_print_handler_t; + + +// Implement this structure to handle events related to find results. The +// functions of this structure will be called on the UI thread. +typedef struct _cef_find_handler_t +{ + // Base structure. + cef_base_t base; + + // Called to report find results returned by cef_browser_t::find(). + // |identifer| is the identifier passed to cef_browser_t::find(), |count| is + // the number of matches currently identified, |selectionRect| is the location + // of where the match was found (in window coordinates), |activeMatchOrdinal| + // is the current position in the search results, and |finalUpdate| is true + // (1) if this is the last find notification. + void (CEF_CALLBACK *on_find_result)(struct _cef_find_handler_t* self, + struct _cef_browser_t* browser, int identifier, int count, + const cef_rect_t* selectionRect, int activeMatchOrdinal, + int finalUpdate); + +} cef_find_handler_t; + + +// Implement this structure to handle events related to JavaScript dialogs. The +// functions of this structure will be called on the UI thread. +typedef struct _cef_jsdialog_handler_t +{ + // Base structure. + cef_base_t base; + + // Called to run a JavaScript alert message. Return false (0) to display the + // default alert or true (1) if you displayed a custom alert. + int (CEF_CALLBACK *on_jsalert)(struct _cef_jsdialog_handler_t* self, struct _cef_browser_t* browser, struct _cef_frame_t* frame, const cef_string_t* message); - // Called on the UI thread to run a JS confirm request. Return RV_CONTINUE to - // display the default alert or RV_HANDLED if you displayed a custom alert. If - // you handled the alert set |retval| to true (1) if the user accepted the - // confirmation. - enum cef_retval_t (CEF_CALLBACK *handle_jsconfirm)( - struct _cef_handler_t* self, struct _cef_browser_t* browser, - struct _cef_frame_t* frame, const cef_string_t* message, int* retval); + // Called to run a JavaScript confirm request. Return false (0) to display the + // default alert or true (1) if you displayed a custom alert. If you handled + // the alert set |retval| to true (1) if the user accepted the confirmation. + int (CEF_CALLBACK *on_jsconfirm)(struct _cef_jsdialog_handler_t* self, + struct _cef_browser_t* browser, struct _cef_frame_t* frame, + const cef_string_t* message, int* retval); - // Called on the UI thread to run a JS prompt request. Return RV_CONTINUE to - // display the default prompt or RV_HANDLED if you displayed a custom prompt. - // If you handled the prompt set |retval| to true (1) if the user accepted the - // prompt and request and |result| to the resulting value. - enum cef_retval_t (CEF_CALLBACK *handle_jsprompt)(struct _cef_handler_t* self, + // Called to run a JavaScript prompt request. Return false (0) to display the + // default prompt or true (1) if you displayed a custom prompt. If you handled + // the prompt set |retval| to true (1) if the user accepted the prompt and + // request and |result| to the resulting value. + int (CEF_CALLBACK *on_jsprompt)(struct _cef_jsdialog_handler_t* self, struct _cef_browser_t* browser, struct _cef_frame_t* frame, const cef_string_t* message, const cef_string_t* defaultValue, int* retval, cef_string_t* result); - // Called on the UI thread for adding values to a frame's JavaScript 'window' - // object. The return value is currently ignored. - enum cef_retval_t (CEF_CALLBACK *handle_jsbinding)( - struct _cef_handler_t* self, struct _cef_browser_t* browser, - struct _cef_frame_t* frame, struct _cef_v8value_t* object); +} cef_jsdialog_handler_t; - // Called on the UI thread just before a window is closed. The return value is - // currently ignored. - enum cef_retval_t (CEF_CALLBACK *handle_before_window_close)( - struct _cef_handler_t* self, struct _cef_browser_t* browser); - // Called on the UI thread when the browser component is about to loose focus. - // For instance, if focus was on the last HTML element and the user pressed - // the TAB key. The return value is currently ignored. - enum cef_retval_t (CEF_CALLBACK *handle_take_focus)( - struct _cef_handler_t* self, struct _cef_browser_t* browser, - int reverse); +// Implement this structure to handle JavaScript binding. The functions of this +// structure will be called on the UI thread. +typedef struct _cef_jsbinding_handler_t +{ + // Base structure. + cef_base_t base; - // Called on the UI thread when the browser component is requesting focus. - // |isWidget| will be true (1) if the focus is requested for a child widget of - // the browser window. Return RV_CONTINUE to allow the focus to be set or - // RV_HANDLED to cancel setting the focus. - enum cef_retval_t (CEF_CALLBACK *handle_set_focus)( - struct _cef_handler_t* self, struct _cef_browser_t* browser, - int isWidget); + // Called for adding values to a frame's JavaScript 'window' object. + void (CEF_CALLBACK *on_jsbinding)(struct _cef_jsbinding_handler_t* self, + struct _cef_browser_t* browser, struct _cef_frame_t* frame, + struct _cef_v8value_t* object); - // Called on the UI thread when the browser component receives a keyboard - // event. |type| is the type of keyboard event, |code| is the windows scan- - // code for the event, |modifiers| is a set of bit-flags describing any - // pressed modifier keys and |isSystemKey| is true (1) if Windows considers - // this a 'system key' message (see http://msdn.microsoft.com/en- - // us/library/ms646286(VS.85).aspx). Return RV_HANDLED if the keyboard event - // was handled or RV_CONTINUE to allow the browser component to handle the - // event. - enum cef_retval_t (CEF_CALLBACK *handle_key_event)( - struct _cef_handler_t* self, struct _cef_browser_t* browser, - enum cef_handler_keyevent_type_t type, int code, int modifiers, - int isSystemKey); +} cef_jsbinding_handler_t; - // Called on the UI thread when the browser is about to display a tooltip. - // |text| contains the text that will be displayed in the tooltip. To handle - // the display of the tooltip yourself return RV_HANDLED. Otherwise, you can - // optionally modify |text| and then return RV_CONTINUE to allow the browser - // to display the tooltip. - enum cef_retval_t (CEF_CALLBACK *handle_tooltip)(struct _cef_handler_t* self, - struct _cef_browser_t* browser, cef_string_t* text); - // Called on the UI thread when the browser has a status message. |text| - // contains the text that will be displayed in the status message and |type| - // indicates the status message type. The return value is currently ignored. - enum cef_retval_t (CEF_CALLBACK *handle_status)(struct _cef_handler_t* self, - struct _cef_browser_t* browser, const cef_string_t* value, - enum cef_handler_statustype_t type); +// Implement this structure to handle events when window rendering is disabled. +// The functions of this structure will be called on the UI thread. +typedef struct _cef_render_handler_t +{ + // Base structure. + cef_base_t base; - // Called on the UI thread to display a console message. Return RV_HANDLED to - // stop the message from being output to the console. - enum cef_retval_t (CEF_CALLBACK *handle_console_message)( - struct _cef_handler_t* self, struct _cef_browser_t* browser, - const cef_string_t* message, const cef_string_t* source, int line); + // Called to retrieve the view rectangle which is relative to screen + // coordinates. Return true (1) if the rectangle was provided. + int (CEF_CALLBACK *get_view_rect)(struct _cef_render_handler_t* self, + struct _cef_browser_t* browser, cef_rect_t* rect); - // Called on the UI thread to report find results returned by - // cef_browser_t::find(). |identifer| is the identifier passed to - // cef_browser_t::find(), |count| is the number of matches currently - // identified, |selectionRect| is the location of where the match was found - // (in window coordinates), |activeMatchOrdinal| is the current position in - // the search results, and |finalUpdate| is true (1) if this is the last find - // notification. The return value is currently ignored. - enum cef_retval_t (CEF_CALLBACK *handle_find_result)( - struct _cef_handler_t* self, struct _cef_browser_t* browser, - int identifier, int count, const cef_rect_t* selectionRect, - int activeMatchOrdinal, int finalUpdate); - - // Called on the UI thread to retrieve either the simulated screen rectangle - // if |screen| is true (1) or the view rectangle if |screen| is false (0). The - // view rectangle is relative to the screen coordinates. This function is only - // called if window rendering has been disabled. Return RV_CONTINUE if the + // Called to retrieve the simulated screen rectangle. Return true (1) if the // rectangle was provided. - enum cef_retval_t (CEF_CALLBACK *handle_get_rect)(struct _cef_handler_t* self, - struct _cef_browser_t* browser, int screen, cef_rect_t* rect); + int (CEF_CALLBACK *get_screen_rect)(struct _cef_render_handler_t* self, + struct _cef_browser_t* browser, cef_rect_t* rect); - // Called on the UI thread retrieve the translation from view coordinates to - // actual screen coordinates. This function is only called if window rendering - // has been disabled. Return RV_CONTINUE if the screen coordinates were - // provided. - enum cef_retval_t (CEF_CALLBACK *handle_get_screen_point)( - struct _cef_handler_t* self, struct _cef_browser_t* browser, int viewX, - int viewY, int* screenX, int* screenY); + // Called to retrieve the translation from view coordinates to actual screen + // coordinates. Return true (1) if the screen coordinates were provided. + int (CEF_CALLBACK *get_screen_point)(struct _cef_render_handler_t* self, + struct _cef_browser_t* browser, int viewX, int viewY, int* screenX, + int* screenY); - // Called on the UI thread when the browser wants to show, hide, resize or - // move the popup. If |show| is true (1) and |rect| is zero size then the - // popup should be shown. If |show| is true (1) and |rect| is non-zero size - // then |rect| represents the popup location in view coordinates. If |show| is - // false (0) then the popup should be hidden. This function is only called if - // window rendering has been disabled. The return value is currently ignored. - enum cef_retval_t (CEF_CALLBACK *handle_popup_change)( - struct _cef_handler_t* self, struct _cef_browser_t* browser, int show, - const cef_rect_t* rect); + // Called when the browser wants to show or hide the popup widget. The popup + // should be shown if |show| is true (1) and hidden if |show| is false (0). + void (CEF_CALLBACK *on_popup_show)(struct _cef_render_handler_t* self, + struct _cef_browser_t* browser, int show); + + // Called when the browser wants to move or resize the popup widget. |rect| + // contains the new location and size. + void (CEF_CALLBACK *on_popup_size)(struct _cef_render_handler_t* self, + struct _cef_browser_t* browser, const cef_rect_t* rect); // Called when an element should be painted. |type| indicates whether the - // element is the view or the popup. |buffer| contains the pixel data for the - // whole image. |dirtyRect| indicates the portion of the image that has been - // repainted. On Windows |buffer| will be width*height*4 bytes in size and - // represents a BGRA image with an upper-left origin. This function is only - // called if window rendering has been disabled. The return value is currently - // ignored. - enum cef_retval_t (CEF_CALLBACK *handle_paint)(struct _cef_handler_t* self, + // element is the view or the popup widget. |buffer| contains the pixel data + // for the whole image. |dirtyRect| indicates the portion of the image that + // has been repainted. On Windows |buffer| will be width*height*4 bytes in + // size and represents a BGRA image with an upper-left origin. + void (CEF_CALLBACK *on_paint)(struct _cef_render_handler_t* self, struct _cef_browser_t* browser, enum cef_paint_element_type_t type, const cef_rect_t* dirtyRect, const void* buffer); - // Called when the browser window's cursor has changed. This function is only - // called if window rendering has been disabled. The return value is currently - // ignored. - enum cef_retval_t (CEF_CALLBACK *handle_cursor_change)( - struct _cef_handler_t* self, struct _cef_browser_t* browser, - cef_cursor_handle_t cursor); + // Called when the browser window's cursor has changed. + void (CEF_CALLBACK *on_cursor_change)(struct _cef_render_handler_t* self, + struct _cef_browser_t* browser, cef_cursor_handle_t cursor); -} cef_handler_t; +} cef_render_handler_t; + + +// Implement this structure to provide handler implementations. +typedef struct _cef_client_t +{ + // Base structure. + cef_base_t base; + + // Return the handler for browser life span events. + struct _cef_life_span_handler_t* (CEF_CALLBACK *get_life_span_handler)( + struct _cef_client_t* self); + + // Return the handler for browser load status events. + struct _cef_load_handler_t* (CEF_CALLBACK *get_load_handler)( + struct _cef_client_t* self); + + // Return the handler for browser request events. + struct _cef_request_handler_t* (CEF_CALLBACK *get_request_handler)( + struct _cef_client_t* self); + + // Return the handler for browser display state events. + struct _cef_display_handler_t* (CEF_CALLBACK *get_display_handler)( + struct _cef_client_t* self); + + // Return the handler for focus events. + struct _cef_focus_handler_t* (CEF_CALLBACK *get_focus_handler)( + struct _cef_client_t* self); + + // Return the handler for keyboard events. + struct _cef_keyboard_handler_t* (CEF_CALLBACK *get_keyboard_handler)( + struct _cef_client_t* self); + + // Return the handler for context menu events. + struct _cef_menu_handler_t* (CEF_CALLBACK *get_menu_handler)( + struct _cef_client_t* self); + + // Return the handler for printing events. + struct _cef_print_handler_t* (CEF_CALLBACK *get_print_handler)( + struct _cef_client_t* self); + + // Return the handler for find result events. + struct _cef_find_handler_t* (CEF_CALLBACK *get_find_handler)( + struct _cef_client_t* self); + + // Return the handler for JavaScript dialog events. + struct _cef_jsdialog_handler_t* (CEF_CALLBACK *get_jsdialog_handler)( + struct _cef_client_t* self); + + // Return the handler for JavaScript binding events. + struct _cef_jsbinding_handler_t* (CEF_CALLBACK *get_jsbinding_handler)( + struct _cef_client_t* self); + + // Return the handler for off-screen rendering events. + struct _cef_render_handler_t* (CEF_CALLBACK *get_render_handler)( + struct _cef_client_t* self); + +} cef_client_t; // Structure used to represent a web request. The functions of this structure @@ -1447,7 +1588,7 @@ typedef struct _cef_download_handler_t // Structure used to make a Web URL request. Web URL requests are not associated -// with a browser instance so no cef_handler_t callbacks will be executed. The +// with a browser instance so no cef_client_t callbacks will be executed. The // functions of this structure may be called on any thread. typedef struct _cef_web_urlrequest_t { diff --git a/include/cef_export.h b/include/cef_export.h index fbaea9d7e..25d81a0eb 100644 --- a/include/cef_export.h +++ b/include/cef_export.h @@ -28,18 +28,22 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#if defined(_WIN32) -#ifdef _MSC_VER // MSVC +#include "cef_build.h" + +#if defined(COMPILER_MSVC) + #ifdef BUILDING_CEF_SHARED #define CEF_EXPORT __declspec(dllexport) #elif USING_CEF_SHARED #define CEF_EXPORT __declspec(dllimport) #else #define CEF_EXPORT -#endif // BUILDING_CEF_SHARED +#endif #define CEF_CALLBACK __stdcall -#endif // MSVC -#elif defined(__GNUC__) + +#elif defined(COMPILER_GCC) + #define CEF_EXPORT __attribute__ ((visibility("default"))) #define CEF_CALLBACK -#endif // defined(__GNUC__) + +#endif // COMPILER_GCC diff --git a/include/cef_runnable.h b/include/cef_runnable.h index 3941cd606..b0dcddc5e 100644 --- a/include/cef_runnable.h +++ b/include/cef_runnable.h @@ -130,7 +130,7 @@ struct CefRunnableMethodTraits { // CefRunnableMethod and NewCefRunnableMethod implementation ------------------ template -class CefRunnableMethod : public CefThreadSafeBase { +class CefRunnableMethod : public CefTask { public: CefRunnableMethod(T* obj, Method meth, const Params& params) : obj_(obj), meth_(meth), params_(params) { @@ -154,6 +154,8 @@ class CefRunnableMethod : public CefThreadSafeBase { Method meth_; Params params_; CefRunnableMethodTraits traits_; + + IMPLEMENT_REFCOUNTING(CefRunnableMethod); }; template @@ -241,7 +243,7 @@ inline CefRefPtr NewCefRunnableMethod(T* object, Method method, // CefRunnableFunction and NewCefRunnableFunction implementation -------------- template -class CefRunnableFunction : public CefThreadSafeBase { +class CefRunnableFunction : public CefTask { public: CefRunnableFunction(Function function, const Params& params) : function_(function), params_(params) { @@ -258,6 +260,8 @@ class CefRunnableFunction : public CefThreadSafeBase { private: Function function_; Params params_; + + IMPLEMENT_REFCOUNTING(CefRunnableFunction); }; template diff --git a/include/cef_string_types.h b/include/cef_string_types.h index b66923545..f62d43ad1 100644 --- a/include/cef_string_types.h +++ b/include/cef_string_types.h @@ -39,20 +39,21 @@ extern "C" { #endif +#include "cef_build.h" #include "cef_export.h" #include // CEF character type definitions. wchat_t is 2 bytes on Windows and 4 bytes on // most other platforms. -#ifdef _WIN32 +#if defined(OS_WIN) typedef wchar_t char16_t; -#else // _WIN32 +#else // !OS_WIN typedef unsigned short char16_t; #ifndef WCHAR_T_IS_UTF32 #define WCHAR_T_IS_UTF32 #endif // WCHAR_T_IS_UTF32 -#endif // _WIN32 +#endif // !OS_WIN // CEF string type definitions. Whomever allocates |str| is responsible for diff --git a/include/cef_types.h b/include/cef_types.h index 22fe4f58f..534984686 100644 --- a/include/cef_types.h +++ b/include/cef_types.h @@ -31,14 +31,16 @@ #ifndef _CEF_TYPES_H #define _CEF_TYPES_H +#include "cef_build.h" +#include "cef_string.h" #include "cef_string_list.h" // Bring in platform-specific definitions. -#if defined(_WIN32) +#if defined(OS_WIN) #include "cef_types_win.h" -#elif defined(__APPLE__) +#elif defined(OS_MACOSX) #include "cef_types_mac.h" -#elif defined(__linux__) +#elif defined(OS_LINUX) #include "cef_types_linux.h" #endif @@ -336,17 +338,6 @@ enum cef_key_type_t KT_CHAR, }; -// Define handler return value types. Returning RV_HANDLED indicates -// that the implementation completely handled the method and that no further -// processing is required. Returning RV_CONTINUE indicates that the -// implementation did not handle the method and that the default handler -// should be called. -enum cef_retval_t -{ - RV_HANDLED = 0, - RV_CONTINUE = 1, -}; - // Various browser navigation types supported by chrome. enum cef_handler_navtype_t { diff --git a/include/cef_types_linux.h b/include/cef_types_linux.h index 5cc291f14..a2f571cf2 100644 --- a/include/cef_types_linux.h +++ b/include/cef_types_linux.h @@ -31,7 +31,7 @@ #ifndef _CEF_TYPES_LINUX_H #define _CEF_TYPES_LINUX_H -#if defined(__linux__) +#if defined(OS_LINUX) #include #include "cef_string.h" @@ -63,6 +63,6 @@ typedef struct _cef_print_info_t } #endif -#endif // defined(__linux__) +#endif // OS_LINUX #endif // _CEF_TYPES_LINUX_H diff --git a/include/cef_types_mac.h b/include/cef_types_mac.h index 1ec632c39..5c2ccdd3e 100644 --- a/include/cef_types_mac.h +++ b/include/cef_types_mac.h @@ -31,7 +31,7 @@ #ifndef _CEF_TYPES_MAC_H #define _CEF_TYPES_MAC_H -#if defined(__APPLE__) +#if defined(OS_MACOSX) #include "cef_string.h" // Window handle. @@ -78,6 +78,6 @@ typedef struct _cef_print_info_t } #endif -#endif // defined(__APPLE__) +#endif // OS_MACOSX #endif // _CEF_TYPES_MAC_H diff --git a/include/cef_types_win.h b/include/cef_types_win.h index 6ca6fba2d..b8566605e 100644 --- a/include/cef_types_win.h +++ b/include/cef_types_win.h @@ -31,7 +31,7 @@ #ifndef _CEF_TYPES_WIN_H #define _CEF_TYPES_WIN_H -#ifdef _WIN32 +#if defined(OS_WIN) #include #include "cef_string.h" @@ -78,6 +78,6 @@ typedef struct _cef_print_info_t } #endif -#endif // _WIN32 +#endif // OS_WIN #endif // _CEF_TYPES_WIN_H diff --git a/include/cef_wrapper.h b/include/cef_wrapper.h index 5a849f13d..7152e0eeb 100644 --- a/include/cef_wrapper.h +++ b/include/cef_wrapper.h @@ -60,7 +60,7 @@ // (b) Entity reference nodes are resolved to the corresponding entity // value. // (c) Element nodes are represented by their outer XML string. -class CefXmlObject : public CefThreadSafeBase +class CefXmlObject : public CefBase { public: typedef std::vector > ObjectVector; @@ -148,12 +148,15 @@ private: CefString value_; AttributeMap attributes_; ObjectVector children_; + + IMPLEMENT_REFCOUNTING(CefXmlObject); + IMPLEMENT_LOCKING(CefXmlObject); }; // Thread safe implementation of the CefReadHandler class for reading an // in-memory array of bytes. -class CefByteReadHandler : public CefThreadSafeBase +class CefByteReadHandler : public CefReadHandler { public: // Create a new object for reading an array of bytes. An optional |source| @@ -180,6 +183,9 @@ private: size_t size_; size_t offset_; CefRefPtr source_; + + IMPLEMENT_REFCOUNTING(CefByteReadHandler); + IMPLEMENT_LOCKING(CefByteReadHandler); }; @@ -192,7 +198,7 @@ private: // (3) File ordering from the original zip archive is not maintained. This // means that files from the same folder may not be located together in the // file content map. -class CefZipArchive : public CefThreadSafeBase +class CefZipArchive : public CefBase { public: // Class representing a file in the archive. Accessing the file data from @@ -241,6 +247,9 @@ public: private: FileMap contents_; + + IMPLEMENT_REFCOUNTING(CefZipArchive); + IMPLEMENT_LOCKING(CefZipArchive); }; #endif // _CEF_WRAPPER_H diff --git a/libcef/browser_impl.cc b/libcef/browser_impl.cc index 29a970a18..1e9c2fccc 100644 --- a/libcef/browser_impl.cc +++ b/libcef/browser_impl.cc @@ -50,21 +50,25 @@ namespace { class CreateBrowserHelper { public: - CreateBrowserHelper(CefWindowInfo& windowInfo, bool popup, - CefRefPtr handler, const CefString& url) - : window_info_(windowInfo), popup_(popup), - handler_(handler), url_(url) {} + CreateBrowserHelper(CefWindowInfo& windowInfo, + CefRefPtr client, + const CefString& url, + const CefBrowserSettings& settings) + : window_info_(windowInfo), + client_(client), + url_(url), + settings_(settings) {} CefWindowInfo window_info_; - bool popup_; - CefRefPtr handler_; + CefRefPtr client_; CefString url_; + CefBrowserSettings settings_; }; void UIT_CreateBrowserWithHelper(CreateBrowserHelper* helper) { - CefBrowser::CreateBrowserSync(helper->window_info_, helper->popup_, - helper->handler_, helper->url_); + CefBrowser::CreateBrowserSync(helper->window_info_, helper->client_, + helper->url_, helper->settings_); delete helper; } @@ -83,20 +87,24 @@ void CefBrowserImpl::PaintDelegate::Paint(bool popup, const gfx::Rect& dirtyRect, const void* buffer) { - CefRefPtr handler = browser_->GetHandler(); + CefRefPtr client = browser_->GetClient(); + if (!client.get()) + return; + CefRefPtr handler = client->GetRenderHandler(); if (!handler.get()) return; CefRect rect(dirtyRect.x(), dirtyRect.y(), dirtyRect.width(), dirtyRect.height()); - handler->HandlePaint(browser_, (popup?PET_POPUP:PET_VIEW), rect, buffer); + handler->OnPaint(browser_, (popup?PET_POPUP:PET_VIEW), rect, buffer); } // static -bool CefBrowser::CreateBrowser(CefWindowInfo& windowInfo, bool popup, - CefRefPtr handler, - const CefString& url) +bool CefBrowser::CreateBrowser(CefWindowInfo& windowInfo, + CefRefPtr client, + const CefString& url, + const CefBrowserSettings& settings) { // Verify that the context is in a valid state. if (!CONTEXT_STATE_VALID()) { @@ -104,17 +112,24 @@ bool CefBrowser::CreateBrowser(CefWindowInfo& windowInfo, bool popup, return false; } + // Verify that the settings structure is a valid size. + if (settings.size != sizeof(cef_browser_settings_t)) { + NOTREACHED(); + return false; + } + // Create the browser on the UI thread. CreateBrowserHelper* helper = - new CreateBrowserHelper(windowInfo, popup, handler, url); + new CreateBrowserHelper(windowInfo, client, url, settings); CefThread::PostTask(CefThread::UI, FROM_HERE, NewRunnableFunction( UIT_CreateBrowserWithHelper, helper)); return true; } // static -CefRefPtr CefBrowser::CreateBrowserSync(CefWindowInfo& windowInfo, - bool popup, CefRefPtr handler, const CefString& url) +CefRefPtr CefBrowser::CreateBrowserSync( + CefWindowInfo& windowInfo, CefRefPtr client, + const CefString& url, const CefBrowserSettings& settings) { // Verify that the context is in a valid state. if (!CONTEXT_STATE_VALID()) { @@ -122,27 +137,20 @@ CefRefPtr CefBrowser::CreateBrowserSync(CefWindowInfo& windowInfo, return NULL; } + // Verify that the settings structure is a valid size. + if (settings.size != sizeof(cef_browser_settings_t)) { + NOTREACHED(); + return NULL; + } + // Verify that this method is being called on the UI thread. if (!CefThread::CurrentlyOn(CefThread::UI)) { NOTREACHED(); return NULL; } - CefRefPtr alternateBrowser; - CefBrowserSettings settings(_Context->browser_defaults()); - - if(handler.get()) - { - // Give the handler an opportunity to modify window attributes, handler, - // or cancel the window creation. - CefHandler::RetVal rv = handler->HandleBeforeCreated(NULL, windowInfo, - popup, CefPopupFeatures(), handler, url, settings); - if(rv == RV_HANDLED) - return false; - } - CefRefPtr browser( - new CefBrowserImpl(windowInfo, settings, popup, handler)); + new CefBrowserImpl(windowInfo, settings, false, client)); static_cast(browser.get())->UIT_CreateBrowser(url); return browser; @@ -151,9 +159,9 @@ CefRefPtr CefBrowser::CreateBrowserSync(CefWindowInfo& windowInfo, CefBrowserImpl::CefBrowserImpl(const CefWindowInfo& windowInfo, const CefBrowserSettings& settings, bool popup, - CefRefPtr handler) + CefRefPtr client) : window_info_(windowInfo), settings_(settings), is_popup_(popup), - is_modal_(false), handler_(handler), webviewhost_(NULL), popuphost_(NULL), + is_modal_(false), client_(client), webviewhost_(NULL), popuphost_(NULL), zoom_level_(0.0), can_go_back_(false), can_go_forward_(false), main_frame_(NULL), unique_id_(0) { @@ -666,9 +674,12 @@ WebFrame* CefBrowserImpl::UIT_GetWebFrame(CefRefPtr frame) void CefBrowserImpl::UIT_DestroyBrowser() { - if(handler_.get()) { - // Notify the handler that the window is about to be closed. - handler_->HandleBeforeWindowClose(this); + if(client_.get()) { + CefRefPtr handler = client_->GetLifeSpanHandler(); + if (handler.get()) { + // Notify the handler that the window is about to be closed. + handler->OnBeforeClose(this); + } } UIT_GetWebViewDelegate()->RevokeDragDrop(); @@ -915,22 +926,25 @@ bool CefBrowserImpl::UIT_Navigate(const BrowserNavigationEntry& entry, // In case LoadRequest failed before DidCreateDataSource was called. delegate_->set_pending_extra_data(NULL); - if (handler_.get() && handler_->HandleSetFocus(this, false) == RV_CONTINUE) { - // Restore focus to the main frame prior to loading new request. - // This makes sure that we don't have a focused iframe. Otherwise, that - // iframe would keep focus when the SetFocus called immediately after - // LoadRequest, thus making some tests fail (see http://b/issue?id=845337 - // for more details). - // TODO(cef): The above comment may be wrong, or the below call to - // setFocusedFrame() may be unnecessary or in the wrong place. See this - // thread for additional details: - // http://groups.google.com/group/chromium-dev/browse_thread/thread/42bcd31b59e3a168 - view->setFocusedFrame(frame); + if (client_.get()) { + CefRefPtr handler = client_->GetFocusHandler(); + if (handler.get() && !handler->OnSetFocus(this, false)) { + // Restore focus to the main frame prior to loading new request. + // This makes sure that we don't have a focused iframe. Otherwise, that + // iframe would keep focus when the SetFocus called immediately after + // LoadRequest, thus making some tests fail (see http://b/issue?id=845337 + // for more details). + // TODO(cef): The above comment may be wrong, or the below call to + // setFocusedFrame() may be unnecessary or in the wrong place. See this + // thread for additional details: + // http://groups.google.com/group/chromium-dev/browse_thread/thread/42bcd31b59e3a168 + view->setFocusedFrame(frame); - // Give focus to the window if it is currently visible. - if (!IsWindowRenderingDisabled() && - UIT_IsViewVisible(UIT_GetMainWndHandle())) - UIT_SetFocus(UIT_GetWebViewHost(), true); + // Give focus to the window if it is currently visible. + if (!IsWindowRenderingDisabled() && + UIT_IsViewVisible(UIT_GetMainWndHandle())) + UIT_SetFocus(UIT_GetWebViewHost(), true); + } } return true; @@ -1052,23 +1066,23 @@ CefRefPtr CefBrowserImpl::UIT_CreatePopupWindow( if(features.heightSet) info.m_nHeight = features.height; - CefRefPtr handler = handler_; + CefRefPtr client = client_; // Start with the current browser window's settings. CefBrowserSettings settings(settings_); - if(handler_.get()) - { + if (client_.get()) { + CefRefPtr handler = client_->GetLifeSpanHandler(); // Give the handler an opportunity to modify window attributes, handler, // or cancel the window creation. - CefHandler::RetVal rv = handler_->HandleBeforeCreated(this, info, true, - features, handler, url, settings); - if(rv == RV_HANDLED) + if (handler.get() && + handler->OnBeforePopup(this, features, info, url, client, settings)) { return NULL; + } } CefRefPtr browser( - new CefBrowserImpl(info, settings, true, handler)); + new CefBrowserImpl(info, settings, true, client)); // Don't pass the URL to UIT_CreateBrowser for popup windows or the URL will // be loaded twice. browser->UIT_CreateBrowser(CefString()); @@ -1104,9 +1118,12 @@ void CefBrowserImpl::UIT_ClosePopupWidget() popuphost_ = NULL; popup_rect_ = gfx::Rect(); - if (IsWindowRenderingDisabled() && handler_.get()) { - // Notify the handler of popup visibility change. - handler_->HandlePopupChange(this, false, CefRect()); + if (IsWindowRenderingDisabled() && client_.get()) { + CefRefPtr handler = client_->GetRenderHandler(); + if (handler.get()) { + // Notify the handler of popup visibility change. + handler->OnPopupShow(this, false); + } } } @@ -1116,12 +1133,12 @@ void CefBrowserImpl::UIT_Show(WebKit::WebNavigationPolicy policy) delegate_->show(policy); } -void CefBrowserImpl::UIT_HandleActionView(CefHandler::MenuId menuId) +void CefBrowserImpl::UIT_HandleActionView(cef_handler_menuid_t menuId) { return UIT_HandleAction(menuId, NULL); } -void CefBrowserImpl::UIT_HandleAction(CefHandler::MenuId menuId, +void CefBrowserImpl::UIT_HandleAction(cef_handler_menuid_t menuId, CefRefPtr frame) { REQUIRE_UIT(); @@ -1342,11 +1359,14 @@ void CefBrowserImpl::UIT_NotifyFindStatus(int identifier, int count, int active_match_ordinal, bool final_update) { - if(handler_.get()) { - CefRect rect(selection_rect.x, selection_rect.y, selection_rect.width, - selection_rect.height); - handler_->HandleFindResult(this, identifier, count, rect, - active_match_ordinal, final_update); + if(client_.get()) { + CefRefPtr handler = client_->GetFindHandler(); + if (handler.get()) { + CefRect rect(selection_rect.x, selection_rect.y, selection_rect.width, + selection_rect.height); + handler->OnFindResult(this, identifier, count, rect, active_match_ordinal, + final_update); + } } } diff --git a/libcef/browser_impl.h b/libcef/browser_impl.h index f30dd82cc..dfb246350 100644 --- a/libcef/browser_impl.h +++ b/libcef/browser_impl.h @@ -33,7 +33,7 @@ class WebView; // Implementation of CefBrowser. -class CefBrowserImpl : public CefThreadSafeBase +class CefBrowserImpl : public CefBrowser { public: class PaintDelegate : public WebWidgetHost::PaintDelegate @@ -51,7 +51,7 @@ public: CefBrowserImpl(const CefWindowInfo& windowInfo, const CefBrowserSettings& settings, bool popup, - CefRefPtr handler); + CefRefPtr client); virtual ~CefBrowserImpl() {} #if defined(OS_WIN) @@ -61,45 +61,46 @@ public: #endif // CefBrowser methods - virtual void CloseBrowser(); - virtual bool CanGoBack() { return can_go_back(); } - virtual void GoBack(); - virtual bool CanGoForward() { return can_go_forward(); } - virtual void GoForward(); - virtual void Reload(); - virtual void ReloadIgnoreCache(); - virtual void StopLoad(); - virtual void SetFocus(bool enable); - virtual CefWindowHandle GetWindowHandle(); - virtual bool IsPopup() { return is_popup(); } - virtual CefRefPtr GetHandler() { return handler_; } - virtual CefRefPtr GetMainFrame() { return GetMainCefFrame(); } - virtual CefRefPtr GetFocusedFrame(); - virtual CefRefPtr GetFrame(const CefString& name); - virtual void GetFrameNames(std::vector& names); + virtual void CloseBrowser() OVERRIDE; + virtual bool CanGoBack() OVERRIDE { return can_go_back(); } + virtual void GoBack() OVERRIDE; + virtual bool CanGoForward() OVERRIDE { return can_go_forward(); } + virtual void GoForward() OVERRIDE; + virtual void Reload() OVERRIDE; + virtual void ReloadIgnoreCache() OVERRIDE; + virtual void StopLoad() OVERRIDE; + virtual void SetFocus(bool enable) OVERRIDE; + virtual CefWindowHandle GetWindowHandle() OVERRIDE; + virtual bool IsPopup() OVERRIDE { return is_popup(); } + virtual CefRefPtr GetClient() OVERRIDE { return client_; } + virtual CefRefPtr GetMainFrame() OVERRIDE + { return GetMainCefFrame(); } + virtual CefRefPtr GetFocusedFrame() OVERRIDE; + virtual CefRefPtr GetFrame(const CefString& name) OVERRIDE; + virtual void GetFrameNames(std::vector& names) OVERRIDE; virtual void Find(int identifier, const CefString& searchText, - bool forward, bool matchCase, bool findNext); - virtual void StopFinding(bool clearSelection); - virtual double GetZoomLevel() { return zoom_level(); } - virtual void SetZoomLevel(double zoomLevel); - virtual void ShowDevTools(); - virtual void CloseDevTools(); - virtual bool IsWindowRenderingDisabled(); - virtual bool GetSize(PaintElementType type, int& width, int& height); - virtual void SetSize(PaintElementType type, int width, int height); - virtual bool IsPopupVisible(); - virtual void HidePopup(); - virtual void Invalidate(const CefRect& dirtyRect); + bool forward, bool matchCase, bool findNext) OVERRIDE; + virtual void StopFinding(bool clearSelection) OVERRIDE; + virtual double GetZoomLevel() OVERRIDE { return zoom_level(); } + virtual void SetZoomLevel(double zoomLevel) OVERRIDE; + virtual void ShowDevTools() OVERRIDE; + virtual void CloseDevTools() OVERRIDE; + virtual bool IsWindowRenderingDisabled() OVERRIDE; + virtual bool GetSize(PaintElementType type, int& width, int& height) OVERRIDE; + virtual void SetSize(PaintElementType type, int width, int height) OVERRIDE; + virtual bool IsPopupVisible() OVERRIDE; + virtual void HidePopup() OVERRIDE; + virtual void Invalidate(const CefRect& dirtyRect) OVERRIDE; virtual bool GetImage(PaintElementType type, int width, int height, - void* buffer); + void* buffer) OVERRIDE; virtual void SendKeyEvent(KeyType type, int key, int modifiers, bool sysChar, - bool imeChar); + bool imeChar) OVERRIDE; virtual void SendMouseClickEvent(int x, int y, MouseButtonType type, - bool mouseUp, int clickCount); - virtual void SendMouseMoveEvent(int x, int y, bool mouseLeave); - virtual void SendMouseWheelEvent(int x, int y, int delta); - virtual void SendFocusEvent(bool setFocus); - virtual void SendCaptureLostEvent(); + bool mouseUp, int clickCount) OVERRIDE; + virtual void SendMouseMoveEvent(int x, int y, bool mouseLeave) OVERRIDE; + virtual void SendMouseWheelEvent(int x, int y, int delta) OVERRIDE; + virtual void SendFocusEvent(bool setFocus) OVERRIDE; + virtual void SendCaptureLostEvent() OVERRIDE; // Frame-related methods void Undo(CefRefPtr frame); @@ -268,8 +269,8 @@ public: void UIT_Show(WebKit::WebNavigationPolicy policy); // Handles most simple browser actions - void UIT_HandleActionView(CefHandler::MenuId menuId); - void UIT_HandleAction(CefHandler::MenuId menuId, CefRefPtr frame); + void UIT_HandleActionView(cef_handler_menuid_t menuId); + void UIT_HandleAction(cef_handler_menuid_t menuId, CefRefPtr frame); // Save the document HTML to a temporary file and open in the default viewing // application @@ -333,7 +334,7 @@ protected: CefBrowserSettings settings_; bool is_popup_; bool is_modal_; - CefRefPtr handler_; + CefRefPtr client_; scoped_ptr webviewhost_; WebWidgetHost* popuphost_; gfx::Rect popup_rect_; @@ -369,52 +370,57 @@ protected: // A temporary directory for FileSystem API. ScopedTempDir file_system_root_; + + IMPLEMENT_REFCOUNTING(CefBrowserImpl); + IMPLEMENT_LOCKING(CefBrowserImpl); }; // Implementation of CefFrame. -class CefFrameImpl : public CefThreadSafeBase +class CefFrameImpl : public CefFrame { public: CefFrameImpl(CefBrowserImpl* browser, const CefString& name); virtual ~CefFrameImpl(); // CefFrame methods - virtual void Undo() { browser_->Undo(this); } - virtual void Redo() { browser_->Redo(this); } - virtual void Cut() { browser_->Cut(this); } - virtual void Copy() { browser_->Copy(this); } - virtual void Paste() { browser_->Paste(this); } - virtual void Delete() { browser_->Delete(this); } - virtual void SelectAll() { browser_->SelectAll(this); } - virtual void Print() { browser_->Print(this); } - virtual void ViewSource() { browser_->ViewSource(this); } - virtual CefString GetSource() { return browser_->GetSource(this); } - virtual CefString GetText() { return browser_->GetText(this); } - virtual void LoadRequest(CefRefPtr request) + virtual void Undo() OVERRIDE { browser_->Undo(this); } + virtual void Redo() OVERRIDE { browser_->Redo(this); } + virtual void Cut() OVERRIDE { browser_->Cut(this); } + virtual void Copy() OVERRIDE { browser_->Copy(this); } + virtual void Paste() OVERRIDE { browser_->Paste(this); } + virtual void Delete() OVERRIDE { browser_->Delete(this); } + virtual void SelectAll() OVERRIDE { browser_->SelectAll(this); } + virtual void Print() OVERRIDE { browser_->Print(this); } + virtual void ViewSource() OVERRIDE { browser_->ViewSource(this); } + virtual CefString GetSource() OVERRIDE { return browser_->GetSource(this); } + virtual CefString GetText() OVERRIDE { return browser_->GetText(this); } + virtual void LoadRequest(CefRefPtr request) OVERRIDE { return browser_->LoadRequest(this, request); } - virtual void LoadURL(const CefString& url) + virtual void LoadURL(const CefString& url) OVERRIDE { return browser_->LoadURL(this, url); } virtual void LoadString(const CefString& string, - const CefString& url) + const CefString& url) OVERRIDE { return browser_->LoadString(this, string, url); } virtual void LoadStream(CefRefPtr stream, - const CefString& url) + const CefString& url) OVERRIDE { return browser_->LoadStream(this, stream, url); } virtual void ExecuteJavaScript(const CefString& jsCode, const CefString& scriptUrl, - int startLine) + int startLine) OVERRIDE { return browser_->ExecuteJavaScript(this, jsCode, scriptUrl, startLine); } - virtual bool IsMain() { return name_.empty(); } - virtual bool IsFocused(); - virtual CefString GetName() { return name_; } - virtual CefString GetURL() { return browser_->GetURL(this); } - virtual CefRefPtr GetBrowser() { return browser_.get(); } - virtual void VisitDOM(CefRefPtr visitor); + virtual bool IsMain() OVERRIDE { return name_.empty(); } + virtual bool IsFocused() OVERRIDE; + virtual CefString GetName() OVERRIDE { return name_; } + virtual CefString GetURL() OVERRIDE { return browser_->GetURL(this); } + virtual CefRefPtr GetBrowser() OVERRIDE { return browser_.get(); } + virtual void VisitDOM(CefRefPtr visitor) OVERRIDE; private: CefRefPtr browser_; CefString name_; + + IMPLEMENT_REFCOUNTING(CefFrameImpl); }; #endif // _BROWSER_IMPL_H diff --git a/libcef/browser_impl_win.cc b/libcef/browser_impl_win.cc index 3a533f8d5..21d6f186a 100644 --- a/libcef/browser_impl_win.cc +++ b/libcef/browser_impl_win.cc @@ -167,9 +167,12 @@ void CefBrowserImpl::UIT_CreateBrowser(const CefString& url) cr.bottom, flags); } - if(handler_.get()) { - // Notify the handler that we're done creating the new window - handler_->HandleAfterCreated(this); + if(client_.get()) { + CefRefPtr handler = client_->GetLifeSpanHandler(); + if (handler.get()) { + // Notify the handler that we're done creating the new window + handler->OnAfterCreated(this); + } } if(url.length() > 0) @@ -303,7 +306,11 @@ void CefBrowserImpl::UIT_PrintPage(int page_number, int total_pages, res = RestoreDC(hDC, saved_state); DCHECK_NE(res, 0); - if(handler_.get()) { + CefRefPtr handler; + if (client_.get()) + handler = client_->GetPrintHandler(); + + if(handler.get()) { saved_state = SaveDC(hDC); DCHECK_NE(saved_state, 0); @@ -334,12 +341,12 @@ void CefBrowserImpl::UIT_PrintPage(int page_number, int total_pages, CefString topLeft, topCenter, topRight; CefString bottomLeft, bottomCenter, bottomRight; - // allow the handler to format print header and/or footer - CefHandler::RetVal rv = handler_->HandlePrintHeaderFooter(this, - UIT_GetCefFrame(frame), printInfo, url, title, page_number+1, total_pages, - topLeft, topCenter, topRight, bottomLeft, bottomCenter, bottomRight); + // Allow the handler to format print header and/or footer. + bool handled = handler->GetPrintHeaderFooter(this, UIT_GetCefFrame(frame), + printInfo, url, title, page_number+1, total_pages, topLeft, topCenter, + topRight, bottomLeft, bottomCenter, bottomRight); - if(rv != RV_HANDLED) { + if (!handled) { // Draw handler-defined headers and/or footers. LOGFONT lf; memset(&lf, 0, sizeof(lf)); @@ -414,9 +421,12 @@ void CefBrowserImpl::UIT_PrintPages(WebKit::WebFrame* frame) { memset(&print_options, 0, sizeof(print_options)); settings.UpdatePrintOptions(print_options); + CefRefPtr handler; + if (client_.get()) + handler = client_->GetPrintHandler(); + // Ask the handler if they want to update the print options. - if (handler_.get() && RV_HANDLED == - handler_->HandlePrintOptions(this, print_options)) { + if (handler.get() && handler->GetPrintOptions(this, print_options)) { settings.UpdateFromPrintOptions(print_options); print_context_.InitWithSettings(settings); } diff --git a/libcef/browser_resource_loader_bridge.cc b/libcef/browser_resource_loader_bridge.cc index 10e5f9081..08a18f775 100644 --- a/libcef/browser_resource_loader_bridge.cc +++ b/libcef/browser_resource_loader_bridge.cc @@ -195,7 +195,11 @@ class RequestProxy : public net::URLRequest::Delegate, const GURL& url, bool allow_download) { if (browser_.get() && info.headers.get()) { - CefRefPtr handler = browser_->GetHandler(); + CefRefPtr client = browser_->GetClient(); + CefRefPtr handler; + if (client.get()) + handler = client->GetRequestHandler(); + if (handler.get()) { std::string content_disposition; info.headers->GetNormalizedHeader("Content-Disposition", @@ -206,9 +210,9 @@ class RequestProxy : public net::URLRequest::Delegate, string16 filename = net::GetSuggestedFilename(url, content_disposition, info.charset, ASCIIToUTF16("download")); CefRefPtr dl_handler; - if (handler->HandleDownloadResponse(browser_, info.mime_type, - filename, info.content_length, dl_handler) == - RV_CONTINUE) { + if (handler->GetDownloadHandler(browser_, info.mime_type, + filename, info.content_length, + dl_handler)) { download_handler_ = dl_handler; } } @@ -285,7 +289,11 @@ class RequestProxy : public net::URLRequest::Delegate, bool handled = false; if (browser_.get()) { - CefRefPtr handler = browser_->GetHandler(); + CefRefPtr client = browser_->GetClient(); + CefRefPtr handler; + if (client.get()) + handler = client->GetRequestHandler(); + if(handler.get()) { // Build the request object for passing to the handler CefRefPtr request(new CefRequestImpl()); @@ -317,53 +325,54 @@ class RequestProxy : public net::URLRequest::Delegate, CefRefPtr resourceStream; CefRefPtr response(new CefResponseImpl()); - CefHandler::RetVal rv = handler->HandleBeforeResourceLoad( - browser_, request, redirectUrl, resourceStream, response, - loadFlags); + handled = handler->OnBeforeResourceLoad(browser_, request, redirectUrl, + resourceStream, response, loadFlags); + if (!handled) { + // Observe URL from request. + const std::string requestUrl(request->GetURL()); + if(requestUrl != originalUrl) { + params->url = GURL(requestUrl); + redirectUrl.clear(); // Request URL trumps redirect URL + } - // Observe URL from request. - const std::string requestUrl(request->GetURL()); - if(requestUrl != originalUrl) { - params->url = GURL(requestUrl); - redirectUrl.clear(); // Request URL trumps redirect URL + // Observe method from request. + params->method = request->GetMethod(); + + // Observe headers from request. + request->GetHeaderMap(headerMap); + CefString referrerStr; + referrerStr.FromASCII("Referrer"); + CefRequest::HeaderMap::iterator referrer = headerMap.find(referrerStr); + if(referrer == headerMap.end()) { + params->referrer = GURL(); + } else { + params->referrer = GURL(std::string(referrer->second)); + headerMap.erase(referrer); + } + params->headers = HttpHeaderUtils::GenerateHeaders(headerMap); + + // Observe post data from request. + CefRefPtr postData = request->GetPostData(); + if(postData.get()) { + params->upload = new net::UploadData(); + static_cast(postData.get())->Get(*params->upload); + } } - // Observe method from request. - params->method = request->GetMethod(); - - // Observe headers from request. - request->GetHeaderMap(headerMap); - CefString referrerStr; - referrerStr.FromASCII("Referrer"); - CefRequest::HeaderMap::iterator referrer = headerMap.find(referrerStr); - if(referrer == headerMap.end()) { - params->referrer = GURL(); - } else { - params->referrer = GURL(std::string(referrer->second)); - headerMap.erase(referrer); - } - params->headers = HttpHeaderUtils::GenerateHeaders(headerMap); - - // Observe post data from request. - CefRefPtr postData = request->GetPostData(); - if(postData.get()) { - params->upload = new net::UploadData(); - static_cast(postData.get())->Get(*params->upload); - } - - if(rv == RV_HANDLED) { + if (handled) { // cancel the resource load - handled = true; OnCompletedRequest( URLRequestStatus(URLRequestStatus::CANCELED, net::ERR_ABORTED), std::string(), base::Time()); - } else if(!redirectUrl.empty()) { + } else if (!redirectUrl.empty()) { // redirect to the specified URL + handled = true; + params->url = GURL(std::string(redirectUrl)); ResourceResponseInfo info; bool defer_redirect; OnReceivedRedirect(params->url, info, &defer_redirect); - } else if(resourceStream.get()) { + } else if (resourceStream.get()) { // load from the provided resource stream handled = true; @@ -403,16 +412,14 @@ class RequestProxy : public net::URLRequest::Delegate, AsyncReadData(); } - if(!handled && ResourceType::IsFrame(params->request_type) && - !net::URLRequest::IsHandledProtocol(params->url.scheme())) { + if (!handled && ResourceType::IsFrame(params->request_type) && + !net::URLRequest::IsHandledProtocol(params->url.scheme())) { bool allow_os_execution = false; - CefHandler::RetVal rv = handler->HandleProtocolExecution(browser_, - params->url.spec(), allow_os_execution); - if (rv == RV_CONTINUE && allow_os_execution && + handled = handler->OnProtocolExecution(browser_, params->url.spec(), + allow_os_execution); + if (!handled && allow_os_execution && ExternalProtocolHandler::HandleExternalProtocol(params->url)) { handled = true; - } else if(rv == RV_HANDLED) { - handled = true; } if (handled) { @@ -599,16 +606,18 @@ class RequestProxy : public net::URLRequest::Delegate, virtual void OnAuthRequired(net::URLRequest* request, net::AuthChallengeInfo* auth_info) { if (browser_.get()) { - CefRefPtr handler = browser_->GetHandler(); - if(handler.get()) { - CefString username, password; - CefHandler::RetVal rv = handler->HandleAuthenticationRequest( - browser_, auth_info->is_proxy, - auth_info->host_and_port, auth_info->realm, - auth_info->scheme, username, password); - if (rv == RV_HANDLED) { - request->SetAuth(username, password); - return; + CefRefPtr client = browser_->GetClient(); + if (client.get()) { + CefRefPtr handler = client->GetRequestHandler(); + if(handler.get()) { + CefString username, password; + if (handler->GetAuthCredentials(browser_, auth_info->is_proxy, + auth_info->host_and_port, + auth_info->realm, auth_info->scheme, + username, password)) { + request->SetAuth(username, password); + return; + } } } } diff --git a/libcef/browser_webkit_init.h b/libcef/browser_webkit_init.h index aaf2b5417..f4e72c8ef 100644 --- a/libcef/browser_webkit_init.h +++ b/libcef/browser_webkit_init.h @@ -95,78 +95,78 @@ class BrowserWebKitInit : public webkit_glue::WebKitClientImpl { WebKit::shutdown(); } - virtual WebKit::WebMimeRegistry* mimeRegistry() { + virtual WebKit::WebMimeRegistry* mimeRegistry() OVERRIDE { return &mime_registry_; } - WebKit::WebClipboard* clipboard() { + virtual WebKit::WebClipboard* clipboard() OVERRIDE { return &clipboard_; } - virtual WebKit::WebFileUtilities* fileUtilities() { + virtual WebKit::WebFileUtilities* fileUtilities() OVERRIDE { return &file_utilities_; } - virtual WebKit::WebSandboxSupport* sandboxSupport() { + virtual WebKit::WebSandboxSupport* sandboxSupport() OVERRIDE { return NULL; } - virtual WebKit::WebBlobRegistry* blobRegistry() { + virtual WebKit::WebBlobRegistry* blobRegistry() OVERRIDE { return blob_registry_.get(); } - virtual WebKit::WebCookieJar* cookieJar() { + virtual WebKit::WebCookieJar* cookieJar() OVERRIDE { return &cookie_jar_; } - virtual WebKit::WebFileSystem* fileSystem() { + virtual WebKit::WebFileSystem* fileSystem() OVERRIDE { return &file_system_; } - virtual bool sandboxEnabled() { + virtual bool sandboxEnabled() OVERRIDE { return true; } virtual WebKit::WebKitClient::FileHandle databaseOpenFile( - const WebKit::WebString& vfs_file_name, int desired_flags) { + const WebKit::WebString& vfs_file_name, int desired_flags) OVERRIDE { return BrowserDatabaseSystem::GetInstance()->OpenFile( vfs_file_name, desired_flags); } virtual int databaseDeleteFile(const WebKit::WebString& vfs_file_name, - bool sync_dir) { + bool sync_dir) OVERRIDE { return BrowserDatabaseSystem::GetInstance()->DeleteFile( vfs_file_name, sync_dir); } virtual long databaseGetFileAttributes( - const WebKit::WebString& vfs_file_name) { + const WebKit::WebString& vfs_file_name) OVERRIDE { return BrowserDatabaseSystem::GetInstance()->GetFileAttributes( vfs_file_name); } virtual long long databaseGetFileSize( - const WebKit::WebString& vfs_file_name) { + const WebKit::WebString& vfs_file_name) OVERRIDE { return BrowserDatabaseSystem::GetInstance()->GetFileSize(vfs_file_name); } virtual unsigned long long visitedLinkHash(const char* canonicalURL, - size_t length) { + size_t length) OVERRIDE { return 0; } - virtual bool isLinkVisited(unsigned long long linkHash) { + virtual bool isLinkVisited(unsigned long long linkHash) OVERRIDE { return false; } - virtual WebKit::WebMessagePortChannel* createMessagePortChannel() { + virtual WebKit::WebMessagePortChannel* createMessagePortChannel() OVERRIDE { return NULL; } - virtual void prefetchHostName(const WebKit::WebString&) { + virtual void prefetchHostName(const WebKit::WebString&) OVERRIDE { } - virtual WebKit::WebData loadResource(const char* name) { + virtual WebKit::WebData loadResource(const char* name) OVERRIDE { if (!strcmp(name, "deleteButton")) { // Create a red 30x30 square. const char red_square[] = @@ -186,12 +186,12 @@ class BrowserWebKitInit : public webkit_glue::WebKitClientImpl { return webkit_glue::WebKitClientImpl::loadResource(name); } - virtual WebKit::WebString defaultLocale() { + virtual WebKit::WebString defaultLocale() OVERRIDE { return ASCIIToUTF16("en-US"); } virtual WebKit::WebStorageNamespace* createLocalStorageNamespace( - const WebKit::WebString& path, unsigned quota) { + const WebKit::WebString& path, unsigned quota) OVERRIDE { if (BrowserWebStorageNamespaceImpl::IsStorageActive()) { // Use the localStorage implementation that writes data to disk. return new BrowserWebStorageNamespaceImpl(DOM_STORAGE_LOCAL); @@ -205,18 +205,18 @@ class BrowserWebKitInit : public webkit_glue::WebKitClientImpl { void dispatchStorageEvent(const WebKit::WebString& key, const WebKit::WebString& old_value, const WebKit::WebString& new_value, const WebKit::WebString& origin, const WebKit::WebURL& url, - bool is_local_storage) { + bool is_local_storage) OVERRIDE { // The event is dispatched by the proxy. } - virtual WebKit::WebIDBFactory* idbFactory() { + virtual WebKit::WebIDBFactory* idbFactory() OVERRIDE { return WebKit::WebIDBFactory::create(); } virtual void createIDBKeysFromSerializedValuesAndKeyPath( const WebKit::WebVector& values, const WebKit::WebString& keyPath, - WebKit::WebVector& keys_out) { + WebKit::WebVector& keys_out) OVERRIDE { WebKit::WebVector keys(values.size()); for (size_t i = 0; i < values.size(); ++i) { keys[i] = WebKit::WebIDBKey::createFromValueAndKeyPath( @@ -228,18 +228,18 @@ class BrowserWebKitInit : public webkit_glue::WebKitClientImpl { virtual WebKit::WebSerializedScriptValue injectIDBKeyIntoSerializedValue( const WebKit::WebIDBKey& key, const WebKit::WebSerializedScriptValue& value, - const WebKit::WebString& keyPath) { + const WebKit::WebString& keyPath) OVERRIDE { return WebKit::WebIDBKey::injectIDBKeyIntoSerializedValue( key, value, WebKit::WebIDBKeyPath::create(keyPath)); } - virtual WebKit::WebGraphicsContext3D* createGraphicsContext3D() { + virtual WebKit::WebGraphicsContext3D* createGraphicsContext3D() OVERRIDE { gfx::BindSkiaToInProcessGL(); return new webkit::gpu::WebGraphicsContext3DInProcessImpl(); } WebKit::WebString queryLocalizedString( - WebKit::WebLocalizedString::Name name) { + WebKit::WebLocalizedString::Name name) OVERRIDE { switch (name) { case WebKit::WebLocalizedString::ValidationValueMissing: case WebKit::WebLocalizedString::ValidationValueMissingForCheckbox: @@ -269,7 +269,8 @@ class BrowserWebKitInit : public webkit_glue::WebKitClientImpl { } WebKit::WebString queryLocalizedString( - WebKit::WebLocalizedString::Name name, const WebKit::WebString& value) { + WebKit::WebLocalizedString::Name name, const WebKit::WebString& value) + OVERRIDE { if (name == WebKit::WebLocalizedString::ValidationRangeUnderflow) return ASCIIToUTF16("range underflow"); if (name == WebKit::WebLocalizedString::ValidationRangeOverflow) @@ -280,7 +281,7 @@ class BrowserWebKitInit : public webkit_glue::WebKitClientImpl { WebKit::WebString queryLocalizedString( WebKit::WebLocalizedString::Name name, const WebKit::WebString& value1, - const WebKit::WebString& value2) { + const WebKit::WebString& value2) OVERRIDE { if (name == WebKit::WebLocalizedString::ValidationTooLong) return ASCIIToUTF16("too long"); if (name == WebKit::WebLocalizedString::ValidationStepMismatch) diff --git a/libcef/browser_webview_delegate.cc b/libcef/browser_webview_delegate.cc index bbcb1a55d..ea8a65de7 100644 --- a/libcef/browser_webview_delegate.cc +++ b/libcef/browser_webview_delegate.cc @@ -197,14 +197,17 @@ void BrowserWebViewDelegate::didAddMessageToConsole( std::string messageStr = message.text.utf8(); std::string sourceStr = source_name.utf8(); - CefHandler::RetVal rv = RV_CONTINUE; - CefRefPtr handler = browser_->GetHandler(); - if(handler.get()) { - rv = handler->HandleConsoleMessage(browser_, messageStr, sourceStr, - source_line); + bool handled = false; + CefRefPtr client = browser_->GetClient(); + if (client.get()) { + CefRefPtr handler = client->GetDisplayHandler(); + if (handler.get()) { + handled = handler->OnConsoleMessage(browser_, messageStr, sourceStr, + source_line); + } } - if(rv == RV_CONTINUE) { + if(!handled) { logging::LogMessage("CONSOLE", 0).stream() << "\"" << messageStr << ",\" source: " @@ -269,8 +272,13 @@ bool BrowserWebViewDelegate::isSelectTrailingWhitespaceEnabled() { } bool BrowserWebViewDelegate::handleCurrentKeyboardEvent() { - CefHandler::RetVal rv = RV_CONTINUE; - CefRefPtr handler = browser_->GetHandler(); + bool handled = false; + + CefRefPtr client = browser_->GetClient(); + CefRefPtr handler; + if (client.get()) + handler = client->GetKeyboardHandler(); + if (handler.get()) { WebWidgetHost* host = GetWidgetHost(); if (host) { @@ -278,17 +286,17 @@ bool BrowserWebViewDelegate::handleCurrentKeyboardEvent() { switch (event.type) { case WebKeyboardEvent::RawKeyDown: - rv = handler->HandleKeyEvent(browser_, + handled = handler->OnKeyEvent(browser_, KEYEVENT_RAWKEYDOWN, event.windowsKeyCode, event.modifiers, event.isSystemKey?true:false); break; case WebKeyboardEvent::KeyUp: - rv = handler->HandleKeyEvent(browser_, + handled = handler->OnKeyEvent(browser_, KEYEVENT_KEYUP, event.windowsKeyCode, event.modifiers, event.isSystemKey?true:false); break; case WebKeyboardEvent::Char: - rv = handler->HandleKeyEvent(browser_, + handled = handler->OnKeyEvent(browser_, KEYEVENT_CHAR, event.windowsKeyCode, event.modifiers, event.isSystemKey?true:false); break; @@ -297,7 +305,7 @@ bool BrowserWebViewDelegate::handleCurrentKeyboardEvent() { } } } - if (rv == RV_HANDLED) + if (handled) return true; if (edit_command_name_.empty()) @@ -337,28 +345,38 @@ bool BrowserWebViewDelegate::runFileChooser( void BrowserWebViewDelegate::runModalAlertDialog( WebFrame* frame, const WebString& message) { - CefHandler::RetVal rv = RV_CONTINUE; CefString messageStr = string16(message); - CefRefPtr handler = browser_->GetHandler(); - if(handler.get()) { - rv = handler->HandleJSAlert(browser_, browser_->UIT_GetCefFrame(frame), + bool handled = false; + + CefRefPtr client = browser_->GetClient(); + CefRefPtr handler; + if (client.get()) + handler = client->GetJSDialogHandler(); + + if (handler.get()) { + handled = handler->OnJSAlert(browser_, browser_->UIT_GetCefFrame(frame), messageStr); } - if(rv != RV_HANDLED) + if (!handled) ShowJavaScriptAlert(frame, messageStr); } bool BrowserWebViewDelegate::runModalConfirmDialog( WebFrame* frame, const WebString& message) { - CefHandler::RetVal rv = RV_CONTINUE; CefString messageStr = string16(message); bool retval = false; - CefRefPtr handler = browser_->GetHandler(); - if(handler.get()) { - rv = handler->HandleJSConfirm(browser_, browser_->UIT_GetCefFrame(frame), + bool handled = false; + + CefRefPtr client = browser_->GetClient(); + CefRefPtr handler; + if (client.get()) + handler = client->GetJSDialogHandler(); + + if (handler.get()) { + handled = handler->OnJSConfirm(browser_, browser_->UIT_GetCefFrame(frame), messageStr, retval); } - if(rv != RV_HANDLED) + if (!handled) retval = ShowJavaScriptConfirm(frame, messageStr); return retval; } @@ -372,14 +390,19 @@ bool BrowserWebViewDelegate::runModalPromptDialog( if(actual_value) actualValueStr = string16(*actual_value); - CefHandler::RetVal rv = RV_CONTINUE; bool retval = false; - CefRefPtr handler = browser_->GetHandler(); - if(handler.get()) { - rv = handler->HandleJSPrompt(browser_, browser_->UIT_GetCefFrame(frame), + bool handled = false; + + CefRefPtr client = browser_->GetClient(); + CefRefPtr handler; + if (client.get()) + handler = client->GetJSDialogHandler(); + + if (handler.get()) { + handled = handler->OnJSPrompt(browser_, browser_->UIT_GetCefFrame(frame), messageStr, defaultValueStr, retval, actualValueStr); } - if(rv != RV_HANDLED) { + if (!handled) { retval = ShowJavaScriptPrompt(frame, messageStr, defaultValueStr, &actualValueStr); } @@ -410,11 +433,16 @@ void BrowserWebViewDelegate::setToolTipText( const WebString& text, WebTextDirection hint) { CefString tooltipStr = string16(text); - CefRefPtr handler = browser_->GetHandler(); - if(handler.get() && handler->HandleTooltip(browser_, tooltipStr) - == RV_CONTINUE){ - GetWidgetHost()->SetTooltipText(tooltipStr); + bool handled = false; + CefRefPtr client = browser_->GetClient(); + if (client.get()) { + CefRefPtr handler = client->GetDisplayHandler(); + if (handler.get()) + handled = handler->OnTooltip(browser_, tooltipStr); } + + if (!handled) + GetWidgetHost()->SetTooltipText(tooltipStr); } void BrowserWebViewDelegate::startDragging( @@ -439,18 +467,24 @@ void BrowserWebViewDelegate::startDragging( } void BrowserWebViewDelegate::focusNext() { - CefRefPtr handler = browser_->GetHandler(); - if(handler.get()) { - // Notify the handler that it should take a focus - handler->HandleTakeFocus(browser_, false); + CefRefPtr client = browser_->GetClient(); + if (client.get()) { + CefRefPtr handler = client->GetFocusHandler(); + if (handler.get()) { + // Notify the handler that it should take a focus + handler->OnTakeFocus(browser_, true); + } } } void BrowserWebViewDelegate::focusPrevious() { - CefRefPtr handler = browser_->GetHandler(); - if(handler.get()) { - // Notify the handler that it should take a focus - handler->HandleTakeFocus(browser_, true); + CefRefPtr client = browser_->GetClient(); + if (client.get()) { + CefRefPtr handler = client->GetFocusHandler(); + if (handler.get()) { + // Notify the handler that it should take a focus + handler->OnTakeFocus(browser_, false); + } } } @@ -502,8 +536,15 @@ void BrowserWebViewDelegate::scheduleAnimation() { void BrowserWebViewDelegate::didFocus() { if (WebWidgetHost* host = GetWidgetHost()) { - CefRefPtr handler = browser_->GetHandler(); - if (handler.get() && handler->HandleSetFocus(browser_, true) == RV_CONTINUE) + bool handled = false; + CefRefPtr client = browser_->GetClient(); + if (client.get()) { + CefRefPtr handler = client->GetFocusHandler(); + if (handler.get()) + handled = handler->OnSetFocus(browser_, true); + } + + if (!handled) browser_->UIT_SetFocus(host, true); } } @@ -527,13 +568,16 @@ WebScreenInfo BrowserWebViewDelegate::screenInfo() { if (browser_->IsWindowRenderingDisabled()) { // Retrieve the screen rectangle from the handler. - CefRefPtr handler = browser_->GetHandler(); - if (handler.get()) { - CefRect rect(info.rect.x, info.rect.y, info.rect.width, - info.rect.height); - if (handler->HandleGetRect(browser_, true, rect) == RV_CONTINUE) { - info.rect = WebRect(rect.x, rect.y, rect.width, rect.height); - info.availableRect = info.rect; + CefRefPtr client = browser_->GetClient(); + if (client.get()) { + CefRefPtr handler = client->GetRenderHandler(); + if (handler.get()) { + CefRect rect(info.rect.x, info.rect.y, info.rect.width, + info.rect.height); + if (handler->GetScreenRect(browser_, rect)) { + info.rect = WebRect(rect.x, rect.y, rect.width, rect.height); + info.availableRect = info.rect; + } } } } @@ -639,7 +683,7 @@ void BrowserWebViewDelegate::loadURLExternally( WebNavigationPolicy policy) { DCHECK_NE(policy, WebKit::WebNavigationPolicyCurrentTab); std::string url = request.url().spec().data(); - CefRefPtr newBrowser = + CefRefPtr newBrowser = browser_->UIT_CreatePopupWindow(url, CefPopupFeatures()); if (newBrowser.get() && !url.empty()) newBrowser->GetMainFrame()->LoadURL(url); @@ -649,37 +693,40 @@ WebNavigationPolicy BrowserWebViewDelegate::decidePolicyForNavigation( WebFrame* frame, const WebURLRequest& request, WebNavigationType type, const WebNode& originating_node, WebNavigationPolicy default_policy, bool is_redirect) { - CefRefPtr handler = browser_->GetHandler(); - if(handler.get()) { - // Gather browse request information - CefRefPtr req(CefRequest::CreateRequest()); + CefRefPtr client = browser_->GetClient(); + if (client.get()) { + CefRefPtr handler = client->GetRequestHandler(); + if (handler.get()) { + // Gather browse request information + CefRefPtr req(CefRequest::CreateRequest()); - GURL request_url = request.url(); - if (!request_url.is_valid()) - return WebKit::WebNavigationPolicyIgnore; + GURL request_url = request.url(); + if (!request_url.is_valid()) + return WebKit::WebNavigationPolicyIgnore; - req->SetURL(request_url.spec()); - req->SetMethod(string16(request.httpMethod())); + req->SetURL(request_url.spec()); + req->SetMethod(string16(request.httpMethod())); - const WebKit::WebHTTPBody& httpBody = request.httpBody(); - if(!httpBody.isNull()) { - CefRefPtr postdata(CefPostData::CreatePostData()); - static_cast(postdata.get())->Set(httpBody); - req->SetPostData(postdata); - } - - CefRequest::HeaderMap map; - CefRequestImpl::GetHeaderMap(request, map); - if(map.size() > 0) - static_cast(req.get())->SetHeaderMap(map); - - // Notify the handler of a browse request - CefHandler::RetVal rv = handler->HandleBeforeBrowse(browser_, - browser_->UIT_GetCefFrame(frame), req, (CefHandler::NavType)type, - is_redirect); - if(rv == RV_HANDLED) - return WebKit::WebNavigationPolicyIgnore; + const WebKit::WebHTTPBody& httpBody = request.httpBody(); + if(!httpBody.isNull()) { + CefRefPtr postdata(CefPostData::CreatePostData()); + static_cast(postdata.get())->Set(httpBody); + req->SetPostData(postdata); + } + + CefRequest::HeaderMap map; + CefRequestImpl::GetHeaderMap(request, map); + if(map.size() > 0) + static_cast(req.get())->SetHeaderMap(map); + + // Notify the handler of a browse request + bool handled = handler->OnBeforeBrowse(browser_, + browser_->UIT_GetCefFrame(frame), req, (cef_handler_navtype_t)type, + is_redirect); + if(handled) + return WebKit::WebNavigationPolicyIgnore; } + } WebNavigationPolicy result; if (policy_delegate_enabled_) { @@ -748,17 +795,21 @@ void BrowserWebViewDelegate::didFailProvisionalLoad( std::string error_text; CefString errorStr; - CefRefPtr handler = browser_->GetHandler(); - CefHandler::RetVal rv = RV_CONTINUE; - if(handler.get()) { - // give the handler an opportunity to generate a custom error message - rv = handler->HandleLoadError(browser_, - browser_->UIT_GetCefFrame(frame), - static_cast(error.reason), - std::string(failed_ds->request().url().spec().data()), errorStr); + bool handled = false; + + CefRefPtr client = browser_->GetClient(); + if (client.get()) { + CefRefPtr handler = client->GetLoadHandler(); + if (handler.get()) { + // give the handler an opportunity to generate a custom error message + handled = handler->OnLoadError(browser_, + browser_->UIT_GetCefFrame(frame), + static_cast(error.reason), + std::string(failed_ds->request().url().spec().data()), errorStr); + } } - if(rv == RV_HANDLED && !errorStr.empty()) { + if(handled && !errorStr.empty()) { error_text = errorStr; } else { error_text = StringPrintf("Error %d when loading url %s", @@ -785,14 +836,17 @@ void BrowserWebViewDelegate::didCommitProvisionalLoad( UpdateForCommittedLoad(frame, is_new_navigation); - CefRefPtr handler = browser_->GetHandler(); - if(handler.get()) { - // Notify the handler that loading has started. - handler->HandleLoadStart(browser_, browser_->UIT_GetCefFrame(frame)); + CefRefPtr client = browser_->GetClient(); + if (client.get()) { + CefRefPtr handler = client->GetLoadHandler(); + if (handler.get()) { + // Notify the handler that loading has started. + handler->OnLoadStart(browser_, browser_->UIT_GetCefFrame(frame)); + } } // Apply zoom settings only on top-level frames. - if(is_main_frame) { + if (is_main_frame) { // Restore the zoom value that we have for this URL, if any. double zoomLevel = 0.0; ZoomMap::GetInstance()->get(frame->url(), zoomLevel); @@ -802,18 +856,21 @@ void BrowserWebViewDelegate::didCommitProvisionalLoad( } void BrowserWebViewDelegate::didClearWindowObject(WebFrame* frame) { - CefRefPtr handler = browser_->GetHandler(); - if(handler.get()) { - v8::HandleScope handle_scope; - v8::Handle context = webkit_glue::GetV8Context(frame); - if(context.IsEmpty()) - return; + CefRefPtr client = browser_->GetClient(); + if (client.get()) { + CefRefPtr handler = client->GetJSBindingHandler(); + if (handler.get()) { + v8::HandleScope handle_scope; + v8::Handle context = webkit_glue::GetV8Context(frame); + if(context.IsEmpty()) + return; - v8::Context::Scope scope(context); + v8::Context::Scope scope(context); - CefRefPtr cframe(browser_->UIT_GetCefFrame(frame)); - CefRefPtr object = new CefV8ValueImpl(context->Global()); - handler->HandleJSBinding(browser_, cframe, object); + CefRefPtr cframe(browser_->UIT_GetCefFrame(frame)); + CefRefPtr object = new CefV8ValueImpl(context->Global()); + handler->OnJSBinding(browser_, cframe, object); + } } } @@ -823,10 +880,13 @@ void BrowserWebViewDelegate::didReceiveTitle( if (is_main_frame) { CefString titleStr = string16(title); browser_->UIT_SetTitle(titleStr); - CefRefPtr handler = browser_->GetHandler(); - if(handler.get()) { - // Notify the handler of a page title change - handler->HandleTitleChange(browser_, titleStr); + CefRefPtr client = browser_->GetClient(); + if (client.get()) { + CefRefPtr handler = client->GetDisplayHandler(); + if (handler.get()) { + // Notify the handler of a page title change + handler->OnTitleChange(browser_, titleStr); + } } } } @@ -955,34 +1015,42 @@ void BrowserWebViewDelegate::WaitForPolicyDelegate() { // Private methods ----------------------------------------------------------- void BrowserWebViewDelegate::ShowStatus(const WebString& text, - CefHandler::StatusType type) + cef_handler_statustype_t type) { - CefRefPtr handler = browser_->GetHandler(); - if(handler.get()) { - CefString textStr = string16(text); - handler->HandleStatus(browser_, textStr, type); + CefRefPtr client = browser_->GetClient(); + if (client.get()) { + CefRefPtr handler = client->GetDisplayHandler(); + if (handler.get()) { + CefString textStr = string16(text); + handler->OnStatusMessage(browser_, textStr, type); + } } } void BrowserWebViewDelegate::LocationChangeDone(WebFrame* frame) { - CefRefPtr handler = browser_->GetHandler(); - if (!handler.get()) + CefRefPtr client = browser_->GetClient(); + if (!client.get()) return; - + bool is_main_frame = (frame->parent() == 0); if (is_main_frame) { CefString title = browser_->UIT_GetTitle(); if (title.empty()) { // No title was provided by the page, so send a blank string to the // client. - handler->HandleTitleChange(browser_, title); + CefRefPtr handler = client->GetDisplayHandler(); + if (handler.get()) + handler->OnTitleChange(browser_, title); } } - // Notify the handler that loading has ended. - int httpStatusCode = frame->dataSource()->response().httpStatusCode(); - handler->HandleLoadEnd(browser_, browser_->UIT_GetCefFrame(frame), - httpStatusCode); + CefRefPtr handler = client->GetLoadHandler(); + if (handler.get()) { + // Notify the handler that loading has ended. + int httpStatusCode = frame->dataSource()->response().httpStatusCode(); + handler->OnLoadEnd(browser_, browser_->UIT_GetCefFrame(frame), + httpStatusCode); + } } WebWidgetHost* BrowserWebViewDelegate::GetWidgetHost() { @@ -1043,13 +1111,15 @@ void BrowserWebViewDelegate::UpdateURL(WebFrame* frame) { } bool is_main_frame = (frame->parent() == 0); - CefRefPtr handler = browser_->GetHandler(); + CefRefPtr client = browser_->GetClient(); - if (is_main_frame && handler.get()) { - // Notify the handler of an address change - std::string url = std::string(entry->GetURL().spec().c_str()); - handler->HandleAddressChange(browser_, browser_->UIT_GetCefFrame(frame), - url); + if (is_main_frame && client.get()) { + CefRefPtr handler = client->GetDisplayHandler(); + if (handler.get()) { + // Notify the handler of an address change + std::string url = std::string(entry->GetURL().spec().c_str()); + handler->OnAddressChange(browser_, browser_->UIT_GetCefFrame(frame), url); + } } const WebHistoryItem& history_item = frame->currentHistoryItem(); @@ -1070,10 +1140,10 @@ void BrowserWebViewDelegate::UpdateURL(WebFrame* frame) { if (old_can_go_back != new_can_go_back || old_can_go_forward != new_can_go_forward) { browser_->set_nav_state(new_can_go_back, new_can_go_forward); + CefRefPtr handler = client->GetDisplayHandler(); if (handler.get()) { // Notify the handler of a navigation state change - handler->HandleNavStateChange(browser_, new_can_go_back, - new_can_go_forward); + handler->OnNavStateChange(browser_, new_can_go_back, new_can_go_forward); } } } diff --git a/libcef/browser_webview_delegate.h b/libcef/browser_webview_delegate.h index 4c18d0a26..24e14279d 100644 --- a/libcef/browser_webview_delegate.h +++ b/libcef/browser_webview_delegate.h @@ -54,155 +54,156 @@ class BrowserWebViewDelegate : public WebKit::WebViewClient, // WebKit::WebViewClient virtual WebKit::WebView* createView( WebKit::WebFrame* creator, const WebKit::WebURLRequest& request, - const WebKit::WebWindowFeatures& features, const WebKit::WebString& name); - virtual WebKit::WebWidget* createPopupMenu(WebKit::WebPopupType popup_type); + const WebKit::WebWindowFeatures& features, const WebKit::WebString& name) + OVERRIDE; + virtual WebKit::WebWidget* createPopupMenu(WebKit::WebPopupType popup_type) + OVERRIDE; virtual WebKit::WebExternalPopupMenu* createExternalPopupMenu( const WebKit::WebPopupMenuInfo& info, - WebKit::WebExternalPopupMenuClient* client); + WebKit::WebExternalPopupMenuClient* client) OVERRIDE; virtual WebKit::WebStorageNamespace* createSessionStorageNamespace( - unsigned quota); + unsigned quota) OVERRIDE; virtual void didAddMessageToConsole( const WebKit::WebConsoleMessage& message, - const WebKit::WebString& source_name, unsigned source_line); - virtual void printPage(WebKit::WebFrame* frame); - virtual bool shouldBeginEditing(const WebKit::WebRange& range); - virtual bool shouldEndEditing(const WebKit::WebRange& range); + const WebKit::WebString& source_name, unsigned source_line) OVERRIDE; + virtual void printPage(WebKit::WebFrame* frame) OVERRIDE; + virtual bool shouldBeginEditing(const WebKit::WebRange& range) OVERRIDE; + virtual bool shouldEndEditing(const WebKit::WebRange& range) OVERRIDE; virtual bool shouldInsertNode( const WebKit::WebNode& node, const WebKit::WebRange& range, - WebKit::WebEditingAction action); + WebKit::WebEditingAction action) OVERRIDE; virtual bool shouldInsertText( const WebKit::WebString& text, const WebKit::WebRange& range, - WebKit::WebEditingAction action); + WebKit::WebEditingAction action) OVERRIDE; virtual bool shouldChangeSelectedRange( const WebKit::WebRange& from, const WebKit::WebRange& to, - WebKit::WebTextAffinity affinity, bool still_selecting); - virtual bool shouldDeleteRange(const WebKit::WebRange& range); + WebKit::WebTextAffinity affinity, bool still_selecting) OVERRIDE; + virtual bool shouldDeleteRange(const WebKit::WebRange& range) OVERRIDE; virtual bool shouldApplyStyle( - const WebKit::WebString& style, const WebKit::WebRange& range); - virtual bool isSmartInsertDeleteEnabled(); - virtual bool isSelectTrailingWhitespaceEnabled(); - virtual bool handleCurrentKeyboardEvent(); + const WebKit::WebString& style, const WebKit::WebRange& range) OVERRIDE; + virtual bool isSmartInsertDeleteEnabled() OVERRIDE; + virtual bool isSelectTrailingWhitespaceEnabled() OVERRIDE; + virtual bool handleCurrentKeyboardEvent() OVERRIDE; virtual bool runFileChooser( const WebKit::WebFileChooserParams& params, - WebKit::WebFileChooserCompletion* chooser_completion); + WebKit::WebFileChooserCompletion* chooser_completion) OVERRIDE; virtual void runModalAlertDialog( - WebKit::WebFrame* frame, const WebKit::WebString& message); + WebKit::WebFrame* frame, const WebKit::WebString& message) OVERRIDE; virtual bool runModalConfirmDialog( - WebKit::WebFrame* frame, const WebKit::WebString& message); + WebKit::WebFrame* frame, const WebKit::WebString& message) OVERRIDE; virtual bool runModalPromptDialog( WebKit::WebFrame* frame, const WebKit::WebString& message, - const WebKit::WebString& default_value, WebKit::WebString* actual_value); + const WebKit::WebString& default_value, WebKit::WebString* actual_value) + OVERRIDE; virtual bool runModalBeforeUnloadDialog( - WebKit::WebFrame* frame, const WebKit::WebString& message); + WebKit::WebFrame* frame, const WebKit::WebString& message) OVERRIDE; virtual void showContextMenu( - WebKit::WebFrame* frame, const WebKit::WebContextMenuData& data); - virtual void setStatusText(const WebKit::WebString& text); - virtual void setMouseOverURL(const WebKit::WebURL& url); - virtual void setKeyboardFocusURL(const WebKit::WebURL& url); + WebKit::WebFrame* frame, const WebKit::WebContextMenuData& data) OVERRIDE; + virtual void setStatusText(const WebKit::WebString& text) OVERRIDE; + virtual void setMouseOverURL(const WebKit::WebURL& url) OVERRIDE; + virtual void setKeyboardFocusURL(const WebKit::WebURL& url) OVERRIDE; virtual void setToolTipText( - const WebKit::WebString& text, WebKit::WebTextDirection hint); + const WebKit::WebString& text, WebKit::WebTextDirection hint) OVERRIDE; virtual void startDragging( const WebKit::WebDragData& data, WebKit::WebDragOperationsMask mask, const WebKit::WebImage& image, - const WebKit::WebPoint& image_offset); - virtual bool acceptsLoadDrops() { return true; } - virtual void focusNext(); - virtual void focusPrevious(); - virtual void navigateBackForwardSoon(int offset); - virtual int historyBackListCount(); - virtual int historyForwardListCount(); + const WebKit::WebPoint& image_offset) OVERRIDE; + virtual bool acceptsLoadDrops() OVERRIDE { return true; } + virtual void focusNext() OVERRIDE; + virtual void focusPrevious() OVERRIDE; + virtual void navigateBackForwardSoon(int offset) OVERRIDE; + virtual int historyBackListCount() OVERRIDE; + virtual int historyForwardListCount() OVERRIDE; // WebKit::WebWidgetClient - virtual void didInvalidateRect(const WebKit::WebRect& rect); + virtual void didInvalidateRect(const WebKit::WebRect& rect) OVERRIDE; virtual void didScrollRect(int dx, int dy, - const WebKit::WebRect& clip_rect); - virtual void scheduleComposite(); - virtual void scheduleAnimation(); - virtual void didFocus(); - virtual void didBlur(); - virtual void didChangeCursor(const WebKit::WebCursorInfo& cursor); - virtual void closeWidgetSoon(); - virtual void show(WebKit::WebNavigationPolicy policy); - virtual void runModal(); - virtual WebKit::WebRect windowRect(); - virtual void setWindowRect(const WebKit::WebRect& rect); - virtual WebKit::WebRect rootWindowRect(); - virtual WebKit::WebRect windowResizerRect(); - virtual WebKit::WebScreenInfo screenInfo(); + const WebKit::WebRect& clip_rect) OVERRIDE; + virtual void scheduleComposite() OVERRIDE; + virtual void scheduleAnimation() OVERRIDE; + virtual void didFocus() OVERRIDE; + virtual void didBlur() OVERRIDE; + virtual void didChangeCursor(const WebKit::WebCursorInfo& cursor) OVERRIDE; + virtual void closeWidgetSoon() OVERRIDE; + virtual void show(WebKit::WebNavigationPolicy policy) OVERRIDE; + virtual void runModal() OVERRIDE; + virtual WebKit::WebRect windowRect() OVERRIDE; + virtual void setWindowRect(const WebKit::WebRect& rect) OVERRIDE; + virtual WebKit::WebRect rootWindowRect() OVERRIDE; + virtual WebKit::WebRect windowResizerRect() OVERRIDE; + virtual WebKit::WebScreenInfo screenInfo() OVERRIDE; // WebKit::WebFrameClient virtual WebKit::WebPlugin* createPlugin( - WebKit::WebFrame*, const WebKit::WebPluginParams&); + WebKit::WebFrame*, const WebKit::WebPluginParams&) OVERRIDE; virtual WebKit::WebWorker* createWorker( - WebKit::WebFrame*, WebKit::WebWorkerClient*); + WebKit::WebFrame*, WebKit::WebWorkerClient*) OVERRIDE; virtual WebKit::WebMediaPlayer* createMediaPlayer( - WebKit::WebFrame*, WebKit::WebMediaPlayerClient*); + WebKit::WebFrame*, WebKit::WebMediaPlayerClient*) OVERRIDE; virtual WebKit::WebApplicationCacheHost* createApplicationCacheHost( - WebKit::WebFrame* frame, WebKit::WebApplicationCacheHostClient* client); - virtual void willClose(WebKit::WebFrame*); + WebKit::WebFrame* frame, WebKit::WebApplicationCacheHostClient* client) + OVERRIDE; + virtual void willClose(WebKit::WebFrame*) OVERRIDE; virtual void loadURLExternally( WebKit::WebFrame*, const WebKit::WebURLRequest&, - WebKit::WebNavigationPolicy); + WebKit::WebNavigationPolicy) OVERRIDE; virtual WebKit::WebNavigationPolicy decidePolicyForNavigation( WebKit::WebFrame*, const WebKit::WebURLRequest&, WebKit::WebNavigationType, const WebKit::WebNode&, - WebKit::WebNavigationPolicy default_policy, bool isRedirect); + WebKit::WebNavigationPolicy default_policy, bool isRedirect) OVERRIDE; virtual bool canHandleRequest( - WebKit::WebFrame*, const WebKit::WebURLRequest&) { return true; } + WebKit::WebFrame*, const WebKit::WebURLRequest&) OVERRIDE { return true; } virtual WebKit::WebURLError cannotHandleRequestError( - WebKit::WebFrame*, const WebKit::WebURLRequest& request); + WebKit::WebFrame*, const WebKit::WebURLRequest& request) OVERRIDE; virtual WebKit::WebURLError cancelledError( - WebKit::WebFrame*, const WebKit::WebURLRequest& request); + WebKit::WebFrame*, const WebKit::WebURLRequest& request) OVERRIDE; virtual void didCreateDataSource( - WebKit::WebFrame*, WebKit::WebDataSource*); - virtual void didStartProvisionalLoad(WebKit::WebFrame*); - virtual void didReceiveServerRedirectForProvisionalLoad(WebKit::WebFrame*); + WebKit::WebFrame*, WebKit::WebDataSource*) OVERRIDE; + virtual void didStartProvisionalLoad(WebKit::WebFrame*) OVERRIDE; + virtual void didReceiveServerRedirectForProvisionalLoad(WebKit::WebFrame*) + OVERRIDE; virtual void didFailProvisionalLoad( - WebKit::WebFrame*, const WebKit::WebURLError&); + WebKit::WebFrame*, const WebKit::WebURLError&) OVERRIDE; virtual void didCommitProvisionalLoad( - WebKit::WebFrame*, bool is_new_navigation); - virtual void didClearWindowObject(WebKit::WebFrame*); + WebKit::WebFrame*, bool is_new_navigation) OVERRIDE; + virtual void didClearWindowObject(WebKit::WebFrame*) OVERRIDE; virtual void didReceiveTitle( WebKit::WebFrame*, const WebKit::WebString& title, - WebKit::WebTextDirection direction); + WebKit::WebTextDirection direction) OVERRIDE; virtual void didFailLoad( - WebKit::WebFrame*, const WebKit::WebURLError&); - virtual void didFinishLoad(WebKit::WebFrame*); + WebKit::WebFrame*, const WebKit::WebURLError&) OVERRIDE; + virtual void didFinishLoad(WebKit::WebFrame*) OVERRIDE; virtual void didNavigateWithinPage( - WebKit::WebFrame*, bool isNewNavigation); + WebKit::WebFrame*, bool isNewNavigation) OVERRIDE; virtual void willSendRequest( WebKit::WebFrame*, unsigned identifier, WebKit::WebURLRequest&, - const WebKit::WebURLResponse& redirectResponse); + const WebKit::WebURLResponse& redirectResponse) OVERRIDE; virtual void reportFindInPageMatchCount( - int request_id, int count, bool final_update); + int request_id, int count, bool final_update) OVERRIDE; virtual void reportFindInPageSelection( - int request_id, int active_match_ordinal, const WebKit::WebRect& sel); + int request_id, int active_match_ordinal, const WebKit::WebRect& sel) + OVERRIDE; virtual void openFileSystem( WebKit::WebFrame* frame, WebKit::WebFileSystem::Type type, long long size, bool create, - WebKit::WebFileSystemCallbacks* callbacks); + WebKit::WebFileSystemCallbacks* callbacks) OVERRIDE; // webkit_glue::WebPluginPageDelegate virtual webkit::npapi::WebPluginDelegate* CreatePluginDelegate( const FilePath& file_path, - const std::string& mime_type); + const std::string& mime_type) OVERRIDE; virtual void CreatedPluginWindow( - gfx::PluginWindowHandle handle); + gfx::PluginWindowHandle handle) OVERRIDE; virtual void WillDestroyPluginWindow( - gfx::PluginWindowHandle handle); + gfx::PluginWindowHandle handle) OVERRIDE; virtual void DidMovePlugin( - const webkit::npapi::WebPluginGeometry& move); - virtual void DidStartLoadingForPlugin() {} - virtual void DidStopLoadingForPlugin() {} - virtual void ShowModalHTMLDialogForPlugin( - const GURL& url, - const gfx::Size& size, - const std::string& json_arguments, - std::string* json_retval) {} - virtual WebKit::WebCookieJar* GetCookieJar(); + const webkit::npapi::WebPluginGeometry& move) OVERRIDE; + virtual void DidStartLoadingForPlugin() OVERRIDE {} + virtual void DidStopLoadingForPlugin() OVERRIDE {} + virtual WebKit::WebCookieJar* GetCookieJar() OVERRIDE; BrowserWebViewDelegate(CefBrowserImpl* browser); ~BrowserWebViewDelegate(); @@ -275,7 +276,7 @@ class BrowserWebViewDelegate : public WebKit::WebViewClient, const FilePath& default_file); // Called to show status messages. - void ShowStatus(const WebKit::WebString& text, CefHandler::StatusType type); + void ShowStatus(const WebKit::WebString& text, cef_handler_statustype_t type); // In the Mac code, this is called to trigger the end of a test after the // page has finished loading. From here, we can generate the dump for the diff --git a/libcef/browser_webview_delegate_win.cc b/libcef/browser_webview_delegate_win.cc index 194775f8f..477efabd2 100644 --- a/libcef/browser_webview_delegate_win.cc +++ b/libcef/browser_webview_delegate_win.cc @@ -76,9 +76,12 @@ void BrowserWebViewDelegate::show(WebNavigationPolicy) { ShowWindow(browser_->UIT_GetPopupWndHandle(), SW_SHOWNA); } else { // Notify the handler of popup visibility change. - CefRefPtr handler = browser_->GetHandler(); - if (handler.get()) - handler->HandlePopupChange(browser_, true, CefRect()); + CefRefPtr client = browser_->GetClient(); + if (client.get()) { + CefRefPtr handler = client->GetRenderHandler(); + if (handler.get()) + handler->OnPopupShow(browser_, true); + } } } } @@ -95,9 +98,12 @@ void BrowserWebViewDelegate::didChangeCursor(const WebCursorInfo& cursor_info) { host->SetCursor(hCursor); } else { // Notify the handler of cursor change. - CefRefPtr handler = browser_->GetHandler(); - if (handler.get()) - handler->HandleCursorChange(browser_, hCursor); + CefRefPtr client = browser_->GetClient(); + if (client.get()) { + CefRefPtr handler = client->GetRenderHandler(); + if (handler.get()) + handler->OnCursorChange(browser_, hCursor); + } } } } @@ -110,11 +116,14 @@ WebRect BrowserWebViewDelegate::windowRect() { return gfx::Rect(rect); } else { // Retrieve the view rectangle from the handler. - CefRefPtr handler = browser_->GetHandler(); - if (handler.get()) { - CefRect rect(0, 0, 0, 0); - if (handler->HandleGetRect(browser_, false, rect) == RV_CONTINUE) - return WebRect(rect.x, rect.y, rect.width, rect.height); + CefRefPtr client = browser_->GetClient(); + if (client.get()) { + CefRefPtr handler = client->GetRenderHandler(); + if (handler.get()) { + CefRect rect(0, 0, 0, 0); + if (handler->GetViewRect(browser_, rect)) + return WebRect(rect.x, rect.y, rect.width, rect.height); + } } } } @@ -133,10 +142,13 @@ void BrowserWebViewDelegate::setWindowRect(const WebRect& rect) { browser_->UIT_GetPopupHost()->SetSize(rect.width, rect.height); // Notify the handler of popup size change. - CefRefPtr handler = browser_->GetHandler(); - if (handler.get()) { - handler->HandlePopupChange(browser_, true, - CefRect(rect.x, rect.y, rect.width, rect.height)); + CefRefPtr client = browser_->GetClient(); + if (client.get()) { + CefRefPtr handler = client->GetRenderHandler(); + if (handler.get()) { + handler->OnPopupSize(browser_, + CefRect(rect.x, rect.y, rect.width, rect.height)); + } } } } @@ -278,14 +290,17 @@ void BrowserWebViewDelegate::DidMovePlugin( } static void AddMenuItem(CefRefPtr browser, HMENU menu, int index, - CefHandler::MenuId id, const wchar_t* label, + cef_handler_menuid_t id, const wchar_t* label, bool enabled, std::list& label_list) { CefString actual_label(label); - CefRefPtr handler = browser->GetHandler(); - if(handler.get()) { - // Let the handler change the label if desired - handler->HandleGetMenuLabel(browser, id, actual_label); + CefRefPtr client = browser->GetClient(); + if (client.get()) { + CefRefPtr handler = client->GetMenuHandler(); + if(handler.get()) { + // Let the handler change the label if desired + handler->GetMenuLabel(browser, id, actual_label); + } } // store the label in a list to simplify memory management @@ -364,10 +379,14 @@ void BrowserWebViewDelegate::showContextMenu( if(data.mediaType == WebContextMenuData::MediaTypeAudio) type_flags |= MENUTYPE_AUDIO; - CefRefPtr handler = browser_->GetHandler(); - if(handler.get()) { + CefRefPtr client = browser_->GetClient(); + CefRefPtr handler; + if (client.get()) + handler = client->GetMenuHandler(); + + if (handler.get()) { // Gather menu information - CefHandler::MenuInfo menuInfo; + cef_handler_menuinfo_t menuInfo; memset(&menuInfo, 0, sizeof(menuInfo)); CefString linkStr(std::string(data.linkURL.spec())); @@ -396,15 +415,16 @@ void BrowserWebViewDelegate::showContextMenu( &menuInfo.securityInfo, false); // Notify the handler that a context menu is requested - CefHandler::RetVal rv = handler->HandleBeforeMenu(browser_, menuInfo); - if(rv == RV_HANDLED) + if (handler->OnBeforeMenu(browser_, menuInfo)) goto end; + } - if (browser_->IsWindowRenderingDisabled()) { - rv = handler->HandleGetScreenPoint(browser_, mouse_pt.x, mouse_pt.y, - screenX, screenY); - if(rv != RV_CONTINUE) - goto end; + if (client.get() && browser_->IsWindowRenderingDisabled()) { + CefRefPtr render_handler = client->GetRenderHandler(); + if (render_handler.get() && + !render_handler->GetScreenPoint(browser_, mouse_pt.x, mouse_pt.y, + screenX, screenY)) { + goto end; } } @@ -444,20 +464,20 @@ void BrowserWebViewDelegate::showContextMenu( true, label_list); } - if(menu) { + if (menu) { // show the context menu int selected_id = TrackPopupMenu(menu, TPM_LEFTALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD | TPM_RECURSE, screenX, screenY, 0, browser_->UIT_GetMainWndHandle(), NULL); - if(selected_id != 0) { + if (selected_id != 0) { // An action was chosen - CefHandler::MenuId menuId = static_cast(selected_id); + cef_handler_menuid_t menuId = + static_cast(selected_id); bool handled = false; - if(handler.get()) { + if (handler.get()) { // Ask the handler if it wants to handle the action - CefHandler::RetVal rv = handler->HandleMenuAction(browser_, menuId); - handled = (rv == RV_HANDLED); + handled = handler->OnMenuAction(browser_, menuId); } if(!handled) { diff --git a/libcef/cef_context.cc b/libcef/cef_context.cc index baad557cf..7935cd313 100644 --- a/libcef/cef_context.cc +++ b/libcef/cef_context.cc @@ -158,15 +158,13 @@ void IOT_VisitUrlCookies(const GURL& url, bool includeHttpOnly, } // anonymous -bool CefInitialize(const CefSettings& settings, - const CefBrowserSettings& browser_defaults) +bool CefInitialize(const CefSettings& settings) { // Return true if the global context already exists. if(_Context.get()) return true; - if(settings.size != sizeof(cef_settings_t) || - browser_defaults.size != sizeof(cef_browser_settings_t)) { + if(settings.size != sizeof(cef_settings_t)) { NOTREACHED(); return false; } @@ -175,7 +173,7 @@ bool CefInitialize(const CefSettings& settings, _Context = new CefContext(); // Initialize the global context. - return _Context->Initialize(settings, browser_defaults); + return _Context->Initialize(settings); } void CefShutdown() @@ -477,11 +475,9 @@ CefContext::~CefContext() Shutdown(); } -bool CefContext::Initialize(const CefSettings& settings, - const CefBrowserSettings& browser_defaults) +bool CefContext::Initialize(const CefSettings& settings) { settings_ = settings; - browser_defaults_ = browser_defaults; cache_path_ = FilePath(CefString(&settings.cache_path)); @@ -529,7 +525,7 @@ bool CefContext::AddBrowser(CefRefPtr browser) { bool found = false; - Lock(); + AutoLock lock_scope(this); // check that the browser isn't already in the list before adding BrowserList::const_iterator it = browserlist_.begin(); @@ -545,8 +541,7 @@ bool CefContext::AddBrowser(CefRefPtr browser) browser->UIT_SetUniqueID(next_browser_id_++); browserlist_.push_back(browser); } - - Unlock(); + return !found; } @@ -555,24 +550,24 @@ bool CefContext::RemoveBrowser(CefRefPtr browser) bool deleted = false; bool empty = false; - Lock(); + { + AutoLock lock_scope(this); - BrowserList::iterator it = browserlist_.begin(); - for(; it != browserlist_.end(); ++it) { - if(it->get() == browser.get()) { - browserlist_.erase(it); - deleted = true; - break; + BrowserList::iterator it = browserlist_.begin(); + for(; it != browserlist_.end(); ++it) { + if(it->get() == browser.get()) { + browserlist_.erase(it); + deleted = true; + break; + } + } + + if (browserlist_.empty()) { + next_browser_id_ = kNextBrowserIdReset; + empty = true; } } - if (browserlist_.empty()) { - next_browser_id_ = kNextBrowserIdReset; - empty = true; - } - - Unlock(); - if (empty) { CefThread::PostTask(CefThread::UI, FROM_HERE, NewRunnableFunction(webkit_glue::ClearCache)); @@ -583,20 +578,15 @@ bool CefContext::RemoveBrowser(CefRefPtr browser) CefRefPtr CefContext::GetBrowserByID(int id) { - CefRefPtr browser; - Lock(); + AutoLock lock_scope(this); BrowserList::const_iterator it = browserlist_.begin(); for(; it != browserlist_.end(); ++it) { - if(it->get()->UIT_GetUniqueID() == id) { - browser = it->get(); - break; - } + if(it->get()->UIT_GetUniqueID() == id) + return it->get(); } - Unlock(); - - return browser; + return NULL; } void CefContext::UIT_FinishShutdown(base::WaitableEvent* event) @@ -605,12 +595,13 @@ void CefContext::UIT_FinishShutdown(base::WaitableEvent* event) BrowserList list; - Lock(); - if (!browserlist_.empty()) { - list = browserlist_; - browserlist_.clear(); + { + AutoLock lock_scope(this); + if (!browserlist_.empty()) { + list = browserlist_; + browserlist_.clear(); + } } - Unlock(); // Destroy any remaining browser windows. if (!list.empty()) { diff --git a/libcef/cef_context.h b/libcef/cef_context.h index e477b3cba..a8e9c4d7a 100644 --- a/libcef/cef_context.h +++ b/libcef/cef_context.h @@ -21,7 +21,7 @@ class BrowserRequestContext; class CefBrowserImpl; class WebViewHost; -class CefContext : public CefThreadSafeBase +class CefContext : public CefBase { public: typedef std::list > BrowserList; @@ -30,8 +30,7 @@ public: ~CefContext(); // These methods will be called on the main application thread. - bool Initialize(const CefSettings& settings, - const CefBrowserSettings& browser_defaults); + bool Initialize(const CefSettings& settings); void Shutdown(); // Returns true if the context is initialized. @@ -52,8 +51,6 @@ public: const FilePath& cache_path() const { return cache_path_; } const CefSettings& settings() const { return settings_; } - const CefBrowserSettings& browser_defaults() const - { return browser_defaults_; } // The BrowserRequestContext object is managed by CefProcessIOThread. void set_request_context(BrowserRequestContext* request_context) @@ -92,7 +89,6 @@ private: base::AtExitManager at_exit_manager_; CefSettings settings_; - CefBrowserSettings browser_defaults_; FilePath cache_path_; scoped_refptr request_context_; scoped_ptr storage_context_; @@ -104,6 +100,9 @@ private: int next_browser_id_; WebViewHost* current_webviewhost_; + + IMPLEMENT_REFCOUNTING(CefContext); + IMPLEMENT_LOCKING(CefContext); }; // Global context object pointer. diff --git a/libcef/dom_document_impl.h b/libcef/dom_document_impl.h index 09326a83f..b70f8c8fb 100644 --- a/libcef/dom_document_impl.h +++ b/libcef/dom_document_impl.h @@ -15,29 +15,29 @@ class WebNode; class CefBrowserImpl; -class CefDOMDocumentImpl : public CefThreadSafeBase +class CefDOMDocumentImpl : public CefDOMDocument { public: CefDOMDocumentImpl(CefBrowserImpl* browser, WebKit::WebFrame* frame); virtual ~CefDOMDocumentImpl(); - virtual Type GetType(); - virtual CefRefPtr GetDocument(); - virtual CefRefPtr GetBody(); - virtual CefRefPtr GetHead(); - virtual CefString GetTitle(); - virtual CefRefPtr GetElementById(const CefString& id); - virtual CefRefPtr GetFocusedNode(); - virtual bool HasSelection(); - virtual CefRefPtr GetSelectionStartNode(); - virtual int GetSelectionStartOffset(); - virtual CefRefPtr GetSelectionEndNode(); - virtual int GetSelectionEndOffset(); - virtual CefString GetSelectionAsMarkup(); - virtual CefString GetSelectionAsText(); - virtual CefString GetBaseURL(); - virtual CefString GetCompleteURL(const CefString& partialURL); + virtual Type GetType() OVERRIDE; + virtual CefRefPtr GetDocument() OVERRIDE; + virtual CefRefPtr GetBody() OVERRIDE; + virtual CefRefPtr GetHead() OVERRIDE; + virtual CefString GetTitle() OVERRIDE; + virtual CefRefPtr GetElementById(const CefString& id) OVERRIDE; + virtual CefRefPtr GetFocusedNode() OVERRIDE; + virtual bool HasSelection() OVERRIDE; + virtual CefRefPtr GetSelectionStartNode() OVERRIDE; + virtual int GetSelectionStartOffset() OVERRIDE; + virtual CefRefPtr GetSelectionEndNode() OVERRIDE; + virtual int GetSelectionEndOffset() OVERRIDE; + virtual CefString GetSelectionAsMarkup() OVERRIDE; + virtual CefString GetSelectionAsText() OVERRIDE; + virtual CefString GetBaseURL() OVERRIDE; + virtual CefString GetCompleteURL(const CefString& partialURL) OVERRIDE; CefBrowserImpl* GetBrowser() { return browser_; } WebKit::WebFrame* GetFrame() { return frame_; } @@ -58,6 +58,8 @@ protected: typedef std::map NodeMap; NodeMap node_map_; + + IMPLEMENT_REFCOUNTING(CefDOMDocumentImpl); }; #endif // _DOM_DOCUMENT_IMPL_H diff --git a/libcef/dom_event_impl.h b/libcef/dom_event_impl.h index e1ad1a7d8..377ad15ad 100644 --- a/libcef/dom_event_impl.h +++ b/libcef/dom_event_impl.h @@ -10,21 +10,21 @@ class CefDOMDocumentImpl; -class CefDOMEventImpl : public CefThreadSafeBase +class CefDOMEventImpl : public CefDOMEvent { public: CefDOMEventImpl(CefRefPtr document, const WebKit::WebDOMEvent& event); virtual ~CefDOMEventImpl(); - virtual CefString GetType(); - virtual Category GetCategory(); - virtual Phase GetPhase(); - virtual bool CanBubble(); - virtual bool CanCancel(); - virtual CefRefPtr GetDocument(); - virtual CefRefPtr GetTarget(); - virtual CefRefPtr GetCurrentTarget(); + virtual CefString GetType() OVERRIDE; + virtual Category GetCategory() OVERRIDE; + virtual Phase GetPhase() OVERRIDE; + virtual bool CanBubble() OVERRIDE; + virtual bool CanCancel() OVERRIDE; + virtual CefRefPtr GetDocument() OVERRIDE; + virtual CefRefPtr GetTarget() OVERRIDE; + virtual CefRefPtr GetCurrentTarget() OVERRIDE; // Will be called from CefDOMEventListenerWrapper::handleEvent(). void Detach(); @@ -35,6 +35,8 @@ public: protected: CefRefPtr document_; WebKit::WebDOMEvent event_; + + IMPLEMENT_REFCOUNTING(CefDOMEventImpl); }; #endif // _DOM_EVENT_IMPL_H diff --git a/libcef/dom_node_impl.h b/libcef/dom_node_impl.h index 14a858df3..8c74e8d4c 100644 --- a/libcef/dom_node_impl.h +++ b/libcef/dom_node_impl.h @@ -10,39 +10,39 @@ class CefDOMDocumentImpl; -class CefDOMNodeImpl : public CefThreadSafeBase +class CefDOMNodeImpl : public CefDOMNode { public: CefDOMNodeImpl(CefRefPtr document, const WebKit::WebNode& node); virtual ~CefDOMNodeImpl(); - virtual Type GetType(); - virtual bool IsText(); - virtual bool IsElement(); - virtual bool IsSame(CefRefPtr that); - virtual CefString GetName(); - virtual CefString GetValue(); - virtual bool SetValue(const CefString& value); - virtual CefString GetAsMarkup(); - virtual CefRefPtr GetDocument(); - virtual CefRefPtr GetParent(); - virtual CefRefPtr GetPreviousSibling(); - virtual CefRefPtr GetNextSibling(); - virtual bool HasChildren(); - virtual CefRefPtr GetFirstChild(); - virtual CefRefPtr GetLastChild(); + virtual Type GetType() OVERRIDE; + virtual bool IsText() OVERRIDE; + virtual bool IsElement() OVERRIDE; + virtual bool IsSame(CefRefPtr that) OVERRIDE; + virtual CefString GetName() OVERRIDE; + virtual CefString GetValue() OVERRIDE; + virtual bool SetValue(const CefString& value) OVERRIDE; + virtual CefString GetAsMarkup() OVERRIDE; + virtual CefRefPtr GetDocument() OVERRIDE; + virtual CefRefPtr GetParent() OVERRIDE; + virtual CefRefPtr GetPreviousSibling() OVERRIDE; + virtual CefRefPtr GetNextSibling() OVERRIDE; + virtual bool HasChildren() OVERRIDE; + virtual CefRefPtr GetFirstChild() OVERRIDE; + virtual CefRefPtr GetLastChild() OVERRIDE; virtual void AddEventListener(const CefString& eventType, CefRefPtr listener, - bool useCapture); - virtual CefString GetElementTagName(); - virtual bool HasElementAttributes(); - virtual bool HasElementAttribute(const CefString& attrName); - virtual CefString GetElementAttribute(const CefString& attrName); - virtual void GetElementAttributes(AttributeMap& attrMap); + bool useCapture) OVERRIDE; + virtual CefString GetElementTagName() OVERRIDE; + virtual bool HasElementAttributes() OVERRIDE; + virtual bool HasElementAttribute(const CefString& attrName) OVERRIDE; + virtual CefString GetElementAttribute(const CefString& attrName) OVERRIDE; + virtual void GetElementAttributes(AttributeMap& attrMap) OVERRIDE; virtual bool SetElementAttribute(const CefString& attrName, - const CefString& value); - virtual CefString GetElementInnerText(); + const CefString& value) OVERRIDE; + virtual CefString GetElementInnerText() OVERRIDE; // Will be called from CefDOMDocumentImpl::Detach(). void Detach(); @@ -53,6 +53,8 @@ public: protected: CefRefPtr document_; WebKit::WebNode node_; + + IMPLEMENT_REFCOUNTING(CefDOMNodeImpl); }; #endif // _DOM_NODE_IMPL_H diff --git a/libcef/request_impl.h b/libcef/request_impl.h index 66c62113b..5906a393e 100644 --- a/libcef/request_impl.h +++ b/libcef/request_impl.h @@ -16,28 +16,28 @@ class URLRequest; }; // Implementation of CefRequest -class CefRequestImpl : public CefThreadSafeBase +class CefRequestImpl : public CefRequest { public: CefRequestImpl(); ~CefRequestImpl() {} - virtual CefString GetURL(); - virtual void SetURL(const CefString& url); - virtual CefString GetMethod(); - virtual void SetMethod(const CefString& method); - virtual CefRefPtr GetPostData(); - virtual void SetPostData(CefRefPtr postData); - virtual void GetHeaderMap(HeaderMap& headerMap); - virtual void SetHeaderMap(const HeaderMap& headerMap); + virtual CefString GetURL() OVERRIDE; + virtual void SetURL(const CefString& url) OVERRIDE; + virtual CefString GetMethod() OVERRIDE; + virtual void SetMethod(const CefString& method) OVERRIDE; + virtual CefRefPtr GetPostData() OVERRIDE; + virtual void SetPostData(CefRefPtr postData) OVERRIDE; + virtual void GetHeaderMap(HeaderMap& headerMap) OVERRIDE; + virtual void SetHeaderMap(const HeaderMap& headerMap) OVERRIDE; virtual void Set(const CefString& url, const CefString& method, CefRefPtr postData, - const HeaderMap& headerMap); - virtual RequestFlags GetFlags(); - virtual void SetFlags(RequestFlags flags); - virtual CefString GetFirstPartyForCookies(); - virtual void SetFirstPartyForCookies(const CefString& url); + const HeaderMap& headerMap) OVERRIDE; + virtual RequestFlags GetFlags() OVERRIDE; + virtual void SetFlags(RequestFlags flags) OVERRIDE; + virtual CefString GetFirstPartyForCookies() OVERRIDE; + virtual void SetFirstPartyForCookies(const CefString& url) OVERRIDE; void Set(net::URLRequest* request); void Set(const WebKit::WebURLRequest& request); @@ -59,19 +59,22 @@ protected: // The below methods are used by WebURLRequest. RequestFlags flags_; CefString first_party_for_cookies_; + + IMPLEMENT_REFCOUNTING(CefRequestImpl); + IMPLEMENT_LOCKING(CefRequestImpl); }; // Implementation of CefPostData -class CefPostDataImpl : public CefThreadSafeBase +class CefPostDataImpl : public CefPostData { public: CefPostDataImpl(); ~CefPostDataImpl() {} - virtual size_t GetElementCount(); - virtual void GetElements(ElementVector& elements); - virtual bool RemoveElement(CefRefPtr element); - virtual bool AddElement(CefRefPtr element); + virtual size_t GetElementCount() OVERRIDE; + virtual void GetElements(ElementVector& elements) OVERRIDE; + virtual bool RemoveElement(CefRefPtr element) OVERRIDE; + virtual bool AddElement(CefRefPtr element) OVERRIDE; virtual void RemoveElements(); void Set(net::UploadData& data); @@ -81,22 +84,25 @@ public: protected: ElementVector elements_; + + IMPLEMENT_REFCOUNTING(CefPostDataImpl); + IMPLEMENT_LOCKING(CefPostDataImpl); }; // Implementation of CefPostDataElement -class CefPostDataElementImpl : public CefThreadSafeBase +class CefPostDataElementImpl : public CefPostDataElement { public: CefPostDataElementImpl(); ~CefPostDataElementImpl(); - virtual void SetToEmpty(); - virtual void SetToFile(const CefString& fileName); - virtual void SetToBytes(size_t size, const void* bytes); - virtual Type GetType(); - virtual CefString GetFile(); - virtual size_t GetBytesCount(); - virtual size_t GetBytes(size_t size, void* bytes); + virtual void SetToEmpty() OVERRIDE; + virtual void SetToFile(const CefString& fileName) OVERRIDE; + virtual void SetToBytes(size_t size, const void* bytes) OVERRIDE; + virtual Type GetType() OVERRIDE; + virtual CefString GetFile() OVERRIDE; + virtual size_t GetBytesCount() OVERRIDE; + virtual size_t GetBytes(size_t size, void* bytes) OVERRIDE; void* GetBytes() { return data_.bytes.bytes; } @@ -114,6 +120,9 @@ protected: } bytes; cef_string_t filename; } data_; + + IMPLEMENT_REFCOUNTING(CefPostDataElementImpl); + IMPLEMENT_LOCKING(CefPostDataElementImpl); }; #endif // _REQUEST_IMPL_H diff --git a/libcef/response_impl.h b/libcef/response_impl.h index 99426bf29..4d3f64e47 100644 --- a/libcef/response_impl.h +++ b/libcef/response_impl.h @@ -12,7 +12,7 @@ class WebURLResponse; }; // Implementation of CefResponse. -class CefResponseImpl : public CefThreadSafeBase +class CefResponseImpl : public CefResponse { public: CefResponseImpl(); @@ -37,6 +37,9 @@ protected: CefString status_text_; CefString mime_type_; HeaderMap header_map_; + + IMPLEMENT_REFCOUNTING(CefResponseImpl); + IMPLEMENT_LOCKING(CefResponseImpl); }; #endif // _RESPONSE_IMPL_H diff --git a/libcef/scheme_impl.cc b/libcef/scheme_impl.cc index 40d676917..abe543eb4 100644 --- a/libcef/scheme_impl.cc +++ b/libcef/scheme_impl.cc @@ -58,7 +58,7 @@ public: virtual ~CefUrlRequestJob(){} - virtual void Start() + virtual void Start() OVERRIDE { handler_->Cancel(); // Continue asynchronously. @@ -70,7 +70,7 @@ public: return; } - virtual void Kill() + virtual void Kill() OVERRIDE { if (async_resolver_) { async_resolver_->Cancel(); @@ -81,6 +81,7 @@ public: } virtual bool ReadRawData(net::IOBuffer* dest, int dest_size, int *bytes_read) + OVERRIDE { DCHECK_NE(dest_size, 0); DCHECK(bytes_read); @@ -119,7 +120,7 @@ public: } } - virtual void GetResponseInfo(net::HttpResponseInfo* info) { + virtual void GetResponseInfo(net::HttpResponseInfo* info) OVERRIDE { CefResponseImpl* responseImpl = static_cast(response_.get()); scoped_refptr headers( @@ -128,6 +129,7 @@ public: } virtual bool IsRedirectResponse(GURL* location, int* http_status_code) + OVERRIDE { if (redirect_url_.is_valid()) { // Redirect to the new URL. @@ -138,7 +140,7 @@ public: return false; } - virtual bool GetMimeType(std::string* mime_type) const + virtual bool GetMimeType(std::string* mime_type) const OVERRIDE { DCHECK(request_); // call handler to get mime type @@ -146,10 +148,6 @@ public: return true; } - virtual void SetExtraRequestHeaders(const std::string& headers) - { - } - CefRefPtr handler_; CefRefPtr response_; int response_length_; @@ -376,7 +374,7 @@ private: CefUrlRequestFilter* CefUrlRequestFilter::shared_instance_ = NULL; -class SchemeRequestJobWrapper : public CefThreadSafeBase { +class SchemeRequestJobWrapper : public CefBase { public: SchemeRequestJobWrapper(const std::string& scheme_name, const std::string& host_name, @@ -411,6 +409,8 @@ private: std::string host_name_; bool is_standard_; CefSchemeHandlerFactory* factory_; + + IMPLEMENT_REFCOUNTING(SchemeRequestJobWrapper); }; bool CefRegisterScheme(const CefString& scheme_name, diff --git a/libcef/stream_impl.cc b/libcef/stream_impl.cc index c129af144..b917e6e00 100644 --- a/libcef/stream_impl.cc +++ b/libcef/stream_impl.cc @@ -72,42 +72,33 @@ CefFileReader::CefFileReader(FILE* file, bool close) CefFileReader::~CefFileReader() { - Lock(); + AutoLock lock_scope(this); if(close_) fclose(file_); - Unlock(); } size_t CefFileReader::Read(void* ptr, size_t size, size_t n) { - Lock(); - size_t rv = fread(ptr, size, n, file_); - Unlock(); - return rv; + AutoLock lock_scope(this); + return fread(ptr, size, n, file_); } int CefFileReader::Seek(long offset, int whence) { - Lock(); - int rv = fseek(file_, offset, whence); - Unlock(); - return rv; + AutoLock lock_scope(this); + return fseek(file_, offset, whence); } long CefFileReader::Tell() { - Lock(); - long rv = ftell(file_); - Unlock(); - return rv; + AutoLock lock_scope(this); + return ftell(file_); } int CefFileReader::Eof() { - Lock(); - int rv = feof(file_); - Unlock(); - return rv; + AutoLock lock_scope(this); + return feof(file_); } @@ -120,42 +111,33 @@ CefFileWriter::CefFileWriter(FILE* file, bool close) CefFileWriter::~CefFileWriter() { - Lock(); + AutoLock lock_scope(this); if(close_) fclose(file_); - Unlock(); } size_t CefFileWriter::Write(const void* ptr, size_t size, size_t n) { - Lock(); - size_t rv = (size_t)fwrite(ptr, size, n, file_); - Unlock(); - return rv; + AutoLock lock_scope(this); + return (size_t)fwrite(ptr, size, n, file_); } int CefFileWriter::Seek(long offset, int whence) { - Lock(); - int rv = fseek(file_, offset, whence); - Unlock(); - return rv; + AutoLock lock_scope(this); + return fseek(file_, offset, whence); } long CefFileWriter::Tell() { - Lock(); - long rv = ftell(file_); - Unlock(); - return rv; + AutoLock lock_scope(this); + return ftell(file_); } int CefFileWriter::Flush() { - Lock(); - int rv = fflush(file_); - Unlock(); - return rv; + AutoLock lock_scope(this); + return fflush(file_); } @@ -174,19 +156,18 @@ CefBytesReader::~CefBytesReader() size_t CefBytesReader::Read(void* ptr, size_t size, size_t n) { - Lock(); + AutoLock lock_scope(this); size_t s = (datasize_ - offset_) / size; size_t ret = (n < s ? n : s); memcpy(ptr, ((char*)data_) + offset_, ret * size); offset_ += ret * size; - Unlock(); - return ret; + return ret; } int CefBytesReader::Seek(long offset, int whence) { int rv = -1L; - Lock(); + AutoLock lock_scope(this); switch(whence) { case SEEK_CUR: if(offset_ + offset > datasize_) { @@ -210,30 +191,25 @@ int CefBytesReader::Seek(long offset, int whence) rv = 0; break; } - Unlock(); - + return rv; } long CefBytesReader::Tell() { - Lock(); - long rv = offset_; - Unlock(); - return rv; + AutoLock lock_scope(this); + return offset_; } int CefBytesReader::Eof() { - Lock(); - int rv = (offset_ >= datasize_); - Unlock(); - return rv; + AutoLock lock_scope(this); + return (offset_ >= datasize_); } void CefBytesReader::SetData(void* data, long datasize, bool copy) { - Lock(); + AutoLock lock_scope(this); if(copy_) free(data_); @@ -249,7 +225,6 @@ void CefBytesReader::SetData(void* data, long datasize, bool copy) } else { data_ = data; } - Unlock(); } @@ -265,15 +240,14 @@ CefBytesWriter::CefBytesWriter(size_t grow) CefBytesWriter::~CefBytesWriter() { - Lock(); + AutoLock lock_scope(this); if(data_) free(data_); - Unlock(); } size_t CefBytesWriter::Write(const void* ptr, size_t size, size_t n) { - Lock(); + AutoLock lock_scope(this); size_t rv; if(offset_ + size * n >= datasize_ && Grow(size * n) == 0) { rv = 0; @@ -282,14 +256,14 @@ size_t CefBytesWriter::Write(const void* ptr, size_t size, size_t n) offset_ += size * n; rv = n; } - Unlock(); + return rv; } int CefBytesWriter::Seek(long offset, int whence) { int rv = -1L; - Lock(); + AutoLock lock_scope(this); switch(whence) { case SEEK_CUR: if(offset_ + offset > datasize_) { @@ -312,17 +286,14 @@ int CefBytesWriter::Seek(long offset, int whence) rv = offset_; break; } - Unlock(); return rv; } long CefBytesWriter::Tell() { - Lock(); - long rv = offset_; - Unlock(); - return rv; + AutoLock lock_scope(this); + return offset_; } int CefBytesWriter::Flush() @@ -332,15 +303,14 @@ int CefBytesWriter::Flush() std::string CefBytesWriter::GetDataString() { - Lock(); + AutoLock lock_scope(this); std::string str((char*)data_, offset_); - Unlock(); return str; } size_t CefBytesWriter::Grow(size_t size) { - Lock(); + AutoLock lock_scope(this); size_t rv; size_t s = (size > grow_ ? size : grow_); void* tmp = realloc(data_, datasize_ + s); @@ -352,6 +322,6 @@ size_t CefBytesWriter::Grow(size_t size) } else { rv = 0; } - Unlock(); + return rv; } diff --git a/libcef/stream_impl.h b/libcef/stream_impl.h index b4fcb41be..90d310b60 100644 --- a/libcef/stream_impl.h +++ b/libcef/stream_impl.h @@ -9,50 +9,56 @@ #include // Implementation of CefStreamReader for files. -class CefFileReader : public CefThreadSafeBase +class CefFileReader : public CefStreamReader { public: CefFileReader(FILE* file, bool close); virtual ~CefFileReader(); - virtual size_t Read(void* ptr, size_t size, size_t n); - virtual int Seek(long offset, int whence); - virtual long Tell(); - virtual int Eof(); + virtual size_t Read(void* ptr, size_t size, size_t n) OVERRIDE; + virtual int Seek(long offset, int whence) OVERRIDE; + virtual long Tell() OVERRIDE; + virtual int Eof() OVERRIDE; protected: bool close_; FILE *file_; + + IMPLEMENT_REFCOUNTING(CefFileReader); + IMPLEMENT_LOCKING(CefFileReader); }; // Implementation of CefStreamWriter for files. -class CefFileWriter : public CefThreadSafeBase +class CefFileWriter : public CefStreamWriter { public: CefFileWriter(FILE* file, bool close); virtual ~CefFileWriter(); - virtual size_t Write(const void* ptr, size_t size, size_t n); - virtual int Seek(long offset, int whence); - virtual long Tell(); - virtual int Flush(); + virtual size_t Write(const void* ptr, size_t size, size_t n) OVERRIDE; + virtual int Seek(long offset, int whence) OVERRIDE; + virtual long Tell() OVERRIDE; + virtual int Flush() OVERRIDE; protected: FILE *file_; bool close_; + + IMPLEMENT_REFCOUNTING(CefFileWriter); + IMPLEMENT_LOCKING(CefFileWriter); }; // Implementation of CefStreamReader for byte buffers. -class CefBytesReader : public CefThreadSafeBase +class CefBytesReader : public CefStreamReader { public: CefBytesReader(void* data, long datasize, bool copy); virtual ~CefBytesReader(); - virtual size_t Read(void* ptr, size_t size, size_t n); - virtual int Seek(long offset, int whence); - virtual long Tell(); - virtual int Eof(); + virtual size_t Read(void* ptr, size_t size, size_t n) OVERRIDE; + virtual int Seek(long offset, int whence) OVERRIDE; + virtual long Tell() OVERRIDE; + virtual int Eof() OVERRIDE; void SetData(void* data, long datasize, bool copy); @@ -64,19 +70,22 @@ protected: size_t datasize_; bool copy_; size_t offset_; + + IMPLEMENT_REFCOUNTING(CefBytesReader); + IMPLEMENT_LOCKING(CefBytesReader); }; // Implementation of CefStreamWriter for byte buffers. -class CefBytesWriter : public CefThreadSafeBase +class CefBytesWriter : public CefStreamWriter { public: CefBytesWriter(size_t grow); virtual ~CefBytesWriter(); - virtual size_t Write(const void* ptr, size_t size, size_t n); - virtual int Seek(long offset, int whence); - virtual long Tell(); - virtual int Flush(); + virtual size_t Write(const void* ptr, size_t size, size_t n) OVERRIDE; + virtual int Seek(long offset, int whence) OVERRIDE; + virtual long Tell() OVERRIDE; + virtual int Flush() OVERRIDE; void* GetData() { return data_; } size_t GetDataSize() { return offset_; } @@ -85,65 +94,71 @@ public: protected: size_t Grow(size_t size); -protected: size_t grow_; void* data_; size_t datasize_; size_t offset_; + + IMPLEMENT_REFCOUNTING(CefBytesWriter); + IMPLEMENT_LOCKING(CefBytesWriter); }; // Implementation of CefStreamReader for handlers. -class CefHandlerReader : public CefThreadSafeBase +class CefHandlerReader : public CefStreamReader { public: CefHandlerReader(CefRefPtr handler) : handler_(handler) {} - virtual size_t Read(void* ptr, size_t size, size_t n) + virtual size_t Read(void* ptr, size_t size, size_t n) OVERRIDE { return handler_->Read(ptr, size, n); } - virtual int Seek(long offset, int whence) + virtual int Seek(long offset, int whence) OVERRIDE { return handler_->Seek(offset, whence); } - virtual long Tell() + virtual long Tell() OVERRIDE { return handler_->Tell(); } - virtual int Eof() + virtual int Eof() OVERRIDE { return handler_->Eof(); } protected: CefRefPtr handler_; + + IMPLEMENT_REFCOUNTING(CefHandlerReader); }; // Implementation of CefStreamWriter for handlers. -class CefHandlerWriter : public CefThreadSafeBase +class CefHandlerWriter : public CefStreamWriter { public: CefHandlerWriter(CefRefPtr handler) : handler_(handler) {} - virtual size_t Write(const void* ptr, size_t size, size_t n) + virtual size_t Write(const void* ptr, size_t size, size_t n) OVERRIDE { return handler_->Write(ptr, size, n); } - virtual int Seek(long offset, int whence) + virtual int Seek(long offset, int whence) OVERRIDE { return handler_->Seek(offset, whence); } - virtual long Tell() + virtual long Tell() OVERRIDE { return handler_->Tell(); } - virtual int Flush() + virtual int Flush() OVERRIDE { return handler_->Flush(); } protected: CefRefPtr handler_; + + IMPLEMENT_REFCOUNTING(CefHandlerWriter); }; #endif // _STREAM_IMPL_H diff --git a/libcef/tracker.h b/libcef/tracker.h index b7e536ad9..6bd8e16db 100644 --- a/libcef/tracker.h +++ b/libcef/tracker.h @@ -74,7 +74,7 @@ private: // manager object is destroyed. A manager object can be created as either a // member variable of another class or by using lazy initialization: // base::LazyInstance g_singleton(base::LINKER_INITIALIZED); -class CefTrackManager : public CefThreadSafeBase +class CefTrackManager : public CefBase { public: CefTrackManager() : object_count_(0) {} @@ -131,6 +131,9 @@ public: private: CefTrackObject tracker_; long object_count_; + + IMPLEMENT_REFCOUNTING(CefTrackManager); + IMPLEMENT_LOCKING(CefTrackManager); }; #endif // _TRACKER_H diff --git a/libcef/v8_impl.cc b/libcef/v8_impl.cc index 702c123a4..d82a4eed5 100644 --- a/libcef/v8_impl.cc +++ b/libcef/v8_impl.cc @@ -83,22 +83,18 @@ void TrackDestructor(v8::Persistent object, void* parameter) // Return the browser associated with the specified WebFrame. CefRefPtr FindBrowserForFrame(WebKit::WebFrame *frame) { - CefRefPtr browser; - - CefContext::BrowserList *list; + CefContext::AutoLock lock_scope(_Context); + + CefContext::BrowserList *list = _Context->GetBrowserList(); CefContext::BrowserList::const_iterator i; - _Context->Lock(); - list = _Context->GetBrowserList(); i = list->begin(); for (; i != list->end(); ++i) { WebKit::WebFrame* thisframe = i->get()->UIT_GetMainWebFrame(); - if (thisframe == frame) { - browser = i->get(); - break; - } + if (thisframe == frame) + return i->get(); } - _Context->Unlock(); - return browser; + + return NULL; } // Convert a wide string to a V8 string. @@ -293,7 +289,7 @@ CefRefPtr CefV8Context::GetEnteredContext() // CefV8ContextImpl CefV8ContextImpl::CefV8ContextImpl(v8::Handle context) -#ifdef _DEBUG +#ifndef NDEBUG : enter_count_(0) #endif { @@ -346,7 +342,7 @@ bool CefV8ContextImpl::Enter() { CEF_REQUIRE_UI_THREAD(false); v8_context_->GetHandle()->Enter(); -#ifdef _DEBUG +#ifndef NDEBUG ++enter_count_; #endif return true; @@ -357,7 +353,7 @@ bool CefV8ContextImpl::Exit() CEF_REQUIRE_UI_THREAD(false); DLOG_ASSERT(enter_count_ > 0); v8_context_->GetHandle()->Exit(); -#ifdef _DEBUG +#ifndef NDEBUG --enter_count_; #endif return true; diff --git a/libcef/v8_impl.h b/libcef/v8_impl.h index c98219768..73419a8e2 100644 --- a/libcef/v8_impl.h +++ b/libcef/v8_impl.h @@ -59,17 +59,17 @@ public: } }; -class CefV8ContextImpl : public CefThreadSafeBase +class CefV8ContextImpl : public CefV8Context { public: CefV8ContextImpl(v8::Handle context); virtual ~CefV8ContextImpl(); - virtual CefRefPtr GetBrowser(); - virtual CefRefPtr GetFrame(); - virtual CefRefPtr GetGlobal(); - virtual bool Enter(); - virtual bool Exit(); + virtual CefRefPtr GetBrowser() OVERRIDE; + virtual CefRefPtr GetFrame() OVERRIDE; + virtual CefRefPtr GetGlobal() OVERRIDE; + virtual bool Enter() OVERRIDE; + virtual bool Exit() OVERRIDE; v8::Local GetContext(); WebKit::WebFrame* GetWebFrame(); @@ -77,10 +77,12 @@ public: protected: scoped_refptr v8_context_; -#ifdef _DEBUG +#ifndef NDEBUG // Used in debug builds to catch missing Exits in destructor. int enter_count_; #endif + + IMPLEMENT_REFCOUNTING(CefV8ContextImpl); }; // Special class for a v8::Value to ensure that it is deleted from the UI @@ -101,51 +103,52 @@ private: CefTrackObject *tracker_; }; -class CefV8ValueImpl : public CefThreadSafeBase +class CefV8ValueImpl : public CefV8Value { public: CefV8ValueImpl(v8::Handle value, CefTrackObject* tracker = NULL); virtual ~CefV8ValueImpl(); - virtual bool IsUndefined(); - virtual bool IsNull(); - virtual bool IsBool(); - virtual bool IsInt(); - virtual bool IsDouble(); - virtual bool IsString(); - virtual bool IsObject(); - virtual bool IsArray(); - virtual bool IsFunction(); - virtual bool IsSame(CefRefPtr value); - virtual bool GetBoolValue(); - virtual int GetIntValue(); - virtual double GetDoubleValue(); - virtual CefString GetStringValue(); - virtual bool HasValue(const CefString& key); - virtual bool HasValue(int index); - virtual bool DeleteValue(const CefString& key); - virtual bool DeleteValue(int index); - virtual CefRefPtr GetValue(const CefString& key); - virtual CefRefPtr GetValue(int index); - virtual bool SetValue(const CefString& key, CefRefPtr value); - virtual bool SetValue(int index, CefRefPtr value); + virtual bool IsUndefined() OVERRIDE; + virtual bool IsNull() OVERRIDE; + virtual bool IsBool() OVERRIDE; + virtual bool IsInt() OVERRIDE; + virtual bool IsDouble() OVERRIDE; + virtual bool IsString() OVERRIDE; + virtual bool IsObject() OVERRIDE; + virtual bool IsArray() OVERRIDE; + virtual bool IsFunction() OVERRIDE; + virtual bool IsSame(CefRefPtr value) OVERRIDE; + virtual bool GetBoolValue() OVERRIDE; + virtual int GetIntValue() OVERRIDE; + virtual double GetDoubleValue() OVERRIDE; + virtual CefString GetStringValue() OVERRIDE; + virtual bool HasValue(const CefString& key) OVERRIDE; + virtual bool HasValue(int index) OVERRIDE; + virtual bool DeleteValue(const CefString& key) OVERRIDE; + virtual bool DeleteValue(int index) OVERRIDE; + virtual CefRefPtr GetValue(const CefString& key) OVERRIDE; + virtual CefRefPtr GetValue(int index) OVERRIDE; + virtual bool SetValue(const CefString& key, CefRefPtr value) + OVERRIDE; + virtual bool SetValue(int index, CefRefPtr value) OVERRIDE; virtual bool SetValue(const CefString& key, AccessControl settings, - PropertyAttribute attribute); - virtual bool GetKeys(std::vector& keys); - virtual CefRefPtr GetUserData(); - virtual int GetArrayLength(); - virtual CefString GetFunctionName(); - virtual CefRefPtr GetFunctionHandler(); + PropertyAttribute attribute) OVERRIDE; + virtual bool GetKeys(std::vector& keys) OVERRIDE; + virtual CefRefPtr GetUserData() OVERRIDE; + virtual int GetArrayLength() OVERRIDE; + virtual CefString GetFunctionName() OVERRIDE; + virtual CefRefPtr GetFunctionHandler() OVERRIDE; virtual bool ExecuteFunction(CefRefPtr object, const CefV8ValueList& arguments, CefRefPtr& retval, - CefString& exception); + CefString& exception) OVERRIDE; virtual bool ExecuteFunctionWithContext( CefRefPtr context, CefRefPtr object, const CefV8ValueList& arguments, CefRefPtr& retval, - CefString& exception); + CefString& exception) OVERRIDE; inline v8::Handle GetHandle() { @@ -157,6 +160,8 @@ public: protected: scoped_refptr v8_value_; + + IMPLEMENT_REFCOUNTING(CefV8ValueImpl); }; #endif //_V8_IMPL_H diff --git a/libcef/web_urlrequest_impl.h b/libcef/web_urlrequest_impl.h index a70d52611..bcf5a857a 100644 --- a/libcef/web_urlrequest_impl.h +++ b/libcef/web_urlrequest_impl.h @@ -8,8 +8,7 @@ #include "include/cef.h" #include "base/memory/ref_counted.h" -class CefWebURLRequestImpl : - public CefThreadSafeBase +class CefWebURLRequestImpl : public CefWebURLRequest { public: class Context; @@ -19,8 +18,8 @@ public: virtual ~CefWebURLRequestImpl(); // Can be called on any thread. - virtual RequestState GetState(); - virtual void Cancel(); + virtual RequestState GetState() OVERRIDE; + virtual void Cancel() OVERRIDE; // Can only be called on the UI thread. void DoSend(CefRefPtr request); @@ -37,6 +36,9 @@ protected: // The below parameters are only modified on the UI thread. RequestState state_; scoped_refptr context_; + + IMPLEMENT_REFCOUNTING(CefWebURLRequestImpl); + IMPLEMENT_LOCKING(CefWebURLRequestImpl); }; #endif // _WEB_URL_REQUEST_CLIENT_IMPL_H diff --git a/libcef/xml_reader_impl.h b/libcef/xml_reader_impl.h index 83d33168d..766c71c61 100644 --- a/libcef/xml_reader_impl.h +++ b/libcef/xml_reader_impl.h @@ -11,7 +11,7 @@ #include // Implementation of CefXmlReader -class CefXmlReaderImpl : public CefThreadSafeBase +class CefXmlReaderImpl : public CefXmlReader { public: CefXmlReaderImpl(); @@ -65,6 +65,8 @@ protected: CefRefPtr stream_; xmlTextReaderPtr reader_; std::stringstream error_buf_; + + IMPLEMENT_REFCOUNTING(CefXMLReaderImpl); }; #endif // _XML_READER_IMPL_H diff --git a/libcef/zip_reader_impl.h b/libcef/zip_reader_impl.h index f847e9b65..4e022ad65 100644 --- a/libcef/zip_reader_impl.h +++ b/libcef/zip_reader_impl.h @@ -11,7 +11,7 @@ #include // Implementation of CefZipReader -class CefZipReaderImpl : public CefThreadSafeBase +class CefZipReaderImpl : public CefZipReader { public: CefZipReaderImpl(); @@ -47,6 +47,8 @@ protected: CefString filename_; long filesize_; time_t filemodified_; + + IMPLEMENT_REFCOUNTING(CefZipReaderImpl); }; #endif // _ZIP_READER_IMPL_H diff --git a/libcef_dll/cpptoc/base_cpptoc.h b/libcef_dll/cpptoc/base_cpptoc.h index 76aa7c4d6..9b14519af 100644 --- a/libcef_dll/cpptoc/base_cpptoc.h +++ b/libcef_dll/cpptoc/base_cpptoc.h @@ -11,7 +11,7 @@ // CefCppToC implementation for CefBase. -class CefBaseCppToC : public CefThreadSafeBase +class CefBaseCppToC : public CefBase { public: // Use this method to retrieve the underlying class instance from our @@ -88,16 +88,20 @@ public: // CefBase methods increment/decrement reference counts on both this object // and the underlying wrapper class. - virtual int AddRef() + int AddRef() { UnderlyingAddRef(); - return CefThreadSafeBase::AddRef(); + return refct_.AddRef(); } - virtual int Release() + int Release() { UnderlyingRelease(); - return CefThreadSafeBase::Release(); + int retval = refct_.Release(); + if (retval == 0) + delete this; + return retval; } + int GetRefCt() { return refct_.GetRefCt(); } // Increment/decrement reference counts on only the underlying class. int UnderlyingAddRef() { return class_->AddRef(); } @@ -136,6 +140,7 @@ private: } protected: + CefRefCount refct_; Struct struct_; CefBase* class_; }; diff --git a/libcef_dll/cpptoc/browser_cpptoc.cc b/libcef_dll/cpptoc/browser_cpptoc.cc index 99c36e529..33790d429 100644 --- a/libcef_dll/cpptoc/browser_cpptoc.cc +++ b/libcef_dll/cpptoc/browser_cpptoc.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -12,41 +12,55 @@ #include "libcef_dll/cpptoc/browser_cpptoc.h" #include "libcef_dll/cpptoc/frame_cpptoc.h" -#include "libcef_dll/ctocpp/handler_ctocpp.h" +#include "libcef_dll/ctocpp/client_ctocpp.h" #include "libcef_dll/transfer_util.h" // GLOBAL FUNCTIONS - Body may be edited by hand. -CEF_EXPORT int cef_browser_create(cef_window_info_t* windowInfo, int popup, - struct _cef_handler_t* handler, const cef_string_t* url) +CEF_EXPORT int cef_browser_create(cef_window_info_t* windowInfo, + struct _cef_client_t* client, const cef_string_t* url, + const struct _cef_browser_settings_t* settings) { DCHECK(windowInfo); + if (!windowInfo) + return 0; - CefRefPtr handlerPtr; - CefWindowInfo wi = *windowInfo; + CefRefPtr clientPtr; + CefWindowInfo windowInfoObj; + CefBrowserSettings browserSettingsObj; - if(handler) - handlerPtr = CefHandlerCToCpp::Wrap(handler); - - return CefBrowser::CreateBrowser(wi, popup?true:false, handlerPtr, - CefString(url)); + windowInfoObj.Set(*windowInfo, false); + if(client) + clientPtr = CefClientCToCpp::Wrap(client); + if (settings) + browserSettingsObj.Set(*settings, false); + + return CefBrowser::CreateBrowser(windowInfoObj, clientPtr, CefString(url), + browserSettingsObj); } CEF_EXPORT cef_browser_t* cef_browser_create_sync(cef_window_info_t* windowInfo, - int popup, struct _cef_handler_t* handler, const cef_string_t* url) + struct _cef_client_t* client, const cef_string_t* url, + const struct _cef_browser_settings_t* settings) { DCHECK(windowInfo); + if (!windowInfo) + return NULL; - CefRefPtr handlerPtr; - CefWindowInfo wi = *windowInfo; + CefRefPtr clientPtr; + CefWindowInfo windowInfoObj; + CefBrowserSettings browserSettingsObj; - if(handler) - handlerPtr = CefHandlerCToCpp::Wrap(handler); + windowInfoObj.Set(*windowInfo, false); + if(client) + clientPtr = CefClientCToCpp::Wrap(client); + if (settings) + browserSettingsObj.Set(*settings, false); CefRefPtr browserPtr( - CefBrowser::CreateBrowserSync(wi, popup?true:false, handlerPtr, - CefString(url))); + CefBrowser::CreateBrowserSync(windowInfoObj, clientPtr, CefString(url), + browserSettingsObj)); if(browserPtr.get()) return CefBrowserCppToC::Wrap(browserPtr); return NULL; @@ -155,17 +169,16 @@ int CEF_CALLBACK browser_is_popup(struct _cef_browser_t* self) return CefBrowserCppToC::Get(self)->IsPopup(); } -struct _cef_handler_t* CEF_CALLBACK browser_get_handler( +struct _cef_client_t* CEF_CALLBACK browser_get_client( struct _cef_browser_t* self) { DCHECK(self); - if(!self) + if (!self) return NULL; - CefRefPtr browserPtr = CefBrowserCppToC::Get(self); - CefRefPtr handlerPtr = browserPtr->GetHandler(); - if(handlerPtr.get()) - return CefHandlerCToCpp::Unwrap(handlerPtr); + CefRefPtr clientPtr = CefBrowserCppToC::Get(self)->GetClient(); + if(clientPtr.get()) + return CefClientCToCpp::Unwrap(clientPtr); return NULL; } @@ -438,7 +451,7 @@ CefBrowserCppToC::CefBrowserCppToC(CefBrowser* cls) struct_.struct_.set_focus = browser_set_focus; struct_.struct_.get_window_handle = browser_get_window_handle; struct_.struct_.is_popup = browser_is_popup; - struct_.struct_.get_handler = browser_get_handler; + struct_.struct_.get_client = browser_get_client; struct_.struct_.get_main_frame = browser_get_main_frame; struct_.struct_.get_focused_frame = browser_get_focused_frame; struct_.struct_.get_frame = browser_get_frame; @@ -465,7 +478,7 @@ CefBrowserCppToC::CefBrowserCppToC(CefBrowser* cls) struct_.struct_.send_capture_lost_event = browser_send_capture_lost_event; } -#ifdef _DEBUG +#ifndef NDEBUG template<> long CefCppToC::DebugObjCt = 0; #endif diff --git a/libcef_dll/cpptoc/browser_cpptoc.h b/libcef_dll/cpptoc/browser_cpptoc.h index 287b15cf8..474deee19 100644 --- a/libcef_dll/cpptoc/browser_cpptoc.h +++ b/libcef_dll/cpptoc/browser_cpptoc.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // diff --git a/libcef_dll/cpptoc/client_cpptoc.cc b/libcef_dll/cpptoc/client_cpptoc.cc new file mode 100644 index 000000000..590b808c1 --- /dev/null +++ b/libcef_dll/cpptoc/client_cpptoc.cc @@ -0,0 +1,234 @@ +// 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. +// +// --------------------------------------------------------------------------- +// +// A portion of this file was generated by the CEF translator tool. When +// making changes by hand only do so within the body of existing function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/client_cpptoc.h" +#include "libcef_dll/cpptoc/display_handler_cpptoc.h" +#include "libcef_dll/cpptoc/find_handler_cpptoc.h" +#include "libcef_dll/cpptoc/focus_handler_cpptoc.h" +#include "libcef_dll/cpptoc/jsbinding_handler_cpptoc.h" +#include "libcef_dll/cpptoc/jsdialog_handler_cpptoc.h" +#include "libcef_dll/cpptoc/keyboard_handler_cpptoc.h" +#include "libcef_dll/cpptoc/life_span_handler_cpptoc.h" +#include "libcef_dll/cpptoc/load_handler_cpptoc.h" +#include "libcef_dll/cpptoc/menu_handler_cpptoc.h" +#include "libcef_dll/cpptoc/print_handler_cpptoc.h" +#include "libcef_dll/cpptoc/render_handler_cpptoc.h" +#include "libcef_dll/cpptoc/request_handler_cpptoc.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +cef_life_span_handler_t* CEF_CALLBACK client_get_life_span_handler( + struct _cef_client_t* self) +{ + DCHECK(self); + if (!self) + return NULL; + + CefRefPtr handlerPtr = + CefClientCppToC::Get(self)->GetLifeSpanHandler(); + if(handlerPtr.get()) + return CefLifeSpanHandlerCppToC::Wrap(handlerPtr); + + return NULL; +} + +cef_load_handler_t* CEF_CALLBACK client_get_load_handler( + struct _cef_client_t* self) +{ + DCHECK(self); + if (!self) + return NULL; + + CefRefPtr handlerPtr = + CefClientCppToC::Get(self)->GetLoadHandler(); + if(handlerPtr.get()) + return CefLoadHandlerCppToC::Wrap(handlerPtr); + + return NULL; +} + +cef_request_handler_t* CEF_CALLBACK client_get_request_handler( + struct _cef_client_t* self) +{ + DCHECK(self); + if (!self) + return NULL; + + CefRefPtr handlerPtr = + CefClientCppToC::Get(self)->GetRequestHandler(); + if(handlerPtr.get()) + return CefRequestHandlerCppToC::Wrap(handlerPtr); + + return NULL; +} + +cef_display_handler_t* CEF_CALLBACK client_get_display_handler( + struct _cef_client_t* self) +{ + DCHECK(self); + if (!self) + return NULL; + + CefRefPtr handlerPtr = + CefClientCppToC::Get(self)->GetDisplayHandler(); + if(handlerPtr.get()) + return CefDisplayHandlerCppToC::Wrap(handlerPtr); + + return NULL; +} + +cef_focus_handler_t* CEF_CALLBACK client_get_focus_handler( + struct _cef_client_t* self) +{ + DCHECK(self); + if (!self) + return NULL; + + CefRefPtr handlerPtr = + CefClientCppToC::Get(self)->GetFocusHandler(); + if(handlerPtr.get()) + return CefFocusHandlerCppToC::Wrap(handlerPtr); + + return NULL; +} + +cef_keyboard_handler_t* CEF_CALLBACK client_get_keyboard_handler( + struct _cef_client_t* self) +{ + DCHECK(self); + if (!self) + return NULL; + + CefRefPtr handlerPtr = + CefClientCppToC::Get(self)->GetKeyboardHandler(); + if(handlerPtr.get()) + return CefKeyboardHandlerCppToC::Wrap(handlerPtr); + + return NULL; +} + +cef_menu_handler_t* CEF_CALLBACK client_get_menu_handler( + struct _cef_client_t* self) +{ + DCHECK(self); + if (!self) + return NULL; + + CefRefPtr handlerPtr = + CefClientCppToC::Get(self)->GetMenuHandler(); + if(handlerPtr.get()) + return CefMenuHandlerCppToC::Wrap(handlerPtr); + + return NULL; +} + +cef_print_handler_t* CEF_CALLBACK client_get_print_handler( + struct _cef_client_t* self) +{ + DCHECK(self); + if (!self) + return NULL; + + CefRefPtr handlerPtr = + CefClientCppToC::Get(self)->GetPrintHandler(); + if(handlerPtr.get()) + return CefPrintHandlerCppToC::Wrap(handlerPtr); + + return NULL; +} + +cef_find_handler_t* CEF_CALLBACK client_get_find_handler( + struct _cef_client_t* self) +{ + DCHECK(self); + if (!self) + return NULL; + + CefRefPtr handlerPtr = + CefClientCppToC::Get(self)->GetFindHandler(); + if(handlerPtr.get()) + return CefFindHandlerCppToC::Wrap(handlerPtr); + + return NULL; +} + +cef_jsdialog_handler_t* CEF_CALLBACK client_get_jsdialog_handler( + struct _cef_client_t* self) +{ + DCHECK(self); + if (!self) + return NULL; + + CefRefPtr handlerPtr = + CefClientCppToC::Get(self)->GetJSDialogHandler(); + if(handlerPtr.get()) + return CefJSDialogHandlerCppToC::Wrap(handlerPtr); + + return NULL; +} + +cef_jsbinding_handler_t* CEF_CALLBACK client_get_jsbinding_handler( + struct _cef_client_t* self) +{ + DCHECK(self); + if (!self) + return NULL; + + CefRefPtr handlerPtr = + CefClientCppToC::Get(self)->GetJSBindingHandler(); + if(handlerPtr.get()) + return CefJSBindingHandlerCppToC::Wrap(handlerPtr); + + return NULL; +} + +cef_render_handler_t* CEF_CALLBACK client_get_render_handler( + struct _cef_client_t* self) +{ + DCHECK(self); + if (!self) + return NULL; + + CefRefPtr handlerPtr = + CefClientCppToC::Get(self)->GetRenderHandler(); + if(handlerPtr.get()) + return CefRenderHandlerCppToC::Wrap(handlerPtr); + + return NULL; +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefClientCppToC::CefClientCppToC(CefClient* cls) + : CefCppToC(cls) +{ + struct_.struct_.get_life_span_handler = client_get_life_span_handler; + struct_.struct_.get_load_handler = client_get_load_handler; + struct_.struct_.get_request_handler = client_get_request_handler; + struct_.struct_.get_display_handler = client_get_display_handler; + struct_.struct_.get_focus_handler = client_get_focus_handler; + struct_.struct_.get_keyboard_handler = client_get_keyboard_handler; + struct_.struct_.get_menu_handler = client_get_menu_handler; + struct_.struct_.get_print_handler = client_get_print_handler; + struct_.struct_.get_find_handler = client_get_find_handler; + struct_.struct_.get_jsdialog_handler = client_get_jsdialog_handler; + struct_.struct_.get_jsbinding_handler = client_get_jsbinding_handler; + struct_.struct_.get_render_handler = client_get_render_handler; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/libcef_dll/cpptoc/handler_cpptoc.h b/libcef_dll/cpptoc/client_cpptoc.h similarity index 71% rename from libcef_dll/cpptoc/handler_cpptoc.h rename to libcef_dll/cpptoc/client_cpptoc.h index 12a191abf..5ac0f17af 100644 --- a/libcef_dll/cpptoc/handler_cpptoc.h +++ b/libcef_dll/cpptoc/client_cpptoc.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -8,8 +8,8 @@ // by hand. See the translator.README.txt file in the tools directory for // more information. // -#ifndef _HANDLER_CPPTOC_H -#define _HANDLER_CPPTOC_H +#ifndef _CLIENT_CPPTOC_H +#define _CLIENT_CPPTOC_H #ifndef USING_CEF_SHARED #pragma message("Warning: "__FILE__" may be accessed wrapper-side only") @@ -21,14 +21,14 @@ // Wrap a C++ class with a C structure. // This class may be instantiated and accessed wrapper-side only. -class CefHandlerCppToC - : public CefCppToC +class CefClientCppToC + : public CefCppToC { public: - CefHandlerCppToC(CefHandler* cls); - virtual ~CefHandlerCppToC() {} + CefClientCppToC(CefClient* cls); + virtual ~CefClientCppToC() {} }; #endif // USING_CEF_SHARED -#endif // _HANDLER_CPPTOC_H +#endif // _CLIENT_CPPTOC_H diff --git a/libcef_dll/cpptoc/cookie_visitor_cpptoc.cc b/libcef_dll/cpptoc/cookie_visitor_cpptoc.cc index 43f7bd001..681cbc5c3 100644 --- a/libcef_dll/cpptoc/cookie_visitor_cpptoc.cc +++ b/libcef_dll/cpptoc/cookie_visitor_cpptoc.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -46,7 +46,7 @@ CefCookieVisitorCppToC::CefCookieVisitorCppToC(CefCookieVisitor* cls) struct_.struct_.visit = cookie_visitor_visit; } -#ifdef _DEBUG +#ifndef NDEBUG template<> long CefCppToC::DebugObjCt = 0; #endif diff --git a/libcef_dll/cpptoc/cookie_visitor_cpptoc.h b/libcef_dll/cpptoc/cookie_visitor_cpptoc.h index 5ad07cb44..f9512e4a4 100644 --- a/libcef_dll/cpptoc/cookie_visitor_cpptoc.h +++ b/libcef_dll/cpptoc/cookie_visitor_cpptoc.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // diff --git a/libcef_dll/cpptoc/cpptoc.h b/libcef_dll/cpptoc/cpptoc.h index c08cc46dc..bbfc431e7 100644 --- a/libcef_dll/cpptoc/cpptoc.h +++ b/libcef_dll/cpptoc/cpptoc.h @@ -14,7 +14,7 @@ // implementation exists on this side of the DLL boundary but will have methods // called from the other side of the DLL boundary. template -class CefCppToC : public CefThreadSafeBase +class CefCppToC : public CefBase { public: // Structure representation with pointer to the C++ class. @@ -78,13 +78,13 @@ public: struct_.struct_.base.release = struct_release; struct_.struct_.base.get_refct = struct_get_refct; -#ifdef _DEBUG +#ifndef NDEBUG CefAtomicIncrement(&DebugObjCt); #endif } virtual ~CefCppToC() { -#ifdef _DEBUG +#ifndef NDEBUG CefAtomicDecrement(&DebugObjCt); #endif } @@ -98,23 +98,27 @@ public: // CefBase methods increment/decrement reference counts on both this object // and the underlying wrapper class. - virtual int AddRef() + int AddRef() { UnderlyingAddRef(); - return CefThreadSafeBase::AddRef(); + return refct_.AddRef(); } - virtual int Release() + int Release() { UnderlyingRelease(); - return CefThreadSafeBase::Release(); + int retval = refct_.Release(); + if (retval == 0) + delete this; + return retval; } + int GetRefCt() { return refct_.GetRefCt(); } // Increment/decrement reference counts on only the underlying class. int UnderlyingAddRef() { return class_->AddRef(); } int UnderlyingRelease() { return class_->Release(); } int UnderlyingGetRefCt() { return class_->GetRefCt(); } -#ifdef _DEBUG +#ifndef NDEBUG // Simple tracking of allocated objects. static long DebugObjCt; #endif @@ -151,6 +155,7 @@ private: } protected: + CefRefCount refct_; Struct struct_; BaseName* class_; }; diff --git a/libcef_dll/cpptoc/display_handler_cpptoc.cc b/libcef_dll/cpptoc/display_handler_cpptoc.cc new file mode 100644 index 000000000..686258d93 --- /dev/null +++ b/libcef_dll/cpptoc/display_handler_cpptoc.cc @@ -0,0 +1,123 @@ +// 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. +// +// --------------------------------------------------------------------------- +// +// A portion of this file was generated by the CEF translator tool. When +// making changes by hand only do so within the body of existing function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/display_handler_cpptoc.h" +#include "libcef_dll/ctocpp/browser_ctocpp.h" +#include "libcef_dll/ctocpp/frame_ctocpp.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +void CEF_CALLBACK display_handler_on_nav_state_change( + struct _cef_display_handler_t* self, cef_browser_t* browser, int canGoBack, + int canGoForward) +{ + DCHECK(self); + DCHECK(browser); + if (!self || !browser) + return; + + CefDisplayHandlerCppToC::Get(self)->OnNavStateChange( + CefBrowserCToCpp::Wrap(browser), (canGoBack?true:false), + (canGoForward?true:false)); +} + +void CEF_CALLBACK display_handler_on_address_change( + struct _cef_display_handler_t* self, cef_browser_t* browser, + cef_frame_t* frame, const cef_string_t* url) +{ + DCHECK(self); + DCHECK(browser); + DCHECK(frame); + DCHECK(url); + if (!self || !browser || !frame || !url) + return; + + CefDisplayHandlerCppToC::Get(self)->OnAddressChange( + CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame), + CefString(url)); +} + +void CEF_CALLBACK display_handler_on_title_change( + struct _cef_display_handler_t* self, cef_browser_t* browser, + const cef_string_t* title) +{ + DCHECK(self); + DCHECK(browser); + if (!self || !browser) + return; + + CefDisplayHandlerCppToC::Get(self)->OnTitleChange( + CefBrowserCToCpp::Wrap(browser), CefString(title)); +} + +int CEF_CALLBACK display_handler_on_tooltip(struct _cef_display_handler_t* self, + cef_browser_t* browser, cef_string_t* text) +{ + DCHECK(self); + DCHECK(browser); + if (!self || !browser) + return 0; + + CefString textStr(text); + return CefDisplayHandlerCppToC::Get(self)->OnTooltip( + CefBrowserCToCpp::Wrap(browser), textStr); +} + +void CEF_CALLBACK display_handler_on_status_message( + struct _cef_display_handler_t* self, cef_browser_t* browser, + const cef_string_t* value, enum cef_handler_statustype_t type) +{ + DCHECK(self); + DCHECK(browser); + if (!self || !browser) + return; + + CefDisplayHandlerCppToC::Get(self)->OnStatusMessage( + CefBrowserCToCpp::Wrap(browser), CefString(value), type); +} + +int CEF_CALLBACK display_handler_on_console_message( + struct _cef_display_handler_t* self, cef_browser_t* browser, + const cef_string_t* message, const cef_string_t* source, int line) +{ + DCHECK(self); + DCHECK(browser); + DCHECK(message); + if (!self || !browser || !message) + return 0; + + return CefDisplayHandlerCppToC::Get(self)->OnConsoleMessage( + CefBrowserCToCpp::Wrap(browser), CefString(message), CefString(source), + line); +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefDisplayHandlerCppToC::CefDisplayHandlerCppToC(CefDisplayHandler* cls) + : CefCppToC(cls) +{ + struct_.struct_.on_nav_state_change = display_handler_on_nav_state_change; + struct_.struct_.on_address_change = display_handler_on_address_change; + struct_.struct_.on_title_change = display_handler_on_title_change; + struct_.struct_.on_tooltip = display_handler_on_tooltip; + struct_.struct_.on_status_message = display_handler_on_status_message; + struct_.struct_.on_console_message = display_handler_on_console_message; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/libcef_dll/cpptoc/display_handler_cpptoc.h b/libcef_dll/cpptoc/display_handler_cpptoc.h new file mode 100644 index 000000000..23dd1e143 --- /dev/null +++ b/libcef_dll/cpptoc/display_handler_cpptoc.h @@ -0,0 +1,35 @@ +// 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 was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// +#ifndef _DISPLAYHANDLER_CPPTOC_H +#define _DISPLAYHANDLER_CPPTOC_H + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef.h" +#include "include/cef_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed wrapper-side only. +class CefDisplayHandlerCppToC + : public CefCppToC +{ +public: + CefDisplayHandlerCppToC(CefDisplayHandler* cls); + virtual ~CefDisplayHandlerCppToC() {} +}; + +#endif // USING_CEF_SHARED +#endif // _DISPLAYHANDLER_CPPTOC_H + diff --git a/libcef_dll/cpptoc/domdocument_cpptoc.cc b/libcef_dll/cpptoc/domdocument_cpptoc.cc index 23b945656..c6b982aef 100644 --- a/libcef_dll/cpptoc/domdocument_cpptoc.cc +++ b/libcef_dll/cpptoc/domdocument_cpptoc.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -235,7 +235,7 @@ CefDOMDocumentCppToC::CefDOMDocumentCppToC(CefDOMDocument* cls) struct_.struct_.get_complete_url = domdocument_get_complete_url; } -#ifdef _DEBUG +#ifndef NDEBUG template<> long CefCppToC::DebugObjCt = 0; #endif diff --git a/libcef_dll/cpptoc/domdocument_cpptoc.h b/libcef_dll/cpptoc/domdocument_cpptoc.h index d6b8dda78..3b1097a99 100644 --- a/libcef_dll/cpptoc/domdocument_cpptoc.h +++ b/libcef_dll/cpptoc/domdocument_cpptoc.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // diff --git a/libcef_dll/cpptoc/domevent_cpptoc.cc b/libcef_dll/cpptoc/domevent_cpptoc.cc index 007938bb2..f8d369f6b 100644 --- a/libcef_dll/cpptoc/domevent_cpptoc.cc +++ b/libcef_dll/cpptoc/domevent_cpptoc.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -122,7 +122,7 @@ CefDOMEventCppToC::CefDOMEventCppToC(CefDOMEvent* cls) struct_.struct_.get_current_target = domevent_get_current_target; } -#ifdef _DEBUG +#ifndef NDEBUG template<> long CefCppToC::DebugObjCt = 0; #endif diff --git a/libcef_dll/cpptoc/domevent_cpptoc.h b/libcef_dll/cpptoc/domevent_cpptoc.h index 35467061b..37da2359c 100644 --- a/libcef_dll/cpptoc/domevent_cpptoc.h +++ b/libcef_dll/cpptoc/domevent_cpptoc.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // diff --git a/libcef_dll/cpptoc/domevent_listener_cpptoc.cc b/libcef_dll/cpptoc/domevent_listener_cpptoc.cc index 184896e52..250b29c1b 100644 --- a/libcef_dll/cpptoc/domevent_listener_cpptoc.cc +++ b/libcef_dll/cpptoc/domevent_listener_cpptoc.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -40,7 +40,7 @@ CefDOMEventListenerCppToC::CefDOMEventListenerCppToC(CefDOMEventListener* cls) struct_.struct_.handle_event = domevent_listener_handle_event; } -#ifdef _DEBUG +#ifndef NDEBUG template<> long CefCppToC::DebugObjCt = 0; #endif diff --git a/libcef_dll/cpptoc/domevent_listener_cpptoc.h b/libcef_dll/cpptoc/domevent_listener_cpptoc.h index ded07e032..7d509efff 100644 --- a/libcef_dll/cpptoc/domevent_listener_cpptoc.h +++ b/libcef_dll/cpptoc/domevent_listener_cpptoc.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // diff --git a/libcef_dll/cpptoc/domnode_cpptoc.cc b/libcef_dll/cpptoc/domnode_cpptoc.cc index e250f6147..f9fbc6a0e 100644 --- a/libcef_dll/cpptoc/domnode_cpptoc.cc +++ b/libcef_dll/cpptoc/domnode_cpptoc.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -314,7 +314,7 @@ CefDOMNodeCppToC::CefDOMNodeCppToC(CefDOMNode* cls) struct_.struct_.get_element_inner_text = domnode_get_element_inner_text; } -#ifdef _DEBUG +#ifndef NDEBUG template<> long CefCppToC::DebugObjCt = 0; #endif diff --git a/libcef_dll/cpptoc/domnode_cpptoc.h b/libcef_dll/cpptoc/domnode_cpptoc.h index 940f22c74..3b2c65f61 100644 --- a/libcef_dll/cpptoc/domnode_cpptoc.h +++ b/libcef_dll/cpptoc/domnode_cpptoc.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // diff --git a/libcef_dll/cpptoc/domvisitor_cpptoc.cc b/libcef_dll/cpptoc/domvisitor_cpptoc.cc index 598e283a0..e24fad77d 100644 --- a/libcef_dll/cpptoc/domvisitor_cpptoc.cc +++ b/libcef_dll/cpptoc/domvisitor_cpptoc.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -39,7 +39,7 @@ CefDOMVisitorCppToC::CefDOMVisitorCppToC(CefDOMVisitor* cls) struct_.struct_.visit = domvisitor_visit; } -#ifdef _DEBUG +#ifndef NDEBUG template<> long CefCppToC::DebugObjCt = 0; #endif diff --git a/libcef_dll/cpptoc/domvisitor_cpptoc.h b/libcef_dll/cpptoc/domvisitor_cpptoc.h index 7353d46fa..800284377 100644 --- a/libcef_dll/cpptoc/domvisitor_cpptoc.h +++ b/libcef_dll/cpptoc/domvisitor_cpptoc.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // diff --git a/libcef_dll/cpptoc/download_handler_cpptoc.cc b/libcef_dll/cpptoc/download_handler_cpptoc.cc index a5ffd6dc0..ec135f9fc 100644 --- a/libcef_dll/cpptoc/download_handler_cpptoc.cc +++ b/libcef_dll/cpptoc/download_handler_cpptoc.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -46,7 +46,7 @@ CefDownloadHandlerCppToC::CefDownloadHandlerCppToC(CefDownloadHandler* cls) struct_.struct_.complete = download_handler_complete; } -#ifdef _DEBUG +#ifndef NDEBUG template<> long CefCppToC::DebugObjCt = 0; #endif diff --git a/libcef_dll/cpptoc/download_handler_cpptoc.h b/libcef_dll/cpptoc/download_handler_cpptoc.h index 737aecdf9..04e8c9a1d 100644 --- a/libcef_dll/cpptoc/download_handler_cpptoc.h +++ b/libcef_dll/cpptoc/download_handler_cpptoc.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // diff --git a/libcef_dll/cpptoc/find_handler_cpptoc.cc b/libcef_dll/cpptoc/find_handler_cpptoc.cc new file mode 100644 index 000000000..eff968a2b --- /dev/null +++ b/libcef_dll/cpptoc/find_handler_cpptoc.cc @@ -0,0 +1,48 @@ +// 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. +// +// --------------------------------------------------------------------------- +// +// A portion of this file was generated by the CEF translator tool. When +// making changes by hand only do so within the body of existing function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/find_handler_cpptoc.h" +#include "libcef_dll/ctocpp/browser_ctocpp.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +void CEF_CALLBACK find_handler_on_find_result(struct _cef_find_handler_t* self, + cef_browser_t* browser, int identifier, int count, + const cef_rect_t* selectionRect, int activeMatchOrdinal, int finalUpdate) +{ + DCHECK(self); + DCHECK(browser); + DCHECK(selectionRect); + if (!self || !browser || !selectionRect) + return; + + CefRect rect(*selectionRect); + CefFindHandlerCppToC::Get(self)->OnFindResult( + CefBrowserCToCpp::Wrap(browser), identifier, count, rect, + activeMatchOrdinal, finalUpdate?true:false); +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefFindHandlerCppToC::CefFindHandlerCppToC(CefFindHandler* cls) + : CefCppToC(cls) +{ + struct_.struct_.on_find_result = find_handler_on_find_result; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/libcef_dll/cpptoc/find_handler_cpptoc.h b/libcef_dll/cpptoc/find_handler_cpptoc.h new file mode 100644 index 000000000..898bba1ae --- /dev/null +++ b/libcef_dll/cpptoc/find_handler_cpptoc.h @@ -0,0 +1,34 @@ +// 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 was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// +#ifndef _FINDHANDLER_CPPTOC_H +#define _FINDHANDLER_CPPTOC_H + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef.h" +#include "include/cef_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed wrapper-side only. +class CefFindHandlerCppToC + : public CefCppToC +{ +public: + CefFindHandlerCppToC(CefFindHandler* cls); + virtual ~CefFindHandlerCppToC() {} +}; + +#endif // USING_CEF_SHARED +#endif // _FINDHANDLER_CPPTOC_H + diff --git a/libcef_dll/cpptoc/focus_handler_cpptoc.cc b/libcef_dll/cpptoc/focus_handler_cpptoc.cc new file mode 100644 index 000000000..1147991d3 --- /dev/null +++ b/libcef_dll/cpptoc/focus_handler_cpptoc.cc @@ -0,0 +1,58 @@ +// 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. +// +// --------------------------------------------------------------------------- +// +// A portion of this file was generated by the CEF translator tool. When +// making changes by hand only do so within the body of existing function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/focus_handler_cpptoc.h" +#include "libcef_dll/ctocpp/browser_ctocpp.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +void CEF_CALLBACK focus_handler_on_take_focus(struct _cef_focus_handler_t* self, + cef_browser_t* browser, int next) +{ + DCHECK(self); + DCHECK(browser); + if (!self || !browser) + return; + + CefFocusHandlerCppToC::Get(self)->OnTakeFocus( + CefBrowserCToCpp::Wrap(browser), next?true:false); +} + +int CEF_CALLBACK focus_handler_on_set_focus(struct _cef_focus_handler_t* self, + cef_browser_t* browser, int isWidget) +{ + DCHECK(self); + DCHECK(browser); + if (!self || !browser) + return 0; + + return CefFocusHandlerCppToC::Get(self)->OnSetFocus( + CefBrowserCToCpp::Wrap(browser), isWidget?true:false); +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefFocusHandlerCppToC::CefFocusHandlerCppToC(CefFocusHandler* cls) + : CefCppToC( + cls) +{ + struct_.struct_.on_take_focus = focus_handler_on_take_focus; + struct_.struct_.on_set_focus = focus_handler_on_set_focus; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/libcef_dll/cpptoc/focus_handler_cpptoc.h b/libcef_dll/cpptoc/focus_handler_cpptoc.h new file mode 100644 index 000000000..2f3259453 --- /dev/null +++ b/libcef_dll/cpptoc/focus_handler_cpptoc.h @@ -0,0 +1,35 @@ +// 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 was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// +#ifndef _FOCUSHANDLER_CPPTOC_H +#define _FOCUSHANDLER_CPPTOC_H + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef.h" +#include "include/cef_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed wrapper-side only. +class CefFocusHandlerCppToC + : public CefCppToC +{ +public: + CefFocusHandlerCppToC(CefFocusHandler* cls); + virtual ~CefFocusHandlerCppToC() {} +}; + +#endif // USING_CEF_SHARED +#endif // _FOCUSHANDLER_CPPTOC_H + diff --git a/libcef_dll/cpptoc/frame_cpptoc.cc b/libcef_dll/cpptoc/frame_cpptoc.cc index 26277d691..609671041 100644 --- a/libcef_dll/cpptoc/frame_cpptoc.cc +++ b/libcef_dll/cpptoc/frame_cpptoc.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -267,7 +267,7 @@ CefFrameCppToC::CefFrameCppToC(CefFrame* cls) struct_.struct_.visit_dom = frame_visit_dom; } -#ifdef _DEBUG +#ifndef NDEBUG template<> long CefCppToC::DebugObjCt = 0; #endif diff --git a/libcef_dll/cpptoc/frame_cpptoc.h b/libcef_dll/cpptoc/frame_cpptoc.h index e87620e94..270227420 100644 --- a/libcef_dll/cpptoc/frame_cpptoc.h +++ b/libcef_dll/cpptoc/frame_cpptoc.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // diff --git a/libcef_dll/cpptoc/handler_cpptoc.cc b/libcef_dll/cpptoc/handler_cpptoc.cc deleted file mode 100644 index e3bec8cf5..000000000 --- a/libcef_dll/cpptoc/handler_cpptoc.cc +++ /dev/null @@ -1,681 +0,0 @@ -// 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. -// -// --------------------------------------------------------------------------- -// -// A portion of this file was generated by the CEF translator tool. When -// making changes by hand only do so within the body of existing function -// implementations. See the translator.README.txt file in the tools directory -// for more information. -// - -#include "libcef_dll/cpptoc/download_handler_cpptoc.h" -#include "libcef_dll/cpptoc/handler_cpptoc.h" -#include "libcef_dll/ctocpp/browser_ctocpp.h" -#include "libcef_dll/ctocpp/frame_ctocpp.h" -#include "libcef_dll/ctocpp/request_ctocpp.h" -#include "libcef_dll/ctocpp/response_ctocpp.h" -#include "libcef_dll/ctocpp/stream_reader_ctocpp.h" -#include "libcef_dll/ctocpp/v8value_ctocpp.h" - - -// MEMBER FUNCTIONS - Body may be edited by hand. - -enum cef_retval_t CEF_CALLBACK handler_handle_before_created( - struct _cef_handler_t* self, cef_browser_t* parentBrowser, - cef_window_info_t* windowInfo, int popup, - const struct _cef_popup_features_t* popupFeatures, - struct _cef_handler_t** handler, const cef_string_t* url, - struct _cef_browser_settings_t* settings) -{ - DCHECK(self); - DCHECK(windowInfo); - DCHECK(handler && *handler); - if(!self || !windowInfo || !handler || !*handler) - return RV_CONTINUE; - - CefWindowInfo wndInfo; - CefBrowserSettings browserSettings; - CefPopupFeatures features; - - // Take ownership of the values. - wndInfo.AttachTo(*windowInfo); - browserSettings.AttachTo(*settings); - - // Reference the existing values instead of copying. - features.Set(*popupFeatures, false); - - // |newHandler| will start off pointing to the current handler. - CefRefPtr handlerPtr = CefHandlerCppToC::Unwrap(*handler); - CefHandler* origHandler = handlerPtr.get(); - - // |parentBrowser| will be NULL if this is a top-level browser window. - CefRefPtr browserPtr; - if(parentBrowser) - browserPtr = CefBrowserCToCpp::Wrap(parentBrowser); - - enum cef_retval_t rv = CefHandlerCppToC::Get(self)->HandleBeforeCreated( - browserPtr, wndInfo, popup?true:false, features, handlerPtr, - CefString(url), browserSettings); - - if(handlerPtr.get() != origHandler) { - // The handler has been changed. - *handler = CefHandlerCppToC::Wrap(handlerPtr); - } - - // Return the values to the structures. - wndInfo.DetachTo(*windowInfo); - browserSettings.DetachTo(*settings); - - return rv; -} - -enum cef_retval_t CEF_CALLBACK handler_handle_after_created( - struct _cef_handler_t* self, cef_browser_t* browser) -{ - DCHECK(self); - DCHECK(browser); - if(!self || !browser) - return RV_CONTINUE; - - return CefHandlerCppToC::Get(self)->HandleAfterCreated( - CefBrowserCToCpp::Wrap(browser)); -} - -enum cef_retval_t CEF_CALLBACK handler_handle_address_change( - struct _cef_handler_t* self, cef_browser_t* browser, cef_frame_t* frame, - const cef_string_t* url) -{ - DCHECK(self); - DCHECK(browser); - DCHECK(frame); - if(!self || !browser || !frame) - return RV_CONTINUE; - - return CefHandlerCppToC::Get(self)->HandleAddressChange( - CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame), - CefString(url)); -} - -enum cef_retval_t CEF_CALLBACK handler_handle_title_change( - struct _cef_handler_t* self, cef_browser_t* browser, - const cef_string_t* title) -{ - DCHECK(self); - DCHECK(browser); - if(!self || !browser) - return RV_CONTINUE; - - return CefHandlerCppToC::Get(self)->HandleTitleChange( - CefBrowserCToCpp::Wrap(browser), CefString(title)); -} - -enum cef_retval_t CEF_CALLBACK handler_handle_nav_state_change( - struct _cef_handler_t* self, cef_browser_t* browser, int canGoBack, - int canGoForward) -{ - DCHECK(self); - DCHECK(browser); - if(!self || !browser) - return RV_CONTINUE; - - return CefHandlerCppToC::Get(self)->HandleNavStateChange( - CefBrowserCToCpp::Wrap(browser), (canGoBack?true:false), - (canGoForward?true:false)); -} - -enum cef_retval_t CEF_CALLBACK handler_handle_before_browse( - struct _cef_handler_t* self, cef_browser_t* browser, cef_frame_t* frame, - struct _cef_request_t* request, enum cef_handler_navtype_t navType, - int isRedirect) -{ - DCHECK(self); - DCHECK(browser); - DCHECK(frame); - DCHECK(request); - if(!self || !browser || !request || !frame) - return RV_CONTINUE; - - return CefHandlerCppToC::Get(self)->HandleBeforeBrowse( - CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame), - CefRequestCToCpp::Wrap(request), navType, (isRedirect ? true : false)); -} - -enum cef_retval_t CEF_CALLBACK handler_handle_load_start( - struct _cef_handler_t* self, cef_browser_t* browser, cef_frame_t* frame) -{ - DCHECK(self); - DCHECK(browser); - if(!self || !browser) - return RV_CONTINUE; - - CefRefPtr framePtr; - if(frame) - framePtr = CefFrameCToCpp::Wrap(frame); - - return CefHandlerCppToC::Get(self)->HandleLoadStart( - CefBrowserCToCpp::Wrap(browser), framePtr); -} - -enum cef_retval_t CEF_CALLBACK handler_handle_load_end( - struct _cef_handler_t* self, cef_browser_t* browser, cef_frame_t* frame, - int httpStatusCode) -{ - DCHECK(self); - DCHECK(browser); - if(!self || !browser) - return RV_CONTINUE; - - CefRefPtr framePtr; - if(frame) - framePtr = CefFrameCToCpp::Wrap(frame); - - return CefHandlerCppToC::Get(self)->HandleLoadEnd( - CefBrowserCToCpp::Wrap(browser), framePtr, httpStatusCode); -} - -enum cef_retval_t CEF_CALLBACK handler_handle_load_error( - struct _cef_handler_t* self, cef_browser_t* browser, cef_frame_t* frame, - enum cef_handler_errorcode_t errorCode, const cef_string_t* failedUrl, - cef_string_t* errorText) -{ - DCHECK(self); - DCHECK(browser); - DCHECK(frame); - DCHECK(errorText); - if(!self || !browser || !errorText || !frame) - return RV_CONTINUE; - - CefString errorTextStr(errorText); - return CefHandlerCppToC::Get(self)->HandleLoadError( - CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame), errorCode, - CefString(failedUrl), errorTextStr); -} - -enum cef_retval_t CEF_CALLBACK handler_handle_before_resource_load( - struct _cef_handler_t* self, cef_browser_t* browser, - struct _cef_request_t* request, cef_string_t* redirectUrl, - struct _cef_stream_reader_t** resourceStream, - struct _cef_response_t* response, int loadFlags) -{ - DCHECK(self); - DCHECK(browser); - DCHECK(redirectUrl); - DCHECK(resourceStream); - DCHECK(response); - if(!self || !browser || !redirectUrl || !resourceStream || !response) - return RV_CONTINUE; - - CefRefPtr streamPtr; - - CefString redirectUrlStr(redirectUrl); - enum cef_retval_t rv = CefHandlerCppToC::Get(self)-> - HandleBeforeResourceLoad(CefBrowserCToCpp::Wrap(browser), - CefRequestCToCpp::Wrap(request), redirectUrlStr, streamPtr, - CefResponseCToCpp::Wrap(response), loadFlags); - - if(streamPtr.get()) - *resourceStream = CefStreamReaderCToCpp::Unwrap(streamPtr); - - return rv; -} - -enum cef_retval_t CEF_CALLBACK handler_handle_protocol_execution( - struct _cef_handler_t* self, cef_browser_t* browser, - const cef_string_t* url, int* allow_os_execution) -{ - DCHECK(self); - DCHECK(browser); - if(!self || !browser) - return RV_CONTINUE; - - bool allowExec = *allow_os_execution?true:false; - enum cef_retval_t rv = CefHandlerCppToC::Get(self)->HandleProtocolExecution( - CefBrowserCToCpp::Wrap(browser), CefString(url), allowExec); - *allow_os_execution = allowExec; - return rv; -} - -enum cef_retval_t CEF_CALLBACK handler_handle_download_response( - struct _cef_handler_t* self, cef_browser_t* browser, - const cef_string_t* mimeType, const cef_string_t* fileName, - int64 contentLength, struct _cef_download_handler_t** handler) -{ - DCHECK(self); - DCHECK(browser); - DCHECK(mimeType); - DCHECK(fileName); - if(!self || !browser || !mimeType || !fileName) - return RV_CONTINUE; - - CefRefPtr downloadPtr; - - enum cef_retval_t rv = CefHandlerCppToC::Get(self)-> - HandleDownloadResponse(CefBrowserCToCpp::Wrap(browser), - CefString(mimeType), CefString(fileName), contentLength, downloadPtr); - - if(downloadPtr.get()) - *handler = CefDownloadHandlerCppToC::Wrap(downloadPtr); - - return rv; -} - -enum cef_retval_t CEF_CALLBACK handler_handle_authentication_request( - struct _cef_handler_t* self, cef_browser_t* browser, int isProxy, - const cef_string_t* host, const cef_string_t* realm, - const cef_string_t* scheme, cef_string_t* username, - cef_string_t* password) -{ - DCHECK(self); - DCHECK(browser); - DCHECK(username && password); - if (!self || !browser || !username || !password) - return RV_CONTINUE; - - CefString usernameStr(username); - CefString passwordStr(password); - - return CefHandlerCppToC::Get(self)-> - HandleAuthenticationRequest(CefBrowserCToCpp::Wrap(browser), - (isProxy ? true : false), CefString(host), CefString(realm), - CefString(scheme), usernameStr, passwordStr); -} - -enum cef_retval_t CEF_CALLBACK handler_handle_before_menu( - struct _cef_handler_t* self, cef_browser_t* browser, - const cef_handler_menuinfo_t* menuInfo) -{ - DCHECK(self); - DCHECK(browser); - DCHECK(menuInfo); - if(!self || !browser || !menuInfo) - return RV_CONTINUE; - - return CefHandlerCppToC::Get(self)->HandleBeforeMenu( - CefBrowserCToCpp::Wrap(browser), *menuInfo); -} - -enum cef_retval_t CEF_CALLBACK handler_handle_get_menu_label( - struct _cef_handler_t* self, cef_browser_t* browser, - enum cef_handler_menuid_t menuId, cef_string_t* label) -{ - DCHECK(self); - DCHECK(browser); - DCHECK(label); - if(!self || !browser || !label) - return RV_CONTINUE; - - CefString labelStr(label); - return CefHandlerCppToC::Get(self)->HandleGetMenuLabel( - CefBrowserCToCpp::Wrap(browser), menuId, labelStr); -} - -enum cef_retval_t CEF_CALLBACK handler_handle_menu_action( - struct _cef_handler_t* self, cef_browser_t* browser, - enum cef_handler_menuid_t menuId) -{ - DCHECK(self); - DCHECK(browser); - if(!self || !browser) - return RV_CONTINUE; - - return CefHandlerCppToC::Get(self)->HandleMenuAction( - CefBrowserCToCpp::Wrap(browser), menuId); -} - -enum cef_retval_t CEF_CALLBACK handler_handle_print_options( - struct _cef_handler_t* self, cef_browser_t* browser, - struct _cef_print_options_t* printOptions) -{ - DCHECK(self); - DCHECK(browser); - DCHECK(printOptions); - if(!self || !browser || !printOptions) - return RV_CONTINUE; - - return CefHandlerCppToC::Get(self)->HandlePrintOptions(CefBrowserCToCpp::Wrap(browser), *printOptions); -} - -enum cef_retval_t CEF_CALLBACK handler_handle_print_header_footer( - struct _cef_handler_t* self, cef_browser_t* browser, cef_frame_t* frame, - cef_print_info_t* printInfo, const cef_string_t* url, - const cef_string_t* title, int currentPage, int maxPages, - cef_string_t* topLeft, cef_string_t* topCenter, cef_string_t* topRight, - cef_string_t* bottomLeft, cef_string_t* bottomCenter, - cef_string_t* bottomRight) -{ - DCHECK(self); - DCHECK(browser); - DCHECK(frame); - DCHECK(printInfo); - DCHECK(topLeft && topCenter && topRight); - DCHECK(bottomLeft && bottomCenter && bottomRight); - if(!self || !browser || !frame || !printInfo || !topLeft || !topCenter - || !topRight || !bottomLeft || !bottomCenter || !bottomRight) - return RV_CONTINUE; - - CefPrintInfo info = *printInfo; - - CefString topLeftStr(topLeft); - CefString topCenterStr(topCenter); - CefString topRightStr(topRight); - CefString bottomLeftStr(bottomLeft); - CefString bottomCenterStr(bottomCenter); - CefString bottomRightStr(bottomRight); - return CefHandlerCppToC::Get(self)-> - HandlePrintHeaderFooter(CefBrowserCToCpp::Wrap(browser), - CefFrameCToCpp::Wrap(frame), info, CefString(url), CefString(title), - currentPage, maxPages, topLeftStr, topCenterStr, topRightStr, - bottomLeftStr, bottomCenterStr, bottomRightStr); -} - -enum cef_retval_t CEF_CALLBACK handler_handle_jsalert( - struct _cef_handler_t* self, cef_browser_t* browser, cef_frame_t* frame, - const cef_string_t* message) -{ - DCHECK(self); - DCHECK(browser); - DCHECK(frame); - if(!self || !browser || !frame) - return RV_CONTINUE; - - return CefHandlerCppToC::Get(self)->HandleJSAlert( - CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame), - CefString(message)); -} - -enum cef_retval_t CEF_CALLBACK handler_handle_jsconfirm( - struct _cef_handler_t* self, cef_browser_t* browser, cef_frame_t* frame, - const cef_string_t* message, int* retval) -{ - DCHECK(self); - DCHECK(browser); - DCHECK(frame); - DCHECK(retval); - if(!self || !browser || !retval || !frame) - return RV_CONTINUE; - - bool ret = false; - enum cef_retval_t rv = CefHandlerCppToC::Get(self)->HandleJSConfirm( - CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame), - CefString(message), ret); - *retval = (ret ? 1 : 0); - - return rv; -} - -enum cef_retval_t CEF_CALLBACK handler_handle_jsprompt( - struct _cef_handler_t* self, cef_browser_t* browser, cef_frame_t* frame, - const cef_string_t* message, const cef_string_t* defaultValue, int* retval, - cef_string_t* result) -{ - DCHECK(self); - DCHECK(browser); - DCHECK(frame); - DCHECK(retval); - DCHECK(result); - if(!self || !browser || !frame || !retval || !result) - return RV_CONTINUE; - - bool ret = false; - CefString resultStr(result); - enum cef_retval_t rv = CefHandlerCppToC::Get(self)->HandleJSPrompt( - CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame), - CefString(message), CefString(defaultValue), ret, resultStr); - *retval = (ret ? 1 : 0); - - return rv; -} - -enum cef_retval_t CEF_CALLBACK handler_handle_jsbinding( - struct _cef_handler_t* self, cef_browser_t* browser, cef_frame_t* frame, - struct _cef_v8value_t* object) -{ - DCHECK(self); - DCHECK(browser); - DCHECK(frame); - DCHECK(object); - if(!self || !browser || !frame || !object) - return RV_CONTINUE; - - return CefHandlerCppToC::Get(self)->HandleJSBinding( - CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame), - CefV8ValueCToCpp::Wrap(object)); -} - -enum cef_retval_t CEF_CALLBACK handler_handle_before_window_close( - struct _cef_handler_t* self, cef_browser_t* browser) -{ - DCHECK(self); - DCHECK(browser); - if(!self || !browser) - return RV_CONTINUE; - - return CefHandlerCppToC::Get(self)->HandleBeforeWindowClose( - CefBrowserCToCpp::Wrap(browser)); -} - -enum cef_retval_t CEF_CALLBACK handler_handle_take_focus( - struct _cef_handler_t* self, cef_browser_t* browser, int reverse) -{ - DCHECK(self); - DCHECK(browser); - if(!self || !browser) - return RV_CONTINUE; - - return CefHandlerCppToC::Get(self)->HandleTakeFocus( - CefBrowserCToCpp::Wrap(browser), (reverse ? true : false)); -} - -enum cef_retval_t CEF_CALLBACK handler_handle_set_focus( - struct _cef_handler_t* self, cef_browser_t* browser, int isWidget) -{ - DCHECK(self); - DCHECK(browser); - if(!self || !browser) - return RV_CONTINUE; - - return CefHandlerCppToC::Get(self)->HandleSetFocus( - CefBrowserCToCpp::Wrap(browser), isWidget?true:false); -} - -enum cef_retval_t CEF_CALLBACK handler_handle_key_event( - struct _cef_handler_t* self, cef_browser_t* browser, - enum cef_handler_keyevent_type_t type, int code, int modifiers, - int isSystemKey) -{ - DCHECK(self); - DCHECK(browser); - if(!self || !browser) - return RV_CONTINUE; - - return CefHandlerCppToC::Get(self)->HandleKeyEvent( - CefBrowserCToCpp::Wrap(browser), type, code, - modifiers, isSystemKey?true:false); -} - -enum cef_retval_t CEF_CALLBACK handler_handle_tooltip( - struct _cef_handler_t* self, cef_browser_t* browser, cef_string_t* text) -{ - DCHECK(self); - DCHECK(browser); - DCHECK(text); - if(!self || !browser || !text) - return RV_CONTINUE; - - CefString textStr(text); - return CefHandlerCppToC::Get(self)->HandleTooltip( - CefBrowserCToCpp::Wrap(browser), textStr); -} - -enum cef_retval_t CEF_CALLBACK handler_handle_status( - struct _cef_handler_t* self, cef_browser_t* browser, - const cef_string_t* value, enum cef_handler_statustype_t type) -{ - DCHECK(self); - DCHECK(browser); - if(!self || !browser) - return RV_CONTINUE; - - return CefHandlerCppToC::Get(self)->HandleStatus( - CefBrowserCToCpp::Wrap(browser), CefString(value), type); -} - -enum cef_retval_t CEF_CALLBACK handler_handle_console_message( - struct _cef_handler_t* self, cef_browser_t* browser, - const cef_string_t* message, const cef_string_t* source, int line) -{ - DCHECK(self); - DCHECK(browser); - if(!self || !browser) - return RV_CONTINUE; - - return CefHandlerCppToC::Get(self)->HandleConsoleMessage( - CefBrowserCToCpp::Wrap(browser), CefString(message), CefString(source), - line); -} - -enum cef_retval_t CEF_CALLBACK handler_handle_find_result( - struct _cef_handler_t* self, cef_browser_t* browser, int identifier, - int count, const cef_rect_t* selectionRect, int activeMatchOrdinal, - int finalUpdate) -{ - DCHECK(self); - DCHECK(browser); - if(!self || !browser) - return RV_CONTINUE; - - CefRect rect(*selectionRect); - return CefHandlerCppToC::Get(self)->HandleFindResult( - CefBrowserCToCpp::Wrap(browser), identifier, count, rect, - activeMatchOrdinal, finalUpdate?true:false); -} - -enum cef_retval_t CEF_CALLBACK handler_handle_get_rect( - struct _cef_handler_t* self, cef_browser_t* browser, int screen, - cef_rect_t* rect) -{ - DCHECK(self); - DCHECK(browser); - DCHECK(rect); - if(!self || !browser || !rect) - return RV_CONTINUE; - - CefRect changeRect(*rect); - cef_retval_t rv = CefHandlerCppToC::Get(self)->HandleGetRect( - CefBrowserCToCpp::Wrap(browser), screen?true:false, changeRect); - *rect = changeRect; - return rv; -} - -enum cef_retval_t CEF_CALLBACK handler_handle_get_screen_point( - struct _cef_handler_t* self, cef_browser_t* browser, int viewX, int viewY, - int* screenX, int* screenY) -{ - DCHECK(self); - DCHECK(browser); - DCHECK(screenX); - DCHECK(screenY); - if(!self || !browser || !screenX || !screenY) - return RV_CONTINUE; - - return CefHandlerCppToC::Get(self)->HandleGetScreenPoint( - CefBrowserCToCpp::Wrap(browser), viewX, viewY, *screenX, *screenY); -} - -enum cef_retval_t CEF_CALLBACK handler_handle_popup_change( - struct _cef_handler_t* self, cef_browser_t* browser, int show, - const cef_rect_t* rect) -{ - DCHECK(self); - DCHECK(browser); - DCHECK(rect); - if(!self || !browser || !rect) - return RV_CONTINUE; - - CefRect changeRect(*rect); - return CefHandlerCppToC::Get(self)->HandlePopupChange( - CefBrowserCToCpp::Wrap(browser), show?true:false, changeRect); -} - -enum cef_retval_t CEF_CALLBACK handler_handle_paint(struct _cef_handler_t* self, - cef_browser_t* browser, enum cef_paint_element_type_t type, - const cef_rect_t* dirtyRect, const void* buffer) -{ - DCHECK(self); - DCHECK(browser); - DCHECK(dirtyRect); - if(!self || !browser || !dirtyRect) - return RV_CONTINUE; - - CefRect rect(*dirtyRect); - return CefHandlerCppToC::Get(self)->HandlePaint( - CefBrowserCToCpp::Wrap(browser), type, rect, buffer); -} - -enum cef_retval_t CEF_CALLBACK handler_handle_cursor_change( - struct _cef_handler_t* self, cef_browser_t* browser, - cef_cursor_handle_t cursor) -{ - DCHECK(self); - DCHECK(browser); - if(!self || !browser) - return RV_CONTINUE; - - return CefHandlerCppToC::Get(self)->HandleCursorChange( - CefBrowserCToCpp::Wrap(browser), cursor); -} - - -// CONSTRUCTOR - Do not edit by hand. - -CefHandlerCppToC::CefHandlerCppToC(CefHandler* cls) - : CefCppToC(cls) -{ - struct_.struct_.handle_before_created = handler_handle_before_created; - struct_.struct_.handle_after_created = handler_handle_after_created; - struct_.struct_.handle_address_change = handler_handle_address_change; - struct_.struct_.handle_title_change = handler_handle_title_change; - struct_.struct_.handle_nav_state_change = handler_handle_nav_state_change; - struct_.struct_.handle_before_browse = handler_handle_before_browse; - struct_.struct_.handle_load_start = handler_handle_load_start; - struct_.struct_.handle_load_end = handler_handle_load_end; - struct_.struct_.handle_load_error = handler_handle_load_error; - struct_.struct_.handle_before_resource_load = - handler_handle_before_resource_load; - struct_.struct_.handle_protocol_execution = handler_handle_protocol_execution; - struct_.struct_.handle_download_response = handler_handle_download_response; - struct_.struct_.handle_authentication_request = - handler_handle_authentication_request; - struct_.struct_.handle_before_menu = handler_handle_before_menu; - struct_.struct_.handle_get_menu_label = handler_handle_get_menu_label; - struct_.struct_.handle_menu_action = handler_handle_menu_action; - struct_.struct_.handle_print_options = handler_handle_print_options; - struct_.struct_.handle_print_header_footer = - handler_handle_print_header_footer; - struct_.struct_.handle_jsalert = handler_handle_jsalert; - struct_.struct_.handle_jsconfirm = handler_handle_jsconfirm; - struct_.struct_.handle_jsprompt = handler_handle_jsprompt; - struct_.struct_.handle_jsbinding = handler_handle_jsbinding; - struct_.struct_.handle_before_window_close = - handler_handle_before_window_close; - struct_.struct_.handle_take_focus = handler_handle_take_focus; - struct_.struct_.handle_set_focus = handler_handle_set_focus; - struct_.struct_.handle_key_event = handler_handle_key_event; - struct_.struct_.handle_tooltip = handler_handle_tooltip; - struct_.struct_.handle_status = handler_handle_status; - struct_.struct_.handle_console_message = handler_handle_console_message; - struct_.struct_.handle_find_result = handler_handle_find_result; - struct_.struct_.handle_get_rect = handler_handle_get_rect; - struct_.struct_.handle_get_screen_point = handler_handle_get_screen_point; - struct_.struct_.handle_popup_change = handler_handle_popup_change; - struct_.struct_.handle_paint = handler_handle_paint; - struct_.struct_.handle_cursor_change = handler_handle_cursor_change; -} - -#ifdef _DEBUG -template<> long CefCppToC::DebugObjCt = 0; -#endif - diff --git a/libcef_dll/cpptoc/jsbinding_handler_cpptoc.cc b/libcef_dll/cpptoc/jsbinding_handler_cpptoc.cc new file mode 100644 index 000000000..2723fec5d --- /dev/null +++ b/libcef_dll/cpptoc/jsbinding_handler_cpptoc.cc @@ -0,0 +1,51 @@ +// 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. +// +// --------------------------------------------------------------------------- +// +// A portion of this file was generated by the CEF translator tool. When +// making changes by hand only do so within the body of existing function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/jsbinding_handler_cpptoc.h" +#include "libcef_dll/ctocpp/browser_ctocpp.h" +#include "libcef_dll/ctocpp/frame_ctocpp.h" +#include "libcef_dll/ctocpp/v8value_ctocpp.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +void CEF_CALLBACK jsbinding_handler_on_jsbinding( + struct _cef_jsbinding_handler_t* self, cef_browser_t* browser, + cef_frame_t* frame, struct _cef_v8value_t* object) +{ + DCHECK(self); + DCHECK(browser); + DCHECK(frame); + DCHECK(object); + if (!self || !browser || !frame || !object) + return; + + return CefJSBindingHandlerCppToC::Get(self)->OnJSBinding( + CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame), + CefV8ValueCToCpp::Wrap(object)); +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefJSBindingHandlerCppToC::CefJSBindingHandlerCppToC(CefJSBindingHandler* cls) + : CefCppToC(cls) +{ + struct_.struct_.on_jsbinding = jsbinding_handler_on_jsbinding; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/libcef_dll/cpptoc/jsbinding_handler_cpptoc.h b/libcef_dll/cpptoc/jsbinding_handler_cpptoc.h new file mode 100644 index 000000000..3a9b3ed4d --- /dev/null +++ b/libcef_dll/cpptoc/jsbinding_handler_cpptoc.h @@ -0,0 +1,35 @@ +// 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 was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// +#ifndef _JSBINDINGHANDLER_CPPTOC_H +#define _JSBINDINGHANDLER_CPPTOC_H + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef.h" +#include "include/cef_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed wrapper-side only. +class CefJSBindingHandlerCppToC + : public CefCppToC +{ +public: + CefJSBindingHandlerCppToC(CefJSBindingHandler* cls); + virtual ~CefJSBindingHandlerCppToC() {} +}; + +#endif // USING_CEF_SHARED +#endif // _JSBINDINGHANDLER_CPPTOC_H + diff --git a/libcef_dll/cpptoc/jsdialog_handler_cpptoc.cc b/libcef_dll/cpptoc/jsdialog_handler_cpptoc.cc new file mode 100644 index 000000000..22bff7797 --- /dev/null +++ b/libcef_dll/cpptoc/jsdialog_handler_cpptoc.cc @@ -0,0 +1,99 @@ +// 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. +// +// --------------------------------------------------------------------------- +// +// A portion of this file was generated by the CEF translator tool. When +// making changes by hand only do so within the body of existing function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/jsdialog_handler_cpptoc.h" +#include "libcef_dll/ctocpp/browser_ctocpp.h" +#include "libcef_dll/ctocpp/frame_ctocpp.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +int CEF_CALLBACK jsdialog_handler_on_jsalert( + struct _cef_jsdialog_handler_t* self, cef_browser_t* browser, + cef_frame_t* frame, const cef_string_t* message) +{ + DCHECK(self); + DCHECK(browser); + DCHECK(frame); + DCHECK(message); + if (!self || !browser || !frame || !message) + return 0; + + return CefJSDialogHandlerCppToC::Get(self)->OnJSAlert( + CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame), + CefString(message)); +} + +int CEF_CALLBACK jsdialog_handler_on_jsconfirm( + struct _cef_jsdialog_handler_t* self, cef_browser_t* browser, + cef_frame_t* frame, const cef_string_t* message, int* retval) +{ + DCHECK(self); + DCHECK(browser); + DCHECK(frame); + DCHECK(message); + DCHECK(retval); + if (!self || !browser || !frame || !message || !retval) + return 0; + + bool ret = false; + int rv = CefJSDialogHandlerCppToC::Get(self)->OnJSConfirm( + CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame), + CefString(message), ret); + *retval = (ret ? 1 : 0); + + return rv; +} + +int CEF_CALLBACK jsdialog_handler_on_jsprompt( + struct _cef_jsdialog_handler_t* self, cef_browser_t* browser, + cef_frame_t* frame, const cef_string_t* message, + const cef_string_t* defaultValue, int* retval, cef_string_t* result) +{ + DCHECK(self); + DCHECK(browser); + DCHECK(frame); + DCHECK(message); + DCHECK(defaultValue); + DCHECK(retval); + DCHECK(result); + if (!self || !browser || !frame || !message || !defaultValue || !retval || + !result) + return 0; + + bool ret = false; + CefString resultStr(result); + int rv = CefJSDialogHandlerCppToC::Get(self)->OnJSPrompt( + CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame), + CefString(message), CefString(defaultValue), ret, resultStr); + *retval = (ret ? 1 : 0); + + return rv; +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefJSDialogHandlerCppToC::CefJSDialogHandlerCppToC(CefJSDialogHandler* cls) + : CefCppToC(cls) +{ + struct_.struct_.on_jsalert = jsdialog_handler_on_jsalert; + struct_.struct_.on_jsconfirm = jsdialog_handler_on_jsconfirm; + struct_.struct_.on_jsprompt = jsdialog_handler_on_jsprompt; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/libcef_dll/cpptoc/jsdialog_handler_cpptoc.h b/libcef_dll/cpptoc/jsdialog_handler_cpptoc.h new file mode 100644 index 000000000..03e533faa --- /dev/null +++ b/libcef_dll/cpptoc/jsdialog_handler_cpptoc.h @@ -0,0 +1,35 @@ +// 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 was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// +#ifndef _JSDIALOGHANDLER_CPPTOC_H +#define _JSDIALOGHANDLER_CPPTOC_H + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef.h" +#include "include/cef_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed wrapper-side only. +class CefJSDialogHandlerCppToC + : public CefCppToC +{ +public: + CefJSDialogHandlerCppToC(CefJSDialogHandler* cls); + virtual ~CefJSDialogHandlerCppToC() {} +}; + +#endif // USING_CEF_SHARED +#endif // _JSDIALOGHANDLER_CPPTOC_H + diff --git a/libcef_dll/cpptoc/keyboard_handler_cpptoc.cc b/libcef_dll/cpptoc/keyboard_handler_cpptoc.cc new file mode 100644 index 000000000..299c4ef21 --- /dev/null +++ b/libcef_dll/cpptoc/keyboard_handler_cpptoc.cc @@ -0,0 +1,48 @@ +// 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. +// +// --------------------------------------------------------------------------- +// +// A portion of this file was generated by the CEF translator tool. When +// making changes by hand only do so within the body of existing function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/keyboard_handler_cpptoc.h" +#include "libcef_dll/ctocpp/browser_ctocpp.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +int CEF_CALLBACK keyboard_handler_on_key_event( + struct _cef_keyboard_handler_t* self, cef_browser_t* browser, + enum cef_handler_keyevent_type_t type, int code, int modifiers, + int isSystemKey) +{ + DCHECK(self); + DCHECK(browser); + if (!self || !browser) + return 0; + + return CefKeyboardHandlerCppToC::Get(self)->OnKeyEvent( + CefBrowserCToCpp::Wrap(browser), type, code, + modifiers, isSystemKey?true:false); +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefKeyboardHandlerCppToC::CefKeyboardHandlerCppToC(CefKeyboardHandler* cls) + : CefCppToC(cls) +{ + struct_.struct_.on_key_event = keyboard_handler_on_key_event; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/libcef_dll/cpptoc/keyboard_handler_cpptoc.h b/libcef_dll/cpptoc/keyboard_handler_cpptoc.h new file mode 100644 index 000000000..28b635bdc --- /dev/null +++ b/libcef_dll/cpptoc/keyboard_handler_cpptoc.h @@ -0,0 +1,35 @@ +// 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 was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// +#ifndef _KEYBOARDHANDLER_CPPTOC_H +#define _KEYBOARDHANDLER_CPPTOC_H + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef.h" +#include "include/cef_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed wrapper-side only. +class CefKeyboardHandlerCppToC + : public CefCppToC +{ +public: + CefKeyboardHandlerCppToC(CefKeyboardHandler* cls); + virtual ~CefKeyboardHandlerCppToC() {} +}; + +#endif // USING_CEF_SHARED +#endif // _KEYBOARDHANDLER_CPPTOC_H + diff --git a/libcef_dll/cpptoc/life_span_handler_cpptoc.cc b/libcef_dll/cpptoc/life_span_handler_cpptoc.cc new file mode 100644 index 000000000..1331ec640 --- /dev/null +++ b/libcef_dll/cpptoc/life_span_handler_cpptoc.cc @@ -0,0 +1,117 @@ +// 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. +// +// --------------------------------------------------------------------------- +// +// A portion of this file was generated by the CEF translator tool. When +// making changes by hand only do so within the body of existing function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/client_cpptoc.h" +#include "libcef_dll/cpptoc/life_span_handler_cpptoc.h" +#include "libcef_dll/ctocpp/browser_ctocpp.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +int CEF_CALLBACK life_span_handler_on_before_popup( + struct _cef_life_span_handler_t* self, cef_browser_t* parentBrowser, + const struct _cef_popup_features_t* popupFeatures, + cef_window_info_t* windowInfo, const cef_string_t* url, + struct _cef_client_t** client, struct _cef_browser_settings_t* settings) +{ + DCHECK(self); + DCHECK(parentBrowser); + DCHECK(popupFeatures); + DCHECK(windowInfo); + DCHECK(url); + DCHECK(client); + DCHECK(settings); + if (!self || !parentBrowser || !popupFeatures || !windowInfo || !url || + !client || !settings) + return 0; + + CefWindowInfo wndInfo; + CefBrowserSettings browserSettings; + CefPopupFeatures features; + + // Take ownership of the values. + wndInfo.AttachTo(*windowInfo); + browserSettings.AttachTo(*settings); + + // Reference the existing values instead of copying. + features.Set(*popupFeatures, false); + + // |newHandler| will start off pointing to the current handler. + CefRefPtr clientPtr; + if (*client) + clientPtr = CefClientCppToC::Unwrap(*client); + CefClient* origClient = clientPtr.get(); + + // |parentBrowser| will be NULL if this is a top-level browser window. + CefRefPtr browserPtr(CefBrowserCToCpp::Wrap(parentBrowser)); + + bool rv = CefLifeSpanHandlerCppToC::Get(self)->OnBeforePopup( + browserPtr, features, wndInfo, CefString(url), clientPtr, + browserSettings); + + if (clientPtr.get()) { + if (clientPtr.get() != origClient) { + // The handler has been changed. + *client = CefClientCppToC::Wrap(clientPtr); + } + } else { + *client = NULL; + } + + // Return the values to the structures. + wndInfo.DetachTo(*windowInfo); + browserSettings.DetachTo(*settings); + + return rv; +} + +void CEF_CALLBACK life_span_handler_on_after_created( + struct _cef_life_span_handler_t* self, cef_browser_t* browser) +{ + DCHECK(self); + DCHECK(browser); + if (!self || !browser) + return; + + CefLifeSpanHandlerCppToC::Get(self)->OnAfterCreated( + CefBrowserCToCpp::Wrap(browser)); +} + +void CEF_CALLBACK life_span_handler_on_before_close( + struct _cef_life_span_handler_t* self, cef_browser_t* browser) +{ + DCHECK(self); + DCHECK(browser); + if (!self || !browser) + return; + + CefLifeSpanHandlerCppToC::Get(self)->OnBeforeClose( + CefBrowserCToCpp::Wrap(browser)); +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefLifeSpanHandlerCppToC::CefLifeSpanHandlerCppToC(CefLifeSpanHandler* cls) + : CefCppToC(cls) +{ + struct_.struct_.on_before_popup = life_span_handler_on_before_popup; + struct_.struct_.on_after_created = life_span_handler_on_after_created; + struct_.struct_.on_before_close = life_span_handler_on_before_close; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/libcef_dll/cpptoc/life_span_handler_cpptoc.h b/libcef_dll/cpptoc/life_span_handler_cpptoc.h new file mode 100644 index 000000000..92b2c96f6 --- /dev/null +++ b/libcef_dll/cpptoc/life_span_handler_cpptoc.h @@ -0,0 +1,35 @@ +// 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 was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// +#ifndef _LIFESPANHANDLER_CPPTOC_H +#define _LIFESPANHANDLER_CPPTOC_H + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef.h" +#include "include/cef_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed wrapper-side only. +class CefLifeSpanHandlerCppToC + : public CefCppToC +{ +public: + CefLifeSpanHandlerCppToC(CefLifeSpanHandler* cls); + virtual ~CefLifeSpanHandlerCppToC() {} +}; + +#endif // USING_CEF_SHARED +#endif // _LIFESPANHANDLER_CPPTOC_H + diff --git a/libcef_dll/cpptoc/load_handler_cpptoc.cc b/libcef_dll/cpptoc/load_handler_cpptoc.cc new file mode 100644 index 000000000..88de43d7c --- /dev/null +++ b/libcef_dll/cpptoc/load_handler_cpptoc.cc @@ -0,0 +1,81 @@ +// 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. +// +// --------------------------------------------------------------------------- +// +// A portion of this file was generated by the CEF translator tool. When +// making changes by hand only do so within the body of existing function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/load_handler_cpptoc.h" +#include "libcef_dll/ctocpp/browser_ctocpp.h" +#include "libcef_dll/ctocpp/frame_ctocpp.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +void CEF_CALLBACK load_handler_on_load_start(struct _cef_load_handler_t* self, + cef_browser_t* browser, cef_frame_t* frame) +{ + DCHECK(self); + DCHECK(browser); + DCHECK(frame); + if (!self || !browser || !frame) + return; + + CefLoadHandlerCppToC::Get(self)->OnLoadStart( + CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame)); +} + +void CEF_CALLBACK load_handler_on_load_end(struct _cef_load_handler_t* self, + cef_browser_t* browser, cef_frame_t* frame, int httpStatusCode) +{ + DCHECK(self); + DCHECK(browser); + DCHECK(frame); + if (!self || !browser || !frame) + return; + + CefLoadHandlerCppToC::Get(self)->OnLoadEnd( + CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame), + httpStatusCode); +} + +int CEF_CALLBACK load_handler_on_load_error(struct _cef_load_handler_t* self, + cef_browser_t* browser, cef_frame_t* frame, + enum cef_handler_errorcode_t errorCode, const cef_string_t* failedUrl, + cef_string_t* errorText) +{ + DCHECK(self); + DCHECK(browser); + DCHECK(frame); + DCHECK(failedUrl); + DCHECK(errorText); + if (!self || !browser || !frame || !failedUrl || !errorText) + return 0; + + CefString errorTextStr(errorText); + return CefLoadHandlerCppToC::Get(self)->OnLoadError( + CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame), errorCode, + CefString(failedUrl), errorTextStr); +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefLoadHandlerCppToC::CefLoadHandlerCppToC(CefLoadHandler* cls) + : CefCppToC(cls) +{ + struct_.struct_.on_load_start = load_handler_on_load_start; + struct_.struct_.on_load_end = load_handler_on_load_end; + struct_.struct_.on_load_error = load_handler_on_load_error; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/libcef_dll/cpptoc/load_handler_cpptoc.h b/libcef_dll/cpptoc/load_handler_cpptoc.h new file mode 100644 index 000000000..288df1bc2 --- /dev/null +++ b/libcef_dll/cpptoc/load_handler_cpptoc.h @@ -0,0 +1,34 @@ +// 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 was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// +#ifndef _LOADHANDLER_CPPTOC_H +#define _LOADHANDLER_CPPTOC_H + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef.h" +#include "include/cef_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed wrapper-side only. +class CefLoadHandlerCppToC + : public CefCppToC +{ +public: + CefLoadHandlerCppToC(CefLoadHandler* cls); + virtual ~CefLoadHandlerCppToC() {} +}; + +#endif // USING_CEF_SHARED +#endif // _LOADHANDLER_CPPTOC_H + diff --git a/libcef_dll/cpptoc/menu_handler_cpptoc.cc b/libcef_dll/cpptoc/menu_handler_cpptoc.cc new file mode 100644 index 000000000..104d1736c --- /dev/null +++ b/libcef_dll/cpptoc/menu_handler_cpptoc.cc @@ -0,0 +1,74 @@ +// 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. +// +// --------------------------------------------------------------------------- +// +// A portion of this file was generated by the CEF translator tool. When +// making changes by hand only do so within the body of existing function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/menu_handler_cpptoc.h" +#include "libcef_dll/ctocpp/browser_ctocpp.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +int CEF_CALLBACK menu_handler_on_before_menu(struct _cef_menu_handler_t* self, + cef_browser_t* browser, const cef_handler_menuinfo_t* menuInfo) +{ + DCHECK(self); + DCHECK(browser); + DCHECK(menuInfo); + if (!self || !browser || !menuInfo) + return 0; + + return CefMenuHandlerCppToC::Get(self)->OnBeforeMenu( + CefBrowserCToCpp::Wrap(browser), *menuInfo); +} + +void CEF_CALLBACK menu_handler_get_menu_label(struct _cef_menu_handler_t* self, + cef_browser_t* browser, enum cef_handler_menuid_t menuId, + cef_string_t* label) +{ + DCHECK(self); + DCHECK(browser); + DCHECK(label); + if (!self || !browser || !label) + return; + + CefString labelStr(label); + CefMenuHandlerCppToC::Get(self)->GetMenuLabel( + CefBrowserCToCpp::Wrap(browser), menuId, labelStr); +} + +int CEF_CALLBACK menu_handler_on_menu_action(struct _cef_menu_handler_t* self, + cef_browser_t* browser, enum cef_handler_menuid_t menuId) +{ + DCHECK(self); + DCHECK(browser); + if (!self || !browser) + return 0; + + return CefMenuHandlerCppToC::Get(self)->OnMenuAction( + CefBrowserCToCpp::Wrap(browser), menuId); +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefMenuHandlerCppToC::CefMenuHandlerCppToC(CefMenuHandler* cls) + : CefCppToC(cls) +{ + struct_.struct_.on_before_menu = menu_handler_on_before_menu; + struct_.struct_.get_menu_label = menu_handler_get_menu_label; + struct_.struct_.on_menu_action = menu_handler_on_menu_action; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/libcef_dll/cpptoc/menu_handler_cpptoc.h b/libcef_dll/cpptoc/menu_handler_cpptoc.h new file mode 100644 index 000000000..9688adbdf --- /dev/null +++ b/libcef_dll/cpptoc/menu_handler_cpptoc.h @@ -0,0 +1,34 @@ +// 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 was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// +#ifndef _MENUHANDLER_CPPTOC_H +#define _MENUHANDLER_CPPTOC_H + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef.h" +#include "include/cef_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed wrapper-side only. +class CefMenuHandlerCppToC + : public CefCppToC +{ +public: + CefMenuHandlerCppToC(CefMenuHandler* cls); + virtual ~CefMenuHandlerCppToC() {} +}; + +#endif // USING_CEF_SHARED +#endif // _MENUHANDLER_CPPTOC_H + diff --git a/libcef_dll/cpptoc/post_data_cpptoc.cc b/libcef_dll/cpptoc/post_data_cpptoc.cc index df90a1289..bfe5400e0 100644 --- a/libcef_dll/cpptoc/post_data_cpptoc.cc +++ b/libcef_dll/cpptoc/post_data_cpptoc.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -100,7 +100,7 @@ CefPostDataCppToC::CefPostDataCppToC(CefPostData* cls) struct_.struct_.remove_elements = post_data_remove_elements; } -#ifdef _DEBUG +#ifndef NDEBUG template<> long CefCppToC::DebugObjCt = 0; #endif diff --git a/libcef_dll/cpptoc/post_data_cpptoc.h b/libcef_dll/cpptoc/post_data_cpptoc.h index 13a644491..d4ce8ac3a 100644 --- a/libcef_dll/cpptoc/post_data_cpptoc.h +++ b/libcef_dll/cpptoc/post_data_cpptoc.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // diff --git a/libcef_dll/cpptoc/post_data_element_cpptoc.cc b/libcef_dll/cpptoc/post_data_element_cpptoc.cc index c83e2dea8..dc76459df 100644 --- a/libcef_dll/cpptoc/post_data_element_cpptoc.cc +++ b/libcef_dll/cpptoc/post_data_element_cpptoc.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -114,7 +114,7 @@ CefPostDataElementCppToC::CefPostDataElementCppToC(CefPostDataElement* cls) struct_.struct_.get_bytes = post_data_element_get_bytes; } -#ifdef _DEBUG +#ifndef NDEBUG template<> long CefCppToC::DebugObjCt = 0; #endif diff --git a/libcef_dll/cpptoc/post_data_element_cpptoc.h b/libcef_dll/cpptoc/post_data_element_cpptoc.h index 9be615b65..976e726ed 100644 --- a/libcef_dll/cpptoc/post_data_element_cpptoc.h +++ b/libcef_dll/cpptoc/post_data_element_cpptoc.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // diff --git a/libcef_dll/cpptoc/print_handler_cpptoc.cc b/libcef_dll/cpptoc/print_handler_cpptoc.cc new file mode 100644 index 000000000..ce31dd48b --- /dev/null +++ b/libcef_dll/cpptoc/print_handler_cpptoc.cc @@ -0,0 +1,87 @@ +// 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. +// +// --------------------------------------------------------------------------- +// +// A portion of this file was generated by the CEF translator tool. When +// making changes by hand only do so within the body of existing function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/print_handler_cpptoc.h" +#include "libcef_dll/ctocpp/browser_ctocpp.h" +#include "libcef_dll/ctocpp/frame_ctocpp.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +int CEF_CALLBACK print_handler_get_print_options( + struct _cef_print_handler_t* self, cef_browser_t* browser, + struct _cef_print_options_t* printOptions) +{ + DCHECK(self); + DCHECK(browser); + DCHECK(printOptions); + if (!self || !browser || !printOptions) + return 0; + + return CefPrintHandlerCppToC::Get(self)->GetPrintOptions( + CefBrowserCToCpp::Wrap(browser), *printOptions); +} + +int CEF_CALLBACK print_handler_get_print_header_footer( + struct _cef_print_handler_t* self, cef_browser_t* browser, + cef_frame_t* frame, const cef_print_info_t* printInfo, + const cef_string_t* url, const cef_string_t* title, int currentPage, + int maxPages, cef_string_t* topLeft, cef_string_t* topCenter, + cef_string_t* topRight, cef_string_t* bottomLeft, + cef_string_t* bottomCenter, cef_string_t* bottomRight) +{ + DCHECK(self); + DCHECK(browser); + DCHECK(frame); + DCHECK(printInfo); + DCHECK(url); + DCHECK(title); + DCHECK(topLeft); + DCHECK(topCenter); + DCHECK(topRight); + DCHECK(bottomLeft); + DCHECK(bottomCenter); + DCHECK(bottomRight); + if (!self || !browser || !frame || !printInfo || !url || !title || !topLeft || + !topCenter || !topRight || !bottomLeft || !bottomCenter || !bottomRight) + return 0; + + CefString topLeftStr(topLeft); + CefString topCenterStr(topCenter); + CefString topRightStr(topRight); + CefString bottomLeftStr(bottomLeft); + CefString bottomCenterStr(bottomCenter); + CefString bottomRightStr(bottomRight); + return CefPrintHandlerCppToC::Get(self)->GetPrintHeaderFooter( + CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame), *printInfo, + CefString(url), CefString(title), currentPage, maxPages, topLeftStr, + topCenterStr, topRightStr, bottomLeftStr, bottomCenterStr, + bottomRightStr); +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefPrintHandlerCppToC::CefPrintHandlerCppToC(CefPrintHandler* cls) + : CefCppToC( + cls) +{ + struct_.struct_.get_print_options = print_handler_get_print_options; + struct_.struct_.get_print_header_footer = + print_handler_get_print_header_footer; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/libcef_dll/cpptoc/print_handler_cpptoc.h b/libcef_dll/cpptoc/print_handler_cpptoc.h new file mode 100644 index 000000000..ab405f0f9 --- /dev/null +++ b/libcef_dll/cpptoc/print_handler_cpptoc.h @@ -0,0 +1,35 @@ +// 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 was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// +#ifndef _PRINTHANDLER_CPPTOC_H +#define _PRINTHANDLER_CPPTOC_H + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef.h" +#include "include/cef_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed wrapper-side only. +class CefPrintHandlerCppToC + : public CefCppToC +{ +public: + CefPrintHandlerCppToC(CefPrintHandler* cls); + virtual ~CefPrintHandlerCppToC() {} +}; + +#endif // USING_CEF_SHARED +#endif // _PRINTHANDLER_CPPTOC_H + diff --git a/libcef_dll/cpptoc/read_handler_cpptoc.cc b/libcef_dll/cpptoc/read_handler_cpptoc.cc index 4c5842694..b93f25582 100644 --- a/libcef_dll/cpptoc/read_handler_cpptoc.cc +++ b/libcef_dll/cpptoc/read_handler_cpptoc.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -65,7 +65,7 @@ CefReadHandlerCppToC::CefReadHandlerCppToC(CefReadHandler* cls) struct_.struct_.eof = read_handler_eof; } -#ifdef _DEBUG +#ifndef NDEBUG template<> long CefCppToC::DebugObjCt = 0; #endif diff --git a/libcef_dll/cpptoc/read_handler_cpptoc.h b/libcef_dll/cpptoc/read_handler_cpptoc.h index 04118b261..222d347bf 100644 --- a/libcef_dll/cpptoc/read_handler_cpptoc.h +++ b/libcef_dll/cpptoc/read_handler_cpptoc.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // diff --git a/libcef_dll/cpptoc/render_handler_cpptoc.cc b/libcef_dll/cpptoc/render_handler_cpptoc.cc new file mode 100644 index 000000000..f4b87594d --- /dev/null +++ b/libcef_dll/cpptoc/render_handler_cpptoc.cc @@ -0,0 +1,144 @@ +// 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. +// +// --------------------------------------------------------------------------- +// +// A portion of this file was generated by the CEF translator tool. When +// making changes by hand only do so within the body of existing function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/render_handler_cpptoc.h" +#include "libcef_dll/ctocpp/browser_ctocpp.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +int CEF_CALLBACK render_handler_get_view_rect( + struct _cef_render_handler_t* self, cef_browser_t* browser, + cef_rect_t* rect) +{ + DCHECK(self); + DCHECK(browser); + DCHECK(rect); + if (!self || !browser || !rect) + return 0; + + CefRect changeRect(*rect); + int rv = CefRenderHandlerCppToC::Get(self)->GetViewRect( + CefBrowserCToCpp::Wrap(browser), changeRect); + *rect = changeRect; + return rv; +} + +int CEF_CALLBACK render_handler_get_screen_rect( + struct _cef_render_handler_t* self, cef_browser_t* browser, + cef_rect_t* rect) +{ + DCHECK(self); + DCHECK(browser); + DCHECK(rect); + if (!self || !browser || !rect) + return 0; + + CefRect changeRect(*rect); + int rv = CefRenderHandlerCppToC::Get(self)->GetScreenRect( + CefBrowserCToCpp::Wrap(browser), changeRect); + *rect = changeRect; + return rv; +} + +int CEF_CALLBACK render_handler_get_screen_point( + struct _cef_render_handler_t* self, cef_browser_t* browser, int viewX, + int viewY, int* screenX, int* screenY) +{ + DCHECK(self); + DCHECK(browser); + DCHECK(screenX); + DCHECK(screenY); + if (!self || !browser || !screenX || !screenY) + return 0; + + return CefRenderHandlerCppToC::Get(self)->GetScreenPoint( + CefBrowserCToCpp::Wrap(browser), viewX, viewY, *screenX, *screenY); +} + +void CEF_CALLBACK render_handler_on_popup_show( + struct _cef_render_handler_t* self, cef_browser_t* browser, int show) +{ + DCHECK(self); + DCHECK(browser); + if (!self || !browser) + return; + + CefRenderHandlerCppToC::Get(self)->OnPopupShow( + CefBrowserCToCpp::Wrap(browser), show?true:false); +} + +void CEF_CALLBACK render_handler_on_popup_size( + struct _cef_render_handler_t* self, cef_browser_t* browser, + const cef_rect_t* rect) +{ + DCHECK(self); + DCHECK(browser); + DCHECK(rect); + if (!self || !browser || !rect) + return; + + CefRect sizeRect(*rect); + return CefRenderHandlerCppToC::Get(self)->OnPopupSize( + CefBrowserCToCpp::Wrap(browser), sizeRect); +} + +void CEF_CALLBACK render_handler_on_paint(struct _cef_render_handler_t* self, + cef_browser_t* browser, enum cef_paint_element_type_t type, + const cef_rect_t* dirtyRect, const void* buffer) +{ + DCHECK(self); + DCHECK(browser); + DCHECK(dirtyRect); + DCHECK(buffer); + if (!self || !browser || !dirtyRect || !buffer) + return; + + CefRect rect(*dirtyRect); + return CefRenderHandlerCppToC::Get(self)->OnPaint( + CefBrowserCToCpp::Wrap(browser), type, rect, buffer); +} + +void CEF_CALLBACK render_handler_on_cursor_change( + struct _cef_render_handler_t* self, cef_browser_t* browser, + cef_cursor_handle_t cursor) +{ + DCHECK(self); + DCHECK(browser); + if (!self || !browser) + return; + + return CefRenderHandlerCppToC::Get(self)->OnCursorChange( + CefBrowserCToCpp::Wrap(browser), cursor); +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefRenderHandlerCppToC::CefRenderHandlerCppToC(CefRenderHandler* cls) + : CefCppToC( + cls) +{ + struct_.struct_.get_view_rect = render_handler_get_view_rect; + struct_.struct_.get_screen_rect = render_handler_get_screen_rect; + struct_.struct_.get_screen_point = render_handler_get_screen_point; + struct_.struct_.on_popup_show = render_handler_on_popup_show; + struct_.struct_.on_popup_size = render_handler_on_popup_size; + struct_.struct_.on_paint = render_handler_on_paint; + struct_.struct_.on_cursor_change = render_handler_on_cursor_change; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/libcef_dll/cpptoc/render_handler_cpptoc.h b/libcef_dll/cpptoc/render_handler_cpptoc.h new file mode 100644 index 000000000..8c9d8e9ff --- /dev/null +++ b/libcef_dll/cpptoc/render_handler_cpptoc.h @@ -0,0 +1,35 @@ +// 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 was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// +#ifndef _RENDERHANDLER_CPPTOC_H +#define _RENDERHANDLER_CPPTOC_H + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef.h" +#include "include/cef_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed wrapper-side only. +class CefRenderHandlerCppToC + : public CefCppToC +{ +public: + CefRenderHandlerCppToC(CefRenderHandler* cls); + virtual ~CefRenderHandlerCppToC() {} +}; + +#endif // USING_CEF_SHARED +#endif // _RENDERHANDLER_CPPTOC_H + diff --git a/libcef_dll/cpptoc/request_cpptoc.cc b/libcef_dll/cpptoc/request_cpptoc.cc index 30374b4c1..4011518c9 100644 --- a/libcef_dll/cpptoc/request_cpptoc.cc +++ b/libcef_dll/cpptoc/request_cpptoc.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -208,7 +208,7 @@ CefRequestCppToC::CefRequestCppToC(CefRequest* cls) request_set_first_party_for_cookies; } -#ifdef _DEBUG +#ifndef NDEBUG template<> long CefCppToC::DebugObjCt = 0; #endif diff --git a/libcef_dll/cpptoc/request_cpptoc.h b/libcef_dll/cpptoc/request_cpptoc.h index 7d6165a0a..d3d80ee7d 100644 --- a/libcef_dll/cpptoc/request_cpptoc.h +++ b/libcef_dll/cpptoc/request_cpptoc.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // diff --git a/libcef_dll/cpptoc/request_handler_cpptoc.cc b/libcef_dll/cpptoc/request_handler_cpptoc.cc new file mode 100644 index 000000000..11e847a4b --- /dev/null +++ b/libcef_dll/cpptoc/request_handler_cpptoc.cc @@ -0,0 +1,157 @@ +// 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. +// +// --------------------------------------------------------------------------- +// +// A portion of this file was generated by the CEF translator tool. When +// making changes by hand only do so within the body of existing function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/download_handler_cpptoc.h" +#include "libcef_dll/cpptoc/request_handler_cpptoc.h" +#include "libcef_dll/ctocpp/browser_ctocpp.h" +#include "libcef_dll/ctocpp/frame_ctocpp.h" +#include "libcef_dll/ctocpp/request_ctocpp.h" +#include "libcef_dll/ctocpp/response_ctocpp.h" +#include "libcef_dll/ctocpp/stream_reader_ctocpp.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +int CEF_CALLBACK request_handler_on_before_browse( + struct _cef_request_handler_t* self, cef_browser_t* browser, + cef_frame_t* frame, struct _cef_request_t* request, + enum cef_handler_navtype_t navType, int isRedirect) +{ + DCHECK(self); + DCHECK(browser); + DCHECK(frame); + DCHECK(request); + if (!self || !browser || !frame || !request) + return 0; + + return CefRequestHandlerCppToC::Get(self)->OnBeforeBrowse( + CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame), + CefRequestCToCpp::Wrap(request), navType, (isRedirect ? true : false)); +} + +int CEF_CALLBACK request_handler_on_before_resource_load( + struct _cef_request_handler_t* self, cef_browser_t* browser, + struct _cef_request_t* request, cef_string_t* redirectUrl, + struct _cef_stream_reader_t** resourceStream, + struct _cef_response_t* response, int loadFlags) +{ + DCHECK(self); + DCHECK(browser); + DCHECK(request); + DCHECK(redirectUrl); + DCHECK(resourceStream); + DCHECK(response); + if (!self || !browser || !request || !redirectUrl || !resourceStream || + !response) + return 0; + + CefRefPtr streamPtr; + + CefString redirectUrlStr(redirectUrl); + int rv = CefRequestHandlerCppToC::Get(self)->OnBeforeResourceLoad( + CefBrowserCToCpp::Wrap(browser), CefRequestCToCpp::Wrap(request), + redirectUrlStr, streamPtr, CefResponseCToCpp::Wrap(response), loadFlags); + + if(streamPtr.get()) + *resourceStream = CefStreamReaderCToCpp::Unwrap(streamPtr); + + return rv; +} + +int CEF_CALLBACK request_handler_on_protocol_execution( + struct _cef_request_handler_t* self, cef_browser_t* browser, + const cef_string_t* url, int* allowOSExecution) +{ + DCHECK(self); + DCHECK(browser); + DCHECK(url); + DCHECK(allowOSExecution); + if (!self || !browser || !url || !allowOSExecution) + return 0; + + bool allowExec = *allowOSExecution?true:false; + int rv = CefRequestHandlerCppToC::Get(self)->OnProtocolExecution( + CefBrowserCToCpp::Wrap(browser), CefString(url), allowExec); + *allowOSExecution = allowExec; + + return rv; +} + +int CEF_CALLBACK request_handler_get_download_handler( + struct _cef_request_handler_t* self, cef_browser_t* browser, + const cef_string_t* mimeType, const cef_string_t* fileName, + int64 contentLength, struct _cef_download_handler_t** handler) +{ + DCHECK(self); + DCHECK(browser); + DCHECK(mimeType); + DCHECK(fileName); + DCHECK(handler); + if (!self || !browser || !mimeType || !fileName || !handler) + return 0; + + CefRefPtr downloadPtr; + + int rv = CefRequestHandlerCppToC::Get(self)->GetDownloadHandler( + CefBrowserCToCpp::Wrap(browser), CefString(mimeType), CefString(fileName), + contentLength, downloadPtr); + + if(downloadPtr.get()) + *handler = CefDownloadHandlerCppToC::Wrap(downloadPtr); + + return rv; +} + +int CEF_CALLBACK request_handler_get_auth_credentials( + struct _cef_request_handler_t* self, cef_browser_t* browser, int isProxy, + const cef_string_t* host, const cef_string_t* realm, + const cef_string_t* scheme, cef_string_t* username, + cef_string_t* password) +{ + DCHECK(self); + DCHECK(browser); + DCHECK(host); + DCHECK(realm); + DCHECK(scheme); + DCHECK(username); + DCHECK(password); + if (!self || !browser || !host || !realm || !scheme || !username || !password) + return 0; + + CefString usernameStr(username); + CefString passwordStr(password); + return CefRequestHandlerCppToC::Get(self)->GetAuthCredentials( + CefBrowserCToCpp::Wrap(browser), (isProxy ? true : false), + CefString(host), CefString(realm), CefString(scheme), usernameStr, + passwordStr); +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefRequestHandlerCppToC::CefRequestHandlerCppToC(CefRequestHandler* cls) + : CefCppToC(cls) +{ + struct_.struct_.on_before_browse = request_handler_on_before_browse; + struct_.struct_.on_before_resource_load = + request_handler_on_before_resource_load; + struct_.struct_.on_protocol_execution = request_handler_on_protocol_execution; + struct_.struct_.get_download_handler = request_handler_get_download_handler; + struct_.struct_.get_auth_credentials = request_handler_get_auth_credentials; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/libcef_dll/cpptoc/request_handler_cpptoc.h b/libcef_dll/cpptoc/request_handler_cpptoc.h new file mode 100644 index 000000000..0d1c0b647 --- /dev/null +++ b/libcef_dll/cpptoc/request_handler_cpptoc.h @@ -0,0 +1,35 @@ +// 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 was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// +#ifndef _REQUESTHANDLER_CPPTOC_H +#define _REQUESTHANDLER_CPPTOC_H + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef.h" +#include "include/cef_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed wrapper-side only. +class CefRequestHandlerCppToC + : public CefCppToC +{ +public: + CefRequestHandlerCppToC(CefRequestHandler* cls); + virtual ~CefRequestHandlerCppToC() {} +}; + +#endif // USING_CEF_SHARED +#endif // _REQUESTHANDLER_CPPTOC_H + diff --git a/libcef_dll/cpptoc/response_cpptoc.cc b/libcef_dll/cpptoc/response_cpptoc.cc index de32da944..92ebec254 100644 --- a/libcef_dll/cpptoc/response_cpptoc.cc +++ b/libcef_dll/cpptoc/response_cpptoc.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -130,7 +130,7 @@ CefResponseCppToC::CefResponseCppToC(CefResponse* cls) struct_.struct_.set_header_map = response_set_header_map; } -#ifdef _DEBUG +#ifndef NDEBUG template<> long CefCppToC::DebugObjCt = 0; #endif diff --git a/libcef_dll/cpptoc/response_cpptoc.h b/libcef_dll/cpptoc/response_cpptoc.h index 4f996ee96..1fce7673e 100644 --- a/libcef_dll/cpptoc/response_cpptoc.h +++ b/libcef_dll/cpptoc/response_cpptoc.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // diff --git a/libcef_dll/cpptoc/scheme_handler_cpptoc.cc b/libcef_dll/cpptoc/scheme_handler_cpptoc.cc index 6abdecffb..1b553dae3 100644 --- a/libcef_dll/cpptoc/scheme_handler_cpptoc.cc +++ b/libcef_dll/cpptoc/scheme_handler_cpptoc.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -72,7 +72,7 @@ CefSchemeHandlerCppToC::CefSchemeHandlerCppToC(CefSchemeHandler* cls) struct_.struct_.read_response = scheme_handler_read_response; } -#ifdef _DEBUG +#ifndef NDEBUG template<> long CefCppToC::DebugObjCt = 0; #endif diff --git a/libcef_dll/cpptoc/scheme_handler_cpptoc.h b/libcef_dll/cpptoc/scheme_handler_cpptoc.h index 3c4eb9350..51297f48e 100644 --- a/libcef_dll/cpptoc/scheme_handler_cpptoc.h +++ b/libcef_dll/cpptoc/scheme_handler_cpptoc.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // diff --git a/libcef_dll/cpptoc/scheme_handler_factory_cpptoc.cc b/libcef_dll/cpptoc/scheme_handler_factory_cpptoc.cc index 8041e3957..e7100d3a4 100644 --- a/libcef_dll/cpptoc/scheme_handler_factory_cpptoc.cc +++ b/libcef_dll/cpptoc/scheme_handler_factory_cpptoc.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -36,7 +36,7 @@ CefSchemeHandlerFactoryCppToC::CefSchemeHandlerFactoryCppToC( struct_.struct_.create = scheme_handler_factory_create; } -#ifdef _DEBUG +#ifndef NDEBUG template<> long CefCppToC::DebugObjCt = 0; #endif diff --git a/libcef_dll/cpptoc/scheme_handler_factory_cpptoc.h b/libcef_dll/cpptoc/scheme_handler_factory_cpptoc.h index 7397e4bd1..6a1124373 100644 --- a/libcef_dll/cpptoc/scheme_handler_factory_cpptoc.h +++ b/libcef_dll/cpptoc/scheme_handler_factory_cpptoc.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // diff --git a/libcef_dll/cpptoc/stream_reader_cpptoc.cc b/libcef_dll/cpptoc/stream_reader_cpptoc.cc index 9bffde6e4..80296000e 100644 --- a/libcef_dll/cpptoc/stream_reader_cpptoc.cc +++ b/libcef_dll/cpptoc/stream_reader_cpptoc.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -99,7 +99,7 @@ CefStreamReaderCppToC::CefStreamReaderCppToC(CefStreamReader* cls) struct_.struct_.eof = stream_reader_eof; } -#ifdef _DEBUG +#ifndef NDEBUG template<> long CefCppToC::DebugObjCt = 0; #endif diff --git a/libcef_dll/cpptoc/stream_reader_cpptoc.h b/libcef_dll/cpptoc/stream_reader_cpptoc.h index b5757fb44..eb455d08a 100644 --- a/libcef_dll/cpptoc/stream_reader_cpptoc.h +++ b/libcef_dll/cpptoc/stream_reader_cpptoc.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // diff --git a/libcef_dll/cpptoc/stream_writer_cpptoc.cc b/libcef_dll/cpptoc/stream_writer_cpptoc.cc index 11bc8a30e..a4e783a72 100644 --- a/libcef_dll/cpptoc/stream_writer_cpptoc.cc +++ b/libcef_dll/cpptoc/stream_writer_cpptoc.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -98,7 +98,7 @@ CefStreamWriterCppToC::CefStreamWriterCppToC(CefStreamWriter* cls) struct_.struct_.flush = stream_writer_flush; } -#ifdef _DEBUG +#ifndef NDEBUG template<> long CefCppToC::DebugObjCt = 0; #endif diff --git a/libcef_dll/cpptoc/stream_writer_cpptoc.h b/libcef_dll/cpptoc/stream_writer_cpptoc.h index 6d26b597f..0f10936b3 100644 --- a/libcef_dll/cpptoc/stream_writer_cpptoc.h +++ b/libcef_dll/cpptoc/stream_writer_cpptoc.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // diff --git a/libcef_dll/cpptoc/task_cpptoc.cc b/libcef_dll/cpptoc/task_cpptoc.cc index a8d0cc0b5..605c22a9b 100644 --- a/libcef_dll/cpptoc/task_cpptoc.cc +++ b/libcef_dll/cpptoc/task_cpptoc.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -34,7 +34,7 @@ CefTaskCppToC::CefTaskCppToC(CefTask* cls) struct_.struct_.execute = task_execute; } -#ifdef _DEBUG +#ifndef NDEBUG template<> long CefCppToC::DebugObjCt = 0; #endif diff --git a/libcef_dll/cpptoc/task_cpptoc.h b/libcef_dll/cpptoc/task_cpptoc.h index 84aa3b5e7..d3ddb01fb 100644 --- a/libcef_dll/cpptoc/task_cpptoc.h +++ b/libcef_dll/cpptoc/task_cpptoc.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // diff --git a/libcef_dll/cpptoc/v8accessor_cpptoc.cc b/libcef_dll/cpptoc/v8accessor_cpptoc.cc index ab1c98dc6..fda4687ba 100644 --- a/libcef_dll/cpptoc/v8accessor_cpptoc.cc +++ b/libcef_dll/cpptoc/v8accessor_cpptoc.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -70,7 +70,7 @@ CefV8AccessorCppToC::CefV8AccessorCppToC(CefV8Accessor* cls) struct_.struct_.set = v8accessor_set; } -#ifdef _DEBUG +#ifndef NDEBUG template<> long CefCppToC::DebugObjCt = 0; #endif diff --git a/libcef_dll/cpptoc/v8accessor_cpptoc.h b/libcef_dll/cpptoc/v8accessor_cpptoc.h index cb0601eb9..0dadafbf8 100644 --- a/libcef_dll/cpptoc/v8accessor_cpptoc.h +++ b/libcef_dll/cpptoc/v8accessor_cpptoc.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // diff --git a/libcef_dll/cpptoc/v8context_cpptoc.cc b/libcef_dll/cpptoc/v8context_cpptoc.cc index 7c2fc2e1f..79889371f 100644 --- a/libcef_dll/cpptoc/v8context_cpptoc.cc +++ b/libcef_dll/cpptoc/v8context_cpptoc.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -112,7 +112,7 @@ CefV8ContextCppToC::CefV8ContextCppToC(CefV8Context* cls) struct_.struct_.exit = v8context_exit; } -#ifdef _DEBUG +#ifndef NDEBUG template<> long CefCppToC::DebugObjCt = 0; #endif diff --git a/libcef_dll/cpptoc/v8context_cpptoc.h b/libcef_dll/cpptoc/v8context_cpptoc.h index 259825418..4a31be34d 100644 --- a/libcef_dll/cpptoc/v8context_cpptoc.h +++ b/libcef_dll/cpptoc/v8context_cpptoc.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // diff --git a/libcef_dll/cpptoc/v8handler_cpptoc.cc b/libcef_dll/cpptoc/v8handler_cpptoc.cc index 44cb74538..f6fb83e61 100644 --- a/libcef_dll/cpptoc/v8handler_cpptoc.cc +++ b/libcef_dll/cpptoc/v8handler_cpptoc.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -23,7 +23,7 @@ int CEF_CALLBACK v8handler_execute(struct _cef_v8handler_t* self, { DCHECK(self); if(!self) - return RV_CONTINUE; + return 0; CefRefPtr objectPtr; if(object) @@ -55,7 +55,7 @@ CefV8HandlerCppToC::CefV8HandlerCppToC(CefV8Handler* cls) struct_.struct_.execute = v8handler_execute; } -#ifdef _DEBUG +#ifndef NDEBUG template<> long CefCppToC::DebugObjCt = 0; #endif diff --git a/libcef_dll/cpptoc/v8handler_cpptoc.h b/libcef_dll/cpptoc/v8handler_cpptoc.h index 6c69c7287..171fb5095 100644 --- a/libcef_dll/cpptoc/v8handler_cpptoc.h +++ b/libcef_dll/cpptoc/v8handler_cpptoc.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // diff --git a/libcef_dll/cpptoc/v8value_cpptoc.cc b/libcef_dll/cpptoc/v8value_cpptoc.cc index b2c02a81d..d76c38f8a 100644 --- a/libcef_dll/cpptoc/v8value_cpptoc.cc +++ b/libcef_dll/cpptoc/v8value_cpptoc.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -507,7 +507,7 @@ CefV8ValueCppToC::CefV8ValueCppToC(CefV8Value* cls) v8value_execute_function_with_context; } -#ifdef _DEBUG +#ifndef NDEBUG template<> long CefCppToC::DebugObjCt = 0; #endif diff --git a/libcef_dll/cpptoc/v8value_cpptoc.h b/libcef_dll/cpptoc/v8value_cpptoc.h index ba992302b..da541b492 100644 --- a/libcef_dll/cpptoc/v8value_cpptoc.h +++ b/libcef_dll/cpptoc/v8value_cpptoc.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // diff --git a/libcef_dll/cpptoc/web_urlrequest_client_cpptoc.cc b/libcef_dll/cpptoc/web_urlrequest_client_cpptoc.cc index 8dd846ab2..ad45327e1 100644 --- a/libcef_dll/cpptoc/web_urlrequest_client_cpptoc.cc +++ b/libcef_dll/cpptoc/web_urlrequest_client_cpptoc.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -118,7 +118,7 @@ CefWebURLRequestClientCppToC::CefWebURLRequestClientCppToC( struct_.struct_.on_error = web_urlrequest_client_on_error; } -#ifdef _DEBUG +#ifndef NDEBUG template<> long CefCppToC::DebugObjCt = 0; #endif diff --git a/libcef_dll/cpptoc/web_urlrequest_client_cpptoc.h b/libcef_dll/cpptoc/web_urlrequest_client_cpptoc.h index 626cbe372..fabcd94d9 100644 --- a/libcef_dll/cpptoc/web_urlrequest_client_cpptoc.h +++ b/libcef_dll/cpptoc/web_urlrequest_client_cpptoc.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // diff --git a/libcef_dll/cpptoc/web_urlrequest_cpptoc.cc b/libcef_dll/cpptoc/web_urlrequest_cpptoc.cc index 8f0aa6435..270db8ab8 100644 --- a/libcef_dll/cpptoc/web_urlrequest_cpptoc.cc +++ b/libcef_dll/cpptoc/web_urlrequest_cpptoc.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -66,7 +66,7 @@ CefWebURLRequestCppToC::CefWebURLRequestCppToC(CefWebURLRequest* cls) struct_.struct_.get_state = web_urlrequest_get_state; } -#ifdef _DEBUG +#ifndef NDEBUG template<> long CefCppToC::DebugObjCt = 0; #endif diff --git a/libcef_dll/cpptoc/web_urlrequest_cpptoc.h b/libcef_dll/cpptoc/web_urlrequest_cpptoc.h index 6e73d1b60..934fe263f 100644 --- a/libcef_dll/cpptoc/web_urlrequest_cpptoc.h +++ b/libcef_dll/cpptoc/web_urlrequest_cpptoc.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // diff --git a/libcef_dll/cpptoc/write_handler_cpptoc.cc b/libcef_dll/cpptoc/write_handler_cpptoc.cc index 7bc286da5..7409c3fbe 100644 --- a/libcef_dll/cpptoc/write_handler_cpptoc.cc +++ b/libcef_dll/cpptoc/write_handler_cpptoc.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -66,7 +66,7 @@ CefWriteHandlerCppToC::CefWriteHandlerCppToC(CefWriteHandler* cls) struct_.struct_.flush = write_handler_flush; } -#ifdef _DEBUG +#ifndef NDEBUG template<> long CefCppToC::DebugObjCt = 0; #endif diff --git a/libcef_dll/cpptoc/write_handler_cpptoc.h b/libcef_dll/cpptoc/write_handler_cpptoc.h index 328aff966..9cf60294a 100644 --- a/libcef_dll/cpptoc/write_handler_cpptoc.h +++ b/libcef_dll/cpptoc/write_handler_cpptoc.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // diff --git a/libcef_dll/cpptoc/xml_reader_cpptoc.cc b/libcef_dll/cpptoc/xml_reader_cpptoc.cc index fbd4c490a..986bdb45b 100644 --- a/libcef_dll/cpptoc/xml_reader_cpptoc.cc +++ b/libcef_dll/cpptoc/xml_reader_cpptoc.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -377,7 +377,7 @@ CefXmlReaderCppToC::CefXmlReaderCppToC(CefXmlReader* cls) xml_reader_move_to_carrying_element; } -#ifdef _DEBUG +#ifndef NDEBUG template<> long CefCppToC::DebugObjCt = 0; #endif diff --git a/libcef_dll/cpptoc/xml_reader_cpptoc.h b/libcef_dll/cpptoc/xml_reader_cpptoc.h index a20cbfbb7..a1b1ee073 100644 --- a/libcef_dll/cpptoc/xml_reader_cpptoc.h +++ b/libcef_dll/cpptoc/xml_reader_cpptoc.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // diff --git a/libcef_dll/cpptoc/zip_reader_cpptoc.cc b/libcef_dll/cpptoc/zip_reader_cpptoc.cc index 82b60d3c8..40b3a5fc5 100644 --- a/libcef_dll/cpptoc/zip_reader_cpptoc.cc +++ b/libcef_dll/cpptoc/zip_reader_cpptoc.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -165,7 +165,7 @@ CefZipReaderCppToC::CefZipReaderCppToC(CefZipReader* cls) struct_.struct_.eof = zip_reader_eof; } -#ifdef _DEBUG +#ifndef NDEBUG template<> long CefCppToC::DebugObjCt = 0; #endif diff --git a/libcef_dll/cpptoc/zip_reader_cpptoc.h b/libcef_dll/cpptoc/zip_reader_cpptoc.h index 292b95dda..6a6b0e24c 100644 --- a/libcef_dll/cpptoc/zip_reader_cpptoc.h +++ b/libcef_dll/cpptoc/zip_reader_cpptoc.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // diff --git a/libcef_dll/ctocpp/base_ctocpp.h b/libcef_dll/ctocpp/base_ctocpp.h index 8abd0f42f..2a74aaef2 100644 --- a/libcef_dll/ctocpp/base_ctocpp.h +++ b/libcef_dll/ctocpp/base_ctocpp.h @@ -11,7 +11,7 @@ // CefCToCpp implementation for CefBase. -class CefBaseCToCpp : public CefThreadSafeBase +class CefBaseCToCpp : public CefBase { public: // Use this method to create a wrapper class instance for a structure @@ -56,16 +56,20 @@ public: // CefBase methods increment/decrement reference counts on both this object // and the underlying wrapped structure. - virtual int AddRef() + int AddRef() { UnderlyingAddRef(); - return CefThreadSafeBase::AddRef(); + return refct_.AddRef(); } - virtual int Release() + int Release() { UnderlyingRelease(); - return CefThreadSafeBase::Release(); + int retval = refct_.Release(); + if (retval == 0) + delete this; + return retval; } + int GetRefCt() { return refct_.GetRefCt(); } // Increment/decrement reference counts on only the underlying class. int UnderlyingAddRef() @@ -88,6 +92,7 @@ public: } protected: + CefRefCount refct_; cef_base_t* struct_; }; diff --git a/libcef_dll/ctocpp/browser_ctocpp.cc b/libcef_dll/ctocpp/browser_ctocpp.cc index 41de0b90a..eeb644228 100644 --- a/libcef_dll/ctocpp/browser_ctocpp.cc +++ b/libcef_dll/ctocpp/browser_ctocpp.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -10,7 +10,7 @@ // tools directory for more information. // -#include "libcef_dll/cpptoc/handler_cpptoc.h" +#include "libcef_dll/cpptoc/client_cpptoc.h" #include "libcef_dll/ctocpp/browser_ctocpp.h" #include "libcef_dll/ctocpp/frame_ctocpp.h" #include "libcef_dll/transfer_util.h" @@ -18,18 +18,20 @@ // STATIC METHODS - Body may be edited by hand. -bool CefBrowser::CreateBrowser(CefWindowInfo& windowInfo, bool popup, - CefRefPtr handler, const CefString& url) +bool CefBrowser::CreateBrowser(CefWindowInfo& windowInfo, + CefRefPtr client, const CefString& url, + const CefBrowserSettings& settings) { - return cef_browser_create(&windowInfo, popup, CefHandlerCppToC::Wrap(handler), - url.GetStruct())?true:false; + return cef_browser_create(&windowInfo, CefClientCppToC::Wrap(client), + url.GetStruct(), &settings)?true:false; } CefRefPtr CefBrowser::CreateBrowserSync(CefWindowInfo& windowInfo, - bool popup, CefRefPtr handler, const CefString& url) + CefRefPtr client, const CefString& url, + const CefBrowserSettings& settings) { - cef_browser_t* impl = cef_browser_create_sync(&windowInfo, popup, - CefHandlerCppToC::Wrap(handler), url.GetStruct()); + cef_browser_t* impl = cef_browser_create_sync(&windowInfo, + CefClientCppToC::Wrap(client), url.GetStruct(), &settings); if(impl) return CefBrowserCToCpp::Wrap(impl); return NULL; @@ -126,14 +128,14 @@ bool CefBrowserCToCpp::IsPopup() return struct_->is_popup(struct_)?true:false; } -CefRefPtr CefBrowserCToCpp::GetHandler() +CefRefPtr CefBrowserCToCpp::GetClient() { - if(CEF_MEMBER_MISSING(struct_, get_handler)) + if (CEF_MEMBER_MISSING(struct_, get_client)) return NULL; - cef_handler_t* handlerStruct = struct_->get_handler(struct_); - if(handlerStruct) - return CefHandlerCppToC::Unwrap(handlerStruct); + cef_client_t* clientStruct = struct_->get_client(struct_); + if(clientStruct) + return CefClientCppToC::Unwrap(clientStruct); return NULL; } @@ -341,7 +343,7 @@ void CefBrowserCToCpp::SendCaptureLostEvent() } -#ifdef _DEBUG +#ifndef NDEBUG template<> long CefCToCpp::DebugObjCt = 0; #endif diff --git a/libcef_dll/ctocpp/browser_ctocpp.h b/libcef_dll/ctocpp/browser_ctocpp.h index b78684d7f..8482dcb2d 100644 --- a/libcef_dll/ctocpp/browser_ctocpp.h +++ b/libcef_dll/ctocpp/browser_ctocpp.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -31,45 +31,45 @@ public: virtual ~CefBrowserCToCpp() {} // CefBrowser methods - virtual void CloseBrowser(); - virtual bool CanGoBack(); - virtual void GoBack(); - virtual bool CanGoForward(); - virtual void GoForward(); - virtual void Reload(); - virtual void ReloadIgnoreCache(); - virtual void StopLoad(); - virtual void SetFocus(bool enable); - virtual CefWindowHandle GetWindowHandle(); - virtual bool IsPopup(); - virtual CefRefPtr GetHandler(); - virtual CefRefPtr GetMainFrame(); - virtual CefRefPtr GetFocusedFrame(); - virtual CefRefPtr GetFrame(const CefString& name); - virtual void GetFrameNames(std::vector& names); + virtual void CloseBrowser() OVERRIDE; + virtual bool CanGoBack() OVERRIDE; + virtual void GoBack() OVERRIDE; + virtual bool CanGoForward() OVERRIDE; + virtual void GoForward() OVERRIDE; + virtual void Reload() OVERRIDE; + virtual void ReloadIgnoreCache() OVERRIDE; + virtual void StopLoad() OVERRIDE; + virtual void SetFocus(bool enable) OVERRIDE; + virtual CefWindowHandle GetWindowHandle() OVERRIDE; + virtual bool IsPopup() OVERRIDE; + virtual CefRefPtr GetClient() OVERRIDE; + virtual CefRefPtr GetMainFrame() OVERRIDE; + virtual CefRefPtr GetFocusedFrame() OVERRIDE; + virtual CefRefPtr GetFrame(const CefString& name) OVERRIDE; + virtual void GetFrameNames(std::vector& names) OVERRIDE; virtual void Find(int identifier, const CefString& searchText, bool forward, - bool matchCase, bool findNext); - virtual void StopFinding(bool clearSelection); - virtual double GetZoomLevel(); - virtual void SetZoomLevel(double zoomLevel); - virtual void ShowDevTools(); - virtual void CloseDevTools(); - virtual bool IsWindowRenderingDisabled(); - virtual bool GetSize(PaintElementType type, int& width, int& height); - virtual void SetSize(PaintElementType type, int width, int height); - virtual bool IsPopupVisible(); - virtual void HidePopup(); - virtual void Invalidate(const CefRect& dirtyRect); + bool matchCase, bool findNext) OVERRIDE; + virtual void StopFinding(bool clearSelection) OVERRIDE; + virtual double GetZoomLevel() OVERRIDE; + virtual void SetZoomLevel(double zoomLevel) OVERRIDE; + virtual void ShowDevTools() OVERRIDE; + virtual void CloseDevTools() OVERRIDE; + virtual bool IsWindowRenderingDisabled() OVERRIDE; + virtual bool GetSize(PaintElementType type, int& width, int& height) OVERRIDE; + virtual void SetSize(PaintElementType type, int width, int height) OVERRIDE; + virtual bool IsPopupVisible() OVERRIDE; + virtual void HidePopup() OVERRIDE; + virtual void Invalidate(const CefRect& dirtyRect) OVERRIDE; virtual bool GetImage(PaintElementType type, int width, int height, - void* buffer); + void* buffer) OVERRIDE; virtual void SendKeyEvent(KeyType type, int key, int modifiers, bool sysChar, - bool imeChar); + bool imeChar) OVERRIDE; virtual void SendMouseClickEvent(int x, int y, MouseButtonType type, - bool mouseUp, int clickCount); - virtual void SendMouseMoveEvent(int x, int y, bool mouseLeave); - virtual void SendMouseWheelEvent(int x, int y, int delta); - virtual void SendFocusEvent(bool setFocus); - virtual void SendCaptureLostEvent(); + bool mouseUp, int clickCount) OVERRIDE; + virtual void SendMouseMoveEvent(int x, int y, bool mouseLeave) OVERRIDE; + virtual void SendMouseWheelEvent(int x, int y, int delta) OVERRIDE; + virtual void SendFocusEvent(bool setFocus) OVERRIDE; + virtual void SendCaptureLostEvent() OVERRIDE; }; #endif // USING_CEF_SHARED diff --git a/libcef_dll/ctocpp/client_ctocpp.cc b/libcef_dll/ctocpp/client_ctocpp.cc new file mode 100644 index 000000000..ddd076905 --- /dev/null +++ b/libcef_dll/ctocpp/client_ctocpp.cc @@ -0,0 +1,183 @@ +// 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. +// +// --------------------------------------------------------------------------- +// +// A portion of this file was generated by the CEF translator tool. When +// making changes by hand only do so within the body of existing static and +// virtual method implementations. See the translator.README.txt file in the +// tools directory for more information. +// + +#include "libcef_dll/ctocpp/client_ctocpp.h" +#include "libcef_dll/ctocpp/display_handler_ctocpp.h" +#include "libcef_dll/ctocpp/find_handler_ctocpp.h" +#include "libcef_dll/ctocpp/focus_handler_ctocpp.h" +#include "libcef_dll/ctocpp/jsbinding_handler_ctocpp.h" +#include "libcef_dll/ctocpp/jsdialog_handler_ctocpp.h" +#include "libcef_dll/ctocpp/keyboard_handler_ctocpp.h" +#include "libcef_dll/ctocpp/life_span_handler_ctocpp.h" +#include "libcef_dll/ctocpp/load_handler_ctocpp.h" +#include "libcef_dll/ctocpp/menu_handler_ctocpp.h" +#include "libcef_dll/ctocpp/print_handler_ctocpp.h" +#include "libcef_dll/ctocpp/render_handler_ctocpp.h" +#include "libcef_dll/ctocpp/request_handler_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +CefRefPtr CefClientCToCpp::GetLifeSpanHandler() +{ + if (CEF_MEMBER_MISSING(struct_, get_life_span_handler)) + return NULL; + + cef_life_span_handler_t* handlerStruct = + struct_->get_life_span_handler(struct_); + if(handlerStruct) + return CefLifeSpanHandlerCToCpp::Wrap(handlerStruct); + + return NULL; +} + +CefRefPtr CefClientCToCpp::GetLoadHandler() +{ + if (CEF_MEMBER_MISSING(struct_, get_load_handler)) + return NULL; + + cef_load_handler_t* handlerStruct = struct_->get_load_handler(struct_); + if(handlerStruct) + return CefLoadHandlerCToCpp::Wrap(handlerStruct); + + return NULL; +} + +CefRefPtr CefClientCToCpp::GetRequestHandler() +{ + if (CEF_MEMBER_MISSING(struct_, get_request_handler)) + return NULL; + + cef_request_handler_t* handlerStruct = struct_->get_request_handler(struct_); + if(handlerStruct) + return CefRequestHandlerCToCpp::Wrap(handlerStruct); + + return NULL; +} + +CefRefPtr CefClientCToCpp::GetDisplayHandler() +{ + if (CEF_MEMBER_MISSING(struct_, get_display_handler)) + return NULL; + + cef_display_handler_t* handlerStruct = struct_->get_display_handler(struct_); + if(handlerStruct) + return CefDisplayHandlerCToCpp::Wrap(handlerStruct); + + return NULL; +} + +CefRefPtr CefClientCToCpp::GetFocusHandler() +{ + if (CEF_MEMBER_MISSING(struct_, get_focus_handler)) + return NULL; + + cef_focus_handler_t* handlerStruct = struct_->get_focus_handler(struct_); + if(handlerStruct) + return CefFocusHandlerCToCpp::Wrap(handlerStruct); + + return NULL; +} + +CefRefPtr CefClientCToCpp::GetKeyboardHandler() +{ + if (CEF_MEMBER_MISSING(struct_, get_keyboard_handler)) + return NULL; + + cef_keyboard_handler_t* handlerStruct = + struct_->get_keyboard_handler(struct_); + if(handlerStruct) + return CefKeyboardHandlerCToCpp::Wrap(handlerStruct); + + return NULL; +} + +CefRefPtr CefClientCToCpp::GetMenuHandler() +{ + if (CEF_MEMBER_MISSING(struct_, get_menu_handler)) + return NULL; + + cef_menu_handler_t* handlerStruct = struct_->get_menu_handler(struct_); + if(handlerStruct) + return CefMenuHandlerCToCpp::Wrap(handlerStruct); + + return NULL; +} + +CefRefPtr CefClientCToCpp::GetPrintHandler() +{ + if (CEF_MEMBER_MISSING(struct_, get_print_handler)) + return NULL; + + cef_print_handler_t* handlerStruct = struct_->get_print_handler(struct_); + if(handlerStruct) + return CefPrintHandlerCToCpp::Wrap(handlerStruct); + + return NULL; +} + +CefRefPtr CefClientCToCpp::GetFindHandler() +{ + if (CEF_MEMBER_MISSING(struct_, get_find_handler)) + return NULL; + + cef_find_handler_t* handlerStruct = struct_->get_find_handler(struct_); + if(handlerStruct) + return CefFindHandlerCToCpp::Wrap(handlerStruct); + + return NULL; +} + +CefRefPtr CefClientCToCpp::GetJSDialogHandler() +{ + if (CEF_MEMBER_MISSING(struct_, get_jsdialog_handler)) + return NULL; + + cef_jsdialog_handler_t* handlerStruct = + struct_->get_jsdialog_handler(struct_); + if(handlerStruct) + return CefJSDialogHandlerCToCpp::Wrap(handlerStruct); + + return NULL; +} + +CefRefPtr CefClientCToCpp::GetJSBindingHandler() +{ + if (CEF_MEMBER_MISSING(struct_, get_jsbinding_handler)) + return NULL; + + cef_jsbinding_handler_t* handlerStruct = + struct_->get_jsbinding_handler(struct_); + if(handlerStruct) + return CefJSBindingHandlerCToCpp::Wrap(handlerStruct); + + return NULL; +} + +CefRefPtr CefClientCToCpp::GetRenderHandler() +{ + if (CEF_MEMBER_MISSING(struct_, get_render_handler)) + return NULL; + + cef_render_handler_t* handlerStruct = struct_->get_render_handler(struct_); + if(handlerStruct) + return CefRenderHandlerCToCpp::Wrap(handlerStruct); + + return NULL; +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/libcef_dll/ctocpp/client_ctocpp.h b/libcef_dll/ctocpp/client_ctocpp.h new file mode 100644 index 000000000..e69801423 --- /dev/null +++ b/libcef_dll/ctocpp/client_ctocpp.h @@ -0,0 +1,50 @@ +// 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 was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// + +#ifndef _CLIENT_CTOCPP_H +#define _CLIENT_CTOCPP_H + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef.h" +#include "include/cef_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed DLL-side only. +class CefClientCToCpp + : public CefCToCpp +{ +public: + CefClientCToCpp(cef_client_t* str) + : CefCToCpp(str) {} + virtual ~CefClientCToCpp() {} + + // CefClient methods + virtual CefRefPtr GetLifeSpanHandler() OVERRIDE; + virtual CefRefPtr GetLoadHandler() OVERRIDE; + virtual CefRefPtr GetRequestHandler() OVERRIDE; + virtual CefRefPtr GetDisplayHandler() OVERRIDE; + virtual CefRefPtr GetFocusHandler() OVERRIDE; + virtual CefRefPtr GetKeyboardHandler() OVERRIDE; + virtual CefRefPtr GetMenuHandler() OVERRIDE; + virtual CefRefPtr GetPrintHandler() OVERRIDE; + virtual CefRefPtr GetFindHandler() OVERRIDE; + virtual CefRefPtr GetJSDialogHandler() OVERRIDE; + virtual CefRefPtr GetJSBindingHandler() OVERRIDE; + virtual CefRefPtr GetRenderHandler() OVERRIDE; +}; + +#endif // BUILDING_CEF_SHARED +#endif // _CLIENT_CTOCPP_H + diff --git a/libcef_dll/ctocpp/cookie_visitor_ctocpp.cc b/libcef_dll/ctocpp/cookie_visitor_ctocpp.cc index 6b6816271..89f53d999 100644 --- a/libcef_dll/ctocpp/cookie_visitor_ctocpp.cc +++ b/libcef_dll/ctocpp/cookie_visitor_ctocpp.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -30,7 +30,7 @@ bool CefCookieVisitorCToCpp::Visit(const CefCookie& cookie, int count, } -#ifdef _DEBUG +#ifndef NDEBUG template<> long CefCToCpp::DebugObjCt = 0; #endif diff --git a/libcef_dll/ctocpp/cookie_visitor_ctocpp.h b/libcef_dll/ctocpp/cookie_visitor_ctocpp.h index d74620bf7..f79e11faa 100644 --- a/libcef_dll/ctocpp/cookie_visitor_ctocpp.h +++ b/libcef_dll/ctocpp/cookie_visitor_ctocpp.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -34,7 +34,7 @@ public: // CefCookieVisitor methods virtual bool Visit(const CefCookie& cookie, int count, int total, - bool& deleteCookie); + bool& deleteCookie) OVERRIDE; }; #endif // BUILDING_CEF_SHARED diff --git a/libcef_dll/ctocpp/ctocpp.h b/libcef_dll/ctocpp/ctocpp.h index bd4360f04..4b8348c44 100644 --- a/libcef_dll/ctocpp/ctocpp.h +++ b/libcef_dll/ctocpp/ctocpp.h @@ -14,7 +14,7 @@ // exists on the other side of the DLL boundary but will have methods called on // this side of the DLL boundary. template -class CefCToCpp : public CefThreadSafeBase +class CefCToCpp : public BaseName { public: // Use this method to create a wrapper class instance for a structure @@ -50,13 +50,13 @@ public: { DCHECK(str); -#ifdef _DEBUG +#ifndef NDEBUG CefAtomicIncrement(&DebugObjCt); #endif } virtual ~CefCToCpp() { -#ifdef _DEBUG +#ifndef NDEBUG CefAtomicDecrement(&DebugObjCt); #endif } @@ -68,16 +68,20 @@ public: // CefBase methods increment/decrement reference counts on both this object // and the underlying wrapped structure. - virtual int AddRef() + int AddRef() { UnderlyingAddRef(); - return CefThreadSafeBase::AddRef(); + return refct_.AddRef(); } - virtual int Release() + int Release() { UnderlyingRelease(); - return CefThreadSafeBase::Release(); + int retval = refct_.Release(); + if (retval == 0) + delete this; + return retval; } + int GetRefCt() { return refct_.GetRefCt(); } // Increment/decrement reference counts on only the underlying class. int UnderlyingAddRef() @@ -99,12 +103,13 @@ public: return struct_->base.get_refct(&struct_->base); } -#ifdef _DEBUG +#ifndef NDEBUG // Simple tracking of allocated objects. static long DebugObjCt; #endif protected: + CefRefCount refct_; StructName* struct_; }; diff --git a/libcef_dll/ctocpp/display_handler_ctocpp.cc b/libcef_dll/ctocpp/display_handler_ctocpp.cc new file mode 100644 index 000000000..f85075ab3 --- /dev/null +++ b/libcef_dll/ctocpp/display_handler_ctocpp.cc @@ -0,0 +1,85 @@ +// 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. +// +// --------------------------------------------------------------------------- +// +// A portion of this file was generated by the CEF translator tool. When +// making changes by hand only do so within the body of existing static and +// virtual method implementations. See the translator.README.txt file in the +// tools directory for more information. +// + +#include "libcef_dll/cpptoc/browser_cpptoc.h" +#include "libcef_dll/cpptoc/frame_cpptoc.h" +#include "libcef_dll/ctocpp/display_handler_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +void CefDisplayHandlerCToCpp::OnNavStateChange(CefRefPtr browser, + bool canGoBack, bool canGoForward) +{ + if (CEF_MEMBER_MISSING(struct_, on_nav_state_change)) + return; + + struct_->on_nav_state_change(struct_, CefBrowserCppToC::Wrap(browser), + canGoBack, canGoForward); +} + +void CefDisplayHandlerCToCpp::OnAddressChange(CefRefPtr browser, + CefRefPtr frame, const CefString& url) +{ + if (CEF_MEMBER_MISSING(struct_, on_address_change)) + return; + + struct_->on_address_change(struct_, CefBrowserCppToC::Wrap(browser), + CefFrameCppToC::Wrap(frame), url.GetStruct()); +} + +void CefDisplayHandlerCToCpp::OnTitleChange(CefRefPtr browser, + const CefString& title) +{ + if (CEF_MEMBER_MISSING(struct_, on_title_change)) + return; + + struct_->on_title_change(struct_, CefBrowserCppToC::Wrap(browser), + title.GetStruct()); +} + +bool CefDisplayHandlerCToCpp::OnTooltip(CefRefPtr browser, + CefString& text) +{ + if (CEF_MEMBER_MISSING(struct_, on_tooltip)) + return false; + + return struct_->on_tooltip(struct_, CefBrowserCppToC::Wrap(browser), + text.GetWritableStruct()) ? true : false; +} + +void CefDisplayHandlerCToCpp::OnStatusMessage(CefRefPtr browser, + const CefString& value, StatusType type) +{ + if (CEF_MEMBER_MISSING(struct_, on_status_message)) + return; + + struct_->on_status_message(struct_, CefBrowserCppToC::Wrap(browser), + value.GetStruct(), type); +} + +bool CefDisplayHandlerCToCpp::OnConsoleMessage(CefRefPtr browser, + const CefString& message, const CefString& source, int line) +{ + if (CEF_MEMBER_MISSING(struct_, on_console_message)) + return false; + + return struct_->on_console_message(struct_, CefBrowserCppToC::Wrap(browser), + message.GetStruct(), source.GetStruct(), line) ? true : false; +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/libcef_dll/ctocpp/display_handler_ctocpp.h b/libcef_dll/ctocpp/display_handler_ctocpp.h new file mode 100644 index 000000000..12ab990e3 --- /dev/null +++ b/libcef_dll/ctocpp/display_handler_ctocpp.h @@ -0,0 +1,52 @@ +// 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 was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// + +#ifndef _DISPLAYHANDLER_CTOCPP_H +#define _DISPLAYHANDLER_CTOCPP_H + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef.h" +#include "include/cef_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed DLL-side only. +class CefDisplayHandlerCToCpp + : public CefCToCpp +{ +public: + CefDisplayHandlerCToCpp(cef_display_handler_t* str) + : CefCToCpp(str) {} + virtual ~CefDisplayHandlerCToCpp() {} + + // 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 OnTooltip(CefRefPtr browser, + CefString& text) OVERRIDE; + virtual void OnStatusMessage(CefRefPtr browser, + const CefString& value, StatusType type) OVERRIDE; + virtual bool OnConsoleMessage(CefRefPtr browser, + const CefString& message, const CefString& source, int line) OVERRIDE; +}; + +#endif // BUILDING_CEF_SHARED +#endif // _DISPLAYHANDLER_CTOCPP_H + diff --git a/libcef_dll/ctocpp/domdocument_ctocpp.cc b/libcef_dll/ctocpp/domdocument_ctocpp.cc index 9726e316e..98b2ef60d 100644 --- a/libcef_dll/ctocpp/domdocument_ctocpp.cc +++ b/libcef_dll/ctocpp/domdocument_ctocpp.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -183,7 +183,7 @@ CefString CefDOMDocumentCToCpp::GetCompleteURL(const CefString& partialURL) } -#ifdef _DEBUG +#ifndef NDEBUG template<> long CefCToCpp::DebugObjCt = 0; #endif diff --git a/libcef_dll/ctocpp/domdocument_ctocpp.h b/libcef_dll/ctocpp/domdocument_ctocpp.h index 98ceaea75..1f7b20a1f 100644 --- a/libcef_dll/ctocpp/domdocument_ctocpp.h +++ b/libcef_dll/ctocpp/domdocument_ctocpp.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -32,22 +32,22 @@ public: virtual ~CefDOMDocumentCToCpp() {} // CefDOMDocument methods - virtual Type GetType(); - virtual CefRefPtr GetDocument(); - virtual CefRefPtr GetBody(); - virtual CefRefPtr GetHead(); - virtual CefString GetTitle(); - virtual CefRefPtr GetElementById(const CefString& id); - virtual CefRefPtr GetFocusedNode(); - virtual bool HasSelection(); - virtual CefRefPtr GetSelectionStartNode(); - virtual int GetSelectionStartOffset(); - virtual CefRefPtr GetSelectionEndNode(); - virtual int GetSelectionEndOffset(); - virtual CefString GetSelectionAsMarkup(); - virtual CefString GetSelectionAsText(); - virtual CefString GetBaseURL(); - virtual CefString GetCompleteURL(const CefString& partialURL); + virtual Type GetType() OVERRIDE; + virtual CefRefPtr GetDocument() OVERRIDE; + virtual CefRefPtr GetBody() OVERRIDE; + virtual CefRefPtr GetHead() OVERRIDE; + virtual CefString GetTitle() OVERRIDE; + virtual CefRefPtr GetElementById(const CefString& id) OVERRIDE; + virtual CefRefPtr GetFocusedNode() OVERRIDE; + virtual bool HasSelection() OVERRIDE; + virtual CefRefPtr GetSelectionStartNode() OVERRIDE; + virtual int GetSelectionStartOffset() OVERRIDE; + virtual CefRefPtr GetSelectionEndNode() OVERRIDE; + virtual int GetSelectionEndOffset() OVERRIDE; + virtual CefString GetSelectionAsMarkup() OVERRIDE; + virtual CefString GetSelectionAsText() OVERRIDE; + virtual CefString GetBaseURL() OVERRIDE; + virtual CefString GetCompleteURL(const CefString& partialURL) OVERRIDE; }; #endif // USING_CEF_SHARED diff --git a/libcef_dll/ctocpp/domevent_ctocpp.cc b/libcef_dll/ctocpp/domevent_ctocpp.cc index a738c933c..f04e4adff 100644 --- a/libcef_dll/ctocpp/domevent_ctocpp.cc +++ b/libcef_dll/ctocpp/domevent_ctocpp.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -94,7 +94,7 @@ CefRefPtr CefDOMEventCToCpp::GetCurrentTarget() } -#ifdef _DEBUG +#ifndef NDEBUG template<> long CefCToCpp::DebugObjCt = 0; #endif diff --git a/libcef_dll/ctocpp/domevent_ctocpp.h b/libcef_dll/ctocpp/domevent_ctocpp.h index b98335e71..2ce132bcf 100644 --- a/libcef_dll/ctocpp/domevent_ctocpp.h +++ b/libcef_dll/ctocpp/domevent_ctocpp.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -31,14 +31,14 @@ public: virtual ~CefDOMEventCToCpp() {} // CefDOMEvent methods - virtual CefString GetType(); - virtual Category GetCategory(); - virtual Phase GetPhase(); - virtual bool CanBubble(); - virtual bool CanCancel(); - virtual CefRefPtr GetDocument(); - virtual CefRefPtr GetTarget(); - virtual CefRefPtr GetCurrentTarget(); + virtual CefString GetType() OVERRIDE; + virtual Category GetCategory() OVERRIDE; + virtual Phase GetPhase() OVERRIDE; + virtual bool CanBubble() OVERRIDE; + virtual bool CanCancel() OVERRIDE; + virtual CefRefPtr GetDocument() OVERRIDE; + virtual CefRefPtr GetTarget() OVERRIDE; + virtual CefRefPtr GetCurrentTarget() OVERRIDE; }; #endif // USING_CEF_SHARED diff --git a/libcef_dll/ctocpp/domevent_listener_ctocpp.cc b/libcef_dll/ctocpp/domevent_listener_ctocpp.cc index d5c43fff7..4214cbbbc 100644 --- a/libcef_dll/ctocpp/domevent_listener_ctocpp.cc +++ b/libcef_dll/ctocpp/domevent_listener_ctocpp.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -28,7 +28,7 @@ void CefDOMEventListenerCToCpp::HandleEvent(CefRefPtr event) } -#ifdef _DEBUG +#ifndef NDEBUG template<> long CefCToCpp::DebugObjCt = 0; #endif diff --git a/libcef_dll/ctocpp/domevent_listener_ctocpp.h b/libcef_dll/ctocpp/domevent_listener_ctocpp.h index 99079ec62..a602c82f3 100644 --- a/libcef_dll/ctocpp/domevent_listener_ctocpp.h +++ b/libcef_dll/ctocpp/domevent_listener_ctocpp.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -33,7 +33,7 @@ public: virtual ~CefDOMEventListenerCToCpp() {} // CefDOMEventListener methods - virtual void HandleEvent(CefRefPtr event); + virtual void HandleEvent(CefRefPtr event) OVERRIDE; }; #endif // BUILDING_CEF_SHARED diff --git a/libcef_dll/ctocpp/domnode_ctocpp.cc b/libcef_dll/ctocpp/domnode_ctocpp.cc index d3db53b3d..0790cc775 100644 --- a/libcef_dll/ctocpp/domnode_ctocpp.cc +++ b/libcef_dll/ctocpp/domnode_ctocpp.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -253,7 +253,7 @@ CefString CefDOMNodeCToCpp::GetElementInnerText() } -#ifdef _DEBUG +#ifndef NDEBUG template<> long CefCToCpp::DebugObjCt = 0; #endif diff --git a/libcef_dll/ctocpp/domnode_ctocpp.h b/libcef_dll/ctocpp/domnode_ctocpp.h index 64c02eb6b..181e9ac1e 100644 --- a/libcef_dll/ctocpp/domnode_ctocpp.h +++ b/libcef_dll/ctocpp/domnode_ctocpp.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -31,31 +31,31 @@ public: virtual ~CefDOMNodeCToCpp() {} // CefDOMNode methods - virtual Type GetType(); - virtual bool IsText(); - virtual bool IsElement(); - virtual bool IsSame(CefRefPtr that); - virtual CefString GetName(); - virtual CefString GetValue(); - virtual bool SetValue(const CefString& value); - virtual CefString GetAsMarkup(); - virtual CefRefPtr GetDocument(); - virtual CefRefPtr GetParent(); - virtual CefRefPtr GetPreviousSibling(); - virtual CefRefPtr GetNextSibling(); - virtual bool HasChildren(); - virtual CefRefPtr GetFirstChild(); - virtual CefRefPtr GetLastChild(); + virtual Type GetType() OVERRIDE; + virtual bool IsText() OVERRIDE; + virtual bool IsElement() OVERRIDE; + virtual bool IsSame(CefRefPtr that) OVERRIDE; + virtual CefString GetName() OVERRIDE; + virtual CefString GetValue() OVERRIDE; + virtual bool SetValue(const CefString& value) OVERRIDE; + virtual CefString GetAsMarkup() OVERRIDE; + virtual CefRefPtr GetDocument() OVERRIDE; + virtual CefRefPtr GetParent() OVERRIDE; + virtual CefRefPtr GetPreviousSibling() OVERRIDE; + virtual CefRefPtr GetNextSibling() OVERRIDE; + virtual bool HasChildren() OVERRIDE; + virtual CefRefPtr GetFirstChild() OVERRIDE; + virtual CefRefPtr GetLastChild() OVERRIDE; virtual void AddEventListener(const CefString& eventType, - CefRefPtr listener, bool useCapture); - virtual CefString GetElementTagName(); - virtual bool HasElementAttributes(); - virtual bool HasElementAttribute(const CefString& attrName); - virtual CefString GetElementAttribute(const CefString& attrName); - virtual void GetElementAttributes(AttributeMap& attrMap); + CefRefPtr listener, bool useCapture) OVERRIDE; + virtual CefString GetElementTagName() OVERRIDE; + virtual bool HasElementAttributes() OVERRIDE; + virtual bool HasElementAttribute(const CefString& attrName) OVERRIDE; + virtual CefString GetElementAttribute(const CefString& attrName) OVERRIDE; + virtual void GetElementAttributes(AttributeMap& attrMap) OVERRIDE; virtual bool SetElementAttribute(const CefString& attrName, - const CefString& value); - virtual CefString GetElementInnerText(); + const CefString& value) OVERRIDE; + virtual CefString GetElementInnerText() OVERRIDE; }; #endif // USING_CEF_SHARED diff --git a/libcef_dll/ctocpp/domvisitor_ctocpp.cc b/libcef_dll/ctocpp/domvisitor_ctocpp.cc index a9a58d09c..9ff7da0b1 100644 --- a/libcef_dll/ctocpp/domvisitor_ctocpp.cc +++ b/libcef_dll/ctocpp/domvisitor_ctocpp.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -28,7 +28,7 @@ void CefDOMVisitorCToCpp::Visit(CefRefPtr document) } -#ifdef _DEBUG +#ifndef NDEBUG template<> long CefCToCpp::DebugObjCt = 0; #endif diff --git a/libcef_dll/ctocpp/domvisitor_ctocpp.h b/libcef_dll/ctocpp/domvisitor_ctocpp.h index 74b45098e..05d8b4a5c 100644 --- a/libcef_dll/ctocpp/domvisitor_ctocpp.h +++ b/libcef_dll/ctocpp/domvisitor_ctocpp.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -31,7 +31,7 @@ public: virtual ~CefDOMVisitorCToCpp() {} // CefDOMVisitor methods - virtual void Visit(CefRefPtr document); + virtual void Visit(CefRefPtr document) OVERRIDE; }; #endif // BUILDING_CEF_SHARED diff --git a/libcef_dll/ctocpp/download_handler_ctocpp.cc b/libcef_dll/ctocpp/download_handler_ctocpp.cc index 6f4fddb14..cf3216f36 100644 --- a/libcef_dll/ctocpp/download_handler_ctocpp.cc +++ b/libcef_dll/ctocpp/download_handler_ctocpp.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -32,7 +32,7 @@ void CefDownloadHandlerCToCpp::Complete() } -#ifdef _DEBUG +#ifndef NDEBUG template<> long CefCToCpp::DebugObjCt = 0; #endif diff --git a/libcef_dll/ctocpp/download_handler_ctocpp.h b/libcef_dll/ctocpp/download_handler_ctocpp.h index 3f48f8c72..a1705de97 100644 --- a/libcef_dll/ctocpp/download_handler_ctocpp.h +++ b/libcef_dll/ctocpp/download_handler_ctocpp.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -33,8 +33,8 @@ public: virtual ~CefDownloadHandlerCToCpp() {} // CefDownloadHandler methods - virtual bool ReceivedData(void* data, int data_size); - virtual void Complete(); + virtual bool ReceivedData(void* data, int data_size) OVERRIDE; + virtual void Complete() OVERRIDE; }; #endif // BUILDING_CEF_SHARED diff --git a/libcef_dll/ctocpp/find_handler_ctocpp.cc b/libcef_dll/ctocpp/find_handler_ctocpp.cc new file mode 100644 index 000000000..52e7748fc --- /dev/null +++ b/libcef_dll/ctocpp/find_handler_ctocpp.cc @@ -0,0 +1,35 @@ +// 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. +// +// --------------------------------------------------------------------------- +// +// A portion of this file was generated by the CEF translator tool. When +// making changes by hand only do so within the body of existing static and +// virtual method implementations. See the translator.README.txt file in the +// tools directory for more information. +// + +#include "libcef_dll/cpptoc/browser_cpptoc.h" +#include "libcef_dll/ctocpp/find_handler_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +void CefFindHandlerCToCpp::OnFindResult(CefRefPtr browser, + int identifier, int count, const CefRect& selectionRect, + int activeMatchOrdinal, bool finalUpdate) +{ + if (CEF_MEMBER_MISSING(struct_, on_find_result)) + return; + + struct_->on_find_result(struct_, CefBrowserCppToC::Wrap(browser), identifier, + count, &selectionRect, activeMatchOrdinal, finalUpdate); +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/libcef_dll/ctocpp/find_handler_ctocpp.h b/libcef_dll/ctocpp/find_handler_ctocpp.h new file mode 100644 index 000000000..388b2b57d --- /dev/null +++ b/libcef_dll/ctocpp/find_handler_ctocpp.h @@ -0,0 +1,42 @@ +// 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 was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// + +#ifndef _FINDHANDLER_CTOCPP_H +#define _FINDHANDLER_CTOCPP_H + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef.h" +#include "include/cef_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed DLL-side only. +class CefFindHandlerCToCpp + : public CefCToCpp +{ +public: + CefFindHandlerCToCpp(cef_find_handler_t* str) + : CefCToCpp( + str) {} + virtual ~CefFindHandlerCToCpp() {} + + // CefFindHandler methods + virtual void OnFindResult(CefRefPtr browser, int identifier, + int count, const CefRect& selectionRect, int activeMatchOrdinal, + bool finalUpdate) OVERRIDE; +}; + +#endif // BUILDING_CEF_SHARED +#endif // _FINDHANDLER_CTOCPP_H + diff --git a/libcef_dll/ctocpp/focus_handler_ctocpp.cc b/libcef_dll/ctocpp/focus_handler_ctocpp.cc new file mode 100644 index 000000000..5ea366cf6 --- /dev/null +++ b/libcef_dll/ctocpp/focus_handler_ctocpp.cc @@ -0,0 +1,43 @@ +// 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. +// +// --------------------------------------------------------------------------- +// +// A portion of this file was generated by the CEF translator tool. When +// making changes by hand only do so within the body of existing static and +// virtual method implementations. See the translator.README.txt file in the +// tools directory for more information. +// + +#include "libcef_dll/cpptoc/browser_cpptoc.h" +#include "libcef_dll/ctocpp/focus_handler_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +void CefFocusHandlerCToCpp::OnTakeFocus(CefRefPtr browser, + bool next) +{ + if (CEF_MEMBER_MISSING(struct_, on_take_focus)) + return; + + struct_->on_take_focus(struct_, CefBrowserCppToC::Wrap(browser), next); +} + +bool CefFocusHandlerCToCpp::OnSetFocus(CefRefPtr browser, + bool isWidget) +{ + if (CEF_MEMBER_MISSING(struct_, on_set_focus)) + return false; + + return struct_->on_set_focus(struct_, CefBrowserCppToC::Wrap(browser), + isWidget) ? true : false; +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/libcef_dll/ctocpp/focus_handler_ctocpp.h b/libcef_dll/ctocpp/focus_handler_ctocpp.h new file mode 100644 index 000000000..7bdb1df63 --- /dev/null +++ b/libcef_dll/ctocpp/focus_handler_ctocpp.h @@ -0,0 +1,43 @@ +// 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 was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// + +#ifndef _FOCUSHANDLER_CTOCPP_H +#define _FOCUSHANDLER_CTOCPP_H + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef.h" +#include "include/cef_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed DLL-side only. +class CefFocusHandlerCToCpp + : public CefCToCpp +{ +public: + CefFocusHandlerCToCpp(cef_focus_handler_t* str) + : CefCToCpp( + str) {} + virtual ~CefFocusHandlerCToCpp() {} + + // CefFocusHandler methods + virtual void OnTakeFocus(CefRefPtr browser, bool next) OVERRIDE; + virtual bool OnSetFocus(CefRefPtr browser, + bool isWidget) OVERRIDE; +}; + +#endif // BUILDING_CEF_SHARED +#endif // _FOCUSHANDLER_CTOCPP_H + diff --git a/libcef_dll/ctocpp/frame_ctocpp.cc b/libcef_dll/ctocpp/frame_ctocpp.cc index 02fe698d3..a0ee725bc 100644 --- a/libcef_dll/ctocpp/frame_ctocpp.cc +++ b/libcef_dll/ctocpp/frame_ctocpp.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -217,7 +217,7 @@ void CefFrameCToCpp::VisitDOM(CefRefPtr visitor) } -#ifdef _DEBUG +#ifndef NDEBUG template<> long CefCToCpp::DebugObjCt = 0; #endif diff --git a/libcef_dll/ctocpp/frame_ctocpp.h b/libcef_dll/ctocpp/frame_ctocpp.h index 2f6df4b91..c90f87a16 100644 --- a/libcef_dll/ctocpp/frame_ctocpp.h +++ b/libcef_dll/ctocpp/frame_ctocpp.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -31,30 +31,31 @@ public: virtual ~CefFrameCToCpp() {} // CefFrame methods - virtual void Undo(); - virtual void Redo(); - virtual void Cut(); - virtual void Copy(); - virtual void Paste(); - virtual void Delete(); - virtual void SelectAll(); - virtual void Print(); - virtual void ViewSource(); - virtual CefString GetSource(); - virtual CefString GetText(); - virtual void LoadRequest(CefRefPtr request); - virtual void LoadURL(const CefString& url); - virtual void LoadString(const CefString& string, const CefString& url); + virtual void Undo() OVERRIDE; + virtual void Redo() OVERRIDE; + virtual void Cut() OVERRIDE; + virtual void Copy() OVERRIDE; + virtual void Paste() OVERRIDE; + virtual void Delete() OVERRIDE; + virtual void SelectAll() OVERRIDE; + virtual void Print() OVERRIDE; + virtual void ViewSource() OVERRIDE; + virtual CefString GetSource() OVERRIDE; + virtual CefString GetText() OVERRIDE; + virtual void LoadRequest(CefRefPtr request) OVERRIDE; + virtual void LoadURL(const CefString& url) OVERRIDE; + virtual void LoadString(const CefString& string, + const CefString& url) OVERRIDE; virtual void LoadStream(CefRefPtr stream, - const CefString& url); + const CefString& url) OVERRIDE; virtual void ExecuteJavaScript(const CefString& jsCode, - const CefString& scriptUrl, int startLine); - virtual bool IsMain(); - virtual bool IsFocused(); - virtual CefString GetName(); - virtual CefString GetURL(); - virtual CefRefPtr GetBrowser(); - virtual void VisitDOM(CefRefPtr visitor); + const CefString& scriptUrl, int startLine) OVERRIDE; + virtual bool IsMain() OVERRIDE; + virtual bool IsFocused() OVERRIDE; + virtual CefString GetName() OVERRIDE; + virtual CefString GetURL() OVERRIDE; + virtual CefRefPtr GetBrowser() OVERRIDE; + virtual void VisitDOM(CefRefPtr visitor) OVERRIDE; }; #endif // USING_CEF_SHARED diff --git a/libcef_dll/ctocpp/handler_ctocpp.cc b/libcef_dll/ctocpp/handler_ctocpp.cc deleted file mode 100644 index e576ae0c2..000000000 --- a/libcef_dll/ctocpp/handler_ctocpp.cc +++ /dev/null @@ -1,474 +0,0 @@ -// 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. -// -// --------------------------------------------------------------------------- -// -// A portion of this file was generated by the CEF translator tool. When -// making changes by hand only do so within the body of existing static and -// virtual method implementations. See the translator.README.txt file in the -// tools directory for more information. -// - -#include "libcef_dll/cpptoc/browser_cpptoc.h" -#include "libcef_dll/cpptoc/frame_cpptoc.h" -#include "libcef_dll/cpptoc/request_cpptoc.h" -#include "libcef_dll/cpptoc/response_cpptoc.h" -#include "libcef_dll/cpptoc/stream_reader_cpptoc.h" -#include "libcef_dll/cpptoc/v8value_cpptoc.h" -#include "libcef_dll/ctocpp/download_handler_ctocpp.h" -#include "libcef_dll/ctocpp/handler_ctocpp.h" - - -// VIRTUAL METHODS - Body may be edited by hand. - -CefHandler::RetVal CefHandlerCToCpp::HandleBeforeCreated( - CefRefPtr parentBrowser, CefWindowInfo& windowInfo, bool popup, - const CefPopupFeatures& popupFeatures, CefRefPtr& handler, - const CefString& url, CefBrowserSettings& settings) -{ - if(CEF_MEMBER_MISSING(struct_, handle_before_created)) - return RV_CONTINUE; - - cef_browser_t* browserStruct = NULL; - if(parentBrowser.get()) - browserStruct = CefBrowserCppToC::Wrap(parentBrowser); - - cef_handler_t* handlerStruct = NULL; - if(handler.get()) - handlerStruct = CefHandlerCToCpp::Unwrap(handler); - cef_handler_t *origHandlerStruct = handlerStruct; - - cef_retval_t rv = struct_->handle_before_created(struct_, - browserStruct, &windowInfo, popup, &popupFeatures, &handlerStruct, - url.GetStruct(), &settings); - - if(handlerStruct && handlerStruct != origHandlerStruct) { - // The handler was changed. - if(handlerStruct) - handler = CefHandlerCToCpp::Wrap(handlerStruct); - else - handler = NULL; - } - - return rv; -} - -CefHandler::RetVal CefHandlerCToCpp::HandleAfterCreated( - CefRefPtr browser) -{ - if(CEF_MEMBER_MISSING(struct_, handle_after_created)) - return RV_CONTINUE; - - return struct_->handle_after_created(struct_, - CefBrowserCppToC::Wrap(browser)); -} - -CefHandler::RetVal CefHandlerCToCpp::HandleAddressChange( - CefRefPtr browser, CefRefPtr frame, - const CefString& url) -{ - if(CEF_MEMBER_MISSING(struct_, handle_address_change)) - return RV_CONTINUE; - - return struct_->handle_address_change(struct_, - CefBrowserCppToC::Wrap(browser), CefFrameCppToC::Wrap(frame), - url.GetStruct()); -} - -CefHandler::RetVal CefHandlerCToCpp::HandleTitleChange( - CefRefPtr browser, const CefString& title) -{ - if(CEF_MEMBER_MISSING(struct_, handle_title_change)) - return RV_CONTINUE; - - return struct_->handle_title_change(struct_, CefBrowserCppToC::Wrap(browser), - title.GetStruct()); -} - -CefHandler::RetVal CefHandlerCToCpp::HandleNavStateChange( - CefRefPtr browser, bool canGoBack, bool canGoForward) -{ - if(CEF_MEMBER_MISSING(struct_, handle_nav_state_change)) - return RV_CONTINUE; - - return struct_->handle_nav_state_change(struct_, - CefBrowserCppToC::Wrap(browser), canGoBack, canGoForward); -} - -CefHandler::RetVal CefHandlerCToCpp::HandleBeforeBrowse( - CefRefPtr browser, CefRefPtr frame, - CefRefPtr request, NavType navType, bool isRedirect) -{ - if(CEF_MEMBER_MISSING(struct_, handle_before_browse)) - return RV_CONTINUE; - - return struct_->handle_before_browse(struct_, CefBrowserCppToC::Wrap(browser), - CefFrameCppToC::Wrap(frame), CefRequestCppToC::Wrap(request), - navType, isRedirect); -} - -CefHandler::RetVal CefHandlerCToCpp::HandleLoadStart( - CefRefPtr browser, CefRefPtr frame) -{ - if(CEF_MEMBER_MISSING(struct_, handle_load_start)) - return RV_CONTINUE; - - cef_frame_t* frameStruct = NULL; - if(frame.get()) - frameStruct = CefFrameCppToC::Wrap(frame); - - return struct_->handle_load_start(struct_, CefBrowserCppToC::Wrap(browser), - frameStruct); -} - -CefHandler::RetVal CefHandlerCToCpp::HandleLoadEnd( - CefRefPtr browser, CefRefPtr frame, - int httpStatusCode) -{ - if(CEF_MEMBER_MISSING(struct_, handle_load_end)) - return RV_CONTINUE; - - cef_frame_t* frameStruct = NULL; - if(frame.get()) - frameStruct = CefFrameCppToC::Wrap(frame); - - return struct_->handle_load_end(struct_, CefBrowserCppToC::Wrap(browser), - frameStruct, httpStatusCode); -} - -CefHandler::RetVal CefHandlerCToCpp::HandleLoadError( - CefRefPtr browser, CefRefPtr frame, - ErrorCode errorCode, const CefString& failedUrl, CefString& errorText) -{ - if(CEF_MEMBER_MISSING(struct_, handle_load_error)) - return RV_CONTINUE; - - return struct_->handle_load_error(struct_, - CefBrowserCppToC::Wrap(browser), CefFrameCppToC::Wrap(frame), errorCode, - failedUrl.GetStruct(), errorText.GetWritableStruct()); -} - -CefHandler::RetVal CefHandlerCToCpp::HandleBeforeResourceLoad( - CefRefPtr browser, CefRefPtr request, - CefString& redirectUrl, CefRefPtr& resourceStream, - CefRefPtr response, int loadFlags) -{ - if(CEF_MEMBER_MISSING(struct_, handle_before_resource_load)) - return RV_CONTINUE; - - cef_stream_reader_t* streamRet = NULL; - - cef_retval_t rv = struct_->handle_before_resource_load(struct_, - CefBrowserCppToC::Wrap(browser), CefRequestCppToC::Wrap(request), - redirectUrl.GetWritableStruct(), &streamRet, - CefResponseCppToC::Wrap(response), loadFlags); - - if(streamRet) - resourceStream = CefStreamReaderCppToC::Unwrap(streamRet); - - return rv; -} - -CefHandler::RetVal CefHandlerCToCpp::HandleProtocolExecution( - CefRefPtr browser, const CefString& url, - bool& allow_os_execution) -{ - if(CEF_MEMBER_MISSING(struct_, handle_protocol_execution)) - return RV_CONTINUE; - - int allowExec = allow_os_execution; - cef_retval_t rv = struct_->handle_protocol_execution(struct_, - CefBrowserCppToC::Wrap(browser), url.GetStruct(), &allowExec); - allow_os_execution = allowExec?true:false; - return rv; -} - -CefHandler::RetVal CefHandlerCToCpp::HandleDownloadResponse( - CefRefPtr browser, const CefString& mimeType, - const CefString& fileName, int64 contentLength, - CefRefPtr& handler) -{ - if(CEF_MEMBER_MISSING(struct_, handle_download_response)) - return RV_CONTINUE; - - cef_download_handler_t* handlerRet = NULL; - - cef_retval_t rv = struct_->handle_download_response(struct_, - CefBrowserCppToC::Wrap(browser), mimeType.GetStruct(), fileName.GetStruct(), - contentLength, &handlerRet); - - if(handlerRet) - handler = CefDownloadHandlerCToCpp::Wrap(handlerRet); - - return rv; -} - -CefHandler::RetVal CefHandlerCToCpp::HandleAuthenticationRequest( - CefRefPtr browser, bool isProxy, const CefString& host, - const CefString& realm, const CefString& scheme, CefString& username, - CefString& password) -{ - if(CEF_MEMBER_MISSING(struct_, handle_authentication_request)) - return RV_CONTINUE; - - return struct_->handle_authentication_request(struct_, - CefBrowserCppToC::Wrap(browser), isProxy, - host.GetStruct(), realm.GetStruct(), scheme.GetStruct(), - username.GetWritableStruct(), password.GetWritableStruct()); -} - -CefHandler::RetVal CefHandlerCToCpp::HandleBeforeMenu( - CefRefPtr browser, const MenuInfo& menuInfo) -{ - if(CEF_MEMBER_MISSING(struct_, handle_before_menu)) - return RV_CONTINUE; - - return struct_->handle_before_menu(struct_, CefBrowserCppToC::Wrap(browser), - &menuInfo); -} - -CefHandler::RetVal CefHandlerCToCpp::HandleGetMenuLabel( - CefRefPtr browser, MenuId menuId, CefString& label) -{ - if(CEF_MEMBER_MISSING(struct_, handle_get_menu_label)) - return RV_CONTINUE; - - return struct_->handle_get_menu_label(struct_, - CefBrowserCppToC::Wrap(browser), menuId, label.GetWritableStruct()); -} - -CefHandler::RetVal CefHandlerCToCpp::HandleMenuAction( - CefRefPtr browser, MenuId menuId) -{ - if(CEF_MEMBER_MISSING(struct_, handle_menu_action)) - return RV_CONTINUE; - - return struct_->handle_menu_action(struct_, CefBrowserCppToC::Wrap(browser), - menuId); -} - -CefHandler::RetVal CefHandlerCToCpp::HandlePrintOptions( - CefRefPtr browser, CefPrintOptions& printOptions) -{ - if (CEF_MEMBER_MISSING(struct_, handle_print_options)) - return RV_CONTINUE; - - return struct_->handle_print_options(struct_, CefBrowserCppToC::Wrap(browser), - &printOptions); -} - -CefHandler::RetVal CefHandlerCToCpp::HandlePrintHeaderFooter( - CefRefPtr browser, CefRefPtr frame, - CefPrintInfo& printInfo, const CefString& url, const CefString& title, - int currentPage, int maxPages, CefString& topLeft, CefString& topCenter, - CefString& topRight, CefString& bottomLeft, CefString& bottomCenter, - CefString& bottomRight) -{ - if(CEF_MEMBER_MISSING(struct_, handle_print_header_footer)) - return RV_CONTINUE; - - return struct_->handle_print_header_footer(struct_, - CefBrowserCppToC::Wrap(browser), CefFrameCppToC::Wrap(frame), - &printInfo, url.GetStruct(), title.GetStruct(), currentPage, maxPages, - topLeft.GetWritableStruct(), topCenter.GetWritableStruct(), - topRight.GetWritableStruct(), bottomLeft.GetWritableStruct(), - bottomCenter.GetWritableStruct(), bottomRight.GetWritableStruct()); -} - -CefHandler::RetVal CefHandlerCToCpp::HandleJSAlert( - CefRefPtr browser, CefRefPtr frame, - const CefString& message) -{ - if(CEF_MEMBER_MISSING(struct_, handle_jsalert)) - return RV_CONTINUE; - - return struct_->handle_jsalert(struct_, CefBrowserCppToC::Wrap(browser), - CefFrameCppToC::Wrap(frame), message.GetStruct()); -} - -CefHandler::RetVal CefHandlerCToCpp::HandleJSConfirm( - CefRefPtr browser, CefRefPtr frame, - const CefString& message, bool& retval) -{ - if(CEF_MEMBER_MISSING(struct_, handle_jsconfirm)) - return RV_CONTINUE; - - int ret = 0; - cef_retval_t rv = struct_->handle_jsconfirm(struct_, - CefBrowserCppToC::Wrap(browser), CefFrameCppToC::Wrap(frame), - message.GetStruct(), &ret); - retval = (ret ? true : false); - return rv; -} - -CefHandler::RetVal CefHandlerCToCpp::HandleJSPrompt( - CefRefPtr browser, CefRefPtr frame, - const CefString& message, const CefString& defaultValue, bool& retval, - CefString& result) -{ - if(CEF_MEMBER_MISSING(struct_, handle_jsprompt)) - return RV_CONTINUE; - - int ret = 0; - cef_retval_t rv = struct_->handle_jsprompt(struct_, - CefBrowserCppToC::Wrap(browser), CefFrameCppToC::Wrap(frame), - message.GetStruct(), defaultValue.GetStruct(), &ret, - result.GetWritableStruct()); - retval = (ret ? true : false); - return rv; -} - -CefHandler::RetVal CefHandlerCToCpp::HandleJSBinding( - CefRefPtr browser, CefRefPtr frame, - CefRefPtr object) -{ - if(CEF_MEMBER_MISSING(struct_, handle_jsbinding)) - return RV_CONTINUE; - - return struct_->handle_jsbinding(struct_, CefBrowserCppToC::Wrap(browser), - CefFrameCppToC::Wrap(frame), CefV8ValueCppToC::Wrap(object)); -} - -CefHandler::RetVal CefHandlerCToCpp::HandleBeforeWindowClose( - CefRefPtr browser) -{ - if(CEF_MEMBER_MISSING(struct_, handle_before_window_close)) - return RV_CONTINUE; - - return struct_->handle_before_window_close(struct_, - CefBrowserCppToC::Wrap(browser)); -} - -CefHandler::RetVal CefHandlerCToCpp::HandleTakeFocus( - CefRefPtr browser, bool reverse) -{ - if(CEF_MEMBER_MISSING(struct_, handle_take_focus)) - return RV_CONTINUE; - - return struct_->handle_take_focus(struct_, CefBrowserCppToC::Wrap(browser), - reverse); -} - -CefHandler::RetVal CefHandlerCToCpp::HandleSetFocus( - CefRefPtr browser, bool isWidget) -{ - if(CEF_MEMBER_MISSING(struct_, handle_set_focus)) - return RV_CONTINUE; - - return struct_->handle_set_focus(struct_, CefBrowserCppToC::Wrap(browser), - isWidget); -} - -CefHandler::RetVal CefHandlerCToCpp::HandleKeyEvent( - CefRefPtr browser, KeyEventType type, int code, int modifiers, - bool isSystemKey) -{ - if(CEF_MEMBER_MISSING(struct_, handle_key_event)) - return RV_CONTINUE; - - return struct_->handle_key_event(struct_, CefBrowserCppToC::Wrap(browser), - type, code, modifiers, isSystemKey); -} - -CefHandler::RetVal CefHandlerCToCpp::HandleTooltip( - CefRefPtr browser, CefString& text) -{ - if(CEF_MEMBER_MISSING(struct_, handle_tooltip)) - return RV_CONTINUE; - - return struct_->handle_tooltip(struct_, - CefBrowserCppToC::Wrap(browser), text.GetWritableStruct()); -} - -CefHandler::RetVal CefHandlerCToCpp::HandleStatus(CefRefPtr browser, - const CefString& value, StatusType type) -{ - if(CEF_MEMBER_MISSING(struct_, handle_status)) - return RV_CONTINUE; - - return struct_->handle_status(struct_, - CefBrowserCppToC::Wrap(browser), value.GetStruct(), type); -} - -CefHandler::RetVal CefHandlerCToCpp::HandleConsoleMessage( - CefRefPtr browser, const CefString& message, - const CefString& source, int line) -{ - if(CEF_MEMBER_MISSING(struct_, handle_console_message)) - return RV_CONTINUE; - - return struct_->handle_console_message(struct_, - CefBrowserCppToC::Wrap(browser), message.GetStruct(), source.GetStruct(), - line); -} - -CefHandler::RetVal CefHandlerCToCpp::HandleFindResult( - CefRefPtr browser, int identifier, int count, - const CefRect& selectionRect, int activeMatchOrdinal, bool finalUpdate) -{ - if(CEF_MEMBER_MISSING(struct_, handle_find_result)) - return RV_CONTINUE; - - return struct_->handle_find_result(struct_, - CefBrowserCppToC::Wrap(browser), identifier, count, &selectionRect, - activeMatchOrdinal, finalUpdate); -} - -CefHandler::RetVal CefHandlerCToCpp::HandleGetRect( - CefRefPtr browser, bool screen, CefRect& rect) -{ - if(CEF_MEMBER_MISSING(struct_, handle_get_rect)) - return RV_CONTINUE; - - return struct_->handle_get_rect(struct_, CefBrowserCppToC::Wrap(browser), - screen, &rect); -} - -CefHandler::RetVal CefHandlerCToCpp::HandleGetScreenPoint( - CefRefPtr browser, int viewX, int viewY, int& screenX, - int& screenY) -{ - if(CEF_MEMBER_MISSING(struct_, handle_get_screen_point)) - return RV_CONTINUE; - - return struct_->handle_get_screen_point(struct_, - CefBrowserCppToC::Wrap(browser), viewX, viewY, &screenX, &screenY); -} - -CefHandler::RetVal CefHandlerCToCpp::HandlePopupChange( - CefRefPtr browser, bool show, const CefRect& rect) -{ - if(CEF_MEMBER_MISSING(struct_, handle_popup_change)) - return RV_CONTINUE; - - return struct_->handle_popup_change(struct_, CefBrowserCppToC::Wrap(browser), - show, &rect); -} - -CefHandler::RetVal CefHandlerCToCpp::HandlePaint(CefRefPtr browser, - PaintElementType type, const CefRect& dirtyRect, const void* buffer) -{ - if(CEF_MEMBER_MISSING(struct_, handle_paint)) - return RV_CONTINUE; - - return struct_->handle_paint(struct_, CefBrowserCppToC::Wrap(browser), type, - &dirtyRect, buffer); -} - -CefHandler::RetVal CefHandlerCToCpp::HandleCursorChange( - CefRefPtr browser, CefCursorHandle cursor) -{ - if(CEF_MEMBER_MISSING(struct_, handle_cursor_change)) - return RV_CONTINUE; - - return struct_->handle_cursor_change(struct_, CefBrowserCppToC::Wrap(browser), - cursor); -} - - -#ifdef _DEBUG -template<> long CefCToCpp::DebugObjCt = 0; -#endif - diff --git a/libcef_dll/ctocpp/handler_ctocpp.h b/libcef_dll/ctocpp/handler_ctocpp.h deleted file mode 100644 index c5509526c..000000000 --- a/libcef_dll/ctocpp/handler_ctocpp.h +++ /dev/null @@ -1,115 +0,0 @@ -// 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. -// -// ------------------------------------------------------------------------- -// -// This file was generated by the CEF translator tool and should not edited -// by hand. See the translator.README.txt file in the tools directory for -// more information. -// - -#ifndef _HANDLER_CTOCPP_H -#define _HANDLER_CTOCPP_H - -#ifndef BUILDING_CEF_SHARED -#pragma message("Warning: "__FILE__" may be accessed DLL-side only") -#else // BUILDING_CEF_SHARED - -#include "include/cef.h" -#include "include/cef_capi.h" -#include "libcef_dll/ctocpp/ctocpp.h" - -// Wrap a C structure with a C++ class. -// This class may be instantiated and accessed DLL-side only. -class CefHandlerCToCpp - : public CefCToCpp -{ -public: - CefHandlerCToCpp(cef_handler_t* str) - : CefCToCpp(str) {} - virtual ~CefHandlerCToCpp() {} - - // CefHandler methods - virtual RetVal HandleBeforeCreated(CefRefPtr parentBrowser, - CefWindowInfo& windowInfo, bool popup, - const CefPopupFeatures& popupFeatures, CefRefPtr& handler, - const CefString& url, CefBrowserSettings& settings); - virtual RetVal HandleAfterCreated(CefRefPtr browser); - virtual RetVal HandleAddressChange(CefRefPtr browser, - CefRefPtr frame, const CefString& url); - virtual RetVal HandleTitleChange(CefRefPtr browser, - const CefString& title); - virtual RetVal HandleNavStateChange(CefRefPtr browser, - bool canGoBack, bool canGoForward); - virtual RetVal HandleBeforeBrowse(CefRefPtr browser, - CefRefPtr frame, CefRefPtr request, - NavType navType, bool isRedirect); - virtual RetVal HandleLoadStart(CefRefPtr browser, - CefRefPtr frame); - virtual RetVal HandleLoadEnd(CefRefPtr browser, - CefRefPtr frame, int httpStatusCode); - virtual RetVal HandleLoadError(CefRefPtr browser, - CefRefPtr frame, ErrorCode errorCode, - const CefString& failedUrl, CefString& errorText); - virtual RetVal HandleBeforeResourceLoad(CefRefPtr browser, - CefRefPtr request, CefString& redirectUrl, - CefRefPtr& resourceStream, - CefRefPtr response, int loadFlags); - virtual RetVal HandleProtocolExecution(CefRefPtr browser, - const CefString& url, bool& allow_os_execution); - virtual RetVal HandleDownloadResponse(CefRefPtr browser, - const CefString& mimeType, const CefString& fileName, - int64 contentLength, CefRefPtr& handler); - virtual RetVal HandleAuthenticationRequest(CefRefPtr browser, - bool isProxy, const CefString& host, const CefString& realm, - const CefString& scheme, CefString& username, CefString& password); - virtual RetVal HandleBeforeMenu(CefRefPtr browser, - const MenuInfo& menuInfo); - virtual RetVal HandleGetMenuLabel(CefRefPtr browser, - MenuId menuId, CefString& label); - virtual RetVal HandleMenuAction(CefRefPtr browser, MenuId menuId); - virtual RetVal HandlePrintOptions(CefRefPtr browser, - CefPrintOptions& printOptions); - virtual RetVal HandlePrintHeaderFooter(CefRefPtr browser, - CefRefPtr frame, CefPrintInfo& printInfo, const CefString& url, - const CefString& title, int currentPage, int maxPages, - CefString& topLeft, CefString& topCenter, CefString& topRight, - CefString& bottomLeft, CefString& bottomCenter, CefString& bottomRight); - virtual RetVal HandleJSAlert(CefRefPtr browser, - CefRefPtr frame, const CefString& message); - virtual RetVal HandleJSConfirm(CefRefPtr browser, - CefRefPtr frame, const CefString& message, bool& retval); - virtual RetVal HandleJSPrompt(CefRefPtr browser, - CefRefPtr frame, const CefString& message, - const CefString& defaultValue, bool& retval, CefString& result); - virtual RetVal HandleJSBinding(CefRefPtr browser, - CefRefPtr frame, CefRefPtr object); - virtual RetVal HandleBeforeWindowClose(CefRefPtr browser); - virtual RetVal HandleTakeFocus(CefRefPtr browser, bool reverse); - virtual RetVal HandleSetFocus(CefRefPtr browser, bool isWidget); - virtual RetVal HandleKeyEvent(CefRefPtr browser, - KeyEventType type, int code, int modifiers, bool isSystemKey); - virtual RetVal HandleTooltip(CefRefPtr browser, CefString& text); - virtual RetVal HandleStatus(CefRefPtr browser, - const CefString& value, StatusType type); - virtual RetVal HandleConsoleMessage(CefRefPtr browser, - const CefString& message, const CefString& source, int line); - virtual RetVal HandleFindResult(CefRefPtr browser, int identifier, - int count, const CefRect& selectionRect, int activeMatchOrdinal, - bool finalUpdate); - virtual RetVal HandleGetRect(CefRefPtr browser, bool screen, - CefRect& rect); - virtual RetVal HandleGetScreenPoint(CefRefPtr browser, int viewX, - int viewY, int& screenX, int& screenY); - virtual RetVal HandlePopupChange(CefRefPtr browser, bool show, - const CefRect& rect); - virtual RetVal HandlePaint(CefRefPtr browser, - PaintElementType type, const CefRect& dirtyRect, const void* buffer); - virtual RetVal HandleCursorChange(CefRefPtr browser, - CefCursorHandle cursor); -}; - -#endif // BUILDING_CEF_SHARED -#endif // _HANDLER_CTOCPP_H - diff --git a/libcef_dll/ctocpp/jsbinding_handler_ctocpp.cc b/libcef_dll/ctocpp/jsbinding_handler_ctocpp.cc new file mode 100644 index 000000000..07b6c3e5f --- /dev/null +++ b/libcef_dll/ctocpp/jsbinding_handler_ctocpp.cc @@ -0,0 +1,36 @@ +// 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. +// +// --------------------------------------------------------------------------- +// +// A portion of this file was generated by the CEF translator tool. When +// making changes by hand only do so within the body of existing static and +// virtual method implementations. See the translator.README.txt file in the +// tools directory for more information. +// + +#include "libcef_dll/cpptoc/browser_cpptoc.h" +#include "libcef_dll/cpptoc/frame_cpptoc.h" +#include "libcef_dll/cpptoc/v8value_cpptoc.h" +#include "libcef_dll/ctocpp/jsbinding_handler_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +void CefJSBindingHandlerCToCpp::OnJSBinding(CefRefPtr browser, + CefRefPtr frame, CefRefPtr object) +{ + if (CEF_MEMBER_MISSING(struct_, on_jsbinding)) + return; + + struct_->on_jsbinding(struct_, CefBrowserCppToC::Wrap(browser), + CefFrameCppToC::Wrap(frame), CefV8ValueCppToC::Wrap(object)); +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/libcef_dll/ctocpp/jsbinding_handler_ctocpp.h b/libcef_dll/ctocpp/jsbinding_handler_ctocpp.h new file mode 100644 index 000000000..8b4b0c4ee --- /dev/null +++ b/libcef_dll/ctocpp/jsbinding_handler_ctocpp.h @@ -0,0 +1,42 @@ +// 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 was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// + +#ifndef _JSBINDINGHANDLER_CTOCPP_H +#define _JSBINDINGHANDLER_CTOCPP_H + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef.h" +#include "include/cef_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed DLL-side only. +class CefJSBindingHandlerCToCpp + : public CefCToCpp +{ +public: + CefJSBindingHandlerCToCpp(cef_jsbinding_handler_t* str) + : CefCToCpp(str) {} + virtual ~CefJSBindingHandlerCToCpp() {} + + // CefJSBindingHandler methods + virtual void OnJSBinding(CefRefPtr browser, + CefRefPtr frame, CefRefPtr object) OVERRIDE; +}; + +#endif // BUILDING_CEF_SHARED +#endif // _JSBINDINGHANDLER_CTOCPP_H + diff --git a/libcef_dll/ctocpp/jsdialog_handler_ctocpp.cc b/libcef_dll/ctocpp/jsdialog_handler_ctocpp.cc new file mode 100644 index 000000000..d57a20458 --- /dev/null +++ b/libcef_dll/ctocpp/jsdialog_handler_ctocpp.cc @@ -0,0 +1,63 @@ +// 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. +// +// --------------------------------------------------------------------------- +// +// A portion of this file was generated by the CEF translator tool. When +// making changes by hand only do so within the body of existing static and +// virtual method implementations. See the translator.README.txt file in the +// tools directory for more information. +// + +#include "libcef_dll/cpptoc/browser_cpptoc.h" +#include "libcef_dll/cpptoc/frame_cpptoc.h" +#include "libcef_dll/ctocpp/jsdialog_handler_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +bool CefJSDialogHandlerCToCpp::OnJSAlert(CefRefPtr browser, + CefRefPtr frame, const CefString& message) +{ + if (CEF_MEMBER_MISSING(struct_, on_jsalert)) + return false; + + return struct_->on_jsalert(struct_, CefBrowserCppToC::Wrap(browser), + CefFrameCppToC::Wrap(frame), message.GetStruct()) ? true : false; +} + +bool CefJSDialogHandlerCToCpp::OnJSConfirm(CefRefPtr browser, + CefRefPtr frame, const CefString& message, bool& retval) +{ + if (CEF_MEMBER_MISSING(struct_, on_jsconfirm)) + return false; + + int ret = 0; + int rv = struct_->on_jsconfirm(struct_, CefBrowserCppToC::Wrap(browser), + CefFrameCppToC::Wrap(frame), message.GetStruct(), &ret); + retval = (ret ? true : false); + return (rv ? true : false); +} + +bool CefJSDialogHandlerCToCpp::OnJSPrompt(CefRefPtr browser, + CefRefPtr frame, const CefString& message, + const CefString& defaultValue, bool& retval, CefString& result) +{ + if (CEF_MEMBER_MISSING(struct_, on_jsprompt)) + return false; + + int ret = 0; + int rv = struct_->on_jsprompt(struct_, CefBrowserCppToC::Wrap(browser), + CefFrameCppToC::Wrap(frame), message.GetStruct(), + defaultValue.GetStruct(), &ret, result.GetWritableStruct()); + retval = (ret ? true : false); + return (rv ? true : false); +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/libcef_dll/ctocpp/jsdialog_handler_ctocpp.h b/libcef_dll/ctocpp/jsdialog_handler_ctocpp.h new file mode 100644 index 000000000..f1c69906b --- /dev/null +++ b/libcef_dll/ctocpp/jsdialog_handler_ctocpp.h @@ -0,0 +1,49 @@ +// 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 was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// + +#ifndef _JSDIALOGHANDLER_CTOCPP_H +#define _JSDIALOGHANDLER_CTOCPP_H + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef.h" +#include "include/cef_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed DLL-side only. +class CefJSDialogHandlerCToCpp + : public CefCToCpp +{ +public: + CefJSDialogHandlerCToCpp(cef_jsdialog_handler_t* str) + : CefCToCpp(str) {} + virtual ~CefJSDialogHandlerCToCpp() {} + + // CefJSDialogHandler methods + virtual bool OnJSAlert(CefRefPtr browser, + CefRefPtr frame, const CefString& message) OVERRIDE; + virtual bool OnJSConfirm(CefRefPtr browser, + CefRefPtr frame, const CefString& message, + bool& retval) OVERRIDE; + virtual bool OnJSPrompt(CefRefPtr browser, + CefRefPtr frame, const CefString& message, + const CefString& defaultValue, bool& retval, + CefString& result) OVERRIDE; +}; + +#endif // BUILDING_CEF_SHARED +#endif // _JSDIALOGHANDLER_CTOCPP_H + diff --git a/libcef_dll/ctocpp/keyboard_handler_ctocpp.cc b/libcef_dll/ctocpp/keyboard_handler_ctocpp.cc new file mode 100644 index 000000000..b1a2049f3 --- /dev/null +++ b/libcef_dll/ctocpp/keyboard_handler_ctocpp.cc @@ -0,0 +1,34 @@ +// 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. +// +// --------------------------------------------------------------------------- +// +// A portion of this file was generated by the CEF translator tool. When +// making changes by hand only do so within the body of existing static and +// virtual method implementations. See the translator.README.txt file in the +// tools directory for more information. +// + +#include "libcef_dll/cpptoc/browser_cpptoc.h" +#include "libcef_dll/ctocpp/keyboard_handler_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +bool CefKeyboardHandlerCToCpp::OnKeyEvent(CefRefPtr browser, + KeyEventType type, int code, int modifiers, bool isSystemKey) +{ + if (CEF_MEMBER_MISSING(struct_, on_key_event)) + return false; + + return struct_->on_key_event(struct_, CefBrowserCppToC::Wrap(browser), + type, code, modifiers, isSystemKey) ? true : false; +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/libcef_dll/ctocpp/keyboard_handler_ctocpp.h b/libcef_dll/ctocpp/keyboard_handler_ctocpp.h new file mode 100644 index 000000000..c74f8dd3e --- /dev/null +++ b/libcef_dll/ctocpp/keyboard_handler_ctocpp.h @@ -0,0 +1,42 @@ +// 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 was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// + +#ifndef _KEYBOARDHANDLER_CTOCPP_H +#define _KEYBOARDHANDLER_CTOCPP_H + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef.h" +#include "include/cef_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed DLL-side only. +class CefKeyboardHandlerCToCpp + : public CefCToCpp +{ +public: + CefKeyboardHandlerCToCpp(cef_keyboard_handler_t* str) + : CefCToCpp(str) {} + virtual ~CefKeyboardHandlerCToCpp() {} + + // CefKeyboardHandler methods + virtual bool OnKeyEvent(CefRefPtr browser, KeyEventType type, + int code, int modifiers, bool isSystemKey) OVERRIDE; +}; + +#endif // BUILDING_CEF_SHARED +#endif // _KEYBOARDHANDLER_CTOCPP_H + diff --git a/libcef_dll/ctocpp/life_span_handler_ctocpp.cc b/libcef_dll/ctocpp/life_span_handler_ctocpp.cc new file mode 100644 index 000000000..36d4c61f7 --- /dev/null +++ b/libcef_dll/ctocpp/life_span_handler_ctocpp.cc @@ -0,0 +1,71 @@ +// 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. +// +// --------------------------------------------------------------------------- +// +// A portion of this file was generated by the CEF translator tool. When +// making changes by hand only do so within the body of existing static and +// virtual method implementations. See the translator.README.txt file in the +// tools directory for more information. +// + +#include "libcef_dll/cpptoc/browser_cpptoc.h" +#include "libcef_dll/ctocpp/client_ctocpp.h" +#include "libcef_dll/ctocpp/life_span_handler_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +bool CefLifeSpanHandlerCToCpp::OnBeforePopup( + CefRefPtr parentBrowser, const CefPopupFeatures& popupFeatures, + CefWindowInfo& windowInfo, const CefString& url, + CefRefPtr& client, CefBrowserSettings& settings) +{ + if (CEF_MEMBER_MISSING(struct_, on_before_popup)) + return false; + + cef_browser_t* browserStruct = CefBrowserCppToC::Wrap(parentBrowser); + cef_client_t* clientStruct = NULL; + if(client.get()) + clientStruct = CefClientCToCpp::Unwrap(client); + cef_client_t* origClientStruct = clientStruct; + + int rv = struct_->on_before_popup(struct_, + browserStruct, &popupFeatures, &windowInfo, url.GetStruct(), + &clientStruct, &settings); + + if (clientStruct) { + if (clientStruct != origClientStruct) { + // The handler was changed. + client = CefClientCToCpp::Wrap(clientStruct); + } + } else { + client = NULL; + } + + return (rv ? true : false); +} + +void CefLifeSpanHandlerCToCpp::OnAfterCreated(CefRefPtr browser) +{ + if (CEF_MEMBER_MISSING(struct_, on_after_created)) + return; + + return struct_->on_after_created(struct_, CefBrowserCppToC::Wrap(browser)); +} + +void CefLifeSpanHandlerCToCpp::OnBeforeClose(CefRefPtr browser) +{ + if (CEF_MEMBER_MISSING(struct_, on_before_close)) + return; + + return struct_->on_before_close(struct_, CefBrowserCppToC::Wrap(browser)); +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/libcef_dll/ctocpp/life_span_handler_ctocpp.h b/libcef_dll/ctocpp/life_span_handler_ctocpp.h new file mode 100644 index 000000000..65db16643 --- /dev/null +++ b/libcef_dll/ctocpp/life_span_handler_ctocpp.h @@ -0,0 +1,46 @@ +// 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 was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// + +#ifndef _LIFESPANHANDLER_CTOCPP_H +#define _LIFESPANHANDLER_CTOCPP_H + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef.h" +#include "include/cef_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed DLL-side only. +class CefLifeSpanHandlerCToCpp + : public CefCToCpp +{ +public: + CefLifeSpanHandlerCToCpp(cef_life_span_handler_t* str) + : CefCToCpp(str) {} + virtual ~CefLifeSpanHandlerCToCpp() {} + + // 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 void OnBeforeClose(CefRefPtr browser) OVERRIDE; +}; + +#endif // BUILDING_CEF_SHARED +#endif // _LIFESPANHANDLER_CTOCPP_H + diff --git a/libcef_dll/ctocpp/load_handler_ctocpp.cc b/libcef_dll/ctocpp/load_handler_ctocpp.cc new file mode 100644 index 000000000..02bafaa41 --- /dev/null +++ b/libcef_dll/ctocpp/load_handler_ctocpp.cc @@ -0,0 +1,57 @@ +// 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. +// +// --------------------------------------------------------------------------- +// +// A portion of this file was generated by the CEF translator tool. When +// making changes by hand only do so within the body of existing static and +// virtual method implementations. See the translator.README.txt file in the +// tools directory for more information. +// + +#include "libcef_dll/cpptoc/browser_cpptoc.h" +#include "libcef_dll/cpptoc/frame_cpptoc.h" +#include "libcef_dll/ctocpp/load_handler_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +void CefLoadHandlerCToCpp::OnLoadStart(CefRefPtr browser, + CefRefPtr frame) +{ + if (CEF_MEMBER_MISSING(struct_, on_load_start)) + return; + + struct_->on_load_start(struct_, CefBrowserCppToC::Wrap(browser), + CefFrameCppToC::Wrap(frame)); +} + +void CefLoadHandlerCToCpp::OnLoadEnd(CefRefPtr browser, + CefRefPtr frame, int httpStatusCode) +{ + if (CEF_MEMBER_MISSING(struct_, on_load_end)) + return; + + struct_->on_load_end(struct_, CefBrowserCppToC::Wrap(browser), + CefFrameCppToC::Wrap(frame), httpStatusCode); +} + +bool CefLoadHandlerCToCpp::OnLoadError(CefRefPtr browser, + CefRefPtr frame, ErrorCode errorCode, const CefString& failedUrl, + CefString& errorText) +{ + if (CEF_MEMBER_MISSING(struct_, on_load_error)) + return false; + + return struct_->on_load_error(struct_, CefBrowserCppToC::Wrap(browser), + CefFrameCppToC::Wrap(frame), errorCode, failedUrl.GetStruct(), + errorText.GetWritableStruct()) ? true : false; +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/libcef_dll/ctocpp/load_handler_ctocpp.h b/libcef_dll/ctocpp/load_handler_ctocpp.h new file mode 100644 index 000000000..1d38d7ac8 --- /dev/null +++ b/libcef_dll/ctocpp/load_handler_ctocpp.h @@ -0,0 +1,46 @@ +// 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 was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// + +#ifndef _LOADHANDLER_CTOCPP_H +#define _LOADHANDLER_CTOCPP_H + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef.h" +#include "include/cef_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed DLL-side only. +class CefLoadHandlerCToCpp + : public CefCToCpp +{ +public: + CefLoadHandlerCToCpp(cef_load_handler_t* str) + : CefCToCpp( + str) {} + virtual ~CefLoadHandlerCToCpp() {} + + // 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; +}; + +#endif // BUILDING_CEF_SHARED +#endif // _LOADHANDLER_CTOCPP_H + diff --git a/libcef_dll/ctocpp/menu_handler_ctocpp.cc b/libcef_dll/ctocpp/menu_handler_ctocpp.cc new file mode 100644 index 000000000..8bfe6c5fc --- /dev/null +++ b/libcef_dll/ctocpp/menu_handler_ctocpp.cc @@ -0,0 +1,54 @@ +// 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. +// +// --------------------------------------------------------------------------- +// +// A portion of this file was generated by the CEF translator tool. When +// making changes by hand only do so within the body of existing static and +// virtual method implementations. See the translator.README.txt file in the +// tools directory for more information. +// + +#include "libcef_dll/cpptoc/browser_cpptoc.h" +#include "libcef_dll/ctocpp/menu_handler_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +bool CefMenuHandlerCToCpp::OnBeforeMenu(CefRefPtr browser, + const MenuInfo& menuInfo) +{ + if (CEF_MEMBER_MISSING(struct_, on_before_menu)) + return false; + + return struct_->on_before_menu(struct_, CefBrowserCppToC::Wrap(browser), + &menuInfo) ? true : false; +} + +void CefMenuHandlerCToCpp::GetMenuLabel(CefRefPtr browser, + MenuId menuId, CefString& label) +{ + if (CEF_MEMBER_MISSING(struct_, get_menu_label)) + return; + + return struct_->get_menu_label(struct_, CefBrowserCppToC::Wrap(browser), + menuId, label.GetWritableStruct()); +} + +bool CefMenuHandlerCToCpp::OnMenuAction(CefRefPtr browser, + MenuId menuId) +{ + if (CEF_MEMBER_MISSING(struct_, on_menu_action)) + return false; + + return struct_->on_menu_action(struct_, CefBrowserCppToC::Wrap(browser), + menuId) ? true : false; +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/libcef_dll/ctocpp/menu_handler_ctocpp.h b/libcef_dll/ctocpp/menu_handler_ctocpp.h new file mode 100644 index 000000000..903e76f02 --- /dev/null +++ b/libcef_dll/ctocpp/menu_handler_ctocpp.h @@ -0,0 +1,45 @@ +// 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 was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// + +#ifndef _MENUHANDLER_CTOCPP_H +#define _MENUHANDLER_CTOCPP_H + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef.h" +#include "include/cef_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed DLL-side only. +class CefMenuHandlerCToCpp + : public CefCToCpp +{ +public: + CefMenuHandlerCToCpp(cef_menu_handler_t* str) + : CefCToCpp( + str) {} + virtual ~CefMenuHandlerCToCpp() {} + + // CefMenuHandler methods + virtual bool OnBeforeMenu(CefRefPtr browser, + const MenuInfo& menuInfo) OVERRIDE; + virtual void GetMenuLabel(CefRefPtr browser, MenuId menuId, + CefString& label) OVERRIDE; + virtual bool OnMenuAction(CefRefPtr browser, + MenuId menuId) OVERRIDE; +}; + +#endif // BUILDING_CEF_SHARED +#endif // _MENUHANDLER_CTOCPP_H + diff --git a/libcef_dll/ctocpp/post_data_ctocpp.cc b/libcef_dll/ctocpp/post_data_ctocpp.cc index 90214fb04..a64c34059 100644 --- a/libcef_dll/ctocpp/post_data_ctocpp.cc +++ b/libcef_dll/ctocpp/post_data_ctocpp.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -79,7 +79,7 @@ void CefPostDataCToCpp::RemoveElements() } -#ifdef _DEBUG +#ifndef NDEBUG template<> long CefCToCpp::DebugObjCt = 0; #endif diff --git a/libcef_dll/ctocpp/post_data_ctocpp.h b/libcef_dll/ctocpp/post_data_ctocpp.h index 4c591104c..d03df2e4e 100644 --- a/libcef_dll/ctocpp/post_data_ctocpp.h +++ b/libcef_dll/ctocpp/post_data_ctocpp.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -31,11 +31,11 @@ public: virtual ~CefPostDataCToCpp() {} // CefPostData methods - virtual size_t GetElementCount(); - virtual void GetElements(ElementVector& elements); - virtual bool RemoveElement(CefRefPtr element); - virtual bool AddElement(CefRefPtr element); - virtual void RemoveElements(); + virtual size_t GetElementCount() OVERRIDE; + virtual void GetElements(ElementVector& elements) OVERRIDE; + virtual bool RemoveElement(CefRefPtr element) OVERRIDE; + virtual bool AddElement(CefRefPtr element) OVERRIDE; + virtual void RemoveElements() OVERRIDE; }; #endif // USING_CEF_SHARED diff --git a/libcef_dll/ctocpp/post_data_element_ctocpp.cc b/libcef_dll/ctocpp/post_data_element_ctocpp.cc index 955c68c98..76b7f5f21 100644 --- a/libcef_dll/ctocpp/post_data_element_ctocpp.cc +++ b/libcef_dll/ctocpp/post_data_element_ctocpp.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -86,7 +86,7 @@ size_t CefPostDataElementCToCpp::GetBytes(size_t size, void* bytes) } -#ifdef _DEBUG +#ifndef NDEBUG template<> long CefCToCpp::DebugObjCt = 0; #endif diff --git a/libcef_dll/ctocpp/post_data_element_ctocpp.h b/libcef_dll/ctocpp/post_data_element_ctocpp.h index 3c35caf2c..2b8496dee 100644 --- a/libcef_dll/ctocpp/post_data_element_ctocpp.h +++ b/libcef_dll/ctocpp/post_data_element_ctocpp.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -33,13 +33,13 @@ public: virtual ~CefPostDataElementCToCpp() {} // CefPostDataElement methods - virtual void SetToEmpty(); - virtual void SetToFile(const CefString& fileName); - virtual void SetToBytes(size_t size, const void* bytes); - virtual Type GetType(); - virtual CefString GetFile(); - virtual size_t GetBytesCount(); - virtual size_t GetBytes(size_t size, void* bytes); + virtual void SetToEmpty() OVERRIDE; + virtual void SetToFile(const CefString& fileName) OVERRIDE; + virtual void SetToBytes(size_t size, const void* bytes) OVERRIDE; + virtual Type GetType() OVERRIDE; + virtual CefString GetFile() OVERRIDE; + virtual size_t GetBytesCount() OVERRIDE; + virtual size_t GetBytes(size_t size, void* bytes) OVERRIDE; }; #endif // USING_CEF_SHARED diff --git a/libcef_dll/ctocpp/print_handler_ctocpp.cc b/libcef_dll/ctocpp/print_handler_ctocpp.cc new file mode 100644 index 000000000..6fcca75e9 --- /dev/null +++ b/libcef_dll/ctocpp/print_handler_ctocpp.cc @@ -0,0 +1,54 @@ +// 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. +// +// --------------------------------------------------------------------------- +// +// A portion of this file was generated by the CEF translator tool. When +// making changes by hand only do so within the body of existing static and +// virtual method implementations. See the translator.README.txt file in the +// tools directory for more information. +// + +#include "libcef_dll/cpptoc/browser_cpptoc.h" +#include "libcef_dll/cpptoc/frame_cpptoc.h" +#include "libcef_dll/ctocpp/print_handler_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +bool CefPrintHandlerCToCpp::GetPrintOptions(CefRefPtr browser, + CefPrintOptions& printOptions) +{ + if (CEF_MEMBER_MISSING(struct_, get_print_options)) + return false; + + return struct_->get_print_options(struct_, CefBrowserCppToC::Wrap(browser), + &printOptions) ? true : false; +} + +bool CefPrintHandlerCToCpp::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) +{ + if (CEF_MEMBER_MISSING(struct_, get_print_header_footer)) + return false; + + return struct_->get_print_header_footer(struct_, + CefBrowserCppToC::Wrap(browser), CefFrameCppToC::Wrap(frame), + &printInfo, url.GetStruct(), title.GetStruct(), currentPage, maxPages, + topLeft.GetWritableStruct(), topCenter.GetWritableStruct(), + topRight.GetWritableStruct(), bottomLeft.GetWritableStruct(), + bottomCenter.GetWritableStruct(), bottomRight.GetWritableStruct()) ? + true : false; +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/libcef_dll/ctocpp/print_handler_ctocpp.h b/libcef_dll/ctocpp/print_handler_ctocpp.h new file mode 100644 index 000000000..a0574f66b --- /dev/null +++ b/libcef_dll/ctocpp/print_handler_ctocpp.h @@ -0,0 +1,48 @@ +// 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 was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// + +#ifndef _PRINTHANDLER_CTOCPP_H +#define _PRINTHANDLER_CTOCPP_H + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef.h" +#include "include/cef_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed DLL-side only. +class CefPrintHandlerCToCpp + : public CefCToCpp +{ +public: + CefPrintHandlerCToCpp(cef_print_handler_t* str) + : CefCToCpp( + str) {} + virtual ~CefPrintHandlerCToCpp() {} + + // CefPrintHandler methods + virtual bool GetPrintOptions(CefRefPtr browser, + CefPrintOptions& printOptions) OVERRIDE; + 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; +}; + +#endif // BUILDING_CEF_SHARED +#endif // _PRINTHANDLER_CTOCPP_H + diff --git a/libcef_dll/ctocpp/read_handler_ctocpp.cc b/libcef_dll/ctocpp/read_handler_ctocpp.cc index a7e827e22..ba4c5dabc 100644 --- a/libcef_dll/ctocpp/read_handler_ctocpp.cc +++ b/libcef_dll/ctocpp/read_handler_ctocpp.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -48,7 +48,7 @@ int CefReadHandlerCToCpp::Eof() } -#ifdef _DEBUG +#ifndef NDEBUG template<> long CefCToCpp::DebugObjCt = 0; #endif diff --git a/libcef_dll/ctocpp/read_handler_ctocpp.h b/libcef_dll/ctocpp/read_handler_ctocpp.h index 4de27653e..09cad2d44 100644 --- a/libcef_dll/ctocpp/read_handler_ctocpp.h +++ b/libcef_dll/ctocpp/read_handler_ctocpp.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -32,10 +32,10 @@ public: virtual ~CefReadHandlerCToCpp() {} // CefReadHandler methods - virtual size_t Read(void* ptr, size_t size, size_t n); - virtual int Seek(long offset, int whence); - virtual long Tell(); - virtual int Eof(); + virtual size_t Read(void* ptr, size_t size, size_t n) OVERRIDE; + virtual int Seek(long offset, int whence) OVERRIDE; + virtual long Tell() OVERRIDE; + virtual int Eof() OVERRIDE; }; #endif // BUILDING_CEF_SHARED diff --git a/libcef_dll/ctocpp/render_handler_ctocpp.cc b/libcef_dll/ctocpp/render_handler_ctocpp.cc new file mode 100644 index 000000000..f1661afe2 --- /dev/null +++ b/libcef_dll/ctocpp/render_handler_ctocpp.cc @@ -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. +// +// --------------------------------------------------------------------------- +// +// A portion of this file was generated by the CEF translator tool. When +// making changes by hand only do so within the body of existing static and +// virtual method implementations. See the translator.README.txt file in the +// tools directory for more information. +// + +#include "libcef_dll/cpptoc/browser_cpptoc.h" +#include "libcef_dll/ctocpp/render_handler_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +bool CefRenderHandlerCToCpp::GetViewRect(CefRefPtr browser, + CefRect& rect) +{ + if (CEF_MEMBER_MISSING(struct_, get_view_rect)) + return false; + + return struct_->get_view_rect(struct_, CefBrowserCppToC::Wrap(browser), + &rect) ? true : false; +} + +bool CefRenderHandlerCToCpp::GetScreenRect(CefRefPtr browser, + CefRect& rect) +{ + if (CEF_MEMBER_MISSING(struct_, get_screen_rect)) + return false; + + return struct_->get_screen_rect(struct_, CefBrowserCppToC::Wrap(browser), + &rect) ? true : false; +} + +bool CefRenderHandlerCToCpp::GetScreenPoint(CefRefPtr browser, + int viewX, int viewY, int& screenX, int& screenY) +{ + if (CEF_MEMBER_MISSING(struct_, get_screen_point)) + return false; + + return struct_->get_screen_point(struct_, CefBrowserCppToC::Wrap(browser), + viewX, viewY, &screenX, &screenY) ? true : false; +} + +void CefRenderHandlerCToCpp::OnPopupShow(CefRefPtr browser, + bool show) +{ + if (CEF_MEMBER_MISSING(struct_, on_popup_show)) + return; + + struct_->on_popup_show(struct_, CefBrowserCppToC::Wrap(browser), show); +} + +void CefRenderHandlerCToCpp::OnPopupSize(CefRefPtr browser, + const CefRect& rect) +{ + // BEGIN DELETE BEFORE MODIFYING + if (CEF_MEMBER_MISSING(struct_, on_popup_size)) + return; + + struct_->on_popup_size(struct_, CefBrowserCppToC::Wrap(browser), &rect); +} + +void CefRenderHandlerCToCpp::OnPaint(CefRefPtr browser, + PaintElementType type, const CefRect& dirtyRect, const void* buffer) +{ + if (CEF_MEMBER_MISSING(struct_, on_paint)) + return; + + return struct_->on_paint(struct_, CefBrowserCppToC::Wrap(browser), type, + &dirtyRect, buffer); +} + +void CefRenderHandlerCToCpp::OnCursorChange(CefRefPtr browser, + CefCursorHandle cursor) +{ + if (CEF_MEMBER_MISSING(struct_, on_cursor_change)) + return; + + return struct_->on_cursor_change(struct_, CefBrowserCppToC::Wrap(browser), + cursor); +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/libcef_dll/ctocpp/render_handler_ctocpp.h b/libcef_dll/ctocpp/render_handler_ctocpp.h new file mode 100644 index 000000000..7375e06da --- /dev/null +++ b/libcef_dll/ctocpp/render_handler_ctocpp.h @@ -0,0 +1,53 @@ +// 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 was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// + +#ifndef _RENDERHANDLER_CTOCPP_H +#define _RENDERHANDLER_CTOCPP_H + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef.h" +#include "include/cef_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed DLL-side only. +class CefRenderHandlerCToCpp + : public CefCToCpp +{ +public: + CefRenderHandlerCToCpp(cef_render_handler_t* str) + : CefCToCpp(str) {} + virtual ~CefRenderHandlerCToCpp() {} + + // CefRenderHandler methods + virtual bool GetViewRect(CefRefPtr browser, + CefRect& rect) OVERRIDE; + virtual bool GetScreenRect(CefRefPtr browser, + CefRect& rect) OVERRIDE; + virtual bool GetScreenPoint(CefRefPtr browser, int viewX, + int viewY, int& screenX, int& screenY) OVERRIDE; + virtual void OnPopupShow(CefRefPtr browser, bool show) OVERRIDE; + virtual void OnPopupSize(CefRefPtr browser, + const CefRect& rect) OVERRIDE; + virtual void OnPaint(CefRefPtr browser, PaintElementType type, + const CefRect& dirtyRect, const void* buffer) OVERRIDE; + virtual void OnCursorChange(CefRefPtr browser, + CefCursorHandle cursor) OVERRIDE; +}; + +#endif // BUILDING_CEF_SHARED +#endif // _RENDERHANDLER_CTOCPP_H + diff --git a/libcef_dll/ctocpp/request_ctocpp.cc b/libcef_dll/ctocpp/request_ctocpp.cc index 4c9190d3d..ca0886776 100644 --- a/libcef_dll/ctocpp/request_ctocpp.cc +++ b/libcef_dll/ctocpp/request_ctocpp.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -183,7 +183,7 @@ void CefRequestCToCpp::SetFirstPartyForCookies(const CefString& url) } -#ifdef _DEBUG +#ifndef NDEBUG template<> long CefCToCpp::DebugObjCt = 0; #endif diff --git a/libcef_dll/ctocpp/request_ctocpp.h b/libcef_dll/ctocpp/request_ctocpp.h index b1179fa4a..60e089a77 100644 --- a/libcef_dll/ctocpp/request_ctocpp.h +++ b/libcef_dll/ctocpp/request_ctocpp.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -31,20 +31,20 @@ public: virtual ~CefRequestCToCpp() {} // CefRequest methods - virtual CefString GetURL(); - virtual void SetURL(const CefString& url); - virtual CefString GetMethod(); - virtual void SetMethod(const CefString& method); - virtual CefRefPtr GetPostData(); - virtual void SetPostData(CefRefPtr postData); - virtual void GetHeaderMap(HeaderMap& headerMap); - virtual void SetHeaderMap(const HeaderMap& headerMap); + virtual CefString GetURL() OVERRIDE; + virtual void SetURL(const CefString& url) OVERRIDE; + virtual CefString GetMethod() OVERRIDE; + virtual void SetMethod(const CefString& method) OVERRIDE; + virtual CefRefPtr GetPostData() OVERRIDE; + virtual void SetPostData(CefRefPtr postData) OVERRIDE; + virtual void GetHeaderMap(HeaderMap& headerMap) OVERRIDE; + virtual void SetHeaderMap(const HeaderMap& headerMap) OVERRIDE; virtual void Set(const CefString& url, const CefString& method, - CefRefPtr postData, const HeaderMap& headerMap); - virtual RequestFlags GetFlags(); - virtual void SetFlags(RequestFlags flags); - virtual CefString GetFirstPartyForCookies(); - virtual void SetFirstPartyForCookies(const CefString& url); + CefRefPtr postData, const HeaderMap& headerMap) OVERRIDE; + virtual RequestFlags GetFlags() OVERRIDE; + virtual void SetFlags(RequestFlags flags) OVERRIDE; + virtual CefString GetFirstPartyForCookies() OVERRIDE; + virtual void SetFirstPartyForCookies(const CefString& url) OVERRIDE; }; #endif // USING_CEF_SHARED diff --git a/libcef_dll/ctocpp/request_handler_ctocpp.cc b/libcef_dll/ctocpp/request_handler_ctocpp.cc new file mode 100644 index 000000000..6fdb0e65f --- /dev/null +++ b/libcef_dll/ctocpp/request_handler_ctocpp.cc @@ -0,0 +1,107 @@ +// 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. +// +// --------------------------------------------------------------------------- +// +// A portion of this file was generated by the CEF translator tool. When +// making changes by hand only do so within the body of existing static and +// virtual method implementations. See the translator.README.txt file in the +// tools directory for more information. +// + +#include "libcef_dll/cpptoc/browser_cpptoc.h" +#include "libcef_dll/cpptoc/frame_cpptoc.h" +#include "libcef_dll/cpptoc/request_cpptoc.h" +#include "libcef_dll/cpptoc/response_cpptoc.h" +#include "libcef_dll/cpptoc/stream_reader_cpptoc.h" +#include "libcef_dll/ctocpp/download_handler_ctocpp.h" +#include "libcef_dll/ctocpp/request_handler_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +bool CefRequestHandlerCToCpp::OnBeforeBrowse(CefRefPtr browser, + CefRefPtr frame, CefRefPtr request, NavType navType, + bool isRedirect) +{ + if (CEF_MEMBER_MISSING(struct_, on_before_browse)) + return true; + + return struct_->on_before_browse(struct_, CefBrowserCppToC::Wrap(browser), + CefFrameCppToC::Wrap(frame), CefRequestCppToC::Wrap(request), + navType, isRedirect) ? true : false; +} + +bool CefRequestHandlerCToCpp::OnBeforeResourceLoad( + CefRefPtr browser, CefRefPtr request, + CefString& redirectUrl, CefRefPtr& resourceStream, + CefRefPtr response, int loadFlags) +{ + if (CEF_MEMBER_MISSING(struct_, on_before_resource_load)) + return false; + + cef_stream_reader_t* streamRet = NULL; + + int rv = struct_->on_before_resource_load(struct_, + CefBrowserCppToC::Wrap(browser), CefRequestCppToC::Wrap(request), + redirectUrl.GetWritableStruct(), &streamRet, + CefResponseCppToC::Wrap(response), loadFlags); + + if(streamRet) + resourceStream = CefStreamReaderCppToC::Unwrap(streamRet); + + return (rv ? true : false); +} + +bool CefRequestHandlerCToCpp::OnProtocolExecution(CefRefPtr browser, + const CefString& url, bool& allowOSExecution) +{ + if (CEF_MEMBER_MISSING(struct_, on_protocol_execution)) + return false; + + int allowExec = allowOSExecution; + int rv = struct_->on_protocol_execution(struct_, + CefBrowserCppToC::Wrap(browser), url.GetStruct(), &allowExec); + allowOSExecution = allowExec?true:false; + return (rv ? true : false); +} + +bool CefRequestHandlerCToCpp::GetDownloadHandler(CefRefPtr browser, + const CefString& mimeType, const CefString& fileName, int64 contentLength, + CefRefPtr& handler) +{ + if (CEF_MEMBER_MISSING(struct_, get_download_handler)) + return false; + + cef_download_handler_t* handlerRet = NULL; + + int rv = struct_->get_download_handler(struct_, + CefBrowserCppToC::Wrap(browser), mimeType.GetStruct(), + fileName.GetStruct(), contentLength, &handlerRet); + + if(handlerRet) + handler = CefDownloadHandlerCToCpp::Wrap(handlerRet); + + return (rv ? true : false); +} + +bool CefRequestHandlerCToCpp::GetAuthCredentials(CefRefPtr browser, + bool isProxy, const CefString& host, const CefString& realm, + const CefString& scheme, CefString& username, CefString& password) +{ + if (CEF_MEMBER_MISSING(struct_, get_auth_credentials)) + return false; + + return struct_->get_auth_credentials(struct_, CefBrowserCppToC::Wrap(browser), + isProxy, host.GetStruct(), realm.GetStruct(), scheme.GetStruct(), + username.GetWritableStruct(), password.GetWritableStruct()) ? + true : false; +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/libcef_dll/ctocpp/request_handler_ctocpp.h b/libcef_dll/ctocpp/request_handler_ctocpp.h new file mode 100644 index 000000000..188f84574 --- /dev/null +++ b/libcef_dll/ctocpp/request_handler_ctocpp.h @@ -0,0 +1,55 @@ +// 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 was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// + +#ifndef _REQUESTHANDLER_CTOCPP_H +#define _REQUESTHANDLER_CTOCPP_H + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef.h" +#include "include/cef_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed DLL-side only. +class CefRequestHandlerCToCpp + : public CefCToCpp +{ +public: + CefRequestHandlerCToCpp(cef_request_handler_t* str) + : CefCToCpp(str) {} + virtual ~CefRequestHandlerCToCpp() {} + + // CefRequestHandler methods + virtual bool OnBeforeBrowse(CefRefPtr browser, + CefRefPtr frame, CefRefPtr request, + NavType navType, bool isRedirect) OVERRIDE; + virtual bool OnBeforeResourceLoad(CefRefPtr browser, + CefRefPtr request, CefString& redirectUrl, + CefRefPtr& resourceStream, + CefRefPtr response, int loadFlags) OVERRIDE; + virtual bool OnProtocolExecution(CefRefPtr browser, + const CefString& url, bool& allowOSExecution) OVERRIDE; + virtual bool GetDownloadHandler(CefRefPtr browser, + const CefString& mimeType, const CefString& fileName, + int64 contentLength, CefRefPtr& handler) OVERRIDE; + virtual bool GetAuthCredentials(CefRefPtr browser, bool isProxy, + const CefString& host, const CefString& realm, const CefString& scheme, + CefString& username, CefString& password) OVERRIDE; +}; + +#endif // BUILDING_CEF_SHARED +#endif // _REQUESTHANDLER_CTOCPP_H + diff --git a/libcef_dll/ctocpp/response_ctocpp.cc b/libcef_dll/ctocpp/response_ctocpp.cc index fc1cd8b30..e59eb3a2a 100644 --- a/libcef_dll/ctocpp/response_ctocpp.cc +++ b/libcef_dll/ctocpp/response_ctocpp.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -115,7 +115,7 @@ void CefResponseCToCpp::SetHeaderMap(const HeaderMap& headerMap) } -#ifdef _DEBUG +#ifndef NDEBUG template<> long CefCToCpp::DebugObjCt = 0; #endif diff --git a/libcef_dll/ctocpp/response_ctocpp.h b/libcef_dll/ctocpp/response_ctocpp.h index c8959730d..434a5f97c 100644 --- a/libcef_dll/ctocpp/response_ctocpp.h +++ b/libcef_dll/ctocpp/response_ctocpp.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -31,15 +31,15 @@ public: virtual ~CefResponseCToCpp() {} // CefResponse methods - virtual int GetStatus(); - virtual void SetStatus(int status); - virtual CefString GetStatusText(); - virtual void SetStatusText(const CefString& statusText); - virtual CefString GetMimeType(); - virtual void SetMimeType(const CefString& mimeType); - virtual CefString GetHeader(const CefString& name); - virtual void GetHeaderMap(HeaderMap& headerMap); - virtual void SetHeaderMap(const HeaderMap& headerMap); + virtual int GetStatus() OVERRIDE; + virtual void SetStatus(int status) OVERRIDE; + virtual CefString GetStatusText() OVERRIDE; + virtual void SetStatusText(const CefString& statusText) OVERRIDE; + virtual CefString GetMimeType() OVERRIDE; + virtual void SetMimeType(const CefString& mimeType) OVERRIDE; + virtual CefString GetHeader(const CefString& name) OVERRIDE; + virtual void GetHeaderMap(HeaderMap& headerMap) OVERRIDE; + virtual void SetHeaderMap(const HeaderMap& headerMap) OVERRIDE; }; #endif // USING_CEF_SHARED diff --git a/libcef_dll/ctocpp/scheme_handler_ctocpp.cc b/libcef_dll/ctocpp/scheme_handler_ctocpp.cc index 069c83d76..6728bb051 100644 --- a/libcef_dll/ctocpp/scheme_handler_ctocpp.cc +++ b/libcef_dll/ctocpp/scheme_handler_ctocpp.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -48,7 +48,7 @@ bool CefSchemeHandlerCToCpp::ReadResponse(void* data_out, int bytes_to_read, } -#ifdef _DEBUG +#ifndef NDEBUG template<> long CefCToCpp::DebugObjCt = 0; #endif diff --git a/libcef_dll/ctocpp/scheme_handler_ctocpp.h b/libcef_dll/ctocpp/scheme_handler_ctocpp.h index 3bd60ca2a..60ec92661 100644 --- a/libcef_dll/ctocpp/scheme_handler_ctocpp.h +++ b/libcef_dll/ctocpp/scheme_handler_ctocpp.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -35,9 +35,10 @@ public: // CefSchemeHandler methods virtual bool ProcessRequest(CefRefPtr request, CefString& redirectUrl, CefRefPtr response, - int* response_length); - virtual void Cancel(); - virtual bool ReadResponse(void* data_out, int bytes_to_read, int* bytes_read); + int* response_length) OVERRIDE; + virtual void Cancel() OVERRIDE; + virtual bool ReadResponse(void* data_out, int bytes_to_read, + int* bytes_read) OVERRIDE; }; #endif // BUILDING_CEF_SHARED diff --git a/libcef_dll/ctocpp/scheme_handler_factory_ctocpp.cc b/libcef_dll/ctocpp/scheme_handler_factory_ctocpp.cc index 4c6538e3a..245f0d4cb 100644 --- a/libcef_dll/ctocpp/scheme_handler_factory_ctocpp.cc +++ b/libcef_dll/ctocpp/scheme_handler_factory_ctocpp.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -27,7 +27,7 @@ CefRefPtr CefSchemeHandlerFactoryCToCpp::Create() } -#ifdef _DEBUG +#ifndef NDEBUG template<> long CefCToCpp::DebugObjCt = 0; #endif diff --git a/libcef_dll/ctocpp/scheme_handler_factory_ctocpp.h b/libcef_dll/ctocpp/scheme_handler_factory_ctocpp.h index d291c0492..c1e0051e8 100644 --- a/libcef_dll/ctocpp/scheme_handler_factory_ctocpp.h +++ b/libcef_dll/ctocpp/scheme_handler_factory_ctocpp.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -33,7 +33,7 @@ public: virtual ~CefSchemeHandlerFactoryCToCpp() {} // CefSchemeHandlerFactory methods - virtual CefRefPtr Create(); + virtual CefRefPtr Create() OVERRIDE; }; #endif // BUILDING_CEF_SHARED diff --git a/libcef_dll/ctocpp/stream_reader_ctocpp.cc b/libcef_dll/ctocpp/stream_reader_ctocpp.cc index 76ef1de91..c3ceba4fa 100644 --- a/libcef_dll/ctocpp/stream_reader_ctocpp.cc +++ b/libcef_dll/ctocpp/stream_reader_ctocpp.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -81,7 +81,7 @@ int CefStreamReaderCToCpp::Eof() } -#ifdef _DEBUG +#ifndef NDEBUG template<> long CefCToCpp::DebugObjCt = 0; #endif diff --git a/libcef_dll/ctocpp/stream_reader_ctocpp.h b/libcef_dll/ctocpp/stream_reader_ctocpp.h index 5b5efdef5..ee291cc55 100644 --- a/libcef_dll/ctocpp/stream_reader_ctocpp.h +++ b/libcef_dll/ctocpp/stream_reader_ctocpp.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -33,10 +33,10 @@ public: virtual ~CefStreamReaderCToCpp() {} // CefStreamReader methods - virtual size_t Read(void* ptr, size_t size, size_t n); - virtual int Seek(long offset, int whence); - virtual long Tell(); - virtual int Eof(); + virtual size_t Read(void* ptr, size_t size, size_t n) OVERRIDE; + virtual int Seek(long offset, int whence) OVERRIDE; + virtual long Tell() OVERRIDE; + virtual int Eof() OVERRIDE; }; #endif // USING_CEF_SHARED diff --git a/libcef_dll/ctocpp/stream_writer_ctocpp.cc b/libcef_dll/ctocpp/stream_writer_ctocpp.cc index 36df3aa4d..b92c66ca4 100644 --- a/libcef_dll/ctocpp/stream_writer_ctocpp.cc +++ b/libcef_dll/ctocpp/stream_writer_ctocpp.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -81,7 +81,7 @@ int CefStreamWriterCToCpp::Flush() } -#ifdef _DEBUG +#ifndef NDEBUG template<> long CefCToCpp::DebugObjCt = 0; #endif diff --git a/libcef_dll/ctocpp/stream_writer_ctocpp.h b/libcef_dll/ctocpp/stream_writer_ctocpp.h index c979bd677..777860db0 100644 --- a/libcef_dll/ctocpp/stream_writer_ctocpp.h +++ b/libcef_dll/ctocpp/stream_writer_ctocpp.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -33,10 +33,10 @@ public: virtual ~CefStreamWriterCToCpp() {} // CefStreamWriter methods - virtual size_t Write(const void* ptr, size_t size, size_t n); - virtual int Seek(long offset, int whence); - virtual long Tell(); - virtual int Flush(); + virtual size_t Write(const void* ptr, size_t size, size_t n) OVERRIDE; + virtual int Seek(long offset, int whence) OVERRIDE; + virtual long Tell() OVERRIDE; + virtual int Flush() OVERRIDE; }; #endif // USING_CEF_SHARED diff --git a/libcef_dll/ctocpp/task_ctocpp.cc b/libcef_dll/ctocpp/task_ctocpp.cc index d88d8c2b1..7949065b3 100644 --- a/libcef_dll/ctocpp/task_ctocpp.cc +++ b/libcef_dll/ctocpp/task_ctocpp.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -24,7 +24,7 @@ void CefTaskCToCpp::Execute(CefThreadId threadId) } -#ifdef _DEBUG +#ifndef NDEBUG template<> long CefCToCpp::DebugObjCt = 0; #endif diff --git a/libcef_dll/ctocpp/task_ctocpp.h b/libcef_dll/ctocpp/task_ctocpp.h index 4000ad285..9260338e2 100644 --- a/libcef_dll/ctocpp/task_ctocpp.h +++ b/libcef_dll/ctocpp/task_ctocpp.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -31,7 +31,7 @@ public: virtual ~CefTaskCToCpp() {} // CefTask methods - virtual void Execute(CefThreadId threadId); + virtual void Execute(CefThreadId threadId) OVERRIDE; }; #endif // BUILDING_CEF_SHARED diff --git a/libcef_dll/ctocpp/v8accessor_ctocpp.cc b/libcef_dll/ctocpp/v8accessor_ctocpp.cc index 4628b925a..4598fe69c 100644 --- a/libcef_dll/ctocpp/v8accessor_ctocpp.cc +++ b/libcef_dll/ctocpp/v8accessor_ctocpp.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -46,7 +46,7 @@ bool CefV8AccessorCToCpp::Set(const CefString& name, } -#ifdef _DEBUG +#ifndef NDEBUG template<> long CefCToCpp::DebugObjCt = 0; #endif diff --git a/libcef_dll/ctocpp/v8accessor_ctocpp.h b/libcef_dll/ctocpp/v8accessor_ctocpp.h index 5360edc90..0044920fc 100644 --- a/libcef_dll/ctocpp/v8accessor_ctocpp.h +++ b/libcef_dll/ctocpp/v8accessor_ctocpp.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -32,9 +32,9 @@ public: // CefV8Accessor methods virtual bool Get(const CefString& name, const CefRefPtr object, - CefRefPtr& retval); + CefRefPtr& retval) OVERRIDE; virtual bool Set(const CefString& name, const CefRefPtr object, - const CefRefPtr value); + const CefRefPtr value) OVERRIDE; }; #endif // BUILDING_CEF_SHARED diff --git a/libcef_dll/ctocpp/v8context_ctocpp.cc b/libcef_dll/ctocpp/v8context_ctocpp.cc index ac412fb3a..371e4c4ac 100644 --- a/libcef_dll/ctocpp/v8context_ctocpp.cc +++ b/libcef_dll/ctocpp/v8context_ctocpp.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -90,7 +90,7 @@ bool CefV8ContextCToCpp::Exit() } -#ifdef _DEBUG +#ifndef NDEBUG template<> long CefCToCpp::DebugObjCt = 0; #endif diff --git a/libcef_dll/ctocpp/v8context_ctocpp.h b/libcef_dll/ctocpp/v8context_ctocpp.h index 549d1ace6..82b834b1d 100644 --- a/libcef_dll/ctocpp/v8context_ctocpp.h +++ b/libcef_dll/ctocpp/v8context_ctocpp.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -31,11 +31,11 @@ public: virtual ~CefV8ContextCToCpp() {} // CefV8Context methods - virtual CefRefPtr GetBrowser(); - virtual CefRefPtr GetFrame(); - virtual CefRefPtr GetGlobal(); - virtual bool Enter(); - virtual bool Exit(); + virtual CefRefPtr GetBrowser() OVERRIDE; + virtual CefRefPtr GetFrame() OVERRIDE; + virtual CefRefPtr GetGlobal() OVERRIDE; + virtual bool Enter() OVERRIDE; + virtual bool Exit() OVERRIDE; }; #endif // USING_CEF_SHARED diff --git a/libcef_dll/ctocpp/v8handler_ctocpp.cc b/libcef_dll/ctocpp/v8handler_ctocpp.cc index ec5021a12..1e92400aa 100644 --- a/libcef_dll/ctocpp/v8handler_ctocpp.cc +++ b/libcef_dll/ctocpp/v8handler_ctocpp.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -21,7 +21,7 @@ bool CefV8HandlerCToCpp::Execute(const CefString& name, CefRefPtr& retval, CefString& exception) { if(CEF_MEMBER_MISSING(struct_, execute)) - return RV_CONTINUE; + return false; cef_v8value_t** argsStructPtr = NULL; int argsSize = arguments.size(); @@ -46,7 +46,7 @@ bool CefV8HandlerCToCpp::Execute(const CefString& name, } -#ifdef _DEBUG +#ifndef NDEBUG template<> long CefCToCpp::DebugObjCt = 0; #endif diff --git a/libcef_dll/ctocpp/v8handler_ctocpp.h b/libcef_dll/ctocpp/v8handler_ctocpp.h index 235bb2a70..9c271834d 100644 --- a/libcef_dll/ctocpp/v8handler_ctocpp.h +++ b/libcef_dll/ctocpp/v8handler_ctocpp.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -33,7 +33,7 @@ public: // CefV8Handler methods virtual bool Execute(const CefString& name, CefRefPtr object, const CefV8ValueList& arguments, CefRefPtr& retval, - CefString& exception); + CefString& exception) OVERRIDE; }; #endif // BUILDING_CEF_SHARED diff --git a/libcef_dll/ctocpp/v8value_ctocpp.cc b/libcef_dll/ctocpp/v8value_ctocpp.cc index 70c59d7a6..1bfe649e4 100644 --- a/libcef_dll/ctocpp/v8value_ctocpp.cc +++ b/libcef_dll/ctocpp/v8value_ctocpp.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -439,7 +439,7 @@ bool CefV8ValueCToCpp::ExecuteFunctionWithContext( } -#ifdef _DEBUG +#ifndef NDEBUG template<> long CefCToCpp::DebugObjCt = 0; #endif diff --git a/libcef_dll/ctocpp/v8value_ctocpp.h b/libcef_dll/ctocpp/v8value_ctocpp.h index 69d69253a..712140598 100644 --- a/libcef_dll/ctocpp/v8value_ctocpp.h +++ b/libcef_dll/ctocpp/v8value_ctocpp.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -31,41 +31,42 @@ public: virtual ~CefV8ValueCToCpp() {} // CefV8Value methods - virtual bool IsUndefined(); - virtual bool IsNull(); - virtual bool IsBool(); - virtual bool IsInt(); - virtual bool IsDouble(); - virtual bool IsString(); - virtual bool IsObject(); - virtual bool IsArray(); - virtual bool IsFunction(); - virtual bool IsSame(CefRefPtr that); - virtual bool GetBoolValue(); - virtual int GetIntValue(); - virtual double GetDoubleValue(); - virtual CefString GetStringValue(); - virtual bool HasValue(const CefString& key); - virtual bool HasValue(int index); - virtual bool DeleteValue(const CefString& key); - virtual bool DeleteValue(int index); - virtual CefRefPtr GetValue(const CefString& key); - virtual CefRefPtr GetValue(int index); - virtual bool SetValue(const CefString& key, CefRefPtr value); - virtual bool SetValue(int index, CefRefPtr value); + virtual bool IsUndefined() OVERRIDE; + virtual bool IsNull() OVERRIDE; + virtual bool IsBool() OVERRIDE; + virtual bool IsInt() OVERRIDE; + virtual bool IsDouble() OVERRIDE; + virtual bool IsString() OVERRIDE; + virtual bool IsObject() OVERRIDE; + virtual bool IsArray() OVERRIDE; + virtual bool IsFunction() OVERRIDE; + virtual bool IsSame(CefRefPtr that) OVERRIDE; + virtual bool GetBoolValue() OVERRIDE; + virtual int GetIntValue() OVERRIDE; + virtual double GetDoubleValue() OVERRIDE; + virtual CefString GetStringValue() OVERRIDE; + virtual bool HasValue(const CefString& key) OVERRIDE; + virtual bool HasValue(int index) OVERRIDE; + virtual bool DeleteValue(const CefString& key) OVERRIDE; + virtual bool DeleteValue(int index) OVERRIDE; + virtual CefRefPtr GetValue(const CefString& key) OVERRIDE; + virtual CefRefPtr GetValue(int index) OVERRIDE; + virtual bool SetValue(const CefString& key, + CefRefPtr value) OVERRIDE; + virtual bool SetValue(int index, CefRefPtr value) OVERRIDE; virtual bool SetValue(const CefString& key, AccessControl settings, - PropertyAttribute attribute); - virtual bool GetKeys(std::vector& keys); - virtual CefRefPtr GetUserData(); - virtual int GetArrayLength(); - virtual CefString GetFunctionName(); - virtual CefRefPtr GetFunctionHandler(); + PropertyAttribute attribute) OVERRIDE; + virtual bool GetKeys(std::vector& keys) OVERRIDE; + virtual CefRefPtr GetUserData() OVERRIDE; + virtual int GetArrayLength() OVERRIDE; + virtual CefString GetFunctionName() OVERRIDE; + virtual CefRefPtr GetFunctionHandler() OVERRIDE; virtual bool ExecuteFunction(CefRefPtr object, const CefV8ValueList& arguments, CefRefPtr& retval, - CefString& exception); + CefString& exception) OVERRIDE; virtual bool ExecuteFunctionWithContext(CefRefPtr context, CefRefPtr object, const CefV8ValueList& arguments, - CefRefPtr& retval, CefString& exception); + CefRefPtr& retval, CefString& exception) OVERRIDE; }; #endif // USING_CEF_SHARED diff --git a/libcef_dll/ctocpp/web_urlrequest_client_ctocpp.cc b/libcef_dll/ctocpp/web_urlrequest_client_ctocpp.cc index 7b5a88384..bb5c3e27f 100644 --- a/libcef_dll/ctocpp/web_urlrequest_client_ctocpp.cc +++ b/libcef_dll/ctocpp/web_urlrequest_client_ctocpp.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -81,7 +81,7 @@ void CefWebURLRequestClientCToCpp::OnError( } -#ifdef _DEBUG +#ifndef NDEBUG template<> long CefCToCpp::DebugObjCt = 0; #endif diff --git a/libcef_dll/ctocpp/web_urlrequest_client_ctocpp.h b/libcef_dll/ctocpp/web_urlrequest_client_ctocpp.h index 55af0df84..fa82687f3 100644 --- a/libcef_dll/ctocpp/web_urlrequest_client_ctocpp.h +++ b/libcef_dll/ctocpp/web_urlrequest_client_ctocpp.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -34,17 +34,18 @@ public: // CefWebURLRequestClient methods virtual void OnStateChange(CefRefPtr requester, - RequestState state); + RequestState state) OVERRIDE; virtual void OnRedirect(CefRefPtr requester, - CefRefPtr request, CefRefPtr response); + CefRefPtr request, + CefRefPtr response) OVERRIDE; virtual void OnHeadersReceived(CefRefPtr requester, - CefRefPtr response); + CefRefPtr response) OVERRIDE; virtual void OnProgress(CefRefPtr requester, - uint64 bytesSent, uint64 totalBytesToBeSent); + uint64 bytesSent, uint64 totalBytesToBeSent) OVERRIDE; virtual void OnData(CefRefPtr requester, const void* data, - int dataLength); + int dataLength) OVERRIDE; virtual void OnError(CefRefPtr requester, - ErrorCode errorCode); + ErrorCode errorCode) OVERRIDE; }; #endif // BUILDING_CEF_SHARED diff --git a/libcef_dll/ctocpp/web_urlrequest_ctocpp.cc b/libcef_dll/ctocpp/web_urlrequest_ctocpp.cc index 7c7b701d9..d1e4f9549 100644 --- a/libcef_dll/ctocpp/web_urlrequest_ctocpp.cc +++ b/libcef_dll/ctocpp/web_urlrequest_ctocpp.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -55,7 +55,7 @@ CefWebURLRequest::RequestState CefWebURLRequestCToCpp::GetState() } -#ifdef _DEBUG +#ifndef NDEBUG template<> long CefCToCpp::DebugObjCt = 0; #endif diff --git a/libcef_dll/ctocpp/web_urlrequest_ctocpp.h b/libcef_dll/ctocpp/web_urlrequest_ctocpp.h index 761d32064..f60ddb19b 100644 --- a/libcef_dll/ctocpp/web_urlrequest_ctocpp.h +++ b/libcef_dll/ctocpp/web_urlrequest_ctocpp.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -33,8 +33,8 @@ public: virtual ~CefWebURLRequestCToCpp() {} // CefWebURLRequest methods - virtual void Cancel(); - virtual RequestState GetState(); + virtual void Cancel() OVERRIDE; + virtual RequestState GetState() OVERRIDE; }; #endif // USING_CEF_SHARED diff --git a/libcef_dll/ctocpp/write_handler_ctocpp.cc b/libcef_dll/ctocpp/write_handler_ctocpp.cc index 5f25d66b1..80950a57a 100644 --- a/libcef_dll/ctocpp/write_handler_ctocpp.cc +++ b/libcef_dll/ctocpp/write_handler_ctocpp.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -48,7 +48,7 @@ int CefWriteHandlerCToCpp::Flush() } -#ifdef _DEBUG +#ifndef NDEBUG template<> long CefCToCpp::DebugObjCt = 0; #endif diff --git a/libcef_dll/ctocpp/write_handler_ctocpp.h b/libcef_dll/ctocpp/write_handler_ctocpp.h index 23b345dab..280179238 100644 --- a/libcef_dll/ctocpp/write_handler_ctocpp.h +++ b/libcef_dll/ctocpp/write_handler_ctocpp.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -33,10 +33,10 @@ public: virtual ~CefWriteHandlerCToCpp() {} // CefWriteHandler methods - virtual size_t Write(const void* ptr, size_t size, size_t n); - virtual int Seek(long offset, int whence); - virtual long Tell(); - virtual int Flush(); + virtual size_t Write(const void* ptr, size_t size, size_t n) OVERRIDE; + virtual int Seek(long offset, int whence) OVERRIDE; + virtual long Tell() OVERRIDE; + virtual int Flush() OVERRIDE; }; #endif // BUILDING_CEF_SHARED diff --git a/libcef_dll/ctocpp/xml_reader_ctocpp.cc b/libcef_dll/ctocpp/xml_reader_ctocpp.cc index 0cb9cb4d3..33ecbeeda 100644 --- a/libcef_dll/ctocpp/xml_reader_ctocpp.cc +++ b/libcef_dll/ctocpp/xml_reader_ctocpp.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -307,7 +307,7 @@ bool CefXmlReaderCToCpp::MoveToCarryingElement() } -#ifdef _DEBUG +#ifndef NDEBUG template<> long CefCToCpp::DebugObjCt = 0; #endif diff --git a/libcef_dll/ctocpp/xml_reader_ctocpp.h b/libcef_dll/ctocpp/xml_reader_ctocpp.h index b9db7eef6..65d9035de 100644 --- a/libcef_dll/ctocpp/xml_reader_ctocpp.h +++ b/libcef_dll/ctocpp/xml_reader_ctocpp.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -31,37 +31,37 @@ public: virtual ~CefXmlReaderCToCpp() {} // CefXmlReader methods - virtual bool MoveToNextNode(); - virtual bool Close(); - virtual bool HasError(); - virtual CefString GetError(); - virtual NodeType GetType(); - virtual int GetDepth(); - virtual CefString GetLocalName(); - virtual CefString GetPrefix(); - virtual CefString GetQualifiedName(); - virtual CefString GetNamespaceURI(); - virtual CefString GetBaseURI(); - virtual CefString GetXmlLang(); - virtual bool IsEmptyElement(); - virtual bool HasValue(); - virtual CefString GetValue(); - virtual bool HasAttributes(); - virtual size_t GetAttributeCount(); - virtual CefString GetAttribute(int index); - virtual CefString GetAttribute(const CefString& qualifiedName); + virtual bool MoveToNextNode() OVERRIDE; + virtual bool Close() OVERRIDE; + virtual bool HasError() OVERRIDE; + virtual CefString GetError() OVERRIDE; + virtual NodeType GetType() OVERRIDE; + virtual int GetDepth() OVERRIDE; + virtual CefString GetLocalName() OVERRIDE; + virtual CefString GetPrefix() OVERRIDE; + virtual CefString GetQualifiedName() OVERRIDE; + virtual CefString GetNamespaceURI() OVERRIDE; + virtual CefString GetBaseURI() OVERRIDE; + virtual CefString GetXmlLang() OVERRIDE; + virtual bool IsEmptyElement() OVERRIDE; + virtual bool HasValue() OVERRIDE; + virtual CefString GetValue() OVERRIDE; + virtual bool HasAttributes() OVERRIDE; + virtual size_t GetAttributeCount() OVERRIDE; + virtual CefString GetAttribute(int index) OVERRIDE; + virtual CefString GetAttribute(const CefString& qualifiedName) OVERRIDE; virtual CefString GetAttribute(const CefString& localName, - const CefString& namespaceURI); - virtual CefString GetInnerXml(); - virtual CefString GetOuterXml(); - virtual int GetLineNumber(); - virtual bool MoveToAttribute(int index); - virtual bool MoveToAttribute(const CefString& qualifiedName); + const CefString& namespaceURI) OVERRIDE; + virtual CefString GetInnerXml() OVERRIDE; + virtual CefString GetOuterXml() OVERRIDE; + virtual int GetLineNumber() OVERRIDE; + virtual bool MoveToAttribute(int index) OVERRIDE; + virtual bool MoveToAttribute(const CefString& qualifiedName) OVERRIDE; virtual bool MoveToAttribute(const CefString& localName, - const CefString& namespaceURI); - virtual bool MoveToFirstAttribute(); - virtual bool MoveToNextAttribute(); - virtual bool MoveToCarryingElement(); + const CefString& namespaceURI) OVERRIDE; + virtual bool MoveToFirstAttribute() OVERRIDE; + virtual bool MoveToNextAttribute() OVERRIDE; + virtual bool MoveToCarryingElement() OVERRIDE; }; #endif // USING_CEF_SHARED diff --git a/libcef_dll/ctocpp/zip_reader_ctocpp.cc b/libcef_dll/ctocpp/zip_reader_ctocpp.cc index 75395d828..14dccff11 100644 --- a/libcef_dll/ctocpp/zip_reader_ctocpp.cc +++ b/libcef_dll/ctocpp/zip_reader_ctocpp.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -130,7 +130,7 @@ bool CefZipReaderCToCpp::Eof() } -#ifdef _DEBUG +#ifndef NDEBUG template<> long CefCToCpp::DebugObjCt = 0; #endif diff --git a/libcef_dll/ctocpp/zip_reader_ctocpp.h b/libcef_dll/ctocpp/zip_reader_ctocpp.h index fc0c7c653..11f987f36 100644 --- a/libcef_dll/ctocpp/zip_reader_ctocpp.h +++ b/libcef_dll/ctocpp/zip_reader_ctocpp.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// 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. // @@ -31,18 +31,19 @@ public: virtual ~CefZipReaderCToCpp() {} // CefZipReader methods - virtual bool MoveToFirstFile(); - virtual bool MoveToNextFile(); - virtual bool MoveToFile(const CefString& fileName, bool caseSensitive); - virtual bool Close(); - virtual CefString GetFileName(); - virtual long GetFileSize(); - virtual time_t GetFileLastModified(); - virtual bool OpenFile(const CefString& password); - virtual bool CloseFile(); - virtual int ReadFile(void* buffer, size_t bufferSize); - virtual long Tell(); - virtual bool Eof(); + virtual bool MoveToFirstFile() OVERRIDE; + virtual bool MoveToNextFile() OVERRIDE; + virtual bool MoveToFile(const CefString& fileName, + bool caseSensitive) OVERRIDE; + virtual bool Close() OVERRIDE; + virtual CefString GetFileName() OVERRIDE; + virtual long GetFileSize() OVERRIDE; + virtual time_t GetFileLastModified() OVERRIDE; + virtual bool OpenFile(const CefString& password) OVERRIDE; + virtual bool CloseFile() OVERRIDE; + virtual int ReadFile(void* buffer, size_t bufferSize) OVERRIDE; + virtual long Tell() OVERRIDE; + virtual bool Eof() OVERRIDE; }; #endif // USING_CEF_SHARED diff --git a/libcef_dll/libcef_dll.cc b/libcef_dll/libcef_dll.cc index 94d1e090e..6c7c33501 100644 --- a/libcef_dll/libcef_dll.cc +++ b/libcef_dll/libcef_dll.cc @@ -25,7 +25,6 @@ #include "ctocpp/domevent_listener_ctocpp.h" #include "ctocpp/domvisitor_ctocpp.h" #include "ctocpp/download_handler_ctocpp.h" -#include "ctocpp/handler_ctocpp.h" #include "ctocpp/read_handler_ctocpp.h" #include "ctocpp/scheme_handler_ctocpp.h" #include "ctocpp/scheme_handler_factory_ctocpp.h" @@ -37,19 +36,15 @@ #include "base/string_split.h" -CEF_EXPORT int cef_initialize(const struct _cef_settings_t* settings, - const struct _cef_browser_settings_t* browser_defaults) +CEF_EXPORT int cef_initialize(const struct _cef_settings_t* settings) { CefSettings settingsObj; - CefBrowserSettings browserDefaultsObj; // Reference the values instead of copying. if (settings) settingsObj.Set(*settings, false); - if (browser_defaults) - browserDefaultsObj.Set(*browser_defaults, false); - int ret = CefInitialize(settingsObj, browserDefaultsObj); + int ret = CefInitialize(settingsObj); return ret; } @@ -58,7 +53,7 @@ CEF_EXPORT void cef_shutdown() { CefShutdown(); -#ifdef _DEBUG +#ifndef NDEBUG // Check that all wrapper objects have been destroyed DCHECK(CefBrowserCppToC::DebugObjCt == 0); DCHECK(CefDOMDocumentCppToC::DebugObjCt == 0); @@ -85,12 +80,7 @@ CEF_EXPORT void cef_shutdown() DCHECK(CefV8HandlerCToCpp::DebugObjCt == 0); DCHECK(CefWebURLRequestClientCToCpp::DebugObjCt == 0); DCHECK(CefWriteHandlerCToCpp::DebugObjCt == 0); - - // TODO: This breakpoint may be hit if content is still loading when CEF - // exits. Re-enable the breakpoint if/when CEF stops content loading before - // exit. - //DCHECK(CefHandlerCToCpp::DebugObjCt == 0); -#endif // _DEBUG +#endif // !NDEBUG } CEF_EXPORT void cef_do_message_loop_work() diff --git a/libcef_dll/wrapper/cef_byte_read_handler.cc b/libcef_dll/wrapper/cef_byte_read_handler.cc index 1046a99b0..b11fc5b52 100644 --- a/libcef_dll/wrapper/cef_byte_read_handler.cc +++ b/libcef_dll/wrapper/cef_byte_read_handler.cc @@ -13,19 +13,18 @@ CefByteReadHandler::CefByteReadHandler(const unsigned char* bytes, size_t size, size_t CefByteReadHandler::Read(void* ptr, size_t size, size_t n) { - Lock(); + AutoLock lock_scope(this); size_t s = (size_ - offset_) / size; size_t ret = std::min(n, s); memcpy(ptr, bytes_ + offset_, ret * size); offset_ += ret * size; - Unlock(); return ret; } int CefByteReadHandler::Seek(long offset, int whence) { int rv = -1L; - Lock(); + AutoLock lock_scope(this); switch(whence) { case SEEK_CUR: if(offset_ + offset > size_) @@ -46,23 +45,18 @@ int CefByteReadHandler::Seek(long offset, int whence) rv = 0; break; } - Unlock(); return rv; } long CefByteReadHandler::Tell() { - Lock(); - long rv = offset_; - Unlock(); - return rv; + AutoLock lock_scope(this); + return offset_; } int CefByteReadHandler::Eof() { - Lock(); - int rv = (offset_ >= size_); - Unlock(); - return rv; + AutoLock lock_scope(this); + return (offset_ >= size_); } diff --git a/libcef_dll/wrapper/cef_zip_archive.cc b/libcef_dll/wrapper/cef_zip_archive.cc index e83fdbc55..508750798 100644 --- a/libcef_dll/wrapper/cef_zip_archive.cc +++ b/libcef_dll/wrapper/cef_zip_archive.cc @@ -12,7 +12,7 @@ namespace { -class CefZipFile : public CefThreadSafeBase +class CefZipFile : public CefZipArchive::File { public: CefZipFile(size_t size) : data_(size) {} @@ -35,6 +35,8 @@ public: private: std::vector data_; + + IMPLEMENT_REFCOUNTING(CefZipFile); }; } // namespace diff --git a/libcef_dll/wrapper/libcef_dll_wrapper.cc b/libcef_dll/wrapper/libcef_dll_wrapper.cc index 4f7126072..56837be62 100644 --- a/libcef_dll/wrapper/libcef_dll_wrapper.cc +++ b/libcef_dll/wrapper/libcef_dll_wrapper.cc @@ -10,7 +10,6 @@ #include "libcef_dll/cpptoc/domevent_listener_cpptoc.h" #include "libcef_dll/cpptoc/domvisitor_cpptoc.h" #include "libcef_dll/cpptoc/download_handler_cpptoc.h" -#include "libcef_dll/cpptoc/handler_cpptoc.h" #include "libcef_dll/cpptoc/read_handler_cpptoc.h" #include "libcef_dll/cpptoc/scheme_handler_cpptoc.h" #include "libcef_dll/cpptoc/scheme_handler_factory_cpptoc.h" @@ -35,17 +34,16 @@ #include "libcef_dll/ctocpp/zip_reader_ctocpp.h" -bool CefInitialize(const CefSettings& settings, - const CefBrowserSettings& browser_defaults) +bool CefInitialize(const CefSettings& settings) { - return cef_initialize(&settings, &browser_defaults)?true:false; + return cef_initialize(&settings)?true:false; } void CefShutdown() { cef_shutdown(); -#ifdef _DEBUG +#ifndef NDEBUG // Check that all wrapper objects have been destroyed DCHECK(CefCookieVisitorCppToC::DebugObjCt == 0); DCHECK(CefDOMEventListenerCppToC::DebugObjCt == 0); @@ -72,12 +70,7 @@ void CefShutdown() DCHECK(CefWebURLRequestCToCpp::DebugObjCt == 0); DCHECK(CefXmlReaderCToCpp::DebugObjCt == 0); DCHECK(CefZipReaderCToCpp::DebugObjCt == 0); - - // TODO: This breakpoint may be hit if content is still loading when CEF - // exits. Re-enable the breakpoint if/when CEF stops content loading before - // exit. - //DCHECK(CefHandlerCppToC::DebugObjCt == 0); -#endif // _DEBUG +#endif // !NDEBUG } void CefDoMessageLoopWork() diff --git a/tests/cefclient/binding_test.cpp b/tests/cefclient/binding_test.cpp index 6db249811..c80a74e68 100644 --- a/tests/cefclient/binding_test.cpp +++ b/tests/cefclient/binding_test.cpp @@ -8,7 +8,7 @@ // Implementation of the V8 handler class for the "window.cef_test.Dump" // function. -class ClientV8FunctionHandler : public CefThreadSafeBase +class ClientV8FunctionHandler : public CefV8Handler { public: ClientV8FunctionHandler() {} @@ -122,6 +122,8 @@ public: stream << "\n" << indent_str.c_str() << "]"; } } + + IMPLEMENT_REFCOUNTING(ClientV8FunctionHandler); }; diff --git a/tests/cefclient/cefclient.cpp b/tests/cefclient/cefclient.cpp index 6132710ac..ac2924b06 100644 --- a/tests/cefclient/cefclient.cpp +++ b/tests/cefclient/cefclient.cpp @@ -6,8 +6,8 @@ #include "include/cef_runnable.h" #include "include/cef_wrapper.h" #include "cefclient.h" +#include "client_handler.h" #include "binding_test.h" -#include "download_handler.h" #include "string_util.h" #include "util.h" #include @@ -15,300 +15,6 @@ #include -// ClientHandler::ClientDownloadListener implementation - -void ClientHandler::ClientDownloadListener::NotifyDownloadComplete( - const CefString& fileName) -{ - handler_->SetLastDownloadFile(fileName); - handler_->SendNotification(NOTIFY_DOWNLOAD_COMPLETE); -} - -void ClientHandler::ClientDownloadListener::NotifyDownloadError( - const CefString& fileName) -{ - handler_->SetLastDownloadFile(fileName); - handler_->SendNotification(NOTIFY_DOWNLOAD_ERROR); -} - - -// ClientHandler implementation - -ClientHandler::ClientHandler() - : m_MainHwnd(NULL), - m_BrowserHwnd(NULL), - m_EditHwnd(NULL), - m_BackHwnd(NULL), - m_ForwardHwnd(NULL), - m_StopHwnd(NULL), - m_ReloadHwnd(NULL), - ALLOW_THIS_IN_INITIALIZER_LIST( - m_DownloadListener(new ClientDownloadListener(this))) -{ -} - -ClientHandler::~ClientHandler() -{ -} - -CefHandler::RetVal ClientHandler::HandleAfterCreated( - CefRefPtr browser) -{ - REQUIRE_UI_THREAD(); - - Lock(); - if(!browser->IsPopup()) - { - // We need to keep the main child window, but not popup windows - m_Browser = browser; - m_BrowserHwnd = browser->GetWindowHandle(); - } - Unlock(); - return RV_CONTINUE; -} - - -CefHandler::RetVal ClientHandler::HandleNavStateChange( - CefRefPtr browser, bool canGoBack, bool canGoForward) -{ - REQUIRE_UI_THREAD(); - - SetNavState(canGoBack, canGoForward); - - return RV_CONTINUE; -} - -CefHandler::RetVal ClientHandler::HandleLoadStart(CefRefPtr browser, - CefRefPtr frame) -{ - REQUIRE_UI_THREAD(); - - if(!browser->IsPopup() && frame->IsMain()) - { - // We've just started loading a page - SetLoading(true); - } - return RV_CONTINUE; -} - -CefHandler::RetVal ClientHandler::HandleLoadEnd(CefRefPtr browser, - CefRefPtr frame, int httpStatusCode) -{ - REQUIRE_UI_THREAD(); - - if(!browser->IsPopup() && frame->IsMain()) - { - // We've just finished loading a page - SetLoading(false); - - CefRefPtr visitor = GetDOMVisitor(frame->GetURL()); - if(visitor.get()) - frame->VisitDOM(visitor); - } - return RV_CONTINUE; -} - -CefHandler::RetVal ClientHandler::HandleLoadError(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 RV_HANDLED; -} - -CefHandler::RetVal ClientHandler::HandleDownloadResponse( - CefRefPtr browser, const CefString& mimeType, - const CefString& fileName, int64 contentLength, - CefRefPtr& handler) -{ - REQUIRE_UI_THREAD(); - - // Create the handler for the file download. - handler = CreateDownloadHandler(m_DownloadListener, fileName); - return RV_CONTINUE; -} - -CefHandler::RetVal ClientHandler::HandlePrintHeaderFooter( - CefRefPtr browser, CefRefPtr frame, - 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 RV_CONTINUE; -} - -CefHandler::RetVal ClientHandler::HandleJSBinding(CefRefPtr browser, - CefRefPtr frame, CefRefPtr object) -{ - REQUIRE_UI_THREAD(); - - // Add the V8 bindings. - InitBindingTest(browser, frame, object); - - return RV_HANDLED; -} - -CefHandler::RetVal ClientHandler::HandleBeforeWindowClose( - CefRefPtr browser) -{ - REQUIRE_UI_THREAD(); - - if(m_BrowserHwnd == browser->GetWindowHandle()) - { - // Free the browser pointer so that the browser can be destroyed - m_Browser = NULL; - } - return RV_CONTINUE; -} - -CefHandler::RetVal ClientHandler::HandleConsoleMessage( - CefRefPtr browser, const CefString& message, - const CefString& source, int line) -{ - REQUIRE_UI_THREAD(); - - Lock(); - bool first_message = m_LogFile.empty(); - if(first_message) { - std::stringstream ss; - ss << AppGetWorkingDirectory(); -#ifdef _WIN32 - ss << "\\"; -#else - ss << "/"; -#endif - ss << "console.log"; - m_LogFile = ss.str(); - } - std::string logFile = m_LogFile; - Unlock(); - - 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 RV_HANDLED; -} - -void ClientHandler::SetMainHwnd(CefWindowHandle hwnd) -{ - Lock(); - m_MainHwnd = hwnd; - Unlock(); -} - -void ClientHandler::SetEditHwnd(CefWindowHandle hwnd) -{ - Lock(); - m_EditHwnd = hwnd; - Unlock(); -} - -void ClientHandler::SetButtonHwnds(CefWindowHandle backHwnd, - CefWindowHandle forwardHwnd, - CefWindowHandle reloadHwnd, - CefWindowHandle stopHwnd) -{ - Lock(); - m_BackHwnd = backHwnd; - m_ForwardHwnd = forwardHwnd; - m_ReloadHwnd = reloadHwnd; - m_StopHwnd = stopHwnd; - Unlock(); -} - -std::string ClientHandler::GetLogFile() -{ - Lock(); - std::string str = m_LogFile; - Unlock(); - return str; -} - -void ClientHandler::SetLastDownloadFile(const std::string& fileName) -{ - Lock(); - m_LastDownloadFile = fileName; - Unlock(); -} - -std::string ClientHandler::GetLastDownloadFile() -{ - std::string str; - Lock(); - str = m_LastDownloadFile; - Unlock(); - return str; -} - -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; -} - - -// Global functions - CefRefPtr g_handler; CefRefPtr AppGetBrowser() @@ -438,7 +144,7 @@ void RunXMLHTTPRequestTest(CefRefPtr browser) void RunWebURLRequestTest(CefRefPtr browser) { - class RequestClient : public CefThreadSafeBase + class RequestClient : public CefWebURLRequestClient { public: RequestClient(CefRefPtr browser) : browser_(browser) {} @@ -497,6 +203,8 @@ void RunWebURLRequestTest(CefRefPtr browser) protected: CefRefPtr browser_; std::string buffer_; + + IMPLEMENT_REFCOUNTING(CefWebURLRequestClient); }; CefRefPtr request(CefRequest::CreateRequest()); @@ -509,7 +217,7 @@ void RunWebURLRequestTest(CefRefPtr browser) void RunDOMAccessTest(CefRefPtr browser) { - class Listener : public CefThreadSafeBase + class Listener : public CefDOMEventListener { public: Listener() {} @@ -568,9 +276,11 @@ void RunDOMAccessTest(CefRefPtr browser) ASSERT(text->IsText()); text->SetValue(ss.str()); } + + IMPLEMENT_REFCOUNTING(Listener); }; - class Visitor : public CefThreadSafeBase + class Visitor : public CefDOMVisitor { public: Visitor() {} @@ -581,11 +291,13 @@ void RunDOMAccessTest(CefRefPtr browser) ASSERT(button.get()); button->AddEventListener("click", new Listener(), false); } + + IMPLEMENT_REFCOUNTING(Visitor); }; // The DOM visitor will be called after the path is loaded. - CefRefPtr handler = browser->GetHandler(); - static_cast(handler.get())->AddDOMVisitor( + CefRefPtr client = browser->GetClient(); + static_cast(client.get())->AddDOMVisitor( "http://tests/domaccess", new Visitor()); browser->GetMainFrame()->LoadURL("http://tests/domaccess"); diff --git a/tests/cefclient/cefclient.h b/tests/cefclient/cefclient.h index d803574b8..a8ac1a166 100644 --- a/tests/cefclient/cefclient.h +++ b/tests/cefclient/cefclient.h @@ -1,4 +1,4 @@ -// Copyright (c) 2008 The Chromium Embedded Framework Authors. All rights +// 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. @@ -6,531 +6,6 @@ #define _CEFCLIENT_H #include "include/cef.h" -#include "download_handler.h" -#include "util.h" - -// Define this value to redirect all popup URLs to the main application browser -// window. -//#define TEST_REDIRECT_POPUP_URLS - -// Client implementation of the browser handler class -class ClientHandler : public CefThreadSafeBase -{ -public: - // Implements the DownloadListener interface. - class ClientDownloadListener : public CefThreadSafeBase - { - public: - ClientDownloadListener(ClientHandler* handler) : handler_(handler) {} - - // Called when the download is complete. - virtual void NotifyDownloadComplete(const CefString& fileName); - - // Called if the download fails. - virtual void NotifyDownloadError(const CefString& fileName); - - private: - ClientHandler* handler_; - }; - - ClientHandler(); - virtual ~ClientHandler(); - - // Called on the UI thread before a new window is created. The |parentBrowser| - // parameter will point to the parent browser window, if any. The |popup| - // parameter will be true if the new window is a popup window, in which case - // |popupFeatures| will contain information about the style of popup window - // requested. If you create the window yourself you should populate the window - // handle member of |createInfo| and return RV_HANDLED. Otherwise, return - // RV_CONTINUE and the framework will create the window. By default, a newly - // created window will recieve the same handler as the parent window. To - // change the handler for the new window modify the object that |handler| - // points to. - virtual RetVal HandleBeforeCreated(CefRefPtr parentBrowser, - CefWindowInfo& createInfo, bool popup, - const CefPopupFeatures& popupFeatures, - CefRefPtr& handler, - const CefString& url, - CefBrowserSettings& settings); - - // Called on the UI thread after a new window is created. The return value is - // currently ignored. - virtual RetVal HandleAfterCreated(CefRefPtr browser); - - // Called on the UI thread when a frame's address has changed. The return - // value is currently ignored. - virtual RetVal HandleAddressChange(CefRefPtr browser, - CefRefPtr frame, - const CefString& url); - - // Called on the UI thread when the page title changes. The return value is - // currently ignored. - virtual RetVal HandleTitleChange(CefRefPtr browser, - const CefString& title); - - // Called on the UI thread when the navigation state has changed. The return - // value is currently ignored. - virtual RetVal HandleNavStateChange(CefRefPtr browser, - bool canGoBack, bool canGoForward); - - // Called on the UI thread before browser navigation. The client has an - // opportunity to modify the |request| object if desired. Return RV_HANDLED - // to cancel navigation. - virtual RetVal HandleBeforeBrowse(CefRefPtr browser, - CefRefPtr frame, - CefRefPtr request, - NavType navType, bool isRedirect) - { - REQUIRE_UI_THREAD(); - return RV_CONTINUE; - } - - // Called on the UI thread when the browser begins loading a frame. The - // |frame| value will never be empty -- call the IsMain() method to check if - // this frame is the main frame. Multiple frames may be loading at the same - // time. Sub-frames may start or continue loading after the main frame load - // has ended. This method may not be called for a particular frame if the load - // request for that frame fails. The return value is currently ignored. - virtual RetVal HandleLoadStart(CefRefPtr browser, - CefRefPtr frame); - - // Called on the UI thread when the browser is done loading a frame. The - // |frame| value will never be empty -- call the IsMain() method to check if - // this frame is the main frame. Multiple frames may be loading at the same - // time. Sub-frames may start or continue loading after the main frame load - // has ended. This method will always be called for all frames irrespective of - // whether the request completes successfully. The return value is currently - // ignored. - virtual RetVal HandleLoadEnd(CefRefPtr browser, - CefRefPtr frame, - int httpStatusCode); - - // Called on the UI thread when the browser fails to load a resource. - // |errorCode| is the error code number and |failedUrl| is the URL that failed - // to load. To provide custom error text assign the text to |errorText| and - // return RV_HANDLED. Otherwise, return RV_CONTINUE for the default error - // text. - virtual RetVal HandleLoadError(CefRefPtr browser, - CefRefPtr frame, - ErrorCode errorCode, - const CefString& failedUrl, - CefString& errorText); - - // Called on the IO thread before a resource is loaded. To allow the resource - // to load normally return RV_CONTINUE. To redirect the resource to a new url - // populate the |redirectUrl| value and return RV_CONTINUE. To specify data - // for the resource return a CefStream object in |resourceStream|, set - // |mimeType| to the resource stream's mime type, and return RV_CONTINUE. To - // cancel loading of the resource return RV_HANDLED. Any modifications to - // |request| will be observed. If the URL in |request| is changed and - // |redirectUrl| is also set, the URL in |request| will be used. - virtual RetVal HandleBeforeResourceLoad(CefRefPtr browser, - CefRefPtr request, - CefString& redirectUrl, - CefRefPtr& resourceStream, - CefRefPtr response, - int loadFlags); - - // Called on the IO thread to handle requests for URLs with an unknown - // protocol component. Return RV_HANDLED to indicate that the request should - // succeed because it was externally handled. Set |allow_os_execution| to true - // and return RV_CONTINUE to attempt execution via the registered OS protocol - // handler, if any. If RV_CONTINUE is returned and either |allow_os_execution| - // is false or OS protocol handler execution fails then the request will fail - // with an error condition. - // SECURITY WARNING: YOU SHOULD USE THIS METHOD TO ENFORCE RESTRICTIONS BASED - // ON SCHEME, HOST OR OTHER URL ANALYSIS BEFORE ALLOWING OS EXECUTION. - virtual RetVal HandleProtocolExecution(CefRefPtr browser, - const CefString& url, - bool& allow_os_execution) - { - REQUIRE_IO_THREAD(); - return RV_CONTINUE; - } - - // Called on the UI thread when a server indicates via the - // 'Content-Disposition' header that a response represents a file to download. - // |mimeType| is the mime type for the download, |fileName| is the suggested - // target file name and |contentLength| is either the value of the - // 'Content-Size' header or -1 if no size was provided. Set |handler| to the - // CefDownloadHandler instance that will recieve the file contents. Return - // RV_CONTINUE to download the file or RV_HANDLED to cancel the file download. - virtual RetVal HandleDownloadResponse(CefRefPtr browser, - const CefString& mimeType, - const CefString& fileName, - int64 contentLength, - CefRefPtr& handler); - - // Called on the IO thread when the browser needs credentials from the user. - // |isProxy| indicates whether the host is a proxy server. |host| contains the - // hostname and port number. Set |username| and |password| and return - // RV_HANDLED to handle the request. Return RV_CONTINUE to cancel the request. - virtual RetVal HandleAuthenticationRequest(CefRefPtr browser, - bool isProxy, - const CefString& host, - const CefString& realm, - const CefString& scheme, - CefString& username, - CefString& password) - { - REQUIRE_IO_THREAD(); - return RV_CONTINUE; - } - - // Called on the UI thread before a context menu is displayed. To cancel - // display of the default context menu return RV_HANDLED. - virtual RetVal HandleBeforeMenu(CefRefPtr browser, - const MenuInfo& menuInfo) - { - REQUIRE_UI_THREAD(); - return RV_CONTINUE; - } - - // Called on the UI thread to optionally override the default text for a - // context menu item. |label| contains the default text and may be modified to - // substitute alternate text. The return value is currently ignored. - virtual RetVal HandleGetMenuLabel(CefRefPtr browser, - MenuId menuId, CefString& label) - { - REQUIRE_UI_THREAD(); - return RV_CONTINUE; - } - - // Called on the UI thread when an option is selected from the default context - // menu. Return RV_HANDLED to cancel default handling of the action. - virtual RetVal HandleMenuAction(CefRefPtr browser, - MenuId menuId) - { - REQUIRE_UI_THREAD(); - return RV_CONTINUE; - } - - // Called on the UI thread to allow customization of standard print options - // before the print dialog is displayed. |printOptions| allows specification - // of paper size, orientation and margins. Note that the specified margins may - // be adjusted if they are outside the range supported by the printer. All - // units are in inches. Return RV_CONTINUE to display the default print - // options or RV_HANDLED to display the modified |printOptions|. - virtual RetVal HandlePrintOptions(CefRefPtr browser, - CefPrintOptions& printOptions) - { - REQUIRE_UI_THREAD(); - return RV_CONTINUE; - } - - // Called on the UI thread to format print headers and footers. |printInfo| - // contains platform-specific information about the printer context. |url| is - // the URL if the currently printing page, |title| is the title of the - // currently printing page, |currentPage| is the current page number and - // |maxPages| is the total number of pages. Six default header locations are - // provided by the implementation: top left, top center, top right, bottom - // left, bottom center and bottom right. To use one of these default locations - // just assign a string to the appropriate variable. To draw the header and - // footer yourself return RV_HANDLED. Otherwise, populate the approprate - // variables and return RV_CONTINUE. - virtual RetVal HandlePrintHeaderFooter(CefRefPtr browser, - CefRefPtr frame, - CefPrintInfo& printInfo, - const CefString& url, - const CefString& title, - int currentPage, int maxPages, - CefString& topLeft, - CefString& topCenter, - CefString& topRight, - CefString& bottomLeft, - CefString& bottomCenter, - CefString& bottomRight); - - // Called on the UI thread to run a JS alert message. Return RV_CONTINUE to - // display the default alert or RV_HANDLED if you displayed a custom alert. - virtual RetVal HandleJSAlert(CefRefPtr browser, - CefRefPtr frame, - const CefString& message) - { - REQUIRE_UI_THREAD(); - return RV_CONTINUE; - } - - // Called on the UI thread to run a JS confirm request. Return RV_CONTINUE to - // display the default alert or RV_HANDLED if you displayed a custom alert. If - // you handled the alert set |retval| to true if the user accepted the - // confirmation. - virtual RetVal HandleJSConfirm(CefRefPtr browser, - CefRefPtr frame, - const CefString& message, bool& retval) - { - REQUIRE_UI_THREAD(); - return RV_CONTINUE; - } - - // Called on the UI thread to run a JS prompt request. Return RV_CONTINUE to - // display the default prompt or RV_HANDLED if you displayed a custom prompt. - // If you handled the prompt set |retval| to true if the user accepted the - // prompt and request and |result| to the resulting value. - virtual RetVal HandleJSPrompt(CefRefPtr browser, - CefRefPtr frame, - const CefString& message, - const CefString& defaultValue, - bool& retval, - CefString& result) - { - REQUIRE_UI_THREAD(); - return RV_CONTINUE; - } - - // Called on the UI thread for adding values to a frame's JavaScript 'window' - // object. The return value is currently ignored. - virtual RetVal HandleJSBinding(CefRefPtr browser, - CefRefPtr frame, - CefRefPtr object); - - // Called on the UI thread just before a window is closed. The return value is - // currently ignored. - virtual RetVal HandleBeforeWindowClose(CefRefPtr browser); - - // Called on the UI thread when the browser component is about to loose focus. - // For instance, if focus was on the last HTML element and the user pressed - // the TAB key. The return value is currently ignored. - virtual RetVal HandleTakeFocus(CefRefPtr browser, bool reverse) - { - REQUIRE_UI_THREAD(); - return RV_CONTINUE; - } - - // Called on the UI thread when the browser component is requesting focus. - // |isWidget| will be true if the focus is requested for a child widget of the - // browser window. Return RV_CONTINUE to allow the focus to be set or - // RV_HANDLED to cancel setting the focus. - virtual RetVal HandleSetFocus(CefRefPtr browser, - bool isWidget) - { - REQUIRE_UI_THREAD(); - return RV_CONTINUE; - } - - // Called on the UI thread when the browser component receives a keyboard - // event. |type| is the type of keyboard event, |code| is the windows scan- - // code for the event, |modifiers| is a set of bit-flags describing any - // pressed modifier keys and |isSystemKey| is true if Windows considers this a - // 'system key' message (see - // http://msdn.microsoft.com/en-us/library/ms646286(VS.85).aspx). Return - // RV_HANDLED if the keyboard event was handled or RV_CONTINUE to allow the - // browser component to handle the event. - virtual RetVal HandleKeyEvent(CefRefPtr browser, - KeyEventType type, - int code, - int modifiers, - bool isSystemKey) - { - REQUIRE_UI_THREAD(); - return RV_CONTINUE; - } - - // Called on the UI thread when the browser is about to display a tooltip. - // |text| contains the text that will be displayed in the tooltip. To handle - // the display of the tooltip yourself return RV_HANDLED. Otherwise, you can - // optionally modify |text| and then return RV_CONTINUE to allow the browser - // to display the tooltip. - virtual RetVal HandleTooltip(CefRefPtr browser, - CefString& text) - { - REQUIRE_UI_THREAD(); - return RV_CONTINUE; - } - - // Called on the UI thread when the browser has a status message. |text| - // contains the text that will be displayed in the status message and |type| - // indicates the status message type. The return value is currently ignored. - virtual RetVal HandleStatus(CefRefPtr browser, - const CefString& text, StatusType type) - { - REQUIRE_UI_THREAD(); - return RV_CONTINUE; - } - - // Called on the UI thread to display a console message. Return RV_HANDLED to - // stop the message from being output to the console. - virtual RetVal HandleConsoleMessage(CefRefPtr browser, - const CefString& message, - const CefString& source, int line); - - // Called on the UI thread to report find results returned by - // CefBrowser::Find(). |identifer| is the identifier passed to - // CefBrowser::Find(), |count| is the number of matches currently identified, - // |selectionRect| is the location of where the match was found (in window - // coordinates), |activeMatchOrdinal| is the current position in the search - // results, and |finalUpdate| is true if this is the last find notification. - // The return value is currently ignored. - virtual RetVal HandleFindResult(CefRefPtr browser, - int identifier, int count, - const CefRect& selectionRect, - int activeMatchOrdinal, bool finalUpdate) - { - REQUIRE_UI_THREAD(); - return RV_CONTINUE; - } - - // Called on the UI thread to retrieve either the simulated screen rectangle - // if |screen| is true or the view rectangle if |screen| is false. The view - // rectangle is relative to the screen coordinates. This method is only called - // if window rendering has been disabled. Return RV_CONTINUE if the rectangle - // was provided. - virtual RetVal HandleGetRect(CefRefPtr browser, bool screen, - CefRect& rect) - { - // Only called when rendering off-screen. - ASSERT(false); - return RV_CONTINUE; - } - - // Called on the UI thread retrieve the translation from view coordinates to - // actual screen coordinates. This method is only called if window rendering - // has been disabled. Return RV_CONTINUE if the screen coordinates were - // provided. - virtual RetVal HandleGetScreenPoint(CefRefPtr browser, - int viewX, int viewY, int& screenX, - int& screenY) - { - // Only called when rendering off-screen. - ASSERT(false); - return RV_CONTINUE; - } - - // Called on the UI thread when the browser wants to show, hide, resize or - // move the popup. If |show| is true and |rect| is zero size then the popup - // should be shown. If |show| is true and |rect| is non-zero size then |rect| - // represents the popup location in view coordinates. If |show| is false - // then the popup should be hidden. This method is only called if window - // rendering has been disabled. The return value is currently ignored. - virtual RetVal HandlePopupChange(CefRefPtr browser, bool show, - const CefRect& rect) - { - // Only called when rendering off-screen. - ASSERT(false); - return RV_CONTINUE; - } - - // Called when an element should be painted. |type| indicates whether the - // element is the view or the popup. |buffer| contains the pixel data for the - // whole image. |dirtyRect| indicates the portion of the image that has been - // repainted. On Windows |buffer| will be width*height*4 bytes in size and - // represents a BGRA image with an upper-left origin. This method is only - // called if window rendering has been disabled. The return value is currently - // ignored. - virtual RetVal HandlePaint(CefRefPtr browser, - PaintElementType type, const CefRect& dirtyRect, - const void* buffer) - { - // Only called when rendering off-screen. - ASSERT(false); - return RV_CONTINUE; - } - - // Called when the browser window's cursor has changed. This method is only - // called if window rendering has been disabled. The return value is currently - // ignored. - virtual RetVal HandleCursorChange(CefRefPtr browser, - CefCursorHandle cursor) - { - // Only called when rendering off-screen. - ASSERT(false); - return RV_CONTINUE; - } - - // Retrieve the current navigation state flags - 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(); - - void SetLastDownloadFile(const std::string& fileName); - std::string GetLastDownloadFile(); - - // 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); - - // Send a notification to the application. Notifications should not block the - // caller. - enum NotificationType - { - NOTIFY_CONSOLE_MESSAGE, - NOTIFY_DOWNLOAD_COMPLETE, - NOTIFY_DOWNLOAD_ERROR, - }; - void SendNotification(NotificationType type); - -protected: - virtual void SetLoading(bool isLoading); - virtual 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; - - std::string m_LogFile; - - // Support for downloading files. - CefRefPtr m_DownloadListener; - std::string m_LastDownloadFile; - - typedef std::map > DOMVisitorMap; - DOMVisitorMap m_DOMVisitors; -}; - -// Handler for popup windows that loads the request in an existing browser -// window. -class ClientPopupHandler : public ClientHandler -{ -public: - ClientPopupHandler(CefRefPtr parentBrowser) - : m_ParentBrowser(parentBrowser) - { - } - virtual ~ClientPopupHandler() - { - } - - virtual RetVal HandleBeforeBrowse(CefRefPtr browser, - CefRefPtr frame, - CefRefPtr request, - NavType navType, bool isRedirect) - { - REQUIRE_UI_THREAD(); - - if (m_ParentBrowser.get()) { - m_ParentBrowser->GetMainFrame()->LoadRequest(request); - browser->CloseBrowser(); - m_ParentBrowser = NULL; - } - return RV_HANDLED; - } - -protected: - CefRefPtr m_ParentBrowser; -}; // Returns the main browser window instance. CefRefPtr AppGetBrowser(); diff --git a/tests/cefclient/cefclient_mac.mm b/tests/cefclient/cefclient_mac.mm index e86a4c18b..b889971a4 100644 --- a/tests/cefclient/cefclient_mac.mm +++ b/tests/cefclient/cefclient_mac.mm @@ -4,9 +4,9 @@ // found in the LICENSE file. #include "include/cef.h" -#include "include/cef_wrapper.h" #include "cefclient.h" #include "binding_test.h" +#include "client_handler.h" #include "extension_test.h" #include "resource_util.h" #include "scheme_test.h" @@ -324,9 +324,10 @@ NSButton* MakeButton(NSRect* rect, NSString* title, NSView* parent) { // Create the browser view. CefWindowInfo window_info; + CefBrowserSettings settings; window_info.SetAsChild(contentView, 0, 0, kWindowWidth, kWindowHeight); - CefBrowser::CreateBrowser(window_info, false, g_handler.get(), - "http://www.google.com"); + CefBrowser::CreateBrowser(window_info, g_handler.get(), + "http://www.google.com", settings); // Show the window. [mainWnd makeKeyAndOrderFront: nil]; @@ -459,8 +460,7 @@ int main(int argc, char* argv[]) // Initialize CEF. This will also create the NSApplication instance. CefSettings settings; - CefBrowserSettings browserDefaults; - CefInitialize(settings, browserDefaults); + CefInitialize(settings); // Initialize tests. InitExtensionTest(); @@ -479,135 +479,6 @@ int main(int argc, char* argv[]) } -// ClientHandler implementation - -CefHandler::RetVal ClientHandler::HandleBeforeCreated( - CefRefPtr parentBrowser, CefWindowInfo& createInfo, bool popup, - const CefPopupFeatures& popupFeatures, CefRefPtr& handler, - const CefString& url, CefBrowserSettings& settings) -{ - REQUIRE_UI_THREAD(); - -#ifdef TEST_REDIRECT_POPUP_URLS - if(popup) { - std::string urlStr = url; - if(urlStr.find("resources/inspector/devtools.html") == std::string::npos) { - // Show all popup windows excluding DevTools in the current window. - createInfo.m_bHidden = true; - handler = new ClientPopupHandler(m_Browser); - } - } -#endif // TEST_REDIRECT_POPUP_URLS - - return RV_CONTINUE; -} - -CefHandler::RetVal ClientHandler::HandleAddressChange( - CefRefPtr browser, CefRefPtr frame, - const CefString& url) -{ - REQUIRE_UI_THREAD(); - - if(m_BrowserHwnd == browser->GetWindowHandle() && frame->IsMain()) - { - // Set the edit window text - NSTextField* textField = (NSTextField*)m_EditHwnd; - std::string urlStr(url); - NSString* str = [NSString stringWithUTF8String:urlStr.c_str()]; - [textField setStringValue:str]; - } - return RV_CONTINUE; -} - -CefHandler::RetVal ClientHandler::HandleTitleChange( - CefRefPtr browser, const CefString& title) -{ - REQUIRE_UI_THREAD(); - - // Set the frame window title bar - NSView* view = (NSView*)browser->GetWindowHandle(); - NSWindow* window = [view window]; - std::string titleStr(title); - NSString* str = [NSString stringWithUTF8String:titleStr.c_str()]; - [window setTitle:str]; - return RV_CONTINUE; -} - -CefHandler::RetVal ClientHandler::HandleBeforeResourceLoad( - CefRefPtr browser, CefRefPtr request, - CefString& redirectUrl, CefRefPtr& resourceStream, - CefRefPtr response, int loadFlags) -{ - REQUIRE_IO_THREAD(); - - std::string url = request->GetURL(); - if(url == "http://tests/request") { - // Show the request contents - std::string dump; - DumpRequestContents(request, dump); - resourceStream = CefStreamReader::CreateForData( - (void*)dump.c_str(), dump.size()); - response->SetMimeType("text/plain"); - response->SetStatus(200); - } else if (strstr(url.c_str(), "/ps_logo2.png") != NULL) { - // Any time we find "ps_logo2.png" in the URL substitute in our own image - resourceStream = GetBinaryResourceReader("logo.png"); - response->SetMimeType("image/png"); - response->SetStatus(200); - } else if(url == "http://tests/localstorage") { - // Show the localstorage contents - resourceStream = GetBinaryResourceReader("localstorage.html"); - response->SetMimeType("text/html"); - response->SetStatus(200); - } else if(url == "http://tests/xmlhttprequest") { - // Show the xmlhttprequest HTML contents - resourceStream = GetBinaryResourceReader("xmlhttprequest.html"); - response->SetMimeType("text/html"); - response->SetStatus(200); - } else if(url == "http://tests/domaccess") { - // Show the domaccess HTML contents - resourceStream = GetBinaryResourceReader("domaccess.html"); - response->SetMimeType("text/html"); - response->SetStatus(200); - } - - return RV_CONTINUE; -} - -void ClientHandler::SendNotification(NotificationType type) -{ - SEL sel = nil; - switch(type) { - case NOTIFY_CONSOLE_MESSAGE: - sel = @selector(notifyConsoleMessage:); - break; - case NOTIFY_DOWNLOAD_COMPLETE: - sel = @selector(notifyDownloadComplete:); - break; - case NOTIFY_DOWNLOAD_ERROR: - sel = @selector(notifyDownloadError:); - break; - } - - if(sel == nil) - return; - - NSWindow* window = [g_handler->GetMainHwnd() window]; - NSObject* delegate = [window delegate]; - [delegate performSelectorOnMainThread:sel withObject:nil waitUntilDone:NO]; -} - -void ClientHandler::SetLoading(bool isLoading) -{ - // TODO(port): Change button status. -} - -void ClientHandler::SetNavState(bool canGoBack, bool canGoForward) -{ - // TODO(port): Change button status. -} - - // Global functions std::string AppGetWorkingDirectory() diff --git a/tests/cefclient/cefclient_win.cpp b/tests/cefclient/cefclient_win.cpp index dccddbfa0..f612a2cb8 100644 --- a/tests/cefclient/cefclient_win.cpp +++ b/tests/cefclient/cefclient_win.cpp @@ -3,14 +3,13 @@ // can be found in the LICENSE file. #include "include/cef.h" -#include "include/cef_wrapper.h" #include "cefclient.h" #include "binding_test.h" +#include "client_handler.h" #include "extension_test.h" #include "osrplugin_test.h" #include "plugin_test.h" #include "resource.h" -#include "resource_util.h" #include "scheme_test.h" #include "string_util.h" #include "uiplugin_test.h" @@ -45,7 +44,7 @@ INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM); // The global ClientHandler reference. extern CefRefPtr g_handler; -#ifdef _WIN32 +#if defined(OS_WIN) // Add Common Controls to the application manifest because it's required to // support the default tooltip implementation. #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") @@ -65,12 +64,11 @@ int APIENTRY wWinMain(HINSTANCE hInstance, szWorkingDir[0] = 0; CefSettings settings; - CefBrowserSettings browserDefaults; // Specify a cache path value. //CefString(&settings.cache_path).FromASCII("c:\\temp\\cache"); -#ifndef _DEBUG +#ifdef NDEBUG // Only log error messages and higher in release build. settings.log_severity = LOGSEVERITY_ERROR; #endif @@ -84,7 +82,7 @@ int APIENTRY wWinMain(HINSTANCE hInstance, settings.multi_threaded_message_loop = true; #endif - CefInitialize(settings, browserDefaults); + CefInitialize(settings); // Register the internal client plugin. InitPluginTest(); @@ -368,14 +366,15 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) rect.top += URLBAR_HEIGHT; CefWindowInfo info; + CefBrowserSettings settings; // Initialize window info to the defaults for a child window info.SetAsChild(hWnd, rect); // Creat the new child child browser window - CefBrowser::CreateBrowser(info, false, - static_cast >(g_handler), - "http://www.google.com"); + CefBrowser::CreateBrowser(info, + static_cast >(g_handler), + "http://www.google.com", settings); } return 0; @@ -639,149 +638,6 @@ INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) } -// ClientHandler implementation - -CefHandler::RetVal ClientHandler::HandleBeforeCreated( - CefRefPtr parentBrowser, CefWindowInfo& createInfo, bool popup, - const CefPopupFeatures& popupFeatures, CefRefPtr& handler, - const CefString& url, CefBrowserSettings& settings) -{ - REQUIRE_UI_THREAD(); - -#ifdef TEST_REDIRECT_POPUP_URLS - if(popup) { - std::string urlStr = url; - if(urlStr.find("resources/inspector/devtools.html") == std::string::npos) { - // Show all popup windows excluding DevTools in the current window. - createInfo.m_dwStyle &= ~WS_VISIBLE; - handler = new ClientPopupHandler(m_Browser); - } - } -#endif // TEST_REDIRECT_POPUP_URLS - - return RV_CONTINUE; -} - -CefHandler::RetVal ClientHandler::HandleAddressChange( - CefRefPtr browser, CefRefPtr frame, - const CefString& url) -{ - REQUIRE_UI_THREAD(); - - if(m_BrowserHwnd == browser->GetWindowHandle() && frame->IsMain()) - { - // Set the edit window text - SetWindowText(m_EditHwnd, std::wstring(url).c_str()); - } - return RV_CONTINUE; -} - -CefHandler::RetVal ClientHandler::HandleTitleChange( - CefRefPtr browser, const CefString& title) -{ - REQUIRE_UI_THREAD(); - - // Set the frame window title bar - CefWindowHandle hwnd = browser->GetWindowHandle(); - if(!browser->IsPopup()) - { - // The frame window will be the parent of the browser window - hwnd = GetParent(hwnd); - } - SetWindowText(hwnd, std::wstring(title).c_str()); - return RV_CONTINUE; -} - -CefHandler::RetVal ClientHandler::HandleBeforeResourceLoad( - CefRefPtr browser, CefRefPtr request, - CefString& redirectUrl, CefRefPtr& resourceStream, - CefRefPtr response, int loadFlags) -{ - REQUIRE_IO_THREAD(); - - std::string url = request->GetURL(); - if(url == "http://tests/request") { - // Show the request contents - std::string dump; - DumpRequestContents(request, dump); - resourceStream = - CefStreamReader::CreateForData((void*)dump.c_str(), dump.size()); - response->SetMimeType("text/plain"); - response->SetStatus(200); - } else if(strstr(url.c_str(), "/ps_logo2.png") != NULL) { - // Any time we find "ps_logo2.png" in the URL substitute in our own image - resourceStream = GetBinaryResourceReader(IDS_LOGO); - response->SetMimeType("image/png"); - response->SetStatus(200); - } else if(url == "http://tests/uiapp") { - // Show the uiapp contents - resourceStream = GetBinaryResourceReader(IDS_UIPLUGIN); - response->SetMimeType("text/html"); - response->SetStatus(200); - } else if(url == "http://tests/osrapp") { - // Show the osrapp contents - resourceStream = GetBinaryResourceReader(IDS_OSRPLUGIN); - response->SetMimeType("text/html"); - response->SetStatus(200); - } else if(url == "http://tests/localstorage") { - // Show the localstorage contents - resourceStream = GetBinaryResourceReader(IDS_LOCALSTORAGE); - response->SetMimeType("text/html"); - response->SetStatus(200); - } else if(url == "http://tests/xmlhttprequest") { - // Show the xmlhttprequest HTML contents - resourceStream = GetBinaryResourceReader(IDS_XMLHTTPREQUEST); - response->SetMimeType("text/html"); - response->SetStatus(200); - } else if(url == "http://tests/domaccess") { - // Show the domaccess HTML contents - resourceStream = GetBinaryResourceReader(IDS_DOMACCESS); - response->SetMimeType("text/html"); - response->SetStatus(200); - } else if(strstr(url.c_str(), "/logoball.png") != NULL) { - // Load the "logoball.png" image resource. - resourceStream = GetBinaryResourceReader(IDS_LOGOBALL); - response->SetMimeType("image/png"); - response->SetStatus(200); - } - return RV_CONTINUE; -} - -void ClientHandler::SendNotification(NotificationType type) -{ - UINT id; - switch(type) - { - case NOTIFY_CONSOLE_MESSAGE: - id = ID_WARN_CONSOLEMESSAGE; - break; - case NOTIFY_DOWNLOAD_COMPLETE: - id = ID_WARN_DOWNLOADCOMPLETE; - break; - case NOTIFY_DOWNLOAD_ERROR: - id = ID_WARN_DOWNLOADERROR; - break; - default: - return; - } - PostMessage(m_MainHwnd, WM_COMMAND, id, 0); -} - -void ClientHandler::SetLoading(bool isLoading) -{ - ASSERT(m_EditHwnd != NULL && m_ReloadHwnd != NULL && m_StopHwnd != NULL); - EnableWindow(m_EditHwnd, TRUE); - EnableWindow(m_ReloadHwnd, !isLoading); - EnableWindow(m_StopHwnd, isLoading); -} - -void ClientHandler::SetNavState(bool canGoBack, bool canGoForward) -{ - ASSERT(m_BackHwnd != NULL && m_ForwardHwnd != NULL); - EnableWindow(m_BackHwnd, canGoBack); - EnableWindow(m_ForwardHwnd, canGoForward); -} - // Global functions std::string AppGetWorkingDirectory() diff --git a/tests/cefclient/client_handler.cpp b/tests/cefclient/client_handler.cpp new file mode 100644 index 000000000..e4fb2b9d7 --- /dev/null +++ b/tests/cefclient/client_handler.cpp @@ -0,0 +1,290 @@ +// 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/cef.h" +#include "client_handler.h" +#include "binding_test.h" +#include "cefclient.h" +#include "download_handler.h" +#include "string_util.h" +#include +#include +#include + + +ClientHandler::ClientHandler() + : m_MainHwnd(NULL), + m_BrowserHwnd(NULL), + m_EditHwnd(NULL), + m_BackHwnd(NULL), + m_ForwardHwnd(NULL), + m_StopHwnd(NULL), + m_ReloadHwnd(NULL) +{ +} + +ClientHandler::~ClientHandler() +{ +} + + +void ClientHandler::OnAfterCreated(CefRefPtr browser) +{ + REQUIRE_UI_THREAD(); + + AutoLock lock_scope(this); + if(!browser->IsPopup()) + { + // We need to keep the main child window, but not popup windows + m_Browser = browser; + m_BrowserHwnd = browser->GetWindowHandle(); + } +} + +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(!browser->IsPopup() && frame->IsMain()) { + // We've just started loading a page + SetLoading(true); + } +} + +void ClientHandler::OnLoadEnd(CefRefPtr browser, + CefRefPtr frame, + int httpStatusCode) +{ + REQUIRE_UI_THREAD(); + + if(!browser->IsPopup() && 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; +} + +bool ClientHandler::GetDownloadHandler(CefRefPtr browser, + const CefString& mimeType, + const CefString& fileName, + int64 contentLength, + CefRefPtr& handler) +{ + REQUIRE_UI_THREAD(); + + // Create the handler for the file download. + handler = CreateDownloadHandler(this, fileName); + return true; +} + +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; +} + +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::OnJSBinding(CefRefPtr browser, + CefRefPtr frame, + CefRefPtr object) +{ + REQUIRE_UI_THREAD(); + + // Add the V8 bindings. + InitBindingTest(browser, frame, object); +} + +void ClientHandler::NotifyDownloadComplete(const CefString& fileName) +{ + SetLastDownloadFile(fileName); + SendNotification(NOTIFY_DOWNLOAD_COMPLETE); +} + +void ClientHandler::NotifyDownloadError(const CefString& fileName) +{ + SetLastDownloadFile(fileName); + SendNotification(NOTIFY_DOWNLOAD_ERROR); +} + +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::SetLastDownloadFile(const std::string& fileName) +{ + AutoLock lock_scope(this); + m_LastDownloadFile = fileName; +} + +std::string ClientHandler::GetLastDownloadFile() +{ + AutoLock lock_scope(this); + return m_LastDownloadFile; +} + +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/tests/cefclient/client_handler.h b/tests/cefclient/client_handler.h new file mode 100644 index 000000000..7bda7369b --- /dev/null +++ b/tests/cefclient/client_handler.h @@ -0,0 +1,188 @@ +// 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 _CLIENT_HANDLER_H +#define _CLIENT_HANDLER_H + +#include "include/cef.h" +#include "download_handler.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 CefRequestHandler, + public CefDisplayHandler, + public CefPrintHandler, + public CefJSBindingHandler, + public DownloadListener +{ +public: + ClientHandler(); + virtual ~ClientHandler(); + + // CefClient methods + virtual CefRefPtr GetLifeSpanHandler() OVERRIDE + { return this; } + virtual CefRefPtr GetLoadHandler() OVERRIDE + { return this; } + virtual CefRefPtr GetRequestHandler() OVERRIDE + { return this; } + virtual CefRefPtr GetDisplayHandler() OVERRIDE + { return this; } + virtual CefRefPtr GetPrintHandler() OVERRIDE + { return this; } + virtual CefRefPtr GetJSBindingHandler() 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 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; + + // CefRequestHandler methods + virtual bool OnBeforeResourceLoad(CefRefPtr browser, + CefRefPtr request, + CefString& redirectUrl, + CefRefPtr& resourceStream, + CefRefPtr response, + int loadFlags) OVERRIDE; + virtual bool GetDownloadHandler(CefRefPtr browser, + const CefString& mimeType, + const CefString& fileName, + int64 contentLength, + CefRefPtr& handler) + 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; + + // 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; + + // CefJSBindingHandler methods + virtual void OnJSBinding(CefRefPtr browser, + CefRefPtr frame, + CefRefPtr object) OVERRIDE; + + // DownloadListener methods + virtual void NotifyDownloadComplete(const CefString& fileName) OVERRIDE; + virtual void NotifyDownloadError(const CefString& fileName) 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(); + + void SetLastDownloadFile(const std::string& fileName); + std::string GetLastDownloadFile(); + + // 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); + + // Send a notification to the application. Notifications should not block the + // caller. + enum NotificationType + { + NOTIFY_CONSOLE_MESSAGE, + NOTIFY_DOWNLOAD_COMPLETE, + NOTIFY_DOWNLOAD_ERROR, + }; + void SendNotification(NotificationType type); + +protected: + virtual void SetLoading(bool isLoading); + virtual 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 downloading files. + std::string m_LastDownloadFile; + + // Support for DOM visitors. + typedef std::map > DOMVisitorMap; + DOMVisitorMap m_DOMVisitors; + + // Include the default reference counting implementation. + IMPLEMENT_REFCOUNTING(ClientHandler); + // Include the default locking implementation. + IMPLEMENT_LOCKING(ClientHandler); +}; + +#endif // _CLIENT_HANDLER_H diff --git a/tests/cefclient/client_handler_mac.mm b/tests/cefclient/client_handler_mac.mm new file mode 100644 index 000000000..6eb30d7f6 --- /dev/null +++ b/tests/cefclient/client_handler_mac.mm @@ -0,0 +1,142 @@ +// 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/cef.h" +#include "include/cef_wrapper.h" +#include "client_handler.h" +#include "resource_util.h" +#include "string_util.h" +#import + +#ifdef TEST_REDIRECT_POPUP_URLS +#include "client_popup_handler.h" +#endif + +// ClientHandler::ClientLifeSpanHandler implementation + +bool ClientHandler::OnBeforePopup(CefRefPtr parentBrowser, + const CefPopupFeatures& popupFeatures, + CefWindowInfo& windowInfo, + const CefString& url, + CefRefPtr& client, + CefBrowserSettings& settings) +{ + REQUIRE_UI_THREAD(); + +#ifdef TEST_REDIRECT_POPUP_URLS + std::string urlStr = url; + if(urlStr.find("resources/inspector/devtools.html") == std::string::npos) { + // Show all popup windows excluding DevTools in the current window. + windowInfo.m_bHidden = true; + client = new ClientPopupHandler(m_Browser); + } +#endif // TEST_REDIRECT_POPUP_URLS + + return false; +} + +bool ClientHandler::OnBeforeResourceLoad(CefRefPtr browser, + CefRefPtr request, + CefString& redirectUrl, + CefRefPtr& resourceStream, + CefRefPtr response, + int loadFlags) +{ + REQUIRE_IO_THREAD(); + + std::string url = request->GetURL(); + if(url == "http://tests/request") { + // Show the request contents + std::string dump; + DumpRequestContents(request, dump); + resourceStream = CefStreamReader::CreateForData( + (void*)dump.c_str(), dump.size()); + response->SetMimeType("text/plain"); + response->SetStatus(200); + } else if (strstr(url.c_str(), "/ps_logo2.png") != NULL) { + // Any time we find "ps_logo2.png" in the URL substitute in our own image + resourceStream = GetBinaryResourceReader("logo.png"); + response->SetMimeType("image/png"); + response->SetStatus(200); + } else if(url == "http://tests/localstorage") { + // Show the localstorage contents + resourceStream = GetBinaryResourceReader("localstorage.html"); + response->SetMimeType("text/html"); + response->SetStatus(200); + } else if(url == "http://tests/xmlhttprequest") { + // Show the xmlhttprequest HTML contents + resourceStream = GetBinaryResourceReader("xmlhttprequest.html"); + response->SetMimeType("text/html"); + response->SetStatus(200); + } else if(url == "http://tests/domaccess") { + // Show the domaccess HTML contents + resourceStream = GetBinaryResourceReader("domaccess.html"); + response->SetMimeType("text/html"); + response->SetStatus(200); + } + + return false; +} + +void ClientHandler::OnAddressChange(CefRefPtr browser, + CefRefPtr frame, + const CefString& url) +{ + REQUIRE_UI_THREAD(); + + ifm_BrowserHwnd == browser->GetWindowHandle() && frame->IsMain()) + { + // Set the edit window text + NSTextField* textField = (NSTextField*)m_EditHwnd; + std::string urlStr(url); + NSString* str = [NSString stringWithUTF8String:urlStr.c_str()]; + [textField setStringValue:str]; + } +} + +void ClientHandler::OnTitleChange(CefRefPtr browser, + const CefString& title) +{ + REQUIRE_UI_THREAD(); + + // Set the frame window title bar + NSView* view = (NSView*)browser->GetWindowHandle(); + NSWindow* window = [view window]; + std::string titleStr(title); + NSString* str = [NSString stringWithUTF8String:titleStr.c_str()]; + [window setTitle:str]; +} + +void ClientHandler::SendNotification(NotificationType type) +{ + SEL sel = nil; + switch(type) { + case NOTIFY_CONSOLE_MESSAGE: + sel = @selector(notifyConsoleMessage:); + break; + case NOTIFY_DOWNLOAD_COMPLETE: + sel = @selector(notifyDownloadComplete:); + break; + case NOTIFY_DOWNLOAD_ERROR: + sel = @selector(notifyDownloadError:); + break; + } + + if(sel == nil) + return; + + NSWindow* window = [AppGetMainHwnd() window]; + NSObject* delegate = [window delegate]; + [delegate performSelectorOnMainThread:sel withObject:nil waitUntilDone:NO]; +} + +void ClientHandler::SetLoading(bool isLoading) +{ + // TODO(port): Change button status. +} + +void ClientHandler::SetNavState(bool canGoBack, bool canGoForward) +{ + // TODO(port): Change button status. +} diff --git a/tests/cefclient/client_handler_win.cpp b/tests/cefclient/client_handler_win.cpp new file mode 100644 index 000000000..0247e68d0 --- /dev/null +++ b/tests/cefclient/client_handler_win.cpp @@ -0,0 +1,156 @@ +// 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/cef.h" +#include "include/cef_wrapper.h" +#include "client_handler.h" +#include "resource.h" +#include "resource_util.h" +#include "string_util.h" + +#ifdef TEST_REDIRECT_POPUP_URLS +#include "client_popup_handler.h" +#endif + +bool ClientHandler::OnBeforePopup(CefRefPtr parentBrowser, + const CefPopupFeatures& popupFeatures, + CefWindowInfo& windowInfo, + const CefString& url, + CefRefPtr& client, + CefBrowserSettings& settings) +{ + REQUIRE_UI_THREAD(); + +#ifdef TEST_REDIRECT_POPUP_URLS + std::string urlStr = url; + if(urlStr.find("resources/inspector/devtools.html") == std::string::npos) { + // Show all popup windows excluding DevTools in the current window. + windowInfo.m_dwStyle &= ~WS_VISIBLE; + client = new ClientPopupHandler(m_Browser); + } +#endif // TEST_REDIRECT_POPUP_URLS + + return false; +} + +bool ClientHandler::OnBeforeResourceLoad(CefRefPtr browser, + CefRefPtr request, + CefString& redirectUrl, + CefRefPtr& resourceStream, + CefRefPtr response, + int loadFlags) +{ + REQUIRE_IO_THREAD(); + + std::string url = request->GetURL(); + if(url == "http://tests/request") { + // Show the request contents + std::string dump; + DumpRequestContents(request, dump); + resourceStream = + CefStreamReader::CreateForData((void*)dump.c_str(), dump.size()); + response->SetMimeType("text/plain"); + response->SetStatus(200); + } else if(strstr(url.c_str(), "/ps_logo2.png") != NULL) { + // Any time we find "ps_logo2.png" in the URL substitute in our own image + resourceStream = GetBinaryResourceReader(IDS_LOGO); + response->SetMimeType("image/png"); + response->SetStatus(200); + } else if(url == "http://tests/uiapp") { + // Show the uiapp contents + resourceStream = GetBinaryResourceReader(IDS_UIPLUGIN); + response->SetMimeType("text/html"); + response->SetStatus(200); + } else if(url == "http://tests/osrapp") { + // Show the osrapp contents + resourceStream = GetBinaryResourceReader(IDS_OSRPLUGIN); + response->SetMimeType("text/html"); + response->SetStatus(200); + } else if(url == "http://tests/localstorage") { + // Show the localstorage contents + resourceStream = GetBinaryResourceReader(IDS_LOCALSTORAGE); + response->SetMimeType("text/html"); + response->SetStatus(200); + } else if(url == "http://tests/xmlhttprequest") { + // Show the xmlhttprequest HTML contents + resourceStream = GetBinaryResourceReader(IDS_XMLHTTPREQUEST); + response->SetMimeType("text/html"); + response->SetStatus(200); + } else if(url == "http://tests/domaccess") { + // Show the domaccess HTML contents + resourceStream = GetBinaryResourceReader(IDS_DOMACCESS); + response->SetMimeType("text/html"); + response->SetStatus(200); + } else if(strstr(url.c_str(), "/logoball.png") != NULL) { + // Load the "logoball.png" image resource. + resourceStream = GetBinaryResourceReader(IDS_LOGOBALL); + response->SetMimeType("image/png"); + response->SetStatus(200); + } + + return false; +} + +void ClientHandler::OnAddressChange(CefRefPtr browser, + CefRefPtr frame, + const CefString& url) +{ + REQUIRE_UI_THREAD(); + + if(m_BrowserHwnd == browser->GetWindowHandle() && frame->IsMain()) + { + // Set the edit window text + SetWindowText(m_EditHwnd, std::wstring(url).c_str()); + } +} + +void ClientHandler::OnTitleChange(CefRefPtr browser, + const CefString& title) +{ + REQUIRE_UI_THREAD(); + + // Set the frame window title bar + CefWindowHandle hwnd = browser->GetWindowHandle(); + if(!browser->IsPopup()) + { + // The frame window will be the parent of the browser window + hwnd = GetParent(hwnd); + } + SetWindowText(hwnd, std::wstring(title).c_str()); +} + +void ClientHandler::SendNotification(NotificationType type) +{ + UINT id; + switch(type) + { + case NOTIFY_CONSOLE_MESSAGE: + id = ID_WARN_CONSOLEMESSAGE; + break; + case NOTIFY_DOWNLOAD_COMPLETE: + id = ID_WARN_DOWNLOADCOMPLETE; + break; + case NOTIFY_DOWNLOAD_ERROR: + id = ID_WARN_DOWNLOADERROR; + break; + default: + return; + } + PostMessage(m_MainHwnd, WM_COMMAND, id, 0); +} + +void ClientHandler::SetLoading(bool isLoading) +{ + ASSERT(m_EditHwnd != NULL && m_ReloadHwnd != NULL && m_StopHwnd != NULL); + EnableWindow(m_EditHwnd, TRUE); + EnableWindow(m_ReloadHwnd, !isLoading); + EnableWindow(m_StopHwnd, isLoading); +} + +void ClientHandler::SetNavState(bool canGoBack, bool canGoForward) +{ + ASSERT(m_BackHwnd != NULL && m_ForwardHwnd != NULL); + EnableWindow(m_BackHwnd, canGoBack); + EnableWindow(m_ForwardHwnd, canGoForward); +} diff --git a/tests/cefclient/client_popup_handler.cpp b/tests/cefclient/client_popup_handler.cpp new file mode 100644 index 000000000..c7e004281 --- /dev/null +++ b/tests/cefclient/client_popup_handler.cpp @@ -0,0 +1,34 @@ +// 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/cef.h" +#include "client_popup_handler.h" +#include "util.h" + +ClientPopupHandler::ClientPopupHandler(CefRefPtr parentBrowser) + : m_ParentBrowser(parentBrowser) +{ + ASSERT(m_ParentBrowser.get()); +} + +ClientPopupHandler::~ClientPopupHandler() +{ +} + + +bool ClientPopupHandler::OnBeforeBrowse(CefRefPtr browser, + CefRefPtr frame, + CefRefPtr request, + NavType navType, + bool isRedirect) +{ + REQUIRE_UI_THREAD(); + + // Load the request in the parent browser window. + m_ParentBrowser->GetMainFrame()->LoadRequest(request); + browser->CloseBrowser(); + m_ParentBrowser = NULL; + + return true; +} diff --git a/tests/cefclient/client_popup_handler.h b/tests/cefclient/client_popup_handler.h new file mode 100644 index 000000000..a26a16de9 --- /dev/null +++ b/tests/cefclient/client_popup_handler.h @@ -0,0 +1,36 @@ +// 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 _CLIENT_POPUP_HANDLER_H +#define _CLIENT_POPUP_HANDLER_H + +#include "include/cef.h" + +// Handler for popup windows that loads the request in an existing browser +// window. +class ClientPopupHandler : public CefClient, + public CefRequestHandler +{ +public: + ClientPopupHandler(CefRefPtr parentBrowser); + virtual ~ClientPopupHandler(); + + // CefClient methods + virtual CefRefPtr GetRequestHandler() OVERRIDE + { return this; } + + // CefRequestHandler methods + virtual bool OnBeforeBrowse(CefRefPtr browser, + CefRefPtr frame, + CefRefPtr request, + NavType navType, + bool isRedirect) OVERRIDE; +protected: + CefRefPtr m_ParentBrowser; + + // Include the default reference counting implementation. + IMPLEMENT_REFCOUNTING(ClientPopupHandler); +}; + +#endif // _CLIENT_POPUP_HANDLER_H diff --git a/tests/cefclient/clientplugin.cpp b/tests/cefclient/clientplugin.cpp index b4e261177..94ab2df5e 100644 --- a/tests/cefclient/clientplugin.cpp +++ b/tests/cefclient/clientplugin.cpp @@ -5,7 +5,7 @@ #include "clientplugin.h" -#ifdef _WIN32 +#if defined(OS_WIN) // Initialized in NP_Initialize. NPNetscapeFuncs* g_browser = NULL; @@ -198,4 +198,4 @@ void ClientPlugin::Paint(HDC hdc) { SetTextColor(hdc, old_color); } -#endif // _WIN32 +#endif // OS_WIN diff --git a/tests/cefclient/clientplugin.h b/tests/cefclient/clientplugin.h index de2fd1e97..8a677725b 100644 --- a/tests/cefclient/clientplugin.h +++ b/tests/cefclient/clientplugin.h @@ -9,11 +9,12 @@ #ifndef _CEFCLIENT_CLIENTPLUGIN_H #define _CEFCLIENT_CLIENTPLUGIN_H -#ifdef _WIN32 +#include "include/cef_nplugin.h" + +#if defined(OS_WIN) #include #include -#include "include/cef_nplugin.h" extern NPNetscapeFuncs* g_browser; @@ -95,6 +96,6 @@ class ClientPlugin : public CWindowImpl { int16 mode_; }; -#endif // _WIN32 +#endif // OS_WIN #endif // _CEFCLIENT_CLIENTPLUGIN_H diff --git a/tests/cefclient/download_handler.cpp b/tests/cefclient/download_handler.cpp index 1efd62925..a4ea052e8 100644 --- a/tests/cefclient/download_handler.cpp +++ b/tests/cefclient/download_handler.cpp @@ -9,14 +9,14 @@ #include #include -#ifdef _WIN32 +#if defined(OS_WIN) #include #include #include -#endif // _WIN32 +#endif // OS_WIN // Implementation of the CefDownloadHandler interface. -class ClientDownloadHandler : public CefThreadSafeBase +class ClientDownloadHandler : public CefDownloadHandler { public: ClientDownloadHandler(CefRefPtr listener, @@ -74,9 +74,10 @@ public: memcpy(&(*buffer)[0], data, data_size); // Add the new data vector to the pending data queue. - Lock(); - pending_data_.push_back(buffer); - Unlock(); + { + AutoLock lock_scope(this); + pending_data_.push_back(buffer); + } // Write data to file on the FILE thread. CefPostTask(TID_FILE, @@ -105,7 +106,7 @@ public: if(file_) return; -#ifdef _WIN32 +#if defined(OS_WIN) TCHAR szFolderPath[MAX_PATH]; // Save the file in the user's "My Documents" folder. @@ -134,9 +135,10 @@ public: ct++; } while(PathFileExists(ss.str().c_str())); - Lock(); - filename_ = ss.str(); - Unlock(); + { + AutoLock lock_scope(this); + filename_ = ss.str(); + } file_ = _wfopen(ss.str().c_str(), L"wb"); ASSERT(file_ != NULL); @@ -171,12 +173,13 @@ public: std::vector*> data; // Remove all data from the pending data queue. - Lock(); - if(!pending_data_.empty()) { - data = pending_data_; - pending_data_.clear(); + { + AutoLock lock_scope(this); + if(!pending_data_.empty()) { + data = pending_data_; + pending_data_.clear(); + } } - Unlock(); if(data.empty()) return; @@ -202,6 +205,9 @@ private: CefString filename_; FILE* file_; std::vector*> pending_data_; + + IMPLEMENT_REFCOUNTING(ClientDownloadHandler); + IMPLEMENT_LOCKING(ClientDownloadHandler); }; CefRefPtr CreateDownloadHandler( diff --git a/tests/cefclient/extension_test.cpp b/tests/cefclient/extension_test.cpp index 4b9cb1a28..b6f63d015 100644 --- a/tests/cefclient/extension_test.cpp +++ b/tests/cefclient/extension_test.cpp @@ -6,7 +6,7 @@ // Implementation of the V8 handler class for the "cef.test" extension. -class ClientV8ExtensionHandler : public CefThreadSafeBase +class ClientV8ExtensionHandler : public CefV8Handler { public: ClientV8ExtensionHandler() : test_param_("An initial string value.") {} @@ -62,6 +62,8 @@ public: private: CefString test_param_; + + IMPLEMENT_REFCOUNTING(ClientV8ExtensionHandler); }; diff --git a/tests/cefclient/osrplugin.cpp b/tests/cefclient/osrplugin.cpp index 28bf31fb8..fc18e7f6b 100644 --- a/tests/cefclient/osrplugin.cpp +++ b/tests/cefclient/osrplugin.cpp @@ -3,16 +3,19 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "include/cef.h" #include "osrplugin.h" #include "cefclient.h" +#include "client_popup_handler.h" #include "string_util.h" +#include "util.h" #include #include #define _USE_MATH_DEFINES #include #include -#ifdef _WIN32 +#if defined(OS_WIN) // Initialized in NP_Initialize. NPNetscapeFuncs* g_osrbrowser = NULL; @@ -42,15 +45,22 @@ public: }; // Handler for off-screen rendering windows. -class ClientOSRHandler : public ClientHandler +class ClientOSRHandler : public CefClient, + public CefLifeSpanHandler, + public CefLoadHandler, + public CefDisplayHandler, + public CefRenderHandler { public: ClientOSRHandler(ClientPlugin* plugin) - : plugin_(plugin), view_buffer_(NULL), view_buffer_size_(0), - popup_buffer_(NULL), popup_buffer_size_(0) + : plugin_(plugin), + view_buffer_(NULL), + view_buffer_size_(0), + popup_buffer_(NULL), + popup_buffer_size_(0) { } - virtual ~ClientOSRHandler() + ~ClientOSRHandler() { if (view_buffer_) delete [] view_buffer_; @@ -58,25 +68,33 @@ public: delete [] popup_buffer_; } - virtual RetVal HandleBeforeCreated(CefRefPtr parentBrowser, - CefWindowInfo& createInfo, bool popup, - const CefPopupFeatures& popupFeatures, - CefRefPtr& handler, - const CefString& url, - CefBrowserSettings& settings) + // CefClient methods + virtual CefRefPtr GetLifeSpanHandler() OVERRIDE + { return this; } + virtual CefRefPtr GetLoadHandler() OVERRIDE + { return this; } + virtual CefRefPtr GetDisplayHandler() OVERRIDE + { return this; } + virtual CefRefPtr GetRenderHandler() OVERRIDE + { return this; } + + // CefLifeSpanHandler methods + + virtual bool OnBeforePopup(CefRefPtr parentBrowser, + const CefPopupFeatures& popupFeatures, + CefWindowInfo& windowInfo, + const CefString& url, + CefRefPtr& client, + CefBrowserSettings& settings) OVERRIDE { REQUIRE_UI_THREAD(); - // Popups will be redirected to this browser window. - if(popup) { - createInfo.m_bWindowRenderingDisabled = TRUE; - handler = new ClientPopupHandler(g_offscreenBrowser); - } - - return RV_CONTINUE; + windowInfo.m_bWindowRenderingDisabled = TRUE; + client = new ClientPopupHandler(g_offscreenBrowser); + return false; } - virtual RetVal HandleAfterCreated(CefRefPtr browser) + virtual void OnAfterCreated(CefRefPtr browser) OVERRIDE { REQUIRE_UI_THREAD(); @@ -84,13 +102,58 @@ public: browser->SetSize(PET_VIEW, g_width, g_height); g_offscreenBrowser = browser; - - return ClientHandler::HandleAfterCreated(browser); } - virtual RetVal HandleAddressChange(CefRefPtr browser, - CefRefPtr frame, - const CefString& url) + virtual void OnBeforeClose(CefRefPtr browser) OVERRIDE + { + g_offscreenBrowser = NULL; + } + + // CefLoadHandler methods + + virtual void OnLoadStart(CefRefPtr browser, + CefRefPtr frame) OVERRIDE + { + REQUIRE_UI_THREAD(); + + if(!browser->IsPopup() && frame->IsMain()) { + // We've just started loading a page + SetLoading(true); + } + } + + virtual void OnLoadEnd(CefRefPtr browser, + CefRefPtr frame, + int httpStatusCode) OVERRIDE + { + REQUIRE_UI_THREAD(); + + if(!browser->IsPopup() && frame->IsMain()) { + // We've just finished loading a page + SetLoading(false); + } + } + + // CefDisplayHandler methods + + virtual void OnNavStateChange(CefRefPtr browser, + bool canGoBack, + bool canGoForward) OVERRIDE + { + REQUIRE_UI_THREAD(); + + // Set the "back" and "forward" button state in the HTML. + std::stringstream ss; + ss << "document.getElementById('back').disabled = " + << (canGoBack?"false":"true") << ";"; + ss << "document.getElementById('forward').disabled = " + << (canGoForward?"false":"true") << ";"; + AppGetBrowser()->GetMainFrame()->ExecuteJavaScript(ss.str(), "", 0); + } + + virtual void OnAddressChange(CefRefPtr browser, + CefRefPtr frame, + const CefString& url) OVERRIDE { REQUIRE_UI_THREAD(); @@ -100,11 +163,10 @@ public: StringReplace(urlStr, "'", "\\'"); ss << "document.getElementById('url').value = '" << urlStr.c_str() << "'"; AppGetBrowser()->GetMainFrame()->ExecuteJavaScript(ss.str(), "", 0); - return RV_CONTINUE; } - virtual RetVal HandleTitleChange(CefRefPtr browser, - const CefString& title) + virtual void OnTitleChange(CefRefPtr browser, + const CefString& title) OVERRIDE { REQUIRE_UI_THREAD(); @@ -115,11 +177,12 @@ public: ss << "document.getElementById('title').innerHTML = '" << titleStr.c_str() << "'"; AppGetBrowser()->GetMainFrame()->ExecuteJavaScript(ss.str(), "", 0); - return RV_CONTINUE; } - virtual RetVal HandleGetRect(CefRefPtr browser, bool screen, - CefRect& rect) + // CefRenderHandler methods + + virtual bool GetViewRect(CefRefPtr browser, + CefRect& rect) OVERRIDE { REQUIRE_UI_THREAD(); @@ -128,12 +191,20 @@ public: rect.x = rect.y = 0; rect.width = g_width; rect.height = g_height; - return RV_CONTINUE; + return true; } - - virtual RetVal HandleGetScreenPoint(CefRefPtr browser, - int viewX, int viewY, int& screenX, - int& screenY) + + virtual bool GetScreenRect(CefRefPtr browser, + CefRect& rect) OVERRIDE + { + return GetViewRect(browser, rect); + } + + virtual bool GetScreenPoint(CefRefPtr browser, + int viewX, + int viewY, + int& screenX, + int& screenY) OVERRIDE { REQUIRE_UI_THREAD(); @@ -142,21 +213,15 @@ public: MapWindowPoints(plugin_->hWnd, HWND_DESKTOP, &screen_pt, 1); screenX = screen_pt.x; screenY = screen_pt.y; - return RV_CONTINUE; + return true; } - virtual RetVal HandlePopupChange(CefRefPtr browser, bool show, - const CefRect& rect) + virtual void OnPopupShow(CefRefPtr browser, + bool show) OVERRIDE { REQUIRE_UI_THREAD(); - if (show && rect.width > 0) { - // Update the popup rectange. It will always be inside the view due to - // HandleGetRect(). - ASSERT(rect.x + rect.width < g_width && - rect.y + rect.height < g_height); - popup_rect_ = rect; - } else if(!show) { + if(!show) { // Clear the popup buffer. popup_rect_.Set(0,0,0,0); if (popup_buffer_) { @@ -165,12 +230,26 @@ public: popup_buffer_size_ = 0; } } - return RV_CONTINUE; } - virtual RetVal HandlePaint(CefRefPtr browser, - PaintElementType type, const CefRect& dirtyRect, - const void* buffer) + virtual void OnPopupSize(CefRefPtr browser, + const CefRect& rect) OVERRIDE + { + REQUIRE_UI_THREAD(); + + if (rect.width > 0) { + // Update the popup rectange. It will always be inside the view due to + // HandleGetRect(). + ASSERT(rect.x + rect.width < g_width && + rect.y + rect.height < g_height); + popup_rect_ = rect; + } + } + + virtual void OnPaint(CefRefPtr browser, + PaintElementType type, + const CefRect& dirtyRect, + const void* buffer) OVERRIDE { REQUIRE_UI_THREAD(); @@ -201,12 +280,10 @@ public: popup_rect_.height, GL_RGB, GL_UNSIGNED_BYTE, popup_buffer_); } } - - return RV_CONTINUE; } - virtual RetVal HandleCursorChange(CefRefPtr browser, - CefCursorHandle cursor) + virtual void OnCursorChange(CefRefPtr browser, + CefCursorHandle cursor) OVERRIDE { REQUIRE_UI_THREAD(); @@ -214,11 +291,10 @@ public: SetClassLong(plugin_->hWnd, GCL_HCURSOR, static_cast(reinterpret_cast(cursor))); SetCursor(cursor); - return RV_CONTINUE; } -protected: - virtual void SetLoading(bool isLoading) +private: + void SetLoading(bool isLoading) { // Set the "stop" and "reload" button state in the HTML. std::stringstream ss; @@ -229,17 +305,6 @@ protected: AppGetBrowser()->GetMainFrame()->ExecuteJavaScript(ss.str(), "", 0); } - virtual void SetNavState(bool canGoBack, bool canGoForward) - { - // Set the "back" and "forward" button state in the HTML. - std::stringstream ss; - ss << "document.getElementById('back').disabled = " - << (canGoBack?"false":"true") << ";"; - ss << "document.getElementById('forward').disabled = " - << (canGoForward?"false":"true") << ";"; - AppGetBrowser()->GetMainFrame()->ExecuteJavaScript(ss.str(), "", 0); - } - // Set the contents of the RGB buffer. void SetRGB(const void* src, int width, int height, bool view) { @@ -286,13 +351,15 @@ protected: } } -private: ClientPlugin* plugin_; unsigned char* view_buffer_; int view_buffer_size_; unsigned char* popup_buffer_; int popup_buffer_size_; CefRect popup_rect_; + + // Include the default reference counting implementation. + IMPLEMENT_REFCOUNTING(ClientOSRPlugin); }; // Forward declarations of functions included in this code module: @@ -487,9 +554,10 @@ NPError NPP_SetWindowImpl(NPP instance, NPWindow* window_info) { // Create the off-screen rendering window. CefWindowInfo windowInfo; + CefBrowserSettings settings; windowInfo.SetAsOffScreen(plugin->hWnd); - CefBrowser::CreateBrowser(windowInfo, false, - new ClientOSRHandler(plugin), "http://www.google.com"); + CefBrowser::CreateBrowser(windowInfo, new ClientOSRHandler(plugin), + "http://www.google.com", settings); } // Position the plugin window and make sure it's visible. @@ -703,4 +771,4 @@ CefRefPtr GetOffScreenBrowser() return g_offscreenBrowser; } -#endif // _WIN32 +#endif // OS_WIN diff --git a/tests/cefclient/osrplugin.h b/tests/cefclient/osrplugin.h index 9a6337d42..d6a31e397 100644 --- a/tests/cefclient/osrplugin.h +++ b/tests/cefclient/osrplugin.h @@ -12,7 +12,7 @@ #include "include/cef.h" #include "include/cef_nplugin.h" -#ifdef _WIN32 +#if defined(OS_WIN) extern NPNetscapeFuncs* g_osrbrowser; @@ -22,6 +22,6 @@ NPError API_CALL NP_OSRShutdown(void); CefRefPtr GetOffScreenBrowser(); -#endif // _WIN32 +#endif // OS_WIN #endif // _CEFCLIENT_OSRPLUGIN_H diff --git a/tests/cefclient/osrplugin_test.cpp b/tests/cefclient/osrplugin_test.cpp index 5df3d80ec..e81fb48df 100644 --- a/tests/cefclient/osrplugin_test.cpp +++ b/tests/cefclient/osrplugin_test.cpp @@ -5,6 +5,7 @@ #include "osrplugin_test.h" #include "osrplugin.h" #include "cefclient.h" +#include "client_handler.h" #include "plugin_test.h" void InitOSRPluginTest() @@ -27,7 +28,7 @@ void InitOSRPluginTest() void RunOSRPluginTest(CefRefPtr browser) { - class Listener : public CefThreadSafeBase + class Listener : public CefDOMEventListener { public: Listener() {} @@ -72,9 +73,11 @@ void RunOSRPluginTest(CefRefPtr browser) ASSERT(false); } } + + IMPLEMENT_REFCOUNTING(Listener); }; - class Visitor : public CefThreadSafeBase + class Visitor : public CefDOMVisitor { public: Visitor() {} @@ -102,6 +105,8 @@ void RunOSRPluginTest(CefRefPtr browser) RegisterClickListener(document, listener, "testWindowlessPlugin"); RegisterClickListener(document, listener, "viewSource"); } + + IMPLEMENT_REFCOUNTING(Visitor); }; // Center the window on the screen. @@ -115,8 +120,8 @@ void RunOSRPluginTest(CefRefPtr browser) SWP_NOZORDER | SWP_SHOWWINDOW); // The DOM visitor will be called after the path is loaded. - CefRefPtr handler = browser->GetHandler(); - static_cast(handler.get())->AddDOMVisitor( + CefRefPtr client = browser->GetClient(); + static_cast(client.get())->AddDOMVisitor( "http://tests/osrapp", new Visitor()); browser->GetMainFrame()->LoadURL("http://tests/osrapp"); diff --git a/tests/cefclient/resource_util.h b/tests/cefclient/resource_util.h index 2b100e99e..11cd310fd 100644 --- a/tests/cefclient/resource_util.h +++ b/tests/cefclient/resource_util.h @@ -7,20 +7,18 @@ #include "include/cef.h" -#if defined(_WIN32) +#if defined(OS_WIN) // Load a resource of type BINARY bool LoadBinaryResource(int binaryId, DWORD &dwSize, LPBYTE &pBytes); CefRefPtr GetBinaryResourceReader(int binaryId); -// end of _WIN32 -#elif defined(__APPLE__) +#elif defined(OS_MACOSX) // Load the resource with the specified name. bool LoadBinaryResource(const char* resource_name, std::string& resource_data); CefRefPtr GetBinaryResourceReader(const char* resource_name); -// end of __APPLE__ #endif #endif // _CEFCLIENT_RESOURCE_UTIL diff --git a/tests/cefclient/resource_util_win.cpp b/tests/cefclient/resource_util_win.cpp index c0bb5613a..6023b5535 100644 --- a/tests/cefclient/resource_util_win.cpp +++ b/tests/cefclient/resource_util_win.cpp @@ -5,7 +5,7 @@ #include "resource_util.h" #include "include/cef_wrapper.h" -#ifdef _WIN32 +#if defined(OS_WIN) bool LoadBinaryResource(int binaryId, DWORD &dwSize, LPBYTE &pBytes) { @@ -40,4 +40,4 @@ CefRefPtr GetBinaryResourceReader(int binaryId) return NULL; } -#endif // _WIN32 +#endif // OS_WIN diff --git a/tests/cefclient/scheme_test.cpp b/tests/cefclient/scheme_test.cpp index cbc65f49f..7c959f53d 100644 --- a/tests/cefclient/scheme_test.cpp +++ b/tests/cefclient/scheme_test.cpp @@ -8,13 +8,13 @@ #include "string_util.h" #include "util.h" -#ifdef _WIN32 +#if defined(OS_WIN) #include "resource.h" -#endif // _WIN32 +#endif // Implementation of the schema handler for client:// requests. -class ClientSchemeHandler : public CefThreadSafeBase +class ClientSchemeHandler : public CefSchemeHandler { public: ClientSchemeHandler() : offset_(0) {} @@ -39,7 +39,8 @@ public: bool handled = false; - Lock(); + AutoLock lock_scope(this); + std::string url = request->GetURL(); if(strstr(url.c_str(), "handler.html") != NULL) { // Build the response html @@ -69,7 +70,7 @@ public: } else if(strstr(url.c_str(), "client.png") != NULL) { // Load the response image -#if defined(_WIN32) +#if defined(OS_WIN) DWORD dwSize; LPBYTE pBytes; if(LoadBinaryResource(IDS_LOGO, dwSize, pBytes)) { @@ -79,18 +80,18 @@ public: response->SetMimeType("image/jpg"); response->SetStatus(200); } -#elif defined(__APPLE__) +#elif defined(OS_MACOSX) if(LoadBinaryResource("logo.png", data_)) { handled = true; - mime_type = "image/png"; + response->SetMimeType("image/png"); + response->SetStatus(200); } #endif } // Set the resulting response length *response_length = data_.length(); - Unlock(); - + return handled; } @@ -111,7 +112,7 @@ public: bool has_data = false; *bytes_read = 0; - Lock(); + AutoLock lock_scope(this); if(offset_ < data_.length()) { // Copy the next block of data into the buffer. @@ -124,19 +125,19 @@ public: has_data = true; } - Unlock(); - return has_data; } private: std::string data_; size_t offset_; + + IMPLEMENT_REFCOUNTING(ClientSchemeHandler); + IMPLEMENT_LOCKING(ClientSchemeHandler); }; // Implementation of the factory for for creating schema handlers. -class ClientSchemeHandlerFactory : - public CefThreadSafeBase +class ClientSchemeHandlerFactory : public CefSchemeHandlerFactory { public: // Return a new scheme handler instance to handle the request. @@ -145,6 +146,8 @@ public: REQUIRE_IO_THREAD(); return new ClientSchemeHandler(); } + + IMPLEMENT_REFCOUNTING(ClientSchemeHandlerFactory); }; void InitSchemeTest() diff --git a/tests/cefclient/uiplugin.cpp b/tests/cefclient/uiplugin.cpp index 5f6daefe6..d6fd4cef0 100644 --- a/tests/cefclient/uiplugin.cpp +++ b/tests/cefclient/uiplugin.cpp @@ -8,7 +8,7 @@ #include #include -#ifdef _WIN32 +#if defined(OS_WIN) // Initialized in NP_Initialize. NPNetscapeFuncs* g_uibrowser = NULL; @@ -290,4 +290,4 @@ void ResetRotation() NotifyNewRotation(g_rotationspeed); } -#endif // _WIN32 +#endif // OS_WIN diff --git a/tests/cefclient/uiplugin.h b/tests/cefclient/uiplugin.h index 2f1600449..108f2a57c 100644 --- a/tests/cefclient/uiplugin.h +++ b/tests/cefclient/uiplugin.h @@ -11,7 +11,7 @@ #include "include/cef_nplugin.h" -#ifdef _WIN32 +#if defined(OS_WIN) extern NPNetscapeFuncs* g_uibrowser; @@ -24,6 +24,6 @@ void ModifyRotation(float value); // Function called to reset the rotation value. void ResetRotation(); -#endif // _WIN32 +#endif // OS_WIN #endif // _CEFCLIENT_UIPLUGIN_H diff --git a/tests/cefclient/uiplugin_test.cpp b/tests/cefclient/uiplugin_test.cpp index 65aa30122..7e9c12f28 100644 --- a/tests/cefclient/uiplugin_test.cpp +++ b/tests/cefclient/uiplugin_test.cpp @@ -8,7 +8,7 @@ // Implementation of the V8 handler class for the "window.uiapp" functions. -class ClientV8UIHandler : public CefThreadSafeBase +class ClientV8UIHandler : public CefV8Handler { public: ClientV8UIHandler() {} @@ -52,6 +52,8 @@ public: return false; } + + IMPLEMENT_REFCOUNTING(ClientV8UIHandler); }; void InitUIPluginTest() diff --git a/tests/cefclient/util.h b/tests/cefclient/util.h index fc7f702b2..e7a064fc5 100644 --- a/tests/cefclient/util.h +++ b/tests/cefclient/util.h @@ -1,62 +1,33 @@ -// Copyright (c) 2011 The Chromium Embedded Framework Authors. -// Portions copyright (c) 2006-2010 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. +// 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 _CEFCLIENT_UTIL_H #define _CEFCLIENT_UTIL_H #include "include/cef.h" -#ifdef _WIN32 +#if defined(OS_WIN) #include -#ifdef _DEBUG +#ifndef NDEBUG #define ASSERT(condition) if(!(condition)) { DebugBreak(); } #else #define ASSERT(condition) ((void)0) #endif -// MSVC_PUSH_DISABLE_WARNING pushes |n| onto a stack of warnings to be disabled. -// The warning remains disabled until popped by MSVC_POP_WARNING. -#define MSVC_PUSH_DISABLE_WARNING(n) __pragma(warning(push)) \ - __pragma(warning(disable:n)) - -// MSVC_PUSH_WARNING_LEVEL pushes |n| as the global warning level. The level -// remains in effect until popped by MSVC_POP_WARNING(). Use 0 to disable all -// warnings. -#define MSVC_PUSH_WARNING_LEVEL(n) __pragma(warning(push, n)) - -// Pop effects of innermost MSVC_PUSH_* macro. -#define MSVC_POP_WARNING() __pragma(warning(pop)) - -// Allows |this| to be passed as an argument in constructor initializer lists. -// This uses push/pop instead of the seemingly simpler suppress feature to avoid -// having the warning be disabled for more than just |code|. -// -// Example usage: -// Foo::Foo() : x(NULL), ALLOW_THIS_IN_INITIALIZER_LIST(y(this)), z(3) {} -// -// Compiler warning C4355: 'this': used in base member initializer list: -// http://msdn.microsoft.com/en-us/library/3c594ae3(VS.80).aspx -#define ALLOW_THIS_IN_INITIALIZER_LIST(code) MSVC_PUSH_DISABLE_WARNING(4355) \ - code \ - MSVC_POP_WARNING() - -#else // !_WIN32 +#else // !OS_WIN #include -#ifdef _DEBUG +#ifndef NDEBUG #define ASSERT(condition) if(!(condition)) { assert(false); } #else #define ASSERT(condition) ((void)0) #endif -#define ALLOW_THIS_IN_INITIALIZER_LIST(code) code - -#endif // !_WIN32 +#endif // !OS_WIN #define REQUIRE_UI_THREAD() ASSERT(CefCurrentlyOn(TID_UI)); #define REQUIRE_IO_THREAD() ASSERT(CefCurrentlyOn(TID_IO)); diff --git a/tests/unittests/cookie_unittest.cc b/tests/unittests/cookie_unittest.cc index 97e443429..f51655cc2 100644 --- a/tests/unittests/cookie_unittest.cc +++ b/tests/unittests/cookie_unittest.cc @@ -32,7 +32,7 @@ void IOT_Delete(const CefString& url, const CefString& cookie_name, event->Signal(); } -class TestVisitor : public CefThreadSafeBase +class TestVisitor : public CefCookieVisitor { public: TestVisitor(CookieVector* cookies, bool deleteCookies, @@ -57,6 +57,8 @@ public: CookieVector* cookies_; bool delete_cookies_; base::WaitableEvent* event_; + + IMPLEMENT_REFCOUNTING(TestVisitor); }; } // anonymous diff --git a/tests/unittests/dom_unittest.cc b/tests/unittests/dom_unittest.cc index 861873e42..07daf207d 100644 --- a/tests/unittests/dom_unittest.cc +++ b/tests/unittests/dom_unittest.cc @@ -11,7 +11,7 @@ namespace { class TestDOMHandler : public TestHandler { public: - class Visitor : public CefThreadSafeBase + class Visitor : public CefDOMVisitor { public: Visitor(TestDOMHandler* handler) : handler_(handler) {} @@ -201,6 +201,8 @@ public: protected: TestDOMHandler* handler_; + + IMPLEMENT_REFCOUNTING(Visitor); }; enum TestType { @@ -213,7 +215,7 @@ public: visitor_ = new Visitor(this); } - virtual void RunTest() + virtual void RunTest() OVERRIDE { std::stringstream mainHtml; mainHtml << @@ -228,16 +230,14 @@ public: CreateBrowser("http://tests/main.html"); } - virtual RetVal HandleLoadEnd(CefRefPtr browser, - CefRefPtr frame, - int httpStatusCode) + virtual void OnLoadEnd(CefRefPtr browser, + CefRefPtr frame, + int httpStatusCode) OVERRIDE { if(frame->IsMain()) { // The page is done loading so visit the DOM. browser->GetMainFrame()->VisitDOM(visitor_.get()); } - - return RV_CONTINUE; } CefRefPtr visitor_; diff --git a/tests/unittests/request_unittest.cc b/tests/unittests/request_unittest.cc index 229519d34..9a7862b19 100644 --- a/tests/unittests/request_unittest.cc +++ b/tests/unittests/request_unittest.cc @@ -224,7 +224,7 @@ class RequestSendRecvTestHandler : public TestHandler public: RequestSendRecvTestHandler() {} - virtual void RunTest() + virtual void RunTest() OVERRIDE { // Create the test request CreateRequest(request_); @@ -233,34 +233,34 @@ public: CreateBrowser(CefString()); } - virtual RetVal HandleAfterCreated(CefRefPtr browser) + virtual void OnAfterCreated(CefRefPtr browser) OVERRIDE { - TestHandler::HandleAfterCreated(browser); + TestHandler::OnAfterCreated(browser); // Load the test request browser->GetMainFrame()->LoadRequest(request_); - return RV_CONTINUE; } - virtual RetVal HandleBeforeBrowse(CefRefPtr browser, - CefRefPtr frame, - CefRefPtr request, - NavType navType, bool isRedirect) + virtual bool OnBeforeBrowse(CefRefPtr browser, + CefRefPtr frame, + CefRefPtr request, + NavType navType, + bool isRedirect) OVERRIDE { g_RequestSendRecvTestHandlerHandleBeforeBrowseCalled = true; // Verify that the request is the same VerifyRequestEqual(request_, request, true); - return RV_CONTINUE; + return false; } - virtual RetVal HandleBeforeResourceLoad(CefRefPtr browser, - CefRefPtr request, - CefString& redirectUrl, - CefRefPtr& resourceStream, - CefRefPtr response, - int loadFlags) + virtual bool OnBeforeResourceLoad(CefRefPtr browser, + CefRefPtr request, + CefString& redirectUrl, + CefRefPtr& resourceStream, + CefRefPtr response, + int loadFlags) OVERRIDE { g_RequestSendRecvTestHandlerHandleBeforeResourceLoadCalled = true; @@ -268,16 +268,15 @@ public: VerifyRequestEqual(request_, request, true); // No results - return RV_HANDLED; + return true; } - virtual RetVal HandleLoadEnd(CefRefPtr browser, - CefRefPtr frame, - int httpStatusCode) + virtual void OnLoadEnd(CefRefPtr browser, + CefRefPtr frame, + int httpStatusCode) OVERRIDE { if(!browser->IsPopup() && frame->IsMain()) DestroyTest(); - return RV_CONTINUE; } CefRefPtr request_; diff --git a/tests/unittests/scheme_handler_unittest.cc b/tests/unittests/scheme_handler_unittest.cc index 3ff4a1a08..9bb16274c 100644 --- a/tests/unittests/scheme_handler_unittest.cc +++ b/tests/unittests/scheme_handler_unittest.cc @@ -44,15 +44,16 @@ public: { } - virtual void RunTest() + virtual void RunTest() OVERRIDE { CreateBrowser(test_results_->url); } - virtual RetVal HandleBeforeBrowse(CefRefPtr browser, - CefRefPtr frame, - CefRefPtr request, - NavType navType, bool isRedirect) + virtual bool OnBeforeBrowse(CefRefPtr browser, + CefRefPtr frame, + CefRefPtr request, + NavType navType, + bool isRedirect) OVERRIDE { if (isRedirect) { test_results_->got_redirect.yes(); @@ -68,12 +69,12 @@ public: test_results_->redirect_url.clear(); } - return RV_CONTINUE; + return false; } - virtual RetVal HandleLoadEnd(CefRefPtr browser, - CefRefPtr frame, - int httpStatusCode) + virtual void OnLoadEnd(CefRefPtr browser, + CefRefPtr frame, + int httpStatusCode) OVERRIDE { // Test that the output is correct. std::string output = frame->GetSource(); @@ -84,15 +85,13 @@ public: EXPECT_EQ(httpStatusCode, test_results_->status_code); DestroyTest(); - - return RV_CONTINUE; } protected: TestResults* test_results_; }; -class ClientSchemeHandler : public CefThreadSafeBase +class ClientSchemeHandler : public CefSchemeHandler { public: ClientSchemeHandler(TestResults* tr) @@ -138,7 +137,7 @@ public: bool has_data = false; *bytes_read = 0; - Lock(); + AutoLock lock_scope(this); size_t size = test_results_->html.size(); if(offset_ < size) { @@ -151,18 +150,18 @@ public: has_data = true; } - Unlock(); - return has_data; } private: TestResults* test_results_; size_t offset_; + + IMPLEMENT_REFCOUNTING(ClientSchemeHandler); + IMPLEMENT_LOCKING(ClientSchemeHandler); }; -class ClientSchemeHandlerFactory : - public CefThreadSafeBase +class ClientSchemeHandlerFactory : public CefSchemeHandlerFactory { public: ClientSchemeHandlerFactory(TestResults* tr) @@ -175,6 +174,8 @@ public: } TestResults* test_results_; + + IMPLEMENT_REFCOUNTING(ClientSchemeHandlerFactory); }; // Global test results object. diff --git a/tests/unittests/stream_unittest.cc b/tests/unittests/stream_unittest.cc index 76edefa6b..886726d58 100644 --- a/tests/unittests/stream_unittest.cc +++ b/tests/unittests/stream_unittest.cc @@ -158,7 +158,7 @@ TEST(StreamTest, WriteFile) bool g_ReadHandlerTesterDeleted = false; -class ReadHandlerTester : public CefThreadSafeBase +class ReadHandlerTester : public CefReadHandler { public: ReadHandlerTester() @@ -213,6 +213,8 @@ public: bool tell_called_; bool eof_called_; + + IMPLEMENT_REFCOUNTING(ReadHandlerTester); }; TEST(StreamTest, ReadHandler) @@ -262,7 +264,7 @@ TEST(StreamTest, ReadHandler) bool g_WriteHandlerTesterDeleted = false; -class WriteHandlerTester : public CefThreadSafeBase +class WriteHandlerTester : public CefWriteHandler { public: WriteHandlerTester() @@ -317,6 +319,8 @@ public: bool tell_called_; bool flush_called_; + + IMPLEMENT_REFCOUNTING(WriteHandlerTester); }; TEST(StreamTest, WriteHandler) diff --git a/tests/unittests/test_handler.h b/tests/unittests/test_handler.h index 236448082..c6c59eb66 100644 --- a/tests/unittests/test_handler.h +++ b/tests/unittests/test_handler.h @@ -21,8 +21,13 @@ protected: bool gotit_; }; -// Base implementation of CefHandler for unit tests. -class TestHandler : public CefThreadSafeBase +// Base implementation of CefClient for unit tests. Add new interfaces as needed +// by test cases. +class TestHandler : public CefClient, + public CefLifeSpanHandler, + public CefLoadHandler, + public CefRequestHandler, + public CefJSBindingHandler { public: TestHandler() : browser_hwnd_(NULL), completion_event_(true, false) @@ -36,86 +41,53 @@ public: // Implement this method to run the test virtual void RunTest() =0; - virtual RetVal HandleBeforeCreated(CefRefPtr parentBrowser, - CefWindowInfo& createInfo, bool popup, - const CefPopupFeatures& popupFeatures, - CefRefPtr& handler, - const CefString& url, - CefBrowserSettings& settings) - { - return RV_CONTINUE; - } + // CefClient methods. Add new methods as needed by test cases. + virtual CefRefPtr GetLifeSpanHandler() OVERRIDE + { return this; } + virtual CefRefPtr GetLoadHandler() OVERRIDE + { return this; } + virtual CefRefPtr GetRequestHandler() OVERRIDE + { return this; } + virtual CefRefPtr GetJSBindingHandler() OVERRIDE + { return this; } + + // CefLifeSpanHandler methods - virtual RetVal HandleAfterCreated(CefRefPtr browser) + virtual void OnAfterCreated(CefRefPtr browser) OVERRIDE { - Lock(); + AutoLock lock_scope(this); if(!browser->IsPopup()) { // Keep the main child window, but not popup windows browser_ = browser; browser_hwnd_ = browser->GetWindowHandle(); } - Unlock(); - return RV_CONTINUE; } - virtual RetVal HandleAddressChange(CefRefPtr browser, - CefRefPtr frame, - const CefString& url) + virtual void OnBeforeClose(CefRefPtr browser) OVERRIDE { - return RV_CONTINUE; + AutoLock lock_scope(this); + if(browser_hwnd_ == browser->GetWindowHandle()) + { + // Free the browser pointer so that the browser can be destroyed + browser_ = NULL; + browser_hwnd_ = NULL; + + // Signal that the test is now complete. + completion_event_.Signal(); + } } - virtual RetVal HandleNavStateChange(CefRefPtr browser, - bool canGoBack, bool canGoForward) - { - return RV_CONTINUE; - } + // CefRequestHandler methods - virtual RetVal HandleTitleChange(CefRefPtr browser, - const CefString& title) - { - return RV_CONTINUE; - } - - virtual RetVal HandleBeforeBrowse(CefRefPtr browser, - CefRefPtr frame, + virtual bool OnBeforeResourceLoad(CefRefPtr browser, CefRefPtr request, - NavType navType, bool isRedirect) + CefString& redirectUrl, + CefRefPtr& resourceStream, + CefRefPtr response, + int loadFlags) OVERRIDE { - return RV_CONTINUE; - } - - virtual RetVal HandleLoadStart(CefRefPtr browser, - CefRefPtr frame) - { - return RV_CONTINUE; - } - - virtual RetVal HandleLoadEnd(CefRefPtr browser, - CefRefPtr frame, - int httpStatusCode) - { - return RV_CONTINUE; - } - - virtual RetVal HandleLoadError(CefRefPtr browser, - CefRefPtr frame, - ErrorCode errorCode, - const CefString& failedUrl, - CefString& errorText) - { - return RV_CONTINUE; - } - - virtual RetVal HandleBeforeResourceLoad(CefRefPtr browser, - CefRefPtr request, - CefString& redirectUrl, - CefRefPtr& resourceStream, - CefRefPtr response, - int loadFlags) - { - Lock(); + AutoLock lock_scope(this); if(resource_map_.size() > 0) { CefString url = request->GetURL(); ResourceMap::const_iterator it = resource_map_.find(url); @@ -127,201 +99,8 @@ public: response->SetStatus(200); } } - Unlock(); - return RV_CONTINUE; - } - - virtual RetVal HandleProtocolExecution(CefRefPtr browser, - const CefString& url, - bool& allow_os_execution) - { - return RV_CONTINUE; - } - - virtual RetVal HandleDownloadResponse(CefRefPtr browser, - const CefString& mimeType, - const CefString& fileName, - int64 contentLength, - CefRefPtr& handler) - { - return RV_CONTINUE; - } - - virtual RetVal HandleAuthenticationRequest(CefRefPtr browser, - bool isProxy, - const CefString& host, - const CefString& realm, - const CefString& scheme, - CefString& username, - CefString& password) - { - return RV_CONTINUE; - } - - virtual RetVal HandleBeforeMenu(CefRefPtr browser, - const MenuInfo& menuInfo) - { - return RV_CONTINUE; - } - - - virtual RetVal HandleGetMenuLabel(CefRefPtr browser, - MenuId menuId, CefString& label) - { - return RV_CONTINUE; - } - - virtual RetVal HandleMenuAction(CefRefPtr browser, - MenuId menuId) - { - return RV_CONTINUE; - } - - virtual RetVal HandlePrintOptions(CefRefPtr browser, - CefPrintOptions& printOptions) - { - return RV_CONTINUE; - } - - virtual RetVal HandlePrintHeaderFooter(CefRefPtr browser, - CefRefPtr frame, - CefPrintInfo& printInfo, - const CefString& url, - const CefString& title, - int currentPage, int maxPages, - CefString& topLeft, - CefString& topCenter, - CefString& topRight, - CefString& bottomLeft, - CefString& bottomCenter, - CefString& bottomRight) - { - return RV_CONTINUE; - } - - virtual RetVal HandleJSAlert(CefRefPtr browser, - CefRefPtr frame, - const CefString& message) - { - return RV_CONTINUE; - } - - virtual RetVal HandleJSConfirm(CefRefPtr browser, - CefRefPtr frame, - const CefString& message, bool& retval) - { - return RV_CONTINUE; - } - - virtual RetVal HandleJSPrompt(CefRefPtr browser, - CefRefPtr frame, - const CefString& message, - const CefString& defaultValue, - bool& retval, - CefString& result) - { - return RV_CONTINUE; - } - - virtual RetVal HandleJSBinding(CefRefPtr browser, - CefRefPtr frame, - CefRefPtr object) - { - return RV_CONTINUE; - } - - virtual RetVal HandleBeforeWindowClose(CefRefPtr browser) - { - Lock(); - if(browser_hwnd_ == browser->GetWindowHandle()) - { - // Free the browser pointer so that the browser can be destroyed - browser_ = NULL; - browser_hwnd_ = NULL; - - // Signal that the test is now complete. - completion_event_.Signal(); - } - Unlock(); - return RV_CONTINUE; - } - - virtual RetVal HandleTakeFocus(CefRefPtr browser, bool reverse) - { - return RV_CONTINUE; - } - - virtual RetVal HandleSetFocus(CefRefPtr browser, - bool isWidget) - { - return RV_CONTINUE; - } - - virtual RetVal HandleKeyEvent(CefRefPtr browser, - KeyEventType type, int code, - int modifiers, bool isSystemKey) - { - return RV_CONTINUE; - } - - virtual RetVal HandleTooltip(CefRefPtr browser, - CefString& text) - { - return RV_CONTINUE; - } - - virtual RetVal HandleStatus(CefRefPtr browser, - const CefString& text, StatusType type) - { - return RV_CONTINUE; - } - - virtual RetVal HandleConsoleMessage(CefRefPtr browser, - const CefString& message, - const CefString& source, int line) - { - return RV_CONTINUE; - } - - virtual RetVal HandleFindResult(CefRefPtr browser, - int identifier, int count, - const CefRect& selectionRect, - int activeMatchOrdinal, bool finalUpdate) - { - return RV_CONTINUE; - } - - virtual RetVal HandleGetRect(CefRefPtr browser, bool screen, - CefRect& rect) - { - return RV_CONTINUE; - } - - virtual RetVal HandleGetScreenPoint(CefRefPtr browser, - int viewX, int viewY, int& screenX, - int& screenY) - { - return RV_CONTINUE; - } - - virtual RetVal HandlePopupChange(CefRefPtr browser, bool show, - const CefRect& rect) - { - return RV_CONTINUE; - } - - virtual RetVal HandlePaint(CefRefPtr browser, - PaintElementType type, const CefRect& dirtyRect, - const void* buffer) - { - return RV_CONTINUE; - } - - virtual RetVal HandleCursorChange(CefRefPtr browser, - CefCursorHandle cursor) - { - return RV_CONTINUE; + return false; } CefRefPtr GetBrowser() @@ -362,11 +141,12 @@ protected: void CreateBrowser(const CefString& url) { CefWindowInfo windowInfo; + CefBrowserSettings settings; #if defined(OS_WIN) windowInfo.SetAsPopup(NULL, "CefUnitTest"); windowInfo.m_dwStyle |= WS_VISIBLE; #endif - CefBrowser::CreateBrowser(windowInfo, false, this, url); + CefBrowser::CreateBrowser(windowInfo, this, url, settings); } void AddResource(const CefString& key, const std::string& value, @@ -393,6 +173,11 @@ private: // Map of resources that can be automatically loaded typedef std::map > ResourceMap; ResourceMap resource_map_; + + // Include the default reference counting implementation. + IMPLEMENT_REFCOUNTING(TestHandler); + // Include the default locking implementation. + IMPLEMENT_LOCKING(TestHandler); }; #endif // _TEST_HANDLER_H diff --git a/tests/unittests/test_suite.h b/tests/unittests/test_suite.h index b693895be..425c0fcbc 100644 --- a/tests/unittests/test_suite.h +++ b/tests/unittests/test_suite.h @@ -21,9 +21,8 @@ class CefTestSuite : public TestSuite { TestSuite::Initialize(); CefSettings settings; - CefBrowserSettings browserDefaults; settings.multi_threaded_message_loop = true; - CefInitialize(settings, browserDefaults); + CefInitialize(settings); } virtual void Shutdown() { diff --git a/tests/unittests/v8_unittest.cc b/tests/unittests/v8_unittest.cc index 8695dd86d..b051b6b8e 100644 --- a/tests/unittests/v8_unittest.cc +++ b/tests/unittests/v8_unittest.cc @@ -12,7 +12,7 @@ namespace { bool g_V8TestV8HandlerExecuteCalled; bool g_V8TestV8HandlerExecute2Called; -class V8TestV8Handler : public CefThreadSafeBase +class V8TestV8Handler : public CefV8Handler { public: V8TestV8Handler(bool bindingTest) { binding_test_ = bindingTest; } @@ -213,6 +213,8 @@ public: } bool binding_test_; + + IMPLEMENT_REFCOUNTING(V8TestV8Handler); }; class V8TestHandler : public TestHandler @@ -220,7 +222,7 @@ class V8TestHandler : public TestHandler public: V8TestHandler(bool bindingTest) { binding_test_ = bindingTest; } - virtual void RunTest() + virtual void RunTest() OVERRIDE { std::string object; if(binding_test_) { @@ -249,24 +251,20 @@ public: CreateBrowser("http://tests/run.html"); } - virtual RetVal HandleLoadEnd(CefRefPtr browser, - CefRefPtr frame, - int httpStatusCode) + virtual void OnLoadEnd(CefRefPtr browser, + CefRefPtr frame, + int httpStatusCode) OVERRIDE { if(!browser->IsPopup() && frame->IsMain()) DestroyTest(); - return RV_CONTINUE; } - virtual RetVal HandleJSBinding(CefRefPtr browser, - CefRefPtr frame, - CefRefPtr object) + virtual void OnJSBinding(CefRefPtr browser, + CefRefPtr frame, + CefRefPtr object) OVERRIDE { - if(binding_test_) { + if(binding_test_) TestHandleJSBinding(browser, frame, object); - return RV_HANDLED; - } - return RV_CONTINUE; } void TestHandleJSBinding(CefRefPtr browser, @@ -376,7 +374,7 @@ public: const CefRefPtr value) = 0; }; -class DelegatingV8Handler : public CefThreadSafeBase +class DelegatingV8Handler : public CefV8Handler { public: DelegatingV8Handler(CefV8HandlerDelegate *delegate): @@ -397,9 +395,11 @@ public: private: CefV8HandlerDelegate *delegate_; + + IMPLEMENT_REFCOUNTING(DelegatingV8Handler); }; -class DelegatingV8Accessor: public CefThreadSafeBase +class DelegatingV8Accessor: public CefV8Accessor { public: DelegatingV8Accessor(CefV8HandlerDelegate *delegate) @@ -419,6 +419,8 @@ public: private: CefV8HandlerDelegate *delegate_; + + IMPLEMENT_REFCOUNTING(DelegatingV8Accessor); }; class TestContextHandler: public TestHandler, public CefV8HandlerDelegate @@ -426,7 +428,7 @@ class TestContextHandler: public TestHandler, public CefV8HandlerDelegate public: TestContextHandler() {} - virtual void RunTest() + virtual void RunTest() OVERRIDE { // Test Flow: // load main.html. @@ -526,16 +528,15 @@ public: CreateBrowser("http://tests/main.html"); } - virtual RetVal HandleLoadEnd(CefRefPtr browser, - CefRefPtr frame, - int httpStatusCode) + virtual void OnLoadEnd(CefRefPtr browser, + CefRefPtr frame, + int httpStatusCode) OVERRIDE { - return RV_CONTINUE; } - virtual RetVal HandleJSBinding(CefRefPtr browser, - CefRefPtr frame, - CefRefPtr object) + virtual void OnJSBinding(CefRefPtr browser, + CefRefPtr frame, + CefRefPtr object) OVERRIDE { CefRefPtr cc = CefV8Context::GetCurrentContext(); CefRefPtr currentBrowser = cc->GetBrowser(); @@ -579,8 +580,6 @@ public: V8_PROPERTY_ATTRIBUTE_NONE); object->SetValue("point", point); - - return RV_HANDLED; } void CallIFrame() diff --git a/tests/unittests/web_urlrequest_unittest.cc b/tests/unittests/web_urlrequest_unittest.cc index 3303e990b..3e80f2a20 100644 --- a/tests/unittests/web_urlrequest_unittest.cc +++ b/tests/unittests/web_urlrequest_unittest.cc @@ -45,7 +45,7 @@ public: cef_weburlrequest_state_t cancelAtState = WUR_STATE_UNSENT): cancelAtState_(cancelAtState), test_results_(tr) { } - virtual void RunTest() + virtual void RunTest() OVERRIDE { std::stringstream testHtml; testHtml << @@ -57,12 +57,11 @@ public: CreateBrowser("http://tests/run.html"); } - virtual RetVal HandleLoadEnd(CefRefPtr browser, - CefRefPtr frame, - int httpStatusCode) + virtual void OnLoadEnd(CefRefPtr browser, + CefRefPtr frame, + int httpStatusCode) { StartTest(); - return RV_CONTINUE; } void TestCompleted() @@ -77,8 +76,7 @@ public: TestResults& test_results_; }; -class TestWebURLRequestClient: - public CefThreadSafeBase +class TestWebURLRequestClient : public CefWebURLRequestClient { public: TestWebURLRequestClient(TestResults& tr, BrowserTestHandler* browser): @@ -243,6 +241,8 @@ protected: CefRefPtr requester_; CefRefPtr request_; std::string contents_; + + IMPLEMENT_REFCOUNTING(TestWebURLRequestClient); }; TEST(WebURLRequestTest, GET) diff --git a/tools/cef_parser.py b/tools/cef_parser.py index 2e33ec6ce..40b5d2417 100644 --- a/tools/cef_parser.py +++ b/tools/cef_parser.py @@ -1,4 +1,4 @@ -# Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +# 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. @@ -439,14 +439,15 @@ class obj_header: # extract classes p = re.compile('\n'+_cre_attrib+ '\nclass'+_cre_space+_cre_cfname+_cre_space+ - ':'+_cre_space+'public'+_cre_space+'CefBase'+ + ':'+_cre_space+'public'+_cre_space+'virtual'+ + _cre_space+'CefBase'+ '\n{(.*?)};', re.MULTILINE | re.DOTALL) list = p.findall(data) # build the class objects self.classes = [] for attrib, name, body in list: - comment = get_comment(data, name+' : public CefBase') + comment = get_comment(data, name+' : public virtual CefBase') self.classes.append( obj_class(self, attrib, name, body, comment)) diff --git a/tools/make_capi_header.py b/tools/make_capi_header.py index e0c6116e3..0f066cb3c 100644 --- a/tools/make_capi_header.py +++ b/tools/make_capi_header.py @@ -1,4 +1,4 @@ -# Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +# 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. @@ -45,7 +45,7 @@ def make_capi_header(header): # header string result = \ -"""// Copyright (c) 2010 Marshall A. Greenblatt. All rights reserved. +"""// Copyright (c) 2011 Marshall A. Greenblatt. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are diff --git a/tools/make_cpptoc_header.py b/tools/make_cpptoc_header.py index 9256e5aa7..7086ce9ab 100644 --- a/tools/make_cpptoc_header.py +++ b/tools/make_cpptoc_header.py @@ -1,4 +1,4 @@ -# Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +# 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. @@ -14,7 +14,7 @@ def make_cpptoc_header(header, clsname): capiname = cls.get_capi_name() result = \ -"""// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +"""// 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. // diff --git a/tools/make_cpptoc_impl.py b/tools/make_cpptoc_impl.py index 2e23bce01..1e1853539 100644 --- a/tools/make_cpptoc_impl.py +++ b/tools/make_cpptoc_impl.py @@ -1,4 +1,4 @@ -# Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +# 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. @@ -117,7 +117,7 @@ def make_cpptoc_impl(header, clsname, impl): # build the final output result = \ -"""// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +"""// 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. // @@ -144,7 +144,7 @@ def make_cpptoc_impl(header, clsname, impl): const += ' struct_.struct_.'+name+' = '+prefixname+'_'+name+';\n' const += '}\n\n'+ \ - '#ifdef _DEBUG\n'+ \ + '#ifndef NDEBUG\n'+ \ 'template<> long CefCppToC<'+clsname+'CppToC, '+clsname+', '+capiname+'>::DebugObjCt = 0;\n'+ \ '#endif\n' result += wrap_code(const) diff --git a/tools/make_ctocpp_header.py b/tools/make_ctocpp_header.py index a2e4ac10b..e84d9510c 100644 --- a/tools/make_ctocpp_header.py +++ b/tools/make_ctocpp_header.py @@ -1,4 +1,4 @@ -# Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +# 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. @@ -14,7 +14,7 @@ def make_ctocpp_header(header, clsname): capiname = cls.get_capi_name() result = \ -"""// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +"""// 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. // @@ -66,7 +66,7 @@ def make_ctocpp_header(header, clsname): funcs = cls.get_virtual_funcs() for func in funcs: - result += ' virtual '+func.get_cpp_proto()+';\n' + result += ' virtual '+func.get_cpp_proto()+' OVERRIDE;\n' result += '};\n\n' diff --git a/tools/make_ctocpp_impl.py b/tools/make_ctocpp_impl.py index fd52f495c..2d266bbbb 100644 --- a/tools/make_ctocpp_impl.py +++ b/tools/make_ctocpp_impl.py @@ -1,4 +1,4 @@ -# Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +# 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. @@ -107,7 +107,7 @@ def make_ctocpp_impl(header, clsname, impl): # build the final output result = \ -"""// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +"""// 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. // @@ -123,7 +123,7 @@ def make_ctocpp_impl(header, clsname, impl): result += includes+'\n'+resultingimpl+'\n' - result += wrap_code('#ifdef _DEBUG\n'+ \ + result += wrap_code('#ifndef NDEBUG\n'+ \ 'template<> long CefCToCpp<'+clsname+'CToCpp, '+clsname+', '+capiname+'>::DebugObjCt = 0;\n'+ \ '#endif\n')