diff --git a/Atom.xcodeproj/project.pbxproj b/Atom.xcodeproj/project.pbxproj index 1d199c755..9f65c9696 100644 --- a/Atom.xcodeproj/project.pbxproj +++ b/Atom.xcodeproj/project.pbxproj @@ -7,447 +7,1058 @@ objects = { /* Begin PBXBuildFile section */ - 040BDC9114D71A5600CEE2A4 /* JavaScriptCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 040BDC8E14D71A5600CEE2A4 /* JavaScriptCore.framework */; }; - 040BDC9314D71A5600CEE2A4 /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 040BDC9014D71A5600CEE2A4 /* WebKit.framework */; }; - 040BDC9414D71A6400CEE2A4 /* JavaScriptCore.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 040BDC8E14D71A5600CEE2A4 /* JavaScriptCore.framework */; }; - 040BDC9514D71A6400CEE2A4 /* WebCore.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 040BDC8F14D71A5600CEE2A4 /* WebCore.framework */; }; - 040BDC9614D71A6400CEE2A4 /* WebKit.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 040BDC9014D71A5600CEE2A4 /* WebKit.framework */; }; - 043D7E4C145794990078D710 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 043D7E4B145794990078D710 /* Cocoa.framework */; }; - 043D7E56145794990078D710 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 043D7E54145794990078D710 /* InfoPlist.strings */; }; - 043D7E58145794990078D710 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 043D7E57145794990078D710 /* main.m */; }; - 043D7E621457949A0078D710 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 043D7E601457949A0078D710 /* MainMenu.xib */; }; - 043D7E84145795B20078D710 /* BridgeSupportController.m in Sources */ = {isa = PBXBuildFile; fileRef = 043D7E6D145795B20078D710 /* BridgeSupportController.m */; }; - 043D7E85145795B20078D710 /* JSCocoaController.m in Sources */ = {isa = PBXBuildFile; fileRef = 043D7E70145795B20078D710 /* JSCocoaController.m */; }; - 043D7E86145795B20078D710 /* JSCocoaFFIArgument.m in Sources */ = {isa = PBXBuildFile; fileRef = 043D7E72145795B20078D710 /* JSCocoaFFIArgument.m */; }; - 043D7E87145795B20078D710 /* JSCocoaFFIClosure.m in Sources */ = {isa = PBXBuildFile; fileRef = 043D7E74145795B20078D710 /* JSCocoaFFIClosure.m */; }; - 043D7E88145795B20078D710 /* JSCocoaLib.m in Sources */ = {isa = PBXBuildFile; fileRef = 043D7E76145795B20078D710 /* JSCocoaLib.m */; }; - 043D7E89145795B20078D710 /* JSCocoaPrivateObject.m in Sources */ = {isa = PBXBuildFile; fileRef = 043D7E78145795B20078D710 /* JSCocoaPrivateObject.m */; }; - 043D7E8A145795B20078D710 /* UKFileWatcher.m in Sources */ = {isa = PBXBuildFile; fileRef = 043D7E7B145795B20078D710 /* UKFileWatcher.m */; }; - 043D7E8B145795B20078D710 /* UKFNSubscribeFileWatcher.m in Sources */ = {isa = PBXBuildFile; fileRef = 043D7E7D145795B20078D710 /* UKFNSubscribeFileWatcher.m */; }; - 043D7E8C145795B20078D710 /* UKKQueue.m in Sources */ = {isa = PBXBuildFile; fileRef = 043D7E7F145795B20078D710 /* UKKQueue.m */; }; - 043D7E8D145795B20078D710 /* UKMainThreadProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = 043D7E81145795B20078D710 /* UKMainThreadProxy.m */; }; - 043D7E8E145795B20078D710 /* AtomWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 043D7E83145795B20078D710 /* AtomWindow.xib */; }; - 043D7E94145795B70078D710 /* AtomApp.m in Sources */ = {isa = PBXBuildFile; fileRef = 043D7E91145795B70078D710 /* AtomApp.m */; }; - 043D7E95145795B70078D710 /* AtomController.m in Sources */ = {isa = PBXBuildFile; fileRef = 043D7E93145795B70078D710 /* AtomController.m */; }; - 047F260E145883B9006DC904 /* Icon.icns in Resources */ = {isa = PBXBuildFile; fileRef = 047F260D145883B9006DC904 /* Icon.icns */; }; - EC846C4114B529120021AF1F /* FileSystemHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = EC846C4014B529120021AF1F /* FileSystemHelper.m */; }; - ECBB172814A4F92400ACAAC1 /* AtomMenuItem.m in Sources */ = {isa = PBXBuildFile; fileRef = ECBB172714A4F92400ACAAC1 /* AtomMenuItem.m */; }; + 0487C91714FED5360045E5E3 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0487C91614FED5360045E5E3 /* Cocoa.framework */; }; + 0487C93714FED5FB0045E5E3 /* Atom.icns in Resources */ = {isa = PBXBuildFile; fileRef = 0487C93314FED5FB0045E5E3 /* Atom.icns */; }; + 0487C93814FED5FB0045E5E3 /* ClientWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 0487C93414FED5FB0045E5E3 /* ClientWindow.xib */; }; + 0487C93A14FED5FB0045E5E3 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 0487C93614FED5FB0045E5E3 /* MainMenu.xib */; }; + 0487CD9414FEE1330045E5E3 /* Atom.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0487C93D14FED6090045E5E3 /* Atom.mm */; }; + 0487CD9514FEE1340045E5E3 /* AtomController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0487C93F14FED6090045E5E3 /* AtomController.mm */; }; + 0487CD9614FEE1360045E5E3 /* client_handler.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0487C94114FED6090045E5E3 /* client_handler.mm */; }; + 0487CD9714FEE1380045E5E3 /* main.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0487C94214FED6090045E5E3 /* main.mm */; }; + 0487CD9814FEE13B0045E5E3 /* native_handler.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0487C94414FED6090045E5E3 /* native_handler.mm */; }; + 0487CD9A14FEE1730045E5E3 /* ffmpegsumo.so in Copy Required Chrome Frameworks */ = {isa = PBXBuildFile; fileRef = 0487CD6B14FEE0EC0045E5E3 /* ffmpegsumo.so */; }; + 0487CD9B14FEE1740045E5E3 /* libcef.dylib in Copy Required Chrome Frameworks */ = {isa = PBXBuildFile; fileRef = 0487CD6C14FEE0EC0045E5E3 /* libcef.dylib */; }; + 0487CD9F14FEE1D70045E5E3 /* libcef.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 0487CD6C14FEE0EC0045E5E3 /* libcef.dylib */; }; + 0487CDA014FEE1DA0045E5E3 /* liblibcef_wrapper.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0487CC8114FEDF990045E5E3 /* liblibcef_wrapper.a */; }; + 0487D12614FEE6D60045E5E3 /* app_cpptoc.cc in Sources */ = {isa = PBXBuildFile; fileRef = 0487D0B514FEE6D60045E5E3 /* app_cpptoc.cc */; }; + 0487D12714FEE6D60045E5E3 /* client_cpptoc.cc in Sources */ = {isa = PBXBuildFile; fileRef = 0487D0B814FEE6D60045E5E3 /* client_cpptoc.cc */; }; + 0487D12814FEE6D60045E5E3 /* content_filter_cpptoc.cc in Sources */ = {isa = PBXBuildFile; fileRef = 0487D0BA14FEE6D60045E5E3 /* content_filter_cpptoc.cc */; }; + 0487D12914FEE6D60045E5E3 /* cookie_visitor_cpptoc.cc in Sources */ = {isa = PBXBuildFile; fileRef = 0487D0BC14FEE6D60045E5E3 /* cookie_visitor_cpptoc.cc */; }; + 0487D12A14FEE6D60045E5E3 /* display_handler_cpptoc.cc in Sources */ = {isa = PBXBuildFile; fileRef = 0487D0BF14FEE6D60045E5E3 /* display_handler_cpptoc.cc */; }; + 0487D12B14FEE6D60045E5E3 /* domevent_listener_cpptoc.cc in Sources */ = {isa = PBXBuildFile; fileRef = 0487D0C114FEE6D60045E5E3 /* domevent_listener_cpptoc.cc */; }; + 0487D12C14FEE6D60045E5E3 /* domvisitor_cpptoc.cc in Sources */ = {isa = PBXBuildFile; fileRef = 0487D0C314FEE6D60045E5E3 /* domvisitor_cpptoc.cc */; }; + 0487D12D14FEE6D60045E5E3 /* download_handler_cpptoc.cc in Sources */ = {isa = PBXBuildFile; fileRef = 0487D0C514FEE6D60045E5E3 /* download_handler_cpptoc.cc */; }; + 0487D12E14FEE6D60045E5E3 /* drag_handler_cpptoc.cc in Sources */ = {isa = PBXBuildFile; fileRef = 0487D0C714FEE6D60045E5E3 /* drag_handler_cpptoc.cc */; }; + 0487D12F14FEE6D60045E5E3 /* find_handler_cpptoc.cc in Sources */ = {isa = PBXBuildFile; fileRef = 0487D0C914FEE6D60045E5E3 /* find_handler_cpptoc.cc */; }; + 0487D13014FEE6D60045E5E3 /* focus_handler_cpptoc.cc in Sources */ = {isa = PBXBuildFile; fileRef = 0487D0CB14FEE6D60045E5E3 /* focus_handler_cpptoc.cc */; }; + 0487D13114FEE6D60045E5E3 /* jsdialog_handler_cpptoc.cc in Sources */ = {isa = PBXBuildFile; fileRef = 0487D0CD14FEE6D60045E5E3 /* jsdialog_handler_cpptoc.cc */; }; + 0487D13214FEE6D60045E5E3 /* keyboard_handler_cpptoc.cc in Sources */ = {isa = PBXBuildFile; fileRef = 0487D0CF14FEE6D60045E5E3 /* keyboard_handler_cpptoc.cc */; }; + 0487D13314FEE6D60045E5E3 /* life_span_handler_cpptoc.cc in Sources */ = {isa = PBXBuildFile; fileRef = 0487D0D114FEE6D60045E5E3 /* life_span_handler_cpptoc.cc */; }; + 0487D13414FEE6D60045E5E3 /* load_handler_cpptoc.cc in Sources */ = {isa = PBXBuildFile; fileRef = 0487D0D314FEE6D60045E5E3 /* load_handler_cpptoc.cc */; }; + 0487D13514FEE6D60045E5E3 /* menu_handler_cpptoc.cc in Sources */ = {isa = PBXBuildFile; fileRef = 0487D0D514FEE6D60045E5E3 /* menu_handler_cpptoc.cc */; }; + 0487D13614FEE6D60045E5E3 /* print_handler_cpptoc.cc in Sources */ = {isa = PBXBuildFile; fileRef = 0487D0D714FEE6D60045E5E3 /* print_handler_cpptoc.cc */; }; + 0487D13714FEE6D60045E5E3 /* proxy_handler_cpptoc.cc in Sources */ = {isa = PBXBuildFile; fileRef = 0487D0D914FEE6D60045E5E3 /* proxy_handler_cpptoc.cc */; }; + 0487D13814FEE6D60045E5E3 /* read_handler_cpptoc.cc in Sources */ = {isa = PBXBuildFile; fileRef = 0487D0DB14FEE6D60045E5E3 /* read_handler_cpptoc.cc */; }; + 0487D13914FEE6D60045E5E3 /* render_handler_cpptoc.cc in Sources */ = {isa = PBXBuildFile; fileRef = 0487D0DD14FEE6D60045E5E3 /* render_handler_cpptoc.cc */; }; + 0487D13A14FEE6D60045E5E3 /* request_handler_cpptoc.cc in Sources */ = {isa = PBXBuildFile; fileRef = 0487D0DF14FEE6D60045E5E3 /* request_handler_cpptoc.cc */; }; + 0487D13B14FEE6D60045E5E3 /* scheme_handler_cpptoc.cc in Sources */ = {isa = PBXBuildFile; fileRef = 0487D0E114FEE6D60045E5E3 /* scheme_handler_cpptoc.cc */; }; + 0487D13C14FEE6D60045E5E3 /* scheme_handler_factory_cpptoc.cc in Sources */ = {isa = PBXBuildFile; fileRef = 0487D0E314FEE6D60045E5E3 /* scheme_handler_factory_cpptoc.cc */; }; + 0487D13D14FEE6D60045E5E3 /* storage_visitor_cpptoc.cc in Sources */ = {isa = PBXBuildFile; fileRef = 0487D0E514FEE6D60045E5E3 /* storage_visitor_cpptoc.cc */; }; + 0487D13E14FEE6D60045E5E3 /* task_cpptoc.cc in Sources */ = {isa = PBXBuildFile; fileRef = 0487D0E714FEE6D60045E5E3 /* task_cpptoc.cc */; }; + 0487D13F14FEE6D60045E5E3 /* v8accessor_cpptoc.cc in Sources */ = {isa = PBXBuildFile; fileRef = 0487D0E914FEE6D60045E5E3 /* v8accessor_cpptoc.cc */; }; + 0487D14014FEE6D60045E5E3 /* v8context_handler_cpptoc.cc in Sources */ = {isa = PBXBuildFile; fileRef = 0487D0EB14FEE6D60045E5E3 /* v8context_handler_cpptoc.cc */; }; + 0487D14114FEE6D60045E5E3 /* v8handler_cpptoc.cc in Sources */ = {isa = PBXBuildFile; fileRef = 0487D0ED14FEE6D60045E5E3 /* v8handler_cpptoc.cc */; }; + 0487D14214FEE6D60045E5E3 /* web_urlrequest_client_cpptoc.cc in Sources */ = {isa = PBXBuildFile; fileRef = 0487D0EF14FEE6D60045E5E3 /* web_urlrequest_client_cpptoc.cc */; }; + 0487D14314FEE6D60045E5E3 /* write_handler_cpptoc.cc in Sources */ = {isa = PBXBuildFile; fileRef = 0487D0F114FEE6D60045E5E3 /* write_handler_cpptoc.cc */; }; + 0487D14414FEE6D60045E5E3 /* browser_ctocpp.cc in Sources */ = {isa = PBXBuildFile; fileRef = 0487D0F514FEE6D60045E5E3 /* browser_ctocpp.cc */; }; + 0487D14514FEE6D60045E5E3 /* command_line_ctocpp.cc in Sources */ = {isa = PBXBuildFile; fileRef = 0487D0F714FEE6D60045E5E3 /* command_line_ctocpp.cc */; }; + 0487D14614FEE6D60045E5E3 /* domdocument_ctocpp.cc in Sources */ = {isa = PBXBuildFile; fileRef = 0487D0FA14FEE6D60045E5E3 /* domdocument_ctocpp.cc */; }; + 0487D14714FEE6D60045E5E3 /* domevent_ctocpp.cc in Sources */ = {isa = PBXBuildFile; fileRef = 0487D0FC14FEE6D60045E5E3 /* domevent_ctocpp.cc */; }; + 0487D14814FEE6D60045E5E3 /* domnode_ctocpp.cc in Sources */ = {isa = PBXBuildFile; fileRef = 0487D0FE14FEE6D60045E5E3 /* domnode_ctocpp.cc */; }; + 0487D14914FEE6D60045E5E3 /* drag_data_ctocpp.cc in Sources */ = {isa = PBXBuildFile; fileRef = 0487D10014FEE6D60045E5E3 /* drag_data_ctocpp.cc */; }; + 0487D14A14FEE6D60045E5E3 /* frame_ctocpp.cc in Sources */ = {isa = PBXBuildFile; fileRef = 0487D10214FEE6D60045E5E3 /* frame_ctocpp.cc */; }; + 0487D14B14FEE6D60045E5E3 /* post_data_ctocpp.cc in Sources */ = {isa = PBXBuildFile; fileRef = 0487D10414FEE6D60045E5E3 /* post_data_ctocpp.cc */; }; + 0487D14C14FEE6D60045E5E3 /* post_data_element_ctocpp.cc in Sources */ = {isa = PBXBuildFile; fileRef = 0487D10614FEE6D60045E5E3 /* post_data_element_ctocpp.cc */; }; + 0487D14D14FEE6D60045E5E3 /* request_ctocpp.cc in Sources */ = {isa = PBXBuildFile; fileRef = 0487D10814FEE6D60045E5E3 /* request_ctocpp.cc */; }; + 0487D14E14FEE6D60045E5E3 /* response_ctocpp.cc in Sources */ = {isa = PBXBuildFile; fileRef = 0487D10A14FEE6D60045E5E3 /* response_ctocpp.cc */; }; + 0487D14F14FEE6D60045E5E3 /* scheme_handler_callback_ctocpp.cc in Sources */ = {isa = PBXBuildFile; fileRef = 0487D10C14FEE6D60045E5E3 /* scheme_handler_callback_ctocpp.cc */; }; + 0487D15014FEE6D60045E5E3 /* stream_reader_ctocpp.cc in Sources */ = {isa = PBXBuildFile; fileRef = 0487D10E14FEE6D60045E5E3 /* stream_reader_ctocpp.cc */; }; + 0487D15114FEE6D60045E5E3 /* stream_writer_ctocpp.cc in Sources */ = {isa = PBXBuildFile; fileRef = 0487D11014FEE6D60045E5E3 /* stream_writer_ctocpp.cc */; }; + 0487D15214FEE6D60045E5E3 /* v8context_ctocpp.cc in Sources */ = {isa = PBXBuildFile; fileRef = 0487D11214FEE6D60045E5E3 /* v8context_ctocpp.cc */; }; + 0487D15314FEE6D60045E5E3 /* v8exception_ctocpp.cc in Sources */ = {isa = PBXBuildFile; fileRef = 0487D11414FEE6D60045E5E3 /* v8exception_ctocpp.cc */; }; + 0487D15414FEE6D60045E5E3 /* v8value_ctocpp.cc in Sources */ = {isa = PBXBuildFile; fileRef = 0487D11614FEE6D60045E5E3 /* v8value_ctocpp.cc */; }; + 0487D15514FEE6D60045E5E3 /* web_urlrequest_ctocpp.cc in Sources */ = {isa = PBXBuildFile; fileRef = 0487D11814FEE6D60045E5E3 /* web_urlrequest_ctocpp.cc */; }; + 0487D15614FEE6D60045E5E3 /* xml_reader_ctocpp.cc in Sources */ = {isa = PBXBuildFile; fileRef = 0487D11A14FEE6D60045E5E3 /* xml_reader_ctocpp.cc */; }; + 0487D15714FEE6D60045E5E3 /* zip_reader_ctocpp.cc in Sources */ = {isa = PBXBuildFile; fileRef = 0487D11C14FEE6D60045E5E3 /* zip_reader_ctocpp.cc */; }; + 0487D15814FEE6D60045E5E3 /* transfer_util.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0487D11E14FEE6D60045E5E3 /* transfer_util.cpp */; }; + 0487D15914FEE6D60045E5E3 /* cef_byte_read_handler.cc in Sources */ = {isa = PBXBuildFile; fileRef = 0487D12114FEE6D60045E5E3 /* cef_byte_read_handler.cc */; }; + 0487D15A14FEE6D60045E5E3 /* cef_xml_object.cc in Sources */ = {isa = PBXBuildFile; fileRef = 0487D12214FEE6D60045E5E3 /* cef_xml_object.cc */; }; + 0487D15B14FEE6D60045E5E3 /* cef_zip_archive.cc in Sources */ = {isa = PBXBuildFile; fileRef = 0487D12314FEE6D60045E5E3 /* cef_zip_archive.cc */; }; + 0487D15C14FEE6D60045E5E3 /* libcef_dll_wrapper.cc in Sources */ = {isa = PBXBuildFile; fileRef = 0487D12414FEE6D60045E5E3 /* libcef_dll_wrapper.cc */; }; + 0487D15D14FEE6D60045E5E3 /* libcef_dll_wrapper2.cc in Sources */ = {isa = PBXBuildFile; fileRef = 0487D12514FEE6D60045E5E3 /* libcef_dll_wrapper2.cc */; }; + 0487D15F14FEE7880045E5E3 /* resources in Resources */ = {isa = PBXBuildFile; fileRef = 0487D15E14FEE7880045E5E3 /* resources */; }; + 0487D16014FEE78E0045E5E3 /* resources in Copy Chrome Resources */ = {isa = PBXBuildFile; fileRef = 0487D15E14FEE7880045E5E3 /* resources */; }; /* End PBXBuildFile section */ +/* Begin PBXContainerItemProxy section */ + 0487CD6914FEE0BE0045E5E3 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 0487C90914FED5360045E5E3 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 0487CC8014FEDF990045E5E3; + remoteInfo = libcef_wrapper; + }; +/* End PBXContainerItemProxy section */ + /* Begin PBXCopyFilesBuildPhase section */ - 040BDC8A14D70E1100CEE2A4 /* CopyFiles */ = { + 0487CD9914FEE1500045E5E3 /* Copy Required Chrome Frameworks */ = { isa = PBXCopyFilesBuildPhase; buildActionMask = 2147483647; - dstPath = ""; - dstSubfolderSpec = 10; + dstPath = "$(EXECUTABLE_FOLDER_PATH)"; + dstSubfolderSpec = 16; files = ( - 040BDC9414D71A6400CEE2A4 /* JavaScriptCore.framework in CopyFiles */, - 040BDC9514D71A6400CEE2A4 /* WebCore.framework in CopyFiles */, - 040BDC9614D71A6400CEE2A4 /* WebKit.framework in CopyFiles */, + 0487CD9B14FEE1740045E5E3 /* libcef.dylib in Copy Required Chrome Frameworks */, + 0487CD9A14FEE1730045E5E3 /* ffmpegsumo.so in Copy Required Chrome Frameworks */, ); + name = "Copy Required Chrome Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; + 0487CD9C14FEE17D0045E5E3 /* Copy Chrome Resources */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = "$(CONTENTS_FOLDER_PATH)"; + dstSubfolderSpec = 16; + files = ( + 0487D16014FEE78E0045E5E3 /* resources in Copy Chrome Resources */, + ); + name = "Copy Chrome Resources"; runOnlyForDeploymentPostprocessing = 0; }; /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ - 040BDC8E14D71A5600CEE2A4 /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = frameworks/JavaScriptCore.framework; sourceTree = ""; }; - 040BDC8F14D71A5600CEE2A4 /* WebCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebCore.framework; path = frameworks/WebCore.framework; sourceTree = ""; }; - 040BDC9014D71A5600CEE2A4 /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = frameworks/WebKit.framework; sourceTree = ""; }; - 043D7E47145794990078D710 /* Atom.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Atom.app; sourceTree = BUILT_PRODUCTS_DIR; }; - 043D7E4B145794990078D710 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; }; - 043D7E4E145794990078D710 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; }; - 043D7E4F145794990078D710 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = System/Library/Frameworks/CoreData.framework; sourceTree = SDKROOT; }; - 043D7E50145794990078D710 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; - 043D7E53145794990078D710 /* Atom-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Atom-Info.plist"; sourceTree = ""; }; - 043D7E55145794990078D710 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; - 043D7E57145794990078D710 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; - 043D7E59145794990078D710 /* Atom-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Atom-Prefix.pch"; sourceTree = ""; }; - 043D7E611457949A0078D710 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/MainMenu.xib; sourceTree = ""; }; - 043D7E6C145795B20078D710 /* BridgeSupportController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BridgeSupportController.h; sourceTree = ""; }; - 043D7E6D145795B20078D710 /* BridgeSupportController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BridgeSupportController.m; sourceTree = ""; }; - 043D7E6E145795B20078D710 /* JSCocoa.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCocoa.h; sourceTree = ""; }; - 043D7E6F145795B20078D710 /* JSCocoaController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCocoaController.h; sourceTree = ""; }; - 043D7E70145795B20078D710 /* JSCocoaController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JSCocoaController.m; sourceTree = ""; }; - 043D7E71145795B20078D710 /* JSCocoaFFIArgument.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCocoaFFIArgument.h; sourceTree = ""; }; - 043D7E72145795B20078D710 /* JSCocoaFFIArgument.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JSCocoaFFIArgument.m; sourceTree = ""; }; - 043D7E73145795B20078D710 /* JSCocoaFFIClosure.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCocoaFFIClosure.h; sourceTree = ""; }; - 043D7E74145795B20078D710 /* JSCocoaFFIClosure.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JSCocoaFFIClosure.m; sourceTree = ""; }; - 043D7E75145795B20078D710 /* JSCocoaLib.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCocoaLib.h; sourceTree = ""; }; - 043D7E76145795B20078D710 /* JSCocoaLib.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JSCocoaLib.m; sourceTree = ""; }; - 043D7E77145795B20078D710 /* JSCocoaPrivateObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCocoaPrivateObject.h; sourceTree = ""; }; - 043D7E78145795B20078D710 /* JSCocoaPrivateObject.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JSCocoaPrivateObject.m; sourceTree = ""; }; - 043D7E7A145795B20078D710 /* UKFileWatcher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UKFileWatcher.h; sourceTree = ""; }; - 043D7E7B145795B20078D710 /* UKFileWatcher.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UKFileWatcher.m; sourceTree = ""; }; - 043D7E7C145795B20078D710 /* UKFNSubscribeFileWatcher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UKFNSubscribeFileWatcher.h; sourceTree = ""; }; - 043D7E7D145795B20078D710 /* UKFNSubscribeFileWatcher.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UKFNSubscribeFileWatcher.m; sourceTree = ""; }; - 043D7E7E145795B20078D710 /* UKKQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UKKQueue.h; sourceTree = ""; }; - 043D7E7F145795B20078D710 /* UKKQueue.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UKKQueue.m; sourceTree = ""; }; - 043D7E80145795B20078D710 /* UKMainThreadProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UKMainThreadProxy.h; sourceTree = ""; }; - 043D7E81145795B20078D710 /* UKMainThreadProxy.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UKMainThreadProxy.m; sourceTree = ""; }; - 043D7E83145795B20078D710 /* AtomWindow.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = AtomWindow.xib; path = xibs/AtomWindow.xib; sourceTree = ""; }; - 043D7E90145795B70078D710 /* AtomApp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AtomApp.h; path = Classes/AtomApp.h; sourceTree = ""; }; - 043D7E91145795B70078D710 /* AtomApp.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AtomApp.m; path = Classes/AtomApp.m; sourceTree = ""; }; - 043D7E92145795B70078D710 /* AtomController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AtomController.h; path = Classes/AtomController.h; sourceTree = ""; }; - 043D7E93145795B70078D710 /* AtomController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AtomController.m; path = Classes/AtomController.m; sourceTree = ""; }; - 047F260D145883B9006DC904 /* Icon.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = Icon.icns; sourceTree = ""; }; - EC846C3F14B529120021AF1F /* FileSystemHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FileSystemHelper.h; path = Classes/FileSystemHelper.h; sourceTree = ""; }; - EC846C4014B529120021AF1F /* FileSystemHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = FileSystemHelper.m; path = Classes/FileSystemHelper.m; sourceTree = ""; }; - ECBB172614A4F92400ACAAC1 /* AtomMenuItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AtomMenuItem.h; path = Classes/AtomMenuItem.h; sourceTree = ""; }; - ECBB172714A4F92400ACAAC1 /* AtomMenuItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AtomMenuItem.m; path = Classes/AtomMenuItem.m; sourceTree = ""; }; + 042180E614FF080D00DF25EA /* BrowserDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BrowserDelegate.h; sourceTree = ""; }; + 0487C91214FED5360045E5E3 /* Atom.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Atom.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 0487C91614FED5360045E5E3 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; }; + 0487C91914FED5360045E5E3 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; }; + 0487C91A14FED5360045E5E3 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = System/Library/Frameworks/CoreData.framework; sourceTree = SDKROOT; }; + 0487C91B14FED5360045E5E3 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; + 0487C93314FED5FB0045E5E3 /* Atom.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = Atom.icns; sourceTree = ""; }; + 0487C93414FED5FB0045E5E3 /* ClientWindow.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ClientWindow.xib; sourceTree = ""; }; + 0487C93514FED5FB0045E5E3 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 0487C93614FED5FB0045E5E3 /* MainMenu.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MainMenu.xib; sourceTree = ""; }; + 0487C93C14FED6090045E5E3 /* Atom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Atom.h; sourceTree = ""; }; + 0487C93D14FED6090045E5E3 /* Atom.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Atom.mm; sourceTree = ""; }; + 0487C93E14FED6090045E5E3 /* AtomController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AtomController.h; sourceTree = ""; }; + 0487C93F14FED6090045E5E3 /* AtomController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AtomController.mm; sourceTree = ""; }; + 0487C94014FED6090045E5E3 /* client_handler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = client_handler.h; sourceTree = ""; }; + 0487C94114FED6090045E5E3 /* client_handler.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = client_handler.mm; sourceTree = ""; }; + 0487C94214FED6090045E5E3 /* main.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = main.mm; sourceTree = ""; }; + 0487C94314FED6090045E5E3 /* native_handler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = native_handler.h; sourceTree = ""; }; + 0487C94414FED6090045E5E3 /* native_handler.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = native_handler.mm; sourceTree = ""; }; + 0487CC8114FEDF990045E5E3 /* liblibcef_wrapper.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = liblibcef_wrapper.a; sourceTree = BUILT_PRODUCTS_DIR; }; + 0487CD6B14FEE0EC0045E5E3 /* ffmpegsumo.so */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.bundle"; name = ffmpegsumo.so; path = frameworks/ffmpegsumo.so; sourceTree = ""; }; + 0487CD6C14FEE0EC0045E5E3 /* libcef.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libcef.dylib; path = frameworks/libcef.dylib; sourceTree = ""; }; + 0487CF3614FEE5C40045E5E3 /* cef.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = cef.h; sourceTree = ""; }; + 0487CF3714FEE5C40045E5E3 /* cef_application_mac.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = cef_application_mac.h; sourceTree = ""; }; + 0487CF3814FEE5C40045E5E3 /* cef_capi.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = cef_capi.h; sourceTree = ""; }; + 0487CF3914FEE5C40045E5E3 /* cef_nplugin.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = cef_nplugin.h; sourceTree = ""; }; + 0487CF3A14FEE5C40045E5E3 /* cef_nplugin_capi.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = cef_nplugin_capi.h; sourceTree = ""; }; + 0487CF3B14FEE5C40045E5E3 /* cef_runnable.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = cef_runnable.h; sourceTree = ""; }; + 0487CF3C14FEE5C40045E5E3 /* cef_version.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = cef_version.h; sourceTree = ""; }; + 0487CF3D14FEE5C40045E5E3 /* cef_wrapper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = cef_wrapper.h; sourceTree = ""; }; + 0487CF3F14FEE5C40045E5E3 /* cef_build.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = cef_build.h; sourceTree = ""; }; + 0487CF4014FEE5C40045E5E3 /* cef_export.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = cef_export.h; sourceTree = ""; }; + 0487CF4114FEE5C40045E5E3 /* cef_mac.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = cef_mac.h; sourceTree = ""; }; + 0487CF4214FEE5C40045E5E3 /* cef_nplugin_types.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = cef_nplugin_types.h; sourceTree = ""; }; + 0487CF4314FEE5C40045E5E3 /* cef_ptr.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = cef_ptr.h; sourceTree = ""; }; + 0487CF4414FEE5C40045E5E3 /* cef_string.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = cef_string.h; sourceTree = ""; }; + 0487CF4514FEE5C40045E5E3 /* cef_string_list.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = cef_string_list.h; sourceTree = ""; }; + 0487CF4614FEE5C40045E5E3 /* cef_string_map.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = cef_string_map.h; sourceTree = ""; }; + 0487CF4714FEE5C40045E5E3 /* cef_string_multimap.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = cef_string_multimap.h; sourceTree = ""; }; + 0487CF4814FEE5C40045E5E3 /* cef_string_types.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = cef_string_types.h; sourceTree = ""; }; + 0487CF4914FEE5C40045E5E3 /* cef_string_wrappers.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = cef_string_wrappers.h; sourceTree = ""; }; + 0487CF4A14FEE5C40045E5E3 /* cef_time.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = cef_time.h; sourceTree = ""; }; + 0487CF4B14FEE5C40045E5E3 /* cef_tuple.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = cef_tuple.h; sourceTree = ""; }; + 0487CF4C14FEE5C40045E5E3 /* cef_types.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = cef_types.h; sourceTree = ""; }; + 0487CF4D14FEE5C40045E5E3 /* cef_types_mac.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = cef_types_mac.h; sourceTree = ""; }; + 0487CF4E14FEE5C40045E5E3 /* cef_types_wrappers.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = cef_types_wrappers.h; sourceTree = ""; }; + 0487CF5014FEE5C40045E5E3 /* basictypes.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = basictypes.h; sourceTree = ""; }; + 0487CF5114FEE5C40045E5E3 /* build_config.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = build_config.h; sourceTree = ""; }; + 0487CF5214FEE5C40045E5E3 /* npapi.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = npapi.h; sourceTree = ""; }; + 0487CF5314FEE5C40045E5E3 /* npapi_extensions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = npapi_extensions.h; sourceTree = ""; }; + 0487CF5414FEE5C40045E5E3 /* npfunctions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = npfunctions.h; sourceTree = ""; }; + 0487CF5514FEE5C40045E5E3 /* nphostapi.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = nphostapi.h; sourceTree = ""; }; + 0487CF5614FEE5C40045E5E3 /* npruntime.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = npruntime.h; sourceTree = ""; }; + 0487CF5714FEE5C40045E5E3 /* nptypes.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = nptypes.h; sourceTree = ""; }; + 0487CF5814FEE5C40045E5E3 /* port.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = port.h; sourceTree = ""; }; + 0487CF5914FEE5C40045E5E3 /* README-TRANSFER.txt */ = {isa = PBXFileReference; lastKnownFileType = text; path = "README-TRANSFER.txt"; sourceTree = ""; }; + 0487D0B314FEE6D60045E5E3 /* cef_logging.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cef_logging.h; sourceTree = ""; }; + 0487D0B514FEE6D60045E5E3 /* app_cpptoc.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = app_cpptoc.cc; sourceTree = ""; }; + 0487D0B614FEE6D60045E5E3 /* app_cpptoc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = app_cpptoc.h; sourceTree = ""; }; + 0487D0B714FEE6D60045E5E3 /* base_cpptoc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = base_cpptoc.h; sourceTree = ""; }; + 0487D0B814FEE6D60045E5E3 /* client_cpptoc.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = client_cpptoc.cc; sourceTree = ""; }; + 0487D0B914FEE6D60045E5E3 /* client_cpptoc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = client_cpptoc.h; sourceTree = ""; }; + 0487D0BA14FEE6D60045E5E3 /* content_filter_cpptoc.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = content_filter_cpptoc.cc; sourceTree = ""; }; + 0487D0BB14FEE6D60045E5E3 /* content_filter_cpptoc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = content_filter_cpptoc.h; sourceTree = ""; }; + 0487D0BC14FEE6D60045E5E3 /* cookie_visitor_cpptoc.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cookie_visitor_cpptoc.cc; sourceTree = ""; }; + 0487D0BD14FEE6D60045E5E3 /* cookie_visitor_cpptoc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cookie_visitor_cpptoc.h; sourceTree = ""; }; + 0487D0BE14FEE6D60045E5E3 /* cpptoc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cpptoc.h; sourceTree = ""; }; + 0487D0BF14FEE6D60045E5E3 /* display_handler_cpptoc.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = display_handler_cpptoc.cc; sourceTree = ""; }; + 0487D0C014FEE6D60045E5E3 /* display_handler_cpptoc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = display_handler_cpptoc.h; sourceTree = ""; }; + 0487D0C114FEE6D60045E5E3 /* domevent_listener_cpptoc.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = domevent_listener_cpptoc.cc; sourceTree = ""; }; + 0487D0C214FEE6D60045E5E3 /* domevent_listener_cpptoc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = domevent_listener_cpptoc.h; sourceTree = ""; }; + 0487D0C314FEE6D60045E5E3 /* domvisitor_cpptoc.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = domvisitor_cpptoc.cc; sourceTree = ""; }; + 0487D0C414FEE6D60045E5E3 /* domvisitor_cpptoc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = domvisitor_cpptoc.h; sourceTree = ""; }; + 0487D0C514FEE6D60045E5E3 /* download_handler_cpptoc.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = download_handler_cpptoc.cc; sourceTree = ""; }; + 0487D0C614FEE6D60045E5E3 /* download_handler_cpptoc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = download_handler_cpptoc.h; sourceTree = ""; }; + 0487D0C714FEE6D60045E5E3 /* drag_handler_cpptoc.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = drag_handler_cpptoc.cc; sourceTree = ""; }; + 0487D0C814FEE6D60045E5E3 /* drag_handler_cpptoc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = drag_handler_cpptoc.h; sourceTree = ""; }; + 0487D0C914FEE6D60045E5E3 /* find_handler_cpptoc.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = find_handler_cpptoc.cc; sourceTree = ""; }; + 0487D0CA14FEE6D60045E5E3 /* find_handler_cpptoc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = find_handler_cpptoc.h; sourceTree = ""; }; + 0487D0CB14FEE6D60045E5E3 /* focus_handler_cpptoc.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = focus_handler_cpptoc.cc; sourceTree = ""; }; + 0487D0CC14FEE6D60045E5E3 /* focus_handler_cpptoc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = focus_handler_cpptoc.h; sourceTree = ""; }; + 0487D0CD14FEE6D60045E5E3 /* jsdialog_handler_cpptoc.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jsdialog_handler_cpptoc.cc; sourceTree = ""; }; + 0487D0CE14FEE6D60045E5E3 /* jsdialog_handler_cpptoc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsdialog_handler_cpptoc.h; sourceTree = ""; }; + 0487D0CF14FEE6D60045E5E3 /* keyboard_handler_cpptoc.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = keyboard_handler_cpptoc.cc; sourceTree = ""; }; + 0487D0D014FEE6D60045E5E3 /* keyboard_handler_cpptoc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = keyboard_handler_cpptoc.h; sourceTree = ""; }; + 0487D0D114FEE6D60045E5E3 /* life_span_handler_cpptoc.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = life_span_handler_cpptoc.cc; sourceTree = ""; }; + 0487D0D214FEE6D60045E5E3 /* life_span_handler_cpptoc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = life_span_handler_cpptoc.h; sourceTree = ""; }; + 0487D0D314FEE6D60045E5E3 /* load_handler_cpptoc.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = load_handler_cpptoc.cc; sourceTree = ""; }; + 0487D0D414FEE6D60045E5E3 /* load_handler_cpptoc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = load_handler_cpptoc.h; sourceTree = ""; }; + 0487D0D514FEE6D60045E5E3 /* menu_handler_cpptoc.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = menu_handler_cpptoc.cc; sourceTree = ""; }; + 0487D0D614FEE6D60045E5E3 /* menu_handler_cpptoc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = menu_handler_cpptoc.h; sourceTree = ""; }; + 0487D0D714FEE6D60045E5E3 /* print_handler_cpptoc.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = print_handler_cpptoc.cc; sourceTree = ""; }; + 0487D0D814FEE6D60045E5E3 /* print_handler_cpptoc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = print_handler_cpptoc.h; sourceTree = ""; }; + 0487D0D914FEE6D60045E5E3 /* proxy_handler_cpptoc.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = proxy_handler_cpptoc.cc; sourceTree = ""; }; + 0487D0DA14FEE6D60045E5E3 /* proxy_handler_cpptoc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = proxy_handler_cpptoc.h; sourceTree = ""; }; + 0487D0DB14FEE6D60045E5E3 /* read_handler_cpptoc.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = read_handler_cpptoc.cc; sourceTree = ""; }; + 0487D0DC14FEE6D60045E5E3 /* read_handler_cpptoc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = read_handler_cpptoc.h; sourceTree = ""; }; + 0487D0DD14FEE6D60045E5E3 /* render_handler_cpptoc.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = render_handler_cpptoc.cc; sourceTree = ""; }; + 0487D0DE14FEE6D60045E5E3 /* render_handler_cpptoc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = render_handler_cpptoc.h; sourceTree = ""; }; + 0487D0DF14FEE6D60045E5E3 /* request_handler_cpptoc.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = request_handler_cpptoc.cc; sourceTree = ""; }; + 0487D0E014FEE6D60045E5E3 /* request_handler_cpptoc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = request_handler_cpptoc.h; sourceTree = ""; }; + 0487D0E114FEE6D60045E5E3 /* scheme_handler_cpptoc.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = scheme_handler_cpptoc.cc; sourceTree = ""; }; + 0487D0E214FEE6D60045E5E3 /* scheme_handler_cpptoc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = scheme_handler_cpptoc.h; sourceTree = ""; }; + 0487D0E314FEE6D60045E5E3 /* scheme_handler_factory_cpptoc.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = scheme_handler_factory_cpptoc.cc; sourceTree = ""; }; + 0487D0E414FEE6D60045E5E3 /* scheme_handler_factory_cpptoc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = scheme_handler_factory_cpptoc.h; sourceTree = ""; }; + 0487D0E514FEE6D60045E5E3 /* storage_visitor_cpptoc.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = storage_visitor_cpptoc.cc; sourceTree = ""; }; + 0487D0E614FEE6D60045E5E3 /* storage_visitor_cpptoc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = storage_visitor_cpptoc.h; sourceTree = ""; }; + 0487D0E714FEE6D60045E5E3 /* task_cpptoc.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = task_cpptoc.cc; sourceTree = ""; }; + 0487D0E814FEE6D60045E5E3 /* task_cpptoc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = task_cpptoc.h; sourceTree = ""; }; + 0487D0E914FEE6D60045E5E3 /* v8accessor_cpptoc.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = v8accessor_cpptoc.cc; sourceTree = ""; }; + 0487D0EA14FEE6D60045E5E3 /* v8accessor_cpptoc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = v8accessor_cpptoc.h; sourceTree = ""; }; + 0487D0EB14FEE6D60045E5E3 /* v8context_handler_cpptoc.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = v8context_handler_cpptoc.cc; sourceTree = ""; }; + 0487D0EC14FEE6D60045E5E3 /* v8context_handler_cpptoc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = v8context_handler_cpptoc.h; sourceTree = ""; }; + 0487D0ED14FEE6D60045E5E3 /* v8handler_cpptoc.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = v8handler_cpptoc.cc; sourceTree = ""; }; + 0487D0EE14FEE6D60045E5E3 /* v8handler_cpptoc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = v8handler_cpptoc.h; sourceTree = ""; }; + 0487D0EF14FEE6D60045E5E3 /* web_urlrequest_client_cpptoc.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = web_urlrequest_client_cpptoc.cc; sourceTree = ""; }; + 0487D0F014FEE6D60045E5E3 /* web_urlrequest_client_cpptoc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = web_urlrequest_client_cpptoc.h; sourceTree = ""; }; + 0487D0F114FEE6D60045E5E3 /* write_handler_cpptoc.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = write_handler_cpptoc.cc; sourceTree = ""; }; + 0487D0F214FEE6D60045E5E3 /* write_handler_cpptoc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = write_handler_cpptoc.h; sourceTree = ""; }; + 0487D0F414FEE6D60045E5E3 /* base_ctocpp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = base_ctocpp.h; sourceTree = ""; }; + 0487D0F514FEE6D60045E5E3 /* browser_ctocpp.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = browser_ctocpp.cc; sourceTree = ""; }; + 0487D0F614FEE6D60045E5E3 /* browser_ctocpp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = browser_ctocpp.h; sourceTree = ""; }; + 0487D0F714FEE6D60045E5E3 /* command_line_ctocpp.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = command_line_ctocpp.cc; sourceTree = ""; }; + 0487D0F814FEE6D60045E5E3 /* command_line_ctocpp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = command_line_ctocpp.h; sourceTree = ""; }; + 0487D0F914FEE6D60045E5E3 /* ctocpp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ctocpp.h; sourceTree = ""; }; + 0487D0FA14FEE6D60045E5E3 /* domdocument_ctocpp.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = domdocument_ctocpp.cc; sourceTree = ""; }; + 0487D0FB14FEE6D60045E5E3 /* domdocument_ctocpp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = domdocument_ctocpp.h; sourceTree = ""; }; + 0487D0FC14FEE6D60045E5E3 /* domevent_ctocpp.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = domevent_ctocpp.cc; sourceTree = ""; }; + 0487D0FD14FEE6D60045E5E3 /* domevent_ctocpp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = domevent_ctocpp.h; sourceTree = ""; }; + 0487D0FE14FEE6D60045E5E3 /* domnode_ctocpp.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = domnode_ctocpp.cc; sourceTree = ""; }; + 0487D0FF14FEE6D60045E5E3 /* domnode_ctocpp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = domnode_ctocpp.h; sourceTree = ""; }; + 0487D10014FEE6D60045E5E3 /* drag_data_ctocpp.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = drag_data_ctocpp.cc; sourceTree = ""; }; + 0487D10114FEE6D60045E5E3 /* drag_data_ctocpp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = drag_data_ctocpp.h; sourceTree = ""; }; + 0487D10214FEE6D60045E5E3 /* frame_ctocpp.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = frame_ctocpp.cc; sourceTree = ""; }; + 0487D10314FEE6D60045E5E3 /* frame_ctocpp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = frame_ctocpp.h; sourceTree = ""; }; + 0487D10414FEE6D60045E5E3 /* post_data_ctocpp.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = post_data_ctocpp.cc; sourceTree = ""; }; + 0487D10514FEE6D60045E5E3 /* post_data_ctocpp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = post_data_ctocpp.h; sourceTree = ""; }; + 0487D10614FEE6D60045E5E3 /* post_data_element_ctocpp.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = post_data_element_ctocpp.cc; sourceTree = ""; }; + 0487D10714FEE6D60045E5E3 /* post_data_element_ctocpp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = post_data_element_ctocpp.h; sourceTree = ""; }; + 0487D10814FEE6D60045E5E3 /* request_ctocpp.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = request_ctocpp.cc; sourceTree = ""; }; + 0487D10914FEE6D60045E5E3 /* request_ctocpp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = request_ctocpp.h; sourceTree = ""; }; + 0487D10A14FEE6D60045E5E3 /* response_ctocpp.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = response_ctocpp.cc; sourceTree = ""; }; + 0487D10B14FEE6D60045E5E3 /* response_ctocpp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = response_ctocpp.h; sourceTree = ""; }; + 0487D10C14FEE6D60045E5E3 /* scheme_handler_callback_ctocpp.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = scheme_handler_callback_ctocpp.cc; sourceTree = ""; }; + 0487D10D14FEE6D60045E5E3 /* scheme_handler_callback_ctocpp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = scheme_handler_callback_ctocpp.h; sourceTree = ""; }; + 0487D10E14FEE6D60045E5E3 /* stream_reader_ctocpp.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = stream_reader_ctocpp.cc; sourceTree = ""; }; + 0487D10F14FEE6D60045E5E3 /* stream_reader_ctocpp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = stream_reader_ctocpp.h; sourceTree = ""; }; + 0487D11014FEE6D60045E5E3 /* stream_writer_ctocpp.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = stream_writer_ctocpp.cc; sourceTree = ""; }; + 0487D11114FEE6D60045E5E3 /* stream_writer_ctocpp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = stream_writer_ctocpp.h; sourceTree = ""; }; + 0487D11214FEE6D60045E5E3 /* v8context_ctocpp.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = v8context_ctocpp.cc; sourceTree = ""; }; + 0487D11314FEE6D60045E5E3 /* v8context_ctocpp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = v8context_ctocpp.h; sourceTree = ""; }; + 0487D11414FEE6D60045E5E3 /* v8exception_ctocpp.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = v8exception_ctocpp.cc; sourceTree = ""; }; + 0487D11514FEE6D60045E5E3 /* v8exception_ctocpp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = v8exception_ctocpp.h; sourceTree = ""; }; + 0487D11614FEE6D60045E5E3 /* v8value_ctocpp.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = v8value_ctocpp.cc; sourceTree = ""; }; + 0487D11714FEE6D60045E5E3 /* v8value_ctocpp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = v8value_ctocpp.h; sourceTree = ""; }; + 0487D11814FEE6D60045E5E3 /* web_urlrequest_ctocpp.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = web_urlrequest_ctocpp.cc; sourceTree = ""; }; + 0487D11914FEE6D60045E5E3 /* web_urlrequest_ctocpp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = web_urlrequest_ctocpp.h; sourceTree = ""; }; + 0487D11A14FEE6D60045E5E3 /* xml_reader_ctocpp.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = xml_reader_ctocpp.cc; sourceTree = ""; }; + 0487D11B14FEE6D60045E5E3 /* xml_reader_ctocpp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = xml_reader_ctocpp.h; sourceTree = ""; }; + 0487D11C14FEE6D60045E5E3 /* zip_reader_ctocpp.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = zip_reader_ctocpp.cc; sourceTree = ""; }; + 0487D11D14FEE6D60045E5E3 /* zip_reader_ctocpp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = zip_reader_ctocpp.h; sourceTree = ""; }; + 0487D11E14FEE6D60045E5E3 /* transfer_util.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = transfer_util.cpp; sourceTree = ""; }; + 0487D11F14FEE6D60045E5E3 /* transfer_util.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = transfer_util.h; sourceTree = ""; }; + 0487D12114FEE6D60045E5E3 /* cef_byte_read_handler.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cef_byte_read_handler.cc; sourceTree = ""; }; + 0487D12214FEE6D60045E5E3 /* cef_xml_object.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cef_xml_object.cc; sourceTree = ""; }; + 0487D12314FEE6D60045E5E3 /* cef_zip_archive.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cef_zip_archive.cc; sourceTree = ""; }; + 0487D12414FEE6D60045E5E3 /* libcef_dll_wrapper.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = libcef_dll_wrapper.cc; sourceTree = ""; }; + 0487D12514FEE6D60045E5E3 /* libcef_dll_wrapper2.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = libcef_dll_wrapper2.cc; sourceTree = ""; }; + 0487D15E14FEE7880045E5E3 /* resources */ = {isa = PBXFileReference; lastKnownFileType = folder; path = resources; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ - 043D7E44145794990078D710 /* Frameworks */ = { + 0487C90F14FED5360045E5E3 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 0487CDA014FEE1DA0045E5E3 /* liblibcef_wrapper.a in Frameworks */, + 0487C91714FED5360045E5E3 /* Cocoa.framework in Frameworks */, + 0487CD9F14FEE1D70045E5E3 /* libcef.dylib in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 0487CC7E14FEDF990045E5E3 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 043D7E4C145794990078D710 /* Cocoa.framework in Frameworks */, - 040BDC9114D71A5600CEE2A4 /* JavaScriptCore.framework in Frameworks */, - 040BDC9314D71A5600CEE2A4 /* WebKit.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ - 043D7E3C145794990078D710 = { + 042180E71500266500DF25EA /* cef */ = { isa = PBXGroup; children = ( - 043D7E51145794990078D710 /* Atom */, - 043D7E4A145794990078D710 /* Frameworks */, - 043D7E48145794990078D710 /* Products */, + 0487D0B214FEE6D60045E5E3 /* libcef_wrapper */, + 0487CF3514FEE5C40045E5E3 /* include */, + ); + name = cef; + path = Atom; + sourceTree = ""; + }; + 0487C90714FED5360045E5E3 = { + isa = PBXGroup; + children = ( + 0487C91C14FED5360045E5E3 /* Atom */, + 042180E71500266500DF25EA /* cef */, + 0487C91514FED5360045E5E3 /* frameworks */, + 0487C91314FED5360045E5E3 /* Products */, ); sourceTree = ""; }; - 043D7E48145794990078D710 /* Products */ = { + 0487C91314FED5360045E5E3 /* Products */ = { isa = PBXGroup; children = ( - 043D7E47145794990078D710 /* Atom.app */, + 0487C91214FED5360045E5E3 /* Atom.app */, + 0487CC8114FEDF990045E5E3 /* liblibcef_wrapper.a */, ); name = Products; sourceTree = ""; }; - 043D7E4A145794990078D710 /* Frameworks */ = { + 0487C91514FED5360045E5E3 /* frameworks */ = { isa = PBXGroup; children = ( - 040BDC8E14D71A5600CEE2A4 /* JavaScriptCore.framework */, - 040BDC8F14D71A5600CEE2A4 /* WebCore.framework */, - 040BDC9014D71A5600CEE2A4 /* WebKit.framework */, - 043D7E4B145794990078D710 /* Cocoa.framework */, - 043D7E4D145794990078D710 /* Other Frameworks */, + 0487CD6B14FEE0EC0045E5E3 /* ffmpegsumo.so */, + 0487CD6C14FEE0EC0045E5E3 /* libcef.dylib */, + 0487C91614FED5360045E5E3 /* Cocoa.framework */, + 0487C91814FED5360045E5E3 /* Other Frameworks */, ); - name = Frameworks; + name = frameworks; sourceTree = ""; }; - 043D7E4D145794990078D710 /* Other Frameworks */ = { + 0487C91814FED5360045E5E3 /* Other Frameworks */ = { isa = PBXGroup; children = ( - 043D7E4E145794990078D710 /* AppKit.framework */, - 043D7E4F145794990078D710 /* CoreData.framework */, - 043D7E50145794990078D710 /* Foundation.framework */, + 0487C91914FED5360045E5E3 /* AppKit.framework */, + 0487C91A14FED5360045E5E3 /* CoreData.framework */, + 0487C91B14FED5360045E5E3 /* Foundation.framework */, ); name = "Other Frameworks"; sourceTree = ""; }; - 043D7E51145794990078D710 /* Atom */ = { + 0487C91C14FED5360045E5E3 /* Atom */ = { isa = PBXGroup; children = ( - 043D7E90145795B70078D710 /* AtomApp.h */, - 043D7E91145795B70078D710 /* AtomApp.m */, - 043D7E92145795B70078D710 /* AtomController.h */, - 043D7E93145795B70078D710 /* AtomController.m */, - ECBB172614A4F92400ACAAC1 /* AtomMenuItem.h */, - ECBB172714A4F92400ACAAC1 /* AtomMenuItem.m */, - EC846C3F14B529120021AF1F /* FileSystemHelper.h */, - EC846C4014B529120021AF1F /* FileSystemHelper.m */, - 043D7E6B145795B20078D710 /* JSCocoa */, - 043D7E79145795B20078D710 /* UKKQueue */, - 043D7E52145794990078D710 /* Supporting Files */, + 0487C91D14FED5360045E5E3 /* Supporting Files */, + 0487C93B14FED6090045E5E3 /* src */, ); path = Atom; sourceTree = ""; }; - 043D7E52145794990078D710 /* Supporting Files */ = { + 0487C91D14FED5360045E5E3 /* Supporting Files */ = { isa = PBXGroup; children = ( - 047F260D145883B9006DC904 /* Icon.icns */, - 043D7E601457949A0078D710 /* MainMenu.xib */, - 043D7E83145795B20078D710 /* AtomWindow.xib */, - 043D7E53145794990078D710 /* Atom-Info.plist */, - 043D7E54145794990078D710 /* InfoPlist.strings */, - 043D7E57145794990078D710 /* main.m */, - 043D7E59145794990078D710 /* Atom-Prefix.pch */, + 0487D15E14FEE7880045E5E3 /* resources */, + 0487C93314FED5FB0045E5E3 /* Atom.icns */, + 0487C93414FED5FB0045E5E3 /* ClientWindow.xib */, + 0487C93514FED5FB0045E5E3 /* Info.plist */, + 0487C93614FED5FB0045E5E3 /* MainMenu.xib */, ); name = "Supporting Files"; sourceTree = ""; }; - 043D7E6B145795B20078D710 /* JSCocoa */ = { + 0487C93B14FED6090045E5E3 /* src */ = { isa = PBXGroup; children = ( - 043D7E6C145795B20078D710 /* BridgeSupportController.h */, - 043D7E6D145795B20078D710 /* BridgeSupportController.m */, - 043D7E6E145795B20078D710 /* JSCocoa.h */, - 043D7E6F145795B20078D710 /* JSCocoaController.h */, - 043D7E70145795B20078D710 /* JSCocoaController.m */, - 043D7E71145795B20078D710 /* JSCocoaFFIArgument.h */, - 043D7E72145795B20078D710 /* JSCocoaFFIArgument.m */, - 043D7E73145795B20078D710 /* JSCocoaFFIClosure.h */, - 043D7E74145795B20078D710 /* JSCocoaFFIClosure.m */, - 043D7E75145795B20078D710 /* JSCocoaLib.h */, - 043D7E76145795B20078D710 /* JSCocoaLib.m */, - 043D7E77145795B20078D710 /* JSCocoaPrivateObject.h */, - 043D7E78145795B20078D710 /* JSCocoaPrivateObject.m */, + 0487C93C14FED6090045E5E3 /* Atom.h */, + 0487C93D14FED6090045E5E3 /* Atom.mm */, + 0487C93E14FED6090045E5E3 /* AtomController.h */, + 0487C93F14FED6090045E5E3 /* AtomController.mm */, + 042180E614FF080D00DF25EA /* BrowserDelegate.h */, + 0487C94014FED6090045E5E3 /* client_handler.h */, + 0487C94114FED6090045E5E3 /* client_handler.mm */, + 0487C94214FED6090045E5E3 /* main.mm */, + 0487C94314FED6090045E5E3 /* native_handler.h */, + 0487C94414FED6090045E5E3 /* native_handler.mm */, ); - path = JSCocoa; + path = src; sourceTree = ""; }; - 043D7E79145795B20078D710 /* UKKQueue */ = { + 0487CF3514FEE5C40045E5E3 /* include */ = { isa = PBXGroup; children = ( - 043D7E7A145795B20078D710 /* UKFileWatcher.h */, - 043D7E7B145795B20078D710 /* UKFileWatcher.m */, - 043D7E7C145795B20078D710 /* UKFNSubscribeFileWatcher.h */, - 043D7E7D145795B20078D710 /* UKFNSubscribeFileWatcher.m */, - 043D7E7E145795B20078D710 /* UKKQueue.h */, - 043D7E7F145795B20078D710 /* UKKQueue.m */, - 043D7E80145795B20078D710 /* UKMainThreadProxy.h */, - 043D7E81145795B20078D710 /* UKMainThreadProxy.m */, + 0487CF3614FEE5C40045E5E3 /* cef.h */, + 0487CF3714FEE5C40045E5E3 /* cef_application_mac.h */, + 0487CF3814FEE5C40045E5E3 /* cef_capi.h */, + 0487CF3914FEE5C40045E5E3 /* cef_nplugin.h */, + 0487CF3A14FEE5C40045E5E3 /* cef_nplugin_capi.h */, + 0487CF3B14FEE5C40045E5E3 /* cef_runnable.h */, + 0487CF3C14FEE5C40045E5E3 /* cef_version.h */, + 0487CF3D14FEE5C40045E5E3 /* cef_wrapper.h */, + 0487CF3E14FEE5C40045E5E3 /* internal */, ); - path = UKKQueue; + name = include; + path = ../cef/include; + sourceTree = ""; + }; + 0487CF3E14FEE5C40045E5E3 /* internal */ = { + isa = PBXGroup; + children = ( + 0487CF3F14FEE5C40045E5E3 /* cef_build.h */, + 0487CF4014FEE5C40045E5E3 /* cef_export.h */, + 0487CF4114FEE5C40045E5E3 /* cef_mac.h */, + 0487CF4214FEE5C40045E5E3 /* cef_nplugin_types.h */, + 0487CF4314FEE5C40045E5E3 /* cef_ptr.h */, + 0487CF4414FEE5C40045E5E3 /* cef_string.h */, + 0487CF4514FEE5C40045E5E3 /* cef_string_list.h */, + 0487CF4614FEE5C40045E5E3 /* cef_string_map.h */, + 0487CF4714FEE5C40045E5E3 /* cef_string_multimap.h */, + 0487CF4814FEE5C40045E5E3 /* cef_string_types.h */, + 0487CF4914FEE5C40045E5E3 /* cef_string_wrappers.h */, + 0487CF4A14FEE5C40045E5E3 /* cef_time.h */, + 0487CF4B14FEE5C40045E5E3 /* cef_tuple.h */, + 0487CF4C14FEE5C40045E5E3 /* cef_types.h */, + 0487CF4D14FEE5C40045E5E3 /* cef_types_mac.h */, + 0487CF4E14FEE5C40045E5E3 /* cef_types_wrappers.h */, + 0487CF4F14FEE5C40045E5E3 /* npapi */, + ); + path = internal; + sourceTree = ""; + }; + 0487CF4F14FEE5C40045E5E3 /* npapi */ = { + isa = PBXGroup; + children = ( + 0487CF5014FEE5C40045E5E3 /* basictypes.h */, + 0487CF5114FEE5C40045E5E3 /* build_config.h */, + 0487CF5214FEE5C40045E5E3 /* npapi.h */, + 0487CF5314FEE5C40045E5E3 /* npapi_extensions.h */, + 0487CF5414FEE5C40045E5E3 /* npfunctions.h */, + 0487CF5514FEE5C40045E5E3 /* nphostapi.h */, + 0487CF5614FEE5C40045E5E3 /* npruntime.h */, + 0487CF5714FEE5C40045E5E3 /* nptypes.h */, + 0487CF5814FEE5C40045E5E3 /* port.h */, + 0487CF5914FEE5C40045E5E3 /* README-TRANSFER.txt */, + ); + path = npapi; + sourceTree = ""; + }; + 0487D0B214FEE6D60045E5E3 /* libcef_wrapper */ = { + isa = PBXGroup; + children = ( + 0487D0B314FEE6D60045E5E3 /* cef_logging.h */, + 0487D0B414FEE6D60045E5E3 /* cpptoc */, + 0487D0F314FEE6D60045E5E3 /* ctocpp */, + 0487D11E14FEE6D60045E5E3 /* transfer_util.cpp */, + 0487D11F14FEE6D60045E5E3 /* transfer_util.h */, + 0487D12014FEE6D60045E5E3 /* wrapper */, + ); + name = libcef_wrapper; + path = ../cef/libcef_dll; + sourceTree = ""; + }; + 0487D0B414FEE6D60045E5E3 /* cpptoc */ = { + isa = PBXGroup; + children = ( + 0487D0B514FEE6D60045E5E3 /* app_cpptoc.cc */, + 0487D0B614FEE6D60045E5E3 /* app_cpptoc.h */, + 0487D0B714FEE6D60045E5E3 /* base_cpptoc.h */, + 0487D0B814FEE6D60045E5E3 /* client_cpptoc.cc */, + 0487D0B914FEE6D60045E5E3 /* client_cpptoc.h */, + 0487D0BA14FEE6D60045E5E3 /* content_filter_cpptoc.cc */, + 0487D0BB14FEE6D60045E5E3 /* content_filter_cpptoc.h */, + 0487D0BC14FEE6D60045E5E3 /* cookie_visitor_cpptoc.cc */, + 0487D0BD14FEE6D60045E5E3 /* cookie_visitor_cpptoc.h */, + 0487D0BE14FEE6D60045E5E3 /* cpptoc.h */, + 0487D0BF14FEE6D60045E5E3 /* display_handler_cpptoc.cc */, + 0487D0C014FEE6D60045E5E3 /* display_handler_cpptoc.h */, + 0487D0C114FEE6D60045E5E3 /* domevent_listener_cpptoc.cc */, + 0487D0C214FEE6D60045E5E3 /* domevent_listener_cpptoc.h */, + 0487D0C314FEE6D60045E5E3 /* domvisitor_cpptoc.cc */, + 0487D0C414FEE6D60045E5E3 /* domvisitor_cpptoc.h */, + 0487D0C514FEE6D60045E5E3 /* download_handler_cpptoc.cc */, + 0487D0C614FEE6D60045E5E3 /* download_handler_cpptoc.h */, + 0487D0C714FEE6D60045E5E3 /* drag_handler_cpptoc.cc */, + 0487D0C814FEE6D60045E5E3 /* drag_handler_cpptoc.h */, + 0487D0C914FEE6D60045E5E3 /* find_handler_cpptoc.cc */, + 0487D0CA14FEE6D60045E5E3 /* find_handler_cpptoc.h */, + 0487D0CB14FEE6D60045E5E3 /* focus_handler_cpptoc.cc */, + 0487D0CC14FEE6D60045E5E3 /* focus_handler_cpptoc.h */, + 0487D0CD14FEE6D60045E5E3 /* jsdialog_handler_cpptoc.cc */, + 0487D0CE14FEE6D60045E5E3 /* jsdialog_handler_cpptoc.h */, + 0487D0CF14FEE6D60045E5E3 /* keyboard_handler_cpptoc.cc */, + 0487D0D014FEE6D60045E5E3 /* keyboard_handler_cpptoc.h */, + 0487D0D114FEE6D60045E5E3 /* life_span_handler_cpptoc.cc */, + 0487D0D214FEE6D60045E5E3 /* life_span_handler_cpptoc.h */, + 0487D0D314FEE6D60045E5E3 /* load_handler_cpptoc.cc */, + 0487D0D414FEE6D60045E5E3 /* load_handler_cpptoc.h */, + 0487D0D514FEE6D60045E5E3 /* menu_handler_cpptoc.cc */, + 0487D0D614FEE6D60045E5E3 /* menu_handler_cpptoc.h */, + 0487D0D714FEE6D60045E5E3 /* print_handler_cpptoc.cc */, + 0487D0D814FEE6D60045E5E3 /* print_handler_cpptoc.h */, + 0487D0D914FEE6D60045E5E3 /* proxy_handler_cpptoc.cc */, + 0487D0DA14FEE6D60045E5E3 /* proxy_handler_cpptoc.h */, + 0487D0DB14FEE6D60045E5E3 /* read_handler_cpptoc.cc */, + 0487D0DC14FEE6D60045E5E3 /* read_handler_cpptoc.h */, + 0487D0DD14FEE6D60045E5E3 /* render_handler_cpptoc.cc */, + 0487D0DE14FEE6D60045E5E3 /* render_handler_cpptoc.h */, + 0487D0DF14FEE6D60045E5E3 /* request_handler_cpptoc.cc */, + 0487D0E014FEE6D60045E5E3 /* request_handler_cpptoc.h */, + 0487D0E114FEE6D60045E5E3 /* scheme_handler_cpptoc.cc */, + 0487D0E214FEE6D60045E5E3 /* scheme_handler_cpptoc.h */, + 0487D0E314FEE6D60045E5E3 /* scheme_handler_factory_cpptoc.cc */, + 0487D0E414FEE6D60045E5E3 /* scheme_handler_factory_cpptoc.h */, + 0487D0E514FEE6D60045E5E3 /* storage_visitor_cpptoc.cc */, + 0487D0E614FEE6D60045E5E3 /* storage_visitor_cpptoc.h */, + 0487D0E714FEE6D60045E5E3 /* task_cpptoc.cc */, + 0487D0E814FEE6D60045E5E3 /* task_cpptoc.h */, + 0487D0E914FEE6D60045E5E3 /* v8accessor_cpptoc.cc */, + 0487D0EA14FEE6D60045E5E3 /* v8accessor_cpptoc.h */, + 0487D0EB14FEE6D60045E5E3 /* v8context_handler_cpptoc.cc */, + 0487D0EC14FEE6D60045E5E3 /* v8context_handler_cpptoc.h */, + 0487D0ED14FEE6D60045E5E3 /* v8handler_cpptoc.cc */, + 0487D0EE14FEE6D60045E5E3 /* v8handler_cpptoc.h */, + 0487D0EF14FEE6D60045E5E3 /* web_urlrequest_client_cpptoc.cc */, + 0487D0F014FEE6D60045E5E3 /* web_urlrequest_client_cpptoc.h */, + 0487D0F114FEE6D60045E5E3 /* write_handler_cpptoc.cc */, + 0487D0F214FEE6D60045E5E3 /* write_handler_cpptoc.h */, + ); + path = cpptoc; + sourceTree = ""; + }; + 0487D0F314FEE6D60045E5E3 /* ctocpp */ = { + isa = PBXGroup; + children = ( + 0487D0F414FEE6D60045E5E3 /* base_ctocpp.h */, + 0487D0F514FEE6D60045E5E3 /* browser_ctocpp.cc */, + 0487D0F614FEE6D60045E5E3 /* browser_ctocpp.h */, + 0487D0F714FEE6D60045E5E3 /* command_line_ctocpp.cc */, + 0487D0F814FEE6D60045E5E3 /* command_line_ctocpp.h */, + 0487D0F914FEE6D60045E5E3 /* ctocpp.h */, + 0487D0FA14FEE6D60045E5E3 /* domdocument_ctocpp.cc */, + 0487D0FB14FEE6D60045E5E3 /* domdocument_ctocpp.h */, + 0487D0FC14FEE6D60045E5E3 /* domevent_ctocpp.cc */, + 0487D0FD14FEE6D60045E5E3 /* domevent_ctocpp.h */, + 0487D0FE14FEE6D60045E5E3 /* domnode_ctocpp.cc */, + 0487D0FF14FEE6D60045E5E3 /* domnode_ctocpp.h */, + 0487D10014FEE6D60045E5E3 /* drag_data_ctocpp.cc */, + 0487D10114FEE6D60045E5E3 /* drag_data_ctocpp.h */, + 0487D10214FEE6D60045E5E3 /* frame_ctocpp.cc */, + 0487D10314FEE6D60045E5E3 /* frame_ctocpp.h */, + 0487D10414FEE6D60045E5E3 /* post_data_ctocpp.cc */, + 0487D10514FEE6D60045E5E3 /* post_data_ctocpp.h */, + 0487D10614FEE6D60045E5E3 /* post_data_element_ctocpp.cc */, + 0487D10714FEE6D60045E5E3 /* post_data_element_ctocpp.h */, + 0487D10814FEE6D60045E5E3 /* request_ctocpp.cc */, + 0487D10914FEE6D60045E5E3 /* request_ctocpp.h */, + 0487D10A14FEE6D60045E5E3 /* response_ctocpp.cc */, + 0487D10B14FEE6D60045E5E3 /* response_ctocpp.h */, + 0487D10C14FEE6D60045E5E3 /* scheme_handler_callback_ctocpp.cc */, + 0487D10D14FEE6D60045E5E3 /* scheme_handler_callback_ctocpp.h */, + 0487D10E14FEE6D60045E5E3 /* stream_reader_ctocpp.cc */, + 0487D10F14FEE6D60045E5E3 /* stream_reader_ctocpp.h */, + 0487D11014FEE6D60045E5E3 /* stream_writer_ctocpp.cc */, + 0487D11114FEE6D60045E5E3 /* stream_writer_ctocpp.h */, + 0487D11214FEE6D60045E5E3 /* v8context_ctocpp.cc */, + 0487D11314FEE6D60045E5E3 /* v8context_ctocpp.h */, + 0487D11414FEE6D60045E5E3 /* v8exception_ctocpp.cc */, + 0487D11514FEE6D60045E5E3 /* v8exception_ctocpp.h */, + 0487D11614FEE6D60045E5E3 /* v8value_ctocpp.cc */, + 0487D11714FEE6D60045E5E3 /* v8value_ctocpp.h */, + 0487D11814FEE6D60045E5E3 /* web_urlrequest_ctocpp.cc */, + 0487D11914FEE6D60045E5E3 /* web_urlrequest_ctocpp.h */, + 0487D11A14FEE6D60045E5E3 /* xml_reader_ctocpp.cc */, + 0487D11B14FEE6D60045E5E3 /* xml_reader_ctocpp.h */, + 0487D11C14FEE6D60045E5E3 /* zip_reader_ctocpp.cc */, + 0487D11D14FEE6D60045E5E3 /* zip_reader_ctocpp.h */, + ); + path = ctocpp; + sourceTree = ""; + }; + 0487D12014FEE6D60045E5E3 /* wrapper */ = { + isa = PBXGroup; + children = ( + 0487D12114FEE6D60045E5E3 /* cef_byte_read_handler.cc */, + 0487D12214FEE6D60045E5E3 /* cef_xml_object.cc */, + 0487D12314FEE6D60045E5E3 /* cef_zip_archive.cc */, + 0487D12414FEE6D60045E5E3 /* libcef_dll_wrapper.cc */, + 0487D12514FEE6D60045E5E3 /* libcef_dll_wrapper2.cc */, + ); + path = wrapper; sourceTree = ""; }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ - 043D7E46145794990078D710 /* Atom */ = { + 0487C91114FED5360045E5E3 /* Atom */ = { isa = PBXNativeTarget; - buildConfigurationList = 043D7E651457949A0078D710 /* Build configuration list for PBXNativeTarget "Atom" */; + buildConfigurationList = 0487C93014FED5370045E5E3 /* Build configuration list for PBXNativeTarget "Atom" */; buildPhases = ( - 040BDC8A14D70E1100CEE2A4 /* CopyFiles */, - 043D7E43145794990078D710 /* Sources */, - 043D7E44145794990078D710 /* Frameworks */, - 043D7E45145794990078D710 /* Resources */, - 047F25FF145796A2006DC904 /* Copy HTML folder & compile CoffeeScript */, + 0487CD9914FEE1500045E5E3 /* Copy Required Chrome Frameworks */, + 0487CD9C14FEE17D0045E5E3 /* Copy Chrome Resources */, + 0487C90E14FED5360045E5E3 /* Sources */, + 0487C90F14FED5360045E5E3 /* Frameworks */, + 0487C91014FED5360045E5E3 /* Resources */, + 0487CDA114FEE1F30045E5E3 /* Postbuild "Change Mach-O Flags" */, + 0487CDA214FEE1F50045E5E3 /* Postbuild "Strip If Needed" */, + 0487CDA314FEE1F80045E5E3 /* Compile and Bundle CoffeeScript */, + ); + buildRules = ( + ); + dependencies = ( + 0487CD6A14FEE0BE0045E5E3 /* PBXTargetDependency */, + ); + name = Atom; + productName = Atom; + productReference = 0487C91214FED5360045E5E3 /* Atom.app */; + productType = "com.apple.product-type.application"; + }; + 0487CC8014FEDF990045E5E3 /* libcef_wrapper */ = { + isa = PBXNativeTarget; + buildConfigurationList = 0487CC8214FEDF990045E5E3 /* Build configuration list for PBXNativeTarget "libcef_wrapper" */; + buildPhases = ( + 0487CC7D14FEDF990045E5E3 /* Sources */, + 0487CC7E14FEDF990045E5E3 /* Frameworks */, ); buildRules = ( ); dependencies = ( ); - name = Atom; - productName = Atom; - productReference = 043D7E47145794990078D710 /* Atom.app */; - productType = "com.apple.product-type.application"; + name = libcef_wrapper; + productName = libcef_wrapper; + productReference = 0487CC8114FEDF990045E5E3 /* liblibcef_wrapper.a */; + productType = "com.apple.product-type.library.static"; }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ - 043D7E3E145794990078D710 /* Project object */ = { + 0487C90914FED5360045E5E3 /* Project object */ = { isa = PBXProject; attributes = { LastUpgradeCheck = 0420; }; - buildConfigurationList = 043D7E41145794990078D710 /* Build configuration list for PBXProject "Atom" */; + buildConfigurationList = 0487C90C14FED5360045E5E3 /* Build configuration list for PBXProject "Atom" */; compatibilityVersion = "Xcode 3.2"; developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( en, ); - mainGroup = 043D7E3C145794990078D710; - productRefGroup = 043D7E48145794990078D710 /* Products */; + mainGroup = 0487C90714FED5360045E5E3; + productRefGroup = 0487C91314FED5360045E5E3 /* Products */; projectDirPath = ""; projectRoot = ""; targets = ( - 043D7E46145794990078D710 /* Atom */, + 0487C91114FED5360045E5E3 /* Atom */, + 0487CC8014FEDF990045E5E3 /* libcef_wrapper */, ); }; /* End PBXProject section */ /* Begin PBXResourcesBuildPhase section */ - 043D7E45145794990078D710 /* Resources */ = { + 0487C91014FED5360045E5E3 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - 043D7E56145794990078D710 /* InfoPlist.strings in Resources */, - 043D7E621457949A0078D710 /* MainMenu.xib in Resources */, - 043D7E8E145795B20078D710 /* AtomWindow.xib in Resources */, - 047F260E145883B9006DC904 /* Icon.icns in Resources */, + 0487C93714FED5FB0045E5E3 /* Atom.icns in Resources */, + 0487C93814FED5FB0045E5E3 /* ClientWindow.xib in Resources */, + 0487C93A14FED5FB0045E5E3 /* MainMenu.xib in Resources */, + 0487D15F14FEE7880045E5E3 /* resources in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - 047F25FF145796A2006DC904 /* Copy HTML folder & compile CoffeeScript */ = { + 0487CDA114FEE1F30045E5E3 /* Postbuild "Change Mach-O Flags" */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + "$(BUILT_PRODUCTS_DIR)/$(EXECUTABLE_PATH)", + ); + name = "Postbuild \"Change Mach-O Flags\""; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "exec cef/tools/change_mach_o_flags_from_xcode.sh\nexit 1\n"; + showEnvVarsInLog = 0; + }; + 0487CDA214FEE1F50045E5E3 /* Postbuild "Strip If Needed" */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + "$(BUILT_PRODUCTS_DIR)/$(EXECUTABLE_PATH)", + ); + name = "Postbuild \"Strip If Needed\""; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "exec cef/tools/strip_from_xcode\nexit 1\n"; + showEnvVarsInLog = 0; + }; + 0487CDA314FEE1F80045E5E3 /* Compile and Bundle CoffeeScript */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( ); - name = "Copy HTML folder & compile CoffeeScript"; + name = "Compile and Bundle CoffeeScript"; outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; shellScript = "rake build"; + showEnvVarsInLog = 0; }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ - 043D7E43145794990078D710 /* Sources */ = { + 0487C90E14FED5360045E5E3 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 043D7E58145794990078D710 /* main.m in Sources */, - 043D7E84145795B20078D710 /* BridgeSupportController.m in Sources */, - 043D7E85145795B20078D710 /* JSCocoaController.m in Sources */, - 043D7E86145795B20078D710 /* JSCocoaFFIArgument.m in Sources */, - 043D7E87145795B20078D710 /* JSCocoaFFIClosure.m in Sources */, - 043D7E88145795B20078D710 /* JSCocoaLib.m in Sources */, - 043D7E89145795B20078D710 /* JSCocoaPrivateObject.m in Sources */, - 043D7E8A145795B20078D710 /* UKFileWatcher.m in Sources */, - 043D7E8B145795B20078D710 /* UKFNSubscribeFileWatcher.m in Sources */, - 043D7E8C145795B20078D710 /* UKKQueue.m in Sources */, - 043D7E8D145795B20078D710 /* UKMainThreadProxy.m in Sources */, - 043D7E94145795B70078D710 /* AtomApp.m in Sources */, - 043D7E95145795B70078D710 /* AtomController.m in Sources */, - ECBB172814A4F92400ACAAC1 /* AtomMenuItem.m in Sources */, - EC846C4114B529120021AF1F /* FileSystemHelper.m in Sources */, + 0487CD9414FEE1330045E5E3 /* Atom.mm in Sources */, + 0487CD9514FEE1340045E5E3 /* AtomController.mm in Sources */, + 0487CD9614FEE1360045E5E3 /* client_handler.mm in Sources */, + 0487CD9714FEE1380045E5E3 /* main.mm in Sources */, + 0487CD9814FEE13B0045E5E3 /* native_handler.mm in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 0487CC7D14FEDF990045E5E3 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 0487D12614FEE6D60045E5E3 /* app_cpptoc.cc in Sources */, + 0487D12714FEE6D60045E5E3 /* client_cpptoc.cc in Sources */, + 0487D12814FEE6D60045E5E3 /* content_filter_cpptoc.cc in Sources */, + 0487D12914FEE6D60045E5E3 /* cookie_visitor_cpptoc.cc in Sources */, + 0487D12A14FEE6D60045E5E3 /* display_handler_cpptoc.cc in Sources */, + 0487D12B14FEE6D60045E5E3 /* domevent_listener_cpptoc.cc in Sources */, + 0487D12C14FEE6D60045E5E3 /* domvisitor_cpptoc.cc in Sources */, + 0487D12D14FEE6D60045E5E3 /* download_handler_cpptoc.cc in Sources */, + 0487D12E14FEE6D60045E5E3 /* drag_handler_cpptoc.cc in Sources */, + 0487D12F14FEE6D60045E5E3 /* find_handler_cpptoc.cc in Sources */, + 0487D13014FEE6D60045E5E3 /* focus_handler_cpptoc.cc in Sources */, + 0487D13114FEE6D60045E5E3 /* jsdialog_handler_cpptoc.cc in Sources */, + 0487D13214FEE6D60045E5E3 /* keyboard_handler_cpptoc.cc in Sources */, + 0487D13314FEE6D60045E5E3 /* life_span_handler_cpptoc.cc in Sources */, + 0487D13414FEE6D60045E5E3 /* load_handler_cpptoc.cc in Sources */, + 0487D13514FEE6D60045E5E3 /* menu_handler_cpptoc.cc in Sources */, + 0487D13614FEE6D60045E5E3 /* print_handler_cpptoc.cc in Sources */, + 0487D13714FEE6D60045E5E3 /* proxy_handler_cpptoc.cc in Sources */, + 0487D13814FEE6D60045E5E3 /* read_handler_cpptoc.cc in Sources */, + 0487D13914FEE6D60045E5E3 /* render_handler_cpptoc.cc in Sources */, + 0487D13A14FEE6D60045E5E3 /* request_handler_cpptoc.cc in Sources */, + 0487D13B14FEE6D60045E5E3 /* scheme_handler_cpptoc.cc in Sources */, + 0487D13C14FEE6D60045E5E3 /* scheme_handler_factory_cpptoc.cc in Sources */, + 0487D13D14FEE6D60045E5E3 /* storage_visitor_cpptoc.cc in Sources */, + 0487D13E14FEE6D60045E5E3 /* task_cpptoc.cc in Sources */, + 0487D13F14FEE6D60045E5E3 /* v8accessor_cpptoc.cc in Sources */, + 0487D14014FEE6D60045E5E3 /* v8context_handler_cpptoc.cc in Sources */, + 0487D14114FEE6D60045E5E3 /* v8handler_cpptoc.cc in Sources */, + 0487D14214FEE6D60045E5E3 /* web_urlrequest_client_cpptoc.cc in Sources */, + 0487D14314FEE6D60045E5E3 /* write_handler_cpptoc.cc in Sources */, + 0487D14414FEE6D60045E5E3 /* browser_ctocpp.cc in Sources */, + 0487D14514FEE6D60045E5E3 /* command_line_ctocpp.cc in Sources */, + 0487D14614FEE6D60045E5E3 /* domdocument_ctocpp.cc in Sources */, + 0487D14714FEE6D60045E5E3 /* domevent_ctocpp.cc in Sources */, + 0487D14814FEE6D60045E5E3 /* domnode_ctocpp.cc in Sources */, + 0487D14914FEE6D60045E5E3 /* drag_data_ctocpp.cc in Sources */, + 0487D14A14FEE6D60045E5E3 /* frame_ctocpp.cc in Sources */, + 0487D14B14FEE6D60045E5E3 /* post_data_ctocpp.cc in Sources */, + 0487D14C14FEE6D60045E5E3 /* post_data_element_ctocpp.cc in Sources */, + 0487D14D14FEE6D60045E5E3 /* request_ctocpp.cc in Sources */, + 0487D14E14FEE6D60045E5E3 /* response_ctocpp.cc in Sources */, + 0487D14F14FEE6D60045E5E3 /* scheme_handler_callback_ctocpp.cc in Sources */, + 0487D15014FEE6D60045E5E3 /* stream_reader_ctocpp.cc in Sources */, + 0487D15114FEE6D60045E5E3 /* stream_writer_ctocpp.cc in Sources */, + 0487D15214FEE6D60045E5E3 /* v8context_ctocpp.cc in Sources */, + 0487D15314FEE6D60045E5E3 /* v8exception_ctocpp.cc in Sources */, + 0487D15414FEE6D60045E5E3 /* v8value_ctocpp.cc in Sources */, + 0487D15514FEE6D60045E5E3 /* web_urlrequest_ctocpp.cc in Sources */, + 0487D15614FEE6D60045E5E3 /* xml_reader_ctocpp.cc in Sources */, + 0487D15714FEE6D60045E5E3 /* zip_reader_ctocpp.cc in Sources */, + 0487D15814FEE6D60045E5E3 /* transfer_util.cpp in Sources */, + 0487D15914FEE6D60045E5E3 /* cef_byte_read_handler.cc in Sources */, + 0487D15A14FEE6D60045E5E3 /* cef_xml_object.cc in Sources */, + 0487D15B14FEE6D60045E5E3 /* cef_zip_archive.cc in Sources */, + 0487D15C14FEE6D60045E5E3 /* libcef_dll_wrapper.cc in Sources */, + 0487D15D14FEE6D60045E5E3 /* libcef_dll_wrapper2.cc in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXSourcesBuildPhase section */ -/* Begin PBXVariantGroup section */ - 043D7E54145794990078D710 /* InfoPlist.strings */ = { - isa = PBXVariantGroup; - children = ( - 043D7E55145794990078D710 /* en */, - ); - name = InfoPlist.strings; - sourceTree = ""; +/* Begin PBXTargetDependency section */ + 0487CD6A14FEE0BE0045E5E3 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 0487CC8014FEDF990045E5E3 /* libcef_wrapper */; + targetProxy = 0487CD6914FEE0BE0045E5E3 /* PBXContainerItemProxy */; }; - 043D7E601457949A0078D710 /* MainMenu.xib */ = { - isa = PBXVariantGroup; - children = ( - 043D7E611457949A0078D710 /* en */, - ); - name = MainMenu.xib; - sourceTree = ""; - }; -/* End PBXVariantGroup section */ +/* End PBXTargetDependency section */ /* Begin XCBuildConfiguration section */ - 043D7E631457949A0078D710 /* Debug */ = { + 0487C92E14FED5370045E5E3 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - ARCHS = "$(ARCHS_STANDARD_64_BIT)"; + ARCHS = "$(ARCHS_STANDARD_32_BIT)"; + CLANG_WARN_CXX0X_EXTENSIONS = NO; COPY_PHASE_STRIP = NO; - GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; - GCC_ENABLE_OBJC_EXCEPTIONS = YES; + GCC_INLINES_ARE_PRIVATE_EXTERN = YES; GCC_OPTIMIZATION_LEVEL = 0; - GCC_PRECOMPILE_PREFIX_HEADER = NO; GCC_PREPROCESSOR_DEFINITIONS = ( - "PROJECT_DIR=\"@\\\"$PROJECT_DIR\\\"\"", "DEBUG=1", - "$(inherited)", + "PROJECT_DIR=\"\\\"$PROJECT_DIR\\\"\"", + "\"ENABLE_REMOTING=1\"", + "\"ENABLE_P2P_APIS=1\"", + "\"ENABLE_CONFIGURATION_POLICY\"", + "\"ENABLE_INPUT_SPEECH\"", + "\"ENABLE_NOTIFICATIONS\"", + "\"ENABLE_GPU=1\"", + "\"ENABLE_EGLIMAGE=1\"", + "\"ENABLE_REGISTER_PROTOCOL_HANDLER=1\"", + "\"USING_CEF_SHARED\"", + "\"__STDC_FORMAT_MACROS\"", + NDEBUG, + "\"DYNAMIC_ANNOTATIONS_ENABLED=1\"", + "\"WTF_USE_DYNAMIC_ANNOTATIONS=1\"", ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; - GCC_TREAT_WARNINGS_AS_ERRORS = YES; + GCC_THREADSAFE_STATICS = NO; GCC_VERSION = com.apple.compilers.llvm.clang.1_0; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; MACOSX_DEPLOYMENT_TARGET = 10.7; - ONLY_ACTIVE_ARCH = YES; - OTHER_LDFLAGS = "-lffi"; SDKROOT = macosx; }; name = Debug; }; - 043D7E641457949A0078D710 /* Release */ = { + 0487C92F14FED5370045E5E3 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - ARCHS = "$(ARCHS_STANDARD_64_BIT)"; + ARCHS = "$(ARCHS_STANDARD_32_BIT)"; + CLANG_WARN_CXX0X_EXTENSIONS = NO; COPY_PHASE_STRIP = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_ENABLE_OBJC_EXCEPTIONS = YES; - GCC_PRECOMPILE_PREFIX_HEADER = NO; - GCC_PREPROCESSOR_DEFINITIONS = "PROJECT_DIR=\"@\\\"$PROJECT_DIR\\\"\""; - GCC_TREAT_WARNINGS_AS_ERRORS = YES; + GCC_INLINES_ARE_PRIVATE_EXTERN = YES; + GCC_OPTIMIZATION_LEVEL = 3; + GCC_PREPROCESSOR_DEFINITIONS = ( + "PROJECT_DIR=\"\\\"$PROJECT_DIR\\\"\"", + "\"ENABLE_REMOTING=1\"", + "\"ENABLE_P2P_APIS=1\"", + "\"ENABLE_CONFIGURATION_POLICY\"", + "\"ENABLE_INPUT_SPEECH\"", + "\"ENABLE_NOTIFICATIONS\"", + "\"ENABLE_GPU=1\"", + "\"ENABLE_EGLIMAGE=1\"", + "\"ENABLE_REGISTER_PROTOCOL_HANDLER=1\"", + "\"USING_CEF_SHARED\"", + "\"__STDC_FORMAT_MACROS\"", + "\"DYNAMIC_ANNOTATIONS_ENABLED=1\"", + "\"WTF_USE_DYNAMIC_ANNOTATIONS=1\"", + ); + GCC_THREADSAFE_STATICS = NO; GCC_VERSION = com.apple.compilers.llvm.clang.1_0; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; MACOSX_DEPLOYMENT_TARGET = 10.7; - OTHER_LDFLAGS = "-lffi"; SDKROOT = macosx; }; name = Release; }; - 043D7E661457949A0078D710 /* Debug */ = { + 0487C93114FED5370045E5E3 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", + GCC_CW_ASM_SYNTAX = NO; + GCC_C_LANGUAGE_STANDARD = c99; + GCC_ENABLE_CPP_EXCEPTIONS = NO; + GCC_ENABLE_CPP_RTTI = NO; + GCC_ENABLE_PASCAL_STRINGS = NO; + GCC_OBJC_CALL_CXX_CDTORS = YES; + GCC_TREAT_WARNINGS_AS_ERRORS = YES; + HEADER_SEARCH_PATHS = "\"$(SRCROOT)/cef\""; + INFOPLIST_FILE = Atom/Info.plist; + LIBRARY_SEARCH_PATHS = ( + "$(SDKROOT)/System/Library/Frameworks", "\"$(SRCROOT)/frameworks\"", ); - GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = "Atom/Atom-Prefix.pch"; - INFOPLIST_FILE = "Atom/Atom-Info.plist"; - LD_RUNPATH_SEARCH_PATHS = "@loader_path/../Frameworks"; + OTHER_CFLAGS = ( + "-fno-strict-aliasing", + "-fstack-protector-all", + ); + OTHER_LDFLAGS = ( + "-Wl,-search_paths_first", + "-Wl,-ObjC", + "-Wl,-pie", + ); PRODUCT_NAME = "$(TARGET_NAME)"; - STRINGS_FILE_OUTPUT_ENCODING = "UTF-8"; + USE_HEADERMAP = NO; + WARNING_CFLAGS = ( + "-Wall", + "-Wendif-labels", + "-Wextra", + "-Wno-unused-parameter", + "-Wno-missing-field-initializers", + ); WRAPPER_EXTENSION = app; }; name = Debug; }; - 043D7E671457949A0078D710 /* Release */ = { + 0487C93214FED5370045E5E3 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", + DEAD_CODE_STRIPPING = YES; + GCC_CW_ASM_SYNTAX = NO; + GCC_C_LANGUAGE_STANDARD = c99; + GCC_ENABLE_CPP_EXCEPTIONS = NO; + GCC_ENABLE_CPP_RTTI = NO; + GCC_ENABLE_PASCAL_STRINGS = NO; + GCC_OBJC_CALL_CXX_CDTORS = YES; + GCC_TREAT_WARNINGS_AS_ERRORS = YES; + HEADER_SEARCH_PATHS = "\"$(SRCROOT)/cef\""; + INFOPLIST_FILE = Atom/Info.plist; + LIBRARY_SEARCH_PATHS = ( + "$(SDKROOT)/System/Library/Frameworks", "\"$(SRCROOT)/frameworks\"", ); - GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = "Atom/Atom-Prefix.pch"; - INFOPLIST_FILE = "Atom/Atom-Info.plist"; - LD_RUNPATH_SEARCH_PATHS = "@loader_path/../Frameworks"; + OTHER_CFLAGS = "-fno-strict-aliasing"; + OTHER_LDFLAGS = ( + "-Wl,-search_paths_first", + "-Wl,-ObjC", + "-Wl,-pie", + ); PRODUCT_NAME = "$(TARGET_NAME)"; - STRINGS_FILE_OUTPUT_ENCODING = "UTF-8"; + USE_HEADERMAP = NO; + WARNING_CFLAGS = ( + "-Wall", + "-Wendif-labels", + "-Wextra", + "-Wno-unused-parameter", + "-Wno-missing-field-initializers", + ); WRAPPER_EXTENSION = app; }; name = Release; }; + 0487CC8314FEDF990045E5E3 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_WARN_CXX0X_EXTENSIONS = NO; + EXECUTABLE_PREFIX = lib; + GCC_CW_ASM_SYNTAX = NO; + GCC_C_LANGUAGE_STANDARD = c99; + GCC_ENABLE_CPP_EXCEPTIONS = NO; + GCC_ENABLE_CPP_RTTI = NO; + GCC_ENABLE_PASCAL_STRINGS = NO; + GCC_OBJC_CALL_CXX_CDTORS = YES; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + HEADER_SEARCH_PATHS = "\"$(SRCROOT)/cef\""; + ONLY_ACTIVE_ARCH = YES; + OTHER_CFLAGS = ( + "-fno-strict-aliasing", + "-fstack-protector-all", + ); + PRODUCT_NAME = "$(TARGET_NAME)"; + USE_HEADERMAP = NO; + WARNING_CFLAGS = ( + "-Wall", + "-Wendif-labels", + "-Wextra", + "-Wno-unused-parameter", + "-Wno-missing-field-initializers", + ); + }; + name = Debug; + }; + 0487CC8414FEDF990045E5E3 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_WARN_CXX0X_EXTENSIONS = NO; + EXECUTABLE_PREFIX = lib; + GCC_CW_ASM_SYNTAX = NO; + GCC_C_LANGUAGE_STANDARD = c99; + GCC_ENABLE_CPP_EXCEPTIONS = NO; + GCC_ENABLE_CPP_RTTI = NO; + GCC_ENABLE_PASCAL_STRINGS = NO; + GCC_OBJC_CALL_CXX_CDTORS = YES; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + HEADER_SEARCH_PATHS = "\"$(SRCROOT)/cef\""; + OTHER_CFLAGS = ( + "-fno-strict-aliasing", + "-fstack-protector-all", + ); + PRODUCT_NAME = "$(TARGET_NAME)"; + USE_HEADERMAP = NO; + WARNING_CFLAGS = ( + "-Wall", + "-Wendif-labels", + "-Wextra", + "-Wno-unused-parameter", + "-Wno-missing-field-initializers", + ); + }; + name = Release; + }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ - 043D7E41145794990078D710 /* Build configuration list for PBXProject "Atom" */ = { + 0487C90C14FED5360045E5E3 /* Build configuration list for PBXProject "Atom" */ = { isa = XCConfigurationList; buildConfigurations = ( - 043D7E631457949A0078D710 /* Debug */, - 043D7E641457949A0078D710 /* Release */, + 0487C92E14FED5370045E5E3 /* Debug */, + 0487C92F14FED5370045E5E3 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - 043D7E651457949A0078D710 /* Build configuration list for PBXNativeTarget "Atom" */ = { + 0487C93014FED5370045E5E3 /* Build configuration list for PBXNativeTarget "Atom" */ = { isa = XCConfigurationList; buildConfigurations = ( - 043D7E661457949A0078D710 /* Debug */, - 043D7E671457949A0078D710 /* Release */, + 0487C93114FED5370045E5E3 /* Debug */, + 0487C93214FED5370045E5E3 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 0487CC8214FEDF990045E5E3 /* Build configuration list for PBXNativeTarget "libcef_wrapper" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 0487CC8314FEDF990045E5E3 /* Debug */, + 0487CC8414FEDF990045E5E3 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; - rootObject = 043D7E3E145794990078D710 /* Project object */; + rootObject = 0487C90914FED5360045E5E3 /* Project object */; } diff --git a/Atom/Atom-Prefix.pch b/Atom/Atom-Prefix.pch deleted file mode 100644 index 769e458da..000000000 --- a/Atom/Atom-Prefix.pch +++ /dev/null @@ -1,7 +0,0 @@ -// -// Prefix header for all source files of the 'Atom' target in the 'Atom' project -// - -#ifdef __OBJC__ - #import -#endif diff --git a/Atom/Atom.icns b/Atom/Atom.icns new file mode 100755 index 000000000..f36742de2 Binary files /dev/null and b/Atom/Atom.icns differ diff --git a/Atom/Classes/AtomApp.h b/Atom/Classes/AtomApp.h deleted file mode 100644 index e4761823b..000000000 --- a/Atom/Classes/AtomApp.h +++ /dev/null @@ -1,17 +0,0 @@ -#import - -@class AtomController, AtomMenuItem; - -@interface AtomApp : NSApplication - -@property (nonatomic, retain) NSMutableArray *controllers; - -- (void)removeController:(AtomController *)controller; -- (IBAction)runSpecs:(id)sender; -- (void)performActionForMenuItem:(AtomMenuItem *)item; -- (void)resetMainMenu; - -- (NSString *)getCachedScript:(NSString *)filePath; -- (void)setCachedScript:(NSString *)filePath contents:(NSString *)contents; - -@end diff --git a/Atom/Classes/AtomApp.m b/Atom/Classes/AtomApp.m deleted file mode 100644 index 91f27a8d0..000000000 --- a/Atom/Classes/AtomApp.m +++ /dev/null @@ -1,144 +0,0 @@ -#import "AtomApp.h" - -#import "JSCocoa.h" -#import - -#import "AtomController.h" -#import "AtomMenuItem.h" - -#define ATOM_USER_PATH ([[NSString stringWithString:@"~/.atom/"] stringByStandardizingPath]) -#define ATOM_STORAGE_PATH ([ATOM_USER_PATH stringByAppendingPathComponent:@".app-storage"]) - -@interface AtomApp () { - NSMutableDictionary *_coffeeCache; -} -@end - -@implementation AtomApp - -@synthesize controllers = _controllers; - -- (void)open:(NSString *)path { - AtomController *controller = [[AtomController alloc] initWithURL:path]; - [self.controllers addObject:controller]; -} - -- (void)removeController:(AtomController *)controller { - [self.controllers removeObject:controller]; -} - -// Events in the "app:*" namespace are sent to all controllers -- (void)triggerGlobalAtomEvent:(NSString *)name data:(id)data { - for (AtomController *controller in self.controllers) { - [controller triggerAtomEventWithName:name data:data]; - } -} - -#pragma mark Overrides -- (void) sendEvent: (NSEvent *)event { - // Default implementation for key down tries key equivalents first - // We want to wait until the web view handles the event, then allow key equivalents to be tried - if (([event type] != NSKeyDown) || !event.window) { - [super sendEvent:event]; - return; - } - - [event.window sendEvent:event]; -} - -#pragma mark Actions -- (IBAction)openNewWindow:(id)sender { - [self open:nil]; -} - -- (IBAction)openPathInNewWindow:(id)sender { - NSOpenPanel *panel = [NSOpenPanel openPanel]; - [panel setCanChooseDirectories:YES]; - if ([panel runModal] == NSFileHandlingPanelOKButton) { - [self open:[panel.URLs.lastObject path]]; - } -} - -- (IBAction)runSpecs:(id)sender { - [[AtomController alloc] initForSpecs]; -} - -- (void)terminate:(id)sender { - for (AtomController *controller in self.controllers) { - [controller close]; - } - - [super terminate:sender]; -} - -#pragma mark NSAppDelegate -- (void)applicationWillFinishLaunching:(NSNotification *)aNotification { - self.controllers = [NSMutableArray array]; - - NSDictionary *defaults = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], @"WebKitDeveloperExtras", nil]; - [[NSUserDefaults standardUserDefaults] registerDefaults:defaults]; -} - -- (void)applicationDidFinishLaunching:(NSNotification *)notification { - _coffeeCache = [[NSMutableDictionary alloc] init]; - - if ([[[NSProcessInfo processInfo] environment] objectForKey:@"AUTO-TEST"]) { - [self runSpecs:self]; - } -} - -- (void)performActionForMenuItem:(AtomMenuItem *)item { - AtomController *atomController = self.keyWindow.windowController; - [atomController performActionForMenuItemPath:item.itemPath]; -} - -- (void)resetMenu:(NSMenu *)menu { - for (AtomMenuItem *item in menu.itemArray) { - if (![item isKindOfClass:[AtomMenuItem class]]) continue; - - if (item.submenu) { - [self resetMenu:item.submenu]; - if (item.submenu.numberOfItems == 0) { - [menu removeItem:item]; - } - } - else if (!item.global) { - [menu removeItem:item]; - } - } -} - -- (void)resetMainMenu { - [self resetMenu:self.mainMenu]; -} - -- (NSString *)getCachedScript:(NSString *)filePath { - NSDictionary *cachedObject = [_coffeeCache objectForKey:filePath]; - if (!cachedObject) return nil; - - NSFileManager *fm = [NSFileManager defaultManager]; - NSError *error = nil; - NSDictionary *attributes = [fm attributesOfItemAtPath:filePath error:&error]; - if (error) { - NSLog(@"Error reading cached scripts: %@", [error localizedDescription]); - return nil; - } - - NSDate *cachedAt = [cachedObject objectForKey:@"cachedAt"]; - NSDate *modifedAt = [attributes objectForKey:NSFileModificationDate]; - if (modifedAt && [modifedAt compare:cachedAt] == NSOrderedAscending) { - return [cachedObject objectForKey:@"script"]; - } - else { - return nil; - } -} - -- (void)setCachedScript:(NSString *)filePath contents:(NSString *)contents { - NSMutableDictionary *cachedObject = [NSMutableDictionary dictionary]; - [cachedObject setObject:[NSDate date] forKey:@"cachedAt"]; - [cachedObject setObject:contents forKey:@"script"]; - [_coffeeCache setObject:cachedObject forKey:filePath]; -} - -@end diff --git a/Atom/Classes/AtomController.h b/Atom/Classes/AtomController.h deleted file mode 100644 index af61cad1a..000000000 --- a/Atom/Classes/AtomController.h +++ /dev/null @@ -1,23 +0,0 @@ -#import -#import "JSCocoa.h" - -@class JSCocoa, WebView, FileSystemHelper; - -struct JSGlobalContextRef; - -@interface AtomController : NSWindowController - -@property (assign) WebView *webView; -@property (nonatomic, retain, readonly) NSString *url; -@property (nonatomic, retain, readonly) NSString *bootstrapScript; -@property (nonatomic, retain, readonly) FileSystemHelper *fs; - -- (id)initForSpecs; -- (id)initWithURL:(NSString *)url; - -- (void)triggerAtomEventWithName:(NSString *)name data:(id)data; -- (void)reload; -- (JSValueRefAndContextRef)jsWindow; -- (void)performActionForMenuItemPath:(NSString *)menuItemPath; - -@end diff --git a/Atom/Classes/AtomController.m b/Atom/Classes/AtomController.m deleted file mode 100644 index 243fa5c3b..000000000 --- a/Atom/Classes/AtomController.m +++ /dev/null @@ -1,167 +0,0 @@ -#import "AtomController.h" - -#import "JSCocoa.h" -#import -#import - -#import "AtomApp.h" -#import "FileSystemHelper.h" - -@interface AtomController () -@property (nonatomic, retain) JSCocoa *jscocoa; -@property (nonatomic, retain, readwrite) NSString *url; -@property (nonatomic, retain, readwrite) NSString *bootstrapScript; -@property (nonatomic, retain, readwrite) FileSystemHelper *fs; - -- (void)createWebView; -- (void)blockUntilWebViewLoads; - -@end - -@interface WebView (Atom) -- (id)inspector; -- (void)showConsole:(id)sender; -- (void)startDebuggingJavaScript:(id)sender; -@end - -@implementation AtomController - -@synthesize webView = _webView; -@synthesize jscocoa = _jscocoa; -@synthesize url = _url; -@synthesize bootstrapScript = _bootstrapScript; -@synthesize fs = _fs; - -- (void)dealloc { - self.webView = nil; - self.bootstrapScript = nil; - self.url = nil; - self.jscocoa = nil; - self.fs = nil; - - [super dealloc]; -} - -- (id)initWithBootstrapScript:(NSString *)bootstrapScript url:(NSString *)url { - self = [super initWithWindowNibName:@"AtomWindow"]; - self.bootstrapScript = bootstrapScript; - self.url = url; - - [self.window makeKeyWindow]; - return self; -} - -- (id)initForSpecs { - return [self initWithBootstrapScript:@"spec-bootstrap" url:nil]; -} - -- (id)initWithURL:(NSString *)url { - return [self initWithBootstrapScript:@"bootstrap" url:url]; -} - -- (void)windowDidLoad { - [super windowDidLoad]; - - [self.window setDelegate:self]; - [self.window setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary]; - - [self setShouldCascadeWindows:YES]; - [self setWindowFrameAutosaveName:@"atomController"]; - - [self createWebView]; -} - -- (void)triggerAtomEventWithName:(NSString *)name data:(id)data { - [self.jscocoa callJSFunctionNamed:@"triggerEvent" withArguments:name, data, false, nil]; -} - -- (void)createWebView { - self.webView = [[WebView alloc] initWithFrame:[self.window.contentView frame]]; - - [self.webView setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable]; - [self.window.contentView addSubview:self.webView]; - [self.webView setUIDelegate:self]; - [self.webView setFrameLoadDelegate:self]; - - NSURL *resourceDirURL = [[NSBundle mainBundle] resourceURL]; - NSURL *indexURL = [resourceDirURL URLByAppendingPathComponent:@"index.html"]; - - NSURLRequest *request = [NSURLRequest requestWithURL:indexURL]; - [[self.webView mainFrame] loadRequest:request]; - - [self blockUntilWebViewLoads]; -} - -- (void)blockUntilWebViewLoads { - NSRunLoop *runLoop = [NSRunLoop currentRunLoop]; - while (self.webView.isLoading) { - [runLoop runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; - } -} - -- (void)reload { - [self.webView reload:self]; -} - -- (void)close { - [(AtomApp *)NSApp removeController:self]; - [super close]; -} - -- (NSString *)projectPath { - return PROJECT_DIR; -} - -- (void)performActionForMenuItemPath:(NSString *)menuItemPath { - NSString *jsCode = [NSString stringWithFormat:@"window.performActionForMenuItemPath('%@')", menuItemPath]; - [self.jscocoa evalJSString:jsCode]; -} - -- (JSValueRefAndContextRef)jsWindow { - JSValueRef window = [self.jscocoa evalJSString:@"window"]; - JSValueRefAndContextRef windowWithContext = {window, self.jscocoa.ctx}; - return windowWithContext; -} - -- (NSString *)absolute:(NSString *)path { - path = [path stringByStandardizingPath]; - if ([path characterAtIndex:0] == '/') { - return path; - } - - NSString *resolvedPath = [[NSFileManager defaultManager] currentDirectoryPath]; - resolvedPath = [[resolvedPath stringByAppendingPathComponent:path] stringByStandardizingPath]; - - return resolvedPath; -} - -#pragma mark NSWindowDelegate -- (BOOL)windowShouldClose:(id)sender { - [self close]; - return YES; -} - -- (void)keyDown:(NSEvent *)event { - if ([event modifierFlags] & NSCommandKeyMask && [[event charactersIgnoringModifiers] hasPrefix:@"r"]) { - [self reload]; - } -} - -#pragma mark WebUIDelegate -- (NSArray *)webView:(WebView *)sender contextMenuItemsForElement:(NSDictionary *)element defaultMenuItems:(NSArray *)defaultMenuItems { - return defaultMenuItems; -} - -- (void)webViewClose:(WebView *)sender { // Triggered when closed from javascript - [self close]; -} - -#pragma mark WebFrameLoadDelegate -- (void)webView:(WebView *)sender didCommitLoadForFrame:(WebFrame *)frame { - self.jscocoa = [[JSCocoa alloc] initWithGlobalContext:[frame globalContext]]; - [self.jscocoa setObject:self withName:@"$atomController"]; - [self.jscocoa setObject:self.bootstrapScript withName:@"$bootstrapScript"]; - self.fs = [[[FileSystemHelper alloc] initWithJSContextRef:(JSContextRef)self.jscocoa.ctx] autorelease]; -} - -@end diff --git a/Atom/Classes/AtomMenuItem.h b/Atom/Classes/AtomMenuItem.h deleted file mode 100644 index 6a2e46b41..000000000 --- a/Atom/Classes/AtomMenuItem.h +++ /dev/null @@ -1,10 +0,0 @@ -#import - -@interface AtomMenuItem : NSMenuItem - -@property BOOL global; -@property (nonatomic, retain) NSString *itemPath; - -- initWithTitle:(NSString *)title itemPath:(NSString *)itemPath; - -@end diff --git a/Atom/Classes/AtomMenuItem.m b/Atom/Classes/AtomMenuItem.m deleted file mode 100644 index 529f87a6c..000000000 --- a/Atom/Classes/AtomMenuItem.m +++ /dev/null @@ -1,14 +0,0 @@ -#import "AtomMenuItem.h" - -@implementation AtomMenuItem - -@synthesize global = global_, itemPath = path_; - -- initWithTitle:(NSString *)title itemPath:(NSString *)itemPath { - self = [super initWithTitle:title action:@selector(performActionForMenuItem:) keyEquivalent:@""]; - self.itemPath = itemPath; - return self; -} - - -@end diff --git a/Atom/Classes/FileSystemHelper.h b/Atom/Classes/FileSystemHelper.h deleted file mode 100644 index 27ee7caf6..000000000 --- a/Atom/Classes/FileSystemHelper.h +++ /dev/null @@ -1,13 +0,0 @@ -#import -#import -#import "JSCocoa.h" - -@interface FileSystemHelper : NSObject { - JSContextRef _ctx; -} - -- (id)initWithJSContextRef:(JSContextRef)ctx; -- (void)listFilesAtPath:(NSString *)path recursive:(BOOL)recursive onComplete:(JSValueRefAndContextRef)jsFunction; -- (BOOL)isFile:(NSString *)path; - -@end diff --git a/Atom/Classes/FileSystemHelper.m b/Atom/Classes/FileSystemHelper.m deleted file mode 100644 index 4360b1181..000000000 --- a/Atom/Classes/FileSystemHelper.m +++ /dev/null @@ -1,81 +0,0 @@ -#import "FileSystemHelper.h" - -@interface FileSystemHelper () -- (NSArray *)listFilesAtPath:(NSString *)path recursive:(BOOL)recursive; -- (JSValueRef)convertToJSArrayOfStrings:(NSArray *)nsArray; -@end - -@implementation FileSystemHelper - -- (id)initWithJSContextRef:(JSContextRef)ctx { - self = [super init]; - _ctx = ctx; - return self; -} - -- (void)listFilesAtPath:(NSString *)path recursive:(BOOL)recursive onComplete:(JSValueRefAndContextRef)onComplete { - dispatch_queue_t backgroundQueue = dispatch_get_global_queue(0, 0); - dispatch_queue_t mainQueue = dispatch_get_main_queue(); - - JSValueRef onCompleteFn = onComplete.value; - - JSValueProtect(_ctx, onCompleteFn); - - dispatch_async(backgroundQueue, ^{ - NSArray *paths = [self listFilesAtPath:path recursive:recursive]; - JSValueRef jsPaths = [self convertToJSArrayOfStrings:paths]; - - dispatch_sync(mainQueue, ^{ - JSValueRef args[] = { jsPaths }; - JSObjectCallAsFunction(_ctx, JSValueToObject(_ctx, onCompleteFn, NULL), NULL, 1, args, NULL); - JSValueUnprotect(_ctx, onCompleteFn); - }); - }); -} - -- (BOOL)isFile:(NSString *)path { - BOOL isDir, exists; - exists = [[NSFileManager defaultManager] fileExistsAtPath:path isDirectory:&isDir]; - return exists && !isDir; -} - -- (NSArray *)listFilesAtPath:(NSString *)path recursive:(BOOL)recursive { - NSFileManager *fm = [NSFileManager defaultManager]; - NSMutableArray *paths = [NSMutableArray array]; - - if (recursive) { - for (NSString *subpath in [fm enumeratorAtPath:path]) { - [paths addObject:[path stringByAppendingPathComponent:subpath]]; - } - } else { - NSError *error = nil; - NSArray *subpaths = [fm contentsOfDirectoryAtPath:path error:&error]; - if (error) { - NSLog(@"ERROR %@", error.localizedDescription); - return nil; - } - for (NSString *subpath in subpaths) { - [paths addObject:[path stringByAppendingPathComponent:subpath]]; - } - } - - NSMutableArray *filePaths = [NSMutableArray array]; - for (NSString *path in paths) { - if ([self isFile:path]) [filePaths addObject:path]; - } - return filePaths; -} - -- (JSValueRef)convertToJSArrayOfStrings:(NSArray *)nsArray { - JSValueRef *cArray = malloc(sizeof(JSValueRef) * nsArray.count); - for (int i = 0; i < nsArray.count; i++) { - JSStringRef jsString = JSStringCreateWithCFString((CFStringRef)[nsArray objectAtIndex:i]); - cArray[i] = JSValueMakeString(_ctx, jsString); - JSStringRelease(jsString); - } - JSValueRef jsArray = (JSValueRef)JSObjectMakeArray(_ctx, nsArray.count, cArray, NULL); - free(cArray); - return jsArray; -} - -@end diff --git a/Atom/xibs/AtomWindow.xib b/Atom/ClientWindow.xib similarity index 71% rename from Atom/xibs/AtomWindow.xib rename to Atom/ClientWindow.xib index 36fd520b4..d280e167c 100644 --- a/Atom/xibs/AtomWindow.xib +++ b/Atom/ClientWindow.xib @@ -1,7 +1,7 @@ - 1070 + 1060 11C74 1938 1138.23 @@ -35,26 +35,24 @@ NSApplication - + 15 2 - {{288, 20}, {725, 723}} - 1954021376 - untitled + {{196, 240}, {637, 578}} + 544735232 + Window NSWindow - + 256 - {725, 723} + {637, 578} - - {{0, 0}, {1440, 878}} + {{0, 0}, {2560, 1418}} {10000000000000, 10000000000000} - Atomicity YES @@ -65,9 +63,17 @@ window - + - 7 + 3 + + + + webView + + + + 4 @@ -75,7 +81,7 @@ YES 0 - + YES @@ -84,37 +90,34 @@ -2 - + File's Owner -1 - + First Responder -3 - + Application - 3 - + 1 + YES - + - + - 4 - - - YES - - + 2 + + @@ -125,10 +128,10 @@ -1.IBPluginDependency -2.IBPluginDependency -3.IBPluginDependency - 3.IBPluginDependency - 3.IBWindowTemplateEditedContentRect - 3.NSWindowTemplate.visibleAtLaunch - 4.IBPluginDependency + 1.IBPluginDependency + 1.IBWindowTemplateEditedContentRect + 1.NSWindowTemplate.visibleAtLaunch + 2.IBPluginDependency YES @@ -136,24 +139,24 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - {{324, 121}, {725, 723}} + {{357, 418}, {480, 270}} com.apple.InterfaceBuilder.CocoaPlugin YES - - + + YES - - + + - 7 + 4 @@ -161,6 +164,17 @@ AtomController NSWindowController + + webView + NSView + + + webView + + webView + NSView + + IBProjectSource ./Classes/AtomController.h @@ -170,6 +184,10 @@ 0 IBCocoaFramework + + com.apple.InterfaceBuilder.CocoaPlugin.macosx + + com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3 diff --git a/Atom/Icon.icns b/Atom/Icon.icns deleted file mode 100644 index 01419f162..000000000 Binary files a/Atom/Icon.icns and /dev/null differ diff --git a/Atom/Atom-Info.plist b/Atom/Info.plist old mode 100644 new mode 100755 similarity index 64% rename from Atom/Atom-Info.plist rename to Atom/Info.plist index 0ae74daad..7ecd151e3 --- a/Atom/Atom-Info.plist +++ b/Atom/Info.plist @@ -3,32 +3,26 @@ CFBundleDevelopmentRegion - en + English CFBundleExecutable ${EXECUTABLE_NAME} CFBundleIconFile - Icon.icns + Atom CFBundleIdentifier - GitHub.${PRODUCT_NAME:rfc1034identifier} + org.cef.cefclient CFBundleInfoDictionaryVersion 6.0 CFBundleName ${PRODUCT_NAME} CFBundlePackageType APPL - CFBundleShortVersionString - 1.0 CFBundleSignature ???? CFBundleVersion - 1 - LSMinimumSystemVersion - ${MACOSX_DEPLOYMENT_TARGET} - NSHumanReadableCopyright - Copyright © 2011 __MyCompanyName__. All rights reserved. + 1.0 NSMainNibFile MainMenu NSPrincipalClass - AtomApp + Atom diff --git a/Atom/JSCocoa/BridgeSupportController.h b/Atom/JSCocoa/BridgeSupportController.h deleted file mode 100644 index 5dbab0f07..000000000 --- a/Atom/JSCocoa/BridgeSupportController.h +++ /dev/null @@ -1,43 +0,0 @@ -// -// BridgeSupportController.h -// JSCocoa -// -// Created by Patrick Geiller on 08/07/08. -// Copyright 2008 __MyCompanyName__. All rights reserved. -// - -#if !TARGET_IPHONE_SIMULATOR && !TARGET_OS_IPHONE -#import -#endif - -@interface BridgeSupportController : NSObject { - - - NSMutableArray* paths; - NSMutableArray* xmlDocuments; - - NSMutableDictionary* hash; - NSMutableDictionary* variadicSelectors; - NSMutableDictionary* variadicFunctions; -} - -+ (id)sharedController; - -- (BOOL)loadBridgeSupport:(NSString*)path; -- (BOOL)isBridgeSupportLoaded:(NSString*)path; -- (NSUInteger)bridgeSupportIndexForString:(NSString*)string; - -- (NSMutableDictionary*)variadicSelectors; -- (NSMutableDictionary*)variadicFunctions; - -/* -- (NSString*)query:(NSString*)name withType:(NSString*)type; -- (NSString*)query:(NSString*)name withType:(NSString*)type inBridgeSupportFile:(NSString*)file; -*/ -- (NSString*)queryName:(NSString*)name; -- (NSString*)queryName:(NSString*)name type:(NSString*)type; - -- (NSArray*)keys; - - -@end diff --git a/Atom/JSCocoa/BridgeSupportController.m b/Atom/JSCocoa/BridgeSupportController.m deleted file mode 100644 index 82976be77..000000000 --- a/Atom/JSCocoa/BridgeSupportController.m +++ /dev/null @@ -1,254 +0,0 @@ -// -// BridgeSupportController.m -// JSCocoa -// -// Created by Patrick Geiller on 08/07/08. -// Copyright 2008 __MyCompanyName__. All rights reserved. -// - -#import "BridgeSupportController.h" - - -@implementation BridgeSupportController - - -+ (id)sharedController -{ - static id singleton; - @synchronized(self) - { - if (!singleton) - singleton = [[BridgeSupportController alloc] init]; - return singleton; - } - return singleton; -} - -- (id)init -{ - self = [super init]; - - paths = [[NSMutableArray alloc] init]; - xmlDocuments = [[NSMutableArray alloc] init]; - hash = [[NSMutableDictionary alloc] init]; - variadicSelectors = [[NSMutableDictionary alloc] init]; - variadicFunctions = [[NSMutableDictionary alloc] init]; - - return self; -} - -- (void)dealloc -{ - [variadicFunctions release]; - [variadicSelectors release]; - [hash release]; - [paths release]; - [xmlDocuments release]; - - [super dealloc]; -} - -// -// Load a bridgeSupport file into a hash as { name : xmlTagString } -// -- (BOOL)loadBridgeSupport:(NSString*)path -{ - NSError* error = nil; - /* - Adhoc parser - NSXMLDocument is too slow - loading xml document as string then querying on-demand is too slow - can't get CFXMLParserRef to work - don't wan't to delve into expat - -> ad hoc : load file, build a hash of { name : xmlTagString } - */ - NSString* xmlDocument = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:&error]; - if (error) return NSLog(@"loadBridgeSupport : %@", error), NO; - - char* c = (char*)[xmlDocument UTF8String]; -#ifdef __OBJC_GC__ - char* originalC = c; - [[NSGarbageCollector defaultCollector] disableCollectorForPointer:originalC]; -#endif - -// double t0 = CFAbsoluteTimeGetCurrent(); - // Start parsing - for (; *c; c++) - { - if (*c == '<') - { - char startTagChar = c[1]; - if (startTagChar == 0) return NO; - - // 'co' constant - // 'cl' class - // 'e' enum - // 'fu' function - // 'st' struct - if ((c[1] == 'c' && (c[2] == 'o' || c[2] == 'l')) || c[1] == 'e' || (c[1] == 'f' && c[2] == 'u') || (c[1] == 's' && c[2] == 't')) - { - // Extract name - char* tagStart = c; - for (; *c && *c != '\''; c++); - c++; - char* c0 = c; - for (; *c && *c != '\''; c++); - - id name = [[NSString alloc] initWithBytes:c0 length:c-c0 encoding:NSUTF8StringEncoding]; - - // Move to tag end - BOOL foundEndTag = NO; - BOOL foundOpenTag = NO; - c++; - for (; *c && !foundEndTag; c++) - { - if (*c == '<') foundOpenTag = YES; - else - if (*c == '/') - { - if (!foundOpenTag) - { - if(c[1] == '>') foundEndTag = YES, c++; - } - else - { - if (startTagChar == c[1]) - { - foundEndTag = YES; - // Skip to end of tag - for (; *c && *c != '>'; c++); - } - } - } - else - // Variadic parsing - if (c[0] == 'v' && c[1] == 'a' && c[2] == 'r') - { - if (strncmp(c, "variadic", 8) == 0) - { - // Skip back to tag start - c0 = c; - for (; *c0 != '<'; c0--); - - // Tag name starts with 'm' : variadic method - // - if (c0[1] == 'm') - { - c = c0; - id variadicMethodName = nil; - // Extract selector name - for (; *c != '>'; c++) - { - if (c[0] == ' ' && c[1] == 's' && c[2] == 'e' && c[3] == 'l') - { - for (; *c && *c != '\''; c++); - c++; - c0 = c; - for (; *c && *c != '\''; c++); - variadicMethodName = [[[NSString alloc] initWithBytes:c0 length:c-c0 encoding:NSUTF8StringEncoding] autorelease]; - } - } - [variadicSelectors setValue:@"true" forKey:variadicMethodName]; -// NSLog(@"SELECTOR %@", name); - } - else - // Variadic function - // - { - [variadicFunctions setValue:@"true" forKey:name]; -// NSLog(@"function %@", name); - } - } - } - } - - c0 = tagStart; - id value = [[NSString alloc] initWithBytes:c0 length:c-c0 encoding:NSUTF8StringEncoding]; - - [hash setValue:value forKey:name]; - [value release]; - [name release]; - } - } - } -// double t1 = CFAbsoluteTimeGetCurrent(); -// NSLog(@"BridgeSupport %@ parsed in %f", [[path lastPathComponent] stringByDeletingPathExtension], t1-t0); -#ifdef __OBJC_GC__ - [[NSGarbageCollector defaultCollector] enableCollectorForPointer:originalC]; -#endif - [paths addObject:path]; - [xmlDocuments addObject:xmlDocument]; - - return YES; -} - - -- (BOOL)isBridgeSupportLoaded:(NSString*)path -{ - NSUInteger idx = [self bridgeSupportIndexForString:path]; - return idx == NSNotFound ? NO : YES; -} - -// -// bridgeSupportIndexForString -// given 'AppKit', return index of '/System/Library/Frameworks/AppKit.framework/Versions/C/Resources/BridgeSupport/AppKitFull.bridgesupport' -// -- (NSUInteger)bridgeSupportIndexForString:(NSString*)string -{ - NSUInteger i, l = [paths count]; - for (i=0; i -#import -#define MACOSX -#import -#endif -#import "BridgeSupportController.h" -#import "JSCocoaPrivateObject.h" -#import "JSCocoaFFIArgument.h" -#import "JSCocoaFFIClosure.h" - - -// JS value container, used by methods wanting a straight JSValue and not a converted JS->ObjC value. -struct JSValueRefAndContextRef -{ - JSValueRef value; - JSContextRef ctx; -}; -typedef struct JSValueRefAndContextRef JSValueRefAndContextRef; - -#if TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE -#import "iPhone/libffi/ffi.h" -#import "iPhone/BurksPool.h" -#endif - - -// -// JSCocoaController -// -@interface JSCocoaController : NSObject { - - JSGlobalContextRef ctx; - BOOL ownsContext; - id _delegate; - - // - // Split call - // Allows calling multi param ObjC messages with a jQuery-like syntax. - // - // obj.do({ this : 'hello', andThat : 'world' }) - // instead of - // obj.dothis_andThat_('hello', 'world') - // - BOOL useSplitCall; - - // JSLint : used for ObjJ syntax, class syntax, return if - BOOL useJSLint; - - // Auto call zero arg methods : allow NSWorkspace.sharedWorkspace instead of NSWorkspace.sharedWorkspace() - BOOL useAutoCall; - // Allow setting javascript values on boxed objects (which are collected after nulling all references to them) - BOOL canSetOnBoxedObjects; - // Allow calling obj.method(...) instead of obj.method_(...) - BOOL callSelectorsMissingTrailingSemicolon; - - // Log all exceptions to NSLog, even if they're caught later by downstream Javascript (in f(g()), log even if f catches after g threw) - BOOL logAllExceptions; - - // - // Safe dealloc (For ObjC classes written in Javascript) - // - (void)dealloc cannot be overloaded as it is called during JS GC, which forbids new JS code execution. - // As the js dealloc method cannot be called, safe dealloc allows it to be executed during the next run loop cycle - // NOTE : upon destroying a JSCocoaController, safe dealloc is disabled - // - BOOL useSafeDealloc; - - - NSMutableDictionary* boxedObjects; - - -} - -@property (assign) id delegate; -@property BOOL useSafeDealloc, useSplitCall, useJSLint, useAutoCall, callSelectorsMissingTrailingSemicolon, canSetOnBoxedObjects, logAllExceptions; - - -- (id)init; -- (id)initWithGlobalContext:(JSGlobalContextRef)ctx; - -+ (id)sharedController; -+ (id)controllerFromContext:(JSContextRef)ctx; -+ (BOOL)hasSharedController; -- (JSGlobalContextRef)ctx; -+ (void)hazardReport; -+ (NSString*)runningArchitecture; -+ (void)updateCustomCallPaths; -- (void)accomodateWebKitInspector; - -// -// Evaluation -// -- (id)eval:(NSString*)script; -- (id)callFunction:(NSString*)name; -- (id)callFunction:(NSString*)name withArguments:(NSArray*)arguments; -- (BOOL)hasFunction:(NSString*)name; -- (BOOL)isSyntaxValid:(NSString*)script; - -- (BOOL)evalJSFile:(NSString*)path; -- (BOOL)evalJSFile:(NSString*)path toJSValueRef:(JSValueRef*)returnValue; -- (JSValueRef)evalJSString:(NSString*)script; -- (JSValueRef)evalJSString:(NSString*)script withScriptPath:(NSString*)path; -- (JSValueRef)callJSFunction:(JSValueRef)function withArguments:(NSArray*)arguments; -- (JSValueRef)callJSFunctionNamed:(NSString*)functionName withArguments:arguments, ... NS_REQUIRES_NIL_TERMINATION; -- (JSValueRef)callJSFunctionNamed:(NSString*)functionName withArgumentsArray:(NSArray*)arguments; -- (JSObjectRef)JSFunctionNamed:(NSString*)functionName; -- (BOOL)hasJSFunctionNamed:(NSString*)functionName; -- (NSString*)expandJSMacros:(NSString*)script path:(NSString*)path; -- (NSString*)expandJSMacros:(NSString*)script path:(NSString*)path errors:(NSMutableArray*)array; -- (BOOL)isSyntaxValid:(NSString*)script error:(NSString**)error; -- (BOOL)setObject:(id)object withName:(NSString*)name; -- (BOOL)setObject:(id)object withName:(NSString*)name attributes:(JSPropertyAttributes)attributes; -- (BOOL)setObjectNoRetain:(id)object withName:(NSString*)name attributes:(JSPropertyAttributes)attributes; -- (id)objectWithName:(NSString*)name; -- (BOOL)removeObjectWithName:(NSString*)name; -// Get ObjC and raw values from Javascript -- (id)unboxJSValueRef:(JSValueRef)jsValue; -- (BOOL)toBool:(JSValueRef)value; -- (double)toDouble:(JSValueRef)value; -- (int)toInt:(JSValueRef)value; -- (NSString*)toString:(JSValueRef)value; -// Wrapper for unboxJSValueRef -- (id)toObject:(JSValueRef)value; - - -// -// Framework -// -- (BOOL)loadFrameworkWithName:(NSString*)name; -- (BOOL)loadFrameworkWithName:(NSString*)frameworkName inPath:(NSString*)path; - -// -// Garbage collection -// -+ (void)garbageCollect; -- (void)garbageCollect; -- (void)unlinkAllReferences; -+ (void)upJSCocoaPrivateObjectCount; -+ (void)downJSCocoaPrivateObjectCount; -+ (int)JSCocoaPrivateObjectCount; - -+ (void)upJSValueProtectCount; -+ (void)downJSValueProtectCount; -+ (int)JSValueProtectCount; - -+ (void)logInstanceStats; -- (id)instanceStats; -- (void)logBoxedObjects; - -// -// Class inspection (shortcuts to JSCocoaLib) -// -+ (id)rootclasses; -+ (id)classes; -+ (id)protocols; -+ (id)imageNames; -+ (id)methods; -+ (id)runtimeReport; -+ (id)explainMethodEncoding:(id)encoding; - -// -// Class handling -// -+ (BOOL)overloadInstanceMethod:(NSString*)methodName class:(Class)class jsFunction:(JSValueRefAndContextRef)valueAndContext; -+ (BOOL)overloadClassMethod:(NSString*)methodName class:(Class)class jsFunction:(JSValueRefAndContextRef)valueAndContext; - -+ (BOOL)addClassMethod:(NSString*)methodName class:(Class)class jsFunction:(JSValueRefAndContextRef)valueAndContext encoding:(char*)encoding; -+ (BOOL)addInstanceMethod:(NSString*)methodName class:(Class)class jsFunction:(JSValueRefAndContextRef)valueAndContext encoding:(char*)encoding; - -// Tests -- (int)runTests:(NSString*)path; -- (int)runTests:(NSString*)path withSelector:(SEL)sel; - -// -// Autorelease pool -// -+ (void)allocAutoreleasePool; -+ (void)deallocAutoreleasePool; - -// -// Boxing : each object gets only one box, stored in boxedObjects -// -//+ (JSObjectRef)boxedJSObject:(id)o inContext:(JSContextRef)ctx; -- (JSObjectRef)boxObject:(id)o; -- (BOOL)isObjectBoxed:(id)o; -- (void)deleteBoxOfObject:(id)o; -//+ (void)downBoxedJSObjectCount:(id)o; - - -// -// Various internals -// -//+ (JSObjectRef)jsCocoaPrivateObjectInContext:(JSContextRef)ctx; -- (JSObjectRef)newPrivateObject; -- (JSObjectRef)newPrivateFunction; -+ (NSMutableArray*)parseObjCMethodEncoding:(const char*)typeEncoding; -+ (NSMutableArray*)parseCFunctionEncoding:(NSString*)xml functionName:(NSString**)functionNamePlaceHolder; - -//+ (void)ensureJSValueIsObjectAfterInstanceAutocall:(JSValueRef)value inContext:(JSContextRef)ctx; -- (NSString*)formatJSException:(JSValueRef)exception; -- (id)selectorForJSFunction:(JSObjectRef)function; - - -- (const char*)typeEncodingOfMethod:(NSString*)methodName class:(NSString*)className; -+ (const char*)typeEncodingOfMethod:(NSString*)methodName class:(NSString*)className; - - - -@end - - -// -// JSCocoa delegate methods -// - -// -// Error reporting -// -@interface NSObject (JSCocoaControllerDelegateMethods) -- (void) JSCocoa:(JSCocoaController*)controller hadError:(NSString*)error onLineNumber:(NSInteger)lineNumber atSourceURL:(id)url; -- (void) safeDealloc; - -// -// Getting -// -// Check if getting property is allowed -- (BOOL) JSCocoa:(JSCocoaController*)controller canGetProperty:(NSString*)propertyName ofObject:(id)object inContext:(JSContextRef)ctx exception:(JSValueRef*)exception; -// Custom handler for getting properties -// Return a custom JSValueRef to bypass JSCocoa -// Return NULL to let JSCocoa handle getProperty -// Return JSValueMakeNull() to return a Javascript null -- (JSValueRef) JSCocoa:(JSCocoaController*)controller getProperty:(NSString*)propertyName ofObject:(id)object inContext:(JSContextRef)ctx exception:(JSValueRef*)exception; - -// -// Setting -// -// Check if setting property is allowed -- (BOOL) JSCocoa:(JSCocoaController*)controller canSetProperty:(NSString*)propertyName ofObject:(id)object toValue:(JSValueRef)value inContext:(JSContextRef)ctx exception:(JSValueRef*)exception; -// Custom handler for setting properties -// Return YES to indicate you handled setting -// Return NO to let JSCocoa handle setProperty -- (BOOL) JSCocoa:(JSCocoaController*)controller setProperty:(NSString*)propertyName ofObject:(id)object toValue:(JSValueRef)value inContext:(JSContextRef)ctx exception:(JSValueRef*)exception; - -// -// Calling -// -// Check if calling a C function is allowed -- (BOOL) JSCocoa:(JSCocoaController*)controller canCallFunction:(NSString*)functionName argumentCount:(size_t)argumentCount arguments:(JSValueRef*)arguments inContext:(JSContextRef)ctx exception:(JSValueRef*)exception; -// Check if calling an ObjC method is allowed -- (BOOL) JSCocoa:(JSCocoaController*)controller canCallMethod:(NSString*)methodName ofObject:(id)object argumentCount:(size_t)argumentCount arguments:(JSValueRef*)arguments inContext:(JSContextRef)ctx exception:(JSValueRef*)exception; -// Custom handler for calling -// Return YES to indicate you handled calling -// Return NO to let JSCocoa handle calling -- (JSValueRef) JSCocoa:(JSCocoaController*)controller callMethod:(NSString*)methodName ofObject:(id)callee privateObject:(JSCocoaPrivateObject*)thisPrivateObject argumentCount:(size_t)argumentCount arguments:(JSValueRef*)arguments inContext:(JSContextRef)localCtx exception:(JSValueRef*)exception; - -// -// Getting global properties (classes, structures, C function names, enums via OSXObject_getProperty) -// -// Check if getting property is allowed -- (BOOL) JSCocoa:(JSCocoaController*)controller canGetGlobalProperty:(NSString*)propertyName inContext:(JSContextRef)ctx exception:(JSValueRef*)exception; -// Custom handler for getting properties -// Return a custom JSValueRef to bypass JSCocoa -// Return NULL to let JSCocoa handle getProperty -// Return JSValueMakeNull() to return a Javascript null -- (JSValueRef) JSCocoa:(JSCocoaController*)controller getGlobalProperty:(NSString*)propertyName inContext:(JSContextRef)ctx exception:(JSValueRef*)exception; - -// -// Returning values to Javascript -// -// Called before returning any value to Javascript : return a new value or the original one -//- (JSValueRef) JSCocoa:(JSCocoaController*)controller willReturnValue:(JSValueRef)value inContext:(JSContextRef)ctx exception:(JSValueRef*)exception; - -// -// Evaling -// -// Check if file can be loaded -- (BOOL)JSCocoa:(JSCocoaController*)controller canLoadJSFile:(NSString*)path; -// Check if script can be evaluated -- (BOOL)JSCocoa:(JSCocoaController*)controller canEvaluateScript:(NSString*)script; -// Called before evalJSString, used to modify script about to be evaluated -// Return a custom NSString (eg a macro expanded version of the source) -// Return NULL to let JSCocoa handle evaluation -- (NSString*)JSCocoa:(JSCocoaController*)controller willEvaluateScript:(NSString*)script; - -@end - - -// -// JSCocoa shorthand -// -@interface JSCocoa : JSCocoaController -@end - -// -// Boxed object cache : holds one JSObjectRef for each reference to a pointer to an ObjC object -// -@interface BoxedJSObject : NSObject { - JSObjectRef jsObject; -} -- (void)setJSObject:(JSObjectRef)o; -- (JSObjectRef)jsObject; - -@end - -// -// Helpers -// -id NSStringFromJSValue(JSContextRef ctx, JSValueRef value); -//void* malloc_autorelease(size_t size); - -// Convert values between contexts (eg user context and webkit page context) -JSValueRef valueToExternalContext(JSContextRef ctx, JSValueRef value, JSContextRef externalCtx); - -// valueOf() is called by Javascript on objects, eg someObject + ' someString' -JSValueRef valueOfCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef *exception); - -// -// From PyObjC : when to call objc_msgSend_stret, for structure return -// Depending on structure size & architecture, structures are returned as function first argument (done transparently by ffi) or via registers -// - -#if defined(__ppc__) -# define SMALL_STRUCT_LIMIT 4 -#elif defined(__ppc64__) -# define SMALL_STRUCT_LIMIT 8 -#elif defined(__i386__) -# define SMALL_STRUCT_LIMIT 8 -#elif defined(__x86_64__) -# define SMALL_STRUCT_LIMIT 16 -#elif TARGET_OS_IPHONE -// TOCHECK -# define SMALL_STRUCT_LIMIT 4 -#else -# error "Unsupported MACOSX platform" -#endif - - -// Stored in boxedobjects to access a list of methods, properties, ... -#define RuntimeInformationPropertyName "info" - - - -/* -Some more doc - - __jsHash - __jsCocoaController - Instance variables set on ObjC classes written in Javascript. - These variables enable classes to store Javascript values in them. - -*/ - - diff --git a/Atom/JSCocoa/JSCocoaController.m b/Atom/JSCocoa/JSCocoaController.m deleted file mode 100644 index 97fa8fe75..000000000 --- a/Atom/JSCocoa/JSCocoaController.m +++ /dev/null @@ -1,5042 +0,0 @@ -// -// JSCocoa.m -// JSCocoa -// -// Created by Patrick Geiller on 09/07/08. -// Copyright 2008 __MyCompanyName__. All rights reserved. -// - - -#import "JSCocoaController.h" -#import "JSCocoaLib.h" - -#pragma mark JS objects forward definitions - -// Global object -static JSValueRef OSXObject_getProperty(JSContextRef, JSObjectRef, JSStringRef, JSValueRef*); -static void OSXObject_getPropertyNames(JSContextRef, JSObjectRef, JSPropertyNameAccumulatorRef); - -// Private JS object callbacks -static void jsCocoaObject_initialize(JSContextRef, JSObjectRef); -static void jsCocoaObject_finalize(JSObjectRef); -static JSValueRef jsCocoaObject_callAsFunction(JSContextRef, JSObjectRef, JSObjectRef, size_t, const JSValueRef [], JSValueRef*); -//static bool jsCocoaObject_hasProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName); -static JSValueRef jsCocoaObject_getProperty(JSContextRef, JSObjectRef, JSStringRef, JSValueRef*); -static bool jsCocoaObject_setProperty(JSContextRef, JSObjectRef, JSStringRef, JSValueRef, JSValueRef*); -static bool jsCocoaObject_deleteProperty(JSContextRef, JSObjectRef, JSStringRef, JSValueRef*); -static void jsCocoaObject_getPropertyNames(JSContextRef, JSObjectRef, JSPropertyNameAccumulatorRef); -static JSObjectRef jsCocoaObject_callAsConstructor(JSContextRef, JSObjectRef, size_t, const JSValueRef [], JSValueRef*); -static JSValueRef jsCocoaObject_convertToType(JSContextRef ctx, JSObjectRef object, JSType type, JSValueRef* exception); -static bool jsCocoaObject_hasInstance(JSContextRef ctx, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception); - -static JSValueRef jsCocoaInfo_getProperty(JSContextRef, JSObjectRef, JSStringRef, JSValueRef*); -static void jsCocoaInfo_getPropertyNames(JSContextRef, JSObjectRef, JSPropertyNameAccumulatorRef); - -// Set on valueOf callback property of objects -#define JSCocoaInternalAttribute kJSPropertyAttributeDontEnum - -// These will be destroyed when the last JSCocoa instance dies -static JSClassRef OSXObjectClass = NULL; -static JSClassRef jsCocoaObjectClass = NULL; -static JSClassRef jsCocoaFunctionClass= NULL; -static JSClassRef jsCocoaInfoClass = NULL; -static JSClassRef hashObjectClass = NULL; - -// Convenience method to throw a Javascript exception -static void throwException(JSContextRef ctx, JSValueRef* exception, NSString* reason); - - -BOOL isUsingStret(id argumentEncodings); -JSValueRef valueFromExternalContext(JSContextRef externalCtx, JSValueRef value, JSContextRef ctx); -void* getObjCCallAddress(id argumentEncodings); -JSValueRef boxedValueFromExternalContext(JSContextRef externalCtx, JSValueRef value, JSContextRef ctx); - -// iPhone specifics -#if TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE -const JSClassDefinition kJSClassDefinitionEmpty = { 0, 0, - NULL, NULL, - NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; -#import "GDataDefines.h" -#import "GDataXMLNode.h" -#endif - -// Appended to swizzled method names -#define OriginalMethodPrefix @"original" - - - - - - - -// -// JSCocoaController -// -#pragma mark - -#pragma mark JSCocoaController - -@interface JSCocoaController (Private) -- (void) callDelegateForException:(JSValueRef)exception; -@end - -@implementation JSCocoaController - - -// Instance properties -@synthesize delegate=_delegate; -@synthesize useSafeDealloc, useSplitCall, useJSLint, useAutoCall, callSelectorsMissingTrailingSemicolon, canSetOnBoxedObjects, logAllExceptions; - -// Shared data - - // Given a jsFunction, retrieve its closure (jsFunction's pointer address is used as key) - static id closureHash; - // Given a jsFunction, retrieve its selector - static id jsFunctionSelectors; - // Given a jsFunction, retrieve which class it's attached to - static id jsFunctionClasses; - // Given a class, return the parent class implementing JSCocoaHolder method - static id jsClassParents; - // List of all ObjC classes written in Javascript - static id jsClasses; - - // Given a class + methodName, retrieve its jsFunction - static id jsFunctionHash; - - // Split call cache - static id splitCallCache; - - // Shared instance stats - static id sharedInstanceStats = nil; - - // Boxed objects -// static id boxedObjects; - - - // Auto call zero arg methods : allow NSWorkspace.sharedWorkspace instead of NSWorkspace.sharedWorkspace() -// static BOOL useAutoCall; - // Allow calling obj.method(...) instead of obj.method_(...) -// static BOOL callSelectorsMissingTrailingSemicolon; - // Allows setting javascript values on boxed objects (which are collected after nulling all references to them) -// static BOOL canSetOnBoxedObjects; - - // If true, all exceptions will be sent to NSLog, event if they're caught later on by some Javascript core -// static BOOL logAllExceptions; - // Is speaking when throwing exceptions -// static BOOL isSpeaking; - - // Controller count - static int controllerCount = 0; - - // Hash used to quickly check for variadic methods, Original, Super, toString, valueOf ... - NSMutableDictionary* customCallPaths; - BOOL customCallPathsCacheIsClean; - - // Javascript functions defined for ObjC classes are stored in this hash - // __globalJSFunctionRepository__[className][propertyName] - -// -// Init -// -- (id)initWithGlobalContext:(JSGlobalContextRef)_ctx -{ -// NSLog(@"JSCocoa : %p spawning with context %p", self, _ctx); - self = [super init]; - controllerCount++; - - useAutoCall = YES; - callSelectorsMissingTrailingSemicolon = YES; - canSetOnBoxedObjects= NO; - logAllExceptions = NO; - boxedObjects = [NSMutableDictionary new]; - - @synchronized(self) - { - if (!sharedInstanceStats) - { - sharedInstanceStats = [NSMutableDictionary new]; - closureHash = [NSMutableDictionary new]; - jsFunctionSelectors = [NSMutableDictionary new]; - jsFunctionClasses = [NSMutableDictionary new]; - jsFunctionHash = [NSMutableDictionary new]; - splitCallCache = [NSMutableDictionary new]; - jsClassParents = [NSMutableDictionary new]; -// boxedObjects = [NSMutableDictionary new]; - jsClasses = [NSMutableArray new]; - customCallPathsCacheIsClean = NO; - customCallPaths = nil; - } - } - - // - // Javascript classes with our callbacks - // - if (!OSXObjectClass) { - // - // OSX object javascript definition - // - JSClassDefinition OSXObjectDefinition = kJSClassDefinitionEmpty; - OSXObjectDefinition.className = "OSX"; - OSXObjectDefinition.getProperty = OSXObject_getProperty; - OSXObjectDefinition.getPropertyNames = OSXObject_getPropertyNames; - OSXObjectClass = JSClassCreate(&OSXObjectDefinition); - - - // - // Private object, used for holding references to objects, classes, structs - // - JSClassDefinition jsCocoaObjectDefinition = kJSClassDefinitionEmpty; - jsCocoaObjectDefinition.className = "JSCocoa box"; - jsCocoaObjectDefinition.initialize = jsCocoaObject_initialize; - jsCocoaObjectDefinition.finalize = jsCocoaObject_finalize; -// jsCocoaObjectDefinition.hasProperty = jsCocoaObject_hasProperty; - jsCocoaObjectDefinition.getProperty = jsCocoaObject_getProperty; - jsCocoaObjectDefinition.setProperty = jsCocoaObject_setProperty; - jsCocoaObjectDefinition.deleteProperty = jsCocoaObject_deleteProperty; - jsCocoaObjectDefinition.getPropertyNames = jsCocoaObject_getPropertyNames; -// jsCocoaObjectDefinition.callAsFunction = jsCocoaObject_callAsFunction; - jsCocoaObjectDefinition.callAsConstructor = jsCocoaObject_callAsConstructor; -// jsCocoaObjectDefinition.hasInstance = jsCocoaObject_hasInstance; - jsCocoaObjectDefinition.convertToType = jsCocoaObject_convertToType; - jsCocoaObjectClass = JSClassCreate(&jsCocoaObjectDefinition); - - - // - // Second kind of private object, used to hold method and function names - // Separated from the object because "typeof NSDate.date" gave "function" instead of object, preventing enumeration in WebKit inspector - // - JSClassDefinition jsCocoaFunctionDefinition = kJSClassDefinitionEmpty; - jsCocoaFunctionDefinition.className = "JSCocoa box"; - jsCocoaFunctionDefinition.parentClass = jsCocoaObjectClass; - jsCocoaFunctionDefinition.callAsFunction = jsCocoaObject_callAsFunction; - jsCocoaFunctionClass = JSClassCreate(&jsCocoaFunctionDefinition); - - - // - // Holds __info in objects - // - JSClassDefinition jsCocoaInfoDefinition = kJSClassDefinitionEmpty; - jsCocoaInfoDefinition.className = "Runtime info"; - jsCocoaInfoDefinition.getProperty = jsCocoaInfo_getProperty; - jsCocoaInfoDefinition.getPropertyNames = jsCocoaInfo_getPropertyNames; - jsCocoaInfoClass = JSClassCreate(&jsCocoaInfoDefinition); - - - // - // Private Hash of derived classes, storing js values - // - JSClassDefinition jsCocoaHashObjectDefinition = kJSClassDefinitionEmpty; - hashObjectClass = JSClassCreate(&jsCocoaHashObjectDefinition); - } - - // - // Start context - // - - // Starting from our own context - if (!_ctx) - { - ctx = JSGlobalContextCreate(OSXObjectClass); - } - // Starting from an existing context - else - { - ctx = _ctx; - //JSGlobalContextRetain(ctx); - JSObjectRef o = JSObjectMake(ctx, OSXObjectClass, NULL); - // Set a global var named 'OSX' which will fulfill the usual role of JSCocoa's global object - JSStringRef jsName = JSStringCreateWithUTF8CString("OSX"); - JSObjectSetProperty(ctx, JSContextGetGlobalObject(ctx), jsName, o, kJSPropertyAttributeDontDelete, NULL); - JSStringRelease(jsName); - - [self accomodateWebKitInspector]; - } - -#if !TARGET_IPHONE_SIMULATOR && !TARGET_OS_IPHONE - [self loadFrameworkWithName:@"AppKit"]; - [self loadFrameworkWithName:@"CoreFoundation"]; - [self loadFrameworkWithName:@"Foundation"]; - [self loadFrameworkWithName:@"CoreGraphics" inPath:@"/System/Library/Frameworks/ApplicationServices.framework/Frameworks"]; -#endif - -#if TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE - [BurksPool setJSFunctionHash:jsFunctionHash]; -#endif - // Create a reference to ourselves, and make it read only, don't enum, don't delete - [self setObjectNoRetain:self withName:@"__jsc__" attributes:kJSPropertyAttributeReadOnly|kJSPropertyAttributeDontEnum|kJSPropertyAttributeDontDelete]; - - // Load class kit - if (!_ctx) - { - useJSLint = NO; - id lintPath = [[NSBundle bundleForClass:[self class]] pathForResource:@"jslint-jscocoa" ofType:@"js"]; - if ([[NSFileManager defaultManager] fileExistsAtPath:lintPath]) { - BOOL b = [self evalJSFile:lintPath]; - if (!b) - NSLog(@"[JSCocoa initWithGlobalContext:] JSLint not loaded"); - } - id classKitPath = [[NSBundle bundleForClass:[self class]] pathForResource:@"class" ofType:@"js"]; - if ([[NSFileManager defaultManager] fileExistsAtPath:classKitPath]) [self evalJSFile:classKitPath]; - } - - // Objects can use their own dealloc, normally used up by JSCocoa - // JSCocoa registers 'safeDealloc' in place of 'dealloc' and calls it in the next run loop cycle. - // (Dealloc might be called by JS GC, and running JS fails at this time) - // useSafeDealloc will be turned to NO upon JSCocoaController dealloc - useSafeDealloc = YES; - // Yep ! - useJSLint = YES; - // ObjJ syntax renders split call moot - useSplitCall = NO; - ownsContext = NO; - - [JSCocoa updateCustomCallPaths]; - return self; -} - -- (id)init -{ - id o = [self initWithGlobalContext:nil]; - ownsContext = YES; - return o; -} - - -// -// Dealloc -// -- (void)cleanUp -{ -// NSLog(@"JSCocoa : %p dying (ownsContext=%d)", self, ownsContext); - [self setUseSafeDealloc:NO]; - - // Cleanup if we created the JavascriptCore context. - // If not, let user do it. In a WebView, this method will be called during JS GC, - // and trying to execute more JS code will fail. - // User must clean up manually by calling unlinkAllReferences then destroying the webView - - - if (ownsContext) { - [self unlinkAllReferences]; - JSGarbageCollect(ctx); - [self setObjectNoRetain:self withName:@"__jsc__" attributes:kJSPropertyAttributeReadOnly|kJSPropertyAttributeDontEnum|kJSPropertyAttributeDontDelete]; - } - - controllerCount--; - if (controllerCount == 0) - { - if (OSXObjectClass) { - JSClassRelease(OSXObjectClass); - JSClassRelease(jsCocoaObjectClass); - JSClassRelease(jsCocoaFunctionClass); - JSClassRelease(jsCocoaInfoClass); - JSClassRelease(hashObjectClass); - OSXObjectClass = nil; - jsCocoaObjectClass = nil; - jsCocoaFunctionClass = nil; - jsCocoaInfoClass = nil; - hashObjectClass = nil; - } - - // We need to nil these all out, since they are static - // and if we make another JSCocoaController after this- they will - // still be around and that's kinda bad (like crashing bad). - [sharedInstanceStats release]; - sharedInstanceStats = nil; - [closureHash release]; - closureHash = nil; - [jsFunctionSelectors release]; - jsFunctionSelectors = nil; - [jsFunctionClasses release]; - jsFunctionClasses = nil; - [jsFunctionHash release]; - jsFunctionHash = nil; - [splitCallCache release]; - splitCallCache = nil; - [jsClassParents release]; - jsClassParents = nil; -// [boxedObjects release]; -// boxedObjects = nil; - [customCallPaths release]; - customCallPaths = nil; - - - // Remove classes : go backwards to remove child classes first - for (id class in [jsClasses reverseObjectEnumerator]) - objc_disposeClassPair([class pointerValue]); - - [jsClasses release]; - jsClasses = nil; - } - - [self removeObjectWithName:@"__jsc__"]; - if (ownsContext) - JSGlobalContextRelease(ctx); - - [boxedObjects release]; -} - -- (void)dealloc -{ - [self cleanUp]; - [super dealloc]; -} -- (void)finalize -{ - [self cleanUp]; - [super finalize]; -} - - -// -// Shared instance -// -static id JSCocoaSingleton = NULL; - -+ (id)sharedController -{ - @synchronized(self) - { - if (!JSCocoaSingleton) - { - // 1. alloc - // 2. store pointer - // 3. call init - // - // Why ? if init is calling sharedController, the pointer won't have been set and it will call itself over and over again. - // - JSCocoaSingleton = [self alloc]; -// NSLog(@"JSCocoa : allocating shared instance %p", JSCocoaSingleton); - [JSCocoaSingleton init]; - } - } - return JSCocoaSingleton; -} -+ (BOOL)hasSharedController -{ - return !!JSCocoaSingleton; -} - -// Retrieves the __jsc__ variable from a context and unbox it -+ (id)controllerFromContext:(JSContextRef)ctx -{ - JSStringRef jsName = JSStringCreateWithUTF8CString("__jsc__"); - JSValueRef jsValue = JSObjectGetProperty(ctx, JSContextGetGlobalObject(ctx), jsName, NULL); - JSStringRelease(jsName); - id jsc = nil; - [JSCocoaFFIArgument unboxJSValueRef:jsValue toObject:&jsc inContext:ctx]; - // Commented as it falsely reports failure when controller is cleaning up while being deallocated -// if (!jsc) NSLog(@"controllerFromContext couldn't find found the JSCocoaController in ctx %p", ctx); - return jsc; -} - -// Report if we're running a nightly JavascriptCore, with GC -+ (void)hazardReport -{ - Dl_info info; - // Get info about a JavascriptCore symbol - dladdr(dlsym(RTLD_DEFAULT, "JSClassCreate"), &info); - - BOOL runningFromSystemLibrary = [[NSString stringWithUTF8String:info.dli_fname] hasPrefix:@"/System"]; - if (!runningFromSystemLibrary) NSLog(@"***Running a nightly JavascriptCore***"); -#if !TARGET_OS_IPHONE - if ([NSGarbageCollector defaultCollector]) NSLog(@"***Running with ObjC Garbage Collection***"); -#endif -} -// Report what we're running on -+ (NSString*)runningArchitecture -{ -#if defined(__ppc__) - return @"PPC"; -// Unsupported -//#elif defined(__ppc64__) -// return @"PPC64"; -#elif defined(__i386__) - return @"i386"; -#elif defined(__x86_64__) - return @"x86_64"; -#elif TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR - return @"iPhone"; -#elif TARGET_OS_IPHONE && TARGET_IPHONE_SIMULATOR - return @"iPhone Simulator"; -#else - return @"unknown architecture"; -#endif -} - -// Replace the toString function with our own -- (void)accomodateWebKitInspector -{ - // The inspector uses Object's toString to extract the class name and print it, - // we replace that class name with valueOf when called for JSCocoa boxes - char* script = "\ - var _old_toString = Object.prototype.toString \n\ - Object.prototype.toString = function () \n\ - { \n\ - var str = _old_toString.call(this) \n\ - if (!str.match(/JSCocoa/)) \n\ - return str \n\ - return '[Object ' + (this.valueOf()) + ']' \n\ - } \n\ - "; - JSStringRef scriptJS = JSStringCreateWithCFString((CFStringRef)[NSString stringWithUTF8String:script]); - JSEvaluateScript(ctx, scriptJS, NULL, NULL, 1, NULL); - JSStringRelease(scriptJS); -} - - -#pragma mark Script evaluation - -// -// Quick eval of strings and functions returning ObjC objects -// -- (id)eval:(NSString*)script { return [self toObject:[self evalJSString:script]]; } -- (id)callFunction:(NSString*)name { - return [self toObject:[self callJSFunctionNamed:name withArgumentsArray:nil]]; -} -- (id)callFunction:(NSString*)name withArguments:(NSArray*)arguments { return [self toObject:[self callJSFunctionNamed:name withArgumentsArray:arguments]]; } -- (BOOL)hasFunction:(NSString*)name { return [self hasJSFunctionNamed:name]; } - -- (BOOL)isSyntaxValid:(NSString*)script { return [self isSyntaxValid:script error:nil]; } - - -// -// Eval of strings, functions, files, returning JavascriptCore objects -// -#pragma mark Script evaluation returning JavascriptCore objects - -// -// Evaluate a file -// -- (BOOL)evalJSFile:(NSString*)path toJSValueRef:(JSValueRef*)returnValue -{ - NSError* error; - id script = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:&error]; - // Skip .DS_Store and directories - if (script == nil) return NSLog(@"evalJSFile could not open %@ (%@) — Check file encoding (should be UTF8) and file build phase (should be in \"Copy Bundle Resources\")", path, error), NO; - - // - // Delegate canLoadJSFile - // - if (_delegate && [_delegate respondsToSelector:@selector(JSCocoa:canLoadJSFile:)] && ![_delegate JSCocoa:self canLoadJSFile:path]) return NO; - - // Expand macros - script = [self expandJSMacros:script path:path]; - if (!script) { - NSLog(@"evalJSFile:toJSValueRef: expandJSMacros returned null on %@", path); - return NO; - } - - // - // Delegate canEvaluateScript, willEvaluateScript - // - if (_delegate) - { - if ([_delegate respondsToSelector:@selector(JSCocoa:canEvaluateScript:)] && ![_delegate JSCocoa:self canEvaluateScript:script]) return NO; - if ([_delegate respondsToSelector:@selector(JSCocoa:willEvaluateScript:)]) script = [_delegate JSCocoa:self willEvaluateScript:script]; - } - - if (!customCallPathsCacheIsClean) [JSCocoa updateCustomCallPaths]; - - // Convert script and script URL to js strings - // JSStringRef scriptJS = JSStringCreateWithUTF8CString([script UTF8String]); - // Using CreateWithUTF8 yields wrong results on PPC - JSStringRef scriptJS = JSStringCreateWithCFString((CFStringRef)script); - JSStringRef scriptPath = JSStringCreateWithUTF8CString([path UTF8String]); - - // Eval ! - JSValueRef exception = NULL; - JSValueRef result = JSEvaluateScript(ctx, scriptJS, NULL, scriptPath, 1, &exception); - if (returnValue) *returnValue = result; - // Release - JSStringRelease(scriptPath); - JSStringRelease(scriptJS); - if (exception) - { -// NSLog(@"JSException - %@", [self formatJSException:exception]); - [self callDelegateForException:exception]; - return NO; - } - return YES; -} - - -// -// Evaluate a file, without caring about return result -// -- (BOOL)evalJSFile:(NSString*)path -{ - return [self evalJSFile:path toJSValueRef:nil]; -} - -// -// Evaluate a string -// -- (JSValueRef)evalJSString:(NSString*)script withScriptPath:(NSString*)path -{ - if (!script) return NULL; - - // Expand macros - id expandedScript = [self expandJSMacros:script path:path]; - if (expandedScript) - script = expandedScript; - - // - // Delegate canEvaluateScript, willEvaluateScript - // - if (_delegate) - { - if ([_delegate respondsToSelector:@selector(JSCocoa:canEvaluateScript:)] && ![_delegate JSCocoa:self canEvaluateScript:script]) return NULL; - if ([_delegate respondsToSelector:@selector(JSCocoa:willEvaluateScript:)]) script = [_delegate JSCocoa:self willEvaluateScript:script]; - } - - if (!script) - return NSLog(@"evalJSString has nothing to eval"), NULL; - - if (!customCallPathsCacheIsClean) [JSCocoa updateCustomCallPaths]; - - JSStringRef scriptJS = JSStringCreateWithCFString((CFStringRef)script); - JSValueRef exception = NULL; - JSStringRef scriptPath = path ? JSStringCreateWithUTF8CString([path UTF8String]) : NULL; - JSValueRef result = JSEvaluateScript(ctx, scriptJS, NULL, scriptPath, 1, &exception); - JSStringRelease(scriptJS); - if (path) JSStringRelease(scriptPath); - - if (exception) - { - [self callDelegateForException:exception]; - return NULL; - } - - return result; -} - -// Evaluate a string, no script path -- (JSValueRef)evalJSString:(NSString*)script -{ - return [self evalJSString:script withScriptPath:nil]; -} - - - -// -// Call a Javascript function by function reference (JSValueRef) -// -- (JSValueRef)callJSFunction:(JSValueRef)function withArguments:(NSArray*)arguments -{ - JSObjectRef jsFunction = JSValueToObject(ctx, function, NULL); - // Return if function is not of function type - if (!jsFunction) return NSLog(@"callJSFunction : value is not a function"), NULL; - - // Convert arguments - JSValueRef* jsArguments = NULL; - NSUInteger argumentCount = [arguments count]; - if (argumentCount) - { - jsArguments = malloc(sizeof(JSValueRef)*argumentCount); - for (int i=0; i= '0' && *argsParser <= '9') continue; - else - // Skip ObjC 'const', 'oneway' markers - if (*argsParser == 'r' || *argsParser == 'V') continue; - else - if (*argsParser == '{') - { - // Parse structure encoding - NSInteger count = 0; - [JSCocoaFFIArgument typeEncodingsFromStructureTypeEncoding:[NSString stringWithUTF8String:argsParser] parsedCount:&count]; - - id encoding = [[NSString alloc] initWithBytes:argsParser length:count encoding:NSUTF8StringEncoding]; - id argumentEncoding = [[JSCocoaFFIArgument alloc] init]; - // Set return value - if ([argumentEncodings count] == 0) [argumentEncoding setIsReturnValue:YES]; - [argumentEncoding setStructureTypeEncoding:encoding]; - [argumentEncodings addObject:argumentEncoding]; - [argumentEncoding release]; - - [encoding release]; - argsParser += count-1; - } - else - { - // Custom handling for pointers as they're not one char long. -// char type = *argsParser; - char* typeStart = argsParser; - if (*argsParser == '^') - while (*argsParser && !(*argsParser >= '0' && *argsParser <= '9')) argsParser++; - - id argumentEncoding = [[JSCocoaFFIArgument alloc] init]; - // Set return value - if ([argumentEncodings count] == 0) [argumentEncoding setIsReturnValue:YES]; - - // If pointer, copy pointer type (^i, ^{NSRect}) to the argumentEncoding - if (*typeStart == '^') - { - id encoding = [[NSString alloc] initWithBytes:typeStart length:argsParser-typeStart encoding:NSUTF8StringEncoding]; - [argumentEncoding setPointerTypeEncoding:encoding]; - [encoding release]; - } - else - { - BOOL didSet = [argumentEncoding setTypeEncoding:*typeStart]; - if (!didSet) - { - [argumentEncoding release]; - return nil; - } - // Blocks are '@?', skip '?' - if (typeStart[0] == _C_ID && typeStart[1] == _C_UNDEF) - argsParser++; - } - - [argumentEncodings addObject:argumentEncoding]; - [argumentEncoding release]; - } - if (!*argsParser) break; - } - return argumentEncodings; -} - -// -// This is parsed from BridgeSupport's xml -// -+ (NSMutableArray*)parseCFunctionEncoding:(NSString*)xml functionName:(NSString**)functionNamePlaceHolder -{ - id argumentEncodings = [NSMutableArray array]; - id xmlDocument = [[NSXMLDocument alloc] initWithXMLString:xml options:0 error:nil]; - [xmlDocument autorelease]; - - id rootElement = [xmlDocument rootElement]; - *functionNamePlaceHolder = [[rootElement attributeForName:@"name"] stringValue]; - - // Parse children and return value - NSUInteger i, numChildren = [rootElement childCount]; - id returnValue = NULL; - for (i=0; i introduced because under GC, NSData gets collected early. - -*/ -+ (BOOL)trySplitCall:(id*)_methodName class:(Class)class argumentCount:(size_t*)_argumentCount arguments:(JSValueRef**)_arguments ctx:(JSContextRef)c -{ - id methodName = *_methodName; - size_t argumentCount = *_argumentCount; - JSValueRef* arguments = *_arguments; - if (argumentCount != 1) return NO; - - // Get property array - JSObjectRef o = JSValueToObject(c, arguments[0], NULL); - if (!o) return NO; - JSPropertyNameArrayRef jsNames = JSObjectCopyPropertyNames(c, o); - - // Convert js names to NSString names : { jsName1 : value1, jsName2 : value 2 } -> NSArray[name1, name2] - id names = [NSMutableArray array]; - size_t i, nameCount = JSPropertyNameArrayGetCount(jsNames); - // Length of target selector = length of method + length of each (argument + ':') - NSUInteger targetSelectorLength = [methodName length]; - // Actual arguments - JSValueRef* actualArguments = malloc(sizeof(JSValueRef)*nameCount); - for (i=0; i (JS)JSObjectRef(o) --> (ObjC)BoxedJSObject(JSObjectRef(o)), - // ^stored in the boxedObjects hash to always return the same box for the same object - - // - // Create a new ObjC box around the JSValueRef boxing the JSObject - // - // We are returning an ObjC object to Javascript. - // That ObjC object is boxed in a Javascript object. - // For all boxing requests of the same ObjC object, that Javascript object needs to be unique for object comparisons to work : - // NSApplication.sharedApplication == NSApplication.sharedApplication - // (JavascriptCore has no hook for object to object comparison, that's why objects need to be unique) - // To guarantee unicity, we keep a cache of boxed objects. - // As boxed objects are JSObjectRef not derived from NSObject, we box them in an ObjC object. - // - - // Box the ObjC object in a JSObjectRef -// JSObjectRef jsObject = [JSCocoa jsCocoaPrivateObjectInContext:ctx]; - JSObjectRef jsObject = [self newPrivateObject]; - JSCocoaPrivateObject* private = JSObjectGetPrivate(jsObject); - private.type = @"@"; - [private setObject:o]; - - // Box the JSObjectRef in our ObjC object - value = [[BoxedJSObject alloc] init]; - [value setJSObject:jsObject]; - - // Add to dictionary and make it sole owner - [boxedObjects setValue:value forKey:key]; - [value release]; - return jsObject; -} - -- (BOOL)isObjectBoxed:(id)o { - id key = [NSString stringWithFormat:@"%p", o]; - return !![boxedObjects valueForKey:key]; -} - -- (void)deleteBoxOfObject:(id)o { - id key = [NSString stringWithFormat:@"%p", o]; - id value= [boxedObjects valueForKey:key]; - if (!value) - return; - [boxedObjects removeObjectForKey:key]; -} - -/* -+ (void)downBoxedJSObjectCount:(id)o -{ - id key = [NSString stringWithFormat:@"%p", o]; - id value = [boxedObjects valueForKey:key]; - if (!value) - return; - - [boxedObjects removeObjectForKey:key]; -} - -+ (id)boxedObjects -{ - return boxedObjects; -} -*/ -#pragma mark Helpers -- (id)selectorForJSFunction:(JSObjectRef)function -{ - return [jsFunctionSelectors valueForKey:[NSString stringWithFormat:@"%p", function]]; -} - -- (id)classForJSFunction:(JSObjectRef)function -{ - return [jsFunctionClasses valueForKey:[NSString stringWithFormat:@"%p", function]]; -} - -// -// Given an exception, get its line number, source URL, error message and return them in a NSString -// When throwing an exception from Javascript, throw an object instead of a string. -// This way, JavascriptCore will add line and sourceURL. -// (throw new String('error') instead of throw 'error') -// -+ (NSString*)formatJSException:(JSValueRef)exception inContext:(JSContextRef)context -{ - if (!exception) - return @"formatJSException:(null)"; - // Convert exception to string - JSStringRef resultStringJS = JSValueToStringCopy(context, exception, NULL); - NSString* b = (NSString*)JSStringCopyCFString(kCFAllocatorDefault, resultStringJS); - JSStringRelease(resultStringJS); - [NSMakeCollectable(b) autorelease]; - - // Only objects contain line and source URL - if (JSValueGetType(context, exception) != kJSTypeObject) return b; - - // Iterate over all properties of the exception - JSObjectRef jsObject = JSValueToObject(context, exception, NULL); - JSPropertyNameArrayRef jsNames = JSObjectCopyPropertyNames(context, jsObject); - size_t i, nameCount = JSPropertyNameArrayGetCount(jsNames); - id line = nil, sourceURL = nil; - for (i=0; i>>evaling %@", filePath); - - id evaled = nil; - @try { - evaled = [self performSelector:sel withObject:filePath]; -// NSLog(@">>>EVALED %d, %@", evaled, filePath); - } @catch (id e) { - NSLog(@"(Test exception from %@) %@", file, e); - evaled = nil; - } - if (!evaled) { - id error = [NSString stringWithFormat:@"test %@ failed (Ran %d out of %d tests)", file, count+1, [files count]]; - [JSCocoaController log:error]; - return NO; - } - count ++; - [self garbageCollect]; - } -#endif - return count; -} -- (int)runTests:(NSString*)path { - return [self runTests:path withSelector:@selector(evalJSFile:)]; -} - -#pragma mark Autorelease pool -static id autoreleasePool; -+ (void)allocAutoreleasePool { - autoreleasePool = [[NSAutoreleasePool alloc] init]; -} - -+ (void)deallocAutoreleasePool { - [autoreleasePool release]; -} - - -#pragma mark Garbage Collection -// -// Collect on top of the run loop, not in some JS function -// -+ (void)garbageCollect { - NSLog(@"*** Deprecated — call garbageCollect on an instance ***"); /*JSGarbageCollect(NULL);*/ -} -- (void)garbageCollect { - JSGarbageCollect(ctx); -} - -// -// Make all root Javascript variables point to null -// -- (void)unlinkAllReferences -{ - // Null and delete every reference to every live object -// [self evalJSString:@"for (var i in this) { log('DELETE ' + i); this[i] = null; delete this[i]; }"]; -// [self evalJSString:@"for (var i in this) { this[i] = null; delete this[i]; }"]; - -// id del = @"var keys = Object.keys(this); var c = keys.length; for (var i=0; i", - [self class], - self, - ((id)self == (id)[self class]) ? @"Class" : @"", - [boxedObject class], - boxedObject, - retainCount]; -*/ - - } -// NSLog(@"%@", boxedObjects); -} - -#pragma mark Class inspection -+ (id)rootclasses -{ - return [JSCocoaLib rootclasses]; -} -+ (id)classes -{ - return [JSCocoaLib classes]; -} -+ (id)protocols -{ - return [JSCocoaLib protocols]; -} -+ (id)imageNames -{ - return [JSCocoaLib imageNames]; -} -+ (id)methods -{ - return [JSCocoaLib methods]; -} -+ (id)runtimeReport -{ - return [JSCocoaLib runtimeReport]; -} -+ (id)explainMethodEncoding:(id)encoding -{ - id argumentEncodings = [JSCocoaController parseObjCMethodEncoding:[encoding UTF8String]]; - id explication = [NSMutableArray array]; - for (id arg in argumentEncodings) - [explication addObject:[arg typeDescription] - ]; - - return explication; -} - - - - -// JSCocoa : handle setting with callMethod -// object.width = 100 -// -> -// [object setWidth:100] -// -- (BOOL)JSCocoa:(JSCocoaController*)controller setProperty:(NSString*)propertyName ofObject:(id)object toValue:(JSValueRef)value inContext:(JSContextRef)localCtx exception:(JSValueRef*)exception -{ - // FIXME: this doesn't actually work with objc properties, and we can't always rely that this method will exist either... - // it should probably be moved up into the JSCocoa layer. - - NSString* setterName = [NSString stringWithFormat:@"set%@%@:", - [[propertyName substringWithRange:NSMakeRange(0,1)] capitalizedString], - [propertyName substringWithRange:NSMakeRange(1, [propertyName length]-1)]]; - - if ([self JSCocoa:controller callMethod:setterName ofObject:object privateObject:nil argumentCount:1 arguments:&value inContext:localCtx exception:exception]) { - return YES; - } - - return NO; -} -#pragma mark Distant Object Handling (DO) -// -// NSDistantObject call using NSInvocation -// -- (JSValueRef)JSCocoa:(JSCocoaController*)controller callMethod:(NSString*)methodName ofObject:(id)callee privateObject:(JSCocoaPrivateObject*)thisPrivateObject argumentCount:(size_t)argumentCount arguments:(JSValueRef*)arguments inContext:(JSContextRef)localCtx exception:(JSValueRef*)exception -{ - SEL selector = NSSelectorFromString(methodName); - if (class_getInstanceMethod([callee class], selector) || class_getClassMethod([callee class], selector)) { - return nil; - } - - NSMethodSignature *signature = [callee methodSignatureForSelector:selector]; - - if (!signature) { - return nil; - } - - // we need to do all this for NSDistantObject , since JSCocoa doesn't handle it natively. - - NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature]; - [invocation setSelector:selector]; - NSUInteger argIndex = 0; - while (argIndex < argumentCount) { - - id arg = 0x00; - - [JSCocoaFFIArgument unboxJSValueRef:arguments[argIndex] toObject:&arg inContext:localCtx]; - - const char *type = [signature getArgumentTypeAtIndex:argIndex + 2]; - // Structure argument - if (type && type[0] == '{') - { - id structureType = [NSString stringWithUTF8String:type]; - id fullStructureType = [JSCocoaFFIArgument structureFullTypeEncodingFromStructureTypeEncoding:structureType]; - - int size = [JSCocoaFFIArgument sizeOfStructure:structureType]; - JSObjectRef jsObject = JSValueToObject(ctx, arguments[argIndex], NULL); - if (size && fullStructureType && jsObject) - { - // Alloc structure size and let NSData deallocate it - void* source = malloc(size); - memset(source, 0, size); - [NSData dataWithBytesNoCopy:source length:size freeWhenDone:YES]; - - void* p = source; - NSInteger numParsed = [JSCocoaFFIArgument structureFromJSObjectRef:jsObject inContext:ctx inParentJSValueRef:NULL fromCString:(char*)[fullStructureType UTF8String] fromStorage:&p]; - if (numParsed) [invocation setArgument:source atIndex:argIndex+2]; - } - } - else - if ([arg isKindOfClass:[NSNumber class]]) { - -// const char *type = [signature getArgumentTypeAtIndex:argIndex + 2]; - if (strcmp(type, @encode(BOOL)) == 0) { - BOOL b = [arg boolValue]; - [invocation setArgument:&b atIndex:argIndex + 2]; - } - else if (strcmp(type, @encode(unsigned int)) == 0) { - unsigned int i = [arg unsignedIntValue]; - [invocation setArgument:&i atIndex:argIndex + 2]; - } - else if (strcmp(type, @encode(int)) == 0) { - int i = [arg intValue]; - [invocation setArgument:&i atIndex:argIndex + 2]; - } - else if (strcmp(type, @encode(unsigned long)) == 0) { - unsigned long l = [arg unsignedLongValue]; - [invocation setArgument:&l atIndex:argIndex + 2]; - } - else if (strcmp(type, @encode(long)) == 0) { - long l = [arg longValue]; - [invocation setArgument:&l atIndex:argIndex + 2]; - } - else if (strcmp(type, @encode(float)) == 0) { - float f = [arg floatValue]; - [invocation setArgument:&f atIndex:argIndex + 2]; - } - else if (strcmp(type, @encode(double)) == 0) { - double d = [arg doubleValue]; - [invocation setArgument:&d atIndex:argIndex + 2]; - } - else { // just do int for all else. - int i = [arg intValue]; - [invocation setArgument:&i atIndex:argIndex + 2]; - } - - } - else { - [invocation setArgument:&arg atIndex:argIndex + 2]; - } - - argIndex++; - } - - @try { - [invocation invokeWithTarget:callee]; - } - @catch (NSException * e) { - NSLog(@"Exception while calling %@. %@", methodName, [e reason]); - - if ([[e reason] isEqualToString:@"connection went invalid while waiting for a reply"]) { - // whoops? - // also, how do we not look for some funky localized string here? - // also also, can we now make whatever is pointing to this value, nil? - - if (thisPrivateObject) { - NSLog(@"Connection terminated, removing reference to object"); - thisPrivateObject.object = [NSNull null]; - [thisPrivateObject setJSValueRef:JSValueMakeNull(localCtx) ctx:localCtx]; - } - } - } - - JSValueRef jsReturnValue = NULL; - const char *type = [signature methodReturnType]; - if (strcmp(type, @encode(id)) == 0 || strcmp(type, @encode(Class)) == 0) { - id result = 0x00; - [invocation getReturnValue:&result]; - if (!result) return JSValueMakeNull(localCtx); - [JSCocoaFFIArgument boxObject:result toJSValueRef:&jsReturnValue inContext:localCtx]; - } -/* - case _C_CHR: - case _C_UCHR: - case _C_SHT: - case _C_USHT: - case _C_INT: - case _C_UINT: - case _C_LNG: - case _C_ULNG: - case _C_LNG_LNG: - case _C_ULNG_LNG: - case _C_FLT: - case _C_DBL: -*/ - else if (strcmp(type, @encode(char)) == 0) { - char result; - [invocation getReturnValue:&result]; - if (!result) return JSValueMakeNull(localCtx); - [JSCocoaFFIArgument toJSValueRef:&jsReturnValue inContext:localCtx typeEncoding:@encode(char)[0] fullTypeEncoding:NULL fromStorage:&result]; - } - else if (strcmp(type, @encode(unsigned char)) == 0) { - unsigned char result; - [invocation getReturnValue:&result]; - if (!result) return JSValueMakeNull(localCtx); - [JSCocoaFFIArgument toJSValueRef:&jsReturnValue inContext:localCtx typeEncoding:@encode(unsigned char)[0] fullTypeEncoding:NULL fromStorage:&result]; - } - else if (strcmp(type, @encode(short)) == 0) { - short result; - [invocation getReturnValue:&result]; - if (!result) return JSValueMakeNull(localCtx); - [JSCocoaFFIArgument toJSValueRef:&jsReturnValue inContext:localCtx typeEncoding:@encode(short)[0] fullTypeEncoding:NULL fromStorage:&result]; - } - else if (strcmp(type, @encode(unsigned short)) == 0) { - unsigned short result; - [invocation getReturnValue:&result]; - if (!result) return JSValueMakeNull(localCtx); - [JSCocoaFFIArgument toJSValueRef:&jsReturnValue inContext:localCtx typeEncoding:@encode(unsigned short)[0] fullTypeEncoding:NULL fromStorage:&result]; - } - else if (strcmp(type, @encode(int)) == 0) { - int result; - [invocation getReturnValue:&result]; - if (!result) return JSValueMakeNull(localCtx); - [JSCocoaFFIArgument toJSValueRef:&jsReturnValue inContext:localCtx typeEncoding:@encode(int)[0] fullTypeEncoding:NULL fromStorage:&result]; - } - else if (strcmp(type, @encode(unsigned int)) == 0) { - unsigned int result; - [invocation getReturnValue:&result]; - if (!result) return JSValueMakeNull(localCtx); - [JSCocoaFFIArgument toJSValueRef:&jsReturnValue inContext:localCtx typeEncoding:@encode(unsigned int)[0] fullTypeEncoding:NULL fromStorage:&result]; - } - else if (strcmp(type, @encode(long)) == 0) { - long result; - [invocation getReturnValue:&result]; - if (!result) return JSValueMakeNull(localCtx); - [JSCocoaFFIArgument toJSValueRef:&jsReturnValue inContext:localCtx typeEncoding:@encode(long)[0] fullTypeEncoding:NULL fromStorage:&result]; - } - else if (strcmp(type, @encode(unsigned long)) == 0) { - unsigned long result; - [invocation getReturnValue:&result]; - if (!result) return JSValueMakeNull(localCtx); - [JSCocoaFFIArgument toJSValueRef:&jsReturnValue inContext:localCtx typeEncoding:@encode(unsigned long)[0] fullTypeEncoding:NULL fromStorage:&result]; - } - else if (strcmp(type, @encode(float)) == 0) { - float result; - [invocation getReturnValue:&result]; - if (!result) return JSValueMakeNull(localCtx); - [JSCocoaFFIArgument toJSValueRef:&jsReturnValue inContext:localCtx typeEncoding:@encode(float)[0] fullTypeEncoding:NULL fromStorage:&result]; - } - else if (strcmp(type, @encode(double)) == 0) { - double result; - [invocation getReturnValue:&result]; - if (!result) return JSValueMakeNull(localCtx); - [JSCocoaFFIArgument toJSValueRef:&jsReturnValue inContext:localCtx typeEncoding:@encode(double)[0] fullTypeEncoding:NULL fromStorage:&result]; - } - // Structure return - else if (type && type[0] == '{') - { - id structureType = [NSString stringWithUTF8String:type]; - id fullStructureType = [JSCocoaFFIArgument structureFullTypeEncodingFromStructureTypeEncoding:structureType]; - - int size = [JSCocoaFFIArgument sizeOfStructure:structureType]; - if (size) - { - void* result = malloc(size); - [invocation getReturnValue:result]; - - // structureToJSValueRef will advance the pointer in place, overwriting its original value - void* ptr = result; - NSInteger numParsed = [JSCocoaFFIArgument structureToJSValueRef:&jsReturnValue inContext:localCtx fromCString:(char*)[fullStructureType UTF8String] fromStorage:&ptr]; - if (!numParsed) jsReturnValue = NULL; - free(result); - } - } - if (!jsReturnValue) return JSValueMakeNull(localCtx); - return jsReturnValue; -} - -@end - - - - - - - -#pragma mark Javascript setter functions -// Give ObjC classes written in Javascript extra abilities like storing extra javascript variables in an internal __jsHash. -// The following methods handle that. JSCocoaMethodHolder is a dummy class to hold them. -@interface JSCocoaMethodHolder : NSObject -@end -@implementation JSCocoaMethodHolder -- (BOOL)setJSValue:(JSValueRefAndContextRef)valueAndContext forJSName:(JSValueRefAndContextRef)nameAndContext -{ - if (class_getInstanceVariable([self class], "__jsHash")) - { - JSContextRef c = valueAndContext.ctx; - JSStringRef name = JSValueToStringCopy(c, nameAndContext.value, NULL); - - JSObjectRef hash = NULL; - object_getInstanceVariable(self, "__jsHash", (void**)&hash); - if (!hash) - { - // Retrieve controller - id jsc = [JSCocoaController controllerFromContext:c]; - c = [jsc ctx]; - - hash = JSObjectMake(c, hashObjectClass, NULL); - // Same as copyWithZone: - object_setInstanceVariable(self, "__jsHash", (void*)hash); - object_setInstanceVariable(self, "__jsCocoaController", (void*)jsc); - JSValueProtect(c, hash); - [JSCocoaController upJSValueProtectCount]; - [JSCocoaController upJSCocoaHashCount]; - } - - JSObjectSetProperty(c, hash, name, valueAndContext.value, kJSPropertyAttributeNone, NULL); - JSStringRelease(name); - return YES; - } - return NO; -} -- (JSValueRefAndContextRef)JSValueForJSName:(JSValueRefAndContextRef)nameAndContext -{ - JSValueRefAndContextRef valueAndContext = { JSValueMakeNull(nameAndContext.ctx), NULL }; - if (class_getInstanceVariable([self class], "__jsHash")) - { - JSContextRef c = nameAndContext.ctx; - JSStringRef name = JSValueToStringCopy(c, nameAndContext.value, NULL); - - JSObjectRef hash = NULL; - object_getInstanceVariable(self, "__jsHash", (void**)&hash); - if (!hash || !JSObjectHasProperty(c, hash, name)) - { - JSStringRelease(name); - return valueAndContext; - } - valueAndContext.ctx = c; - valueAndContext.value = JSObjectGetProperty(c, hash, name, NULL); - - JSStringRelease(name); - return valueAndContext; - } - return valueAndContext; -} - -- (BOOL)deleteJSValueForJSName:(JSValueRefAndContextRef)nameAndContext -{ - if (class_getInstanceVariable([self class], "__jsHash")) - { - JSContextRef c = nameAndContext.ctx; - JSStringRef name = JSValueToStringCopy(c, nameAndContext.value, NULL); - - JSObjectRef hash = NULL; - object_getInstanceVariable(self, "__jsHash", (void**)&hash); - if (!hash || !JSObjectHasProperty(c, hash, name)) - { - JSStringRelease(name); - return NO; - } - bool r = JSObjectDeleteProperty(c, hash, name, NULL); - JSStringRelease(name); - return r; - } - return NO; -} - - -// Instance count debug -+ (id)allocWithZone:(NSZone*)zone -{ - // Dynamic super call - id parentClass = [JSCocoaController parentObjCClassOfClassName:[NSString stringWithUTF8String:class_getName(self)]]; - id supermetaclass = objc_getMetaClass(class_getName(parentClass)); - struct objc_super superData = { self, supermetaclass }; - id o = objc_msgSendSuper(&superData, @selector(allocWithZone:), zone); - - [JSCocoaController upInstanceCount:o]; - return o; -} - -// Called by -(id)copy -- (id)copyWithZone:(NSZone *)zone -{ - // Dynamic super call - id parentClass = [JSCocoaController parentObjCClassOfClassName:[NSString stringWithUTF8String:class_getName([self class])]]; - struct objc_super superData = { self, parentClass }; - id o = objc_msgSendSuper(&superData, @selector(copyWithZone:), zone); - - // - // Copy hash by making a new copy - // - - // Return if var has no controller - id jsc = nil; - object_getInstanceVariable(self, "__jsCocoaController", (void**)&jsc); - if (!jsc) return o; - - - JSContextRef ctx = [jsc ctx]; - - - JSObjectRef hash1 = NULL; - JSObjectRef hash2 = NULL; - object_getInstanceVariable(self, "__jsHash", (void**)&hash1); - object_getInstanceVariable(o, "__jsHash", (void**)&hash2); - - // Return if hash does not exist - if (!hash1) return o; - - - // Copy hash - JSStringRef scriptJS = JSStringCreateWithUTF8CString("var hash1 = arguments[0]; var hash2 = {}; for (var i in hash1) hash2[i] = hash1[i]; return hash2"); - JSObjectRef fn = JSObjectMakeFunction(ctx, NULL, 0, NULL, scriptJS, NULL, 1, NULL); - JSValueRef result = JSObjectCallAsFunction(ctx, fn, NULL, 1, (JSValueRef*)&hash1, NULL); - JSStringRelease(scriptJS); - - // Convert hash to object - JSObjectRef hashCopy = JSValueToObject(ctx, result, NULL); - object_getInstanceVariable(o, "__jsHash", (void**)&hash2); - - // Same as setJSValue:forJSName: - // Set new hash - object_setInstanceVariable(o, "__jsHash", (void*)hashCopy); - object_setInstanceVariable(o, "__jsCocoaController", (void*)jsc); - JSValueProtect(ctx, hashCopy); - [JSCocoaController upJSValueProtectCount]; - [JSCocoaController upJSCocoaHashCount]; - - [JSCocoaController upInstanceCount:o]; - return o; -} - - -// Dealloc : unprotect js hash -- (void)deallocAndCleanupJS -{ - JSObjectRef hash = NULL; - object_getInstanceVariable(self, "__jsHash", (void**)&hash); - if (hash) - { - id jsc = NULL; - object_getInstanceVariable(self, "__jsCocoaController", (void**)&jsc); - JSValueUnprotect([jsc ctx], hash); - [JSCocoaController downJSCocoaHashCount]; - } - [JSCocoaController downInstanceCount:self]; - - // Dynamic super call - id parentClass = [JSCocoaController parentObjCClassOfClassName:[NSString stringWithUTF8String:class_getName([self class])]]; - struct objc_super superData = { self, parentClass }; - objc_msgSendSuper(&superData, @selector(dealloc)); -} - -// Finalize - same as dealloc -static BOOL __warningSuppressorAsFinalizeIsCalledBy_objc_msgSendSuper = NO; -- (void)finalize -{ - JSObjectRef hash = NULL; - object_getInstanceVariable(self, "__jsHash", (void**)&hash); - if (hash) - { - id jsc = NULL; - object_getInstanceVariable(self, "__jsCocoaController", (void**)&jsc); - JSValueUnprotect([jsc ctx], hash); - [JSCocoaController downJSCocoaHashCount]; - } - [JSCocoaController downInstanceCount:self]; - - // Dynamic super call - id parentClass = [JSCocoaController parentObjCClassOfClassName:[NSString stringWithUTF8String:class_getName([self class])]]; - struct objc_super superData = { self, parentClass }; - objc_msgSendSuper(&superData, @selector(finalize)); - - // Ignore warning about missing [super finalize] as the call IS made via objc_msgSendSuper - if (__warningSuppressorAsFinalizeIsCalledBy_objc_msgSendSuper) [super finalize]; -} - - - -@end - - - - - - -#pragma mark Common instance method -// Class.instance == class.alloc.init + release (jsObject retains object) -// Class.instance( { withA : ... andB : ... } ) == class.alloc.initWithA:... andB:... + release -@implementation NSObject(CommonInstance) -+ (JSValueRef)instanceWithContext:(JSContextRef)ctx argumentCount:(size_t)argumentCount arguments:(JSValueRef*)arguments exception:(JSValueRef*)exception -{ - id methodName = @"init"; - JSValueRef* argumentsToFree = NULL; - // Recover init method - if (argumentCount == 1) - { - id splitMethodName = @"init"; - BOOL isSplitCall = [JSCocoaController trySplitCall:&splitMethodName class:self argumentCount:&argumentCount arguments:&arguments ctx:ctx]; - if (isSplitCall) - { - methodName = splitMethodName; - argumentsToFree = arguments; - } - else return throwException(ctx, exception, @"Instance split call did not find an init method"), NULL; - } -// NSLog(@"=>Called instance on %@ with init=%@", self, methodName); - - // Allocate new instance - id newInstance = [self alloc]; - - // Set it as new object -// JSObjectRef thisObject = [JSCocoaController jsCocoaPrivateObjectInContext:ctx]; - id jsc = [JSCocoa controllerFromContext:ctx]; - JSObjectRef thisObject = [jsc newPrivateObject]; - JSCocoaPrivateObject* private = JSObjectGetPrivate(thisObject); - private.type = @"@"; - [private setObjectNoRetain:newInstance]; - // No — will retain allocated object and trigger "did you forget to call init" warning - // Object will be automatically boxed when returned to Javascript by -// JSObjectRef thisObject = [JSCocoaController boxedJSObject:newInstance inContext:ctx]; - - // Create function object boxing our init method -// JSObjectRef function = [JSCocoaController jsCocoaPrivateFunctionInContext:ctx]; - JSObjectRef function = [jsc newPrivateFunction]; - private = JSObjectGetPrivate(function); - private.type = @"method"; - private.methodName = methodName; - - // Call callAsFunction on our new instance with our init method - JSValueRef exceptionFromInitCall = NULL; - JSValueRef returnValue = jsCocoaObject_callAsFunction(ctx, function, thisObject, argumentCount, arguments, &exceptionFromInitCall); - free(argumentsToFree); - if (exceptionFromInitCall) return *exception = exceptionFromInitCall, NULL; - - // Release object - JSObjectRef returnObject = JSValueToObject(ctx, returnValue, NULL); - // We can get nil when initWith... fails. (eg var image = NSImage.instance({withContentsOfFile:'DOESNOTEXIST'}) - // Return nil then. - if (returnObject == nil) return JSValueMakeNull(ctx); - private = JSObjectGetPrivate(returnObject); - id boxedObject = [private object]; - [boxedObject release]; - - // Register our context in there so that safeDealloc finds it. - if ([boxedObject respondsToSelector:@selector(safeDealloc)]) - { -// id jsc = [JSCocoaController controllerFromContext:ctx]; -// object_setInstanceVariable(boxedObject, "__jsCocoaController", (void*)jsc); - } - return returnValue; -} - - -@end - - - - - - -#pragma mark - -#pragma mark JavascriptCore callbacks -#pragma mark - -#pragma mark JavascriptCore OSX object - -// -// -// Global resolver : main class used as 'this' in Javascript's global scope. Name requests go through here. -// -// -JSValueRef OSXObject_getProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyNameJS, JSValueRef* exception) -{ - NSString* propertyName = (NSString*)JSStringCopyCFString(kCFAllocatorDefault, propertyNameJS); - [NSMakeCollectable(propertyName) autorelease]; - - if ([propertyName isEqualToString:@"__jsc__"]) return NULL; - -// NSLog(@"Asking for global property %@", propertyName); - JSCocoaController* jsc = [JSCocoaController controllerFromContext:ctx]; - id delegate = jsc.delegate; - // - // Delegate canGetGlobalProperty, getGlobalProperty - // - if (delegate) - { - // Check if getting is allowed - if ([delegate respondsToSelector:@selector(JSCocoa:canGetGlobalProperty:inContext:exception:)]) - { - BOOL canGetGlobal = [delegate JSCocoa:jsc canGetGlobalProperty:propertyName inContext:ctx exception:exception]; - if (!canGetGlobal) - { - if (!*exception) throwException(ctx, exception, [NSString stringWithFormat:@"Delegate does not allow getting global property %@", propertyName]); - return NULL; - } - } - // Check if delegate handles getting - if ([delegate respondsToSelector:@selector(JSCocoa:getGlobalProperty:inContext:exception:)]) - { - JSValueRef delegateGetGlobal = [delegate JSCocoa:jsc getGlobalProperty:propertyName inContext:ctx exception:exception]; - if (delegateGetGlobal) return delegateGetGlobal; - } - } - - // - // ObjC class - // - Class objCClass = NSClassFromString(propertyName); - if (objCClass && ![propertyName isEqualToString:@"Object"]) - { - JSValueRef ret = [jsc boxObject:objCClass]; - return ret; - } - - id xml; - id type = nil; - // - // Query BridgeSupport for property - // - xml = [[BridgeSupportController sharedController] queryName:propertyName]; - if (xml) - { - id error = nil; - id xmlDocument = [[NSXMLDocument alloc] initWithXMLString:xml options:0 error:&error]; - if (error) return NSLog(@"(OSX_getPropertyCallback) malformed xml while getting property %@ of type %@ : %@", propertyName, type, error), NULL; - [xmlDocument autorelease]; - - type = [[xmlDocument rootElement] name]; - - // - // Function - // - if ([type isEqualToString:@"function"]) - { -// JSObjectRef o = [JSCocoaController jsCocoaPrivateFunctionInContext:ctx]; - JSObjectRef o = [jsc newPrivateFunction]; - JSCocoaPrivateObject* private = JSObjectGetPrivate(o); - private.type = @"function"; - private.xml = xml; - return o; - } - - // - // Struct - // - else - if ([type isEqualToString:@"struct"]) - { -// JSObjectRef o = [JSCocoaController jsCocoaPrivateObjectInContext:ctx]; - JSObjectRef o = [jsc newPrivateObject]; - JSCocoaPrivateObject* private = JSObjectGetPrivate(o); - private.type = @"struct"; - private.xml = xml; - return o; - } - - // - // Constant - // - else - if ([type isEqualToString:@"constant"]) - { - // ##fix : NSZeroPoint, NSZeroRect, NSZeroSize would need special (struct) + type64 handling - // Check if constant's declared_type is NSString* - id declared_type = [[xmlDocument rootElement] attributeForName:@"declared_type"]; - if (!declared_type) declared_type = [[xmlDocument rootElement] attributeForName:@"type"]; - if (!declared_type || !([[declared_type stringValue] isEqualToString:@"NSString*"] - || [[declared_type stringValue] isEqualToString:@"@"] - || [[declared_type stringValue] isEqualToString:@"^{__CFString=}"] - )) - return NSLog(@"(OSX_getPropertyCallback) %@ not a NSString* constant : %@", propertyName, xml), NULL; - - // Grab symbol - void* symbol = dlsym(RTLD_DEFAULT, [propertyName UTF8String]); - if (!symbol) return NSLog(@"(OSX_getPropertyCallback) symbol %@ not found", propertyName), NULL; - - // ObjC objects, like NSApp : pointer to NSApplication.sharedApplication - if ([[declared_type stringValue] isEqualToString:@"@"]) - { - id o = *(id*)symbol; - return [jsc boxObject:o]; - } - - // Return symbol as a Javascript string - NSString* str = *(NSString**)symbol; - JSStringRef jsName = JSStringCreateWithUTF8CString([str UTF8String]); - JSValueRef jsString = JSValueMakeString(ctx, jsName); - JSStringRelease(jsName); - return jsString; - } - - // - // Enum - // - else - if ([type isEqualToString:@"enum"]) - { - // Check if constant's declared_type is NSString* - id value = [[xmlDocument rootElement] attributeForName:@"value"]; - if (!value) - { - value = [[xmlDocument rootElement] attributeForName:@"value64"]; - if (!value) - return NSLog(@"(OSX_getPropertyCallback) %@ enum has no value set", propertyName), NULL; - } - - // Try parsing value - double doubleValue = 0; - value = [value stringValue]; - if (![[NSScanner scannerWithString:value] scanDouble:&doubleValue]) return NSLog(@"(OSX_getPropertyCallback) scanning %@ enum failed", propertyName), NULL; - return JSValueMakeNumber(ctx, doubleValue); - } - } - - // Describe ourselves - if ([propertyName isEqualToString:@"toString"] || [propertyName isEqualToString:@"valueOf"]) - { - JSStringRef scriptJS = JSStringCreateWithUTF8CString("return '(JSCocoa global object)'"); - JSObjectRef fn = JSObjectMakeFunction(ctx, NULL, 0, NULL, scriptJS, NULL, 1, NULL); - JSStringRelease(scriptJS); - return fn; - } - - return NULL; -} - - -static void OSXObject_getPropertyNames(JSContextRef ctx, JSObjectRef object, JSPropertyNameAccumulatorRef propertyNames) -{ - // Move to a definition object -/* - NSArray* keys = [[BridgeSupportController sharedController] keys]; - for (id key in keys) - { - JSStringRef jsString = JSStringCreateWithUTF8CString([key UTF8String]); - JSPropertyNameAccumulatorAddName(propertyNames, jsString); - JSStringRelease(jsString); - } -*/ -} - - - - - - -#pragma mark JavascriptCore JSCocoa object - -// -// Below lie the Javascript callbacks for all Javascript objects created by JSCocoa, used to pass ObjC data to and fro Javascript. -// - - -// -// From PyObjC : when to call objc_msgSend_stret, for structure return -// Depending on structure size & architecture, structures are returned as function first argument (done transparently by ffi) or via registers -// -BOOL isUsingStret(id argumentEncodings) -{ - int resultSize = 0; - char returnEncoding = [[argumentEncodings objectAtIndex:0] typeEncoding]; - if (returnEncoding == _C_STRUCT_B) resultSize = [JSCocoaFFIArgument sizeOfStructure:[[argumentEncodings objectAtIndex:0] structureTypeEncoding]]; - if (returnEncoding == _C_STRUCT_B && - //#ifdef __ppc64__ - // ffi64_stret_needs_ptr(signature_to_ffi_return_type(rettype), NULL, NULL) - // - //#else /* !__ppc64__ */ - (resultSize > SMALL_STRUCT_LIMIT - #ifdef __i386__ - /* darwin/x86 ABI is slightly odd ;-) */ - || (resultSize != 1 - && resultSize != 2 - && resultSize != 4 - && resultSize != 8) - #endif - #ifdef __x86_64__ - /* darwin/x86-64 ABI is slightly odd ;-) */ - || (resultSize != 1 - && resultSize != 2 - && resultSize != 4 - && resultSize != 8 - && resultSize != 16 - ) - #endif - ) - //#endif /* !__ppc64__ */ - ) { -// callAddress = objc_msgSend_stret; -// usingStret = YES; - return YES; - } - return NO; -} - -// -// Return the correct objc_msgSend* variety according to encodings -// -void* getObjCCallAddress(id argumentEncodings) -{ - BOOL usingStret = isUsingStret(argumentEncodings); - void* callAddress = objc_msgSend; - if (usingStret) callAddress = objc_msgSend_stret; - - -#if __i386__ // || TARGET_OS_IPHONE no, iPhone uses objc_msgSend - char returnEncoding = [[argumentEncodings objectAtIndex:0] typeEncoding]; - if (returnEncoding == 'f' || returnEncoding == 'd') - { - callAddress = objc_msgSend_fpret; - } -#endif - - return callAddress; -} - -// -// Convert FROM a webView context to a local context (called by valueOf(), toString()) -// -JSValueRef valueFromExternalContext(JSContextRef externalCtx, JSValueRef value, JSContextRef ctx) -{ - int type = JSValueGetType(externalCtx, value); - switch (type) - { - case kJSTypeUndefined: - { - return JSValueMakeUndefined(ctx); - } - - case kJSTypeNull: - { - return JSValueMakeNull(ctx); - } - - case kJSTypeBoolean: - { - bool b = JSValueToBoolean(externalCtx, value); - return JSValueMakeBoolean(ctx, b); - } - - case kJSTypeNumber: - { - double d = JSValueToNumber(externalCtx, value, NULL); - return JSValueMakeNumber(ctx, d); - } - - // Make strings and objects show up only as strings - case kJSTypeString: - case kJSTypeObject: - { - // Add an (externalContext) suffix to distinguish boxed JSValues from a WebView - JSStringRef jsString = JSValueToStringCopy(externalCtx, value, NULL); - - NSString* string = (NSString*)JSStringCopyCFString(kCFAllocatorDefault, jsString); - NSString* idString; - - // Mark only objects as (externalContext), not raw strings - if (type == kJSTypeObject) idString = [NSString stringWithFormat:@"%@ (externalContext)", string]; - else idString = [NSString stringWithFormat:@"%@", string]; - [string release]; - JSStringRelease(jsString); - - jsString = JSStringCreateWithUTF8CString([idString UTF8String]); - JSValueRef returnValue = JSValueMakeString(ctx, jsString); - JSStringRelease(jsString); - - return returnValue; - } - } - return JSValueMakeNull(ctx); -} - -// -// Convert TO a webView context from a local context -// -JSValueRef valueToExternalContext(JSContextRef ctx, JSValueRef value, JSContextRef externalCtx) -{ - int type = JSValueGetType(ctx, value); - switch (type) - { - case kJSTypeUndefined: - { - return JSValueMakeUndefined(externalCtx); - } - - case kJSTypeNull: - { - return JSValueMakeNull(externalCtx); - } - - case kJSTypeBoolean: - { - bool b = JSValueToBoolean(ctx, value); - return JSValueMakeBoolean(externalCtx, b); - } - - case kJSTypeNumber: - { - double d = JSValueToNumber(ctx, value, NULL); - return JSValueMakeNumber(externalCtx, d); - } - - case kJSTypeString: - { - JSStringRef jsString = JSValueToStringCopy(ctx, value, NULL); - JSValueRef returnValue = JSValueMakeString(externalCtx, jsString); - JSStringRelease(jsString); - return returnValue; - } - case kJSTypeObject: - { - JSObjectRef o = JSValueToObject(ctx, value, NULL); - if (!o) return JSValueMakeNull(externalCtx); - JSCocoaPrivateObject* privateObject = JSObjectGetPrivate(o); - if (![privateObject.type isEqualToString:@"externalJSValueRef"]) - { - id object = [privateObject object]; - if ([object isKindOfClass:[NSString class]]) - { - JSStringRef jsName = JSStringCreateWithUTF8CString([object UTF8String]); - JSValueRef jsString = JSValueMakeString(externalCtx, jsName); - JSStringRelease(jsName); - return jsString; - } - if ([object isKindOfClass:[NSNumber class]]) - { - return JSValueMakeNumber(externalCtx, [object doubleValue]); - } -// NSLog(@"Object (%@) converted to undefined", o ); - return JSValueMakeUndefined(externalCtx); - } - return [privateObject jsValueRef]; - } - } - return JSValueMakeNull(externalCtx); -} - -JSValueRef boxedValueFromExternalContext(JSContextRef externalCtx, JSValueRef value, JSContextRef ctx) -{ - if (JSValueGetType(externalCtx, value) < kJSTypeObject) return valueFromExternalContext(externalCtx, value, ctx); - - // If value is function ... - JSStringRef scriptJS= JSStringCreateWithUTF8CString("return (typeof arguments[0]) == 'function' ? true : null"); - JSObjectRef fn = JSObjectMakeFunction(externalCtx, NULL, 0, NULL, scriptJS, NULL, 1, NULL); - JSValueRef result = JSObjectCallAsFunction(externalCtx, fn, NULL, 1, (JSValueRef*)&value, NULL); - JSStringRelease(scriptJS); - - // ... use the function boxer - JSObjectRef o; - if (JSValueIsBoolean(externalCtx, result)) -// o = [JSCocoaController jsCocoaPrivateFunctionInContext:ctx]; - o = [[JSCocoa controllerFromContext:ctx] newPrivateFunction]; - else -// o = [JSCocoaController jsCocoaPrivateObjectInContext:ctx]; - o = [[JSCocoa controllerFromContext:ctx] newPrivateFunction]; - - JSCocoaPrivateObject* private = JSObjectGetPrivate(o); - private.type = @"externalJSValueRef"; - [private setExternalJSValueRef:value ctx:externalCtx]; - return o; -} - - -// -// valueOf : from a boxed ObjC object, returns a primitive javascript value (number or string) -// that JavascriptCore can use in expressions (eg boxedObject + 'this', boxedObject < 4) -// -// The returned value is temporary and does not affect the boxed object. -// -JSValueRef valueOfCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef *exception) -{ - // Holding a native JS value ? Return it - JSCocoaPrivateObject* thisPrivateObject = JSObjectGetPrivate(thisObject); - if ([thisPrivateObject.type isEqualToString:@"jsValueRef"]) - { - return [thisPrivateObject jsValueRef]; - } - - // External jsValueRef from WebView - if ([thisPrivateObject.type isEqualToString:@"externalJSValueRef"]) - { - JSContextRef externalCtx = [thisPrivateObject ctx]; - JSValueRef externalJSValueRef = [thisPrivateObject jsValueRef]; - JSStringRef scriptJS= JSStringCreateWithUTF8CString("return arguments[0].valueOf()"); - JSObjectRef fn = JSObjectMakeFunction(externalCtx, NULL, 0, NULL, scriptJS, NULL, 1, NULL); - JSValueRef result = JSObjectCallAsFunction(externalCtx, fn, NULL, 1, (JSValueRef*)&externalJSValueRef, NULL); - JSStringRelease(scriptJS); - - return valueFromExternalContext(externalCtx, result, ctx); - } - - // NSNumber special case - if ([thisPrivateObject.object isKindOfClass:[NSNumber class]]) - return JSValueMakeNumber(ctx, [thisPrivateObject.object doubleValue]); - - // Convert to string - id toString = [thisPrivateObject description]; - - // Object - if ([thisPrivateObject.type isEqualToString:@"@"]) - { - // Holding an out value ? - if ([thisPrivateObject.object isKindOfClass:[JSCocoaOutArgument class]]) - { - JSValueRef outValue = [(JSCocoaOutArgument*)thisPrivateObject.object outJSValueRefInContext:ctx]; - if (!outValue) - { - JSStringRef jsName = JSStringCreateWithUTF8CString("Unitialized outArgument"); - JSValueRef r = JSValueMakeString(ctx, jsName); - JSStringRelease(jsName); - return r; - } - // Holding an object ? Call valueOf on it - if (JSValueGetType(ctx, outValue) == kJSTypeObject) - return valueOfCallback(ctx, NULL, JSValueToObject(ctx, outValue, NULL), 0, NULL, NULL); - // Return raw JSValueRef - return outValue; - } - else - toString = [NSString stringWithFormat:@"%@", [[thisPrivateObject object] description]]; - } - - // Struct - if ([thisPrivateObject.type isEqualToString:@"struct"]) - { - id structDescription = nil; - id self = [JSCocoaController controllerFromContext:ctx]; - if ([self hasJSFunctionNamed:@"describeStruct"]) - { - JSStringRef scriptJS = JSStringCreateWithUTF8CString("return describeStruct(arguments[0])"); - JSObjectRef fn = JSObjectMakeFunction(ctx, NULL, 0, NULL, scriptJS, NULL, 1, NULL); - JSValueRef jsValue = JSObjectCallAsFunction(ctx, fn, NULL, 1, (JSValueRef*)&thisObject, NULL); - JSStringRelease(scriptJS); - - [JSCocoaFFIArgument unboxJSValueRef:jsValue toObject:&structDescription inContext:ctx]; - } - - toString = [NSString stringWithFormat:@"<%@ %@>", thisPrivateObject.structureName, structDescription]; - } - - // Return a number is the whole string (no spaces, no others chars) is a number - // This emulates the javascript behaviour '4'*2 -> 8 when '4' is a string or an NSString - NSScanner* scan = [NSScanner scannerWithString:toString]; - [scan setCharactersToBeSkipped:nil]; - double v = 0; - [scan scanDouble:&v]; - if ([scan isAtEnd]) - return JSValueMakeNumber(ctx, v); - - // Convert to string and return - JSStringRef jsToString = JSStringCreateWithCFString((CFStringRef)toString); - JSValueRef jsValueToString = JSValueMakeString(ctx, jsToString); - JSStringRelease(jsToString); - return jsValueToString; -} - -// -// initialize -// retain boxed object -// -static void jsCocoaObject_initialize(JSContextRef ctx, JSObjectRef object) -{ - id o = JSObjectGetPrivate(object); - [o retain]; -} - -// -// finalize -// release boxed object -// -static void jsCocoaObject_finalize(JSObjectRef object) -{ -// NSLog(@"finalizing %p", object); - - // If dealloc is overloaded, releasing now will trigger JS code and fail - // As we're being called by GC, KJS might assert() in operationInProgress == NoOperation - JSCocoaPrivateObject* private = JSObjectGetPrivate(object); - - // Clean up the object now as WebKit calls us twice while cleaning __jsc__ (20110730) - JSObjectSetPrivate(object, NULL); - id jsc = nil; - JSContextRef ctx = [private ctx]; - - if (ctx) - jsc = [JSCocoa controllerFromContext:ctx]; - // We will be called during garbage collection before dealloc occurs. - // The __jsc__ variable will be gone, therefore controllerFromContext will yield 0. - // Not a problem since it's only used to remove the object from the boxedObjects hash, - // and dealloc will occur soon after. - - // - // If a boxed object is being destroyed, remove it from the cache - // - id boxedObject = [private object]; - if (boxedObject) { - if ([jsc isObjectBoxed:boxedObject]) { - // Safe dealloc ? - if ([boxedObject retainCount] == 1) { - if ([boxedObject respondsToSelector:@selector(safeDealloc)]) { - jsc = NULL; - object_getInstanceVariable(boxedObject, "__jsCocoaController", (void**)&jsc); - // Call safeDealloc if enabled (will be disabled upon last JSCocoaController release, to make sure the ) - if (jsc) { - if ([jsc useSafeDealloc]) - [jsc performSelector:@selector(safeDeallocInstance:) withObject:boxedObject afterDelay:0]; - } else - NSLog(@"safeDealloc could not find the context attached to %@.%p - allocate this object with instance, or add a Javascript variable to it (obj.hello = 'world')", [boxedObject class], boxedObject); - } - } - [jsc deleteBoxOfObject:boxedObject]; - } - } - - // Immediate release if dealloc is not overloaded - [private release]; - -#ifdef __OBJC_GC__ - // Mark internal object as collectable - [[NSGarbageCollector defaultCollector] enableCollectorForPointer:private]; -#endif -} - -/* -// -// Not needed as getProperty can return NULL to indicate property inexistance. -// -// log('doesNotExist' in object) -// getProperty returning undefined would mean the key is defined and has an undefined value. -// getProperty therefore returns NULL and the in operator returns false. -// -> hasProperty not needed. -// -static bool jsCocoaObject_hasProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyNameJS) -{ - NSString* propertyName = (NSString*)JSStringCopyCFString(kCFAllocatorDefault, propertyNameJS); - [NSMakeCollectable(propertyName) autorelease]; - NSLog(@"hasProperty %@", propertyName); - return jsCocoaObject_getProperty(ctx, object, propertyNameJS, NULL); - return YES; -} -*/ - -// -// getProperty -// Return property in object's internal Javascript hash if its contains propertyName -// else ... -// Get objC method matching propertyName, autocall it -// else ... -// method may be a split call -> return a private object -// -// At method start, handle special cases for arrays (integers, length) and dictionaries -// -static JSValueRef jsCocoaObject_getProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyNameJS, JSValueRef* exception) -{ - NSString* propertyName = (NSString*)JSStringCopyCFString(kCFAllocatorDefault, propertyNameJS); - [NSMakeCollectable(propertyName) autorelease]; - - JSCocoaPrivateObject* privateObject = JSObjectGetPrivate(object); -// NSLog(@"Asking for property %@ %@(%@)", propertyName, privateObject, privateObject.type); - - // Get delegate - JSCocoaController* jsc = [JSCocoaController controllerFromContext:ctx]; - id delegate = jsc.delegate; - - if ([privateObject.type isEqualToString:@"@"]) - { -call: - // - // Delegate canGetProperty, getProperty - // - if (delegate) - { - // Check if getting is allowed - if ([delegate respondsToSelector:@selector(JSCocoa:canGetProperty:ofObject:inContext:exception:)]) - { - BOOL canGet = [delegate JSCocoa:jsc canGetProperty:propertyName ofObject:privateObject.object inContext:ctx exception:exception]; - if (!canGet) - { - if (!*exception) throwException(ctx, exception, [NSString stringWithFormat:@"Delegate does not allow getting %@.%@", privateObject.object, propertyName]); - return NULL; - } - } - // Check if delegate handles getting - if ([delegate respondsToSelector:@selector(JSCocoa:getProperty:ofObject:inContext:exception:)]) - { - JSValueRef delegateGet = [delegate JSCocoa:jsc getProperty:propertyName ofObject:privateObject.object inContext:ctx exception:exception]; - if (delegateGet) return delegateGet; - } - } - - // Special case for NSMutableArray get and Javascript array methods -// if ([privateObject.object isKindOfClass:[NSArray class]]) - // Use respondsToSelector for custom indexed access - if ([privateObject.object respondsToSelector:@selector(objectAtIndex:)]) - { - id array = privateObject.object; - id scan = [NSScanner scannerWithString:propertyName]; - NSInteger propertyIndex; - // Is asked property an int ? - BOOL convertedToInt = ([scan scanInteger:&propertyIndex]); - if (convertedToInt && [scan isAtEnd]) - { - if (propertyIndex < 0 || propertyIndex >= [array count]) return NULL; - - id o = [array objectAtIndex:propertyIndex]; - JSValueRef value = NULL; - [JSCocoaFFIArgument boxObject:o toJSValueRef:&value inContext:ctx]; - return value; - } - - // If we have 'length', switch it to 'count' - if ([propertyName isEqualToString:@"length"]) propertyName = @"count"; - - // NSArray bridge - id callee = [privateObject object]; - SEL sel = NSSelectorFromString(propertyName); - if ([propertyName rangeOfString:@":"].location == NSNotFound && ![callee respondsToSelector:sel] - && ![propertyName isEqualToString:@"valueOf"] - && ![propertyName isEqualToString:@"toString"] - ) - { - id script = [NSString stringWithFormat:@"return Array.prototype.%@", propertyName]; - JSStringRef scriptJS = JSStringCreateWithUTF8CString([script UTF8String]); - JSObjectRef fn = JSObjectMakeFunction(ctx, NULL, 0, NULL, scriptJS, NULL, 1, NULL); - JSValueRef result = JSObjectCallAsFunction(ctx, fn, NULL, 0, NULL, NULL); - JSStringRelease(scriptJS); - BOOL isJavascriptArrayMethod = result ? !JSValueIsUndefined(ctx, result) : NO; - - // Return the packaged Javascript function - if (isJavascriptArrayMethod) - { -// NSLog(@"*** array method : %@", propertyName); -// JSObjectRef o = [JSCocoaController jsCocoaPrivateFunctionInContext:ctx]; - JSObjectRef o = [jsc newPrivateFunction]; - JSCocoaPrivateObject* private = JSObjectGetPrivate(o); - private.type = @"jsFunction"; - [private setJSValueRef:result ctx:ctx]; - return o; - } - } - } - - - // Special case for NSMutableDictionary get -// if ([privateObject.object isKindOfClass:[NSDictionary class]]) - // Use respondsToSelector for custom indexed access - if ([privateObject.object respondsToSelector:@selector(objectForKey:)]) - { - id dictionary = privateObject.object; - id o = [dictionary objectForKey:propertyName]; - if (o) - { - JSValueRef value = NULL; - [JSCocoaFFIArgument boxObject:o toJSValueRef:&value inContext:ctx]; - return value; - } - } - - // Special case for JSCocoaMemoryBuffer get - if ([privateObject.object isKindOfClass:[JSCocoaMemoryBuffer class]]) - { - id buffer = privateObject.object; - - id scan = [NSScanner scannerWithString:propertyName]; - NSInteger propertyIndex; - // Is asked property an int ? - BOOL convertedToInt = ([scan scanInteger:&propertyIndex]); - if (convertedToInt && [scan isAtEnd]) - { - if (propertyIndex < 0 || propertyIndex >= [buffer typeCount]) return NULL; - return [buffer valueAtIndex:propertyIndex inContext:ctx]; - } - } - - // Check object's internal property in its jsHash - id callee = [privateObject object]; - if ([callee respondsToSelector:@selector(JSValueForJSName:)]) - { - JSValueRefAndContextRef name = { JSValueMakeString(ctx, propertyNameJS), ctx } ; - JSValueRef hashProperty = [callee JSValueForJSName:name].value; - if (hashProperty && !JSValueIsNull(ctx, hashProperty)) - { - BOOL returnHashValue = YES; - // Make sure to not return hash value if it's native code (valueOf, toString) - if ([propertyName isEqualToString:@"valueOf"] || [propertyName isEqualToString:@"toString"]) - { - id script = [NSString stringWithFormat:@"return arguments[0].toString().indexOf('[native code]') != -1", propertyName]; - JSStringRef scriptJS = JSStringCreateWithUTF8CString([script UTF8String]); - JSObjectRef fn = JSObjectMakeFunction(ctx, NULL, 0, NULL, scriptJS, NULL, 1, NULL); - JSValueRef result = JSObjectCallAsFunction(ctx, fn, NULL, 1, (JSValueRef*)&hashProperty, NULL); - JSStringRelease(scriptJS); - BOOL isNativeCode = result ? JSValueToBoolean(ctx, result) : NO; - returnHashValue = !isNativeCode; -// NSLog(@"isNative(%@)=%d rawJSResult=%p hashProperty=%p returnHashValue=%d", propertyName, isNativeCode, result, hashProperty, returnHashValue); - } - if (returnHashValue) return hashProperty; - } - } -/* - // ## Use javascript override functions, only bridge side. Discarded for now as it doesn't give a way to call the original method - // ## Plus : useful ? as it can be done by setting custom js functions on the boxed objects - // Check if this is a Javascript override - id script = [NSString stringWithFormat:@"__globalJSFunctionRepository__.%@.%@", [callee class], propertyName]; - JSStringRef jsScript = JSStringCreateWithUTF8CString([script UTF8String]); - JSValueRef result = JSEvaluateScript(ctx, jsScript, NULL, NULL, 1, NULL); - JSStringRelease(jsScript); - if (result && JSValueGetType(ctx, result) == kJSTypeObject) - { - NSLog(@"GOT IT %@", propertyName); - JSObjectRef o = [JSCocoaController jsCocoaPrivateFunctionInContext:ctx]; - JSCocoaPrivateObject* private = JSObjectGetPrivate(o); - private.type = @"jsFunction"; - [private setJSValueRef:result ctx:ctx]; - return o; - } -*/ - // - // Attempt Zero arg autocall - // Object.alloc().init() -> Object.alloc.init - // - if ([jsc useAutoCall]) - { - callee = [privateObject object]; - SEL sel = NSSelectorFromString(propertyName); - - BOOL isInstanceCall = [propertyName isEqualToString:@"instance"]; - // Go for zero arg call - if ([propertyName rangeOfString:@":"].location == NSNotFound && ([callee respondsToSelector:sel] || isInstanceCall)) - { - // - // Delegate canCallMethod, callMethod - // - if (delegate) - { - // Check if calling is allowed - if ([delegate respondsToSelector:@selector(JSCocoa:canCallMethod:ofObject:argumentCount:arguments:inContext:exception:)]) - { - BOOL canCall = [delegate JSCocoa:jsc canCallMethod:propertyName ofObject:callee argumentCount:0 arguments:NULL inContext:ctx exception:exception]; - if (!canCall) - { - if (!*exception) throwException(ctx, exception, [NSString stringWithFormat:@"Delegate does not allow calling [%@ %@]", callee, propertyName]); - return NULL; - } - } - // Check if delegate handles calling - if ([delegate respondsToSelector:@selector(JSCocoa:callMethod:ofObject:privateObject:argumentCount:arguments:inContext:exception:)]) - { - JSValueRef delegateCall = [delegate JSCocoa:jsc callMethod:propertyName ofObject:callee privateObject:privateObject argumentCount:0 arguments:NULL inContext:ctx exception:exception]; - if (delegateCall) - return delegateCall; - } - } - - // instance - if (isInstanceCall) - { - // Manually call and box our object - id class = [callee class]; - id instance = [[class alloc] init]; - JSValueRef returnValue; - [JSCocoaFFIArgument boxObject:instance toJSValueRef:&returnValue inContext:ctx]; - // Release it, making the javascript box the sole retainer - // Nulling all references to this object will release the instance during Javascript GC - JSCocoaPrivateObject* private = JSObjectGetPrivate(JSValueToObject(ctx, returnValue, NULL)); - [private.object release]; - - return returnValue; - } - - // Special case for alloc autocall — do not retain alloced result as it might crash (eg [[NSLocale alloc] retain] fails in ObjC) - if ([propertyName isEqualToString:@"alloc"]) - { - id allocatedObject = [callee alloc]; -// JSObjectRef jsObject = [JSCocoaController jsCocoaPrivateObjectInContext:ctx]; - JSObjectRef jsObject = [jsc newPrivateObject]; - JSCocoaPrivateObject* private = JSObjectGetPrivate(jsObject); - private.type = @"@"; - [private setObjectNoRetain:allocatedObject]; - return jsObject; - } - - // Get method pointer - Method method = class_getInstanceMethod([callee class], sel); - if (!method) method = class_getClassMethod([callee class], sel); - - // If we didn't find a method, try Distant Object - if (!method) - { - JSValueRef res = [jsc JSCocoa:jsc callMethod:propertyName ofObject:callee privateObject:privateObject argumentCount:0 arguments:NULL inContext:ctx exception:exception]; - if (res) return res; - - throwException(ctx, exception, [NSString stringWithFormat:@"Could not get property[%@ %@]", callee, propertyName]); - return NULL; - } - - // Extract arguments - const char* typeEncoding = method_getTypeEncoding(method); - id argumentEncodings = [JSCocoaController parseObjCMethodEncoding:typeEncoding]; - // Call address - void* callAddress = getObjCCallAddress(argumentEncodings); - - // - // ffi data - // - ffi_cif cif; - ffi_type* args[2]; - void* values[2]; - char* selector; - - selector = (char*)NSSelectorFromString(propertyName); - args[0] = &ffi_type_pointer; - args[1] = &ffi_type_pointer; - values[0] = (void*)&callee; - values[1] = (void*)&selector; - - // Get return value holder - id returnValue = [argumentEncodings objectAtIndex:0]; - - // Allocate return value storage if it's a pointer - if ([returnValue typeEncoding] == '^') - [returnValue allocateStorage]; - - // Setup ffi - ffi_status prep_status = ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, [returnValue ffi_type], args); - // - // Call ! - // - if (prep_status == FFI_OK) - { - void* storage = [returnValue storage]; - if ([returnValue ffi_type] == &ffi_type_void) storage = NULL; - ffi_call(&cif, callAddress, storage, values); - } - - // Return now if our function returns void - // NO - box it -// if ([returnValue ffi_type] == &ffi_type_void) return NULL; - // Else, convert return value - JSValueRef jsReturnValue = NULL; - BOOL converted = [returnValue toJSValueRef:&jsReturnValue inContext:ctx]; - if (!converted) return throwException(ctx, exception, [NSString stringWithFormat:@"Return value not converted in %@", propertyName]), NULL; - - return jsReturnValue; - } - } - - // Check if we're holding an out value - if ([privateObject.object isKindOfClass:[JSCocoaOutArgument class]]) - { - JSValueRef outValue = [(JSCocoaOutArgument*)privateObject.object outJSValueRefInContext:ctx]; - if (outValue && JSValueGetType(ctx, outValue) == kJSTypeObject) - { - JSObjectRef outObject = JSValueToObject(ctx, outValue, NULL); - JSValueRef possibleReturnValue = JSObjectGetProperty(ctx, outObject, propertyNameJS, NULL); - return possibleReturnValue; - } - } - - // Info object for instances and classes - if ([propertyName isEqualToString:@RuntimeInformationPropertyName]) - { - JSObjectRef o = JSObjectMake(ctx, jsCocoaInfoClass, NULL); - - JSStringRef classNameProperty = JSStringCreateWithUTF8CString("className"); - JSStringRef className = JSStringCreateWithUTF8CString([[[[privateObject object] class] description] UTF8String]); - JSObjectSetProperty(ctx, o, classNameProperty, JSValueMakeString(ctx, className), - kJSPropertyAttributeReadOnly|kJSPropertyAttributeDontEnum|kJSPropertyAttributeDontDelete, NULL); - JSStringRelease(classNameProperty); - JSStringRelease(className); - return o; - } - - - // - // We're asked a property name and at this point we've checked the class's jsarray, autocall. - // If the property we're asked does not start a split call we'll return NULL. - // - // Check if the property is actually a method. - // If NO, replace underscores with colons - // add a ':' suffix - // - // If callee still fails to responds to that, check if propertyName starts a split call. - // If NO, return null - // - id methodName = [NSMutableString stringWithString:propertyName]; - // If responds to selector, OK - if (![callee respondsToSelector:NSSelectorFromString(methodName)] - // non ObjC methods - && ![methodName isEqualToString:@"valueOf"] - && ![methodName isEqualToString:@"Super"] - && ![methodName isEqualToString:@"Original"] -/* && ![methodName isEqualToString:@"instance"]*/) - { - // If setting on boxed objects is allowed, check existence of a property set on the js object - this is a reentrant call - if ([jsc canSetOnBoxedObjects]) - { - // We need to bypass our get handler to get the js value - static int canSetCheck = 0; - // Return NULL so the get handler will retrieve the js property stored in the js object - if (canSetCheck > 0) - return NULL; - - canSetCheck++; - // Call default handler - JSValueRef jsValueSetOnBoxedObject = JSObjectGetProperty(ctx, object, propertyNameJS, nil); - canSetCheck--; - - // If we have something other than undefined, return it - if (JSValueGetType(ctx, jsValueSetOnBoxedObject) != kJSTypeUndefined) - return jsValueSetOnBoxedObject; - } - - if ([methodName rangeOfString:@"_"].location != NSNotFound) - [methodName replaceOccurrencesOfString:@"_" withString:@":" options:0 range:NSMakeRange(0, [methodName length])]; - - if ([jsc callSelectorsMissingTrailingSemicolon] && ![methodName hasSuffix:@":"]) [methodName appendString:@":"]; - - if (![callee respondsToSelector:NSSelectorFromString(methodName)]) - { - // Instance check - if ([methodName hasPrefix:@"instance"]) - { - id initMethodName = [NSString stringWithFormat:@"init%@", [methodName substringFromIndex:8]]; - if ([callee instancesRespondToSelector:NSSelectorFromString(initMethodName)]) - { -// JSObjectRef o = [JSCocoaController jsCocoaPrivateFunctionInContext:ctx]; - JSObjectRef o = [jsc newPrivateFunction]; - JSCocoaPrivateObject* private = JSObjectGetPrivate(o); - private.type = @"method"; - private.methodName = methodName; - return o; - } - } - - // - // This may be a JS function - // - Class class = [callee class]; - JSValueRef result = NULL; - while (class) - { - id script = [NSString stringWithFormat:@"__globalJSFunctionRepository__.%@.%@", class, propertyName]; - JSStringRef jsScript = JSStringCreateWithUTF8CString([script UTF8String]); - result = JSEvaluateScript(ctx, jsScript, NULL, NULL, 1, NULL); - JSStringRelease(jsScript); - // Found ? Break - if (result && JSValueGetType(ctx, result) == kJSTypeObject) break; - - // Go up parent class - class = [class superclass]; - } - // This is a pure JS function call — box it - if (result && JSValueGetType(ctx, result) == kJSTypeObject) - { -// JSObjectRef o = [JSCocoaController jsCocoaPrivateFunctionInContext:ctx]; - JSObjectRef o = [jsc newPrivateFunction]; - JSCocoaPrivateObject* private = JSObjectGetPrivate(o); - private.type = @"jsFunction"; - [private setJSValueRef:result ctx:ctx]; - return o; - } - - methodName = propertyName; - - // Get the meta class if callee is a class - class = [callee class]; - if (callee == class) - class = objc_getMetaClass(object_getClassName(class)); - // Try split start - BOOL isMaybeSplit = NO; - if ([jsc useSplitCall]) - isMaybeSplit = [JSCocoaController isMaybeSplitCall:methodName forClass:class]; - // If not split and not NSString, return (if NSString, try to convert to JS string in callAsFunction and use native JS methods) - if (!isMaybeSplit && ![callee isKindOfClass:[NSString class]]) - { - return NULL; - } - } - } - - // Get ready for method call -// JSObjectRef o = [JSCocoaController jsCocoaPrivateFunctionInContext:ctx]; - JSObjectRef o = [jsc newPrivateFunction]; - JSCocoaPrivateObject* private = JSObjectGetPrivate(o); - private.type = @"method"; - private.methodName = methodName; - - return o; - } - - // Struct + rawPointer valueOf - if (/*[privateObject.type isEqualToString:@"struct"] &&*/ ([propertyName isEqualToString:@"valueOf"] || [propertyName isEqualToString:@"toString"])) - { -// JSObjectRef o = [JSCocoaController jsCocoaPrivateFunctionInContext:ctx]; - JSObjectRef o = [jsc newPrivateFunction]; - JSCocoaPrivateObject* private = JSObjectGetPrivate(o); - private.type = @"method"; - private.methodName = propertyName; - return o; - } - - - // Pointer ops - // * If we have an external Javascript context, query it - // * Handle pointer reference / dereference with JSCocoaFFIArgument - if ([privateObject.type isEqualToString:@"rawPointer"]) - { - BOOL responds = NO; - id methodName = propertyName; - responds = [privateObject respondsToSelector:NSSelectorFromString(propertyName)]; - if (!responds) { - methodName = [NSString stringWithFormat:@"%@:", methodName]; - responds = [privateObject respondsToSelector:NSSelectorFromString(methodName)]; - } - if (responds) - { - // When calling a method with arguments, this will be used to get the instance on which to call - id callee = privateObject; - // Retaining the object leaks - [privateObject setObjectNoRetain:privateObject]; - - privateObject = [[JSCocoaPrivateObject new] autorelease]; - privateObject.object = callee; - privateObject.type = @"@"; - goto call; - } - } - - // External WebView value - if ([privateObject.type isEqualToString:@"externalJSValueRef"] || [[privateObject rawPointerEncoding] isEqualToString:@"^{OpaqueJSContext=}"]) - { - JSValueRef externalValue = [privateObject jsValueRef]; - JSContextRef externalCtx = externalValue ? [privateObject ctx] : [privateObject rawPointer]; - JSObjectRef externalObject = externalValue ? JSValueToObject(externalCtx, externalValue, NULL) : JSContextGetGlobalObject(externalCtx); - - if (!JSObjectHasProperty(externalCtx, externalObject, propertyNameJS)) return NULL; - JSValueRef r = JSObjectGetProperty(externalCtx, externalObject, propertyNameJS, exception); - // If WebView had an exception, re-throw it in our context - if (exception && *exception) - { - id s = [JSCocoaController formatJSException:*exception inContext:externalCtx]; - throwException(ctx, exception, [NSString stringWithFormat:@"(WebView) %@", s]); - return JSValueMakeNull(ctx); - } - JSValueRef r2 = boxedValueFromExternalContext(externalCtx, r, ctx); - return r2; - } - - - // Structs will get here when being asked javascript attributes (eg 'x' in point.x) -// NSLog(@"Asking for property %@ %@(%@)", propertyName, privateObject, privateObject.type); - - return NULL; -} - - -// -// setProperty -// call setter : propertyName -> setPropertyName -// -static bool jsCocoaObject_setProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyNameJS, JSValueRef jsValue, JSValueRef* exception) -{ - JSCocoaPrivateObject* privateObject = JSObjectGetPrivate(object); - NSString* propertyName = (NSString*)JSStringCopyCFString(kCFAllocatorDefault, propertyNameJS); - [NSMakeCollectable(propertyName) autorelease]; - -// NSLog(@"****SET %@ in ctx %p on object %p (type=%@) method=%@", propertyName, ctx, object, privateObject.type, privateObject.methodName); - - // Get delegate - JSCocoaController* jsc = [JSCocoaController controllerFromContext:ctx]; - id delegate = jsc.delegate; - - if ([privateObject.type isEqualToString:@"@"]) - { - // - // Delegate canSetProperty, setProperty - // - if (delegate) - { - // Check if setting is allowed - if ([delegate respondsToSelector:@selector(JSCocoa:canSetProperty:ofObject:toValue:inContext:exception:)]) - { - BOOL canSet = [delegate JSCocoa:jsc canSetProperty:propertyName ofObject:privateObject.object toValue:jsValue inContext:ctx exception:exception]; - if (!canSet) - { - if (!*exception) throwException(ctx, exception, [NSString stringWithFormat:@"Delegate does not allow setting %@.%@", privateObject.object, propertyName]); - return NULL; - } - } - // Check if delegate handles getting - if ([delegate respondsToSelector:@selector(JSCocoa:setProperty:ofObject:toValue:inContext:exception:)]) - { - BOOL delegateSet = [delegate JSCocoa:jsc setProperty:propertyName ofObject:privateObject.object toValue:jsValue inContext:ctx exception:exception]; - if (delegateSet) return true; - } - } - - // Special case for NSMutableArray set -// if ([privateObject.object isKindOfClass:[NSArray class]]) - if ([privateObject.object respondsToSelector:@selector(replaceObjectAtIndex:withObject:)]) - { - id array = privateObject.object; -// if (![array respondsToSelector:@selector(replaceObjectAtIndex:withObject:)]) return throwException(ctx, exception, @"Calling set on a non mutable array"), false; - id scan = [NSScanner scannerWithString:propertyName]; - NSInteger propertyIndex; - // Is asked property an int ? - BOOL convertedToInt = ([scan scanInteger:&propertyIndex]); - if (convertedToInt && [scan isAtEnd]) - { - if (propertyIndex < 0 || propertyIndex >= [array count]) return false; - - id property = NULL; - if ([JSCocoaFFIArgument unboxJSValueRef:jsValue toObject:&property inContext:ctx]) - { - [array replaceObjectAtIndex:propertyIndex withObject:property]; - return true; - } - else return false; - } - } - - - // Special case for NSMutableDictionary set -// if ([privateObject.object isKindOfClass:[NSDictionary class]]) - if ([privateObject.object respondsToSelector:@selector(setObject:forKey:)]) - { - id dictionary = privateObject.object; -// if (![dictionary respondsToSelector:@selector(setObject:forKey:)]) return throwException(ctx, exception, @"Calling set on a non mutable dictionary"), false; - - id property = NULL; - if ([JSCocoaFFIArgument unboxJSValueRef:jsValue toObject:&property inContext:ctx]) - { - [dictionary setObject:property forKey:propertyName]; - return true; - } - else return false; - } - - - // Special case for JSCocoaMemoryBuffer get - if ([privateObject.object isKindOfClass:[JSCocoaMemoryBuffer class]]) - { - id buffer = privateObject.object; - - id scan = [NSScanner scannerWithString:propertyName]; - NSInteger propertyIndex; - // Is asked property an int ? - BOOL convertedToInt = ([scan scanInteger:&propertyIndex]); - if (convertedToInt && [scan isAtEnd]) - { - if (propertyIndex < 0 || propertyIndex >= [buffer typeCount]) return NULL; - return [buffer setValue:jsValue atIndex:propertyIndex inContext:ctx]; - } - } - - - - // Try shorthand overload : obc[selector] = function - id callee = [privateObject object]; - if ([propertyName rangeOfString:@":"].location != NSNotFound) - { - JSValueRefAndContextRef v = { jsValue, ctx }; - [JSCocoaController overloadInstanceMethod:propertyName class:[callee class] jsFunction:v]; - return true; - } - - - // Can't use capitalizedString on the whole string as it will transform - // myValue - // to Myvalue (thereby destroying camel letters) - // we want MyValue - - // Capitalize only first letter - NSString* setterName = [NSString stringWithFormat:@"set%@%@:", - [[propertyName substringWithRange:NSMakeRange(0,1)] capitalizedString], - [propertyName substringWithRange:NSMakeRange(1, [propertyName length]-1)]]; - - // - // Attempt Zero arg autocall for setter - // Object.alloc().init() -> Object.alloc.init - // - SEL sel = NSSelectorFromString(setterName); - if ([callee respondsToSelector:sel]) - { - // - // Delegate canCallMethod, callMethod - // - if (delegate) - { - // Check if calling is allowed - if ([delegate respondsToSelector:@selector(JSCocoa:canCallMethod:ofObject:argumentCount:arguments:inContext:exception:)]) - { - BOOL canCall = [delegate JSCocoa:jsc canCallMethod:setterName ofObject:callee argumentCount:0 arguments:NULL inContext:ctx exception:exception]; - if (!canCall) - { - if (!*exception) throwException(ctx, exception, [NSString stringWithFormat:@"Delegate does not allow calling [%@ %@]", callee, setterName]); - return NULL; - } - } - // Check if delegate handles calling - if ([delegate respondsToSelector:@selector(JSCocoa:callMethod:ofObject:privateObject:argumentCount:arguments:inContext:exception:)]) - { - JSValueRef delegateCall = [delegate JSCocoa:jsc callMethod:setterName ofObject:callee privateObject:privateObject argumentCount:0 arguments:NULL inContext:ctx exception:exception]; - if (delegateCall) return !!delegateCall; - } - } - - // Get method pointer - Method method = class_getInstanceMethod([callee class], sel); - if (!method) method = class_getClassMethod([callee class], sel); - - // If we didn't find a method, try Distant Object - if (!method) - { - // Last chance before exception : try calling DO - BOOL b = [jsc JSCocoa:jsc setProperty:propertyName ofObject:callee toValue:jsValue inContext:ctx exception:exception]; - if (b) return YES; - - throwException(ctx, exception, [NSString stringWithFormat:@"Could not set property[%@ %@]", callee, propertyName]); - return NULL; - } - - // Extract arguments - const char* typeEncoding = method_getTypeEncoding(method); - id argumentEncodings = [JSCocoaController parseObjCMethodEncoding:typeEncoding]; - if ([[argumentEncodings objectAtIndex:0] typeEncoding] != 'v') return throwException(ctx, exception, [NSString stringWithFormat:@"(in setter) %@ must return void", setterName]), false; - - // Call address - void* callAddress = getObjCCallAddress(argumentEncodings); - - // - // ffi data - // - ffi_cif cif; - ffi_type* args[3]; - void* values[3]; - char* selector; - - selector = (char*)NSSelectorFromString(setterName); - args[0] = &ffi_type_pointer; - args[1] = &ffi_type_pointer; - values[0] = (void*)&callee; - values[1] = (void*)&selector; - - // Get arg (skip return value, instance, selector) - JSCocoaFFIArgument* arg = [argumentEncodings objectAtIndex:3]; - BOOL converted = [arg fromJSValueRef:jsValue inContext:ctx]; - if (!converted) return throwException(ctx, exception, [NSString stringWithFormat:@"(in setter) Argument %c not converted", [arg typeEncoding]]), false; - args[2] = [arg ffi_type]; - values[2] = [arg storage]; - - // Setup ffi - ffi_status prep_status = ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 3, &ffi_type_void, args); - // - // Call ! - // - if (prep_status == FFI_OK) - { - ffi_call(&cif, callAddress, NULL, values); - } - return true; - } - - if ([callee respondsToSelector:@selector(setJSValue:forJSName:)]) - { - // Set as instance variable -// BOOL set = [callee setJSValue:jsValue forJSName:propertyNameJS]; - JSValueRefAndContextRef value = { JSValueMakeNull(ctx), ctx }; - value.value = jsValue; - - JSValueRefAndContextRef name = { JSValueMakeNull(ctx), ctx } ; - name.value = JSValueMakeString(ctx, propertyNameJS); - BOOL set = [callee setJSValue:value forJSName:name]; - if (set) return true; - } - } - - // External WebView value - if ([privateObject.type isEqualToString:@"externalJSValueRef"] || [[privateObject rawPointerEncoding] isEqualToString:@"^{OpaqueJSContext=}"]) - { - JSValueRef externalValue = [privateObject jsValueRef]; - JSContextRef externalCtx = externalValue ? [privateObject ctx] : [privateObject rawPointer]; - JSObjectRef externalObject = externalValue ? JSValueToObject(externalCtx, externalValue, NULL) : JSContextGetGlobalObject(externalCtx); - if (!externalObject) return false; - - JSValueRef convertedValue = valueToExternalContext(ctx, jsValue, externalCtx); - JSObjectSetProperty(externalCtx, externalObject, propertyNameJS, convertedValue, kJSPropertyAttributeNone, exception); - - // If WebView had an exception, re-throw it in our context - if (exception && *exception) - { - id s = [JSCocoaController formatJSException:*exception inContext:externalCtx]; - throwException(ctx, exception, [NSString stringWithFormat:@"(WebView) %@", s]); - return false; - } - - return true; - } - - // - // From here we return false to have Javascript set values on Javascript objects : valueOf, thisObject, structures - // - - // Special case for autocall : allow current js object to receive a custom valueOf method that will handle autocall - // And a thisObject property holding class for instance autocall - if ([propertyName isEqualToString:@"valueOf"]) return false; - // An out argument allocates pointer storage when calling stuff like gl version. - // JSCocoa needs to set a custom javascript property to recognize out arguments. - if ([propertyName isEqualToString:@"isOutArgument"]) return false; - // Allow general setting on structs - if ([privateObject.type isEqualToString:@"struct"]) return false; - - // Don't throw an exception if setting is allowed - if ([jsc canSetOnBoxedObjects]) return false; - - // Setter fails AND WARNS if propertyName can't be set - // This happens of non-JSCocoa ObjC objects, eg NSWorkspace.sharedWorspace.someVariable = value - return throwException(ctx, exception, [NSString stringWithFormat:@"(in setter) object %@ does not support setting — Derive from that class to make it able to host any Javascript object ", privateObject.object]), false; -} - - -// -// deleteProperty -// delete property in hash -// -static bool jsCocoaObject_deleteProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyNameJS, JSValueRef* exception) -{ - NSString* propertyName = (NSString*)JSStringCopyCFString(kCFAllocatorDefault, propertyNameJS); - [NSMakeCollectable(propertyName) autorelease]; - - JSCocoaPrivateObject* privateObject = JSObjectGetPrivate(object); - - if (![privateObject.type isEqualToString:@"@"]) return false; - - id callee = [privateObject object]; - if (![callee respondsToSelector:@selector(setJSValue:forJSName:)]) return false; - JSValueRefAndContextRef name = { JSValueMakeNull(ctx), ctx } ; - name.value = JSValueMakeString(ctx, propertyNameJS); - return [callee deleteJSValueForJSName:name]; -} - - -// -// getPropertyNames -// enumerate dictionary keys -// -static void jsCocoaObject_getPropertyNames(JSContextRef ctx, JSObjectRef object, JSPropertyNameAccumulatorRef propertyNames) -{ - JSCocoaPrivateObject* privateObject = JSObjectGetPrivate(object); - - // If we have a dictionary, add keys from allKeys - if ([privateObject.type isEqualToString:@"@"]) - { - id o = privateObject.object; - // Vend property only for classes - if (o == [o class]) - { - JSStringRef jsString = JSStringCreateWithUTF8CString(RuntimeInformationPropertyName); - JSPropertyNameAccumulatorAddName(propertyNames, jsString); - JSStringRelease(jsString); - } - if ([o isKindOfClass:[NSDictionary class]]) - { - id dictionary = privateObject.object; - id keys = [dictionary allKeys]; - - for (id key in keys) - { - JSStringRef jsString = JSStringCreateWithUTF8CString([key UTF8String]); - JSPropertyNameAccumulatorAddName(propertyNames, jsString); - JSStringRelease(jsString); - } - } - } -} - - - -// -// callAsFunction -// done in two methods. -// jsCocoaObject_callAsFunction is called first and handles -// * C and ObjC calls : calls jsCocoaObject_callAsFunction_ffi -// * Super call : in a derived ObjC class method, call this.Super(arguments) to call the parent method with jsCocoaObject_callAsFunction_ffi -// * js function calls : on an ObjC class, use of pure js functions as methods -// * toString, valueOf -// -// jsCocoaObject_callAsFunction_ffi calls a C function or an ObjC method with provided arguments. -// - -// This uses libffi to call C and ObjC. -static JSValueRef jsCocoaObject_callAsFunction_ffi(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, JSValueRef arguments[], JSValueRef* exception, NSString* superSelector, Class superSelectorClass, BOOL isVariadic, JSValueRef** argumentsToFree) -{ - JSCocoaPrivateObject* privateObject = JSObjectGetPrivate(function); - JSCocoaPrivateObject* thisPrivateObject = JSObjectGetPrivate(thisObject); - - // Return an exception if calling on NULL - if (thisPrivateObject.object == NULL && !privateObject.xml) - return throwException(ctx, exception, @"jsCocoaObject_callAsFunction : call with null object"), NULL; - - // Function address - void* callAddress = NULL; - - // Number of arguments of called method or function - NSUInteger callAddressArgumentCount = 0; - - // Arguments encoding - // Holds return value encoding as first element - NSMutableArray* argumentEncodings = nil; - - // Calling ObjC ? If NO, we're calling C - BOOL callingObjC = NO; - // Structure return (objc_msgSend_stret) - BOOL usingStret = NO; - // Calling instance... , replaced with init... and released, making the js object sole owner - BOOL callingInstance = NO; - - - // Get delegate - JSCocoaController* jsc = [JSCocoaController controllerFromContext:ctx]; - id delegate = jsc.delegate; - - // - // ObjC setup - // - id callee = NULL, methodName = NULL, functionName = NULL; - - // Calls can be made on boxed ObjC objects AND JSCocoaPrivateObjects - if ([privateObject.type isEqualToString:@"method"] && ([thisPrivateObject.type isEqualToString:@"@"] || [thisPrivateObject.object class] == [JSCocoaPrivateObject class])) - { - callingObjC = YES; - callee = [thisPrivateObject object]; - methodName = superSelector ? superSelector : [NSMutableString stringWithString:privateObject.methodName]; -// NSLog(@"calling %@.%@", callee, methodName); - - // - // Delegate canCallMethod, callMethod - // Called first so it gets a chance to do handle custom messages - // - if (delegate) - { - // Check if calling is allowed - if ([delegate respondsToSelector:@selector(JSCocoa:canCallMethod:ofObject:argumentCount:arguments:inContext:exception:)]) - { - BOOL canCall = [delegate JSCocoa:jsc canCallMethod:methodName ofObject:callee argumentCount:argumentCount arguments:arguments inContext:ctx exception:exception]; - if (!canCall) - { - if (!*exception) throwException(ctx, exception, [NSString stringWithFormat:@"Delegate does not allow calling [%@ %@]", callee, methodName]); - return NULL; - } - } - // Check if delegate handles calling - if ([delegate respondsToSelector:@selector(JSCocoa:callMethod:ofObject:privateObject:argumentCount:arguments:inContext:exception:)]) - { - JSValueRef delegateCall = [delegate JSCocoa:jsc callMethod:methodName ofObject:callee privateObject:thisPrivateObject argumentCount:argumentCount arguments:arguments inContext:ctx exception:exception]; - if (delegateCall) return delegateCall; - } - } - // Special case for alloc autocall — do not retain alloced result as it might crash (eg [[NSLocale alloc] retain] fails in ObjC) - if (![jsc useAutoCall] && argumentCount == 0 && [methodName isEqualToString:@"alloc"]) - { - id allocatedObject = [callee alloc]; -// JSObjectRef jsObject = [JSCocoaController jsCocoaPrivateObjectInContext:ctx]; - JSObjectRef jsObject = [jsc newPrivateObject]; - JSCocoaPrivateObject* private = JSObjectGetPrivate(jsObject); - private.type = @"@"; - [private setObjectNoRetain:allocatedObject]; - return jsObject; - } - - - // Instance call -/* - if ([callee class] == callee && [methodName isEqualToString:@"instance"]) - { - if (argumentCount > 1) return throwException(ctx, exception, @"Invalid argument count in instance call : must be 0 or 1"), NULL; - return [callee instanceWithContext:ctx argumentCount:argumentCount arguments:arguments exception:exception]; - } -*/ - // Check selector - if (![callee respondsToSelector:NSSelectorFromString(methodName)]) - { - // - // Split call - // set( { value : '5', forKey : 'hello' } ) - // -> setValue:forKey: - // - if ([jsc useSplitCall]) - { - id splitMethodName = privateObject.methodName; - id class = [callee class]; - if (callee == class) - class = objc_getMetaClass(object_getClassName(class)); - BOOL isSplitCall = [JSCocoaController trySplitCall:&splitMethodName class:class argumentCount:&argumentCount arguments:&arguments ctx:ctx]; - if (isSplitCall) - { - methodName = splitMethodName; - // trySplitCall returned new arguments that we'll need to free later on - *argumentsToFree = arguments; - } - } - } - - // Get method pointer - Method method = class_getInstanceMethod([callee class], NSSelectorFromString(methodName)); - if (!method) method = class_getClassMethod([callee class], NSSelectorFromString(methodName)); - - // If we didn't find a method, try an instance call, then try treating object as Javascript string, then try Distant Object - if (!method) - { - // Instance Check - if ([methodName hasPrefix:@"instance"]) - { - id initMethodName = [NSString stringWithFormat:@"init%@", [methodName substringFromIndex:8]]; - id class = [callee class]; - method = class_getInstanceMethod(class, NSSelectorFromString(initMethodName)); - methodName = initMethodName; - callee = [class alloc]; - callingInstance = YES; - } - - if (!method) - { - // (First) Last chance before exception : try treating callee as a Javascript string - if ([callee isKindOfClass:[NSString class]]) - { - id script = [NSString stringWithFormat:@"String.prototype.%@", methodName]; - JSStringRef jsScript = JSStringCreateWithUTF8CString([script UTF8String]); - JSValueRef result = JSEvaluateScript(ctx, jsScript, NULL, NULL, 1, NULL); - JSStringRelease(jsScript); - if (result && JSValueGetType(ctx, result) == kJSTypeObject) - { - JSStringRef string = JSStringCreateWithCFString((CFStringRef)callee); - JSValueRef stringValue = JSValueMakeString(ctx, string); - JSStringRelease(string); - - JSObjectRef functionObject = JSValueToObject(ctx, result, NULL); - JSObjectRef jsThisObject = JSValueToObject(ctx, stringValue, NULL); - JSValueRef r = JSObjectCallAsFunction(ctx, functionObject, jsThisObject, argumentCount, arguments, NULL); - return r; - } - } - - // Last chance before exception : try calling DO - JSValueRef res = [jsc JSCocoa:jsc callMethod:methodName ofObject:callee privateObject:thisPrivateObject argumentCount:argumentCount arguments:arguments inContext:ctx exception:exception]; - if (res) return res; - - return throwException(ctx, exception, [NSString stringWithFormat:@"jsCocoaObject_callAsFunction : method %@ of object %@ not found — remnant of a split call ?", methodName, [callee class]]), NULL; - } - } - - // Extract arguments - const char* typeEncoding = method_getTypeEncoding(method); -// NSLog(@"method %@ encoding=%s", methodName, typeEncoding); - argumentEncodings = [JSCocoaController parseObjCMethodEncoding:typeEncoding]; - if (!argumentEncodings) { - return throwException(ctx, exception, [NSString stringWithFormat:@"jsCocoaObject_callAsFunction could not parse type encodings %s of [%@ %@]", [JSCocoa typeEncodingOfMethod:methodName class:[[callee class] description]], methodName, [callee class]]), NULL; - } - // Function arguments is all arguments minus return value and [instance, selector] params to objc_send - callAddressArgumentCount = [argumentEncodings count]-3; - - // Get call address - callAddress = getObjCCallAddress(argumentEncodings); - } - - // - // C setup - // - if (!callingObjC) - { - if (!privateObject.xml) return throwException(ctx, exception, @"jsCocoaObject_callAsFunction : no xml in object = nothing to call (Autocall problem ? To call argless objCobject.method(), remove the parens if autocall is ON)") , NULL; -// NSLog(@"C encoding=%@", privateObject.xml); - argumentEncodings = [JSCocoaController parseCFunctionEncoding:privateObject.xml functionName:&functionName]; - // Grab symbol - callAddress = dlsym(RTLD_DEFAULT, [functionName UTF8String]); - if (!callAddress) return throwException(ctx, exception, [NSString stringWithFormat:@"Function %@ not found", functionName]), NULL; - // Function arguments is all arguments minus return value - callAddressArgumentCount = [argumentEncodings count]-1; - - // - // Delegate canCallFunction - // - if (delegate) - { - // Check if calling is allowed - if ([delegate respondsToSelector:@selector(JSCocoa:canCallFunction:argumentCount:arguments:inContext:exception:)]) - { - BOOL canCall = [delegate JSCocoa:jsc canCallFunction:functionName argumentCount:argumentCount arguments:arguments inContext:ctx exception:exception]; - if (!canCall) - { - if (!*exception) throwException(ctx, exception, [NSString stringWithFormat:@"Delegate does not allow calling function %@", functionName]); - return NULL; - } - } - } - } - - // - // Variadic call ? - // If argument count doesn't match descripted argument count, - // we may have a variadic call - // - // Possibly account for a missing terminating NULL in ObjC variadic method - // -> allows calling - // [NSArray arrayWithObjects:'hello', 'world'] - // instead of - // [NSArray arrayWithObjects:'hello', 'world', null] - // - BOOL sugarCheckVariadic = NO; - // Check if selector or method names matches a known variadic method. This may be a false positive ... - if (isVariadic) - { - // ... so we check further. - if (methodName) isVariadic = [[JSCocoaController controllerFromContext:ctx] isMethodVariadic:methodName class:[callee class]]; - else isVariadic = [[JSCocoaController controllerFromContext:ctx] isFunctionVariadic:functionName]; - - // Bail if not variadic - if (!isVariadic) - { - return throwException(ctx, exception, [NSString stringWithFormat:@"Bad argument count in %@ : expected %d, got %d", functionName ? functionName : methodName, callAddressArgumentCount, argumentCount]), NULL; - } - // Sugar check : if last object is not NULL, account for it - if (isVariadic && callingObjC && argumentCount && !JSValueIsNull(ctx, arguments[argumentCount-1])) - { - // Will be tested during argument conversion - sugarCheckVariadic = YES; - argumentCount++; - } - } - else - { - if (callAddressArgumentCount != argumentCount) - { - return throwException(ctx, exception, [NSString stringWithFormat:@"Bad argument count in %@ : expected %d, got %d", functionName ? functionName : methodName, callAddressArgumentCount, argumentCount]), NULL; - } - } - - // - // ffi data - // - ffi_cif cif; - ffi_type** args = NULL; - void** values = NULL; - char* selector; - // super call - struct objc_super _super; - void* superPointer; - - // Total number of arguments to ffi_call - NSUInteger effectiveArgumentCount = argumentCount + (callingObjC ? 2 : 0); - if (effectiveArgumentCount > 0) - { - args = malloc(sizeof(ffi_type*)*effectiveArgumentCount); - values = malloc(sizeof(void*)*effectiveArgumentCount); - - // If calling ObjC, setup instance and selector - int i, idx = 0; - if (callingObjC) - { - selector = (char*)NSSelectorFromString(methodName); - args[0] = &ffi_type_pointer; - args[1] = &ffi_type_pointer; - values[0] = (void*)&callee; - values[1] = (void*)&selector; - idx = 2; - - // Super handling - if (superSelector) - { - if (superSelectorClass == nil) return throwException(ctx, exception, [NSString stringWithFormat:@"Null superclass in %@", callee]), NULL; - callAddress = objc_msgSendSuper; - if (usingStret) callAddress = objc_msgSendSuper_stret; - _super.receiver = callee; -#if __LP64__ - _super.super_class = superSelectorClass; -//#elif TARGET_IPHONE_SIMULATOR || !TARGET_OS_IPHONE -// _super.class = superSelectorClass; -#else - _super.super_class = superSelectorClass; -#endif - superPointer = &_super; - values[0] = &superPointer; -// NSLog(@"superClass=%@ (old=%@) (%@) function=%p", superSelectorClass, [callee superclass], [callee class], function); - } - } - - // Setup arguments, unboxing or converting data - for (i=0; i= callAddressArgumentCount) - { - arg = [[JSCocoaFFIArgument alloc] init]; - [arg setTypeEncoding:'@']; - [arg autorelease]; - } - else - arg = [argumentEncodings objectAtIndex:idx+1]; - - // Convert argument - JSValueRef jsValue = sugarCheckVariadic && i == argumentCount-1 ? JSValueMakeNull(ctx) : arguments[i]; - BOOL shouldConvert = YES; - // Check type o modifiers - if ([arg typeEncoding] == '^') - { - // If holding a JSCocoaOutArgument, allocate custom storage - if (JSValueGetType(ctx, jsValue) == kJSTypeObject) - { - JSStringRef jsName = JSStringCreateWithUTF8CString("isOutArgument"); - BOOL isOutArgument = JSValueToBoolean(ctx, JSObjectGetProperty(ctx, JSValueToObject(ctx, jsValue, NULL), jsName, NULL)); - JSStringRelease(jsName); - if (isOutArgument) - { - id unboxed = nil; - [JSCocoaFFIArgument unboxJSValueRef:jsValue toObject:&unboxed inContext:ctx]; - if (unboxed && [unboxed isKindOfClass:[JSCocoaOutArgument class]]) - { - if (![(JSCocoaOutArgument*)unboxed mateWithJSCocoaFFIArgument:arg]) return throwException(ctx, exception, [NSString stringWithFormat:@"Pointer argument %@ not handled", [arg pointerTypeEncoding]]), NULL; - shouldConvert = NO; - [arg setIsOutArgument:YES]; - } - if (unboxed && [unboxed isKindOfClass:[JSCocoaMemoryBuffer class]]) - { - JSCocoaMemoryBuffer* buffer = unboxed; - [arg setTypeEncoding:[arg typeEncoding] withCustomStorage:[buffer pointerForIndex:0]]; - shouldConvert = NO; - [arg setIsOutArgument:YES]; - } - } - } - - if (shouldConvert) - { - // Allocate default storage - [arg allocateStorage]; - } - - } - - args[idx] = [arg ffi_type]; - if (shouldConvert) - { - BOOL converted = [arg fromJSValueRef:jsValue inContext:ctx]; - if (!converted) - return throwException(ctx, exception, [NSString stringWithFormat:@"Argument %c not converted", [arg typeEncoding]]), NULL; - } - values[idx] = [arg storage]; - } - } - - // Get return value holder - id returnValue = [argumentEncodings objectAtIndex:0]; - - // Allocate return value storage if it's a pointer - if ([returnValue typeEncoding] == '^') - [returnValue allocateStorage]; - - // Setup ffi - ffi_status prep_status = ffi_prep_cif(&cif, FFI_DEFAULT_ABI, (unsigned int)effectiveArgumentCount, [returnValue ffi_type], args); - - // - // Call ! - // - if (prep_status == FFI_OK) - { - void* storage = [returnValue storage]; - if ([returnValue ffi_type] == &ffi_type_void) storage = NULL; - - // Catch exceptions when calling ObjC - if (callingObjC) - { - @try - { - ffi_call(&cif, callAddress, storage, values); - } - @catch (NSException* e) - { - if (effectiveArgumentCount > 0) - { - free(args); - free(values); - } - [JSCocoaFFIArgument boxObject:e toJSValueRef:exception inContext:ctx]; - return NULL; - } - } - else - ffi_call(&cif, callAddress, storage, values); - } - - if (effectiveArgumentCount > 0) - { - free(args); - free(values); - } - if (prep_status != FFI_OK) return throwException(ctx, exception, @"ffi_prep_cif failed"), NULL; - - // Return now if our function returns void - // Return null as a JSValueRef to avoid crashing - if ([returnValue ffi_type] == &ffi_type_void) return JSValueMakeNull(ctx); - - // Else, convert return value - JSValueRef jsReturnValue = NULL; - BOOL converted = [returnValue toJSValueRef:&jsReturnValue inContext:ctx]; - if (!converted) return throwException(ctx, exception, [NSString stringWithFormat:@"Return value not converted in %@", methodName?methodName:functionName]), NULL; - - // Instance call : release object to make js object sole owner - if (callingInstance) - { - JSCocoaPrivateObject* private = JSObjectGetPrivate(JSValueToObject(ctx, jsReturnValue, NULL)); - [private.object release]; - } - - return jsReturnValue; -} - -// -// This method handles -// * C and ObjC calls -// * Super call : retrieves the method name to call, thereby giving new arguments to jsCocoaObject_callAsFunction_ffi -// * js function calls : on an ObjC class, use of pure js functions as methods -// * toString, valueOf -// -static JSValueRef jsCocoaObject_callAsFunction(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) -{ - JSCocoaPrivateObject* privateObject = JSObjectGetPrivate(function); - JSValueRef* superArguments = NULL; - id superSelector = NULL; - id superSelectorClass = NULL; - - // Pure JS functions for derived ObjC classes - if ([privateObject jsValueRef]) - { - if ([privateObject.type isEqualToString:@"jsFunction"]) - { - JSObjectRef jsFunction = JSValueToObject(ctx, [privateObject jsValueRef], NULL); - JSValueRef ret = JSObjectCallAsFunction(ctx, jsFunction, thisObject, argumentCount, arguments, exception); - return ret; - } - else - if ([privateObject.type isEqualToString:@"externalJSValueRef"]) - { - JSContextRef externalCtx = [privateObject ctx]; - JSObjectRef jsFunction = JSValueToObject(externalCtx, [privateObject jsValueRef], NULL); - if (!jsFunction) - { - throwException(ctx, exception, [NSString stringWithFormat:@"WebView call : value not a function"]); - return JSValueMakeNull(ctx); - } - - // Retrieve 'this' : either the global external object (window), or a result from previous calll - JSObjectRef externalThisObject; - JSCocoaPrivateObject* privateThis = JSObjectGetPrivate(thisObject); - if ([privateThis jsValueRef]) externalThisObject = JSValueToObject(externalCtx, [privateThis jsValueRef], NULL); - else externalThisObject = JSContextGetGlobalObject(externalCtx); - - if (!externalThisObject) - { - throwException(ctx, exception, [NSString stringWithFormat:@"WebView call : externalThisObject not found"]); - return JSValueMakeNull(ctx); - } - - // Convert arguments to WebView context - JSValueRef* convertedArguments = NULL; - if (argumentCount) convertedArguments = malloc(sizeof(JSValueRef)*argumentCount); - for (int i=0; i", - [self class], - self, - ((id)self == (id)[self class]) ? @"Class" : @"", - [boxedObject class], - boxedObject, - retainCount]; -} - -@end - diff --git a/Atom/JSCocoa/JSCocoaFFIArgument.h b/Atom/JSCocoa/JSCocoaFFIArgument.h deleted file mode 100644 index 911d6d563..000000000 --- a/Atom/JSCocoa/JSCocoaFFIArgument.h +++ /dev/null @@ -1,97 +0,0 @@ -// -// JSCocoaFFIArgument.h -// JSCocoa -// -// Created by Patrick Geiller on 14/07/08. -// Copyright 2008 __MyCompanyName__. All rights reserved. -// - -#if !TARGET_IPHONE_SIMULATOR && !TARGET_OS_IPHONE -#import -#import -#define MACOSX -#include -#endif -#if TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE -#import "iPhone/libffi/ffi.h" -#endif - -@interface JSCocoaFFIArgument : NSObject { - char typeEncoding; - NSString* structureTypeEncoding; - NSString* pointerTypeEncoding; - - void* ptr; - - ffi_type structureType; - - id customData; - BOOL isReturnValue; - BOOL ownsStorage; - BOOL isOutArgument; -} - -- (NSString*)typeDescription; - -- (BOOL)setTypeEncoding:(char)encoding; -- (BOOL)setTypeEncoding:(char)encoding withCustomStorage:(void*)storagePtr; -- (void)setStructureTypeEncoding:(NSString*)encoding; -- (void)setStructureTypeEncoding:(NSString*)encoding withCustomStorage:(void*)storagePtr; -- (void)setPointerTypeEncoding:(NSString*)encoding; - -+ (int)sizeOfTypeEncoding:(char)encoding; -+ (int)alignmentOfTypeEncoding:(char)encoding; - -+ (ffi_type*)ffi_typeForTypeEncoding:(char)encoding; - -+ (int)sizeOfStructure:(NSString*)encoding; - - -+ (NSArray*)typeEncodingsFromStructureTypeEncoding:(NSString*)structureTypeEncoding; -+ (NSArray*)typeEncodingsFromStructureTypeEncoding:(NSString*)structureTypeEncoding parsedCount:(NSInteger*)count; - - -+ (NSString*)structureNameFromStructureTypeEncoding:(NSString*)structureTypeEncoding; -+ (NSString*)structureFullTypeEncodingFromStructureTypeEncoding:(NSString*)structureTypeEncoding; -+ (NSString*)structureFullTypeEncodingFromStructureName:(NSString*)structureName; -+ (NSString*)structureTypeEncodingDescription:(NSString*)structureTypeEncoding; - -+ (BOOL)fromJSValueRef:(JSValueRef)value inContext:(JSContextRef)ctx typeEncoding:(char)typeEncoding fullTypeEncoding:(NSString*)fullTypeEncoding fromStorage:(void*)ptr; - -+ (BOOL)toJSValueRef:(JSValueRef*)value inContext:(JSContextRef)ctx typeEncoding:(char)typeEncoding fullTypeEncoding:(NSString*)fullTypeEncoding fromStorage:(void*)ptr; - -+ (NSInteger)structureToJSValueRef:(JSValueRef*)value inContext:(JSContextRef)ctx fromCString:(char*)c fromStorage:(void**)storage; -+ (NSInteger)structureToJSValueRef:(JSValueRef*)value inContext:(JSContextRef)ctx fromCString:(char*)c fromStorage:(void**)ptr initialValues:(JSValueRef*)initialValues initialValueCount:(NSInteger)initialValueCount convertedValueCount:(NSInteger*)convertedValueCount; -+ (NSInteger)structureFromJSObjectRef:(JSObjectRef)value inContext:(JSContextRef)ctx inParentJSValueRef:(JSValueRef)parentValue fromCString:(char*)c fromStorage:(void**)ptr; - -+ (void)alignPtr:(void**)ptr accordingToEncoding:(char)encoding; -+ (void)advancePtr:(void**)ptr accordingToEncoding:(char)encoding; - - -- (void*)allocateStorage; -- (void*)allocatePointerStorage; -- (void**)storage; -- (void**)rawStoragePointer; -- (char)typeEncoding; -- (NSString*)structureTypeEncoding; -- (id)pointerTypeEncoding; - - -- (void)setIsReturnValue:(BOOL)v; -- (BOOL)isReturnValue; -- (void)setIsOutArgument:(BOOL)v; -- (BOOL)isOutArgument; - -- (BOOL)fromJSValueRef:(JSValueRef)value inContext:(JSContextRef)ctx; -- (BOOL)toJSValueRef:(JSValueRef*)value inContext:(JSContextRef)ctx; - - -+ (BOOL)boxObject:(id)o toJSValueRef:(JSValueRef*)value inContext:(JSContextRef)ctx; -+ (BOOL)unboxJSValueRef:(JSValueRef)value toObject:(id*)o inContext:(JSContextRef)ctx; -+ (BOOL)unboxJSArray:(JSObjectRef)value toObject:(id*)o inContext:(JSContextRef)ctx; -+ (BOOL)unboxJSHash:(JSObjectRef)value toObject:(id*)o inContext:(JSContextRef)ctx; - - -- (ffi_type*)ffi_type; - -@end diff --git a/Atom/JSCocoa/JSCocoaFFIArgument.m b/Atom/JSCocoa/JSCocoaFFIArgument.m deleted file mode 100644 index 0b60508ce..000000000 --- a/Atom/JSCocoa/JSCocoaFFIArgument.m +++ /dev/null @@ -1,1357 +0,0 @@ -// -// JSCocoaFFIArgument.m -// JSCocoa -// -// Created by Patrick Geiller on 14/07/08. -// Copyright 2008 __MyCompanyName__. All rights reserved. -// - -#import "JSCocoaFFIArgument.h" -#import "JSCocoaController.h" -#import "JSCocoaPrivateObject.h" -#import - - -#if TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE -#import "GDataDefines.h" -#import "GDataXMLNode.h" -#endif - -@implementation JSCocoaFFIArgument - - -- (id)init -{ - self = [super init]; - - ptr = NULL; - typeEncoding = 0; - isReturnValue = NO; - ownsStorage = YES; - isOutArgument = NO; - - structureTypeEncoding = nil; - structureType.elements = NULL; - - pointerTypeEncoding = nil; - - // Used to store string data while converting JSStrings to char* - customData = nil; - - return self; -} - -- (void)cleanUp -{ - if (structureTypeEncoding) [structureTypeEncoding release]; - if (pointerTypeEncoding) [pointerTypeEncoding release]; - if (ptr && ownsStorage) free(ptr); - if (customData) [customData release]; - - if (structureType.elements) free(structureType.elements); - ptr = NULL; -} - -- (void)dealloc -{ - [self cleanUp]; - [super dealloc]; -} -- (void)finalize -{ - [self cleanUp]; - [super finalize]; -} - -- (NSString*)description -{ - return [NSString stringWithFormat:@"JSCocoaFFIArgument %p typeEncoding=%c %@ isReturnValue=%d storage=%p", self, - typeEncoding, - (structureTypeEncoding ? structureTypeEncoding : @""), - isReturnValue, ptr]; -} - -+ (NSString*)typeDescriptionForTypeEncoding:(char)typeEncoding fullTypeEncoding:(NSString*)fullTypeEncoding -{ - switch (typeEncoding) - { - case _C_VOID: return @"void"; - case _C_ID: return @"ObjC object"; - case _C_CLASS: return @"ObjC class"; - case _C_CHR: return @"char"; - case _C_UCHR: return @"unsigned char"; - case _C_SHT: return @"short"; - case _C_USHT: return @"unsigned short"; - case _C_INT: return @"int"; - case _C_UINT: return @"unsigned int"; - case _C_LNG: return @"long"; - case _C_ULNG: return @"unsigned long"; - case _C_LNG_LNG: return @"long long"; - case _C_ULNG_LNG:return @"unsigned long long"; - case _C_FLT: return @"float"; - case _C_DBL: return @"double"; - case '{': - { - // Special case for getting raw JSValues to ObjC - BOOL isJSStruct = [fullTypeEncoding hasPrefix:@"{JSValueRefAndContextRef"]; - if (isJSStruct) - { - return @"(JSCocoa structure used to pass JSValueRef without conversion)"; - } - -// if (!JSValueIsObject(ctx, value)) return NO; -// JSObjectRef object = JSValueToObject(ctx, value, NULL); -// void* p = ptr; -// id r = [JSCocoaFFIArgument structureFullTypeEncodingFromStructureTypeEncoding:fullTypeEncoding]; -// if (!r) return [NSString stringWithFormat:@"(unknown structure %@)", fullTypeEncoding]; - return [JSCocoaFFIArgument structureTypeEncodingDescription:fullTypeEncoding]; - } - case _C_SEL: return @"selector"; - case _C_CHARPTR: return @"char*"; - case _C_BOOL: return @"BOOL"; - case _C_PTR: return @"pointer"; - case _C_UNDEF: return @"(function pointer or block?)"; - } - return @"(unknown)"; -} - -- (NSString*)typeDescription -{ - return [[self class] typeDescriptionForTypeEncoding:typeEncoding fullTypeEncoding:structureTypeEncoding]; -} - -#pragma mark Getters / Setters - -// -// Needed because libffi needs at least sizeof(long) as return value storage -// -- (void)setIsReturnValue:(BOOL)v -{ - isReturnValue = v; -} -- (BOOL)isReturnValue -{ - return isReturnValue; -} - -- (void)setIsOutArgument:(BOOL)v -{ - isOutArgument = v; -} -- (BOOL)isOutArgument -{ - return isOutArgument; -} - -- (char)typeEncoding -{ - return typeEncoding; -} - -- (BOOL)setTypeEncoding:(char)encoding -{ - if ([JSCocoaFFIArgument sizeOfTypeEncoding:encoding] == -1) { - NSLog(@"Bad type encoding %c", encoding); - return NO; - }; - - typeEncoding = encoding; - [self allocateStorage]; - - return YES; -} - -- (BOOL)setTypeEncoding:(char)encoding withCustomStorage:(void*)storagePtr -{ - if ([JSCocoaFFIArgument sizeOfTypeEncoding:encoding] == -1) { - NSLog(@"Bad type encoding %c", encoding); - return NO; - }; - - typeEncoding = encoding; - ownsStorage = NO; - ptr = storagePtr; - - return YES; -} - -- (NSString*)structureTypeEncoding -{ - return structureTypeEncoding; -} - -- (void)setStructureTypeEncoding:(NSString*)encoding -{ - [self setStructureTypeEncoding:encoding withCustomStorage:NULL]; -} - -- (void)setStructureTypeEncoding:(NSString*)encoding withCustomStorage:(void*)storagePtr -{ - typeEncoding = '{'; - structureTypeEncoding = [[NSString alloc] initWithString:encoding]; - - if (storagePtr) - { - ownsStorage = NO; - ptr = storagePtr; - } - else [self allocateStorage]; - - id types = [JSCocoaFFIArgument typeEncodingsFromStructureTypeEncoding:encoding]; - NSUInteger elementCount = [types count]; - - // - // Build FFI type - // - structureType.size = 0; - structureType.alignment = 0; - structureType.type = FFI_TYPE_STRUCT; - structureType.elements = malloc(sizeof(ffi_type*)*(elementCount+1)); // +1 is trailing NULL - - int i = 0; - for (id type in types) - { - char charEncoding = *(char*)[type UTF8String]; - structureType.elements[i++] = [JSCocoaFFIArgument ffi_typeForTypeEncoding:charEncoding]; - } - structureType.elements[elementCount] = NULL; -} - -// -// type o handling -// (pointers passed as arguments to a function, function writes values to these arguments) -// -- (void)setPointerTypeEncoding:(NSString*)encoding -{ - typeEncoding = '^'; - pointerTypeEncoding = [[NSString alloc] initWithString:encoding]; -} - -- (id)pointerTypeEncoding -{ - return pointerTypeEncoding; -} - - -- (ffi_type*)ffi_type -{ - if (!typeEncoding) return NULL; - if (pointerTypeEncoding) return &ffi_type_pointer; - - if (typeEncoding == '{') return &structureType; - - return [JSCocoaFFIArgument ffi_typeForTypeEncoding:typeEncoding]; -} - - -#pragma mark Storage - -- (void*)allocateStorage -{ - if (!typeEncoding) return NSLog(@"No type encoding set in %@", self), NULL; - - // NO ! will destroy structureTypeEncoding -// [self cleanUp]; - // Special case for structs - if (typeEncoding == '{') - { -// NSLog(@"allocateStorage: Allocating struct"); - // Some front padding for alignment and tail padding for structure - // ( http://developer.apple.com/documentation/DeveloperTools/Conceptual/LowLevelABI/Articles/IA32.html ) - // Structures are tail-padded to 32-bit multiples. - - // +16 for alignment - // +4 for tail padding -// ptr = malloc([JSCocoaFFIArgument sizeOfStructure:structureTypeEncoding] + 16 + 4); - ptr = malloc([JSCocoaFFIArgument sizeOfStructure:structureTypeEncoding] + 4); - return ptr; - } - - int size = [JSCocoaFFIArgument sizeOfTypeEncoding:typeEncoding]; - - // Bail if we can't handle our type - if (size == -1) return NSLog(@"Can't handle type %c", typeEncoding), NULL; - if (size >= 0) - { - int minimalReturnSize = sizeof(long); - if (isReturnValue && size < minimalReturnSize) size = minimalReturnSize; - ptr = malloc(size); - } -// NSLog(@"Allocated size=%d (%p) for object %@", size, ptr, self); - - return ptr; -} - -// type o : out arguments (eg fn(int* pointerToIntResult)) -- (void*)allocatePointerStorage -{ - typeEncoding = [pointerTypeEncoding UTF8String][1]; - if (typeEncoding == '{') - { - structureTypeEncoding = [pointerTypeEncoding substringFromIndex:1]; - [structureTypeEncoding retain]; - } - [self allocateStorage]; - return ptr; -} - -- (void**)storage -{ - if (typeEncoding == '{') - { -/* - int alignOnSize = 16; - - int address = (int)ptr; - if ((address % alignOnSize) != 0) - address = (address+alignOnSize) & ~(alignOnSize-1); -*/ - if (pointerTypeEncoding) return &ptr; -// return (void**)address; - } - - // Type o : return writable address -// if (pointerTypeEncoding) - if (isOutArgument) - { - return &ptr; - } - - return ptr; -} - -- (void**)rawStoragePointer -{ - return ptr; -} - -// This destroys the original pointer value by modifying it in place : maybe change to returning the new address ? -+ (void)alignPtr:(void**)ptr accordingToEncoding:(char)encoding -{ - int alignOnSize = [JSCocoaFFIArgument alignmentOfTypeEncoding:encoding]; - - long address = (long)*ptr; - if ((address % alignOnSize) != 0) - address = (address+alignOnSize) & ~(alignOnSize-1); -// NSLog(@"alignOf(%c)=%d", encoding, alignOnSize); - - *ptr = (void*)address; -} - -// This destroys the original pointer value by modifying it in place : maybe change to returning the new address ? -+ (void)advancePtr:(void**)ptr accordingToEncoding:(char)encoding -{ - long address = (long)*ptr; - address += [JSCocoaFFIArgument sizeOfTypeEncoding:encoding]; - *ptr = (void*)address; -} - - -#pragma mark Conversion - -// -// Convert from js value -// -- (BOOL)fromJSValueRef:(JSValueRef)value inContext:(JSContextRef)ctx -{ - BOOL r = [JSCocoaFFIArgument fromJSValueRef:value inContext:ctx typeEncoding:typeEncoding fullTypeEncoding:structureTypeEncoding?structureTypeEncoding:pointerTypeEncoding fromStorage:ptr]; - if (!r) - { - NSLog(@"fromJSValueRef FAILED, jsType=%d encoding=%c structureEncoding=%@", JSValueGetType(ctx, value), typeEncoding, structureTypeEncoding); - } - return r; -} - -+ (BOOL)fromJSValueRef:(JSValueRef)value inContext:(JSContextRef)ctx typeEncoding:(char)typeEncoding fullTypeEncoding:(NSString*)fullTypeEncoding fromStorage:(void*)ptr -{ - if (!typeEncoding) return NO; - -// JSType type = JSValueGetType(ctx, value); -// NSLog(@"JSType=%d encoding=%c self=%p", type, typeEncoding, self); - - switch (typeEncoding) - { - case _C_ID: - case _C_CLASS: - { - return [self unboxJSValueRef:value toObject:ptr inContext:ctx]; - } - - case _C_CHR: - case _C_UCHR: - case _C_SHT: - case _C_USHT: - case _C_INT: - case _C_UINT: - case _C_LNG: - case _C_ULNG: - case _C_LNG_LNG: - case _C_ULNG_LNG: - case _C_FLT: - case _C_DBL: - { - double number = JSValueToNumber(ctx, value, NULL); -// unsigned int u = number; -// NSLog(@"type=%d typeEncoding=%c n=%f uint=%d, %d", JSValueGetType(ctx, value), typeEncoding, number, (unsigned int)number, u); - - switch (typeEncoding) - { - case _C_CHR: *(char*)ptr = (char)number; break; - case _C_UCHR: *(unsigned char*)ptr = (unsigned char)number; break; - case _C_SHT: *(short*)ptr = (short)number; break; - case _C_USHT: *(unsigned short*)ptr = (unsigned short)number; break; - case _C_INT: - case _C_UINT: - { -#ifdef __BIG_ENDIAN__ - // Two step conversion : to unsigned int then to int. One step conversion fails on PPC. - unsigned int uint = (unsigned int)number; - *(signed int*)ptr = (signed int)uint; - break; -#endif -#ifdef __LITTLE_ENDIAN__ - *(int*)ptr = (int)number; - break; -#endif - } -/* - case _C_UINT: - { - // Two step conversion : to unsigned int then to int. One step conversion fails on PPC. - int uint = (int)number; - unsigned int u = (unsigned)uint; - NSLog(@"%d %u", uint, u); - *(signed int*)ptr = (signed int)uint; - break; - } -*/ -// case _C_UINT: *(unsigned int*)ptr = (unsigned int)number; break; - case _C_LNG: *(long*)ptr = (long)number; break; - case _C_ULNG: *(unsigned long*)ptr = (unsigned long)number; break; - case _C_LNG_LNG: *(long long*)ptr = (long long)number; break; - case _C_ULNG_LNG: *(unsigned long long*)ptr = (unsigned long long)number; break; - case _C_FLT: *(float*)ptr = (float)number; break; - case _C_DBL: *(double*)ptr = (double)number; break; - } - return YES; - } - case '{': - { - // Special case for getting raw JSValues to ObjC -// BOOL isJSStruct = NSOrderedSame == [fullTypeEncoding compare:@"{JSValueRefAndContextRef" options:0 range:NSMakeRange(0, sizeof("{JSValueRefAndContextRef")-1)]; - BOOL isJSStruct = [fullTypeEncoding hasPrefix:@"{JSValueRefAndContextRef"]; - - if (isJSStruct) - { - // Beware ! This context is not the global context and will be valid only for that call. - // Other uses (closures) use the global context via JSCocoaController. - JSValueRefAndContextRef* jsStruct = (JSValueRefAndContextRef*)ptr; - jsStruct->value = value; - jsStruct->ctx = ctx; - return YES; - } - - if (!JSValueIsObject(ctx, value)) return NO; - JSObjectRef object = JSValueToObject(ctx, value, NULL); - void* p = ptr; - id type = [JSCocoaFFIArgument structureFullTypeEncodingFromStructureTypeEncoding:fullTypeEncoding]; - NSInteger numParsed = [JSCocoaFFIArgument structureFromJSObjectRef:object inContext:ctx inParentJSValueRef:NULL fromCString:(char*)[type UTF8String] fromStorage:&p]; - return numParsed; - } - case _C_SEL: - { - id str = NSStringFromJSValue(ctx, value); - *(SEL*)ptr = NSSelectorFromString(str); - return YES; - } - case _C_CHARPTR: - { - id str = NSStringFromJSValue(ctx, value); - *(char**)ptr = (char*)[str UTF8String]; - return YES; - } - case _C_BOOL: - { - bool b = JSValueToBoolean(ctx, value); - *(BOOL*)ptr = b; - return YES; - } - - case _C_PTR: - { - if ([fullTypeEncoding hasPrefix:@"^{OpaqueJSValue"]) - { - NSLog(@"JSValueRef argument was converted to nil — to pass raw Javascript values to ObjC, use JSValueRefAndContextRef"); - *(id*)ptr = nil; - return YES; - } - return [self unboxJSValueRef:value toObject:ptr inContext:ctx]; - } - - } - return NO; -} - - -// -// Convert to js value -// -- (BOOL)toJSValueRef:(JSValueRef*)value inContext:(JSContextRef)ctx -{ - void* p = ptr; -#ifdef __BIG_ENDIAN__ - long v; - // Return value was padded, need to do some shifting on PPC - if (isReturnValue) - { - int size = [JSCocoaFFIArgument sizeOfTypeEncoding:typeEncoding]; - int paddedSize = sizeof(long); - - if (size > 0 && size < paddedSize && paddedSize == 4) - { - v = *(long*)ptr; - v = CFSwapInt32(v); - p = &v; - } - } -#endif -// if (typeEncoding == '{') p = [self storage]; - id encoding = structureTypeEncoding ? structureTypeEncoding : pointerTypeEncoding; - BOOL r = [JSCocoaFFIArgument toJSValueRef:value inContext:ctx typeEncoding:typeEncoding fullTypeEncoding:encoding fromStorage:p]; - if (!r) NSLog(@"toJSValueRef FAILED"); - return r; -} - - -+ (BOOL)toJSValueRef:(JSValueRef*)value inContext:(JSContextRef)ctx typeEncoding:(char)typeEncoding fullTypeEncoding:(NSString*)fullTypeEncoding fromStorage:(void*)ptr -{ - if (!typeEncoding) return NO; - -// NSLog(@"toJSValueRef: %c ptr=%p", typeEncoding, ptr); - switch (typeEncoding) - { - case _C_ID: - case _C_CLASS: - { - id objcObject = *(id*)ptr; - return [self boxObject:(id)objcObject toJSValueRef:value inContext:ctx]; - - } - - case _C_VOID: - return YES; - - case _C_CHR: - case _C_UCHR: - case _C_SHT: - case _C_USHT: - case _C_INT: - case _C_UINT: - case _C_LNG: - case _C_ULNG: - case _C_LNG_LNG: - case _C_ULNG_LNG: - case _C_FLT: - case _C_DBL: - { - double number; - switch (typeEncoding) - { - case _C_CHR: number = *(char*)ptr; break; - case _C_UCHR: number = *(unsigned char*)ptr; break; - case _C_SHT: number = *(short*)ptr; break; - case _C_USHT: number = *(unsigned short*)ptr; break; - case _C_INT: number = *(int*)ptr; break; - case _C_UINT: number = *(unsigned int*)ptr; break; - case _C_LNG: number = *(long*)ptr; break; - case _C_ULNG: number = *(unsigned long*)ptr; break; - case _C_LNG_LNG: number = *(long long*)ptr; break; - case _C_ULNG_LNG: number = *(unsigned long long*)ptr; break; - case _C_FLT: number = *(float*)ptr; break; - case _C_DBL: number = *(double*)ptr; break; - } - *value = JSValueMakeNumber(ctx, number); - return YES; - } - - - case '{': - { - // Special case for getting raw JSValues from ObjC to JS - BOOL isJSStruct = [fullTypeEncoding hasPrefix:@"{JSValueRefAndContextRef"]; - if (isJSStruct) - { - JSValueRefAndContextRef* jsStruct = (JSValueRefAndContextRef*)ptr; - *value = jsStruct->value; - return YES; - } - - void* p = ptr; - id type = [JSCocoaFFIArgument structureFullTypeEncodingFromStructureTypeEncoding:fullTypeEncoding]; - // Bail if structure not found - if (!type) return 0; - -// JSObjectRef jsObject = [JSCocoaController jsCocoaPrivateObjectInContext:ctx]; - JSObjectRef jsObject = [[JSCocoa controllerFromContext:ctx] newPrivateObject]; - JSCocoaPrivateObject* private = JSObjectGetPrivate(jsObject); - private.type = @"struct"; - NSInteger numParsed = [JSCocoaFFIArgument structureToJSValueRef:value inContext:ctx fromCString:(char*)[type UTF8String] fromStorage:&p]; - return numParsed; - } - - case _C_SEL: - { - SEL sel = *(SEL*)ptr; - id str = NSStringFromSelector(sel); -// JSStringRef jsName = JSStringCreateWithUTF8CString([str UTF8String]); - JSStringRef jsName = JSStringCreateWithCFString((CFStringRef)str); - *value = JSValueMakeString(ctx, jsName); - JSStringRelease(jsName); - return YES; - } - case _C_BOOL: - { - BOOL b = *(BOOL*)ptr; - *value = JSValueMakeBoolean(ctx, b); - return YES; - } - case _C_CHARPTR: - { - // Rturn Javascript null if char* is null - char* charPtr = *(char**)ptr; - if (!charPtr) - { - *value = JSValueMakeNull(ctx); - return YES; - } - // Convert to NSString and then to Javascript string - NSString* name = [NSString stringWithUTF8String:charPtr]; - JSStringRef jsName = JSStringCreateWithCFString((CFStringRef)name); - *value = JSValueMakeString(ctx, jsName); - JSStringRelease(jsName); - return YES; - } - - case _C_PTR: - { -// JSObjectRef o = [JSCocoaController jsCocoaPrivateObjectInContext:ctx]; - JSObjectRef o = [[JSCocoa controllerFromContext:ctx] newPrivateObject]; - JSCocoaPrivateObject* private = JSObjectGetPrivate(o); - private.type = @"rawPointer"; - [private setRawPointer:*(void**)ptr encoding:fullTypeEncoding]; - *value = o; - return YES; - } - } - - return NO; -} - -/* - - *value MUST be NULL to be receive allocated JSValue - - The given pointer is advanced in place : its value will change after the call. - Pass a writeable pointer whose original value you don't care about. - -*/ -+ (NSInteger)structureToJSValueRef:(JSValueRef*)value inContext:(JSContextRef)ctx fromCString:(char*)c fromStorage:(void**)ptr -{ - return [self structureToJSValueRef:value inContext:ctx fromCString:c fromStorage:ptr initialValues:nil initialValueCount:0 convertedValueCount:nil]; -} - -+ (NSInteger)structureToJSValueRef:(JSValueRef*)value inContext:(JSContextRef)ctx fromCString:(char*)c fromStorage:(void**)ptr initialValues:(JSValueRef*)initialValues initialValueCount:(NSInteger)initialValueCount convertedValueCount:(NSInteger*)convertedValueCount -{ - // Build new structure object -// JSObjectRef jsObject = [JSCocoaController jsCocoaPrivateObjectInContext:ctx]; - JSObjectRef jsObject = [[JSCocoa controllerFromContext:ctx] newPrivateObject]; - JSCocoaPrivateObject* private = JSObjectGetPrivate(jsObject); - private.type = @"struct"; - private.structureName = [JSCocoaFFIArgument structureNameFromStructureTypeEncoding:[NSString stringWithUTF8String:c]]; - if (!*value) *value = jsObject; - - char* c0 = c; - // Skip '{' - c += 1; - // Skip '_' if it's there - if (*c == '_') c++; - // Skip structureName, '=' - c += [private.structureName length]+1; - - int openedBracesCount = 1; - int closedBracesCount = 0; - for (; *c && closedBracesCount != openedBracesCount; c++) - { - if (*c == '{') openedBracesCount++; - if (*c == '}') closedBracesCount++; - // Parse name then type - if (*c == '"') - { - char* c2 = c+1; - while (c2 && *c2 != '"') c2++; - id propertyName = [[[NSString alloc] initWithBytes:c+1 length:(c2-c-1) encoding:NSUTF8StringEncoding] autorelease]; - c = c2; - // Skip '"' - c++; - char encoding = *c; - - JSValueRef valueJS = NULL; - if (encoding == '{') - { - NSInteger numParsed = [self structureToJSValueRef:&valueJS inContext:ctx fromCString:c fromStorage:ptr initialValues:initialValues initialValueCount:initialValueCount convertedValueCount:convertedValueCount]; - c += numParsed; - } - else - { - // Given a pointer to raw C structure data, convert its members to JS values - if (ptr) - { - // Align - [JSCocoaFFIArgument alignPtr:ptr accordingToEncoding:encoding]; - // Get value - [JSCocoaFFIArgument toJSValueRef:&valueJS inContext:ctx typeEncoding:encoding fullTypeEncoding:nil fromStorage:*ptr]; - // Advance ptr - [JSCocoaFFIArgument advancePtr:ptr accordingToEncoding:encoding]; - } - else - // Given no pointer, get values from initialValues array. If not present, create undefined values - { - if (!convertedValueCount) return 0; - if (initialValues && initialValueCount && *convertedValueCount < initialValueCount) valueJS = initialValues[*convertedValueCount]; - else valueJS = JSValueMakeUndefined(ctx); - } - if (convertedValueCount) *convertedValueCount = *convertedValueCount+1; - } - JSStringRef propertyNameJS = JSStringCreateWithCFString((CFStringRef)propertyName); - JSObjectSetProperty(ctx, jsObject, propertyNameJS, valueJS, 0, NULL); - JSStringRelease(propertyNameJS); - } - } - return c-c0-1; -} - -+ (NSInteger)structureFromJSObjectRef:(JSObjectRef)object inContext:(JSContextRef)ctx inParentJSValueRef:(JSValueRef)parentValue fromCString:(char*)c fromStorage:(void**)ptr -{ - id structureName = [JSCocoaFFIArgument structureNameFromStructureTypeEncoding:[NSString stringWithUTF8String:c]]; - char* c0 = c; - // Skip '{' - c += 1; - // Skip '_' if it's there - if (*c == '_') c++; - // Skip structureName, '=' - c += [structureName length]+1; - -// NSLog(@"%@", structureName); - int openedBracesCount = 1; - int closedBracesCount = 0; - for (; *c && closedBracesCount != openedBracesCount; c++) - { - if (*c == '{') openedBracesCount++; - if (*c == '}') closedBracesCount++; - // Parse name then type - if (*c == '"') - { - char* c2 = c+1; - while (c2 && *c2 != '"') c2++; - id propertyName = [[[NSString alloc] initWithBytes:c+1 length:(c2-c-1) encoding:NSUTF8StringEncoding] autorelease]; - c = c2; - - // Skip '"' - c++; - char encoding = *c; - - JSStringRef propertyNameJS = JSStringCreateWithUTF8CString([propertyName UTF8String]); - JSValueRef valueJS = JSObjectGetProperty(ctx, object, propertyNameJS, NULL); - JSStringRelease(propertyNameJS); -// JSObjectRef objectProperty2 = JSValueToObject(ctx, valueJS, NULL); - -// NSLog(@"%c %@ %p %p", encoding, propertyName, valueJS, objectProperty2); - if (encoding == '{') - { - if (JSValueIsObject(ctx, valueJS)) - { - JSObjectRef objectProperty = JSValueToObject(ctx, valueJS, NULL); - NSInteger numParsed = [self structureFromJSObjectRef:objectProperty inContext:ctx inParentJSValueRef:NULL fromCString:c fromStorage:ptr]; - c += numParsed; - } - else return 0; - } - else - { - // Align - [JSCocoaFFIArgument alignPtr:ptr accordingToEncoding:encoding]; - // Get value - [JSCocoaFFIArgument fromJSValueRef:valueJS inContext:ctx typeEncoding:encoding fullTypeEncoding:nil fromStorage:*ptr]; - // Advance ptr - [JSCocoaFFIArgument advancePtr:ptr accordingToEncoding:encoding]; - } - - } - } - return c-c0-1; -} - - - -#pragma mark Encoding size, alignment, FFI - -+ (int)sizeOfTypeEncoding:(char)encoding -{ - switch (encoding) - { - case _C_ID: return sizeof(id); - case _C_CLASS: return sizeof(Class); - case _C_SEL: return sizeof(SEL); - case _C_CHR: return sizeof(char); - case _C_UCHR: return sizeof(unsigned char); - case _C_SHT: return sizeof(short); - case _C_USHT: return sizeof(unsigned short); - case _C_INT: return sizeof(int); - case _C_UINT: return sizeof(unsigned int); - case _C_LNG: return sizeof(long); - case _C_ULNG: return sizeof(unsigned long); - case _C_LNG_LNG: return sizeof(long long); - case _C_ULNG_LNG:return sizeof(unsigned long long); - case _C_FLT: return sizeof(float); - case _C_DBL: return sizeof(double); - case _C_BOOL: return sizeof(BOOL); - case _C_VOID: return sizeof(void); - case _C_PTR: return sizeof(void*); - case _C_CHARPTR: return sizeof(char*); - // Function pointers -// case _C_UNDEF: return sizeof(void*); - // Blocks are encoded with @? - } - return -1; -} - -/* - __alignOf__ returns 8 for double, but its struct align is 4 - - use dummy structures to get struct alignment, each having a byte as first element -*/ -typedef struct { char a; id b; } struct_C_ID; -typedef struct { char a; char b; } struct_C_CHR; -typedef struct { char a; short b; } struct_C_SHT; -typedef struct { char a; int b; } struct_C_INT; -typedef struct { char a; long b; } struct_C_LNG; -typedef struct { char a; long long b; } struct_C_LNG_LNG; -typedef struct { char a; float b; } struct_C_FLT; -typedef struct { char a; double b; } struct_C_DBL; -typedef struct { char a; BOOL b; } struct_C_BOOL; - -+ (int)alignmentOfTypeEncoding:(char)encoding -{ - switch (encoding) - { - case _C_ID: return offsetof(struct_C_ID, b); - case _C_CLASS: return offsetof(struct_C_ID, b); - case _C_SEL: return offsetof(struct_C_ID, b); - case _C_CHR: return offsetof(struct_C_CHR, b); - case _C_UCHR: return offsetof(struct_C_CHR, b); - case _C_SHT: return offsetof(struct_C_SHT, b); - case _C_USHT: return offsetof(struct_C_SHT, b); - case _C_INT: return offsetof(struct_C_INT, b); - case _C_UINT: return offsetof(struct_C_INT, b); - case _C_LNG: return offsetof(struct_C_LNG, b); - case _C_ULNG: return offsetof(struct_C_LNG, b); - case _C_LNG_LNG: return offsetof(struct_C_LNG_LNG, b); - case _C_ULNG_LNG:return offsetof(struct_C_LNG_LNG, b); - case _C_FLT: return offsetof(struct_C_FLT, b); - case _C_DBL: return offsetof(struct_C_DBL, b); - case _C_BOOL: return offsetof(struct_C_BOOL, b); - case _C_PTR: return offsetof(struct_C_ID, b); - case _C_CHARPTR: return offsetof(struct_C_ID, b); - } - return -1; -} - - -+ (ffi_type*)ffi_typeForTypeEncoding:(char)encoding -{ - switch (encoding) - { - case _C_ID: - case _C_CLASS: - case _C_SEL: - case _C_PTR: - case _C_CHARPTR: return &ffi_type_pointer; - - case _C_CHR: return &ffi_type_sint8; - case _C_UCHR: return &ffi_type_uint8; - case _C_SHT: return &ffi_type_sint16; - case _C_USHT: return &ffi_type_uint16; - case _C_INT: - case _C_LNG: return &ffi_type_sint32; - case _C_UINT: - case _C_ULNG: return &ffi_type_uint32; - case _C_LNG_LNG: return &ffi_type_sint64; - case _C_ULNG_LNG: return &ffi_type_uint64; - case _C_FLT: return &ffi_type_float; - case _C_DBL: return &ffi_type_double; - case _C_BOOL: return &ffi_type_sint8; - case _C_VOID: return &ffi_type_void; - } - return NULL; -} - -// -// Type encodings -// http://developer.apple.com/mac/library/documentation/cocoa/conceptual/ObjCRuntimeGuide/Articles/ocrtTypeEncodings.html -// -// Will change a bit between 32 and 64 bits (NSUInteger I->Q, CGFloat f->d) -// -static NSMutableDictionary* typeEncodings = nil; -+ (NSString*)typeEncodingForType:(NSString*)encoding -{ - if (!typeEncodings) - { - typeEncodings = [NSMutableDictionary new]; - [typeEncodings setValue:[NSString stringWithUTF8String:@encode(char)] forKey:@"char"]; - [typeEncodings setValue:[NSString stringWithUTF8String:@encode(int)] forKey:@"int"]; - [typeEncodings setValue:[NSString stringWithUTF8String:@encode(short)] forKey:@"short"]; - [typeEncodings setValue:[NSString stringWithUTF8String:@encode(long)] forKey:@"long"]; - [typeEncodings setValue:[NSString stringWithUTF8String:@encode(long long)] forKey:@"long long"]; - [typeEncodings setValue:[NSString stringWithUTF8String:@encode(unsigned char)] forKey:@"unsigned char"]; - [typeEncodings setValue:[NSString stringWithUTF8String:@encode(unsigned int)] forKey:@"unsigned int"]; - [typeEncodings setValue:[NSString stringWithUTF8String:@encode(unsigned short)] forKey:@"unsigned short"]; - [typeEncodings setValue:[NSString stringWithUTF8String:@encode(unsigned long)] forKey:@"unsigned long"]; - [typeEncodings setValue:[NSString stringWithUTF8String:@encode(unsigned long long)] forKey:@"unsigned long long"]; - [typeEncodings setValue:[NSString stringWithUTF8String:@encode(float)] forKey:@"float"]; - [typeEncodings setValue:[NSString stringWithUTF8String:@encode(double)] forKey:@"double"]; - [typeEncodings setValue:[NSString stringWithUTF8String:@encode(bool)] forKey:@"bool"]; - [typeEncodings setValue:[NSString stringWithUTF8String:@encode(void)] forKey:@"void"]; - [typeEncodings setValue:[NSString stringWithUTF8String:@encode(char*)] forKey:@"char*"]; - [typeEncodings setValue:[NSString stringWithUTF8String:@encode(id)] forKey:@"id"]; - [typeEncodings setValue:[NSString stringWithUTF8String:@encode(Class)] forKey:@"Class"]; - [typeEncodings setValue:[NSString stringWithUTF8String:@encode(SEL)] forKey:@"selector"]; - [typeEncodings setValue:[NSString stringWithUTF8String:@encode(BOOL)] forKey:@"BOOL"]; - [typeEncodings setValue:[NSString stringWithUTF8String:@encode(void*)] forKey:@"void*"]; - - [typeEncodings setValue:[NSString stringWithUTF8String:@encode(NSInteger)] forKey:@"NSInteger"]; - [typeEncodings setValue:[NSString stringWithUTF8String:@encode(NSUInteger)] forKey:@"NSUInteger"]; - [typeEncodings setValue:[NSString stringWithUTF8String:@encode(CGFloat)] forKey:@"CGFloat"]; - } - return [typeEncodings valueForKey:encoding]; -} - - -#pragma mark Structure encoding, size - -/* - From - {_NSRect={_NSPoint=ff}{_NSSize=ff}} - - Return - {_NSRect="origin"{_NSPoint="x"f"y"f}"size"{_NSSize="width"f"height"f}} -*/ -+ (NSString*)structureNameFromStructureTypeEncoding:(NSString*)encoding -{ - // Extract structure name - // skip '{' - char* c = (char*)[encoding UTF8String]+1; - // skip '_' if it's there - if (*c == '_') c++; - char* c2 = c; - while (*c2 && *c2 != '=') c2++; - return [[[NSString alloc] initWithBytes:c length:(c2-c) encoding:NSUTF8StringEncoding] autorelease]; -} - -+ (NSMutableArray*)encodingsFromStructureTypeEncoding:(NSString*)encoding -{ - return nil; -} - -+ (NSString*)structureFullTypeEncodingFromStructureTypeEncoding:(NSString*)encoding -{ - id structureName = [JSCocoaFFIArgument structureNameFromStructureTypeEncoding:encoding]; - return [self structureFullTypeEncodingFromStructureName:structureName]; -} - -+ (NSString*)structureFullTypeEncodingFromStructureName:(NSString*)structureName -{ - // Fetch structure type encoding from BridgeSupport -// id xml = [[BridgeSupportController sharedController] query:structureName withType:@"struct"]; - id xml = [[BridgeSupportController sharedController] queryName:structureName type:@"struct"]; - - if (xml == nil) - { - NSLog(@"No structure encoding found for %@", structureName); - return nil; - } - id xmlDocument = [[NSXMLDocument alloc] initWithXMLString:xml options:0 error:nil]; - if (!xmlDocument) return NO; - id rootElement = [xmlDocument rootElement]; -#if __LP64__ - id type = [[rootElement attributeForName:@"type64"] stringValue]; -#else - id type = [[rootElement attributeForName:@"type"] stringValue]; -#endif - // Retain the string as releasing xmlDocument deallocs it - [[type retain] autorelease]; - - [xmlDocument release]; - return type; -} - - -+ (NSArray*)typeEncodingsFromStructureTypeEncoding:(NSString*)structureTypeEncoding -{ - return [self typeEncodingsFromStructureTypeEncoding:structureTypeEncoding parsedCount:nil]; -} - - -+ (NSArray*)typeEncodingsFromStructureTypeEncoding:(NSString*)structureTypeEncoding parsedCount:(NSInteger*)count -{ - id types = [[[NSMutableArray alloc] init] autorelease]; - char* c = (char*)[structureTypeEncoding UTF8String]; - char* c0 = c; - int openedBracesCount = 0; - int closedBracesCount = 0; - for (;*c; c++) - { - if (*c == '{') - { - openedBracesCount++; - while (*c && *c != '=') c++; - if (!*c) continue; - } - if (*c == '}') - { - closedBracesCount++; - - // If we parsed something (c>c0) and have an equal amount of opened and closed braces, we're done - if (c0 != c && openedBracesCount == closedBracesCount) - { - c++; - break; - } - continue; - } - if (*c == '=') continue; - - [types addObject:[NSString stringWithFormat:@"%c", *c]]; - - // Special case for pointers - if (*c == '^') - { - // Skip pointers to pointers (^^^) - while (*c && *c == '^') c++; - - // Skip type, special case for structure - if (*c == '{') - { - int openedBracesCount2 = 1; - int closedBracesCount2 = 0; - c++; - for (; *c && closedBracesCount2 != openedBracesCount2; c++) - { - if (*c == '{') openedBracesCount2++; - if (*c == '}') closedBracesCount2++; - } - c--; - } - else c++; - } - } - if (count) *count = c-c0; - if (closedBracesCount != openedBracesCount) return NSLog(@"Could not parse structure type encodings for %@", structureTypeEncoding), nil; - return types; -} - -// -// Given a structure encoding string, produce a human readable format -// -+ (NSInteger)structureTypeEncodingDescription:(NSString*)structureTypeEncoding inString:(NSMutableString**)str -{ - char* c = (char*)[structureTypeEncoding UTF8String]; - char* c0 = c; - // Skip '{' - c += 1; - // Skip '_' if it's there - if (*c == '_') c++; - // Skip structureName, '=' -// c += [private.structureName length]+1; - id structureName = [self structureNameFromStructureTypeEncoding:structureTypeEncoding]; - c += [structureName length]+1; - - int openedBracesCount = 1; - int closedBracesCount = 0; - int propertyCount = 0; - for (; *c && closedBracesCount != openedBracesCount; c++) - { - if (*c == '{') - { - [*str appendString:@"{"]; - openedBracesCount++; - } - if (*c == '}') - { - [*str appendString:@"}"]; - closedBracesCount++; - } - // Parse name then type - if (*c == '"') - { - propertyCount++; - if (propertyCount > 1) [*str appendString:@", "]; - char* c2 = c+1; - while (c2 && *c2 != '"') c2++; - id propertyName = [[[NSString alloc] initWithBytes:c+1 length:(c2-c-1) encoding:NSUTF8StringEncoding] autorelease]; - c = c2; - // Skip '"' - c++; - char encoding = *c; - [*str appendString:propertyName]; - [*str appendString:@": "]; - -// JSValueRef valueJS = NULL; - if (encoding == '{') - { - [*str appendString:@"{"]; - NSInteger parsed = [self structureTypeEncodingDescription:[NSString stringWithUTF8String:c] inString:str]; - c += parsed; -// NSLog(@"parsed %@ (%d)", substr, [substr length]); - } - else - { - [*str appendString:@"("]; - [*str appendString:[self typeDescriptionForTypeEncoding:encoding fullTypeEncoding:nil]]; - [*str appendString:@")"]; - } - } - } - return c-c0-1; -} -+ (NSString*)structureTypeEncodingDescription:(NSString*)structureTypeEncoding -{ - id fullStructureTypeEncoding = [self structureFullTypeEncodingFromStructureTypeEncoding:structureTypeEncoding]; - if (!fullStructureTypeEncoding) return [NSString stringWithFormat:@"(Could not describe struct %@)", structureTypeEncoding]; - - id str = [NSMutableString stringWithFormat:@"%@{", [self structureNameFromStructureTypeEncoding:fullStructureTypeEncoding]]; - [self structureTypeEncodingDescription:fullStructureTypeEncoding inString:&str]; - [str appendString:@"}"]; - return str; -} - - -+ (int)sizeOfStructure:(NSString*)encoding -{ - id types = [self typeEncodingsFromStructureTypeEncoding:encoding]; - int computedSize = 0; - void** ptr = (void**)&computedSize; - for (id type in types) - { - char charEncoding = *(char*)[type UTF8String]; - // Align - [JSCocoaFFIArgument alignPtr:ptr accordingToEncoding:charEncoding]; - // Advance ptr - [JSCocoaFFIArgument advancePtr:ptr accordingToEncoding:charEncoding]; - } - return computedSize; -} - - -#pragma mark Object boxing / unboxing - -// -// Box -// -+ (BOOL)boxObject:(id)objcObject toJSValueRef:(JSValueRef*)value inContext:(JSContextRef)ctx { - // Return null if our pointer is null - if (!objcObject) { - *value = JSValueMakeNull(ctx); - return YES; - } - // Use a global boxing function to always return the same Javascript object - // when requesting multiple boxings of the same ObjC object - *value = [[JSCocoa controllerFromContext:ctx] boxObject:objcObject]; - return YES; -} - -// -// Unbox -// -+ (BOOL)unboxJSValueRef:(JSValueRef)value toObject:(id*)o inContext:(JSContextRef)ctx -{ - // - // Boxing - // - // string -> NSString - // null -> nil (no box) - // number -> NSNumber - // [] -> NSMutableArray - // {} -> NSMutableDictionary - // - - // null - if (!value || JSValueIsNull(ctx, value) || JSValueIsUndefined(ctx, value)) - { - *(id*)o = nil; - return YES; - } - - - // string - if (JSValueIsString(ctx, value)) - { - JSStringRef resultStringJS = JSValueToStringCopy(ctx, value, NULL); - NSString* resultString = (NSString*)JSStringCopyCFString(kCFAllocatorDefault, resultStringJS); -// NSLog(@"unboxed=%@", resultString); - JSStringRelease(resultStringJS); - [NSMakeCollectable(resultString) autorelease]; - *(id*)o = resultString; - return YES; - } - - - // number - if (JSValueIsNumber(ctx, value)) - { - double v = JSValueToNumber(ctx, value, NULL); - // Integer - if (fabs(round(v)-v) < 1e-6) - { - if (v < 0) - { - *(id*)o = [NSNumber numberWithInt:(int)v]; -// NSLog(@"int %d", (int)v); - } - else - { - *(id*)o = [NSNumber numberWithUnsignedInt:(unsigned int)v]; -// NSLog(@"UNSIGNED int %d", (unsigned int)v); - } - } - // Double - else - { - *(id*)o = [NSNumber numberWithDouble:v]; -// NSLog(@"double %f", v); - } - return YES; - } - - // bool - if (JSValueIsBoolean(ctx, value)) - { - bool v = JSValueToBoolean(ctx, value); - if (v) *(id*)o = [NSNumber numberWithBool:YES]; - else *(id*)o = nil; - return YES; - } - - // From here we must have a Javascript object (Array, Hash) or a boxed Cocoa object - if (!JSValueIsObject(ctx, value)) - return NO; - - JSObjectRef jsObject = JSValueToObject(ctx, value, NULL); - JSCocoaPrivateObject* private = JSObjectGetPrivate(jsObject); - // Pure js hashes and arrays are converted to NSArray and NSDictionary - if (!private) - { - // Use an anonymous function to test if object is Array or Object (hash) - // (can't use this.constructor==Array.prototype.constructor with JSEvaluateScript it doesn't take thisObject into account) - JSStringRef scriptJS = JSStringCreateWithUTF8CString("return arguments[0].constructor == Array.prototype.constructor"); - JSObjectRef fn = JSObjectMakeFunction(ctx, NULL, 0, NULL, scriptJS, NULL, 1, NULL); - JSValueRef result = JSObjectCallAsFunction(ctx, fn, NULL, 1, (JSValueRef*)&jsObject, NULL); - JSStringRelease(scriptJS); - - BOOL isArray = JSValueToBoolean(ctx, result); - - if (isArray) return [self unboxJSArray:jsObject toObject:o inContext:ctx]; - else return [self unboxJSHash:jsObject toObject:o inContext:ctx]; - } - // ## Hmmm ? CGColorRef is returned as a pointer but CALayer.foregroundColor asks an objc object (@) -/* - if ([private.type isEqualToString:@"rawPointer"]) *(id*)o = [private rawPointer]; - else *(id*)o = [private object]; -*/ - - id obj = [private object]; - - if ([private.type isEqualToString:@"rawPointer"]) *(id*)o = [private rawPointer]; - else if (obj) *(id*)o = obj; - else if ([private.type isEqualToString:@"externalJSValueRef"]) - { - // Convert external jsValues by calling valueOf - JSValueRef v = valueOfCallback(ctx, NULL, JSValueToObject(ctx, value, NULL), 0, NULL, NULL); - return [self unboxJSValueRef:v toObject:o inContext:ctx]; - } - else - { -// NSLog(@"********* %@", private.type); - *(id*)o = nil; - } - - return YES; -} - -// -// Convert ['a', 'b', 1.23] to an NSArray -// -+ (BOOL)unboxJSArray:(JSObjectRef)object toObject:(id*)o inContext:(JSContextRef)ctx -{ - // Get property count - JSValueRef exception = NULL; - JSStringRef lengthJS = JSStringCreateWithUTF8CString("length"); - NSUInteger length = JSValueToNumber(ctx, JSObjectGetProperty(ctx, object, lengthJS, NULL), &exception); - JSStringRelease(lengthJS); - if (exception) return NO; - - // Converted array - id array = [NSMutableArray array]; - // Converted array property - id value; - int i; - // Loop over all properties of the array and call our trusty unboxer. - // He might reenter that function to convert arrays inside that array. - for (i=0; i -#import -#define MACOSX -#import -#endif -#import "JSCocoaFFIArgument.h" - -#if TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE -#import "iPhone/libffi/ffi.h" -#endif - - -@interface JSCocoaFFIClosure : NSObject { - - JSValueRef jsFunction; - // ##UNSURE This might cause a crash if we're registered in a non global context that will have been destroyed when we JSValueUnprotect the function - JSContextRef ctx; - - ffi_cif cif; -#if !TARGET_OS_IPHONE - ffi_closure* closure; -#endif - ffi_type** argTypes; - - NSMutableArray* encodings; - - JSObjectRef jsThisObject; - - BOOL isObjC; -} - -- (IMP)setJSFunction:(JSValueRef)fn inContext:(JSContextRef)ctx argumentEncodings:(NSMutableArray*)argumentEncodings objC:(BOOL)objC; -- (void*)functionPointer; -- (void)calledByClosureWithArgs:(void**)args returnValue:(void*)returnValue; - -@end diff --git a/Atom/JSCocoa/JSCocoaFFIClosure.m b/Atom/JSCocoa/JSCocoaFFIClosure.m deleted file mode 100644 index c0362bec6..000000000 --- a/Atom/JSCocoa/JSCocoaFFIClosure.m +++ /dev/null @@ -1,215 +0,0 @@ -// -// JSCocoaFFIClosure.m -// JSCocoa -// -// Created by Patrick Geiller on 29/07/08. -// Copyright 2008 __MyCompanyName__. All rights reserved. -// - -#import "JSCocoaFFIClosure.h" -#import "JSCocoaController.h" -#include // for mmap() - -void closure_function(ffi_cif* cif, void* resp, void** args, void* userdata); - -@implementation JSCocoaFFIClosure - - -// -// Common closure function, calling back closure object -// -void closure_function(ffi_cif* cif, void* resp, void** args, void* userdata) -{ - [(id)userdata calledByClosureWithArgs:args returnValue:resp]; -} - -- (id)init -{ - self = [super init]; - - argTypes = NULL; - encodings = NULL; - jsFunction = NULL; - - return self; -} - -// -// Cleanup : called by dealloc and finalize -// -- (void)cleanUp -{ - if (encodings) [encodings release]; - if (argTypes) free(argTypes); - - if (jsFunction) - { - JSValueUnprotect(ctx, jsFunction); - [JSCocoaController downJSValueProtectCount]; - } -#if !TARGET_OS_IPHONE - if (munmap(closure, sizeof(closure)) == -1) NSLog(@"ffi closure munmap failed"); -#endif -} -- (void)dealloc -{ -// NSLog(@"deallocing closure %p IMP=%p", self, closure); - [self cleanUp]; - [super dealloc]; -} -- (void)finalize -{ - [self cleanUp]; - [super finalize]; -} - -- (void*)functionPointer -{ -#if !TARGET_OS_IPHONE - return closure; -#else - return NULL; -#endif -} - - - -// -// Bind a js function to closure. We'll jsValueProtect that function from GC. -// -- (IMP)setJSFunction:(JSValueRef)fn inContext:(JSContextRef)context argumentEncodings:(NSMutableArray*)argumentEncodings objC:(BOOL)objC -{ -#if !TARGET_OS_IPHONE - if ([argumentEncodings count] == 0) return NULL; - - encodings = argumentEncodings; - [encodings retain]; - isObjC = objC; - - unsigned int i, argumentCount = (unsigned int)([argumentEncodings count]-1); - argTypes = malloc(sizeof(ffi_type*)*argumentCount); - for (i=0; i 0 && size < paddedSize && paddedSize == 4) - { - v = *(long*)returnValue; - v = CFSwapInt32(v); - *(long*)returnValue = v; - } -#endif - } - - if (effectiveArgumentCount) free(args); - if (exception) - { - @throw [NSException exceptionWithName:@"JSCocoa exception" - reason:[[JSCocoaController controllerFromContext:ctx] formatJSException:exception] - userInfo:nil]; - } -} - - - -@end diff --git a/Atom/JSCocoa/JSCocoaLib.h b/Atom/JSCocoa/JSCocoaLib.h deleted file mode 100644 index e5c0b3082..000000000 --- a/Atom/JSCocoa/JSCocoaLib.h +++ /dev/null @@ -1,98 +0,0 @@ -// -// JSCocoaLib.h -// JSCocoa -// -// Created by Patrick Geiller on 21/12/08. -// Copyright 2008 __MyCompanyName__. All rights reserved. -// - -#if !TARGET_IPHONE_SIMULATOR && !TARGET_OS_IPHONE -#import -#endif -#import "JSCocoa.h" - -@class JSCocoaMemoryBuffer; - -@interface JSCocoaOutArgument : NSObject -{ - JSCocoaFFIArgument* arg; - JSCocoaMemoryBuffer* buffer; - int bufferIndex; -} -- (BOOL)mateWithJSCocoaFFIArgument:(JSCocoaFFIArgument*)arg; -- (JSValueRef)outJSValueRefInContext:(JSContextRef)ctx; - -@end - - - -@interface JSCocoaMemoryBuffer : NSObject -{ - void* buffer; - int bufferSize; - // NSString holding types - id typeString; - - // Indicates whether types are aligned. - // types not aligned (DEFAULT) - // size('fcf') = 4 + 1 + 4 = 9 - // types aligned - // size('fcf') = 4 + 4(align) + 4 = 12 - BOOL alignTypes; -} -+ (id)bufferWithTypes:(id)types; -- (id)initWithTypes:(id)types; -//- (id)initWithTypes:(id)types andValues:(id)values; -//- (id)initWithMemoryBuffers:(id)buffers; - -- (void*)pointerForIndex:(NSUInteger)index; -- (char)typeAtIndex:(NSUInteger)index; -- (JSValueRef)valueAtIndex:(NSUInteger)index inContext:(JSContextRef)ctx; -- (BOOL)setValue:(JSValueRef)jsValue atIndex:(NSUInteger)index inContext:(JSContextRef)ctx; -- (NSUInteger)typeCount; - -@end - - -@interface JSCocoaLib : NSObject - -+ (id)rootclasses; -+ (id)classes; -+ (id)protocols; -+ (id)imageNames; -+ (id)methods; -+ (id)runtimeReport; - -@end - - - -@interface NSObject(ClassWalker) -+ (id)__classImage; -- (id)__classImage; -+ (id)__derivationPath; -- (id)__derivationPath; -+ (NSUInteger)__derivationLevel; -- (NSUInteger)__derivationLevel; -+ (id)__ownMethods; -- (id)__ownMethods; -+ (id)__methods; -- (id)__methods; -+ (id)__subclasses; -- (id)__subclasses; -+ (id)__subclassTree; -- (id)__subclassTree; -+ (id)__ownIvars; -- (id)__ownIvars; -+ (id)__ivars; -- (id)__ivars; -+ (id)__ownProperties; -- (id)__ownProperties; -+ (id)__properties; -- (id)__properties; -+ (id)__ownProtocols; -- (id)__ownProtocols; -+ (id)__protocols; -- (id)__protocols; - -@end diff --git a/Atom/JSCocoa/JSCocoaLib.m b/Atom/JSCocoa/JSCocoaLib.m deleted file mode 100644 index 2af615ea9..000000000 --- a/Atom/JSCocoa/JSCocoaLib.m +++ /dev/null @@ -1,830 +0,0 @@ -// -// JSCocoaLib.m -// JSCocoa -// -// Created by Patrick Geiller on 21/12/08. -// Copyright 2008 __MyCompanyName__. All rights reserved. -// - -#import "JSCocoaLib.h" - - -// -// Handles out arguments of functions and methods. -// eg NSOpenGLGetVersion(int*, int*) asks for two pointers to int. -// JSCocoaOutArgument will alloc the memory through JSCocoaFFIArgument and get the result back to Javascript (check out value in JSCocoaController) -// -@implementation JSCocoaOutArgument - -- (id)init -{ - self = [super init]; - - arg = nil; - buffer = nil; - return self; -} -- (void)cleanUp -{ - [arg release]; - [buffer release]; -} -- (void)dealloc -{ - [self cleanUp]; - [super dealloc]; -} -- (void)finalize -{ - [self cleanUp]; - [super finalize]; -} - - -// -// convert the out value to a JSValue -// -- (JSValueRef)outJSValueRefInContext:(JSContextRef)ctx -{ - JSValueRef jsValue = NULL; - [arg toJSValueRef:&jsValue inContext:ctx]; - return jsValue; -} - -// Called from Javascript to extract the resulting value as an object (valueOfCallback returns a string) -- (JSValueRefAndContextRef)outValue -{ - JSValueRefAndContextRef r; - - id jsc = nil; - object_getInstanceVariable(self, "__jsCocoaController", (void**)&jsc); - if (!jsc) return r; - - r.ctx = [jsc ctx]; - r.value = [self outJSValueRefInContext:r.ctx]; - - return r; -} - - - -// -// JSCocoaOutArgument holds a JSCocoaFFIArgument around. -// it stays alive after ffi_call and can be queried by Javascript for type modifier values. -// -- (BOOL)mateWithJSCocoaFFIArgument:(JSCocoaFFIArgument*)_arg -{ - // If holding a memory buffer, use its pointer - if (buffer) - { - arg = _arg; - [arg retain]; - void* ptr = [buffer pointerForIndex:bufferIndex]; - if (!ptr) return NO; - [arg setTypeEncoding:[arg typeEncoding] withCustomStorage:ptr]; - return YES; - } - - // Standard pointer - void* p = [_arg allocatePointerStorage]; - if (!p) return NO; - - // Zero out storage - *(void**)p = NULL; - - - arg = _arg; - [arg retain]; - return YES; -} - -- (BOOL)mateWithMemoryBuffer:(id)b atIndex:(int)idx -{ - if (!b || ![b isKindOfClass:[JSCocoaMemoryBuffer class]]) return NSLog(@"mateWithMemoryBuffer called without a memory buffer (%@)", b), NO; - buffer = b; - [buffer retain]; - bufferIndex = idx; - return YES; -} - -@end - - - -// -// Instead of malloc(sizeof(float)*4), JSCocoaMemoryBuffer expects 'ffff' as an init string. -// The buffer can be manipulated like an array (buffer[2] = 0.5) -// * it can be filled, calling methods to copy data in it -// - (NSBezierPathElement)elementAtIndex:(NSInteger)index associatedPoints:(NSPointArray)points; -// * it can be used as data source, calling methods to copy data from it -// - (void)setAssociatedPoints:(NSPointArray)points atIndex:(NSInteger)index; -// -@implementation JSCocoaMemoryBuffer - -+ (id)bufferWithTypes:(id)types -{ - return [[[JSCocoaMemoryBuffer alloc] initWithTypes:types] autorelease]; -} - - -- (id)initWithTypes:(id)_types -{ - self = [super init]; - buffer = NULL; - - // Copy types string - typeString = [NSString stringWithString:_types]; - [typeString retain]; - - // Compute buffer size - const char* types = [typeString UTF8String]; - NSUInteger l = [typeString length]; - bufferSize = 0; - for (int i=0; i= [typeString length]) return NULL; - void* pointedValue = buffer; - for (int i=0; i= [typeString length]) return '\0'; - return [typeString UTF8String][idx]; -} - -- (NSUInteger)typeCount -{ - return [typeString length]; -} - --(BOOL)referenceObject:(id)o usingPointerAtIndex:(NSUInteger)idx -{ - if ([self typeAtIndex:idx] != '^') return NO; - - void* v = *(void**)[self pointerForIndex:idx]; - if (!v) return NO; - *(id*)v = o; - return YES; -} - -- (id)dereferenceObjectAtIndex:(NSUInteger)idx -{ - if ([self typeAtIndex:idx] != '^') return nil; - void* v = *(void**)[self pointerForIndex:idx]; - if (!v) return NULL; - - id o = *(id*)v; - return o; - return *(id*)v; -} - -// -// Using JSValueRefAndContextRef as input to get the current context in which to create the return value -// -- (JSValueRef)valueAtIndex:(NSUInteger)idx inContext:(JSContextRef)ctx -{ - char typeEncoding = [self typeAtIndex:idx]; - void* pointedValue = [self pointerForIndex:idx]; - if (!pointedValue) return JSValueMakeUndefined(ctx); - JSValueRef returnValue; - [JSCocoaFFIArgument toJSValueRef:&returnValue inContext:ctx typeEncoding:typeEncoding fullTypeEncoding:nil fromStorage:pointedValue]; - return returnValue; -} - -- (BOOL)setValue:(JSValueRef)jsValue atIndex:(NSUInteger)idx inContext:(JSContextRef)ctx -{ - char typeEncoding = [self typeAtIndex:idx]; - void* pointedValue = [self pointerForIndex:idx]; - if (!pointedValue) return NO; - [JSCocoaFFIArgument fromJSValueRef:jsValue inContext:ctx typeEncoding:typeEncoding fullTypeEncoding:nil fromStorage:pointedValue]; - return YES; -} - - -@end - - - -@implementation JSCocoaLib - -// -// Class list -// Some classes are skipped as adding them to an array crashes (Zombie, classes derived from Object or NSProxy) -// -+ (NSArray*)classes -{ - int classCount = objc_getClassList(nil, 0); - Class* classList = malloc(sizeof(Class)*classCount); - objc_getClassList(classList, classCount); - - - NSMutableArray* classArray = [NSMutableArray array]; - for (int i=0; i -#import -#endif - -#import -#import -//#import -#import -#import - -// -// Boxing object -// -// type -// @ ObjC object -// struct C struct -// method ObjC method name -// function C function -// rawPointer raw C pointer (_C_PTR) -// jsFunction Javascript function -// jsValueRef raw jsvalue -// externalJSValueRef jsvalue coming from an external context (eg, a WebView) -// - -@interface JSCocoaPrivateObject : NSObject { - - NSString* type; - NSString* xml; - NSString* methodName; - NSString* structureName; - - NSString* declaredType; - void* rawPointer; - - id object; - - Method method; - - JSValueRef jsValue; - JSContextRef ctx; - unsigned int externalJSValueIndex; - // (test) when storing JSValues from a WebView, used to retain the WebView's context. - // Disabled for now. Just make sure the WebView has a longer life than the vars it uses. - // - // Disabled because retaining the context crashes in 32 bits, but works in 64 bit. - // May be reenabled someday. -// JSContextGroupRef contextGroup; - - BOOL isAutoCall; - BOOL retainObject; - // Disabled because of a crash on i386. Release globalContext last. -// BOOL retainContext; -} - -@property (copy) NSString* type; -@property (copy) NSString* xml; -@property (copy) NSString* methodName; -@property (copy) NSString* structureName; -@property (copy) NSString* declaredType; -@property BOOL isAutoCall; - -//- (void)setPtr:(void*)ptrValue; -//- (void*)ptr; - -- (void)setObject:(id)o; -- (void)setObjectNoRetain:(id)o; -- (BOOL)retainObject; -- (id)object; - -- (void)setMethod:(Method)m; -- (Method)method; - -- (void)setJSValueRef:(JSValueRef)v ctx:(JSContextRef)ctx; -- (JSValueRef)jsValueRef; -- (void)setCtx:(JSContextRef)ctx; -- (JSContextRef)ctx; -- (void)setExternalJSValueRef:(JSValueRef)v ctx:(JSContextRef)ctx; - -- (void*)rawPointer; -- (void)setRawPointer:(void*)rp encoding:(id)encoding; -- (id)rawPointerEncoding; - -@end diff --git a/Atom/JSCocoa/JSCocoaPrivateObject.m b/Atom/JSCocoa/JSCocoaPrivateObject.m deleted file mode 100644 index 7f4611b08..000000000 --- a/Atom/JSCocoa/JSCocoaPrivateObject.m +++ /dev/null @@ -1,236 +0,0 @@ -// -// JSCocoaPrivateObject.m -// JSCocoa -// -// Created by Patrick Geiller on 09/07/08. -// Copyright 2008 __MyCompanyName__. All rights reserved. -// - -#import "JSCocoaPrivateObject.h" -#import "JSCocoaController.h" - -@implementation JSCocoaPrivateObject - -@synthesize type, xml, declaredType, methodName, structureName, isAutoCall; - - -- (id)init -{ - self = [super init]; - type = xml = declaredType = methodName = nil; - object = nil; - isAutoCall = NO; - jsValue = NULL; - retainObject= YES; - rawPointer = NULL; - ctx = NULL; -// retainContext = NO; - externalJSValueIndex = 0; - - - [JSCocoaController upJSCocoaPrivateObjectCount]; - return self; -} - -- (void)cleanUp -{ - [JSCocoaController downJSCocoaPrivateObjectCount]; - if (object && retainObject) - { -// NSLog(@"commented downBoxedJSObjectCount"); -// [JSCocoaController downBoxedJSObjectCount:object]; -// NSLog(@"releasing %@(%d)", [object class], [object retainCount]); -// if ([object isKindOfClass:[JSCocoaController class]]) -// [object autorelease]; -// else - [object release]; - } - if (jsValue) - { - if (!externalJSValueIndex) JSValueUnprotect(ctx, jsValue); - [JSCocoaController downJSValueProtectCount]; - - // If holding a value from an external context, remove it from the GC-safe hash and release context. - if (externalJSValueIndex) - { - JSStringRef scriptJS = JSStringCreateWithUTF8CString("delete __gcprotect[arguments[0]]"); - JSObjectRef fn = JSObjectMakeFunction(ctx, NULL, 0, NULL, scriptJS, NULL, 1, NULL); - JSStringRelease(scriptJS); - JSValueRef jsNumber = JSValueMakeNumber(ctx, externalJSValueIndex); - JSValueRef exception = NULL; - JSObjectCallAsFunction(ctx, fn, NULL, 1, (JSValueRef*)&jsNumber, &exception); -// JSGlobalContextRelease((JSGlobalContextRef)ctx); - - if (exception) - NSLog(@"Got an exception while trying to release externalJSValueRef %p of context %p", jsValue, ctx); - } - } -/* - if (retainContext) - { - NSLog(@"releasing %p", ctx); - JSContextGroupRelease(contextGroup); -// JSGlobalContextRelease((JSGlobalContextRef)ctx); - } -*/ - // Release properties - [type release]; - [xml release]; - [methodName release]; - [structureName release]; - [declaredType release]; -} - -- (void)dealloc -{ - [self cleanUp]; - [super dealloc]; -} -- (void)finalize -{ - [self cleanUp]; - [super finalize]; -} - -- (void)setObject:(id)o -{ -// if (object && retainObject) -// [object release]; - object = o; - if (object && [object retainCount] == -1) return; - [object retain]; -} - -- (void)setObjectNoRetain:(id)o -{ - object = o; - retainObject = NO; -} - -- (BOOL)retainObject -{ - return retainObject; -} - -- (id)object -{ - return object; -} - -- (void)setMethod:(Method)m -{ - method = m; -} -- (Method)method -{ - return method; -} - -- (void)setJSValueRef:(JSValueRef)v ctx:(JSContextRef)c -{ - // While autocalling we'll get a NULL value when boxing a void return type - just skip JSValueProtect - if (!v) - { -// NSLog(@"setJSValueRef: NULL value"); - jsValue = 0; - return; - } - jsValue = v; -// ctx = c; - // Register global context (this would crash the launcher as JSValueUnprotect was called on a destroyed context) - ctx = [[JSCocoaController controllerFromContext:c] ctx]; - JSValueProtect(ctx, jsValue); - [JSCocoaController upJSValueProtectCount]; -} -- (JSValueRef)jsValueRef -{ - return jsValue; -} - -- (void)setCtx:(JSContextRef)_ctx { - ctx = _ctx; -} -- (JSContextRef)ctx -{ - return ctx; -} - - -- (void)setExternalJSValueRef:(JSValueRef)v ctx:(JSContextRef)c -{ - if (!v) - { - jsValue = 0; - return; - } - jsValue = v; - ctx = c; - - // Register value in a global hash to protect it from GC. This sucks but JSValueProtect() fails. - JSStringRef scriptJS = JSStringCreateWithUTF8CString("if (!('__gcprotect' in this)) { __gcprotect = {}; __gcprotectidx = 1; } __gcprotect[__gcprotectidx] = arguments[0]; return __gcprotectidx++ "); - JSObjectRef fn = JSObjectMakeFunction(ctx, NULL, 0, NULL, scriptJS, NULL, 1, NULL); - JSStringRelease(scriptJS); - - JSValueRef exception = NULL; - JSValueRef result = JSObjectCallAsFunction(ctx, fn, NULL, 1, (JSValueRef*)&jsValue, &exception); - if (exception) return; - - // Use hash index as key, will be used to remove value from hash upon deletion. - externalJSValueIndex = (unsigned int)JSValueToNumber(ctx, result, &exception); - if (exception) return; - -// JSGlobalContextRetain((JSGlobalContextRef)ctx); - [JSCocoaController upJSValueProtectCount]; -} - - -- (void*)rawPointer -{ - return rawPointer; -} -- (void)setRawPointer:(void*)rp encoding:(id)encoding -{ - rawPointer = rp; -// NSLog(@"RAWPOINTER=%@", encoding); - declaredType = encoding; - [declaredType retain]; -} - -- (id)rawPointerEncoding -{ - return declaredType; -} - - -- (id)description { - id extra = @""; - if ([type isEqualToString:@"rawPointer"]) - extra = [NSString stringWithFormat:@" rawPointer=%p declaredType=%@", rawPointer, declaredType]; - return [NSString stringWithFormat:@"<%@: %p holding %@%@>", - [self class], - self, - type, - extra - ]; -} - -+ (id)description { - return @""; -} - -- (id)dereferencedObject { - if (![type isEqualToString:@"rawPointer"] || !rawPointer) - return nil; - return *(void**)rawPointer; -} - -- (BOOL)referenceObject:(id)o { - if (![type isEqualToString:@"rawPointer"]) - return NO; - *(id*)rawPointer = o; - return YES; -} - - -@end - diff --git a/Atom/MainMenu.xib b/Atom/MainMenu.xib new file mode 100755 index 000000000..56eb0e2d2 --- /dev/null +++ b/Atom/MainMenu.xib @@ -0,0 +1,289 @@ + + + + 1050 + 11C74 + 1938 + 1138.23 + 567.00 + + com.apple.InterfaceBuilder.CocoaPlugin + 1938 + + + YES + NSUserDefaultsController + NSMenu + NSMenuItem + NSCustomObject + + + YES + com.apple.InterfaceBuilder.CocoaPlugin + + + PluginDependencyRecalculationVersion + + + + YES + + ClientApplication + + + FirstResponder + + + Atom + + + AMainMenu + + YES + + + Atom + + 1048576 + 2147483647 + + NSImage + NSMenuCheckmark + + + NSImage + NSMenuMixedState + + submenuAction: + + Atom + + YES + + + Run Specs + s + 1835008 + 2147483647 + + + + + + Quit + q + 1048576 + 2147483647 + + + + + _NSAppleMenu + + + + _NSMainMenu + + + YES + + + + + YES + + + delegate + + + + 440 + + + + stop: + + + + 447 + + + + runSpecs: + + + + 449 + + + + + YES + + 0 + + YES + + + + + + -2 + + + File's Owner + + + -1 + + + First Responder + + + -3 + + + Application + + + 29 + + + YES + + + + MainMenu + + + 56 + + + YES + + + + + + 57 + + + YES + + + + + + + 58 + + + + + 389 + + + + + 441 + + + + + + + YES + + YES + -1.IBPluginDependency + -2.IBPluginDependency + -3.IBPluginDependency + 29.IBPluginDependency + 389.IBPluginDependency + 441.IBPluginDependency + 56.IBPluginDependency + 57.IBPluginDependency + 58.IBPluginDependency + + + YES + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + + + YES + + + + + + YES + + + + + 449 + + + + YES + + Atom + NSApplication + + runSpecs: + id + + + runSpecs: + + runSpecs: + id + + + + IBProjectSource + ./Classes/Atom.h + + + + + 0 + IBCocoaFramework + + com.apple.InterfaceBuilder.CocoaPlugin.macosx + + + + com.apple.InterfaceBuilder.CocoaPlugin.macosx + + + + com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3 + + + YES + 3 + + YES + + YES + NSMenuCheckmark + NSMenuMixedState + + + YES + {9, 8} + {7, 2} + + + + diff --git a/Atom/UKKQueue/UKFNSubscribeFileWatcher.h b/Atom/UKKQueue/UKFNSubscribeFileWatcher.h deleted file mode 100644 index 259cb8378..000000000 --- a/Atom/UKKQueue/UKFNSubscribeFileWatcher.h +++ /dev/null @@ -1,49 +0,0 @@ -/* ============================================================================= - FILE: UKFNSubscribeFileWatcher.m - PROJECT: Filie - - COPYRIGHT: (c) 2005 M. Uli Kusterer, all rights reserved. - - AUTHORS: M. Uli Kusterer - UK - - LICENSES: MIT License - - REVISIONS: - 2006-03-13 UK Commented, added singleton. - 2005-03-02 UK Created. - ========================================================================== */ - -// ----------------------------------------------------------------------------- -// Headers: -// ----------------------------------------------------------------------------- - -#import -#import "UKFileWatcher.h" -#import - -/* - NOTE: FNSubscribe has a built-in delay: If your application is in the - background while the changes happen, all notifications will be queued up - and sent to your app at once the moment it is brought to front again. If - your app really needs to do live updates in the background, use a KQueue - instead. -*/ - -// ----------------------------------------------------------------------------- -// Class declaration: -// ----------------------------------------------------------------------------- - -@interface UKFNSubscribeFileWatcher : NSObject -{ - id delegate; // Delegate must respond to UKFileWatcherDelegate protocol. - NSMutableDictionary* subscriptions; // List of FNSubscription pointers in NSValues, with the pathnames as their keys. -} - -+(id) sharedFileWatcher; - -// UKFileWatcher defines the methods: addPath: removePath: and delegate accessors. - -// Private: --(void) sendDelegateMessage: (FNMessage)message forSubscription: (FNSubscriptionRef)subscription; - -@end diff --git a/Atom/UKKQueue/UKFNSubscribeFileWatcher.m b/Atom/UKKQueue/UKFNSubscribeFileWatcher.m deleted file mode 100644 index d642a3a0d..000000000 --- a/Atom/UKKQueue/UKFNSubscribeFileWatcher.m +++ /dev/null @@ -1,201 +0,0 @@ -/* ============================================================================= - FILE: UKFNSubscribeFileWatcher.m - PROJECT: Filie - - COPYRIGHT: (c) 2005 M. Uli Kusterer, all rights reserved. - - AUTHORS: M. Uli Kusterer - UK - - LICENSES: MIT License - - REVISIONS: - 2006-03-13 UK Commented, added singleton, added notifications. - 2005-03-02 UK Created. - ========================================================================== */ - -// ----------------------------------------------------------------------------- -// Headers: -// ----------------------------------------------------------------------------- - -#import "UKFNSubscribeFileWatcher.h" -#import - - -// ----------------------------------------------------------------------------- -// Prototypes: -// ----------------------------------------------------------------------------- - -void UKFileSubscriptionProc(FNMessage message, OptionBits flags, void *refcon, FNSubscriptionRef subscription); - - -@implementation UKFNSubscribeFileWatcher - -// ----------------------------------------------------------------------------- -// sharedFileWatcher: -// Singleton accessor. -// ----------------------------------------------------------------------------- - -+(id) sharedFileWatcher -{ - static UKFNSubscribeFileWatcher* sSharedFileWatcher = nil; - - if( !sSharedFileWatcher ) - sSharedFileWatcher = [[UKFNSubscribeFileWatcher alloc] init]; // This is a singleton, and thus an intentional "leak". - - return sSharedFileWatcher; -} - - -// ----------------------------------------------------------------------------- -// * CONSTRUCTOR: -// ----------------------------------------------------------------------------- - --(id) init -{ - self = [super init]; - if( !self ) - return nil; - - subscriptions = [[NSMutableDictionary alloc] init]; - - return self; -} - - -// ----------------------------------------------------------------------------- -// * DESTRUCTOR: -// ----------------------------------------------------------------------------- - --(void) dealloc -{ - NSEnumerator* enny = [subscriptions objectEnumerator]; - NSValue* subValue = nil; - - while( (subValue = [enny nextObject]) ) - { - FNSubscriptionRef subscription = [subValue pointerValue]; - FNUnsubscribe( subscription ); - } - - [subscriptions release]; - [super dealloc]; -} - - -// ----------------------------------------------------------------------------- -// addPath: -// Start watching the object at the specified path. This only sends write -// notifications for all changes, as FNSubscribe doesn't tell what actually -// changed about our folder. -// ----------------------------------------------------------------------------- - --(void) addPath: (NSString*)path -{ - OSStatus err = noErr; - static FNSubscriptionUPP subscriptionUPP = NULL; - FNSubscriptionRef subscription = NULL; - - if( !subscriptionUPP ) - subscriptionUPP = NewFNSubscriptionUPP( UKFileSubscriptionProc ); - - err = FNSubscribeByPath( (UInt8*) [path fileSystemRepresentation], subscriptionUPP, (void*)self, - kNilOptions, &subscription ); - if( err != noErr ) - { - NSLog( @"UKFNSubscribeFileWatcher addPath: %@ failed due to error ID=%d.", path, err ); - return; - } - - [subscriptions setObject: [NSValue valueWithPointer: subscription] forKey: path]; -} - - -// ----------------------------------------------------------------------------- -// removePath: -// Stop watching the object at the specified path. -// ----------------------------------------------------------------------------- - --(void) removePath: (NSString*)path -{ - NSValue* subValue = nil; - @synchronized( self ) - { - subValue = [[[subscriptions objectForKey: path] retain] autorelease]; - [subscriptions removeObjectForKey: path]; - } - - if( subValue ) - { - FNSubscriptionRef subscription = [subValue pointerValue]; - - FNUnsubscribe( subscription ); - } -} - - -// ----------------------------------------------------------------------------- -// sendDelegateMessage:forSubscription: -// Bottleneck for change notifications. This is called by our callback -// function to actually inform the delegate and send out notifications. -// -// This *only* sends out write notifications, as FNSubscribe doesn't tell -// what changed about our folder. -// ----------------------------------------------------------------------------- - --(void) sendDelegateMessage: (FNMessage)message forSubscription: (FNSubscriptionRef)subscription -{ - NSValue* subValue = [NSValue valueWithPointer: subscription]; - NSString* path = [[subscriptions allKeysForObject: subValue] objectAtIndex: 0]; - - [[[NSWorkspace sharedWorkspace] notificationCenter] postNotificationName: UKFileWatcherWriteNotification - object: self - userInfo: [NSDictionary dictionaryWithObjectsAndKeys: path, @"path", nil]]; - - [delegate watcher: self receivedNotification: UKFileWatcherWriteNotification forPath: path]; - //NSLog( @"UKFNSubscribeFileWatcher noticed change to %@", path ); // DEBUG ONLY! -} - - - -// ----------------------------------------------------------------------------- -// delegate: -// Accessor for file watcher delegate. -// ----------------------------------------------------------------------------- - --(id) delegate -{ - return delegate; -} - - -// ----------------------------------------------------------------------------- -// setDelegate: -// Mutator for file watcher delegate. -// ----------------------------------------------------------------------------- - --(void) setDelegate: (id)newDelegate -{ - delegate = newDelegate; -} - - -@end - - -// ----------------------------------------------------------------------------- -// UKFileSubscriptionProc: -// Callback function we hand to Carbon so it can tell us when something -// changed about our watched folders. We set the refcon to a pointer to -// our object. This simply extracts the object and hands the info off to -// sendDelegateMessage:forSubscription: which does the actual work. -// ----------------------------------------------------------------------------- - -void UKFileSubscriptionProc( FNMessage message, OptionBits flags, void *refcon, FNSubscriptionRef subscription ) -{ - UKFNSubscribeFileWatcher* obj = (UKFNSubscribeFileWatcher*) refcon; - - if( message == kFNDirectoryModifiedMessage ) // No others exist as of 10.4 - [obj sendDelegateMessage: message forSubscription: subscription]; - else - NSLog( @"UKFileSubscriptionProc: Unknown message %d", message ); -} \ No newline at end of file diff --git a/Atom/UKKQueue/UKFileWatcher.h b/Atom/UKKQueue/UKFileWatcher.h deleted file mode 100644 index c2c4ba28c..000000000 --- a/Atom/UKKQueue/UKFileWatcher.h +++ /dev/null @@ -1,62 +0,0 @@ -/* ============================================================================= - FILE: UKFileWatcher.h - PROJECT: Filie - - COPYRIGHT: (c) 2005 M. Uli Kusterer, all rights reserved. - - AUTHORS: M. Uli Kusterer - UK - - LICENSES: MIT License - - REVISIONS: - 2006-03-13 UK Moved notification constants to .m file. - 2005-02-25 UK Created. - ========================================================================== */ - -/* - This is a protocol that file change notification classes should adopt. - That way, no matter whether you use Carbon's FNNotify/FNSubscribe, BSD's - kqueue or whatever, the object being notified can react to change - notifications the same way, and you can easily swap one out for the other - to cater to different OS versions, target volumes etc. -*/ - -// ----------------------------------------------------------------------------- -// Protocol: -// ----------------------------------------------------------------------------- - -@protocol UKFileWatcher - -// +(id) sharedFileWatcher; // Singleton accessor. Not officially part of the protocol, but use this name if you provide a singleton. - --(void) addPath: (NSString*)path; --(void) removePath: (NSString*)path; - --(id) delegate; --(void) setDelegate: (id)newDelegate; - -@end - -// ----------------------------------------------------------------------------- -// Methods delegates need to provide: -// ----------------------------------------------------------------------------- - -@interface NSObject (UKFileWatcherDelegate) - --(void) watcher: (id)kq receivedNotification: (NSString*)nm forPath: (NSString*)fpath; - -@end - - -// Notifications this sends: -/* object = the file watcher object - userInfo.path = file path watched - These notifications are sent via the NSWorkspace notification center */ -extern NSString* UKFileWatcherRenameNotification; -extern NSString* UKFileWatcherWriteNotification; -extern NSString* UKFileWatcherDeleteNotification; -extern NSString* UKFileWatcherAttributeChangeNotification; -extern NSString* UKFileWatcherSizeIncreaseNotification; -extern NSString* UKFileWatcherLinkCountChangeNotification; -extern NSString* UKFileWatcherAccessRevocationNotification; - diff --git a/Atom/UKKQueue/UKFileWatcher.m b/Atom/UKKQueue/UKFileWatcher.m deleted file mode 100644 index 952cf95fd..000000000 --- a/Atom/UKKQueue/UKFileWatcher.m +++ /dev/null @@ -1,38 +0,0 @@ -/* ============================================================================= - FILE: UKKQueue.m - PROJECT: Filie - - COPYRIGHT: (c) 2005-06 M. Uli Kusterer, all rights reserved. - - AUTHORS: M. Uli Kusterer - UK - - LICENSES: MIT License - - REVISIONS: - 2006-03-13 UK Created, moved notification constants here as exportable - symbols. - ========================================================================== */ - -// ----------------------------------------------------------------------------- -// Headers: -// ----------------------------------------------------------------------------- - -#import -#import "UKFileWatcher.h" - - -// ----------------------------------------------------------------------------- -// Constants: -// ----------------------------------------------------------------------------- - -// Do not rely on the actual contents of these constants. They will eventually -// be changed to be more generic and less KQueue-specific. - -NSString* UKFileWatcherRenameNotification = @"UKKQueueFileRenamedNotification"; -NSString* UKFileWatcherWriteNotification = @"UKKQueueFileWrittenToNotification"; -NSString* UKFileWatcherDeleteNotification = @"UKKQueueFileDeletedNotification"; -NSString* UKFileWatcherAttributeChangeNotification = @"UKKQueueFileAttributesChangedNotification"; -NSString* UKFileWatcherSizeIncreaseNotification = @"UKKQueueFileSizeIncreasedNotification"; -NSString* UKFileWatcherLinkCountChangeNotification = @"UKKQueueFileLinkCountChangedNotification"; -NSString* UKFileWatcherAccessRevocationNotification = @"UKKQueueFileAccessRevocationNotification"; - diff --git a/Atom/UKKQueue/UKKQueue.h b/Atom/UKKQueue/UKKQueue.h deleted file mode 100644 index facd513cb..000000000 --- a/Atom/UKKQueue/UKKQueue.h +++ /dev/null @@ -1,122 +0,0 @@ -/* ============================================================================= - FILE: UKKQueue.h - PROJECT: Filie - - COPYRIGHT: (c) 2003 M. Uli Kusterer, all rights reserved. - - AUTHORS: M. Uli Kusterer - UK - - LICENSES: MIT License - - REVISIONS: - 2006-03-13 UK Clarified license, streamlined UKFileWatcher stuff, - Changed notifications to be useful and turned off by - default some deprecated stuff. - 2003-12-21 UK Created. - ========================================================================== */ - -// ----------------------------------------------------------------------------- -// Headers: -// ----------------------------------------------------------------------------- - -#import -#include -#include -#import "UKFileWatcher.h" - - -// ----------------------------------------------------------------------------- -// Constants: -// ----------------------------------------------------------------------------- - -// Backwards compatibility constants. Don't rely on code commented out with these constants, because it may be deleted in a future version. -#ifndef UKKQUEUE_BACKWARDS_COMPATIBLE -#define UKKQUEUE_BACKWARDS_COMPATIBLE 0 // 1 to send old-style kqueue:receivedNotification:forFile: messages to objects that accept them. -#endif - -#ifndef UKKQUEUE_SEND_STUPID_NOTIFICATIONS -#define UKKQUEUE_SEND_STUPID_NOTIFICATIONS 0 // 1 to send old-style notifications that have the path as the object and no userInfo dictionary. -#endif - -#ifndef UKKQUEUE_OLD_SINGLETON_ACCESSOR_NAME -#define UKKQUEUE_OLD_SINGLETON_ACCESSOR_NAME 0 // 1 to allow use of sharedQueue instead of sharedFileWatcher. -#endif - -#ifndef UKKQUEUE_OLD_NOTIFICATION_NAMES -#define UKKQUEUE_OLD_NOTIFICATION_NAMES 0 // 1 to allow use of old KQueue-style notification names instead of the new more generic ones in UKFileWatcher. -#endif - -// Flags for notifyingAbout: -#define UKKQueueNotifyAboutRename NOTE_RENAME // Item was renamed. -#define UKKQueueNotifyAboutWrite NOTE_WRITE // Item contents changed (also folder contents changed). -#define UKKQueueNotifyAboutDelete NOTE_DELETE // item was removed. -#define UKKQueueNotifyAboutAttributeChange NOTE_ATTRIB // Item attributes changed. -#define UKKQueueNotifyAboutSizeIncrease NOTE_EXTEND // Item size increased. -#define UKKQueueNotifyAboutLinkCountChanged NOTE_LINK // Item's link count changed. -#define UKKQueueNotifyAboutAccessRevocation NOTE_REVOKE // Access to item was revoked. - -// Notifications this sends: -// (see UKFileWatcher) -// Old names: *deprecated* -#if UKKQUEUE_OLD_NOTIFICATION_NAMES -#define UKKQueueFileRenamedNotification UKFileWatcherRenameNotification -#define UKKQueueFileWrittenToNotification UKFileWatcherWriteNotification -#define UKKQueueFileDeletedNotification UKFileWatcherDeleteNotification -#define UKKQueueFileAttributesChangedNotification UKFileWatcherAttributeChangeNotification -#define UKKQueueFileSizeIncreasedNotification UKFileWatcherSizeIncreaseNotification -#define UKKQueueFileLinkCountChangedNotification UKFileWatcherLinkCountChangeNotification -#define UKKQueueFileAccessRevocationNotification UKFileWatcherAccessRevocationNotification -#endif - - -// ----------------------------------------------------------------------------- -// UKKQueue: -// ----------------------------------------------------------------------------- - -@interface UKKQueue : NSObject -{ - int queueFD; // The actual queue ID (Unix file descriptor). - NSMutableArray* watchedPaths; // List of NSStrings containing the paths we're watching. - NSMutableArray* watchedFDs; // List of NSNumbers containing the file descriptors we're watching. - id delegate; // Gets messages about changes instead of notification center, if specified. - id delegateProxy; // Proxy object to which we send messages so they reach delegate on the main thread. - BOOL alwaysNotify; // Send notifications even if we have a delegate? Defaults to NO. - BOOL keepThreadRunning; // Termination criterion of our thread. -} - -+(id) sharedFileWatcher; // Returns a singleton, a shared kqueue object Handy if you're subscribing to the notifications. Use this, or just create separate objects using alloc/init. Whatever floats your boat. - --(int) queueFD; // I know you unix geeks want this... - -// High-level file watching: (use UKFileWatcher protocol methods instead, where possible!) --(void) addPathToQueue: (NSString*)path; --(void) addPathToQueue: (NSString*)path notifyingAbout: (u_int)fflags; --(void) removePathFromQueue: (NSString*)path; - --(id) delegate; --(void) setDelegate: (id)newDelegate; - --(BOOL) alwaysNotify; --(void) setAlwaysNotify: (BOOL)n; - -#if UKKQUEUE_OLD_SINGLETON_ACCESSOR_NAME -+(UKKQueue*) sharedQueue; -#endif - -// private: --(void) watcherThread: (id)sender; --(void) postNotification: (NSString*)nm forFile: (NSString*)fp; // Message-posting bottleneck. - -@end - - -// ----------------------------------------------------------------------------- -// Methods delegates need to provide: -// * DEPRECATED * use UKFileWatcher delegate methods instead! -// ----------------------------------------------------------------------------- - -@interface NSObject (UKKQueueDelegate) - --(void) kqueue: (UKKQueue*)kq receivedNotification: (NSString*)nm forFile: (NSString*)fpath; - -@end diff --git a/Atom/UKKQueue/UKKQueue.m b/Atom/UKKQueue/UKKQueue.m deleted file mode 100644 index 45c8efedc..000000000 --- a/Atom/UKKQueue/UKKQueue.m +++ /dev/null @@ -1,501 +0,0 @@ -/* ============================================================================= - FILE: UKKQueue.m - PROJECT: Filie - - COPYRIGHT: (c) 2003 M. Uli Kusterer, all rights reserved. - - AUTHORS: M. Uli Kusterer - UK - - LICENSES: MIT License - - REVISIONS: - 2006-03-13 UK Clarified license, streamlined UKFileWatcher stuff, - Changed notifications to be useful and turned off by - default some deprecated stuff. - 2004-12-28 UK Several threading fixes. - 2003-12-21 UK Created. - ========================================================================== */ - -// ----------------------------------------------------------------------------- -// Headers: -// ----------------------------------------------------------------------------- - -#import "UKKQueue.h" -#import "UKMainThreadProxy.h" -#import -#import -#import - -// ----------------------------------------------------------------------------- -// Macros: -// ----------------------------------------------------------------------------- - -// @synchronized isn't available prior to 10.3, so we use a typedef so -// this class is thread-safe on Panther but still compiles on older OSs. - -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3 -#define AT_SYNCHRONIZED(n) @synchronized(n) -#else -#define AT_SYNCHRONIZED(n) -#endif - - -// ----------------------------------------------------------------------------- -// Globals: -// ----------------------------------------------------------------------------- - -static UKKQueue * gUKKQueueSharedQueueSingleton = nil; - - -@implementation UKKQueue - -// Deprecated: -#if UKKQUEUE_OLD_SINGLETON_ACCESSOR_NAME -+(UKKQueue*) sharedQueue -{ - return [self sharedFileWatcher]; -} -#endif - -// ----------------------------------------------------------------------------- -// sharedQueue: -// Returns a singleton queue object. In many apps (especially those that -// subscribe to the notifications) there will only be one kqueue instance, -// and in that case you can use this. -// -// For all other cases, feel free to create additional instances to use -// independently. -// -// REVISIONS: -// 2006-03-13 UK Renamed from sharedQueue. -// 2005-07-02 UK Created. -// ----------------------------------------------------------------------------- - -+(id) sharedFileWatcher -{ - AT_SYNCHRONIZED( self ) - { - if( !gUKKQueueSharedQueueSingleton ) - gUKKQueueSharedQueueSingleton = [[UKKQueue alloc] init]; // This is a singleton, and thus an intentional "leak". - } - - return gUKKQueueSharedQueueSingleton; -} - - -// ----------------------------------------------------------------------------- -// * CONSTRUCTOR: -// Creates a new KQueue and starts that thread we use for our -// notifications. -// -// REVISIONS: -// 2004-11-12 UK Doesn't pass self as parameter to watcherThread anymore, -// because detachNewThreadSelector retains target and args, -// which would cause us to never be released. -// 2004-03-13 UK Documented. -// ----------------------------------------------------------------------------- - --(id) init -{ - self = [super init]; - if( self ) - { - queueFD = kqueue(); - if( queueFD == -1 ) - { - [self release]; - return nil; - } - - watchedPaths = [[NSMutableArray alloc] init]; - watchedFDs = [[NSMutableArray alloc] init]; - - // Start new thread that fetches and processes our events: - keepThreadRunning = YES; - [NSThread detachNewThreadSelector:@selector(watcherThread:) toTarget:self withObject:nil]; - } - - return self; -} - - -// ----------------------------------------------------------------------------- -// release: -// Since NSThread retains its target, we need this method to terminate the -// thread when we reach a retain-count of two. The thread is terminated by -// setting keepThreadRunning to NO. -// -// REVISIONS: -// 2004-11-12 UK Created. -// ----------------------------------------------------------------------------- - --(oneway void) release -{ - AT_SYNCHRONIZED(self) - { - //NSLog(@"%@ (%d)", self, [self retainCount]); - if( [self retainCount] == 2 && keepThreadRunning ) - keepThreadRunning = NO; - } - - [super release]; -} - -// ----------------------------------------------------------------------------- -// * DESTRUCTOR: -// Releases the kqueue again. -// -// REVISIONS: -// 2004-03-13 UK Documented. -// ----------------------------------------------------------------------------- - --(void) dealloc -{ - delegate = nil; - [delegateProxy release]; - - if( keepThreadRunning ) - keepThreadRunning = NO; - - // Close all our file descriptors so the files can be deleted: - NSEnumerator* enny = [watchedFDs objectEnumerator]; - NSNumber* fdNum; - while( (fdNum = [enny nextObject]) ) - { - if( close( [fdNum intValue] ) == -1 ) - NSLog(@"dealloc: Couldn't close file descriptor (%d)", errno); - } - - [watchedPaths release]; - watchedPaths = nil; - [watchedFDs release]; - watchedFDs = nil; - - [super dealloc]; - - //NSLog(@"kqueue released."); -} - - -// ----------------------------------------------------------------------------- -// queueFD: -// Returns a Unix file descriptor for the KQueue this uses. The descriptor -// is owned by this object. Do not close it! -// -// REVISIONS: -// 2004-03-13 UK Documented. -// ----------------------------------------------------------------------------- - --(int) queueFD -{ - return queueFD; -} - - -// ----------------------------------------------------------------------------- -// addPathToQueue: -// Tell this queue to listen for all interesting notifications sent for -// the object at the specified path. If you want more control, use the -// addPathToQueue:notifyingAbout: variant instead. -// -// REVISIONS: -// 2004-03-13 UK Documented. -// ----------------------------------------------------------------------------- - --(void) addPathToQueue: (NSString*)path -{ - [self addPath: path]; -} - - --(void) addPath: (NSString*)path -{ - [self addPathToQueue: path notifyingAbout: UKKQueueNotifyAboutRename - | UKKQueueNotifyAboutWrite - | UKKQueueNotifyAboutDelete - | UKKQueueNotifyAboutAttributeChange]; -} - - -// ----------------------------------------------------------------------------- -// addPathToQueue:notfyingAbout: -// Tell this queue to listen for the specified notifications sent for -// the object at the specified path. -// -// REVISIONS: -// 2005-06-29 UK Files are now opened using O_EVTONLY instead of O_RDONLY -// which allows ejecting or deleting watched files/folders. -// Thanks to Phil Hargett for finding this flag in the docs. -// 2004-03-13 UK Documented. -// ----------------------------------------------------------------------------- - --(void) addPathToQueue: (NSString*)path notifyingAbout: (u_int)fflags -{ - struct timespec nullts = { 0, 0 }; - struct kevent ev; - int fd = open( [path fileSystemRepresentation], O_EVTONLY, 0 ); - - if( fd >= 0 ) - { - EV_SET( &ev, fd, EVFILT_VNODE, - EV_ADD | EV_ENABLE | EV_CLEAR, - fflags, 0, (void*)path ); - - AT_SYNCHRONIZED( self ) - { - [watchedPaths addObject: path]; - [watchedFDs addObject: [NSNumber numberWithInt: fd]]; - kevent( queueFD, &ev, 1, NULL, 0, &nullts ); - } - } -} - - --(void) removePath: (NSString*)path -{ - [self removePathFromQueue: path]; -} - - -// ----------------------------------------------------------------------------- -// removePathFromQueue: -// Stop listening for changes to the specified path. This removes all -// notifications. Use this to balance both addPathToQueue:notfyingAbout: -// as well as addPathToQueue:. -// -// REVISIONS: -// 2004-03-13 UK Documented. -// ----------------------------------------------------------------------------- - --(void) removePathFromQueue: (NSString*)path -{ - NSUInteger index = 0; - int fd = -1; - - AT_SYNCHRONIZED( self ) - { - index = [watchedPaths indexOfObject: path]; - - if( index == NSNotFound ) - return; - - fd = [[watchedFDs objectAtIndex: index] intValue]; - - [watchedFDs removeObjectAtIndex: index]; - [watchedPaths removeObjectAtIndex: index]; - } - - if( close( fd ) == -1 ) - NSLog(@"removePathFromQueue: Couldn't close file descriptor (%d)", errno); -} - - -// ----------------------------------------------------------------------------- -// removeAllPathsFromQueue: -// Stop listening for changes to all paths. This removes all -// notifications. -// -// REVISIONS: -// 2004-12-28 UK Added as suggested by bbum. -// ----------------------------------------------------------------------------- - --(void) removeAllPathsFromQueue; -{ - AT_SYNCHRONIZED( self ) - { - NSEnumerator * fdEnumerator = [watchedFDs objectEnumerator]; - NSNumber * anFD; - - while( (anFD = [fdEnumerator nextObject]) != nil ) - close( [anFD intValue] ); - - [watchedFDs removeAllObjects]; - [watchedPaths removeAllObjects]; - } -} - - -// ----------------------------------------------------------------------------- -// watcherThread: -// This method is called by our NSThread to loop and poll for any file -// changes that our kqueue wants to tell us about. This sends separate -// notifications for the different kinds of changes that can happen. -// All messages are sent via the postNotification:forFile: main bottleneck. -// -// This also calls sharedWorkspace's noteFileSystemChanged. -// -// To terminate this method (and its thread), set keepThreadRunning to NO. -// -// REVISIONS: -// 2005-08-27 UK Changed to use keepThreadRunning instead of kqueueFD -// being -1 as termination criterion, and to close the -// queue in this thread so the main thread isn't blocked. -// 2004-11-12 UK Fixed docs to include termination criterion, added -// timeout to make sure the bugger gets disposed. -// 2004-03-13 UK Documented. -// ----------------------------------------------------------------------------- - --(void) watcherThread: (id)sender -{ - int n; - struct kevent ev; - struct timespec timeout = { 5, 0 }; // 5 seconds timeout. - int theFD = queueFD; // So we don't have to risk accessing iVars when the thread is terminated. - - while( keepThreadRunning ) - { - NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; - - NS_DURING - n = kevent( queueFD, NULL, 0, &ev, 1, &timeout ); - if( n > 0 ) - { - if( ev.filter == EVFILT_VNODE ) - { - if( ev.fflags ) - { - NSString* fpath = [[(NSString *)ev.udata retain] autorelease]; // In case one of the notified folks removes the path. - //NSLog(@"UKKQueue: Detected file change: %@", fpath); - [[NSWorkspace sharedWorkspace] noteFileSystemChanged: fpath]; - - //NSLog(@"ev.flags = %u",ev.fflags); // DEBUG ONLY! - - if( (ev.fflags & NOTE_RENAME) == NOTE_RENAME ) { - char path[MAXPATHLEN]; - fcntl((int)ev.ident, F_GETPATH, &path); - [self postNotification: UKFileWatcherRenameNotification forFile: [NSString stringWithUTF8String:path]]; - } - if( (ev.fflags & NOTE_WRITE) == NOTE_WRITE ) { - [self postNotification: UKFileWatcherWriteNotification forFile: fpath]; - } - if( (ev.fflags & NOTE_DELETE) == NOTE_DELETE ) { - [self removePathFromQueue:fpath]; - int newFD = open( [fpath fileSystemRepresentation], O_EVTONLY, 0 ); - if (newFD == -1) { - // It's really a delete - [self postNotification: UKFileWatcherDeleteNotification forFile: fpath]; - } - else { - // Probably an atomic write, readd to the queue. - close(newFD); - [self addPathToQueue:fpath]; - [self postNotification: UKFileWatcherWriteNotification forFile: fpath]; - [self postNotification: UKFileWatcherAttributeChangeNotification forFile: fpath]; - } - } - if( (ev.fflags & NOTE_ATTRIB) == NOTE_ATTRIB ) { - [self postNotification: UKFileWatcherAttributeChangeNotification forFile: fpath]; - } - if( (ev.fflags & NOTE_EXTEND) == NOTE_EXTEND ) { - [self postNotification: UKFileWatcherSizeIncreaseNotification forFile: fpath]; - } - if( (ev.fflags & NOTE_LINK) == NOTE_LINK ) { - [self postNotification: UKFileWatcherLinkCountChangeNotification forFile: fpath]; - } - if( (ev.fflags & NOTE_REVOKE) == NOTE_REVOKE ) { - [self postNotification: UKFileWatcherAccessRevocationNotification forFile: fpath]; - } - } - } - } - NS_HANDLER - NSLog(@"Error in UKKQueue watcherThread: %@",localException); - NS_ENDHANDLER - - [pool release]; - } - - // Close our kqueue's file descriptor: - if( close( theFD ) == -1 ) - NSLog(@"release: Couldn't close main kqueue (%d)", errno); - - //NSLog(@"exiting kqueue watcher thread."); -} - - -// ----------------------------------------------------------------------------- -// postNotification:forFile: -// This is the main bottleneck for posting notifications. If you don't want -// the notifications to go through NSWorkspace, override this method and -// send them elsewhere. -// -// REVISIONS: -// 2004-02-27 UK Changed this to send new notification, and the old one -// only to objects that respond to it. The old category on -// NSObject could cause problems with the proxy itself. -// 2004-10-31 UK Helloween fun: Make this use a mainThreadProxy and -// allow sending the notification even if we have a -// delegate. -// 2004-03-13 UK Documented. -// ----------------------------------------------------------------------------- - --(void) postNotification: (NSString*)nm forFile: (NSString*)fp -{ - if( delegateProxy ) - { - #if UKKQUEUE_BACKWARDS_COMPATIBLE - if( ![delegateProxy respondsToSelector: @selector(watcher:receivedNotification:forPath:)] ) - [delegateProxy kqueue: self receivedNotification: nm forFile: fp]; - else - #endif - [delegateProxy watcher: self receivedNotification: nm forPath: fp]; - } - - if( !delegateProxy || alwaysNotify ) - { - #if UKKQUEUE_SEND_STUPID_NOTIFICATIONS - [[[NSWorkspace sharedWorkspace] notificationCenter] postNotificationName: nm object: fp]; - #else - [[[NSWorkspace sharedWorkspace] notificationCenter] postNotificationName: nm object: self - userInfo: [NSDictionary dictionaryWithObjectsAndKeys: fp, @"path", nil]]; - #endif - } -} - --(id) delegate -{ - return delegate; -} - --(void) setDelegate: (id)newDelegate -{ - id oldProxy = delegateProxy; - delegate = newDelegate; - delegateProxy = [delegate copyMainThreadProxy]; - [oldProxy release]; -} - -// ----------------------------------------------------------------------------- -// Flag to send a notification even if we have a delegate: -// ----------------------------------------------------------------------------- - --(BOOL) alwaysNotify -{ - return alwaysNotify; -} - - --(void) setAlwaysNotify: (BOOL)n -{ - alwaysNotify = n; -} - - -// ----------------------------------------------------------------------------- -// description: -// This method can be used to help in debugging. It provides the value -// used by NSLog & co. when you request to print this object using the -// %@ format specifier. -// -// REVISIONS: -// 2004-11-12 UK Created. -// ----------------------------------------------------------------------------- - --(NSString*) description -{ - return [NSString stringWithFormat: @"%@ { watchedPaths = %@, alwaysNotify = %@ }", NSStringFromClass([self class]), watchedPaths, (alwaysNotify? @"YES" : @"NO") ]; -} - -@end - - diff --git a/Atom/UKKQueue/UKMainThreadProxy.h b/Atom/UKKQueue/UKMainThreadProxy.h deleted file mode 100644 index 9fd6ff453..000000000 --- a/Atom/UKKQueue/UKMainThreadProxy.h +++ /dev/null @@ -1,56 +0,0 @@ -/* ============================================================================= - FILE: UKMainThreadProxy.h - PROJECT: UKMainThreadProxy - - PURPOSE: Send a message to object theObject to [theObject mainThreadProxy] - instead and the message will be received on the main thread by - theObject. - - COPYRIGHT: (c) 2004 M. Uli Kusterer, all rights reserved. - - AUTHORS: M. Uli Kusterer - UK - - LICENSES: MIT License - - REVISIONS: - 2006-03-13 UK Clarified license. - 2004-10-14 UK Created. - ========================================================================== */ - -// ----------------------------------------------------------------------------- -// Headers: -// ----------------------------------------------------------------------------- - -#import - - -// ----------------------------------------------------------------------------- -// Categories: -// ----------------------------------------------------------------------------- - -@interface NSObject (UKMainThreadProxy) - --(id) mainThreadProxy; // You can't init or release this object. --(id) copyMainThreadProxy; // Gives you a retained version. - -@end - - -// ----------------------------------------------------------------------------- -// Classes: -// ----------------------------------------------------------------------------- - -/* - This object is created as a proxy in a second thread for an existing object. - All messages you send to this object will automatically be sent to the other - object on the main thread, except NSObject methods like retain/release etc. -*/ - -@interface UKMainThreadProxy : NSObject -{ - IBOutlet id target; -} - --(id) initWithTarget: (id)targ; - -@end diff --git a/Atom/UKKQueue/UKMainThreadProxy.m b/Atom/UKKQueue/UKMainThreadProxy.m deleted file mode 100644 index 93ded660c..000000000 --- a/Atom/UKKQueue/UKMainThreadProxy.m +++ /dev/null @@ -1,151 +0,0 @@ - /* ============================================================================= - FILE: UKMainThreadProxy.h - PROJECT: UKMainThreadProxy - - PURPOSE: Send a message to object theObject to [theObject mainThreadProxy] - instead and the message will be received on the main thread by - theObject. - - COPYRIGHT: (c) 2004 M. Uli Kusterer, all rights reserved. - - AUTHORS: M. Uli Kusterer - UK - - LICENSES: MIT Licenseâ - - REVISIONS: - 2006-03-13 UK Clarified license. - 2004-10-14 UK Created. - ========================================================================== */ - -// ----------------------------------------------------------------------------- -// Headers: -// ----------------------------------------------------------------------------- - -#import "UKMainThreadProxy.h" - - -@implementation UKMainThreadProxy - --(id) initWithTarget: (id)targ -{ - self = [super init]; - if( self ) - target = targ; - - return self; -} - - -// ----------------------------------------------------------------------------- -// Introspection overrides: -// ----------------------------------------------------------------------------- - --(BOOL) respondsToSelector: (SEL)itemAction -{ - BOOL does = [super respondsToSelector: itemAction]; - - return( does || [target respondsToSelector: itemAction] ); -} - - --(id) performSelector: (SEL)itemAction -{ - BOOL does = [super respondsToSelector: itemAction]; - if( does ) - return [super performSelector: itemAction]; - - if( ![target respondsToSelector: itemAction] ) - [self doesNotRecognizeSelector: itemAction]; - - [target retain]; - [target performSelectorOnMainThread: itemAction withObject: nil waitUntilDone: YES]; - [target release]; - - return nil; -} - - --(id) performSelector: (SEL)itemAction withObject: (id)obj -{ - BOOL does = [super respondsToSelector: itemAction]; - if( does ) - return [super performSelector: itemAction withObject: obj]; - - if( ![target respondsToSelector: itemAction] ) - [self doesNotRecognizeSelector: itemAction]; - - [target retain]; - [obj retain]; - [target performSelectorOnMainThread: itemAction withObject: obj waitUntilDone: YES]; - [obj release]; - [target release]; - - return nil; -} - - -// ----------------------------------------------------------------------------- -// Forwarding unknown methods to the target: -// ----------------------------------------------------------------------------- - --(NSMethodSignature*) methodSignatureForSelector: (SEL)itemAction -{ - NSMethodSignature* sig = [super methodSignatureForSelector: itemAction]; - - if( sig ) - return sig; - - return [target methodSignatureForSelector: itemAction]; -} - --(void) forwardInvocation: (NSInvocation*)invocation -{ - SEL itemAction = [invocation selector]; - - if( [target respondsToSelector: itemAction] ) - { - [invocation retainArguments]; - [target retain]; - [invocation performSelectorOnMainThread: @selector(invokeWithTarget:) withObject: target waitUntilDone: YES]; - [target release]; - } - else - [self doesNotRecognizeSelector: itemAction]; -} - - -// ----------------------------------------------------------------------------- -// Safety net: -// ----------------------------------------------------------------------------- - --(id) mainThreadProxy // Just in case someone accidentally sends this message to a main thread proxy. -{ - return self; -} - --(id) copyMainThreadProxy // Just in case someone accidentally sends this message to a main thread proxy. -{ - return [self retain]; -} - -@end - - -// ----------------------------------------------------------------------------- -// Shorthand notation for getting a main thread proxy: -// ----------------------------------------------------------------------------- - -@implementation NSObject (UKMainThreadProxy) - --(id) mainThreadProxy -{ - return [[[UKMainThreadProxy alloc] initWithTarget: self] autorelease]; -} - --(id) copyMainThreadProxy -{ - return [[UKMainThreadProxy alloc] initWithTarget: self]; -} - -@end - diff --git a/Atom/en.lproj/InfoPlist.strings b/Atom/en.lproj/InfoPlist.strings deleted file mode 100644 index 477b28ff8..000000000 --- a/Atom/en.lproj/InfoPlist.strings +++ /dev/null @@ -1,2 +0,0 @@ -/* Localized versions of Info.plist keys */ - diff --git a/Atom/en.lproj/MainMenu.xib b/Atom/en.lproj/MainMenu.xib deleted file mode 100644 index d01d0fccf..000000000 --- a/Atom/en.lproj/MainMenu.xib +++ /dev/null @@ -1,380 +0,0 @@ - - - - 1070 - 11C74 - 1938 - 1138.23 - 567.00 - - com.apple.InterfaceBuilder.CocoaPlugin - 1938 - - - NSMenu - NSMenuItem - NSCustomObject - - - com.apple.InterfaceBuilder.CocoaPlugin - - - PluginDependencyRecalculationVersion - - - - - AtomApp - - - FirstResponder - - - AtomApp - - - AMainMenu - - - - Atom - - 1048576 - 2147483647 - - NSImage - NSMenuCheckmark - - - NSImage - NSMenuMixedState - - submenuAction: - - Atom - - - - Run Specs - s - 1835008 - 2147483647 - - - - - - Quit Atom - q - 1048576 - 2147483647 - - - - - _NSAppleMenu - - - - - File - - 1048576 - 2147483647 - - - submenuAction: - - File - - - - New - n - 1048576 - 2147483647 - - - - - - Open… - o - 1048576 - 2147483647 - - - - - - - - _NSMainMenu - - - NSFontManager - - - - - - - terminate: - - - - 449 - - - - delegate - - - - 536 - - - - runSpecs: - - - - 541 - - - - openNewWindow: - - - - 545 - - - - openPathInNewWindow: - - - - 547 - - - - - - 0 - - - - - - -2 - - - File's Owner - - - -1 - - - First Responder - - - -3 - - - Application - - - 29 - - - - - - - - - 56 - - - - - - - - 83 - - - - - - - - 81 - - - - - - - - - 72 - - - - - 82 - - - - - 57 - - - - - - - - - 136 - - - - - 420 - - - - - 537 - - - - - - - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - AtomMenuItem - - IBUserDefinedRuntimeAttributesPlaceholderName - - IBUserDefinedRuntimeAttributesPlaceholderName - - - - com.apple.InterfaceBuilder.userDefinedRuntimeAttributeType.boolean - global - - - - - - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - AtomMenuItem - - IBUserDefinedRuntimeAttributesPlaceholderName - - IBUserDefinedRuntimeAttributesPlaceholderName - - - - com.apple.InterfaceBuilder.userDefinedRuntimeAttributeType.boolean - global - - - - - - com.apple.InterfaceBuilder.CocoaPlugin - AtomMenuItem - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - AtomMenuItem - - IBUserDefinedRuntimeAttributesPlaceholderName - - IBUserDefinedRuntimeAttributesPlaceholderName - - - - com.apple.InterfaceBuilder.userDefinedRuntimeAttributeType.boolean - global - - - - - - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - AtomMenuItem - - IBUserDefinedRuntimeAttributesPlaceholderName - - IBUserDefinedRuntimeAttributesPlaceholderName - - - - com.apple.InterfaceBuilder.userDefinedRuntimeAttributeType.boolean - global - - - - - - com.apple.InterfaceBuilder.CocoaPlugin - AtomMenuItem - com.apple.InterfaceBuilder.CocoaPlugin - - - - - - 547 - - - - - AtomApp - NSApplication - - runSpecs: - id - - - runSpecs: - - runSpecs: - id - - - - IBProjectSource - ./Classes/AtomApp.h - - - - AtomMenuItem - NSMenuItem - - IBProjectSource - ./Classes/AtomMenuItem.h - - - - - 0 - IBCocoaFramework - YES - 3 - - {9, 8} - {7, 2} - - - diff --git a/Atom/main.m b/Atom/main.m deleted file mode 100644 index 3248f6878..000000000 --- a/Atom/main.m +++ /dev/null @@ -1,14 +0,0 @@ -// -// main.m -// Atom -// -// Created by Corey Johnson on 10/25/11. -// Copyright (c) 2011 __MyCompanyName__. All rights reserved. -// - -#import - -int main(int argc, char *argv[]) -{ - return NSApplicationMain(argc, (const char **)argv); -} diff --git a/frameworks/WebCore.framework/Versions/A/Resources/aliasCursor.png b/Atom/resources/aliasCursor.png old mode 100644 new mode 100755 similarity index 100% rename from frameworks/WebCore.framework/Versions/A/Resources/aliasCursor.png rename to Atom/resources/aliasCursor.png diff --git a/frameworks/WebCore.framework/Versions/A/Resources/cellCursor.png b/Atom/resources/cellCursor.png old mode 100644 new mode 100755 similarity index 100% rename from frameworks/WebCore.framework/Versions/A/Resources/cellCursor.png rename to Atom/resources/cellCursor.png diff --git a/Atom/resources/chrome.pak b/Atom/resources/chrome.pak new file mode 100755 index 000000000..bbe61def7 Binary files /dev/null and b/Atom/resources/chrome.pak differ diff --git a/frameworks/WebCore.framework/Versions/A/Resources/contextMenuCursor.png b/Atom/resources/contextMenuCursor.png old mode 100644 new mode 100755 similarity index 100% rename from frameworks/WebCore.framework/Versions/A/Resources/contextMenuCursor.png rename to Atom/resources/contextMenuCursor.png diff --git a/frameworks/WebCore.framework/Versions/A/Resources/copyCursor.png b/Atom/resources/copyCursor.png old mode 100644 new mode 100755 similarity index 100% rename from frameworks/WebCore.framework/Versions/A/Resources/copyCursor.png rename to Atom/resources/copyCursor.png diff --git a/frameworks/WebCore.framework/Versions/A/Resources/deleteButton.png b/Atom/resources/deleteButton.png old mode 100644 new mode 100755 similarity index 100% rename from frameworks/WebCore.framework/Versions/A/Resources/deleteButton.png rename to Atom/resources/deleteButton.png diff --git a/Atom/resources/deleteButton.tiff b/Atom/resources/deleteButton.tiff new file mode 100755 index 000000000..bf4347ef6 Binary files /dev/null and b/Atom/resources/deleteButton.tiff differ diff --git a/frameworks/WebCore.framework/Versions/A/Resources/deleteButton@2x.png b/Atom/resources/deleteButton@2x.png old mode 100644 new mode 100755 similarity index 100% rename from frameworks/WebCore.framework/Versions/A/Resources/deleteButton@2x.png rename to Atom/resources/deleteButton@2x.png diff --git a/frameworks/WebCore.framework/Versions/A/Resources/deleteButtonPressed.png b/Atom/resources/deleteButtonPressed.png old mode 100644 new mode 100755 similarity index 100% rename from frameworks/WebCore.framework/Versions/A/Resources/deleteButtonPressed.png rename to Atom/resources/deleteButtonPressed.png diff --git a/Atom/resources/deleteButtonPressed.tiff b/Atom/resources/deleteButtonPressed.tiff new file mode 100755 index 000000000..6232484d6 Binary files /dev/null and b/Atom/resources/deleteButtonPressed.tiff differ diff --git a/frameworks/WebCore.framework/Versions/A/Resources/deleteButtonPressed@2x.png b/Atom/resources/deleteButtonPressed@2x.png old mode 100644 new mode 100755 similarity index 100% rename from frameworks/WebCore.framework/Versions/A/Resources/deleteButtonPressed@2x.png rename to Atom/resources/deleteButtonPressed@2x.png diff --git a/frameworks/WebCore.framework/Versions/A/Resources/eastResizeCursor.png b/Atom/resources/eastResizeCursor.png old mode 100644 new mode 100755 similarity index 100% rename from frameworks/WebCore.framework/Versions/A/Resources/eastResizeCursor.png rename to Atom/resources/eastResizeCursor.png diff --git a/frameworks/WebCore.framework/Versions/A/Resources/eastWestResizeCursor.png b/Atom/resources/eastWestResizeCursor.png old mode 100644 new mode 100755 similarity index 100% rename from frameworks/WebCore.framework/Versions/A/Resources/eastWestResizeCursor.png rename to Atom/resources/eastWestResizeCursor.png diff --git a/Atom/resources/en.lproj/locale.pak b/Atom/resources/en.lproj/locale.pak new file mode 100755 index 000000000..9425bdf36 Binary files /dev/null and b/Atom/resources/en.lproj/locale.pak differ diff --git a/frameworks/WebCore.framework/Versions/A/Resources/helpCursor.png b/Atom/resources/helpCursor.png old mode 100644 new mode 100755 similarity index 100% rename from frameworks/WebCore.framework/Versions/A/Resources/helpCursor.png rename to Atom/resources/helpCursor.png diff --git a/frameworks/WebCore.framework/Versions/A/Resources/inputSpeech.png b/Atom/resources/inputSpeech.png old mode 100644 new mode 100755 similarity index 100% rename from frameworks/WebCore.framework/Versions/A/Resources/inputSpeech.png rename to Atom/resources/inputSpeech.png diff --git a/Atom/resources/inputSpeech.tiff b/Atom/resources/inputSpeech.tiff new file mode 100755 index 000000000..11ba12959 Binary files /dev/null and b/Atom/resources/inputSpeech.tiff differ diff --git a/frameworks/WebCore.framework/Versions/A/Resources/linkCursor.png b/Atom/resources/linkCursor.png old mode 100644 new mode 100755 similarity index 100% rename from frameworks/WebCore.framework/Versions/A/Resources/linkCursor.png rename to Atom/resources/linkCursor.png diff --git a/frameworks/WebCore.framework/Versions/A/Resources/missingImage.png b/Atom/resources/missingImage.png old mode 100644 new mode 100755 similarity index 100% rename from frameworks/WebCore.framework/Versions/A/Resources/missingImage.png rename to Atom/resources/missingImage.png diff --git a/Atom/resources/missingImage.tiff b/Atom/resources/missingImage.tiff new file mode 100755 index 000000000..bfde916ea Binary files /dev/null and b/Atom/resources/missingImage.tiff differ diff --git a/frameworks/WebCore.framework/Versions/A/Resources/missingImage@2x.png b/Atom/resources/missingImage@2x.png old mode 100644 new mode 100755 similarity index 100% rename from frameworks/WebCore.framework/Versions/A/Resources/missingImage@2x.png rename to Atom/resources/missingImage@2x.png diff --git a/frameworks/WebCore.framework/Versions/A/Resources/moveCursor.png b/Atom/resources/moveCursor.png old mode 100644 new mode 100755 similarity index 100% rename from frameworks/WebCore.framework/Versions/A/Resources/moveCursor.png rename to Atom/resources/moveCursor.png diff --git a/frameworks/WebCore.framework/Versions/A/Resources/noDropCursor.png b/Atom/resources/noDropCursor.png old mode 100644 new mode 100755 similarity index 100% rename from frameworks/WebCore.framework/Versions/A/Resources/noDropCursor.png rename to Atom/resources/noDropCursor.png diff --git a/frameworks/WebCore.framework/Versions/A/Resources/noneCursor.png b/Atom/resources/noneCursor.png old mode 100644 new mode 100755 similarity index 100% rename from frameworks/WebCore.framework/Versions/A/Resources/noneCursor.png rename to Atom/resources/noneCursor.png diff --git a/frameworks/WebCore.framework/Versions/A/Resources/northEastResizeCursor.png b/Atom/resources/northEastResizeCursor.png old mode 100644 new mode 100755 similarity index 100% rename from frameworks/WebCore.framework/Versions/A/Resources/northEastResizeCursor.png rename to Atom/resources/northEastResizeCursor.png diff --git a/frameworks/WebCore.framework/Versions/A/Resources/northEastSouthWestResizeCursor.png b/Atom/resources/northEastSouthWestResizeCursor.png old mode 100644 new mode 100755 similarity index 100% rename from frameworks/WebCore.framework/Versions/A/Resources/northEastSouthWestResizeCursor.png rename to Atom/resources/northEastSouthWestResizeCursor.png diff --git a/frameworks/WebCore.framework/Versions/A/Resources/northResizeCursor.png b/Atom/resources/northResizeCursor.png old mode 100644 new mode 100755 similarity index 100% rename from frameworks/WebCore.framework/Versions/A/Resources/northResizeCursor.png rename to Atom/resources/northResizeCursor.png diff --git a/frameworks/WebCore.framework/Versions/A/Resources/northSouthResizeCursor.png b/Atom/resources/northSouthResizeCursor.png old mode 100644 new mode 100755 similarity index 100% rename from frameworks/WebCore.framework/Versions/A/Resources/northSouthResizeCursor.png rename to Atom/resources/northSouthResizeCursor.png diff --git a/frameworks/WebCore.framework/Versions/A/Resources/northWestResizeCursor.png b/Atom/resources/northWestResizeCursor.png old mode 100644 new mode 100755 similarity index 100% rename from frameworks/WebCore.framework/Versions/A/Resources/northWestResizeCursor.png rename to Atom/resources/northWestResizeCursor.png diff --git a/frameworks/WebCore.framework/Versions/A/Resources/northWestSouthEastResizeCursor.png b/Atom/resources/northWestSouthEastResizeCursor.png old mode 100644 new mode 100755 similarity index 100% rename from frameworks/WebCore.framework/Versions/A/Resources/northWestSouthEastResizeCursor.png rename to Atom/resources/northWestSouthEastResizeCursor.png diff --git a/Atom/resources/nullPlugin.png b/Atom/resources/nullPlugin.png new file mode 100755 index 000000000..a4195f67d Binary files /dev/null and b/Atom/resources/nullPlugin.png differ diff --git a/Atom/resources/nullPlugin@2x.png b/Atom/resources/nullPlugin@2x.png new file mode 100755 index 000000000..ccc40188a Binary files /dev/null and b/Atom/resources/nullPlugin@2x.png differ diff --git a/Atom/resources/panIcon.png b/Atom/resources/panIcon.png new file mode 100755 index 000000000..4ca8d7037 Binary files /dev/null and b/Atom/resources/panIcon.png differ diff --git a/frameworks/WebCore.framework/Versions/A/Resources/progressCursor.png b/Atom/resources/progressCursor.png old mode 100644 new mode 100755 similarity index 100% rename from frameworks/WebCore.framework/Versions/A/Resources/progressCursor.png rename to Atom/resources/progressCursor.png diff --git a/frameworks/WebCore.framework/Versions/A/Resources/southEastResizeCursor.png b/Atom/resources/southEastResizeCursor.png old mode 100644 new mode 100755 similarity index 100% rename from frameworks/WebCore.framework/Versions/A/Resources/southEastResizeCursor.png rename to Atom/resources/southEastResizeCursor.png diff --git a/frameworks/WebCore.framework/Versions/A/Resources/southResizeCursor.png b/Atom/resources/southResizeCursor.png old mode 100644 new mode 100755 similarity index 100% rename from frameworks/WebCore.framework/Versions/A/Resources/southResizeCursor.png rename to Atom/resources/southResizeCursor.png diff --git a/frameworks/WebCore.framework/Versions/A/Resources/southWestResizeCursor.png b/Atom/resources/southWestResizeCursor.png old mode 100644 new mode 100755 similarity index 100% rename from frameworks/WebCore.framework/Versions/A/Resources/southWestResizeCursor.png rename to Atom/resources/southWestResizeCursor.png diff --git a/frameworks/WebCore.framework/Versions/A/Resources/textAreaResizeCorner.png b/Atom/resources/textAreaResizeCorner.png old mode 100644 new mode 100755 similarity index 100% rename from frameworks/WebCore.framework/Versions/A/Resources/textAreaResizeCorner.png rename to Atom/resources/textAreaResizeCorner.png diff --git a/Atom/resources/textAreaResizeCorner.tiff b/Atom/resources/textAreaResizeCorner.tiff new file mode 100755 index 000000000..5eeab606a Binary files /dev/null and b/Atom/resources/textAreaResizeCorner.tiff differ diff --git a/frameworks/WebCore.framework/Versions/A/Resources/textAreaResizeCorner@2x.png b/Atom/resources/textAreaResizeCorner@2x.png old mode 100644 new mode 100755 similarity index 100% rename from frameworks/WebCore.framework/Versions/A/Resources/textAreaResizeCorner@2x.png rename to Atom/resources/textAreaResizeCorner@2x.png diff --git a/Atom/resources/urlIcon.png b/Atom/resources/urlIcon.png new file mode 100755 index 000000000..53cb35451 Binary files /dev/null and b/Atom/resources/urlIcon.png differ diff --git a/frameworks/WebCore.framework/Versions/A/Resources/verticalTextCursor.png b/Atom/resources/verticalTextCursor.png old mode 100644 new mode 100755 similarity index 100% rename from frameworks/WebCore.framework/Versions/A/Resources/verticalTextCursor.png rename to Atom/resources/verticalTextCursor.png diff --git a/frameworks/WebCore.framework/Versions/A/Resources/waitCursor.png b/Atom/resources/waitCursor.png old mode 100644 new mode 100755 similarity index 100% rename from frameworks/WebCore.framework/Versions/A/Resources/waitCursor.png rename to Atom/resources/waitCursor.png diff --git a/frameworks/WebCore.framework/Versions/A/Resources/westResizeCursor.png b/Atom/resources/westResizeCursor.png old mode 100644 new mode 100755 similarity index 100% rename from frameworks/WebCore.framework/Versions/A/Resources/westResizeCursor.png rename to Atom/resources/westResizeCursor.png diff --git a/frameworks/WebCore.framework/Versions/A/Resources/zoomInCursor.png b/Atom/resources/zoomInCursor.png old mode 100644 new mode 100755 similarity index 100% rename from frameworks/WebCore.framework/Versions/A/Resources/zoomInCursor.png rename to Atom/resources/zoomInCursor.png diff --git a/frameworks/WebCore.framework/Versions/A/Resources/zoomOutCursor.png b/Atom/resources/zoomOutCursor.png old mode 100644 new mode 100755 similarity index 100% rename from frameworks/WebCore.framework/Versions/A/Resources/zoomOutCursor.png rename to Atom/resources/zoomOutCursor.png diff --git a/Atom/src/Atom.h b/Atom/src/Atom.h new file mode 100755 index 000000000..b71f03a28 --- /dev/null +++ b/Atom/src/Atom.h @@ -0,0 +1,21 @@ +#import "BrowserDelegate.h" +#import "include/cef.h" +#import "include/cef_application_mac.h" + +class ClientHandler; + +@class AtomController; + +@interface Atom : NSApplication { + NSWindow *_hiddenWindow; + BOOL handlingSendEvent_; + CefRefPtr _clientHandler; +} + +- (void)open:(NSString *)path; +- (IBAction)runSpecs:(id)sender; + +@end + +// Returns the application settings based on command line arguments. +void AppGetSettings(CefSettings& settings); diff --git a/Atom/src/Atom.mm b/Atom/src/Atom.mm new file mode 100755 index 000000000..20b2eceae --- /dev/null +++ b/Atom/src/Atom.mm @@ -0,0 +1,120 @@ +#import "Atom.h" +#import "include/cef.h" +#import "AtomController.h" + +#import "native_handler.h" +#import "client_handler.h" + +// Provide the CefAppProtocol implementation required by CEF. +@implementation Atom + ++ (NSApplication *)sharedApplication { + if (!NSApp) { + // Populate the settings based on command line arguments. + CefSettings settings; + AppGetSettings(settings); + + // Initialize CEF. + CefRefPtr app; + CefInitialize(settings, app); + } + + return [super sharedApplication]; +} + +- (void)dealloc { + [_hiddenWindow release]; + [self dealloc]; +} + +- (BOOL)isHandlingSendEvent { + return handlingSendEvent_; +} + +- (void)setHandlingSendEvent:(BOOL)handlingSendEvent { + handlingSendEvent_ = handlingSendEvent; +} + +- (void)sendEvent:(NSEvent*)event { + CefScopedSendingEvent sendingEventScoper; + + if ([[self mainMenu] performKeyEquivalent:event]) return; + + if (_clientHandler && ![self keyWindow] && [event type] == NSKeyDown) { + [_hiddenWindow makeKeyAndOrderFront:self]; + [_hiddenWindow sendEvent:event]; + } + else { + [super sendEvent:event]; + } +} + +- (void)createAtomContext { + _clientHandler = new ClientHandler(self); + + CefWindowInfo window_info; + _hiddenWindow = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 0, 0) styleMask:nil backing:nil defer:YES]; + window_info.SetAsChild([_hiddenWindow contentView], 0, 0, 0, 0); + + CefBrowserSettings settings; + NSURL *resourceDirURL = [[NSBundle mainBundle] resourceURL]; + NSString *indexURLString = [[resourceDirURL URLByAppendingPathComponent:@"index.html"] absoluteString]; + CefBrowser::CreateBrowser(window_info, _clientHandler.get(), [indexURLString UTF8String], settings); + } + +- (void)open:(NSString *)path { + CefRefPtr atomContext = _clientHandler->GetBrowser()->GetMainFrame()->GetV8Context(); + [[AtomController alloc] initWithPath:path atomContext:atomContext]; +} + +- (IBAction)runSpecs:(id)sender { + CefRefPtr atomContext = _clientHandler->GetBrowser()->GetMainFrame()->GetV8Context(); + [[AtomController alloc] initSpecsWithAtomContext:atomContext]; +} + +- (void)applicationWillFinishLaunching:(NSNotification *)notification { + [self createAtomContext]; +} + +- (void)applicationWillTerminate:(NSNotification *)aNotification { + CefShutdown(); +} + +#pragma mark BrowserDelegate + +- (void)loadStart { + CefRefPtr context = _clientHandler->GetBrowser()->GetMainFrame()->GetV8Context(); + CefRefPtr global = context->GetGlobal(); + + context->Enter(); + + CefRefPtr bootstrapScript = CefV8Value::CreateString("atom-bootstrap"); + global->SetValue("$bootstrapScript", bootstrapScript, V8_PROPERTY_ATTRIBUTE_NONE); + + CefRefPtr nativeHandler = new NativeHandler(); + global->SetValue("$native", nativeHandler->m_object, V8_PROPERTY_ATTRIBUTE_NONE); + + CefRefPtr atom = CefV8Value::CreateObject(NULL); + global->SetValue("atom", atom, V8_PROPERTY_ATTRIBUTE_NONE); + + CefRefPtr loadPath = CefV8Value::CreateString(PROJECT_DIR); + atom->SetValue("loadPath", loadPath, V8_PROPERTY_ATTRIBUTE_NONE); + + context->Exit(); +} + +@end + +// Returns the application settings based on command line arguments. +void AppGetSettings(CefSettings& settings) { + CefString(&settings.cache_path) = ""; + CefString(&settings.user_agent) = ""; + CefString(&settings.product_version) = ""; + CefString(&settings.locale) = ""; + CefString(&settings.log_file) = ""; + CefString(&settings.javascript_flags) = ""; + + settings.log_severity = LOGSEVERITY_ERROR; + settings.local_storage_quota = 0; + settings.session_storage_quota = 0; +} diff --git a/Atom/src/AtomController.h b/Atom/src/AtomController.h new file mode 100644 index 000000000..fd630dc11 --- /dev/null +++ b/Atom/src/AtomController.h @@ -0,0 +1,28 @@ +#import + +#import "BrowserDelegate.h" +#import "include/cef.h" + +class ClientHandler; + +@interface AtomController : NSWindowController { + NSView *_webView; + NSString *_bootstrapScript; + NSString *_pathToOpen; + + CefRefPtr _atomContext; + CefRefPtr _clientHandler; +} + +- (id)initWithBootstrapScript:(NSString *)bootstrapScript atomContext:(CefRefPtr) context; +- (id)initWithPath:(NSString *)path atomContext:(CefRefPtr)atomContext; +- (id)initSpecsWithAtomContext:(CefRefPtr)atomContext; + +- (void)createBrowser; + +@property (nonatomic, retain) IBOutlet NSView *webView; + +@end + +// Returns the application browser settings based on command line arguments. +void AppGetBrowserSettings(CefBrowserSettings& settings); diff --git a/Atom/src/AtomController.mm b/Atom/src/AtomController.mm new file mode 100644 index 000000000..f07edbd2a --- /dev/null +++ b/Atom/src/AtomController.mm @@ -0,0 +1,170 @@ +#import "AtomController.h" + +#import "include/cef.h" +#import "client_handler.h" +#import "native_handler.h" + +@implementation AtomController + +@synthesize webView=_webView; + +- (void)dealloc { + [_bootstrapScript release]; + [_webView release]; + [_pathToOpen release]; + + [super dealloc]; +} + +- (id)initWithBootstrapScript:(NSString *)bootstrapScript atomContext:(CefRefPtr)atomContext { + self = [super initWithWindowNibName:@"ClientWindow"]; + _bootstrapScript = [bootstrapScript retain]; + _atomContext = atomContext; + + [self.window makeKeyAndOrderFront:nil]; + [self createBrowser]; + + return self; +} + +- (id)initWithPath:(NSString *)path atomContext:(CefRefPtr)atomContext { + _pathToOpen = [path retain]; + return [self initWithBootstrapScript:@"window-bootstrap" atomContext:atomContext]; +} + +- (id)initSpecsWithAtomContext:(CefRefPtr)atomContext { + return [self initWithBootstrapScript:@"spec-bootstrap" atomContext:atomContext]; +} + +- (void)windowDidLoad { + [self.window setDelegate:self]; + [self.window setReleasedWhenClosed:NO]; +} + +- (void)createBrowser { + _clientHandler = new ClientHandler(self); + + CefWindowInfo window_info; + CefBrowserSettings settings; + + AppGetBrowserSettings(settings); + + window_info.SetAsChild(self.webView, 0, 0, self.webView.bounds.size.width, self.webView.bounds.size.height); + + NSURL *resourceDirURL = [[NSBundle mainBundle] resourceURL]; + NSString *indexURLString = [[resourceDirURL URLByAppendingPathComponent:@"index.html"] absoluteString]; + CefBrowser::CreateBrowser(window_info, _clientHandler.get(), [indexURLString UTF8String], settings); +} + +#pragma mark BrowserDelegate + +- (void)loadStart { + CefRefPtr context = _clientHandler->GetBrowser()->GetMainFrame()->GetV8Context(); + CefRefPtr global = context->GetGlobal(); + + context->Enter(); + + CefRefPtr bootstrapScript = CefV8Value::CreateString([_bootstrapScript UTF8String]); + global->SetValue("$bootstrapScript", bootstrapScript, V8_PROPERTY_ATTRIBUTE_NONE); + + CefRefPtr nativeHandler = new NativeHandler(); + global->SetValue("$native", nativeHandler->m_object, V8_PROPERTY_ATTRIBUTE_NONE); + + CefRefPtr pathToOpen = _pathToOpen ? CefV8Value::CreateString([_pathToOpen UTF8String]) : CefV8Value::CreateNull(); + global->SetValue("$pathToOpen", pathToOpen, V8_PROPERTY_ATTRIBUTE_NONE); + + global->SetValue("atom", _atomContext->GetGlobal()->GetValue("atom"), V8_PROPERTY_ATTRIBUTE_NONE); + + context->Exit(); +} + +- (bool)keyEventOfType:(cef_handler_keyevent_type_t)type + code:(int)code + modifiers:(int)modifiers + isSystemKey:(bool)isSystemKey + isAfterJavaScript:(bool)isAfterJavaScript { + + if (isAfterJavaScript && type == KEYEVENT_RAWKEYDOWN && modifiers == KEY_META && code == 'R') { + _clientHandler->GetBrowser()->ReloadIgnoreCache(); + return YES; + } + + return NO; +} + +#pragma mark NSWindowDelegate + +- (BOOL)windowShouldClose:(id)window { + CefRefPtr context = _clientHandler->GetBrowser()->GetMainFrame()->GetV8Context(); + CefRefPtr global = context->GetGlobal(); + + context->Enter(); + + CefRefPtr atom = context->GetGlobal()->GetValue("atom"); + + CefRefPtr retval; + CefRefPtr exception; + CefV8ValueList arguments; + arguments.push_back(global); + + atom->GetValue("windowClosed")->ExecuteFunction(atom, arguments, retval, exception, true); + + context->Exit(); + + _clientHandler->GetBrowser()->CloseDevTools(); + + _atomContext = NULL; + _clientHandler = NULL; + + // Clean ourselves up after clearing the stack of anything that might have the window on it. + [self autorelease]; + + return YES; +} + +@end + +// Returns the application browser settings based on command line arguments. +void AppGetBrowserSettings(CefBrowserSettings& settings) { + CefString(&settings.default_encoding) = ""; + CefString(&settings.user_style_sheet_location) = ""; + + settings.drag_drop_disabled = false; + settings.load_drops_disabled = false; + settings.history_disabled = false; + settings.remote_fonts_disabled = false; + settings.encoding_detector_enabled = false; + settings.javascript_disabled = false; + settings.javascript_open_windows_disallowed = false; + settings.javascript_close_windows_disallowed = false; + settings.javascript_access_clipboard_disallowed = false; + settings.dom_paste_disabled = false; + settings.caret_browsing_enabled = false; + settings.java_disabled = true; + settings.plugins_disabled = true; + settings.universal_access_from_file_urls_allowed = true; + settings.file_access_from_file_urls_allowed = false; + settings.web_security_disabled = true; + settings.xss_auditor_enabled = false; + settings.image_load_disabled = false; + settings.shrink_standalone_images_to_fit = false; + settings.site_specific_quirks_disabled = false; + settings.text_area_resize_disabled = false; + settings.page_cache_disabled = false; + settings.tab_to_links_disabled = false; + settings.hyperlink_auditing_disabled = false; + settings.user_style_sheet_enabled = false; + settings.author_and_user_styles_disabled = false; + settings.local_storage_disabled = false; + settings.databases_disabled = false; + settings.application_cache_disabled = false; + settings.webgl_disabled = false; + settings.accelerated_compositing_enabled = false; + settings.threaded_compositing_enabled = false; + settings.accelerated_layers_disabled = false; + settings.accelerated_video_disabled = false; + settings.accelerated_2d_canvas_disabled = false; + settings.accelerated_drawing_disabled = false; + settings.accelerated_plugins_disabled = false; + settings.developer_tools_disabled = false; +} diff --git a/Atom/src/BrowserDelegate.h b/Atom/src/BrowserDelegate.h new file mode 100644 index 000000000..6d94f27be --- /dev/null +++ b/Atom/src/BrowserDelegate.h @@ -0,0 +1,11 @@ +#import +#import "include/cef.h" + +@protocol BrowserDelegate + +@optional +- (void)afterCreated; +- (void)loadStart; +- (bool)keyEventOfType:(cef_handler_keyevent_type_t)type code:(int)code modifiers:(int)modifiers isSystemKey:(bool)isSystemKey isAfterJavaScript:(bool)isAfterJavaScript; + +@end diff --git a/Atom/src/client_handler.h b/Atom/src/client_handler.h new file mode 100755 index 000000000..c03ec83ee --- /dev/null +++ b/Atom/src/client_handler.h @@ -0,0 +1,128 @@ +// 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 + +#import "include/cef.h" + +@class AtomController; + +// ClientHandler implementation. +class ClientHandler : public CefClient, + public CefLifeSpanHandler, + public CefLoadHandler, + public CefRequestHandler, + public CefDisplayHandler, + public CefFocusHandler, + public CefKeyboardHandler, + public CefPrintHandler, + public CefV8ContextHandler, + public CefDragHandler +{ +public: + ClientHandler(id delegate); + 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 GetFocusHandler() OVERRIDE + { return this; } + virtual CefRefPtr GetKeyboardHandler() OVERRIDE + { return this; } + virtual CefRefPtr GetPrintHandler() OVERRIDE + { return this; } + virtual CefRefPtr GetV8ContextHandler() OVERRIDE + { return this; } + virtual CefRefPtr GetDragHandler() OVERRIDE + { return this; } + + // CefLifeSpanHandler methods + virtual void OnAfterCreated(CefRefPtr browser) OVERRIDE; + virtual bool DoClose(CefRefPtr browser) OVERRIDE; + virtual void OnBeforeClose(CefRefPtr browser) OVERRIDE; + + // CefLoadHandler methods + virtual void OnLoadStart(CefRefPtr browser, + CefRefPtr frame) OVERRIDE; + virtual void OnLoadEnd(CefRefPtr browser, + CefRefPtr frame, + int httpStatusCode) OVERRIDE; + virtual bool OnLoadError(CefRefPtr browser, + CefRefPtr frame, + ErrorCode errorCode, + const CefString& failedUrl, + CefString& errorText) OVERRIDE; + + // CefRequestHandler methods + virtual bool OnBeforeResourceLoad(CefRefPtr browser, + CefRefPtr request, + CefString& redirectUrl, + CefRefPtr& resourceStream, + CefRefPtr response, + int loadFlags) OVERRIDE; + + + // CefDisplayHandler methods + virtual void OnNavStateChange(CefRefPtr browser, + bool canGoBack, + bool canGoForward) OVERRIDE; + virtual void OnTitleChange(CefRefPtr browser, + const CefString& title) OVERRIDE; + + // CefFocusHandler methods. + virtual void OnFocusedNodeChanged(CefRefPtr browser, + CefRefPtr frame, + CefRefPtr node) OVERRIDE; + + // CefKeyboardHandler methods. + virtual bool OnKeyEvent(CefRefPtr browser, + KeyEventType type, + int code, + int modifiers, + bool isSystemKey, + bool isAfterJavaScript) OVERRIDE; + + // CefV8ContextHandler methods + virtual void OnContextCreated(CefRefPtr browser, + CefRefPtr frame, + CefRefPtr context) OVERRIDE; + + // CefDragHandler methods. + virtual bool OnDragStart(CefRefPtr browser, + CefRefPtr dragData, + DragOperationsMask mask) OVERRIDE; + virtual bool OnDragEnter(CefRefPtr browser, + CefRefPtr dragData, + DragOperationsMask mask) OVERRIDE; + + CefRefPtr GetBrowser() { return m_Browser; } + CefWindowHandle GetBrowserHwnd() { return m_BrowserHwnd; } + +protected: + // The child browser window + CefRefPtr m_Browser; + + // The main frame window handle + CefWindowHandle m_MainHwnd; + + // The child browser window handle + CefWindowHandle m_BrowserHwnd; + + id m_delegate; + + // Include the default reference counting implementation. + IMPLEMENT_REFCOUNTING(ClientHandler); + // Include the default locking implementation. + IMPLEMENT_LOCKING(ClientHandler); +}; + +#endif // _CLIENT_HANDLER_H diff --git a/Atom/src/client_handler.mm b/Atom/src/client_handler.mm new file mode 100755 index 000000000..215ffdbc3 --- /dev/null +++ b/Atom/src/client_handler.mm @@ -0,0 +1,199 @@ +#import "include/cef.h" +#import "include/cef_wrapper.h" +#import "client_handler.h" +#import "AtomController.h" + +#import +#import +#import +#import + +#import + +#ifndef NDEBUG +#define ASSERT(condition) if(!(condition)) { assert(false); } +#else +#define ASSERT(condition) ((void)0) +#endif + +#define REQUIRE_UI_THREAD() ASSERT(CefCurrentlyOn(TID_UI)); +#define REQUIRE_IO_THREAD() ASSERT(CefCurrentlyOn(TID_IO)); +#define REQUIRE_FILE_THREAD() ASSERT(CefCurrentlyOn(TID_FILE)); + +ClientHandler::ClientHandler(id delegate) + : m_MainHwnd(NULL), + m_BrowserHwnd(NULL) +{ + m_delegate = delegate; +} + +ClientHandler::~ClientHandler() +{ +} + + +void ClientHandler::OnAfterCreated(CefRefPtr browser) +{ + REQUIRE_UI_THREAD(); + + AutoLock lock_scope(this); + if(!m_Browser.get()) + { + // We need to keep the main child window, but not popup windows + m_Browser = browser; + m_BrowserHwnd = browser->GetWindowHandle(); + + if ([m_delegate respondsToSelector:@selector(afterCreated)]) { + [m_delegate afterCreated]; + } + } +} + +bool ClientHandler::DoClose(CefRefPtr browser) +{ + REQUIRE_UI_THREAD(); + + return false; +} + +void ClientHandler::OnBeforeClose(CefRefPtr browser) +{ + REQUIRE_UI_THREAD(); + + if(m_BrowserHwnd == browser->GetWindowHandle()) { + // Free the browser pointer so that the browser can be destroyed + m_Browser = NULL; + } +} + +void ClientHandler::OnLoadStart(CefRefPtr browser, + CefRefPtr frame) +{ + REQUIRE_UI_THREAD(); + + if ([m_delegate respondsToSelector:@selector(loadStart)]) { + [m_delegate loadStart]; + } + +} + +void ClientHandler::OnLoadEnd(CefRefPtr browser, + CefRefPtr frame, + int httpStatusCode) +{ + REQUIRE_UI_THREAD(); +} + +bool ClientHandler::OnLoadError(CefRefPtr browser, + CefRefPtr frame, + ErrorCode errorCode, + const CefString& failedUrl, + CefString& errorText) +{ + REQUIRE_UI_THREAD(); + + if(errorCode == ERR_CACHE_MISS) { + // Usually caused by navigating to a page with POST data via back or + // forward buttons. + errorText = "Expired Form Data" + "

Expired Form Data

" + "

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

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

Load Failed

" + "

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

" + ""; + errorText = ss.str(); + } + + return false; +} + +void ClientHandler::OnNavStateChange(CefRefPtr browser, + bool canGoBack, + bool canGoForward) +{ + REQUIRE_UI_THREAD(); +} + + +void ClientHandler::OnFocusedNodeChanged(CefRefPtr browser, + CefRefPtr frame, + CefRefPtr node) +{ + REQUIRE_UI_THREAD(); + +} + +bool ClientHandler::OnKeyEvent(CefRefPtr browser, + KeyEventType type, + int code, + int modifiers, + bool isSystemKey, + bool isAfterJavaScript) +{ + REQUIRE_UI_THREAD(); + + if ([m_delegate respondsToSelector:@selector(keyEventOfType:code:modifiers:isSystemKey:isAfterJavaScript:)]) { + return [m_delegate keyEventOfType:type code:code modifiers:modifiers isSystemKey:isSystemKey isAfterJavaScript:isAfterJavaScript]; + } + else { + return false; + } +} + +void ClientHandler::OnContextCreated(CefRefPtr browser, + CefRefPtr frame, + CefRefPtr context) +{ + REQUIRE_UI_THREAD(); +} + +bool ClientHandler::OnDragStart(CefRefPtr browser, + CefRefPtr dragData, + DragOperationsMask mask) +{ + REQUIRE_UI_THREAD(); + + return false; +} + +bool ClientHandler::OnDragEnter(CefRefPtr browser, + CefRefPtr dragData, + DragOperationsMask mask) +{ + REQUIRE_UI_THREAD(); + + return false; +} + +bool ClientHandler::OnBeforeResourceLoad(CefRefPtr browser, + CefRefPtr request, + CefString& redirectUrl, + CefRefPtr& resourceStream, + CefRefPtr response, + int loadFlags) +{ + REQUIRE_IO_THREAD(); + + return false; +} + +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]; +} diff --git a/Atom/src/main.mm b/Atom/src/main.mm new file mode 100644 index 000000000..33cf2af3b --- /dev/null +++ b/Atom/src/main.mm @@ -0,0 +1,19 @@ +#import + +#include "include/cef.h" + +int main(int argc, char* argv[]) { + NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary]; + Class principalClass = NSClassFromString([infoDictionary objectForKey:@"NSPrincipalClass"]); + NSApplication *application = [principalClass sharedApplication]; + + NSString *mainNibName = [infoDictionary objectForKey:@"NSMainNibFile"]; + NSNib *mainNib = [[NSNib alloc] initWithNibNamed:mainNibName bundle:[NSBundle mainBundle]]; + [mainNib instantiateNibWithOwner:application topLevelObjects:nil]; + + // Run the application message loop. + CefRunMessageLoop(); + + // Don't put anything below this line because it won't be executed. + return 0; +} diff --git a/Atom/src/native_handler.h b/Atom/src/native_handler.h new file mode 100644 index 000000000..b94c62aba --- /dev/null +++ b/Atom/src/native_handler.h @@ -0,0 +1,18 @@ +#import "include/cef.h" +#import + +class NativeHandler : public CefV8Handler { +public: + NativeHandler(); + + CefRefPtr m_object; + + virtual bool Execute(const CefString& name, + CefRefPtr object, + const CefV8ValueList& arguments, + CefRefPtr& retval, + CefString& exception) OVERRIDE; + + // Provide the reference counting implementation for this class. + IMPLEMENT_REFCOUNTING(NativeHandler); +}; diff --git a/Atom/src/native_handler.mm b/Atom/src/native_handler.mm new file mode 100644 index 000000000..8bc51d0f5 --- /dev/null +++ b/Atom/src/native_handler.mm @@ -0,0 +1,258 @@ +#import "native_handler.h" +#import "include/cef.h" +#import "Atom.h" + +NSString *stringFromCefV8Value(const CefRefPtr& value) { + std::string cc_value = value->GetStringValue().ToString(); + return [NSString stringWithUTF8String:cc_value.c_str()]; +} + +NativeHandler::NativeHandler() : CefV8Handler() { + m_object = CefV8Value::CreateObject(NULL); + + const char *functionNames[] = {"exists", "read", "write", "absolute", "list", "isFile", "isDirectory", "remove", "asyncList", "open", "openDialog", "quit", "writeToPasteboard", "readFromPasteboard", "showDevTools", "newWindow", "saveDialog"}; + NSUInteger arrayLength = sizeof(functionNames) / sizeof(const char *); + for (NSUInteger i = 0; i < arrayLength; i++) { + const char *functionName = functionNames[i]; + CefRefPtr function = CefV8Value::CreateFunction(functionName, this); + m_object->SetValue(functionName, function, V8_PROPERTY_ATTRIBUTE_NONE); + } +} + + +bool NativeHandler::Execute(const CefString& name, + CefRefPtr object, + const CefV8ValueList& arguments, + CefRefPtr& retval, + CefString& exception) { + if (name == "exists") { + NSString *path = stringFromCefV8Value(arguments[0]); + bool exists = [[NSFileManager defaultManager] fileExistsAtPath:path isDirectory:nil]; + retval = CefV8Value::CreateBool(exists); + + return true; + } + else if (name == "read") { + NSString *path = stringFromCefV8Value(arguments[0]); + + NSError *error = nil; + NSString *contents = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:&error]; + + if (error) { + exception = [[error localizedDescription] UTF8String]; + } + else { + retval = CefV8Value::CreateString([contents UTF8String]); + } + + return true; + } + else if (name == "write") { + NSString *path = stringFromCefV8Value(arguments[0]); + NSString *content = stringFromCefV8Value(arguments[1]); + + + NSError *error = nil; + BOOL success = [content writeToFile:path atomically:YES encoding:NSUTF8StringEncoding error:&error]; + + if (error) { + exception = [[error localizedDescription] UTF8String]; + } + else if (!success) { + std::string exception = "Cannot write to '"; + exception += [path UTF8String]; + exception += "'"; + } + } + else if (name == "absolute") { + NSString *path = stringFromCefV8Value(arguments[0]); + + path = [path stringByStandardizingPath]; + if ([path characterAtIndex:0] == '/') { + retval = CefV8Value::CreateString([path UTF8String]); + } + + return true; + } + else if (name == "list") { + NSString *path = stringFromCefV8Value(arguments[0]); + bool recursive = arguments[1]->GetBoolValue(); + + NSFileManager *fm = [NSFileManager defaultManager]; + NSArray *relativePaths = [NSArray array]; + NSError *error = nil; + + if (recursive) { + relativePaths = [fm subpathsOfDirectoryAtPath:path error:&error]; + } + else { + relativePaths = [fm contentsOfDirectoryAtPath:path error:&error]; + } + + if (error) { + exception = [[error localizedDescription] UTF8String]; + } + else { + retval = CefV8Value::CreateArray(); + for (NSUInteger i = 0; i < relativePaths.count; i++) { + NSString *relativePath = [relativePaths objectAtIndex:i]; + NSString *fullPath = [path stringByAppendingPathComponent:relativePath]; + retval->SetValue(i, CefV8Value::CreateString([fullPath UTF8String])); + } + } + + return true; + } + else if (name == "isDirectory") { + NSString *path = stringFromCefV8Value(arguments[0]); + + BOOL isDir = false; + BOOL exists = [[NSFileManager defaultManager] fileExistsAtPath:path isDirectory:&isDir]; + retval = CefV8Value::CreateBool(exists && isDir); + + return true; + } + else if (name == "remove") { + NSString *path = stringFromCefV8Value(arguments[0]); + + NSError *error = nil; + [[NSFileManager defaultManager] removeItemAtPath:path error:&error]; + + if (error) { + exception = [[error localizedDescription] UTF8String]; + } + + return true; + } + else if (name == "asyncList") { + NSString *path = stringFromCefV8Value(arguments[0]); + bool recursive = arguments[1]->GetBoolValue(); + + NSFileManager *fm = [NSFileManager defaultManager]; + NSArray *relativePaths = [NSArray array]; + NSError *error = nil; + + if (recursive) { + relativePaths = [fm subpathsOfDirectoryAtPath:path error:&error]; + } + else { + relativePaths = [fm contentsOfDirectoryAtPath:path error:&error]; + } + + if (error) { + exception = [[error localizedDescription] UTF8String]; + } + else { + CefRefPtr paths = CefV8Value::CreateArray(); + for (NSUInteger i = 0; i < relativePaths.count; i++) { + NSString *relativePath = [relativePaths objectAtIndex:i]; + NSString *fullPath = [path stringByAppendingPathComponent:relativePath]; + paths->SetValue(i, CefV8Value::CreateString([fullPath UTF8String])); + } + + CefV8ValueList args; + args.push_back(paths); + CefRefPtr e; + arguments[2]->ExecuteFunction(arguments[2], args, retval, e, true); + if (e) exception = e->GetMessage(); + } + + return true; + } + else if (name == "alert") { + NSString *message = stringFromCefV8Value(arguments[0]); + NSString *detailedMessage = stringFromCefV8Value(arguments[1]); + CefRefPtr buttons = arguments[2]; + + NSAlert *alert = [[[NSAlert alloc] init] autorelease]; + [alert setMessageText:message]; + [alert setInformativeText:detailedMessage]; + + std::vector buttonTitles; + std::vector::iterator iter; + NSMutableDictionary *titleForTag = [NSMutableDictionary dictionary]; + + buttons->GetKeys(buttonTitles); + + for (iter = buttonTitles.begin(); iter != buttonTitles.end(); iter++) { + NSString *buttonTitle = [NSString stringWithUTF8String:(*iter).ToString().c_str()]; + NSButton *button = [alert addButtonWithTitle:buttonTitle]; + [titleForTag setObject:buttonTitle forKey:[NSNumber numberWithInt:button.tag]]; + } + + NSUInteger buttonTag = [alert runModal]; + const char *buttonTitle = [[titleForTag objectForKey:[NSNumber numberWithInt:buttonTag]] UTF8String]; + CefRefPtr callback = buttons->GetValue(buttonTitle); + + CefV8ValueList args; + CefRefPtr e; + callback->ExecuteFunction(callback , args, retval, e, true); + if (e) exception = e->GetMessage(); + + return true; + } + else if (name == "writeToPasteboard") { + NSString *text = stringFromCefV8Value(arguments[0]); + + NSPasteboard *pb = [NSPasteboard generalPasteboard]; + [pb declareTypes:[NSArray arrayWithObjects:NSStringPboardType, nil] owner:nil]; + [pb setString:text forType:NSStringPboardType]; + + return true; + } + else if (name == "readFromPasteboard") { + NSPasteboard *pb = [NSPasteboard generalPasteboard]; + NSArray *results = [pb readObjectsForClasses:[NSArray arrayWithObjects:[NSString class], nil] options:nil]; + if (results) { + retval = CefV8Value::CreateString([[results objectAtIndex:0] UTF8String]); + } + + return true; + } + else if (name == "openDialog") { + NSOpenPanel *panel = [NSOpenPanel openPanel]; + [panel setCanChooseDirectories:YES]; + if ([panel runModal] == NSFileHandlingPanelOKButton) { + NSURL *url = [[panel URLs] lastObject]; + retval = CefV8Value::CreateString([[url path] UTF8String]); + } + else { + retval = CefV8Value::CreateNull(); + } + + return true; + } + else if (name == "open") { + NSString *path = stringFromCefV8Value(arguments[0]); + [NSApp open:path]; + + return true; + } + else if (name == "newWindow") { + [NSApp open:nil]; + + return true; + } + else if (name == "saveDialog") { + NSSavePanel *panel = [NSSavePanel savePanel]; + if ([panel runModal] == NSFileHandlingPanelOKButton) { + NSURL *url = [panel URL]; + retval = CefV8Value::CreateString([[url path] UTF8String]); + } + else { + return CefV8Value::CreateNull(); + } + + return true; + } + else if (name == "quit") { + [NSApp terminate:nil]; + return true; + } + else if (name == "showDevTools") { + CefV8Context::GetCurrentContext()->GetBrowser()->ShowDevTools(); + return true; + } + + return false; +}; \ No newline at end of file diff --git a/Rakefile b/Rakefile index d2c5e3544..74cd0fa4c 100644 --- a/Rakefile +++ b/Rakefile @@ -8,7 +8,7 @@ task :build do dest = File.join(built_dir, contents_dir, "Resources") - %w(index.html src docs static extensions vendor spec).each do |dir| + %w(index.html src static vendor spec).each do |dir| rm_rf File.join(dest, dir) cp_r dir, File.join(dest, dir) end @@ -19,7 +19,8 @@ task :build do "http://coffeescript.org/ - (try `npm i -g coffee-script`)" end - sh "coffee -c #{dest}/src #{dest}/vendor #{dest}/extensions #{dest}/spec" + puts contents_dir + sh "coffee -c #{dest}/src #{dest}/vendor #{dest}/spec" end desc "Install the app in /Applications" diff --git a/Resources/.keep b/Resources/.keep deleted file mode 100644 index e69de29bb..000000000 diff --git a/cef/include/cef.h b/cef/include/cef.h new file mode 100755 index 000000000..a3a24bafe --- /dev/null +++ b/cef/include/cef.h @@ -0,0 +1,3975 @@ +// 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. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + + +#ifndef _CEF_H +#define _CEF_H + +#include +#include +#include +#include "internal/cef_build.h" +#include "internal/cef_ptr.h" +#include "internal/cef_types_wrappers.h" + +/// +// Bring in platform-specific definitions. +#if defined(OS_WIN) +#include "internal/cef_win.h" +#elif defined(OS_MACOSX) +#include "internal/cef_mac.h" +#elif defined(OS_LINUX) +#include "internal/cef_linux.h" +#endif + +class CefApp; +class CefBrowser; +class CefClient; +class CefContentFilter; +class CefCookieVisitor; +class CefDOMDocument; +class CefDOMEvent; +class CefDOMEventListener; +class CefDOMNode; +class CefDOMVisitor; +class CefDownloadHandler; +class CefDragData; +class CefFrame; +class CefPostData; +class CefPostDataElement; +class CefRequest; +class CefResponse; +class CefSchemeHandler; +class CefSchemeHandlerFactory; +class CefStorageVisitor; +class CefStreamReader; +class CefStreamWriter; +class CefTask; +class CefV8Context; +class CefV8Handler; +class CefV8Value; +class CefWebURLRequest; +class CefWebURLRequestClient; + +/// +// This function should be called on the main application thread to initialize +// CEF when the application is started. The |application| parameter may be +// empty. A return value of true indicates that it succeeded and false indicates +// that it failed. +/// +/*--cef(revision_check,optional_param=application)--*/ +bool CefInitialize(const CefSettings& settings, CefRefPtr application); + +/// +// This function should be called on the main application thread to shut down +// CEF before the application exits. +/// +/*--cef()--*/ +void CefShutdown(); + +/// +// Perform a single iteration of CEF message loop processing. This function is +// used to integrate the CEF message loop into an existing application message +// loop. Care must be taken to balance performance against excessive CPU usage. +// This function should only be called on the main application thread and only +// if CefInitialize() is called with a CefSettings.multi_threaded_message_loop +// value of false. This function will not block. +/// +/*--cef()--*/ +void CefDoMessageLoopWork(); + +/// +// Run the CEF message loop. Use this function instead of an application- +// provided message loop to get the best balance between performance and CPU +// usage. This function should only be called on the main application thread and +// only if CefInitialize() is called with a +// CefSettings.multi_threaded_message_loop value of false. This function will +// block until a quit message is received by the system. +/// +/*--cef()--*/ +void CefRunMessageLoop(); + +/// +// Quit the CEF message loop that was started by calling CefRunMessageLoop(). +// This function should only be called on the main application thread and only +// if CefRunMessageLoop() was used. +/// +/*--cef()--*/ +void CefQuitMessageLoop(); + +/// +// Register a new V8 extension with the specified JavaScript extension code and +// handler. Functions implemented by the handler are prototyped using the +// keyword 'native'. The calling of a native function is restricted to the scope +// in which the prototype of the native function is defined. This function may +// be called on any thread. +// +// Example JavaScript extension code: +//
+//   // create the 'example' global object if it doesn't already exist.
+//   if (!example)
+//     example = {};
+//   // create the 'example.test' global object if it doesn't already exist.
+//   if (!example.test)
+//     example.test = {};
+//   (function() {
+//     // Define the function 'example.test.myfunction'.
+//     example.test.myfunction = function() {
+//       // Call CefV8Handler::Execute() with the function name 'MyFunction'
+//       // and no arguments.
+//       native function MyFunction();
+//       return MyFunction();
+//     };
+//     // Define the getter function for parameter 'example.test.myparam'.
+//     example.test.__defineGetter__('myparam', function() {
+//       // Call CefV8Handler::Execute() with the function name 'GetMyParam'
+//       // and no arguments.
+//       native function GetMyParam();
+//       return GetMyParam();
+//     });
+//     // Define the setter function for parameter 'example.test.myparam'.
+//     example.test.__defineSetter__('myparam', function(b) {
+//       // Call CefV8Handler::Execute() with the function name 'SetMyParam'
+//       // and a single argument.
+//       native function SetMyParam();
+//       if(b) SetMyParam(b);
+//     });
+//
+//     // Extension definitions can also contain normal JavaScript variables
+//     // and functions.
+//     var myint = 0;
+//     example.test.increment = function() {
+//       myint += 1;
+//       return myint;
+//     };
+//   })();
+// 
+// Example usage in the page: +//
+//   // Call the function.
+//   example.test.myfunction();
+//   // Set the parameter.
+//   example.test.myparam = value;
+//   // Get the parameter.
+//   value = example.test.myparam;
+//   // Call another function.
+//   example.test.increment();
+// 
+/// +/*--cef(optional_param=handler)--*/ +bool CefRegisterExtension(const CefString& extension_name, + const CefString& javascript_code, + CefRefPtr handler); + +/// +// Register a custom scheme. This method should not be called for the built-in +// HTTP, HTTPS, FILE, FTP, ABOUT and DATA schemes. +// +// If |is_standard| is true the scheme will be treated as a standard scheme. +// Standard schemes are subject to URL canonicalization and parsing rules as +// defined in the Common Internet Scheme Syntax RFC 1738 Section 3.1 available +// at http://www.ietf.org/rfc/rfc1738.txt +// +// In particular, the syntax for standard scheme URLs must be of the form: +//
+//  [scheme]://[username]:[password]@[host]:[port]/[url-path]
+// 
+// Standard scheme URLs must have a host component that is a fully qualified +// domain name as defined in Section 3.5 of RFC 1034 [13] and Section 2.1 of RFC +// 1123. These URLs will be canonicalized to "scheme://host/path" in the +// simplest case and "scheme://username:password@host:port/path" in the most +// explicit case. For example, "scheme:host/path" and "scheme:///host/path" will +// both be canonicalized to "scheme://host/path". The origin of a standard +// scheme URL is the combination of scheme, host and port (i.e., +// "scheme://host:port" in the most explicit case). +// +// For non-standard scheme URLs only the "scheme:" component is parsed and +// canonicalized. The remainder of the URL will be passed to the handler as-is. +// For example, "scheme:///some%20text" will remain the same. Non-standard +// scheme URLs cannot be used as a target for form submission. +// +// If |is_local| is true the scheme will be treated as local (i.e., with the +// same security rules as those applied to "file" URLs). Normal pages cannot +// link to or access local URLs. Also, by default, local URLs can only perform +// XMLHttpRequest calls to the same URL (origin + path) that originated the +// request. To allow XMLHttpRequest calls from a local URL to other URLs with +// the same origin set the CefSettings.file_access_from_file_urls_allowed value +// to true. To allow XMLHttpRequest calls from a local URL to all origins set +// the CefSettings.universal_access_from_file_urls_allowed value to true. +// +// If |is_display_isolated| is true the scheme will be treated as display- +// isolated. This means that pages cannot display these URLs unless they are +// from the same scheme. For example, pages in another origin cannot create +// iframes or hyperlinks to URLs with this scheme. +// +// This function may be called on any thread. It should only be called once +// per unique |scheme_name| value. If |scheme_name| is already registered or if +// an error occurs this method will return false. +/// +/*--cef()--*/ +bool CefRegisterCustomScheme(const CefString& scheme_name, + bool is_standard, + bool is_local, + bool is_display_isolated); + +/// +// Register a scheme handler factory for the specified |scheme_name| and +// optional |domain_name|. An empty |domain_name| value for a standard scheme +// will cause the factory to match all domain names. The |domain_name| value +// will be ignored for non-standard schemes. If |scheme_name| is a built-in +// scheme and no handler is returned by |factory| then the built-in scheme +// handler factory will be called. If |scheme_name| is a custom scheme the +// CefRegisterCustomScheme() function should be called for that scheme. +// This function may be called multiple times to change or remove the factory +// that matches the specified |scheme_name| and optional |domain_name|. +// Returns false if an error occurs. This function may be called on any thread. +/// +/*--cef(optional_param=domain_name,optional_param=factory)--*/ +bool CefRegisterSchemeHandlerFactory(const CefString& scheme_name, + const CefString& domain_name, + CefRefPtr factory); + +/// +// Clear all registered scheme handler factories. Returns false on error. This +// function may be called on any thread. +/// +/*--cef()--*/ +bool CefClearSchemeHandlerFactories(); + +/// +// Add an entry to the cross-origin access whitelist. +// +// The same-origin policy restricts how scripts hosted from different origins +// (scheme + domain + port) can communicate. By default, scripts can only access +// resources with the same origin. Scripts hosted on the HTTP and HTTPS schemes +// (but no other schemes) can use the "Access-Control-Allow-Origin" header to +// allow cross-origin requests. For example, https://source.example.com can make +// XMLHttpRequest requests on http://target.example.com if the +// http://target.example.com request returns an "Access-Control-Allow-Origin: +// https://source.example.com" response header. +// +// Scripts in separate frames or iframes and hosted from the same protocol and +// domain suffix can execute cross-origin JavaScript if both pages set the +// document.domain value to the same domain suffix. For example, +// scheme://foo.example.com and scheme://bar.example.com can communicate using +// JavaScript if both domains set document.domain="example.com". +// +// This method is used to allow access to origins that would otherwise violate +// the same-origin policy. Scripts hosted underneath the fully qualified +// |source_origin| URL (like http://www.example.com) will be allowed access to +// all resources hosted on the specified |target_protocol| and |target_domain|. +// If |allow_target_subdomains| is true access will also be allowed to all +// subdomains of the target domain. +// +// This method cannot be used to bypass the restrictions on local or display +// isolated schemes. See the comments on CefRegisterCustomScheme for more +// information. +// +// This function may be called on any thread. Returns false if |source_origin| +// is invalid or the whitelist cannot be accessed. +/// +/*--cef()--*/ +bool CefAddCrossOriginWhitelistEntry(const CefString& source_origin, + const CefString& target_protocol, + const CefString& target_domain, + bool allow_target_subdomains); + +/// +// Remove an entry from the cross-origin access whitelist. Returns false if +// |source_origin| is invalid or the whitelist cannot be accessed. +/// +/*--cef()--*/ +bool CefRemoveCrossOriginWhitelistEntry(const CefString& source_origin, + const CefString& target_protocol, + const CefString& target_domain, + bool allow_target_subdomains); + +/// +// Remove all entries from the cross-origin access whitelist. Returns false if +// the whitelist cannot be accessed. +/// +/*--cef()--*/ +bool CefClearCrossOriginWhitelist(); + +typedef cef_thread_id_t CefThreadId; + +/// +// CEF maintains multiple internal threads that are used for handling different +// types of tasks. The UI thread creates the browser window and is used for all +// interaction with the WebKit rendering engine and V8 JavaScript engine (The +// UI thread will be the same as the main application thread if CefInitialize() +// is called with a CefSettings.multi_threaded_message_loop value of false.) The +// IO thread is used for handling schema and network requests. The FILE thread +// is used for the application cache and other miscellaneous activities. This +// function will return true if called on the specified thread. +/// +/*--cef()--*/ +bool CefCurrentlyOn(CefThreadId threadId); + +/// +// Post a task for execution on the specified thread. This function may be +// called on any thread. +/// +/*--cef()--*/ +bool CefPostTask(CefThreadId threadId, CefRefPtr task); + +/// +// Post a task for delayed execution on the specified thread. This function may +// be called on any thread. +/// +/*--cef()--*/ +bool CefPostDelayedTask(CefThreadId threadId, CefRefPtr task, + long delay_ms); + +/// +// Parse the specified |url| into its component parts. +// Returns false if the URL is empty or invalid. +/// +/*--cef()--*/ +bool CefParseURL(const CefString& url, + CefURLParts& parts); + +/// +// Creates a URL from the specified |parts|, which must contain a non-empty +// spec or a non-empty host and path (at a minimum), but not both. +// Returns false if |parts| isn't initialized as described. +/// +/*--cef()--*/ +bool CefCreateURL(const CefURLParts& parts, + CefString& url); + +/// +// Visit all cookies. The returned cookies are ordered by longest path, then by +// earliest creation date. Returns false if cookies cannot be accessed. +/// +/*--cef()--*/ +bool CefVisitAllCookies(CefRefPtr visitor); + +/// +// Visit a subset of cookies. The results are filtered by the given url scheme, +// host, domain and path. If |includeHttpOnly| is true HTTP-only cookies will +// also be included in the results. The returned cookies are ordered by longest +// path, then by earliest creation date. Returns false if cookies cannot be +// accessed. +/// +/*--cef()--*/ +bool CefVisitUrlCookies(const CefString& url, bool includeHttpOnly, + CefRefPtr visitor); + +/// +// Sets a cookie given a valid URL and explicit user-provided cookie attributes. +// This function expects each attribute to be well-formed. It will check for +// disallowed characters (e.g. the ';' character is disallowed within the cookie +// value attribute) and will return false without setting the cookie if such +// characters are found. This method must be called on the IO thread. +/// +/*--cef()--*/ +bool CefSetCookie(const CefString& url, const CefCookie& cookie); + +/// +// Delete all cookies that match the specified parameters. If both |url| and +// |cookie_name| are specified all host and domain cookies matching both values +// will be deleted. If only |url| is specified all host cookies (but not domain +// cookies) irrespective of path will be deleted. If |url| is empty all cookies +// for all hosts and domains will be deleted. Returns false if a non-empty +// invalid URL is specified or if cookies cannot be accessed. This method must +// be called on the IO thread. +/// +/*--cef(optional_param=url,optional_param=cookie_name)--*/ +bool CefDeleteCookies(const CefString& url, const CefString& cookie_name); + +/// +// Sets the directory path that will be used for storing cookie data. If |path| +// is empty data will be stored in memory only. By default the cookie path is +// the same as the cache path. Returns false if cookies cannot be accessed. +/// +/*--cef(optional_param=path)--*/ +bool CefSetCookiePath(const CefString& path); + + +typedef cef_storage_type_t CefStorageType; + +/// +// Visit storage of the specified type. If |origin| is non-empty only data +// matching that origin will be visited. If |key| is non-empty only data +// matching that key will be visited. Otherwise, all data for the storage +// type will be visited. Origin should be of the form scheme://domain. If no +// origin is specified only data currently in memory will be returned. Returns +// false if the storage cannot be accessed. +/// +/*--cef(optional_param=origin,optional_param=key)--*/ +bool CefVisitStorage(CefStorageType type, const CefString& origin, + const CefString& key, + CefRefPtr visitor); + +/// +// Sets storage of the specified type, origin, key and value. Returns false if +// storage cannot be accessed. This method must be called on the UI thread. +/// +/*--cef()--*/ +bool CefSetStorage(CefStorageType type, const CefString& origin, + const CefString& key, const CefString& value); + +/// +// Deletes all storage of the specified type. If |origin| is non-empty only data +// matching that origin will be cleared. If |key| is non-empty only data +// matching that key will be cleared. Otherwise, all data for the storage type +// will be cleared. Returns false if storage cannot be accessed. This method +// must be called on the UI thread. +/// +/*--cef(optional_param=origin,optional_param=key)--*/ +bool CefDeleteStorage(CefStorageType type, const CefString& origin, + const CefString& key); + +/// +// Sets the directory path that will be used for storing data of the specified +// type. Currently only the ST_LOCALSTORAGE type is supported by this method. +// If |path| is empty data will be stored in memory only. By default the storage +// path is the same as the cache path. Returns false if the storage cannot be +// accessed. +/// +/*--cef(optional_param=path)--*/ +bool CefSetStoragePath(CefStorageType type, const CefString& path); + + +/// +// Interface defining the reference count implementation methods. All framework +// classes must extend the CefBase class. +/// +class CefBase +{ +public: + /// + // The AddRef method increments the reference count for the object. It should + // be called for every new copy of a pointer to a given object. The resulting + // reference count value is returned and should be used for diagnostic/testing + // purposes only. + /// + virtual int AddRef() =0; + + /// + // The Release method decrements the reference count for the object. If the + // reference count on the object falls to 0, then the object should free + // itself from memory. The resulting reference count value is returned and + // should be used for diagnostic/testing purposes only. + /// + virtual int Release() =0; + + /// + // Return the current number of references. + /// + virtual int GetRefCt() =0; + +protected: + virtual ~CefBase() {} +}; + + +/// +// Class that implements atomic reference counting. +/// +class CefRefCount +{ +public: + CefRefCount() : refct_(0) {} + + /// + // Atomic reference increment. + /// + int AddRef() { + return CefAtomicIncrement(&refct_); + } + + /// + // Atomic reference decrement. Delete the object when no references remain. + /// + int Release() { + return CefAtomicDecrement(&refct_); + } + + /// + // Return the current number of references. + /// + int GetRefCt() { return refct_; } + +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 virtual CefBase +{ +public: + /// + // Method that will be executed. |threadId| is the thread executing the call. + /// + /*--cef()--*/ + virtual void Execute(CefThreadId threadId) =0; +}; + + +/// +// 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 virtual CefBase +{ +public: + /// + // Method that will be called once for each cookie. |count| is the 0-based + // index for the current cookie. |total| is the total number of cookies. + // Set |deleteCookie| to true to delete the cookie currently being visited. + // Return false to stop visiting cookies. This method may never be called if + // no cookies are found. + /// + /*--cef()--*/ + virtual bool Visit(const CefCookie& cookie, int count, int total, + bool& deleteCookie) =0; +}; + + +/// +// Interface to implement for visiting storage. The methods of this class will +// always be called on the UI thread. +/// +/*--cef(source=client)--*/ +class CefStorageVisitor : public virtual CefBase +{ +public: + /// + // Method that will be called once for each key/value data pair in storage. + // |count| is the 0-based index for the current pair. |total| is the total + // number of pairs. Set |deleteData| to true to delete the pair currently + // being visited. Return false to stop visiting pairs. This method may never + // be called if no data is found. + /// + /*--cef()--*/ + virtual bool Visit(CefStorageType type, const CefString& origin, + const CefString& key, const CefString& value, int count, + int total, bool& deleteData) =0; +}; + + +/// +// 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 virtual CefBase +{ +public: + typedef cef_key_type_t KeyType; + typedef cef_mouse_button_type_t MouseButtonType; + typedef cef_paint_element_type_t PaintElementType; + + /// + // 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. This method call will not block. + /// + /*--cef(optional_param=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|. This method should only be called on the UI thread. + /// + /*--cef(optional_param=url)--*/ + static CefRefPtr CreateBrowserSync(CefWindowInfo& windowInfo, + CefRefPtr client, + const CefString& url, + const CefBrowserSettings& settings); + + /// + // Call this method before destroying a contained browser window. This method + // performs any internal cleanup that may be needed before the browser window + // is destroyed. + /// + /*--cef()--*/ + virtual void ParentWindowWillClose() =0; + + /// + // Closes this browser window. + /// + /*--cef()--*/ + virtual void CloseBrowser() =0; + + /// + // Returns true if the browser can navigate backwards. + /// + /*--cef()--*/ + virtual bool CanGoBack() =0; + /// + // Navigate backwards. + /// + /*--cef()--*/ + virtual void GoBack() =0; + /// + // Returns true if the browser can navigate forwards. + /// + /*--cef()--*/ + virtual bool CanGoForward() =0; + /// + // Navigate forwards. + /// + /*--cef()--*/ + virtual void GoForward() =0; + /// + // Reload the current page. + /// + /*--cef()--*/ + virtual void Reload() =0; + /// + // Reload the current page ignoring any cached data. + /// + /*--cef()--*/ + virtual void ReloadIgnoreCache() =0; + /// + // Stop loading the page. + /// + /*--cef()--*/ + virtual void StopLoad() =0; + + /// + // Set focus for the browser window. If |enable| is true focus will be set to + // the window. Otherwise, focus will be removed. + /// + /*--cef()--*/ + virtual void SetFocus(bool enable) =0; + + /// + // Retrieve the window handle for this browser. + /// + /*--cef()--*/ + virtual CefWindowHandle GetWindowHandle() =0; + + /// + // Retrieve the window handle of the browser that opened this browser. Will + // return NULL for non-popup windows. This method can be used in combination + // with custom handling of modal windows. + /// + /*--cef()--*/ + virtual CefWindowHandle GetOpenerWindowHandle() =0; + + /// + // Returns true if the window is a popup window. + /// + /*--cef()--*/ + virtual bool IsPopup() =0; + + // Returns true if a document has been loaded in the browser. + /*--cef()--*/ + virtual bool HasDocument() =0; + + /// + // Returns the client for this browser. + /// + /*--cef()--*/ + virtual CefRefPtr GetClient() =0; + + /// + // Returns the main (top-level) frame for the browser window. + /// + /*--cef()--*/ + virtual CefRefPtr GetMainFrame() =0; + + /// + // Returns the focused frame for the browser window. This method should only + // be called on the UI thread. + /// + /*--cef()--*/ + virtual CefRefPtr GetFocusedFrame() =0; + + /// + // Returns the frame with the specified name, or NULL if not found. This + // method should only be called on the UI thread. + /// + /*--cef()--*/ + virtual CefRefPtr GetFrame(const CefString& name) =0; + + /// + // Returns the names of all existing frames. This method should only be called + // on the UI thread. + /// + /*--cef()--*/ + virtual void GetFrameNames(std::vector& names) =0; + + /// + // Search for |searchText|. |identifier| can be used to have multiple searches + // running simultaniously. |forward| indicates whether to search forward or + // backward within the page. |matchCase| indicates whether the search should + // be case-sensitive. |findNext| indicates whether this is the first request + // or a follow-up. + /// + /*--cef()--*/ + virtual void Find(int identifier, const CefString& searchText, + bool forward, bool matchCase, bool findNext) =0; + + /// + // Cancel all searches that are currently going on. + /// + /*--cef()--*/ + virtual void StopFinding(bool clearSelection) =0; + + /// + // Get the zoom level. + /// + /*--cef()--*/ + virtual double GetZoomLevel() =0; + + /// + // Change the zoom level to the specified value. + /// + /*--cef()--*/ + virtual void SetZoomLevel(double zoomLevel) =0; + + /// + // Clear the back/forward browsing history. + /// + /*--cef()--*/ + virtual void ClearHistory() =0; + + /// + // Open developer tools in its own window. + /// + /*--cef()--*/ + virtual void ShowDevTools() =0; + + /// + // Explicitly close the developer tools window if one exists for this browser + // instance. + /// + /*--cef()--*/ + virtual void CloseDevTools() =0; + + /// + // Returns true if window rendering is disabled. + /// + /*--cef()--*/ + virtual bool IsWindowRenderingDisabled() =0; + + /// + // Get the size of the specified element. This method should only be called on + // the UI thread. + /// + /*--cef()--*/ + virtual bool GetSize(PaintElementType type, int& width, int& height) =0; + + /// + // Set the size of the specified element. This method is only used when window + // rendering is disabled. + /// + /*--cef()--*/ + virtual void SetSize(PaintElementType type, int width, int height) =0; + + /// + // Returns true if a popup is currently visible. This method should only be + // called on the UI thread. + /// + /*--cef()--*/ + virtual bool IsPopupVisible() =0; + + /// + // Hide the currently visible popup, if any. + /// + /*--cef()--*/ + virtual void HidePopup() =0; + + /// + // Invalidate the |dirtyRect| region of the view. This method is only used + // when window rendering is disabled and will result in a call to + // HandlePaint(). + /// + /*--cef()--*/ + virtual void Invalidate(const CefRect& dirtyRect) =0; + + /// + // Get the raw image data contained in the specified element without + // performing validation. The specified |width| and |height| dimensions must + // match the current element size. On Windows |buffer| must be width*height*4 + // bytes in size and represents a BGRA image with an upper-left origin. This + // method should only be called on the UI thread. + /// + /*--cef()--*/ + virtual bool GetImage(PaintElementType type, int width, int height, + void* buffer) =0; + + /// + // Send a key event to the browser. + /// + /*--cef()--*/ + virtual void SendKeyEvent(KeyType type, int key, int modifiers, bool sysChar, + bool imeChar) =0; + + /// + // Send a mouse click event to the browser. The |x| and |y| coordinates are + // relative to the upper-left corner of the view. + /// + /*--cef()--*/ + virtual void SendMouseClickEvent(int x, int y, MouseButtonType type, + bool mouseUp, int clickCount) =0; + + /// + // Send a mouse move event to the browser. The |x| and |y| coordinates are + // relative to the upper-left corner of the view. + /// + /*--cef()--*/ + virtual void SendMouseMoveEvent(int x, int y, bool mouseLeave) =0; + + /// + // Send a mouse wheel event to the browser. The |x| and |y| coordinates are + // relative to the upper-left corner of the view. + /// + /*--cef()--*/ + virtual void SendMouseWheelEvent(int x, int y, int delta) =0; + + /// + // Send a focus event to the browser. + /// + /*--cef()--*/ + virtual void SendFocusEvent(bool setFocus) =0; + + /// + // Send a capture lost event to the browser. + /// + /*--cef()--*/ + virtual void SendCaptureLostEvent() =0; +}; + + +/// +// 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 virtual CefBase +{ +public: + /// + // Execute undo in this frame. + /// + /*--cef()--*/ + virtual void Undo() =0; + /// + // Execute redo in this frame. + /// + /*--cef()--*/ + virtual void Redo() =0; + /// + // Execute cut in this frame. + /// + /*--cef()--*/ + virtual void Cut() =0; + /// + // Execute copy in this frame. + /// + /*--cef()--*/ + virtual void Copy() =0; + /// + // Execute paste in this frame. + /// + /*--cef()--*/ + virtual void Paste() =0; + /// + // Execute delete in this frame. + /// + /*--cef(capi_name=del)--*/ + virtual void Delete() =0; + /// + // Execute select all in this frame. + /// + /*--cef()--*/ + virtual void SelectAll() =0; + + /// + // Execute printing in the this frame. The user will be prompted with the + // print dialog appropriate to the operating system. + /// + /*--cef()--*/ + virtual void Print() =0; + + /// + // Save this frame's HTML source to a temporary file and open it in the + // default text viewing application. + /// + /*--cef()--*/ + virtual void ViewSource() =0; + + /// + // Returns this frame's HTML source as a string. This method should only be + // called on the UI thread. + /// + /*--cef()--*/ + virtual CefString GetSource() =0; + + /// + // Returns this frame's display text as a string. This method should only be + // called on the UI thread. + /// + /*--cef()--*/ + virtual CefString GetText() =0; + + /// + // Load the request represented by the |request| object. + /// + /*--cef()--*/ + virtual void LoadRequest(CefRefPtr request) =0; + + /// + // Load the specified |url|. + /// + /*--cef()--*/ + virtual void LoadURL(const CefString& url) =0; + + /// + // Load the contents of |string| with the optional dummy target |url|. + /// + /*--cef()--*/ + virtual void LoadString(const CefString& string, + const CefString& url) =0; + + /// + // Load the contents of |stream| with the optional dummy target |url|. + /// + /*--cef()--*/ + virtual void LoadStream(CefRefPtr stream, + const CefString& url) =0; + + /// + // Execute a string of JavaScript code in this frame. The |script_url| + // parameter is the URL where the script in question can be found, if any. + // The renderer may request this URL to show the developer the source of the + // error. The |start_line| parameter is the base line number to use for error + // reporting. + /// + /*--cef(optional_param=scriptUrl)--*/ + virtual void ExecuteJavaScript(const CefString& jsCode, + const CefString& scriptUrl, + int startLine) =0; + + /// + // Returns true if this is the main (top-level) frame. + /// + /*--cef()--*/ + virtual bool IsMain() =0; + + /// + // Returns true if this is the focused frame. This method should only be + // called on the UI thread. + /// + /*--cef()--*/ + virtual bool IsFocused() =0; + + /// + // Returns the name for this frame. If the frame has an assigned name (for + // example, set via the iframe "name" attribute) then that value will be + // returned. Otherwise a unique name will be constructed based on the frame + // parent hierarchy. The main (top-level) frame will always have an empty name + // value. + /// + /*--cef()--*/ + virtual CefString GetName() =0; + + /// + // Returns the globally unique identifier for this frame. This method should + // only be called on the UI thread. + /// + /*--cef()--*/ + virtual long long GetIdentifier() =0; + + /// + // Returns the parent of this frame or NULL if this is the main (top-level) + // frame. This method should only be called on the UI thread. + /// + /*--cef()--*/ + virtual CefRefPtr GetParent() =0; + + /// + // Returns the URL currently loaded in this frame. This method should only be + // called on the UI thread. + /// + /*--cef()--*/ + virtual CefString GetURL() =0; + + /// + // Returns the browser that this frame belongs to. + /// + /*--cef()--*/ + virtual CefRefPtr GetBrowser() =0; + + /// + // Visit the DOM document. + /// + /*--cef()--*/ + virtual void VisitDOM(CefRefPtr visitor) =0; + + /// + // Get the V8 context associated with the frame. This method should only be + // called on the UI thread. + /// + /*--cef()--*/ + virtual CefRefPtr GetV8Context() =0; +}; + + +/// +// Implement this interface to handle proxy resolution events. +/// +/*--cef(source=client)--*/ +class CefProxyHandler : public virtual CefBase +{ +public: + /// + // Called to retrieve proxy information for the specified |url|. + /// + /*--cef()--*/ + virtual void GetProxyForUrl(const CefString& url, + CefProxyInfo& proxy_info) {} +}; + + +/// +// Implement this interface to provide handler implementations. +/// +/*--cef(source=client,no_debugct_check)--*/ +class CefApp : public virtual CefBase +{ +public: + /// + // Return the handler for proxy events. If not handler is returned the default + // system handler will be used. + /// + /*--cef()--*/ + virtual CefRefPtr GetProxyHandler() { return NULL; } +}; + + +/// +// 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 CefLifeSpanHandler : public virtual CefBase +{ +public: + /// + // 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(optional_param=url)--*/ + virtual bool OnBeforePopup(CefRefPtr parentBrowser, + const CefPopupFeatures& popupFeatures, + CefWindowInfo& windowInfo, + const CefString& url, + CefRefPtr& client, + CefBrowserSettings& settings) { return false; } + + /// + // Called after a new window is created. + /// + /*--cef()--*/ + virtual void OnAfterCreated(CefRefPtr browser) {} + + /// + // Called when a modal window is about to display and the modal loop should + // begin running. Return false to use the default modal loop implementation or + // true to use a custom implementation. + /// + /*--cef()--*/ + virtual bool RunModal(CefRefPtr browser) { return false; } + + /// + // Called when a window has recieved a request to close. Return false to + // proceed with the window close or true to cancel the window close. If this + // is a modal window and a custom modal loop implementation was provided in + // RunModal() this callback should be used to restore the opener window to a + // usable state. + /// + /*--cef()--*/ + virtual bool DoClose(CefRefPtr browser) { return false; } + + /// + // Called just before a window is closed. If this is a modal window and a + // custom modal loop implementation was provided in RunModal() this callback + // should be used to exit the custom modal loop. + /// + /*--cef()--*/ + virtual void OnBeforeClose(CefRefPtr browser) {} +}; + + +/// +// 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 void OnLoadStart(CefRefPtr browser, + CefRefPtr frame) {} + + /// + // 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 void OnLoadEnd(CefRefPtr browser, + CefRefPtr frame, + int httpStatusCode) {} + + /// + // 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. Return true to cancel + // the navigation or false to allow the navigation to proceed. + /// + /*--cef()--*/ + 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 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 bool OnBeforeResourceLoad(CefRefPtr browser, + CefRefPtr request, + CefString& redirectUrl, + CefRefPtr& resourceStream, + CefRefPtr response, + int loadFlags) { return false; } + + /// + // Called on the IO thread when a resource load is redirected. The |old_url| + // parameter will contain the old URL. The |new_url| parameter will contain + // the new URL and can be changed if desired. + /// + /*--cef()--*/ + virtual void OnResourceRedirect(CefRefPtr browser, + const CefString& old_url, + CefString& new_url) {} + + /// + // Called on the UI thread after a response to the resource request is + // received. Set |filter| if response content needs to be monitored and/or + // modified as it arrives. + /// + /*--cef()--*/ + virtual void OnResourceResponse(CefRefPtr browser, + const CefString& url, + CefRefPtr response, + CefRefPtr& filter) {} + + /// + // Called on the IO thread to handle requests for URLs with an unknown + // 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 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. + // |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 + // true to download the file or false to cancel the file download. + /// + /*--cef()--*/ + 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 + // true to handle the request. Return false to cancel the request. + /// + /*--cef(optional_param=realm)--*/ + virtual bool GetAuthCredentials(CefRefPtr browser, + bool isProxy, + const CefString& host, + int port, + const CefString& realm, + const CefString& scheme, + CefString& username, + CefString& password) { return false; } +}; + + +/// +// 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 when the navigation state has changed. + /// + /*--cef()--*/ + virtual void OnNavStateChange(CefRefPtr browser, + bool canGoBack, + bool canGoForward) {} + + /// + // Called when a frame's address has changed. + /// + /*--cef()--*/ + virtual void OnAddressChange(CefRefPtr browser, + CefRefPtr frame, + const CefString& url) {} + + /// + // Called when the size of the content area has changed. + /// + /*--cef()--*/ + virtual void OnContentsSizeChange(CefRefPtr browser, + CefRefPtr frame, + int width, + int height) {} + + /// + // Called when the page title changes. + /// + /*--cef(optional_param=title)--*/ + virtual void OnTitleChange(CefRefPtr browser, + const CefString& 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. Otherwise, you can optionally modify |text| + // and then return false to allow the browser to display the tooltip. + /// + /*--cef(optional_param=text)--*/ + 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(optional_param=value)--*/ + virtual void OnStatusMessage(CefRefPtr browser, + const CefString& value, + StatusType type) {} + + /// + // Called to display a console message. Return true to stop the message from + // being output to the console. + /// + /*--cef(optional_param=message,optional_param=source)--*/ + 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: + typedef cef_handler_focus_source_t FocusSource; + + /// + // 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. |source| indicates + // where the focus request is originating from. Return false to allow the + // focus to be set or true to cancel setting the focus. + /// + /*--cef()--*/ + virtual bool OnSetFocus(CefRefPtr browser, + FocusSource source) { return false; } + + /// + // Called when a new node in the the browser gets focus. The |node| value may + // be empty if no specific node has gained focus. The node object passed to + // this method represents a snapshot of the DOM at the time this method is + // executed. DOM objects are only valid for the scope of this method. Do not + // keep references to or attempt to access any DOM objects outside the scope + // of this method. + /// + /*--cef(optional_param=frame,optional_param=node)--*/ + virtual void OnFocusedNodeChanged(CefRefPtr browser, + CefRefPtr frame, + CefRefPtr node) {} +}; + + +/// +// 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. This method + // is called both before the event is passed to the renderer and after + // JavaScript in the page has had a chance to handle the 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). If + // |isAfterJavaScript| is true then JavaScript in the page has had a chance + // to handle the event and has chosen not to. Only RAWKEYDOWN, KEYDOWN and + // CHAR events will be sent with |isAfterJavaScript| set to true. Return + // true if the keyboard event was handled or false to allow continued handling + // of the event by the renderer. + /// + /*--cef()--*/ + virtual bool OnKeyEvent(CefRefPtr browser, + KeyEventType type, + int code, + int modifiers, + bool isSystemKey, + bool isAfterJavaScript) { 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_menu_id_t MenuId; + + /// + // 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 CefMenuInfo& 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: + /// + // 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 V8 context events. The methods of this +// class will be called on the UI thread. +/// +/*--cef(source=client)--*/ +class CefV8ContextHandler : public virtual CefBase +{ +public: + /// + // Called immediately after the V8 context for a frame has been created. To + // retrieve the JavaScript 'window' object use the CefV8Context::GetGlobal() + // method. + /// + /*--cef()--*/ + virtual void OnContextCreated(CefRefPtr browser, + CefRefPtr frame, + CefRefPtr context) {} + + /// + // Called immediately before the V8 context for a frame is released. No + // references to the context should be kept after this method is called. + /// + /*--cef()--*/ + virtual void OnContextReleased(CefRefPtr browser, + CefRefPtr frame, + CefRefPtr context) {} +}; + + +/// +// 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; + typedef std::vector RectList; + + /// + // Called to retrieve the view rectangle which is relative to screen + // coordinates. Return true if the rectangle was provided. + /// + /*--cef()--*/ + virtual bool GetViewRect(CefRefPtr browser, + CefRect& rect) { return false; } + + /// + // Called to retrieve the simulated screen rectangle. Return true if the + // rectangle was provided. + /// + /*--cef()--*/ + 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. |dirtyRects| contains the set of rectangles that need + // to be 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 RectList& dirtyRects, + const void* buffer) {} + + /// + // Called when the browser window's cursor has changed. + /// + /*--cef()--*/ + virtual void OnCursorChange(CefRefPtr browser, + CefCursorHandle cursor) {} +}; + + +/// +// Implement this interface to handle events related to dragging. The methods of +// this class will be called on the UI thread. +/// +/*--cef(source=client)--*/ +class CefDragHandler : public virtual CefBase +{ +public: + typedef cef_drag_operations_mask_t DragOperationsMask; + + /// + // Called when the browser window initiates a drag event. |dragData| + // contains the drag event data and |mask| represents the type of drag + // operation. Return false for default drag handling behavior or true to + // cancel the drag event. + /// + /*--cef()--*/ + virtual bool OnDragStart(CefRefPtr browser, + CefRefPtr dragData, + DragOperationsMask mask) { return false; } + + /// + // Called when an external drag event enters the browser window. |dragData| + // contains the drag event data and |mask| represents the type of drag + // operation. Return false for default drag handling behavior or true to + // cancel the drag event. + /// + /*--cef()--*/ + virtual bool OnDragEnter(CefRefPtr browser, + CefRefPtr dragData, + DragOperationsMask mask) { return false; } +}; + + +/// +// Implement this interface to provide handler implementations. +/// +/*--cef(source=client,no_debugct_check)--*/ +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 V8 context events. + /// + /*--cef()--*/ + virtual CefRefPtr GetV8ContextHandler() { return NULL; } + + /// + // Return the handler for off-screen rendering events. + /// + /*--cef()--*/ + virtual CefRefPtr GetRenderHandler() { return NULL; } + + /// + // Return the handler for drag events. + /// + /*--cef()--*/ + virtual CefRefPtr GetDragHandler() { 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 virtual CefBase +{ +public: + typedef std::multimap HeaderMap; + typedef cef_weburlrequest_flags_t RequestFlags; + + /// + // Create a new CefRequest object. + /// + /*--cef()--*/ + static CefRefPtr CreateRequest(); + + /// + // Get the fully qualified URL. + /// + /*--cef()--*/ + virtual CefString GetURL() =0; + /// + // Set the fully qualified URL. + /// + /*--cef()--*/ + virtual void SetURL(const CefString& url) =0; + + /// + // Get the request method type. The value will default to POST if post data + // is provided and GET otherwise. + /// + /*--cef()--*/ + virtual CefString GetMethod() =0; + /// + // Set the request method type. + /// + /*--cef()--*/ + virtual void SetMethod(const CefString& method) =0; + + /// + // Get the post data. + /// + /*--cef()--*/ + virtual CefRefPtr GetPostData() =0; + /// + // Set the post data. + /// + /*--cef()--*/ + virtual void SetPostData(CefRefPtr postData) =0; + + /// + // Get the header values. + /// + /*--cef()--*/ + virtual void GetHeaderMap(HeaderMap& headerMap) =0; + /// + // Set the header values. + /// + /*--cef()--*/ + virtual void SetHeaderMap(const HeaderMap& headerMap) =0; + + /// + // Set all values at one time. + /// + /*--cef(optional_param=postData)--*/ + virtual void Set(const CefString& url, + const CefString& method, + CefRefPtr postData, + const HeaderMap& headerMap) =0; + + /// + // Get the flags used in combination with CefWebURLRequest. + /// + /*--cef(default_retval=WUR_FLAG_NONE)--*/ + virtual RequestFlags GetFlags() =0; + /// + // Set the flags used in combination with CefWebURLRequest. + /// + /*--cef()--*/ + virtual void SetFlags(RequestFlags flags) =0; + + /// + // Set the URL to the first party for cookies used in combination with + // CefWebURLRequest. + /// + /*--cef()--*/ + virtual CefString GetFirstPartyForCookies() =0; + /// + // Get the URL to the first party for cookies used in combination with + // CefWebURLRequest. + /// + /*--cef()--*/ + virtual void SetFirstPartyForCookies(const CefString& url) =0; +}; + + +/// +// 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 virtual CefBase +{ +public: + typedef std::vector > ElementVector; + + /// + // Create a new CefPostData object. + /// + /*--cef()--*/ + static CefRefPtr CreatePostData(); + + /// + // Returns the number of existing post data elements. + /// + /*--cef()--*/ + virtual size_t GetElementCount() =0; + + /// + // Retrieve the post data elements. + /// + /*--cef(count_func=elements:GetElementCount)--*/ + virtual void GetElements(ElementVector& elements) =0; + + /// + // Remove the specified post data element. Returns true if the removal + // succeeds. + /// + /*--cef()--*/ + virtual bool RemoveElement(CefRefPtr element) =0; + + /// + // Add the specified post data element. Returns true if the add succeeds. + /// + /*--cef()--*/ + virtual bool AddElement(CefRefPtr element) =0; + + /// + // Remove all existing post data elements. + /// + /*--cef()--*/ + virtual void RemoveElements() =0; +}; + + +/// +// 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 virtual CefBase +{ +public: + /// + // Post data elements may represent either bytes or files. + /// + typedef cef_postdataelement_type_t Type; + + /// + // Create a new CefPostDataElement object. + /// + /*--cef()--*/ + static CefRefPtr CreatePostDataElement(); + + /// + // Remove all contents from the post data element. + /// + /*--cef()--*/ + virtual void SetToEmpty() =0; + + /// + // The post data element will represent a file. + /// + /*--cef()--*/ + virtual void SetToFile(const CefString& fileName) =0; + + /// + // The post data element will represent bytes. The bytes passed + // in will be copied. + /// + /*--cef()--*/ + virtual void SetToBytes(size_t size, const void* bytes) =0; + + /// + // Return the type of this post data element. + /// + /*--cef(default_retval=PDE_TYPE_EMPTY)--*/ + virtual Type GetType() =0; + + /// + // Return the file name. + /// + /*--cef()--*/ + virtual CefString GetFile() =0; + + /// + // Return the number of bytes. + /// + /*--cef()--*/ + virtual size_t GetBytesCount() =0; + + /// + // Read up to |size| bytes into |bytes| and return the number of bytes + // actually read. + /// + /*--cef()--*/ + virtual size_t GetBytes(size_t size, void* bytes) =0; +}; + + +/// +// Class used to represent a web response. The methods of this class may be +// called on any thread. +/// +/*--cef(source=library)--*/ +class CefResponse : public virtual CefBase +{ +public: + typedef std::multimap HeaderMap; + + /// + // Get the response status code. + /// + /*--cef()--*/ + virtual int GetStatus() =0; + /// + // Set the response status code. + /// + /*--cef()--*/ + virtual void SetStatus(int status) = 0; + + /// + // Get the response status text. + /// + /*--cef()--*/ + virtual CefString GetStatusText() =0; + /// + // Set the response status text. + /// + /*--cef()--*/ + virtual void SetStatusText(const CefString& statusText) = 0; + + /// + // Get the response mime type. + /// + /*--cef()--*/ + virtual CefString GetMimeType() = 0; + /// + // Set the response mime type. + /// + /*--cef()--*/ + virtual void SetMimeType(const CefString& mimeType) = 0; + + /// + // Get the value for the specified response header field. + /// + /*--cef()--*/ + virtual CefString GetHeader(const CefString& name) =0; + + /// + // Get all response header fields. + /// + /*--cef()--*/ + virtual void GetHeaderMap(HeaderMap& headerMap) =0; + /// + // Set all response header fields. + /// + /*--cef()--*/ + virtual void SetHeaderMap(const HeaderMap& headerMap) =0; +}; + + +/// +// 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 virtual CefBase +{ +public: + /// + // Read raw binary data. + /// + /*--cef()--*/ + virtual size_t Read(void* ptr, size_t size, size_t n) =0; + + /// + // Seek to the specified offset position. |whence| may be any one of + // SEEK_CUR, SEEK_END or SEEK_SET. + /// + /*--cef()--*/ + virtual int Seek(long offset, int whence) =0; + + /// + // Return the current offset position. + /// + /*--cef()--*/ + virtual long Tell() =0; + + /// + // Return non-zero if at end of file. + /// + /*--cef()--*/ + virtual int Eof() =0; +}; + + +/// +// 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 virtual CefBase +{ +public: + /// + // Create a new CefStreamReader object from a file. + /// + /*--cef()--*/ + static CefRefPtr CreateForFile(const CefString& fileName); + /// + // Create a new CefStreamReader object from data. + /// + /*--cef()--*/ + static CefRefPtr CreateForData(void* data, size_t size); + /// + // Create a new CefStreamReader object from a custom handler. + /// + /*--cef()--*/ + static CefRefPtr CreateForHandler( + CefRefPtr handler); + + /// + // Read raw binary data. + /// + /*--cef()--*/ + virtual size_t Read(void* ptr, size_t size, size_t n) =0; + + /// + // Seek to the specified offset position. |whence| may be any one of + // SEEK_CUR, SEEK_END or SEEK_SET. Returns zero on success and non-zero on + // failure. + /// + /*--cef()--*/ + virtual int Seek(long offset, int whence) =0; + + /// + // Return the current offset position. + /// + /*--cef()--*/ + virtual long Tell() =0; + + /// + // Return non-zero if at end of file. + /// + /*--cef()--*/ + virtual int Eof() =0; +}; + + +/// +// 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 virtual CefBase +{ +public: + /// + // Write raw binary data. + /// + /*--cef()--*/ + virtual size_t Write(const void* ptr, size_t size, size_t n) =0; + + /// + // Seek to the specified offset position. |whence| may be any one of + // SEEK_CUR, SEEK_END or SEEK_SET. + /// + /*--cef()--*/ + virtual int Seek(long offset, int whence) =0; + + /// + // Return the current offset position. + /// + /*--cef()--*/ + virtual long Tell() =0; + + /// + // Flush the stream. + /// + /*--cef()--*/ + virtual int Flush() =0; +}; + + +/// +// 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 virtual CefBase +{ +public: + /// + // Create a new CefStreamWriter object for a file. + /// + /*--cef()--*/ + static CefRefPtr CreateForFile(const CefString& fileName); + /// + // Create a new CefStreamWriter object for a custom handler. + /// + /*--cef()--*/ + static CefRefPtr CreateForHandler( + CefRefPtr handler); + + /// + // Write raw binary data. + /// + /*--cef()--*/ + virtual size_t Write(const void* ptr, size_t size, size_t n) =0; + + /// + // Seek to the specified offset position. |whence| may be any one of + // SEEK_CUR, SEEK_END or SEEK_SET. + /// + /*--cef()--*/ + virtual int Seek(long offset, int whence) =0; + + /// + // Return the current offset position. + /// + /*--cef()--*/ + virtual long Tell() =0; + + /// + // Flush the stream. + /// + /*--cef()--*/ + virtual int Flush() =0; +}; + + +/// +// Class that encapsulates a V8 context handle. +/// +/*--cef(source=library)--*/ +class CefV8Context : public virtual CefBase +{ +public: + /// + // Returns the current (top) context object in the V8 context stack. + /// + /*--cef()--*/ + static CefRefPtr GetCurrentContext(); + + /// + // Returns the entered (bottom) context object in the V8 context stack. + /// + /*--cef()--*/ + static CefRefPtr GetEnteredContext(); + + /// + // Returns true if V8 is currently inside a context. + /// + /*--cef()--*/ + static bool InContext(); + + /// + // Returns the browser for this context. + /// + /*--cef()--*/ + virtual CefRefPtr GetBrowser() =0; + + /// + // Returns the frame for this context. + /// + /*--cef()--*/ + virtual CefRefPtr GetFrame() =0; + + /// + // Returns the global object for this context. + /// + /*--cef()--*/ + virtual CefRefPtr GetGlobal() =0; + + /// + // Enter this context. A context must be explicitly entered before creating a + // V8 Object, Array or Function asynchronously. Exit() must be called the same + // number of times as Enter() before releasing this context. V8 objects belong + // to the context in which they are created. Returns true if the scope was + // entered successfully. + /// + /*--cef()--*/ + virtual bool Enter() =0; + + /// + // Exit this context. Call this method only after calling Enter(). Returns + // true if the scope was exited successfully. + /// + /*--cef()--*/ + virtual bool Exit() =0; + + /// + // Returns true if this object is pointing to the same handle as |that| + // object. + /// + /*--cef()--*/ + virtual bool IsSame(CefRefPtr that) =0; +}; + + +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 virtual CefBase +{ +public: + /// + // Handle execution of the function identified by |name|. |object| is the + // receiver ('this' object) of the function. |arguments| is the list of + // arguments passed to the function. If execution succeeds set |retval| to the + // function return value. If execution fails set |exception| to the exception + // that will be thrown. Return true if execution was handled. + /// + /*--cef()--*/ + virtual bool Execute(const CefString& name, + CefRefPtr object, + const CefV8ValueList& arguments, + CefRefPtr& retval, + CefString& exception) =0; +}; + +/// +// Interface that should be implemented to handle V8 accessor calls. Accessor +// 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 virtual CefBase +{ +public: + /// + // Handle retrieval the accessor value identified by |name|. |object| is the + // receiver ('this' object) of the accessor. If retrieval succeeds set + // |retval| to the return value. If retrieval fails set |exception| to the + // exception that will be thrown. Return true if accessor retrieval was + // handled. + /// + /*--cef()--*/ + virtual bool Get(const CefString& name, + const CefRefPtr object, + CefRefPtr& retval, + CefString& exception) =0; + + /// + // Handle assignment of the accessor value identified by |name|. |object| is + // the receiver ('this' object) of the accessor. |value| is the new value + // being assigned to the accessor. If assignment fails set |exception| to the + // exception that will be thrown. Return true if accessor assignment was + // handled. + /// + /*--cef()--*/ + virtual bool Set(const CefString& name, + const CefRefPtr object, + const CefRefPtr value, + CefString& exception) =0; +}; + +/// +// Class representing a V8 exception. +/// +/*--cef(source=library)--*/ +class CefV8Exception : public virtual CefBase +{ +public: + /// + // Returns the exception message. + /// + /*--cef()--*/ + virtual CefString GetMessage() =0; + + /// + // Returns the line of source code that the exception occurred within. + /// + /*--cef()--*/ + virtual CefString GetSourceLine() =0; + + /// + // Returns the resource name for the script from where the function causing + // the error originates. + /// + /*--cef()--*/ + virtual CefString GetScriptResourceName() =0; + + /// + // Returns the 1-based number of the line where the error occurred or 0 if the + // line number is unknown. + /// + /*--cef()--*/ + virtual int GetLineNumber() =0; + + /// + // Returns the index within the script of the first character where the error + // occurred. + /// + /*--cef()--*/ + virtual int GetStartPosition() =0; + + /// + // Returns the index within the script of the last character where the error + // occurred. + /// + /*--cef()--*/ + virtual int GetEndPosition() =0; + + /// + // Returns the index within the line of the first character where the error + // occurred. + /// + /*--cef()--*/ + virtual int GetStartColumn() =0; + + /// + // Returns the index within the line of the last character where the error + // occurred. + /// + /*--cef()--*/ + virtual int GetEndColumn() =0; +}; + +/// +// Class representing a V8 value. The methods of this class should only be +// called on the UI thread. +/// +/*--cef(source=library)--*/ +class CefV8Value : public virtual CefBase +{ +public: + typedef cef_v8_accesscontrol_t AccessControl; + typedef cef_v8_propertyattribute_t PropertyAttribute; + + /// + // Create a new CefV8Value object of type undefined. + /// + /*--cef()--*/ + static CefRefPtr CreateUndefined(); + /// + // Create a new CefV8Value object of type null. + /// + /*--cef()--*/ + static CefRefPtr CreateNull(); + /// + // Create a new CefV8Value object of type bool. + /// + /*--cef()--*/ + static CefRefPtr CreateBool(bool value); + /// + // Create a new CefV8Value object of type int. + /// + /*--cef()--*/ + static CefRefPtr CreateInt(int value); + /// + // Create a new CefV8Value object of type double. + /// + /*--cef()--*/ + static CefRefPtr CreateDouble(double value); + /// + // Create a new CefV8Value object of type Date. + /// + /*--cef()--*/ + static CefRefPtr CreateDate(const CefTime& date); + /// + // Create a new CefV8Value object of type string. + /// + /*--cef(optional_param=value)--*/ + static CefRefPtr CreateString(const CefString& value); + /// + // Create a new CefV8Value object of type object. This method should only be + // called from within the scope of a CefV8ContextHandler, CefV8Handler or + // CefV8Accessor callback, or in combination with calling Enter() and Exit() + // on a stored CefV8Context reference. + /// + /*--cef(optional_param=user_data)--*/ + static CefRefPtr CreateObject(CefRefPtr user_data); + /// + // Create a new CefV8Value object of type object with accessors. This method + // should only be called from within the scope of a CefV8ContextHandler, + // CefV8Handler or CefV8Accessor callback, or in combination with calling + // Enter() and Exit() on a stored CefV8Context reference. + /// + /*--cef(capi_name=cef_v8value_create_object_with_accessor, + optional_param=user_data,optional_param=accessor)--*/ + static CefRefPtr CreateObject(CefRefPtr user_data, + CefRefPtr accessor); + /// + // Create a new CefV8Value object of type array. This method should only be + // called from within the scope of a CefV8ContextHandler, CefV8Handler or + // CefV8Accessor callback, or in combination with calling Enter() and Exit() + // on a stored CefV8Context reference. + /// + /*--cef()--*/ + static CefRefPtr CreateArray(); + /// + // Create a new CefV8Value object of type function. This method should only be + // called from within the scope of a CefV8ContextHandler, CefV8Handler or + // CefV8Accessor callback, or in combination with calling Enter() and Exit() + // on a stored CefV8Context reference. + /// + /*--cef()--*/ + static CefRefPtr CreateFunction(const CefString& name, + CefRefPtr handler); + + /// + // True if the value type is undefined. + /// + /*--cef()--*/ + virtual bool IsUndefined() =0; + /// + // True if the value type is null. + /// + /*--cef()--*/ + virtual bool IsNull() =0; + /// + // True if the value type is bool. + /// + /*--cef()--*/ + virtual bool IsBool() =0; + /// + // True if the value type is int. + /// + /*--cef()--*/ + virtual bool IsInt() =0; + /// + // True if the value type is double. + /// + /*--cef()--*/ + virtual bool IsDouble() =0; + /// + // True if the value type is Date. + /// + /*--cef()--*/ + virtual bool IsDate() =0; + /// + // True if the value type is string. + /// + /*--cef()--*/ + virtual bool IsString() =0; + /// + // True if the value type is object. + /// + /*--cef()--*/ + virtual bool IsObject() =0; + /// + // True if the value type is array. + /// + /*--cef()--*/ + virtual bool IsArray() =0; + /// + // True if the value type is function. + /// + /*--cef()--*/ + virtual bool IsFunction() =0; + + /// + // Returns true if this object is pointing to the same handle as |that| + // object. + /// + /*--cef()--*/ + virtual bool IsSame(CefRefPtr that) =0; + + /// + // Return a bool value. The underlying data will be converted to if + // necessary. + /// + /*--cef()--*/ + virtual bool GetBoolValue() =0; + /// + // Return an int value. The underlying data will be converted to if + // necessary. + /// + /*--cef()--*/ + virtual int GetIntValue() =0; + /// + // Return a double value. The underlying data will be converted to if + // necessary. + /// + /*--cef()--*/ + virtual double GetDoubleValue() =0; + /// + // Return a Date value. The underlying data will be converted to if + // necessary. + /// + /*--cef()--*/ + virtual CefTime GetDateValue() =0; + /// + // Return a string value. The underlying data will be converted to if + // necessary. + /// + /*--cef()--*/ + virtual CefString GetStringValue() =0; + + + // OBJECT METHODS - These methods are only available on objects. Arrays and + // functions are also objects. String- and integer-based keys can be used + // interchangably with the framework converting between them as necessary. + + /// + // Returns true if the object has a value with the specified identifier. + /// + /*--cef(capi_name=has_value_bykey)--*/ + virtual bool HasValue(const CefString& key) =0; + /// + // Returns true if the object has a value with the specified identifier. + /// + /*--cef(capi_name=has_value_byindex,index_param=index)--*/ + virtual bool HasValue(int index) =0; + + /// + // Delete the value with the specified identifier. + /// + /*--cef(capi_name=delete_value_bykey)--*/ + virtual bool DeleteValue(const CefString& key) =0; + /// + // Delete the value with the specified identifier. + /// + /*--cef(capi_name=delete_value_byindex,index_param=index)--*/ + virtual bool DeleteValue(int index) =0; + + /// + // Returns the value with the specified identifier. + /// + /*--cef(capi_name=get_value_bykey)--*/ + virtual CefRefPtr GetValue(const CefString& key) =0; + /// + // Returns the value with the specified identifier. + /// + /*--cef(capi_name=get_value_byindex,index_param=index)--*/ + virtual CefRefPtr GetValue(int index) =0; + + /// + // Associate a value with the specified identifier. + /// + /*--cef(capi_name=set_value_bykey)--*/ + virtual bool SetValue(const CefString& key, CefRefPtr value, + PropertyAttribute attribute) =0; + /// + // Associate a value with the specified identifier. + /// + /*--cef(capi_name=set_value_byindex,index_param=index)--*/ + virtual bool SetValue(int index, CefRefPtr value) =0; + + /// + // Register an identifier whose access will be forwarded to the CefV8Accessor + // instance passed to CefV8Value::CreateObject(). + /// + /*--cef(capi_name=set_value_byaccessor)--*/ + virtual bool SetValue(const CefString& key, AccessControl settings, + PropertyAttribute attribute) =0; + + /// + // Read the keys for the object's values into the specified vector. Integer- + // based keys will also be returned as strings. + /// + /*--cef()--*/ + virtual bool GetKeys(std::vector& keys) =0; + + /// + // Returns the user data, if any, specified when the object was created. + /// + /*--cef()--*/ + virtual CefRefPtr GetUserData() =0; + + + // ARRAY METHODS - These methods are only available on arrays. + + /// + // Returns the number of elements in the array. + /// + /*--cef()--*/ + virtual int GetArrayLength() =0; + + + // FUNCTION METHODS - These methods are only available on functions. + + /// + // Returns the function name. + /// + /*--cef()--*/ + virtual CefString GetFunctionName() =0; + + /// + // Returns the function handler or NULL if not a CEF-created function. + /// + /*--cef()--*/ + virtual CefRefPtr GetFunctionHandler() =0; + + /// + // Execute the function using the current V8 context. This method should only + // be called from within the scope of a CefV8Handler or CefV8Accessor + // callback, or in combination with calling Enter() and Exit() on a stored + // CefV8Context reference. |object| is the receiver ('this' object) of the + // function. |arguments| is the list of arguments that will be passed to the + // function. If execution succeeds |retval| will be set to the function return + // value. If execution fails |exception| will be set to the exception that was + // thrown. If |rethrow_exception| is true any exception will also be re- + // thrown. This method returns false if called incorrectly. + /// + /*--cef(optional_param=object)--*/ + virtual bool ExecuteFunction(CefRefPtr object, + const CefV8ValueList& arguments, + CefRefPtr& retval, + CefRefPtr& exception, + bool rethrow_exception) =0; + + /// + // Execute the function using the specified V8 context. |object| is the + // receiver ('this' object) of the function. |arguments| is the list of + // arguments that will be passed to the function. If execution succeeds + // |retval| will be set to the function return value. If execution fails + // |exception| will be set to the exception that was thrown. If + // |rethrow_exception| is true any exception will also be re-thrown. This + // method returns false if called incorrectly. + /// + /*--cef(optional_param=object)--*/ + virtual bool ExecuteFunctionWithContext(CefRefPtr context, + CefRefPtr object, + const CefV8ValueList& arguments, + CefRefPtr& retval, + CefRefPtr& exception, + bool rethrow_exception) =0; +}; + + +/// +// Class that creates CefSchemeHandler instances. The methods of this class will +// always be called on the IO thread. +/// +/*--cef(source=client)--*/ +class CefSchemeHandlerFactory : public virtual CefBase +{ +public: + /// + // Return a new scheme handler instance to handle the request. |browser| will + // be the browser window that initiated the request. If the request was + // initiated using the CefWebURLRequest API |browser| will be NULL. + /// + /*--cef()--*/ + virtual CefRefPtr Create(CefRefPtr browser, + const CefString& scheme_name, + CefRefPtr request) =0; +}; + +/// +// Class used to facilitate asynchronous responses to custom scheme handler +// requests. The methods of this class may be called on any thread. +/// +/*--cef(source=library)--*/ +class CefSchemeHandlerCallback : public virtual CefBase +{ +public: + /// + // Notify that header information is now available for retrieval. + /// + /*--cef()--*/ + virtual void HeadersAvailable() =0; + + /// + // Notify that response data is now available for reading. + /// + /*--cef()--*/ + virtual void BytesAvailable() =0; + + /// + // Cancel processing of the request. + /// + /*--cef()--*/ + virtual void Cancel() =0; +}; + +/// +// Class used to implement a custom scheme handler interface. The methods of +// this class will always be called on the IO thread. +/// +/*--cef(source=client)--*/ +class CefSchemeHandler : public virtual CefBase +{ +public: + /// + // Begin processing the request. To handle the request return true and call + // HeadersAvailable() once the response header information is available + // (HeadersAvailable() can also be called from inside this method if header + // information is available immediately). To cancel the request return false. + /// + /*--cef()--*/ + virtual bool ProcessRequest(CefRefPtr request, + CefRefPtr callback) =0; + + /// + // Retrieve response header information. If the response length is not known + // set |response_length| to -1 and ReadResponse() will be called until it + // returns false. If the response length is known set |response_length| + // to a positive value and ReadResponse() will be called until it returns + // false or the specified number of bytes have been read. Use the |response| + // object to set the mime type, http status code and other optional header + // values. To redirect the request to a new URL set |redirectUrl| to the new + // URL. + /// + /*--cef()--*/ + virtual void GetResponseHeaders(CefRefPtr response, + int64& response_length, + CefString& redirectUrl) =0; + + /// + // Read response data. If data is available immediately copy up to + // |bytes_to_read| bytes into |data_out|, set |bytes_read| to the number of + // bytes copied, and return true. To read the data at a later time set + // |bytes_read| to 0, return true and call BytesAvailable() when the data is + // available. To indicate response completion return false. + /// + /*--cef()--*/ + virtual bool ReadResponse(void* data_out, + int bytes_to_read, + int& bytes_read, + CefRefPtr callback) =0; + + /// + // Request processing has been canceled. + /// + /*--cef()--*/ + virtual void Cancel() =0; +}; + + +/// +// 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 virtual CefBase +{ +public: + /// + // A portion of the file contents have been received. This method will be + // called multiple times until the download is complete. Return |true| to + // continue receiving data and |false| to cancel. + /// + /*--cef()--*/ + virtual bool ReceivedData(void* data, int data_size) =0; + + /// + // The download is complete. + /// + /*--cef()--*/ + virtual void Complete() =0; +}; + + +/// +// Class used to make a Web URL request. Web URL requests are not associated +// 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 virtual CefBase +{ +public: + typedef cef_weburlrequest_state_t RequestState; + + /// + // Create a new CefWebUrlRequest object. + /// + /*--cef()--*/ + static CefRefPtr CreateWebURLRequest( + CefRefPtr request, + CefRefPtr client); + + /// + // Cancels the request. + /// + /*--cef()--*/ + virtual void Cancel() =0; + + /// + // Returns the current ready state of the request. + /// + /*--cef(default_retval=WUR_STATE_UNSENT)--*/ + virtual RequestState GetState() =0; +}; + +/// +// 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 virtual CefBase +{ +public: + typedef cef_weburlrequest_state_t RequestState; + typedef cef_handler_errorcode_t ErrorCode; + + /// + // Notifies the client that the request state has changed. State change + // notifications will always be sent before the below notification methods + // are called. + /// + /*--cef()--*/ + virtual void OnStateChange(CefRefPtr requester, + RequestState state) =0; + + /// + // Notifies the client that the request has been redirected and provides a + // chance to change the request parameters. + /// + /*--cef()--*/ + virtual void OnRedirect(CefRefPtr requester, + CefRefPtr request, + CefRefPtr response) =0; + + /// + // Notifies the client of the response data. + /// + /*--cef()--*/ + virtual void OnHeadersReceived(CefRefPtr requester, + CefRefPtr response) =0; + + /// + // Notifies the client of the upload progress. + /// + /*--cef()--*/ + virtual void OnProgress(CefRefPtr requester, + uint64 bytesSent, uint64 totalBytesToBeSent) =0; + + /// + // Notifies the client that content has been received. + /// + /*--cef()--*/ + virtual void OnData(CefRefPtr requester, + const void* data, int dataLength) =0; + + /// + // Notifies the client that the request ended with an error. + /// + /*--cef()--*/ + virtual void OnError(CefRefPtr requester, + ErrorCode errorCode) =0; +}; + + +/// +// Class that supports the reading of XML data via the libxml streaming API. +// The methods of this class should only be called on the thread that creates +// the object. +/// +/*--cef(source=library)--*/ +class CefXmlReader : public virtual CefBase +{ +public: + typedef cef_xml_encoding_type_t EncodingType; + typedef cef_xml_node_type_t NodeType; + + /// + // Create a new CefXmlReader object. The returned object's methods can only + // be called from the thread that created the object. + /// + /*--cef()--*/ + static CefRefPtr Create(CefRefPtr stream, + EncodingType encodingType, + const CefString& URI); + + /// + // Moves the cursor to the next node in the document. This method must be + // called at least once to set the current cursor position. Returns true if + // the cursor position was set successfully. + /// + /*--cef()--*/ + virtual bool MoveToNextNode() =0; + + /// + // Close the document. This should be called directly to ensure that cleanup + // occurs on the correct thread. + /// + /*--cef()--*/ + virtual bool Close() =0; + + /// + // Returns true if an error has been reported by the XML parser. + /// + /*--cef()--*/ + virtual bool HasError() =0; + + /// + // Returns the error string. + /// + /*--cef()--*/ + virtual CefString GetError() =0; + + + // The below methods retrieve data for the node at the current cursor + // position. + + /// + // Returns the node type. + /// + /*--cef(default_retval=XML_NODE_UNSUPPORTED)--*/ + virtual NodeType GetType() =0; + + /// + // Returns the node depth. Depth starts at 0 for the root node. + /// + /*--cef()--*/ + virtual int GetDepth() =0; + + /// + // Returns the local name. See + // http://www.w3.org/TR/REC-xml-names/#NT-LocalPart for additional details. + /// + /*--cef()--*/ + virtual CefString GetLocalName() =0; + + /// + // Returns the namespace prefix. See http://www.w3.org/TR/REC-xml-names/ for + // additional details. + /// + /*--cef()--*/ + virtual CefString GetPrefix() =0; + + /// + // Returns the qualified name, equal to (Prefix:)LocalName. See + // http://www.w3.org/TR/REC-xml-names/#ns-qualnames for additional details. + /// + /*--cef()--*/ + virtual CefString GetQualifiedName() =0; + + /// + // Returns the URI defining the namespace associated with the node. See + // http://www.w3.org/TR/REC-xml-names/ for additional details. + /// + /*--cef()--*/ + virtual CefString GetNamespaceURI() =0; + + /// + // Returns the base URI of the node. See http://www.w3.org/TR/xmlbase/ for + // additional details. + /// + /*--cef()--*/ + virtual CefString GetBaseURI() =0; + + /// + // Returns the xml:lang scope within which the node resides. See + // http://www.w3.org/TR/REC-xml/#sec-lang-tag for additional details. + /// + /*--cef()--*/ + virtual CefString GetXmlLang() =0; + + /// + // Returns true if the node represents an empty element. is considered + // empty but is not. + /// + /*--cef()--*/ + virtual bool IsEmptyElement() =0; + + /// + // Returns true if the node has a text value. + /// + /*--cef()--*/ + virtual bool HasValue() =0; + + /// + // Returns the text value. + /// + /*--cef()--*/ + virtual CefString GetValue() =0; + + /// + // Returns true if the node has attributes. + /// + /*--cef()--*/ + virtual bool HasAttributes() =0; + + /// + // Returns the number of attributes. + /// + /*--cef()--*/ + virtual size_t GetAttributeCount() =0; + + /// + // Returns the value of the attribute at the specified 0-based index. + /// + /*--cef(capi_name=get_attribute_byindex,index_param=index)--*/ + virtual CefString GetAttribute(int index) =0; + + /// + // Returns the value of the attribute with the specified qualified name. + /// + /*--cef(capi_name=get_attribute_byqname)--*/ + virtual CefString GetAttribute(const CefString& qualifiedName) =0; + + /// + // Returns the value of the attribute with the specified local name and + // namespace URI. + /// + /*--cef(capi_name=get_attribute_bylname)--*/ + virtual CefString GetAttribute(const CefString& localName, + const CefString& namespaceURI) =0; + + /// + // Returns an XML representation of the current node's children. + /// + /*--cef()--*/ + virtual CefString GetInnerXml() =0; + + /// + // Returns an XML representation of the current node including its children. + /// + /*--cef()--*/ + virtual CefString GetOuterXml() =0; + + /// + // Returns the line number for the current node. + /// + /*--cef()--*/ + virtual int GetLineNumber() =0; + + + // Attribute nodes are not traversed by default. The below methods can be + // used to move the cursor to an attribute node. MoveToCarryingElement() can + // be called afterwards to return the cursor to the carrying element. The + // depth of an attribute node will be 1 + the depth of the carrying element. + + /// + // Moves the cursor to the attribute at the specified 0-based index. Returns + // true if the cursor position was set successfully. + /// + /*--cef(capi_name=move_to_attribute_byindex,index_param=index)--*/ + virtual bool MoveToAttribute(int index) =0; + + /// + // Moves the cursor to the attribute with the specified qualified name. + // Returns true if the cursor position was set successfully. + /// + /*--cef(capi_name=move_to_attribute_byqname)--*/ + virtual bool MoveToAttribute(const CefString& qualifiedName) =0; + + /// + // Moves the cursor to the attribute with the specified local name and + // namespace URI. Returns true if the cursor position was set successfully. + /// + /*--cef(capi_name=move_to_attribute_bylname)--*/ + virtual bool MoveToAttribute(const CefString& localName, + const CefString& namespaceURI) =0; + + /// + // Moves the cursor to the first attribute in the current element. Returns + // true if the cursor position was set successfully. + /// + /*--cef()--*/ + virtual bool MoveToFirstAttribute() =0; + + /// + // Moves the cursor to the next attribute in the current element. Returns + // true if the cursor position was set successfully. + /// + /*--cef()--*/ + virtual bool MoveToNextAttribute() =0; + + /// + // Moves the cursor back to the carrying element. Returns true if the cursor + // position was set successfully. + /// + /*--cef()--*/ + virtual bool MoveToCarryingElement() =0; +}; + + +/// +// Class that supports the reading of zip archives via the zlib unzip API. +// The methods of this class should only be called on the thread that creates +// the object. +/// +/*--cef(source=library)--*/ +class CefZipReader : public virtual CefBase +{ +public: + /// + // Create a new CefZipReader object. The returned object's methods can only + // be called from the thread that created the object. + /// + /*--cef()--*/ + static CefRefPtr Create(CefRefPtr stream); + + /// + // Moves the cursor to the first file in the archive. Returns true if the + // cursor position was set successfully. + /// + /*--cef()--*/ + virtual bool MoveToFirstFile() =0; + + /// + // Moves the cursor to the next file in the archive. Returns true if the + // cursor position was set successfully. + /// + /*--cef()--*/ + virtual bool MoveToNextFile() =0; + + /// + // Moves the cursor to the specified file in the archive. If |caseSensitive| + // is true then the search will be case sensitive. Returns true if the cursor + // position was set successfully. + /// + /*--cef()--*/ + virtual bool MoveToFile(const CefString& fileName, bool caseSensitive) =0; + + /// + // Closes the archive. This should be called directly to ensure that cleanup + // occurs on the correct thread. + /// + /*--cef()--*/ + virtual bool Close() =0; + + + // The below methods act on the file at the current cursor position. + + /// + // Returns the name of the file. + /// + /*--cef()--*/ + virtual CefString GetFileName() =0; + + /// + // Returns the uncompressed size of the file. + /// + /*--cef()--*/ + virtual long GetFileSize() =0; + + /// + // Returns the last modified timestamp for the file. + /// + /*--cef()--*/ + virtual time_t GetFileLastModified() =0; + + /// + // Opens the file for reading of uncompressed data. A read password may + // optionally be specified. + /// + /*--cef(optional_param=password)--*/ + virtual bool OpenFile(const CefString& password) =0; + + /// + // Closes the file. + /// + /*--cef()--*/ + virtual bool CloseFile() =0; + + /// + // Read uncompressed file contents into the specified buffer. Returns < 0 if + // an error occurred, 0 if at the end of file, or the number of bytes read. + /// + /*--cef()--*/ + virtual int ReadFile(void* buffer, size_t bufferSize) =0; + + /// + // Returns the current offset in the uncompressed file contents. + /// + /*--cef()--*/ + virtual long Tell() =0; + + /// + // Returns true if at end of the file contents. + /// + /*--cef()--*/ + virtual bool Eof() =0; +}; + + +/// +// 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 virtual CefBase +{ +public: + /// + // Method executed for visiting the DOM. The document object passed to this + // method represents a snapshot of the DOM at the time this method is + // executed. DOM objects are only valid for the scope of this method. Do not + // keep references to or attempt to access any DOM objects outside the scope + // of this method. + /// + /*--cef()--*/ + virtual void Visit(CefRefPtr document) =0; +}; + + +/// +// 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 virtual CefBase +{ +public: + typedef cef_dom_document_type_t Type; + + /// + // Returns the document type. + /// + /*--cef(default_retval=DOM_DOCUMENT_TYPE_UNKNOWN)--*/ + virtual Type GetType() =0; + + /// + // Returns the root document node. + /// + /*--cef()--*/ + virtual CefRefPtr GetDocument() =0; + + /// + // Returns the BODY node of an HTML document. + /// + /*--cef()--*/ + virtual CefRefPtr GetBody() =0; + + /// + // Returns the HEAD node of an HTML document. + /// + /*--cef()--*/ + virtual CefRefPtr GetHead() =0; + + /// + // Returns the title of an HTML document. + /// + /*--cef()--*/ + virtual CefString GetTitle() =0; + + /// + // Returns the document element with the specified ID value. + /// + /*--cef()--*/ + virtual CefRefPtr GetElementById(const CefString& id) =0; + + /// + // Returns the node that currently has keyboard focus. + /// + /*--cef()--*/ + virtual CefRefPtr GetFocusedNode() =0; + + /// + // Returns true if a portion of the document is selected. + /// + /*--cef()--*/ + virtual bool HasSelection() =0; + + /// + // Returns the selection start node. + /// + /*--cef()--*/ + virtual CefRefPtr GetSelectionStartNode() =0; + + /// + // Returns the selection offset within the start node. + /// + /*--cef()--*/ + virtual int GetSelectionStartOffset() =0; + + /// + // Returns the selection end node. + /// + /*--cef()--*/ + virtual CefRefPtr GetSelectionEndNode() =0; + + /// + // Returns the selection offset within the end node. + /// + /*--cef()--*/ + virtual int GetSelectionEndOffset() =0; + + /// + // Returns the contents of this selection as markup. + /// + /*--cef()--*/ + virtual CefString GetSelectionAsMarkup() =0; + + /// + // Returns the contents of this selection as text. + /// + /*--cef()--*/ + virtual CefString GetSelectionAsText() =0; + + /// + // Returns the base URL for the document. + /// + /*--cef()--*/ + virtual CefString GetBaseURL() =0; + + /// + // Returns a complete URL based on the document base URL and the specified + // partial URL. + /// + /*--cef()--*/ + virtual CefString GetCompleteURL(const CefString& partialURL) =0; +}; + + +/// +// 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 virtual CefBase +{ +public: + typedef std::map AttributeMap; + typedef cef_dom_node_type_t Type; + + /// + // Returns the type for this node. + /// + /*--cef(default_retval=DOM_NODE_TYPE_UNSUPPORTED)--*/ + virtual Type GetType() =0; + + /// + // Returns true if this is a text node. + /// + /*--cef()--*/ + virtual bool IsText() =0; + + /// + // Returns true if this is an element node. + /// + /*--cef()--*/ + virtual bool IsElement() =0; + + /// + // Returns true if this is a form control element node. + /// + /*--cef()--*/ + virtual bool IsFormControlElement() =0; + + /// + // Returns the type of this form control element node. + /// + /*--cef()--*/ + virtual CefString GetFormControlElementType() =0; + + /// + // Returns true if this object is pointing to the same handle as |that| + // object. + /// + /*--cef()--*/ + virtual bool IsSame(CefRefPtr that) =0; + + /// + // Returns the name of this node. + /// + /*--cef()--*/ + virtual CefString GetName() =0; + + /// + // Returns the value of this node. + /// + /*--cef()--*/ + virtual CefString GetValue() =0; + + /// + // Set the value of this node. Returns true on success. + /// + /*--cef()--*/ + virtual bool SetValue(const CefString& value) =0; + + /// + // Returns the contents of this node as markup. + /// + /*--cef()--*/ + virtual CefString GetAsMarkup() =0; + + /// + // Returns the document associated with this node. + /// + /*--cef()--*/ + virtual CefRefPtr GetDocument() =0; + + /// + // Returns the parent node. + /// + /*--cef()--*/ + virtual CefRefPtr GetParent() =0; + + /// + // Returns the previous sibling node. + /// + /*--cef()--*/ + virtual CefRefPtr GetPreviousSibling() =0; + + /// + // Returns the next sibling node. + /// + /*--cef()--*/ + virtual CefRefPtr GetNextSibling() =0; + + /// + // Returns true if this node has child nodes. + /// + /*--cef()--*/ + virtual bool HasChildren() =0; + + /// + // Return the first child node. + /// + /*--cef()--*/ + virtual CefRefPtr GetFirstChild() =0; + + /// + // Returns the last child node. + /// + /*--cef()--*/ + virtual CefRefPtr GetLastChild() =0; + + /// + // Add an event listener to this node for the specified event type. If + // |useCapture| is true then this listener will be considered a capturing + // listener. Capturing listeners will recieve all events of the specified + // type before the events are dispatched to any other event targets beneath + // the current node in the tree. Events which are bubbling upwards through + // the tree will not trigger a capturing listener. Separate calls to this + // method can be used to register the same listener with and without capture. + // See WebCore/dom/EventNames.h for the list of supported event types. + /// + /*--cef()--*/ + virtual void AddEventListener(const CefString& eventType, + CefRefPtr listener, + bool useCapture) =0; + + + // The following methods are valid only for element nodes. + + /// + // Returns the tag name of this element. + /// + /*--cef()--*/ + virtual CefString GetElementTagName() =0; + + /// + // Returns true if this element has attributes. + /// + /*--cef()--*/ + virtual bool HasElementAttributes() =0; + + /// + // Returns true if this element has an attribute named |attrName|. + /// + /*--cef()--*/ + virtual bool HasElementAttribute(const CefString& attrName) =0; + + /// + // Returns the element attribute named |attrName|. + /// + /*--cef()--*/ + virtual CefString GetElementAttribute(const CefString& attrName) =0; + + /// + // Returns a map of all element attributes. + /// + /*--cef()--*/ + virtual void GetElementAttributes(AttributeMap& attrMap) =0; + + /// + // Set the value for the element attribute named |attrName|. Returns true on + // success. + /// + /*--cef()--*/ + virtual bool SetElementAttribute(const CefString& attrName, + const CefString& value) =0; + + /// + // Returns the inner text of the element. + /// + /*--cef()--*/ + virtual CefString GetElementInnerText() =0; +}; + + +/// +// 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 virtual CefBase +{ +public: + typedef cef_dom_event_category_t Category; + typedef cef_dom_event_phase_t Phase; + + /// + // Returns the event type. + /// + /*--cef()--*/ + virtual CefString GetType() =0; + + /// + // Returns the event category. + /// + /*--cef(default_retval=DOM_EVENT_CATEGORY_UNKNOWN)--*/ + virtual Category GetCategory() =0; + + /// + // Returns the event processing phase. + /// + /*--cef(default_retval=DOM_EVENT_PHASE_UNKNOWN)--*/ + virtual Phase GetPhase() =0; + + /// + // Returns true if the event can bubble up the tree. + /// + /*--cef()--*/ + virtual bool CanBubble() =0; + + /// + // Returns true if the event can be canceled. + /// + /*--cef()--*/ + virtual bool CanCancel() =0; + + /// + // Returns the document associated with this event. + /// + /*--cef()--*/ + virtual CefRefPtr GetDocument() =0; + + /// + // Returns the target of the event. + /// + /*--cef()--*/ + virtual CefRefPtr GetTarget() =0; + + /// + // Returns the current target of the event. + /// + /*--cef()--*/ + virtual CefRefPtr GetCurrentTarget() =0; +}; + + +/// +// 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 virtual CefBase +{ +public: + /// + // Called when an event is received. The event object passed to this method + // contains a snapshot of the DOM at the time this method is executed. DOM + // objects are only valid for the scope of this method. Do not keep references + // to or attempt to access any DOM objects outside the scope of this method. + /// + /*--cef()--*/ + virtual void HandleEvent(CefRefPtr event) =0; +}; + + +/// +// Interface to implement for filtering response content. The methods of this +// class will always be called on the UI thread. +/// +/*--cef(source=client)--*/ +class CefContentFilter : public virtual CefBase +{ +public: + /// + // Set |substitute_data| to the replacement for the data in |data| if data + // should be modified. + /// + /*--cef()--*/ + virtual void ProcessData(const void* data, int data_size, + CefRefPtr& substitute_data) {} + + /// + // Called when there is no more data to be processed. It is expected that + // whatever data was retained in the last ProcessData() call, it should be + // returned now by setting |remainder| if appropriate. + /// + /*--cef()--*/ + virtual void Drain(CefRefPtr& remainder) {} +}; + + +/// +// Class used to represent drag data. The methods of this class may be called +// on any thread. +/// +/*--cef(source=library)--*/ +class CefDragData : public virtual CefBase +{ +public: + /// + // Returns true if the drag data is a link. + /// + /*--cef()--*/ + virtual bool IsLink() =0; + + /// + // Returns true if the drag data is a text or html fragment. + /// + /*--cef()--*/ + virtual bool IsFragment() =0; + + /// + // Returns true if the drag data is a file. + /// + /*--cef()--*/ + virtual bool IsFile() =0; + + /// + // Return the link URL that is being dragged. + /// + /*--cef()--*/ + virtual CefString GetLinkURL() =0; + + /// + // Return the title associated with the link being dragged. + /// + /*--cef()--*/ + virtual CefString GetLinkTitle() =0; + + /// + // Return the metadata, if any, associated with the link being dragged. + /// + /*--cef()--*/ + virtual CefString GetLinkMetadata() =0; + + /// + // Return the plain text fragment that is being dragged. + /// + /*--cef()--*/ + virtual CefString GetFragmentText() =0; + + /// + // Return the text/html fragment that is being dragged. + /// + /*--cef()--*/ + virtual CefString GetFragmentHtml() =0; + + /// + // Return the base URL that the fragment came from. This value is used for + // resolving relative URLs and may be empty. + /// + /*--cef()--*/ + virtual CefString GetFragmentBaseURL() =0; + + /// + // Return the extension of the file being dragged out of the browser window. + /// + /*--cef()--*/ + virtual CefString GetFileExtension() =0; + + /// + // Return the name of the file being dragged out of the browser window. + /// + /*--cef()--*/ + virtual CefString GetFileName() =0; + + /// + // Retrieve the list of file names that are being dragged into the browser + // window. + /// + /*--cef()--*/ + virtual bool GetFileNames(std::vector& names) =0; +}; + + +/// +// Class used to create and/or parse command line arguments. Arguments with +// '--', '-' and, on Windows, '/' prefixes are considered switches. Switches +// will always precede any arguments without switch prefixes. Switches can +// optionally have a value specified using the '=' delimiter (e.g. +// "-switch=value"). An argument of "--" will terminate switch parsing with all +// subsequent tokens, regardless of prefix, being interpreted as non-switch +// arguments. Switch names are considered case-insensitive. This class can be +// used before CefInitialize() is called. +/// +/*--cef(source=library,no_debugct_check)--*/ +class CefCommandLine : public virtual CefBase +{ +public: + typedef std::vector ArgumentList; + typedef std::map SwitchMap; + + /// + // Create a new CefCommandLine instance. + /// + /*--cef(revision_check)--*/ + static CefRefPtr CreateCommandLine(); + + /// + // Initialize the command line with the specified |argc| and |argv| values. + // The first argument must be the name of the program. This method is only + // supported on non-Windows platforms. + /// + /*--cef()--*/ + virtual void InitFromArgv(int argc, const char* const* argv) =0; + + /// + // Initialize the command line with the string returned by calling + // GetCommandLineW(). This method is only supported on Windows. + /// + /*--cef()--*/ + virtual void InitFromString(const CefString& command_line) =0; + + /// + // Constructs and returns the represented command line string. Use this method + // cautiously because quoting behavior is unclear. + /// + /*--cef()--*/ + virtual CefString GetCommandLineString() =0; + + /// + // Get the program part of the command line string (the first item). + /// + /*--cef()--*/ + virtual CefString GetProgram() =0; + + /// + // Set the program part of the command line string (the first item). + /// + /*--cef()--*/ + virtual void SetProgram(const CefString& program) =0; + + /// + // Returns true if the command line has switches. + /// + /*--cef()--*/ + virtual bool HasSwitches() =0; + + /// + // Returns true if the command line contains the given switch. + /// + /*--cef()--*/ + virtual bool HasSwitch(const CefString& name) =0; + + /// + // Returns the value associated with the given switch. If the switch has no + // value or isn't present this method returns the empty string. + /// + /*--cef()--*/ + virtual CefString GetSwitchValue(const CefString& name) =0; + + /// + // Returns the map of switch names and values. If a switch has no value an + // empty string is returned. + /// + /*--cef()--*/ + virtual void GetSwitches(SwitchMap& switches) =0; + + /// + // Add a switch to the end of the command line. If the switch has no value + // pass an empty value string. + /// + /*--cef()--*/ + virtual void AppendSwitch(const CefString& name) =0; + + /// + // Add a switch with the specified value to the end of the command line. + /// + /*--cef()--*/ + virtual void AppendSwitchWithValue(const CefString& name, + const CefString& value) =0; + + /// + // True if there are remaining command line arguments. + /// + /*--cef()--*/ + virtual bool HasArguments() =0; + + /// + // Get the remaining command line arguments. + /// + /*--cef()--*/ + virtual void GetArguments(ArgumentList& arguments) =0; + + /// + // Add an argument to the end of the command line. + /// + /*--cef()--*/ + virtual void AppendArgument(const CefString& argument) =0; +}; + +#endif // _CEF_H diff --git a/cef/include/cef_application_mac.h b/cef/include/cef_application_mac.h new file mode 100755 index 000000000..aa8547ad8 --- /dev/null +++ b/cef/include/cef_application_mac.h @@ -0,0 +1,120 @@ +// 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_APPLICATION_MAC_H +#define _CEF_APPLICATION_MAC_H +#pragma once + +#include "cef.h" + +#if defined(OS_MACOSX) && defined(__OBJC__) + +#ifdef BUILDING_CEF_SHARED + +// Use the existing CrAppProtocol definition. +#include "base/message_pump_mac.h" + +// Use the existing empty protocol definitions. +#import "base/mac/cocoa_protocols.h" + +#else // BUILDING_CEF_SHARED + +#import +#import + +// Copy of CrAppProtocol definition from base/message_pump_mac.h. +@protocol CrAppProtocol +// Must return true if -[NSApplication sendEvent:] is currently on the stack. +- (BOOL)isHandlingSendEvent; +@end + +// The Mac OS X 10.6 SDK introduced new protocols used for delegates. These +// protocol defintions were not present in earlier releases of the Mac OS X +// SDK. In order to support building against the new SDK, which requires +// delegates to conform to these protocols, and earlier SDKs, which do not +// define these protocols at all, this file will provide empty protocol +// definitions when used with earlier SDK versions. + +#if !defined(MAC_OS_X_VERSION_10_6) || \ +MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_6 + +#define DEFINE_EMPTY_PROTOCOL(p) \ +@protocol p \ +@end + +DEFINE_EMPTY_PROTOCOL(NSAlertDelegate) +DEFINE_EMPTY_PROTOCOL(NSApplicationDelegate) +DEFINE_EMPTY_PROTOCOL(NSControlTextEditingDelegate) +DEFINE_EMPTY_PROTOCOL(NSMatrixDelegate) +DEFINE_EMPTY_PROTOCOL(NSMenuDelegate) +DEFINE_EMPTY_PROTOCOL(NSOpenSavePanelDelegate) +DEFINE_EMPTY_PROTOCOL(NSOutlineViewDataSource) +DEFINE_EMPTY_PROTOCOL(NSOutlineViewDelegate) +DEFINE_EMPTY_PROTOCOL(NSSpeechSynthesizerDelegate) +DEFINE_EMPTY_PROTOCOL(NSSplitViewDelegate) +DEFINE_EMPTY_PROTOCOL(NSTableViewDataSource) +DEFINE_EMPTY_PROTOCOL(NSTableViewDelegate) +DEFINE_EMPTY_PROTOCOL(NSTextFieldDelegate) +DEFINE_EMPTY_PROTOCOL(NSTextViewDelegate) +DEFINE_EMPTY_PROTOCOL(NSWindowDelegate) + +#undef DEFINE_EMPTY_PROTOCOL + +#endif + +#endif // BUILDING_CEF_SHARED + +// All CEF client applications must subclass NSApplication and implement this +// protocol. +@protocol CefAppProtocol +- (void)setHandlingSendEvent:(BOOL)handlingSendEvent; +@end + +// Controls the state of |isHandlingSendEvent| in the event loop so that it is +// reset properly. +class CefScopedSendingEvent { +public: + CefScopedSendingEvent() + : app_(static_cast*>( + [NSApplication sharedApplication])), + handling_([app_ isHandlingSendEvent]) { + [app_ setHandlingSendEvent:YES]; + } + ~CefScopedSendingEvent() { + [app_ setHandlingSendEvent:handling_]; + } + +private: + NSApplication* app_; + BOOL handling_; +}; + +#endif // defined(OS_MACOSX) && defined(__OBJC__) + +#endif // _CEF_APPLICATION_MAC_H diff --git a/cef/include/cef_capi.h b/cef/include/cef_capi.h new file mode 100755 index 000000000..9ac4e0272 --- /dev/null +++ b/cef/include/cef_capi.h @@ -0,0 +1,3769 @@ +// 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. +// +// --------------------------------------------------------------------------- +// +// 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 _CEF_CAPI_H +#define _CEF_CAPI_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "internal/cef_export.h" +#include "internal/cef_string.h" +#include "internal/cef_string_list.h" +#include "internal/cef_string_map.h" +#include "internal/cef_string_multimap.h" +#include "internal/cef_types.h" + + +/// +// This function should be called on the main application thread to initialize +// CEF when the application is started. The |application| parameter may be NULL. +// 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, + struct _cef_app_t* application); + +/// +// This function should be called on the main application thread to shut down +// CEF before the application exits. +/// +CEF_EXPORT void cef_shutdown(); + +/// +// Perform a single iteration of CEF message loop processing. This function is +// used to integrate the CEF message loop into an existing application message +// loop. Care must be taken to balance performance against excessive CPU usage. +// This function should only be called on the main application thread and only +// if cef_initialize() is called with a CefSettings.multi_threaded_message_loop +// value of false (0). This function will not block. +/// +CEF_EXPORT void cef_do_message_loop_work(); + +/// +// Run the CEF message loop. Use this function instead of an application- +// provided message loop to get the best balance between performance and CPU +// usage. This function should only be called on the main application thread and +// only if cef_initialize() is called with a +// CefSettings.multi_threaded_message_loop value of false (0). This function +// will block until a quit message is received by the system. +/// +CEF_EXPORT void cef_run_message_loop(); + +/// +// Quit the CEF message loop that was started by calling cef_run_message_loop(). +// This function should only be called on the main application thread and only +// if cef_run_message_loop() was used. +/// +CEF_EXPORT void cef_quit_message_loop(); + +/// +// Register a new V8 extension with the specified JavaScript extension code and +// handler. Functions implemented by the handler are prototyped using the +// keyword 'native'. The calling of a native function is restricted to the scope +// in which the prototype of the native function is defined. This function may +// be called on any thread. +// +// Example JavaScript extension code:
+//   // create the 'example' global object if it doesn't already exist.
+//   if (!example)
+//     example = {};
+//   // create the 'example.test' global object if it doesn't already exist.
+//   if (!example.test)
+//     example.test = {};
+//   (function() {
+//     // Define the function 'example.test.myfunction'.
+//     example.test.myfunction = function() {
+//       // Call CefV8Handler::Execute() with the function name 'MyFunction'
+//       // and no arguments.
+//       native function MyFunction();
+//       return MyFunction();
+//     };
+//     // Define the getter function for parameter 'example.test.myparam'.
+//     example.test.__defineGetter__('myparam', function() {
+//       // Call CefV8Handler::Execute() with the function name 'GetMyParam'
+//       // and no arguments.
+//       native function GetMyParam();
+//       return GetMyParam();
+//     });
+//     // Define the setter function for parameter 'example.test.myparam'.
+//     example.test.__defineSetter__('myparam', function(b) {
+//       // Call CefV8Handler::Execute() with the function name 'SetMyParam'
+//       // and a single argument.
+//       native function SetMyParam();
+//       if(b) SetMyParam(b);
+//     });
+//
+//     // Extension definitions can also contain normal JavaScript variables
+//     // and functions.
+//     var myint = 0;
+//     example.test.increment = function() {
+//       myint += 1;
+//       return myint;
+//     };
+//   })();
+// 
Example usage in the page:
+//   // Call the function.
+//   example.test.myfunction();
+//   // Set the parameter.
+//   example.test.myparam = value;
+//   // Get the parameter.
+//   value = example.test.myparam;
+//   // Call another function.
+//   example.test.increment();
+// 
+/// +CEF_EXPORT int cef_register_extension(const cef_string_t* extension_name, + const cef_string_t* javascript_code, struct _cef_v8handler_t* handler); + +/// +// Register a custom scheme. This function should not be called for the built-in +// HTTP, HTTPS, FILE, FTP, ABOUT and DATA schemes. +// +// If |is_standard| is true (1) the scheme will be treated as a standard scheme. +// Standard schemes are subject to URL canonicalization and parsing rules as +// defined in the Common Internet Scheme Syntax RFC 1738 Section 3.1 available +// at http://www.ietf.org/rfc/rfc1738.txt +// +// In particular, the syntax for standard scheme URLs must be of the form:
+//  [scheme]://[username]:[password]@[host]:[port]/[url-path]
+// 
Standard scheme URLs must have a host component that is a fully +// qualified domain name as defined in Section 3.5 of RFC 1034 [13] and Section +// 2.1 of RFC 1123. These URLs will be canonicalized to "scheme://host/path" in +// the simplest case and "scheme://username:password@host:port/path" in the most +// explicit case. For example, "scheme:host/path" and "scheme:///host/path" will +// both be canonicalized to "scheme://host/path". The origin of a standard +// scheme URL is the combination of scheme, host and port (i.e., +// "scheme://host:port" in the most explicit case). +// +// For non-standard scheme URLs only the "scheme:" component is parsed and +// canonicalized. The remainder of the URL will be passed to the handler as-is. +// For example, "scheme:///some%20text" will remain the same. Non-standard +// scheme URLs cannot be used as a target for form submission. +// +// If |is_local| is true (1) the scheme will be treated as local (i.e., with the +// same security rules as those applied to "file" URLs). Normal pages cannot +// link to or access local URLs. Also, by default, local URLs can only perform +// XMLHttpRequest calls to the same URL (origin + path) that originated the +// request. To allow XMLHttpRequest calls from a local URL to other URLs with +// the same origin set the CefSettings.file_access_from_file_urls_allowed value +// to true (1). To allow XMLHttpRequest calls from a local URL to all origins +// set the CefSettings.universal_access_from_file_urls_allowed value to true +// (1). +// +// If |is_display_isolated| is true (1) the scheme will be treated as display- +// isolated. This means that pages cannot display these URLs unless they are +// from the same scheme. For example, pages in another origin cannot create +// iframes or hyperlinks to URLs with this scheme. +// +// This function may be called on any thread. It should only be called once per +// unique |scheme_name| value. If |scheme_name| is already registered or if an +// error occurs this function will return false (0). +/// +CEF_EXPORT int cef_register_custom_scheme(const cef_string_t* scheme_name, + int is_standard, int is_local, int is_display_isolated); + +/// +// Register a scheme handler factory for the specified |scheme_name| and +// optional |domain_name|. An NULL |domain_name| value for a standard scheme +// will cause the factory to match all domain names. The |domain_name| value +// will be ignored for non-standard schemes. If |scheme_name| is a built-in +// scheme and no handler is returned by |factory| then the built-in scheme +// handler factory will be called. If |scheme_name| is a custom scheme the +// cef_register_custom_scheme() function should be called for that scheme. This +// function may be called multiple times to change or remove the factory that +// matches the specified |scheme_name| and optional |domain_name|. Returns false +// (0) if an error occurs. This function may be called on any thread. +/// +CEF_EXPORT int cef_register_scheme_handler_factory( + const cef_string_t* scheme_name, const cef_string_t* domain_name, + struct _cef_scheme_handler_factory_t* factory); + +/// +// Clear all registered scheme handler factories. Returns false (0) on error. +// This function may be called on any thread. +/// +CEF_EXPORT int cef_clear_scheme_handler_factories(); + +/// +// Add an entry to the cross-origin access whitelist. +// +// The same-origin policy restricts how scripts hosted from different origins +// (scheme + domain + port) can communicate. By default, scripts can only access +// resources with the same origin. Scripts hosted on the HTTP and HTTPS schemes +// (but no other schemes) can use the "Access-Control-Allow-Origin" header to +// allow cross-origin requests. For example, https://source.example.com can make +// XMLHttpRequest requests on http://target.example.com if the +// http://target.example.com request returns an "Access-Control-Allow-Origin: +// https://source.example.com" response header. +// +// Scripts in separate frames or iframes and hosted from the same protocol and +// domain suffix can execute cross-origin JavaScript if both pages set the +// document.domain value to the same domain suffix. For example, +// scheme://foo.example.com and scheme://bar.example.com can communicate using +// JavaScript if both domains set document.domain="example.com". +// +// This function is used to allow access to origins that would otherwise violate +// the same-origin policy. Scripts hosted underneath the fully qualified +// |source_origin| URL (like http://www.example.com) will be allowed access to +// all resources hosted on the specified |target_protocol| and |target_domain|. +// If |allow_target_subdomains| is true (1) access will also be allowed to all +// subdomains of the target domain. +// +// This function cannot be used to bypass the restrictions on local or display +// isolated schemes. See the comments on CefRegisterCustomScheme for more +// information. +// +// This function may be called on any thread. Returns false (0) if +// |source_origin| is invalid or the whitelist cannot be accessed. +/// +CEF_EXPORT int cef_add_cross_origin_whitelist_entry( + const cef_string_t* source_origin, const cef_string_t* target_protocol, + const cef_string_t* target_domain, int allow_target_subdomains); + +/// +// Remove an entry from the cross-origin access whitelist. Returns false (0) if +// |source_origin| is invalid or the whitelist cannot be accessed. +/// +CEF_EXPORT int cef_remove_cross_origin_whitelist_entry( + const cef_string_t* source_origin, const cef_string_t* target_protocol, + const cef_string_t* target_domain, int allow_target_subdomains); + +/// +// Remove all entries from the cross-origin access whitelist. Returns false (0) +// if the whitelist cannot be accessed. +/// +CEF_EXPORT int cef_clear_cross_origin_whitelist(); + +/// +// CEF maintains multiple internal threads that are used for handling different +// types of tasks. The UI thread creates the browser window and is used for all +// interaction with the WebKit rendering engine and V8 JavaScript engine (The UI +// thread will be the same as the main application thread if cef_initialize() is +// called with a CefSettings.multi_threaded_message_loop value of false (0).) +// The IO thread is used for handling schema and network requests. The FILE +// thread is used for the application cache and other miscellaneous activities. +// This function will return true (1) if called on the specified thread. +/// +CEF_EXPORT int cef_currently_on(cef_thread_id_t threadId); + +/// +// Post a task for execution on the specified thread. This function may be +// called on any thread. +/// +CEF_EXPORT int cef_post_task(cef_thread_id_t threadId, + struct _cef_task_t* task); + +/// +// Post a task for delayed execution on the specified thread. This function may +// be called on any thread. +/// +CEF_EXPORT int cef_post_delayed_task(cef_thread_id_t threadId, + struct _cef_task_t* task, long delay_ms); + +/// +// Parse the specified |url| into its component parts. Returns false (0) if the +// URL is NULL or invalid. +/// +CEF_EXPORT int cef_parse_url(const cef_string_t* url, + struct _cef_urlparts_t* parts); + +/// +// Creates a URL from the specified |parts|, which must contain a non-NULL spec +// or a non-NULL host and path (at a minimum), but not both. Returns false (0) +// if |parts| isn't initialized as described. +/// +CEF_EXPORT int cef_create_url(const struct _cef_urlparts_t* parts, + cef_string_t* url); + +/// +// Visit all cookies. The returned cookies are ordered by longest path, then by +// earliest creation date. Returns false (0) if cookies cannot be accessed. +/// +CEF_EXPORT int cef_visit_all_cookies(struct _cef_cookie_visitor_t* visitor); + +/// +// Visit a subset of cookies. The results are filtered by the given url scheme, +// host, domain and path. If |includeHttpOnly| is true (1) HTTP-only cookies +// will also be included in the results. The returned cookies are ordered by +// longest path, then by earliest creation date. Returns false (0) if cookies +// cannot be accessed. +/// +CEF_EXPORT int cef_visit_url_cookies(const cef_string_t* url, + int includeHttpOnly, struct _cef_cookie_visitor_t* visitor); + +/// +// Sets a cookie given a valid URL and explicit user-provided cookie attributes. +// This function expects each attribute to be well-formed. It will check for +// disallowed characters (e.g. the ';' character is disallowed within the cookie +// value attribute) and will return false (0) without setting the cookie if such +// characters are found. This function must be called on the IO thread. +/// +CEF_EXPORT int cef_set_cookie(const cef_string_t* url, + const struct _cef_cookie_t* cookie); + +/// +// Delete all cookies that match the specified parameters. If both |url| and +// |cookie_name| are specified all host and domain cookies matching both values +// will be deleted. If only |url| is specified all host cookies (but not domain +// cookies) irrespective of path will be deleted. If |url| is NULL all cookies +// for all hosts and domains will be deleted. Returns false (0) if a non-NULL +// invalid URL is specified or if cookies cannot be accessed. This function must +// be called on the IO thread. +/// +CEF_EXPORT int cef_delete_cookies(const cef_string_t* url, + const cef_string_t* cookie_name); + +/// +// Sets the directory path that will be used for storing cookie data. If |path| +// is NULL data will be stored in memory only. By default the cookie path is the +// same as the cache path. Returns false (0) if cookies cannot be accessed. +/// +CEF_EXPORT int cef_set_cookie_path(const cef_string_t* path); + +/// +// Visit storage of the specified type. If |origin| is non-NULL only data +// matching that origin will be visited. If |key| is non-NULL only data matching +// that key will be visited. Otherwise, all data for the storage type will be +// visited. Origin should be of the form scheme://domain. If no origin is +// specified only data currently in memory will be returned. Returns false (0) +// if the storage cannot be accessed. +/// +CEF_EXPORT int cef_visit_storage(enum cef_storage_type_t type, + const cef_string_t* origin, const cef_string_t* key, + struct _cef_storage_visitor_t* visitor); + +/// +// Sets storage of the specified type, origin, key and value. Returns false (0) +// if storage cannot be accessed. This function must be called on the UI thread. +/// +CEF_EXPORT int cef_set_storage(enum cef_storage_type_t type, + const cef_string_t* origin, const cef_string_t* key, + const cef_string_t* value); + +/// +// Deletes all storage of the specified type. If |origin| is non-NULL only data +// matching that origin will be cleared. If |key| is non-NULL only data matching +// that key will be cleared. Otherwise, all data for the storage type will be +// cleared. Returns false (0) if storage cannot be accessed. This function must +// be called on the UI thread. +/// +CEF_EXPORT int cef_delete_storage(enum cef_storage_type_t type, + const cef_string_t* origin, const cef_string_t* key); + +/// +// Sets the directory path that will be used for storing data of the specified +// type. Currently only the ST_LOCALSTORAGE type is supported by this function. +// If |path| is NULL data will be stored in memory only. By default the storage +// path is the same as the cache path. Returns false (0) if the storage cannot +// be accessed. +/// +CEF_EXPORT int cef_set_storage_path(enum cef_storage_type_t type, + const cef_string_t* path); + +typedef struct _cef_base_t +{ + // Size of the data structure. + size_t size; + + // Increment the reference count. + int (CEF_CALLBACK *add_ref)(struct _cef_base_t* self); + // Decrement the reference count. Delete this object when no references + // remain. + int (CEF_CALLBACK *release)(struct _cef_base_t* self); + // Returns the current number of references. + int (CEF_CALLBACK *get_refct)(struct _cef_base_t* self); + +} cef_base_t; + + +// Check that the structure |s|, which is defined with a cef_base_t member named +// |base|, is large enough to contain the specified member |f|. +#define CEF_MEMBER_EXISTS(s, f) \ + ((intptr_t)&((s)->f) - (intptr_t)(s) + sizeof((s)->f) <= (s)->base.size) + +#define CEF_MEMBER_MISSING(s, f) (!CEF_MEMBER_EXISTS(s, f) || !((s)->f)) + + +/// +// Implement this structure for task execution. The functions of this structure +// may be called on any thread. +/// +typedef struct _cef_task_t +{ + // Base structure. + cef_base_t base; + + /// + // Method that will be executed. |threadId| is the thread executing the call. + /// + void (CEF_CALLBACK *execute)(struct _cef_task_t* self, + cef_thread_id_t threadId); + +} cef_task_t; + + +/// +// Structure to implement for visiting cookie values. The functions of this +// structure will always be called on the IO thread. +/// +typedef struct _cef_cookie_visitor_t +{ + // Base structure. + cef_base_t base; + + /// + // Method that will be called once for each cookie. |count| is the 0-based + // index for the current cookie. |total| is the total number of cookies. Set + // |deleteCookie| to true (1) to delete the cookie currently being visited. + // Return false (0) to stop visiting cookies. This function may never be + // called if no cookies are found. + /// + int (CEF_CALLBACK *visit)(struct _cef_cookie_visitor_t* self, + const struct _cef_cookie_t* cookie, int count, int total, + int* deleteCookie); + +} cef_cookie_visitor_t; + + +/// +// Structure to implement for visiting storage. The functions of this structure +// will always be called on the UI thread. +/// +typedef struct _cef_storage_visitor_t +{ + // Base structure. + cef_base_t base; + + /// + // Method that will be called once for each key/value data pair in storage. + // |count| is the 0-based index for the current pair. |total| is the total + // number of pairs. Set |deleteData| to true (1) to delete the pair currently + // being visited. Return false (0) to stop visiting pairs. This function may + // never be called if no data is found. + /// + int (CEF_CALLBACK *visit)(struct _cef_storage_visitor_t* self, + enum cef_storage_type_t type, const cef_string_t* origin, + const cef_string_t* key, const cef_string_t* value, int count, int total, + int* deleteData); + +} cef_storage_visitor_t; + + +/// +// Structure used to represent a browser window. The functions of this structure +// may be called on any thread unless otherwise indicated in the comments. +/// +typedef struct _cef_browser_t +{ + // Base structure. + cef_base_t base; + + /// + // Call this function before destroying a contained browser window. This + // function performs any internal cleanup that may be needed before the + // browser window is destroyed. + /// + void (CEF_CALLBACK *parent_window_will_close)(struct _cef_browser_t* self); + + /// + // Closes this browser window. + /// + void (CEF_CALLBACK *close_browser)(struct _cef_browser_t* self); + + /// + // Returns true (1) if the browser can navigate backwards. + /// + int (CEF_CALLBACK *can_go_back)(struct _cef_browser_t* self); + + /// + // Navigate backwards. + /// + void (CEF_CALLBACK *go_back)(struct _cef_browser_t* self); + + /// + // Returns true (1) if the browser can navigate forwards. + /// + int (CEF_CALLBACK *can_go_forward)(struct _cef_browser_t* self); + + /// + // Navigate forwards. + /// + void (CEF_CALLBACK *go_forward)(struct _cef_browser_t* self); + + /// + // Reload the current page. + /// + void (CEF_CALLBACK *reload)(struct _cef_browser_t* self); + + /// + // Reload the current page ignoring any cached data. + /// + void (CEF_CALLBACK *reload_ignore_cache)(struct _cef_browser_t* self); + + /// + // Stop loading the page. + /// + void (CEF_CALLBACK *stop_load)(struct _cef_browser_t* self); + + /// + // Set focus for the browser window. If |enable| is true (1) focus will be set + // to the window. Otherwise, focus will be removed. + /// + void (CEF_CALLBACK *set_focus)(struct _cef_browser_t* self, int enable); + + /// + // Retrieve the window handle for this browser. + /// + cef_window_handle_t (CEF_CALLBACK *get_window_handle)( + struct _cef_browser_t* self); + + /// + // Retrieve the window handle of the browser that opened this browser. Will + // return NULL for non-popup windows. This function can be used in combination + // with custom handling of modal windows. + /// + cef_window_handle_t (CEF_CALLBACK *get_opener_window_handle)( + struct _cef_browser_t* self); + + /// + // Returns true (1) if the window is a popup window. + /// + int (CEF_CALLBACK *is_popup)(struct _cef_browser_t* self); + + // Returns true (1) if a document has been loaded in the browser. + int (CEF_CALLBACK *has_document)(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)( + struct _cef_browser_t* self); + + /// + // Returns the focused frame for the browser window. This function should only + // be called on the UI thread. + /// + struct _cef_frame_t* (CEF_CALLBACK *get_focused_frame)( + struct _cef_browser_t* self); + + /// + // Returns the frame with the specified name, or NULL if not found. This + // function should only be called on the UI thread. + /// + struct _cef_frame_t* (CEF_CALLBACK *get_frame)(struct _cef_browser_t* self, + const cef_string_t* name); + + /// + // Returns the names of all existing frames. This function should only be + // called on the UI thread. + /// + void (CEF_CALLBACK *get_frame_names)(struct _cef_browser_t* self, + cef_string_list_t names); + + /// + // Search for |searchText|. |identifier| can be used to have multiple searches + // running simultaniously. |forward| indicates whether to search forward or + // backward within the page. |matchCase| indicates whether the search should + // be case-sensitive. |findNext| indicates whether this is the first request + // or a follow-up. + /// + void (CEF_CALLBACK *find)(struct _cef_browser_t* self, int identifier, + const cef_string_t* searchText, int forward, int matchCase, + int findNext); + + /// + // Cancel all searches that are currently going on. + /// + void (CEF_CALLBACK *stop_finding)(struct _cef_browser_t* self, + int clearSelection); + + /// + // Get the zoom level. + /// + double (CEF_CALLBACK *get_zoom_level)(struct _cef_browser_t* self); + + /// + // Change the zoom level to the specified value. + /// + void (CEF_CALLBACK *set_zoom_level)(struct _cef_browser_t* self, + double zoomLevel); + + /// + // Clear the back/forward browsing history. + /// + void (CEF_CALLBACK *clear_history)(struct _cef_browser_t* self); + + /// + // Open developer tools in its own window. + /// + void (CEF_CALLBACK *show_dev_tools)(struct _cef_browser_t* self); + + /// + // Explicitly close the developer tools window if one exists for this browser + // instance. + /// + void (CEF_CALLBACK *close_dev_tools)(struct _cef_browser_t* self); + + /// + // Returns true (1) if window rendering is disabled. + /// + int (CEF_CALLBACK *is_window_rendering_disabled)(struct _cef_browser_t* self); + + /// + // Get the size of the specified element. This function should only be called + // on the UI thread. + /// + int (CEF_CALLBACK *get_size)(struct _cef_browser_t* self, + enum cef_paint_element_type_t type, int* width, int* height); + + /// + // Set the size of the specified element. This function is only used when + // window rendering is disabled. + /// + void (CEF_CALLBACK *set_size)(struct _cef_browser_t* self, + enum cef_paint_element_type_t type, int width, int height); + + /// + // Returns true (1) if a popup is currently visible. This function should only + // be called on the UI thread. + /// + int (CEF_CALLBACK *is_popup_visible)(struct _cef_browser_t* self); + + /// + // Hide the currently visible popup, if any. + /// + void (CEF_CALLBACK *hide_popup)(struct _cef_browser_t* self); + + /// + // Invalidate the |dirtyRect| region of the view. This function is only used + // when window rendering is disabled and will result in a call to + // HandlePaint(). + /// + void (CEF_CALLBACK *invalidate)(struct _cef_browser_t* self, + const cef_rect_t* dirtyRect); + + /// + // Get the raw image data contained in the specified element without + // performing validation. The specified |width| and |height| dimensions must + // match the current element size. On Windows |buffer| must be width*height*4 + // bytes in size and represents a BGRA image with an upper-left origin. This + // function should only be called on the UI thread. + /// + int (CEF_CALLBACK *get_image)(struct _cef_browser_t* self, + enum cef_paint_element_type_t type, int width, int height, + void* buffer); + + /// + // Send a key event to the browser. + /// + void (CEF_CALLBACK *send_key_event)(struct _cef_browser_t* self, + enum cef_key_type_t type, int key, int modifiers, int sysChar, + int imeChar); + + /// + // Send a mouse click event to the browser. The |x| and |y| coordinates are + // relative to the upper-left corner of the view. + /// + void (CEF_CALLBACK *send_mouse_click_event)(struct _cef_browser_t* self, + int x, int y, enum cef_mouse_button_type_t type, int mouseUp, + int clickCount); + + /// + // Send a mouse move event to the browser. The |x| and |y| coordinates are + // relative to the upper-left corner of the view. + /// + void (CEF_CALLBACK *send_mouse_move_event)(struct _cef_browser_t* self, int x, + int y, int mouseLeave); + + /// + // Send a mouse wheel event to the browser. The |x| and |y| coordinates are + // relative to the upper-left corner of the view. + /// + void (CEF_CALLBACK *send_mouse_wheel_event)(struct _cef_browser_t* self, + int x, int y, int delta); + + /// + // Send a focus event to the browser. + /// + void (CEF_CALLBACK *send_focus_event)(struct _cef_browser_t* self, + int setFocus); + + /// + // Send a capture lost event to the browser. + /// + void (CEF_CALLBACK *send_capture_lost_event)(struct _cef_browser_t* self); + +} 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. 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|. This function should only be called on the UI thread. +/// +CEF_EXPORT cef_browser_t* cef_browser_create_sync(cef_window_info_t* windowInfo, + 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 +// this structure may be called on any thread unless otherwise indicated in the +// comments. +/// +typedef struct _cef_frame_t +{ + // Base structure. + cef_base_t base; + + /// + // Execute undo in this frame. + /// + void (CEF_CALLBACK *undo)(struct _cef_frame_t* self); + + /// + // Execute redo in this frame. + /// + void (CEF_CALLBACK *redo)(struct _cef_frame_t* self); + + /// + // Execute cut in this frame. + /// + void (CEF_CALLBACK *cut)(struct _cef_frame_t* self); + + /// + // Execute copy in this frame. + /// + void (CEF_CALLBACK *copy)(struct _cef_frame_t* self); + + /// + // Execute paste in this frame. + /// + void (CEF_CALLBACK *paste)(struct _cef_frame_t* self); + + /// + // Execute delete in this frame. + /// + void (CEF_CALLBACK *del)(struct _cef_frame_t* self); + + /// + // Execute select all in this frame. + /// + void (CEF_CALLBACK *select_all)(struct _cef_frame_t* self); + + /// + // Execute printing in the this frame. The user will be prompted with the + // print dialog appropriate to the operating system. + /// + void (CEF_CALLBACK *print)(struct _cef_frame_t* self); + + /// + // Save this frame's HTML source to a temporary file and open it in the + // default text viewing application. + /// + void (CEF_CALLBACK *view_source)(struct _cef_frame_t* self); + + /// + // Returns this frame's HTML source as a string. This function should only be + // called on the UI thread. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_source)(struct _cef_frame_t* self); + + /// + // Returns this frame's display text as a string. This function should only be + // called on the UI thread. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_text)(struct _cef_frame_t* self); + + /// + // Load the request represented by the |request| object. + /// + void (CEF_CALLBACK *load_request)(struct _cef_frame_t* self, + struct _cef_request_t* request); + + /// + // Load the specified |url|. + /// + void (CEF_CALLBACK *load_url)(struct _cef_frame_t* self, + const cef_string_t* url); + + /// + // Load the contents of |string| with the optional dummy target |url|. + /// + void (CEF_CALLBACK *load_string)(struct _cef_frame_t* self, + const cef_string_t* string, const cef_string_t* url); + + /// + // Load the contents of |stream| with the optional dummy target |url|. + /// + void (CEF_CALLBACK *load_stream)(struct _cef_frame_t* self, + struct _cef_stream_reader_t* stream, const cef_string_t* url); + + /// + // Execute a string of JavaScript code in this frame. The |script_url| + // parameter is the URL where the script in question can be found, if any. The + // renderer may request this URL to show the developer the source of the + // error. The |start_line| parameter is the base line number to use for error + // reporting. + /// + void (CEF_CALLBACK *execute_java_script)(struct _cef_frame_t* self, + const cef_string_t* jsCode, const cef_string_t* scriptUrl, + int startLine); + + /// + // Returns true (1) if this is the main (top-level) frame. + /// + int (CEF_CALLBACK *is_main)(struct _cef_frame_t* self); + + /// + // Returns true (1) if this is the focused frame. This function should only be + // called on the UI thread. + /// + int (CEF_CALLBACK *is_focused)(struct _cef_frame_t* self); + + /// + // Returns the name for this frame. If the frame has an assigned name (for + // example, set via the iframe "name" attribute) then that value will be + // returned. Otherwise a unique name will be constructed based on the frame + // parent hierarchy. The main (top-level) frame will always have an NULL name + // value. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_name)(struct _cef_frame_t* self); + + /// + // Returns the globally unique identifier for this frame. This function should + // only be called on the UI thread. + /// + long long (CEF_CALLBACK *get_identifier)(struct _cef_frame_t* self); + + /// + // Returns the parent of this frame or NULL if this is the main (top-level) + // frame. This function should only be called on the UI thread. + /// + struct _cef_frame_t* (CEF_CALLBACK *get_parent)(struct _cef_frame_t* self); + + /// + // Returns the URL currently loaded in this frame. This function should only + // be called on the UI thread. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_url)(struct _cef_frame_t* self); + + /// + // Returns the browser that this frame belongs to. + /// + struct _cef_browser_t* (CEF_CALLBACK *get_browser)(struct _cef_frame_t* self); + + /// + // Visit the DOM document. + /// + void (CEF_CALLBACK *visit_dom)(struct _cef_frame_t* self, + struct _cef_domvisitor_t* visitor); + + /// + // Get the V8 context associated with the frame. This function should only be + // called on the UI thread. + /// + struct _cef_v8context_t* (CEF_CALLBACK *get_v8context)( + struct _cef_frame_t* self); + +} cef_frame_t; + + +/// +// Implement this structure to handle proxy resolution events. +/// +typedef struct _cef_proxy_handler_t +{ + // Base structure. + cef_base_t base; + + /// + // Called to retrieve proxy information for the specified |url|. + /// + void (CEF_CALLBACK *get_proxy_for_url)(struct _cef_proxy_handler_t* self, + const cef_string_t* url, struct _cef_proxy_info_t* proxy_info); + +} cef_proxy_handler_t; + + +/// +// Implement this structure to provide handler implementations. +/// +typedef struct _cef_app_t +{ + // Base structure. + cef_base_t base; + + /// + // Return the handler for proxy events. If not handler is returned the default + // system handler will be used. + /// + struct _cef_proxy_handler_t* (CEF_CALLBACK *get_proxy_handler)( + struct _cef_app_t* self); + +} cef_app_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 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_window_info_t* windowInfo, const cef_string_t* url, + struct _cef_client_t** client, + struct _cef_browser_settings_t* settings); + + /// + // 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 when a modal window is about to display and the modal loop should + // begin running. Return false (0) to use the default modal loop + // implementation or true (1) to use a custom implementation. + /// + int (CEF_CALLBACK *run_modal)(struct _cef_life_span_handler_t* self, + struct _cef_browser_t* browser); + + /// + // Called when a window has recieved a request to close. Return false (0) to + // proceed with the window close or true (1) to cancel the window close. If + // this is a modal window and a custom modal loop implementation was provided + // in run_modal() this callback should be used to restore the opener window to + // a usable state. + /// + int (CEF_CALLBACK *do_close)(struct _cef_life_span_handler_t* self, + struct _cef_browser_t* browser); + + /// + // Called just before a window is closed. If this is a modal window and a + // custom modal loop implementation was provided in run_modal() this callback + // should be used to exit the custom modal loop. + /// + void (CEF_CALLBACK *on_before_close)(struct _cef_life_span_handler_t* self, + struct _cef_browser_t* browser); + +} cef_life_span_handler_t; + + +/// +// 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 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 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 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. 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 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 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. + /// + 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 when a resource load is redirected. The |old_url| + // parameter will contain the old URL. The |new_url| parameter will contain + // the new URL and can be changed if desired. + /// + void (CEF_CALLBACK *on_resource_redirect)(struct _cef_request_handler_t* self, + struct _cef_browser_t* browser, const cef_string_t* old_url, + cef_string_t* new_url); + + /// + // Called on the UI thread after a response to the resource request is + // received. Set |filter| if response content needs to be monitored and/or + // modified as it arrives. + /// + void (CEF_CALLBACK *on_resource_response)(struct _cef_request_handler_t* self, + struct _cef_browser_t* browser, const cef_string_t* url, + struct _cef_response_t* response, + struct _cef_content_filter_t** filter); + + /// + // Called on the IO thread to handle requests for URLs with an unknown + // 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. + /// + 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. + // |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 + // cef_download_handler_t instance that will recieve the file contents. Return + // 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 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, + int port, const cef_string_t* realm, const cef_string_t* scheme, + cef_string_t* username, cef_string_t* password); + +} 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 size of the content area has changed. + /// + void (CEF_CALLBACK *on_contents_size_change)( + struct _cef_display_handler_t* self, struct _cef_browser_t* browser, + struct _cef_frame_t* frame, int width, int height); + + /// + // 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. |source| indicates + // where the focus request is originating from. 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, enum cef_handler_focus_source_t source); + + /// + // Called when a new node in the the browser gets focus. The |node| value may + // be NULL if no specific node has gained focus. The node object passed to + // this function represents a snapshot of the DOM at the time this function is + // executed. DOM objects are only valid for the scope of this function. Do not + // keep references to or attempt to access any DOM objects outside the scope + // of this function. + /// + void (CEF_CALLBACK *on_focused_node_changed)( + struct _cef_focus_handler_t* self, struct _cef_browser_t* browser, + struct _cef_frame_t* frame, struct _cef_domnode_t* node); + +} 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. This function + // is called both before the event is passed to the renderer and after + // JavaScript in the page has had a chance to handle the 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). If + // |isAfterJavaScript| is true (1) then JavaScript in the page has had a + // chance to handle the event and has chosen not to. Only RAWKEYDOWN, KEYDOWN + // and CHAR events will be sent with |isAfterJavaScript| set to true (1). + // Return true (1) if the keyboard event was handled or false (0) to allow + // continued handling of the event by the renderer. + /// + 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, int isAfterJavaScript); + +} 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_menu_info_t* menuInfo); + + /// + // 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_menu_id_t menuId, + cef_string_t* label); + + /// + // 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_menu_id_t menuId); + +} 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 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); + +} 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 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 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); + +} cef_jsdialog_handler_t; + + +/// +// Implement this structure to handle V8 context events. The functions of this +// structure will be called on the UI thread. +/// +typedef struct _cef_v8context_handler_t +{ + // Base structure. + cef_base_t base; + + /// + // Called immediately after the V8 context for a frame has been created. To + // retrieve the JavaScript 'window' object use the + // cef_v8context_t::get_global() function. + /// + void (CEF_CALLBACK *on_context_created)(struct _cef_v8context_handler_t* self, + struct _cef_browser_t* browser, struct _cef_frame_t* frame, + struct _cef_v8context_t* context); + + /// + // Called immediately before the V8 context for a frame is released. No + // references to the context should be kept after this function is called. + /// + void (CEF_CALLBACK *on_context_released)( + struct _cef_v8context_handler_t* self, struct _cef_browser_t* browser, + struct _cef_frame_t* frame, struct _cef_v8context_t* context); + +} cef_v8context_handler_t; + + +/// +// 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 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 to retrieve the simulated screen rectangle. Return true (1) if the + // rectangle was provided. + /// + int (CEF_CALLBACK *get_screen_rect)(struct _cef_render_handler_t* self, + struct _cef_browser_t* browser, cef_rect_t* rect); + + /// + // 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 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 widget. |buffer| contains the pixel data + // for the whole image. |dirtyRects| contains the set of rectangles that need + // to be 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, + size_t dirtyRectsCount, cef_rect_t const* dirtyRects, + const void* buffer); + + /// + // 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_render_handler_t; + + +/// +// Implement this structure to handle events related to dragging. The functions +// of this structure will be called on the UI thread. +/// +typedef struct _cef_drag_handler_t +{ + // Base structure. + cef_base_t base; + + /// + // Called when the browser window initiates a drag event. |dragData| contains + // the drag event data and |mask| represents the type of drag operation. + // Return false (0) for default drag handling behavior or true (1) to cancel + // the drag event. + /// + int (CEF_CALLBACK *on_drag_start)(struct _cef_drag_handler_t* self, + struct _cef_browser_t* browser, struct _cef_drag_data_t* dragData, + enum cef_drag_operations_mask_t mask); + + /// + // Called when an external drag event enters the browser window. |dragData| + // contains the drag event data and |mask| represents the type of drag + // operation. Return false (0) for default drag handling behavior or true (1) + // to cancel the drag event. + /// + int (CEF_CALLBACK *on_drag_enter)(struct _cef_drag_handler_t* self, + struct _cef_browser_t* browser, struct _cef_drag_data_t* dragData, + enum cef_drag_operations_mask_t mask); + +} cef_drag_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 V8 context events. + /// + struct _cef_v8context_handler_t* (CEF_CALLBACK *get_v8context_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); + + /// + // Return the handler for drag events. + /// + struct _cef_drag_handler_t* (CEF_CALLBACK *get_drag_handler)( + struct _cef_client_t* self); + +} cef_client_t; + + +/// +// Structure used to represent a web request. The functions of this structure +// may be called on any thread. +/// +typedef struct _cef_request_t +{ + // Base structure. + cef_base_t base; + + /// + // Get the fully qualified URL. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_url)(struct _cef_request_t* self); + + /// + // Set the fully qualified URL. + /// + void (CEF_CALLBACK *set_url)(struct _cef_request_t* self, + const cef_string_t* url); + + /// + // Get the request function type. The value will default to POST if post data + // is provided and GET otherwise. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_method)(struct _cef_request_t* self); + + /// + // Set the request function type. + /// + void (CEF_CALLBACK *set_method)(struct _cef_request_t* self, + const cef_string_t* method); + + /// + // Get the post data. + /// + struct _cef_post_data_t* (CEF_CALLBACK *get_post_data)( + struct _cef_request_t* self); + + /// + // Set the post data. + /// + void (CEF_CALLBACK *set_post_data)(struct _cef_request_t* self, + struct _cef_post_data_t* postData); + + /// + // Get the header values. + /// + void (CEF_CALLBACK *get_header_map)(struct _cef_request_t* self, + cef_string_multimap_t headerMap); + + /// + // Set the header values. + /// + void (CEF_CALLBACK *set_header_map)(struct _cef_request_t* self, + cef_string_multimap_t headerMap); + + /// + // Set all values at one time. + /// + void (CEF_CALLBACK *set)(struct _cef_request_t* self, const cef_string_t* url, + const cef_string_t* method, struct _cef_post_data_t* postData, + cef_string_multimap_t headerMap); + + /// + // Get the flags used in combination with cef_web_urlrequest_t. + /// + enum cef_weburlrequest_flags_t (CEF_CALLBACK *get_flags)( + struct _cef_request_t* self); + + /// + // Set the flags used in combination with cef_web_urlrequest_t. + /// + void (CEF_CALLBACK *set_flags)(struct _cef_request_t* self, + enum cef_weburlrequest_flags_t flags); + + /// + // Set the URL to the first party for cookies used in combination with + // cef_web_urlrequest_t. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_first_party_for_cookies)( + struct _cef_request_t* self); + + /// + // Get the URL to the first party for cookies used in combination with + // cef_web_urlrequest_t. + /// + void (CEF_CALLBACK *set_first_party_for_cookies)(struct _cef_request_t* self, + const cef_string_t* url); + +} cef_request_t; + + +/// +// Create a new cef_request_t object. +/// +CEF_EXPORT cef_request_t* cef_request_create(); + + +/// +// Structure used to represent post data for a web request. The functions of +// this structure may be called on any thread. +/// +typedef struct _cef_post_data_t +{ + // Base structure. + cef_base_t base; + + /// + // Returns the number of existing post data elements. + /// + size_t (CEF_CALLBACK *get_element_count)(struct _cef_post_data_t* self); + + /// + // Retrieve the post data elements. + /// + void (CEF_CALLBACK *get_elements)(struct _cef_post_data_t* self, + size_t* elementsCount, struct _cef_post_data_element_t** elements); + + /// + // Remove the specified post data element. Returns true (1) if the removal + // succeeds. + /// + int (CEF_CALLBACK *remove_element)(struct _cef_post_data_t* self, + struct _cef_post_data_element_t* element); + + /// + // Add the specified post data element. Returns true (1) if the add succeeds. + /// + int (CEF_CALLBACK *add_element)(struct _cef_post_data_t* self, + struct _cef_post_data_element_t* element); + + /// + // Remove all existing post data elements. + /// + void (CEF_CALLBACK *remove_elements)(struct _cef_post_data_t* self); + +} cef_post_data_t; + + +/// +// Create a new cef_post_data_t object. +/// +CEF_EXPORT cef_post_data_t* cef_post_data_create(); + + +/// +// Structure used to represent a single element in the request post data. The +// functions of this structure may be called on any thread. +/// +typedef struct _cef_post_data_element_t +{ + // Base structure. + cef_base_t base; + + /// + // Remove all contents from the post data element. + /// + void (CEF_CALLBACK *set_to_empty)(struct _cef_post_data_element_t* self); + + /// + // The post data element will represent a file. + /// + void (CEF_CALLBACK *set_to_file)(struct _cef_post_data_element_t* self, + const cef_string_t* fileName); + + /// + // The post data element will represent bytes. The bytes passed in will be + // copied. + /// + void (CEF_CALLBACK *set_to_bytes)(struct _cef_post_data_element_t* self, + size_t size, const void* bytes); + + /// + // Return the type of this post data element. + /// + enum cef_postdataelement_type_t (CEF_CALLBACK *get_type)( + struct _cef_post_data_element_t* self); + + /// + // Return the file name. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_file)( + struct _cef_post_data_element_t* self); + + /// + // Return the number of bytes. + /// + size_t (CEF_CALLBACK *get_bytes_count)(struct _cef_post_data_element_t* self); + + /// + // Read up to |size| bytes into |bytes| and return the number of bytes + // actually read. + /// + size_t (CEF_CALLBACK *get_bytes)(struct _cef_post_data_element_t* self, + size_t size, void* bytes); + +} cef_post_data_element_t; + + +/// +// Create a new cef_post_data_element_t object. +/// +CEF_EXPORT cef_post_data_element_t* cef_post_data_element_create(); + + +/// +// Structure used to represent a web response. The functions of this structure +// may be called on any thread. +/// +typedef struct _cef_response_t +{ + // Base structure. + cef_base_t base; + + /// + // Get the response status code. + /// + int (CEF_CALLBACK *get_status)(struct _cef_response_t* self); + + /// + // Set the response status code. + /// + void (CEF_CALLBACK *set_status)(struct _cef_response_t* self, int status); + + /// + // Get the response status text. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_status_text)( + struct _cef_response_t* self); + + /// + // Set the response status text. + /// + void (CEF_CALLBACK *set_status_text)(struct _cef_response_t* self, + const cef_string_t* statusText); + + /// + // Get the response mime type. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_mime_type)( + struct _cef_response_t* self); + + /// + // Set the response mime type. + /// + void (CEF_CALLBACK *set_mime_type)(struct _cef_response_t* self, + const cef_string_t* mimeType); + + /// + // Get the value for the specified response header field. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_header)(struct _cef_response_t* self, + const cef_string_t* name); + + /// + // Get all response header fields. + /// + void (CEF_CALLBACK *get_header_map)(struct _cef_response_t* self, + cef_string_multimap_t headerMap); + + /// + // Set all response header fields. + /// + void (CEF_CALLBACK *set_header_map)(struct _cef_response_t* self, + cef_string_multimap_t headerMap); + +} cef_response_t; + + +/// +// Structure the client can implement to provide a custom stream reader. The +// functions of this structure may be called on any thread. +/// +typedef struct _cef_read_handler_t +{ + // Base structure. + cef_base_t base; + + /// + // Read raw binary data. + /// + size_t (CEF_CALLBACK *read)(struct _cef_read_handler_t* self, void* ptr, + size_t size, size_t n); + + /// + // Seek to the specified offset position. |whence| may be any one of SEEK_CUR, + // SEEK_END or SEEK_SET. + /// + int (CEF_CALLBACK *seek)(struct _cef_read_handler_t* self, long offset, + int whence); + + /// + // Return the current offset position. + /// + long (CEF_CALLBACK *tell)(struct _cef_read_handler_t* self); + + /// + // Return non-zero if at end of file. + /// + int (CEF_CALLBACK *eof)(struct _cef_read_handler_t* self); + +} cef_read_handler_t; + + +/// +// Structure used to read data from a stream. The functions of this structure +// may be called on any thread. +/// +typedef struct _cef_stream_reader_t +{ + // Base structure. + cef_base_t base; + + /// + // Read raw binary data. + /// + size_t (CEF_CALLBACK *read)(struct _cef_stream_reader_t* self, void* ptr, + size_t size, size_t n); + + /// + // Seek to the specified offset position. |whence| may be any one of SEEK_CUR, + // SEEK_END or SEEK_SET. Returns zero on success and non-zero on failure. + /// + int (CEF_CALLBACK *seek)(struct _cef_stream_reader_t* self, long offset, + int whence); + + /// + // Return the current offset position. + /// + long (CEF_CALLBACK *tell)(struct _cef_stream_reader_t* self); + + /// + // Return non-zero if at end of file. + /// + int (CEF_CALLBACK *eof)(struct _cef_stream_reader_t* self); + +} cef_stream_reader_t; + + +/// +// Create a new cef_stream_reader_t object from a file. +/// +CEF_EXPORT cef_stream_reader_t* cef_stream_reader_create_for_file( + const cef_string_t* fileName); + +/// +// Create a new cef_stream_reader_t object from data. +/// +CEF_EXPORT cef_stream_reader_t* cef_stream_reader_create_for_data(void* data, + size_t size); + +/// +// Create a new cef_stream_reader_t object from a custom handler. +/// +CEF_EXPORT cef_stream_reader_t* cef_stream_reader_create_for_handler( + cef_read_handler_t* handler); + + +/// +// Structure the client can implement to provide a custom stream writer. The +// functions of this structure may be called on any thread. +/// +typedef struct _cef_write_handler_t +{ + // Base structure. + cef_base_t base; + + /// + // Write raw binary data. + /// + size_t (CEF_CALLBACK *write)(struct _cef_write_handler_t* self, + const void* ptr, size_t size, size_t n); + + /// + // Seek to the specified offset position. |whence| may be any one of SEEK_CUR, + // SEEK_END or SEEK_SET. + /// + int (CEF_CALLBACK *seek)(struct _cef_write_handler_t* self, long offset, + int whence); + + /// + // Return the current offset position. + /// + long (CEF_CALLBACK *tell)(struct _cef_write_handler_t* self); + + /// + // Flush the stream. + /// + int (CEF_CALLBACK *flush)(struct _cef_write_handler_t* self); + +} cef_write_handler_t; + + +/// +// Structure used to write data to a stream. The functions of this structure may +// be called on any thread. +/// +typedef struct _cef_stream_writer_t +{ + // Base structure. + cef_base_t base; + + /// + // Write raw binary data. + /// + size_t (CEF_CALLBACK *write)(struct _cef_stream_writer_t* self, + const void* ptr, size_t size, size_t n); + + /// + // Seek to the specified offset position. |whence| may be any one of SEEK_CUR, + // SEEK_END or SEEK_SET. + /// + int (CEF_CALLBACK *seek)(struct _cef_stream_writer_t* self, long offset, + int whence); + + /// + // Return the current offset position. + /// + long (CEF_CALLBACK *tell)(struct _cef_stream_writer_t* self); + + /// + // Flush the stream. + /// + int (CEF_CALLBACK *flush)(struct _cef_stream_writer_t* self); + +} cef_stream_writer_t; + + +/// +// Create a new cef_stream_writer_t object for a file. +/// +CEF_EXPORT cef_stream_writer_t* cef_stream_writer_create_for_file( + const cef_string_t* fileName); + +/// +// Create a new cef_stream_writer_t object for a custom handler. +/// +CEF_EXPORT cef_stream_writer_t* cef_stream_writer_create_for_handler( + cef_write_handler_t* handler); + + +/// +// Structure that encapsulates a V8 context handle. +/// +typedef struct _cef_v8context_t +{ + // Base structure. + cef_base_t base; + + /// + // Returns the browser for this context. + /// + struct _cef_browser_t* (CEF_CALLBACK *get_browser)( + struct _cef_v8context_t* self); + + /// + // Returns the frame for this context. + /// + struct _cef_frame_t* (CEF_CALLBACK *get_frame)(struct _cef_v8context_t* self); + + /// + // Returns the global object for this context. + /// + struct _cef_v8value_t* (CEF_CALLBACK *get_global)( + struct _cef_v8context_t* self); + + /// + // Enter this context. A context must be explicitly entered before creating a + // V8 Object, Array or Function asynchronously. exit() must be called the same + // number of times as enter() before releasing this context. V8 objects belong + // to the context in which they are created. Returns true (1) if the scope was + // entered successfully. + /// + int (CEF_CALLBACK *enter)(struct _cef_v8context_t* self); + + /// + // Exit this context. Call this function only after calling enter(). Returns + // true (1) if the scope was exited successfully. + /// + int (CEF_CALLBACK *exit)(struct _cef_v8context_t* self); + + /// + // Returns true (1) if this object is pointing to the same handle as |that| + // object. + /// + int (CEF_CALLBACK *is_same)(struct _cef_v8context_t* self, + struct _cef_v8context_t* that); + +} cef_v8context_t; + + +/// +// Returns the current (top) context object in the V8 context stack. +/// +CEF_EXPORT cef_v8context_t* cef_v8context_get_current_context(); + +/// +// Returns the entered (bottom) context object in the V8 context stack. +/// +CEF_EXPORT cef_v8context_t* cef_v8context_get_entered_context(); + +/// +// Returns true (1) if V8 is currently inside a context. +/// +CEF_EXPORT int cef_v8context_in_context(); + + +/// +// Structure that should be implemented to handle V8 function calls. The +// functions of this structure will always be called on the UI thread. +/// +typedef struct _cef_v8handler_t +{ + // Base structure. + cef_base_t base; + + /// + // Handle execution of the function identified by |name|. |object| is the + // receiver ('this' object) of the function. |arguments| is the list of + // arguments passed to the function. If execution succeeds set |retval| to the + // function return value. If execution fails set |exception| to the exception + // that will be thrown. Return true (1) if execution was handled. + /// + int (CEF_CALLBACK *execute)(struct _cef_v8handler_t* self, + const cef_string_t* name, struct _cef_v8value_t* object, + size_t argumentsCount, struct _cef_v8value_t* const* arguments, + struct _cef_v8value_t** retval, cef_string_t* exception); + +} cef_v8handler_t; + + +/// +// Structure that should be implemented to handle V8 accessor calls. Accessor +// identifiers are registered by calling cef_v8value_t::set_value(). The +// functions of this structure will always be called on the UI thread. +/// +typedef struct _cef_v8accessor_t +{ + // Base structure. + cef_base_t base; + + /// + // Handle retrieval the accessor value identified by |name|. |object| is the + // receiver ('this' object) of the accessor. If retrieval succeeds set + // |retval| to the return value. If retrieval fails set |exception| to the + // exception that will be thrown. Return true (1) if accessor retrieval was + // handled. + /// + int (CEF_CALLBACK *get)(struct _cef_v8accessor_t* self, + const cef_string_t* name, struct _cef_v8value_t* object, + struct _cef_v8value_t** retval, cef_string_t* exception); + + /// + // Handle assignment of the accessor value identified by |name|. |object| is + // the receiver ('this' object) of the accessor. |value| is the new value + // being assigned to the accessor. If assignment fails set |exception| to the + // exception that will be thrown. Return true (1) if accessor assignment was + // handled. + /// + int (CEF_CALLBACK *set)(struct _cef_v8accessor_t* self, + const cef_string_t* name, struct _cef_v8value_t* object, + struct _cef_v8value_t* value, cef_string_t* exception); + +} cef_v8accessor_t; + + +/// +// Structure representing a V8 exception. +/// +typedef struct _cef_v8exception_t +{ + // Base structure. + cef_base_t base; + + /// + // Returns the exception message. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_message)( + struct _cef_v8exception_t* self); + + /// + // Returns the line of source code that the exception occurred within. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_source_line)( + struct _cef_v8exception_t* self); + + /// + // Returns the resource name for the script from where the function causing + // the error originates. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_script_resource_name)( + struct _cef_v8exception_t* self); + + /// + // Returns the 1-based number of the line where the error occurred or 0 if the + // line number is unknown. + /// + int (CEF_CALLBACK *get_line_number)(struct _cef_v8exception_t* self); + + /// + // Returns the index within the script of the first character where the error + // occurred. + /// + int (CEF_CALLBACK *get_start_position)(struct _cef_v8exception_t* self); + + /// + // Returns the index within the script of the last character where the error + // occurred. + /// + int (CEF_CALLBACK *get_end_position)(struct _cef_v8exception_t* self); + + /// + // Returns the index within the line of the first character where the error + // occurred. + /// + int (CEF_CALLBACK *get_start_column)(struct _cef_v8exception_t* self); + + /// + // Returns the index within the line of the last character where the error + // occurred. + /// + int (CEF_CALLBACK *get_end_column)(struct _cef_v8exception_t* self); + +} cef_v8exception_t; + + +/// +// Structure representing a V8 value. The functions of this structure should +// only be called on the UI thread. +/// +typedef struct _cef_v8value_t +{ + // Base structure. + cef_base_t base; + + /// + // True if the value type is undefined. + /// + int (CEF_CALLBACK *is_undefined)(struct _cef_v8value_t* self); + + /// + // True if the value type is null. + /// + int (CEF_CALLBACK *is_null)(struct _cef_v8value_t* self); + + /// + // True if the value type is bool. + /// + int (CEF_CALLBACK *is_bool)(struct _cef_v8value_t* self); + + /// + // True if the value type is int. + /// + int (CEF_CALLBACK *is_int)(struct _cef_v8value_t* self); + + /// + // True if the value type is double. + /// + int (CEF_CALLBACK *is_double)(struct _cef_v8value_t* self); + + /// + // True if the value type is Date. + /// + int (CEF_CALLBACK *is_date)(struct _cef_v8value_t* self); + + /// + // True if the value type is string. + /// + int (CEF_CALLBACK *is_string)(struct _cef_v8value_t* self); + + /// + // True if the value type is object. + /// + int (CEF_CALLBACK *is_object)(struct _cef_v8value_t* self); + + /// + // True if the value type is array. + /// + int (CEF_CALLBACK *is_array)(struct _cef_v8value_t* self); + + /// + // True if the value type is function. + /// + int (CEF_CALLBACK *is_function)(struct _cef_v8value_t* self); + + /// + // Returns true (1) if this object is pointing to the same handle as |that| + // object. + /// + int (CEF_CALLBACK *is_same)(struct _cef_v8value_t* self, + struct _cef_v8value_t* that); + + /// + // Return a bool value. The underlying data will be converted to if + // necessary. + /// + int (CEF_CALLBACK *get_bool_value)(struct _cef_v8value_t* self); + + /// + // Return an int value. The underlying data will be converted to if + // necessary. + /// + int (CEF_CALLBACK *get_int_value)(struct _cef_v8value_t* self); + + /// + // Return a double value. The underlying data will be converted to if + // necessary. + /// + double (CEF_CALLBACK *get_double_value)(struct _cef_v8value_t* self); + + /// + // Return a Date value. The underlying data will be converted to if + // necessary. + /// + cef_time_t (CEF_CALLBACK *get_date_value)(struct _cef_v8value_t* self); + + /// + // Return a string value. The underlying data will be converted to if + // necessary. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_string_value)( + struct _cef_v8value_t* self); + + + // OBJECT METHODS - These functions are only available on objects. Arrays and + // functions are also objects. String- and integer-based keys can be used + // interchangably with the framework converting between them as necessary. + + /// + // Returns true (1) if the object has a value with the specified identifier. + /// + int (CEF_CALLBACK *has_value_bykey)(struct _cef_v8value_t* self, + const cef_string_t* key); + + /// + // Returns true (1) if the object has a value with the specified identifier. + /// + int (CEF_CALLBACK *has_value_byindex)(struct _cef_v8value_t* self, int index); + + /// + // Delete the value with the specified identifier. + /// + int (CEF_CALLBACK *delete_value_bykey)(struct _cef_v8value_t* self, + const cef_string_t* key); + + /// + // Delete the value with the specified identifier. + /// + int (CEF_CALLBACK *delete_value_byindex)(struct _cef_v8value_t* self, + int index); + + /// + // Returns the value with the specified identifier. + /// + struct _cef_v8value_t* (CEF_CALLBACK *get_value_bykey)( + struct _cef_v8value_t* self, const cef_string_t* key); + + /// + // Returns the value with the specified identifier. + /// + struct _cef_v8value_t* (CEF_CALLBACK *get_value_byindex)( + struct _cef_v8value_t* self, int index); + + /// + // Associate a value with the specified identifier. + /// + int (CEF_CALLBACK *set_value_bykey)(struct _cef_v8value_t* self, + const cef_string_t* key, struct _cef_v8value_t* value, + enum cef_v8_propertyattribute_t attribute); + + /// + // Associate a value with the specified identifier. + /// + int (CEF_CALLBACK *set_value_byindex)(struct _cef_v8value_t* self, int index, + struct _cef_v8value_t* value); + + /// + // Register an identifier whose access will be forwarded to the + // cef_v8accessor_t instance passed to + // cef_v8value_t::cef_v8value_create_object_with_accessor(). + /// + int (CEF_CALLBACK *set_value_byaccessor)(struct _cef_v8value_t* self, + const cef_string_t* key, enum cef_v8_accesscontrol_t settings, + enum cef_v8_propertyattribute_t attribute); + + /// + // Read the keys for the object's values into the specified vector. Integer- + // based keys will also be returned as strings. + /// + int (CEF_CALLBACK *get_keys)(struct _cef_v8value_t* self, + cef_string_list_t keys); + + /// + // Returns the user data, if any, specified when the object was created. + /// + struct _cef_base_t* (CEF_CALLBACK *get_user_data)( + struct _cef_v8value_t* self); + + + // ARRAY METHODS - These functions are only available on arrays. + + /// + // Returns the number of elements in the array. + /// + int (CEF_CALLBACK *get_array_length)(struct _cef_v8value_t* self); + + + // FUNCTION METHODS - These functions are only available on functions. + + /// + // Returns the function name. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_function_name)( + struct _cef_v8value_t* self); + + /// + // Returns the function handler or NULL if not a CEF-created function. + /// + struct _cef_v8handler_t* (CEF_CALLBACK *get_function_handler)( + struct _cef_v8value_t* self); + + /// + // Execute the function using the current V8 context. This function should + // only be called from within the scope of a cef_v8handler_t or + // cef_v8accessor_t callback, or in combination with calling enter() and + // exit() on a stored cef_v8context_t reference. |object| is the receiver + // ('this' object) of the function. |arguments| is the list of arguments that + // will be passed to the function. If execution succeeds |retval| will be set + // to the function return value. If execution fails |exception| will be set to + // the exception that was thrown. If |rethrow_exception| is true (1) any + // exception will also be re- thrown. This function returns false (0) if + // called incorrectly. + /// + int (CEF_CALLBACK *execute_function)(struct _cef_v8value_t* self, + struct _cef_v8value_t* object, size_t argumentsCount, + struct _cef_v8value_t* const* arguments, struct _cef_v8value_t** retval, + struct _cef_v8exception_t** exception, int rethrow_exception); + + /// + // Execute the function using the specified V8 context. |object| is the + // receiver ('this' object) of the function. |arguments| is the list of + // arguments that will be passed to the function. If execution succeeds + // |retval| will be set to the function return value. If execution fails + // |exception| will be set to the exception that was thrown. If + // |rethrow_exception| is true (1) any exception will also be re-thrown. This + // function returns false (0) if called incorrectly. + /// + int (CEF_CALLBACK *execute_function_with_context)(struct _cef_v8value_t* self, + struct _cef_v8context_t* context, struct _cef_v8value_t* object, + size_t argumentsCount, struct _cef_v8value_t* const* arguments, + struct _cef_v8value_t** retval, struct _cef_v8exception_t** exception, + int rethrow_exception); + +} cef_v8value_t; + + +/// +// Create a new cef_v8value_t object of type undefined. +/// +CEF_EXPORT cef_v8value_t* cef_v8value_create_undefined(); + +/// +// Create a new cef_v8value_t object of type null. +/// +CEF_EXPORT cef_v8value_t* cef_v8value_create_null(); + +/// +// Create a new cef_v8value_t object of type bool. +/// +CEF_EXPORT cef_v8value_t* cef_v8value_create_bool(int value); + +/// +// Create a new cef_v8value_t object of type int. +/// +CEF_EXPORT cef_v8value_t* cef_v8value_create_int(int value); + +/// +// Create a new cef_v8value_t object of type double. +/// +CEF_EXPORT cef_v8value_t* cef_v8value_create_double(double value); + +/// +// Create a new cef_v8value_t object of type Date. +/// +CEF_EXPORT cef_v8value_t* cef_v8value_create_date(const cef_time_t* date); + +/// +// Create a new cef_v8value_t object of type string. +/// +CEF_EXPORT cef_v8value_t* cef_v8value_create_string(const cef_string_t* value); + +/// +// Create a new cef_v8value_t object of type object. This function should only +// be called from within the scope of a cef_v8context_tHandler, cef_v8handler_t +// or cef_v8accessor_t callback, or in combination with calling enter() and +// exit() on a stored cef_v8context_t reference. +/// +CEF_EXPORT cef_v8value_t* cef_v8value_create_object(cef_base_t* user_data); + +/// +// Create a new cef_v8value_t object of type object with accessors. This +// function should only be called from within the scope of a +// cef_v8context_tHandler, cef_v8handler_t or cef_v8accessor_t callback, or in +// combination with calling enter() and exit() on a stored cef_v8context_t +// reference. +/// +CEF_EXPORT cef_v8value_t* cef_v8value_create_object_with_accessor( + cef_base_t* user_data, cef_v8accessor_t* accessor); + +/// +// Create a new cef_v8value_t object of type array. This function should only be +// called from within the scope of a cef_v8context_tHandler, cef_v8handler_t or +// cef_v8accessor_t callback, or in combination with calling enter() and exit() +// on a stored cef_v8context_t reference. +/// +CEF_EXPORT cef_v8value_t* cef_v8value_create_array(); + +/// +// Create a new cef_v8value_t object of type function. This function should only +// be called from within the scope of a cef_v8context_tHandler, cef_v8handler_t +// or cef_v8accessor_t callback, or in combination with calling enter() and +// exit() on a stored cef_v8context_t reference. +/// +CEF_EXPORT cef_v8value_t* cef_v8value_create_function(const cef_string_t* name, + cef_v8handler_t* handler); + + +/// +// Structure that creates cef_scheme_handler_t instances. The functions of this +// structure will always be called on the IO thread. +/// +typedef struct _cef_scheme_handler_factory_t +{ + // Base structure. + cef_base_t base; + + /// + // Return a new scheme handler instance to handle the request. |browser| will + // be the browser window that initiated the request. If the request was + // initiated using the cef_web_urlrequest_t API |browser| will be NULL. + /// + struct _cef_scheme_handler_t* (CEF_CALLBACK *create)( + struct _cef_scheme_handler_factory_t* self, + struct _cef_browser_t* browser, const cef_string_t* scheme_name, + struct _cef_request_t* request); + +} cef_scheme_handler_factory_t; + + +/// +// Structure used to facilitate asynchronous responses to custom scheme handler +// requests. The functions of this structure may be called on any thread. +/// +typedef struct _cef_scheme_handler_callback_t +{ + // Base structure. + cef_base_t base; + + /// + // Notify that header information is now available for retrieval. + /// + void (CEF_CALLBACK *headers_available)( + struct _cef_scheme_handler_callback_t* self); + + /// + // Notify that response data is now available for reading. + /// + void (CEF_CALLBACK *bytes_available)( + struct _cef_scheme_handler_callback_t* self); + + /// + // Cancel processing of the request. + /// + void (CEF_CALLBACK *cancel)(struct _cef_scheme_handler_callback_t* self); + +} cef_scheme_handler_callback_t; + + +/// +// Structure used to implement a custom scheme handler structure. The functions +// of this structure will always be called on the IO thread. +/// +typedef struct _cef_scheme_handler_t +{ + // Base structure. + cef_base_t base; + + /// + // Begin processing the request. To handle the request return true (1) and + // call headers_available() once the response header information is available + // (headers_available() can also be called from inside this function if header + // information is available immediately). To cancel the request return false + // (0). + /// + int (CEF_CALLBACK *process_request)(struct _cef_scheme_handler_t* self, + struct _cef_request_t* request, + struct _cef_scheme_handler_callback_t* callback); + + /// + // Retrieve response header information. If the response length is not known + // set |response_length| to -1 and read_response() will be called until it + // returns false (0). If the response length is known set |response_length| to + // a positive value and read_response() will be called until it returns false + // (0) or the specified number of bytes have been read. Use the |response| + // object to set the mime type, http status code and other optional header + // values. To redirect the request to a new URL set |redirectUrl| to the new + // URL. + /// + void (CEF_CALLBACK *get_response_headers)(struct _cef_scheme_handler_t* self, + struct _cef_response_t* response, int64* response_length, + cef_string_t* redirectUrl); + + /// + // Read response data. If data is available immediately copy up to + // |bytes_to_read| bytes into |data_out|, set |bytes_read| to the number of + // bytes copied, and return true (1). To read the data at a later time set + // |bytes_read| to 0, return true (1) and call bytes_available() when the data + // is available. To indicate response completion return false (0). + /// + int (CEF_CALLBACK *read_response)(struct _cef_scheme_handler_t* self, + void* data_out, int bytes_to_read, int* bytes_read, + struct _cef_scheme_handler_callback_t* callback); + + /// + // Request processing has been canceled. + /// + void (CEF_CALLBACK *cancel)(struct _cef_scheme_handler_t* self); + +} cef_scheme_handler_t; + + +/// +// Structure used to handle file downloads. The functions of this structure will +// always be called on the UI thread. +/// +typedef struct _cef_download_handler_t +{ + // Base structure. + cef_base_t base; + + /// + // A portion of the file contents have been received. This function will be + // called multiple times until the download is complete. Return |true (1)| to + // continue receiving data and |false (0)| to cancel. + /// + int (CEF_CALLBACK *received_data)(struct _cef_download_handler_t* self, + void* data, int data_size); + + /// + // The download is complete. + /// + void (CEF_CALLBACK *complete)(struct _cef_download_handler_t* self); + +} 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_client_t callbacks will be executed. The +// functions of this structure may be called on any thread. +/// +typedef struct _cef_web_urlrequest_t +{ + // Base structure. + cef_base_t base; + + /// + // Cancels the request. + /// + void (CEF_CALLBACK *cancel)(struct _cef_web_urlrequest_t* self); + + /// + // Returns the current ready state of the request. + /// + enum cef_weburlrequest_state_t (CEF_CALLBACK *get_state)( + struct _cef_web_urlrequest_t* self); + +} cef_web_urlrequest_t; + + +/// +// Create a new CefWebUrlRequest object. +/// +CEF_EXPORT cef_web_urlrequest_t* cef_web_urlrequest_create( + cef_request_t* request, struct _cef_web_urlrequest_client_t* client); + + +/// +// Structure that should be implemented by the cef_web_urlrequest_t client. The +// functions of this structure will always be called on the UI thread. +/// +typedef struct _cef_web_urlrequest_client_t +{ + // Base structure. + cef_base_t base; + + /// + // Notifies the client that the request state has changed. State change + // notifications will always be sent before the below notification functions + // are called. + /// + void (CEF_CALLBACK *on_state_change)( + struct _cef_web_urlrequest_client_t* self, + struct _cef_web_urlrequest_t* requester, + enum cef_weburlrequest_state_t state); + + /// + // Notifies the client that the request has been redirected and provides a + // chance to change the request parameters. + /// + void (CEF_CALLBACK *on_redirect)(struct _cef_web_urlrequest_client_t* self, + struct _cef_web_urlrequest_t* requester, struct _cef_request_t* request, + struct _cef_response_t* response); + + /// + // Notifies the client of the response data. + /// + void (CEF_CALLBACK *on_headers_received)( + struct _cef_web_urlrequest_client_t* self, + struct _cef_web_urlrequest_t* requester, + struct _cef_response_t* response); + + /// + // Notifies the client of the upload progress. + /// + void (CEF_CALLBACK *on_progress)(struct _cef_web_urlrequest_client_t* self, + struct _cef_web_urlrequest_t* requester, uint64 bytesSent, + uint64 totalBytesToBeSent); + + /// + // Notifies the client that content has been received. + /// + void (CEF_CALLBACK *on_data)(struct _cef_web_urlrequest_client_t* self, + struct _cef_web_urlrequest_t* requester, const void* data, + int dataLength); + + /// + // Notifies the client that the request ended with an error. + /// + void (CEF_CALLBACK *on_error)(struct _cef_web_urlrequest_client_t* self, + struct _cef_web_urlrequest_t* requester, + enum cef_handler_errorcode_t errorCode); + +} cef_web_urlrequest_client_t; + + +/// +// Structure that supports the reading of XML data via the libxml streaming API. +// The functions of this structure should only be called on the thread that +// creates the object. +/// +typedef struct _cef_xml_reader_t +{ + // Base structure. + cef_base_t base; + + /// + // Moves the cursor to the next node in the document. This function must be + // called at least once to set the current cursor position. Returns true (1) + // if the cursor position was set successfully. + /// + int (CEF_CALLBACK *move_to_next_node)(struct _cef_xml_reader_t* self); + + /// + // Close the document. This should be called directly to ensure that cleanup + // occurs on the correct thread. + /// + int (CEF_CALLBACK *close)(struct _cef_xml_reader_t* self); + + /// + // Returns true (1) if an error has been reported by the XML parser. + /// + int (CEF_CALLBACK *has_error)(struct _cef_xml_reader_t* self); + + /// + // Returns the error string. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_error)( + struct _cef_xml_reader_t* self); + + + // The below functions retrieve data for the node at the current cursor + // position. + + /// + // Returns the node type. + /// + enum cef_xml_node_type_t (CEF_CALLBACK *get_type)( + struct _cef_xml_reader_t* self); + + /// + // Returns the node depth. Depth starts at 0 for the root node. + /// + int (CEF_CALLBACK *get_depth)(struct _cef_xml_reader_t* self); + + /// + // Returns the local name. See http://www.w3.org/TR/REC-xml-names/#NT- + // LocalPart for additional details. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_local_name)( + struct _cef_xml_reader_t* self); + + /// + // Returns the namespace prefix. See http://www.w3.org/TR/REC-xml-names/ for + // additional details. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_prefix)( + struct _cef_xml_reader_t* self); + + /// + // Returns the qualified name, equal to (Prefix:)LocalName. See + // http://www.w3.org/TR/REC-xml-names/#ns-qualnames for additional details. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_qualified_name)( + struct _cef_xml_reader_t* self); + + /// + // Returns the URI defining the namespace associated with the node. See + // http://www.w3.org/TR/REC-xml-names/ for additional details. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_namespace_uri)( + struct _cef_xml_reader_t* self); + + /// + // Returns the base URI of the node. See http://www.w3.org/TR/xmlbase/ for + // additional details. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_base_uri)( + struct _cef_xml_reader_t* self); + + /// + // Returns the xml:lang scope within which the node resides. See + // http://www.w3.org/TR/REC-xml/#sec-lang-tag for additional details. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_xml_lang)( + struct _cef_xml_reader_t* self); + + /// + // Returns true (1) if the node represents an NULL element. is considered + // NULL but is not. + /// + int (CEF_CALLBACK *is_empty_element)(struct _cef_xml_reader_t* self); + + /// + // Returns true (1) if the node has a text value. + /// + int (CEF_CALLBACK *has_value)(struct _cef_xml_reader_t* self); + + /// + // Returns the text value. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_value)( + struct _cef_xml_reader_t* self); + + /// + // Returns true (1) if the node has attributes. + /// + int (CEF_CALLBACK *has_attributes)(struct _cef_xml_reader_t* self); + + /// + // Returns the number of attributes. + /// + size_t (CEF_CALLBACK *get_attribute_count)(struct _cef_xml_reader_t* self); + + /// + // Returns the value of the attribute at the specified 0-based index. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_attribute_byindex)( + struct _cef_xml_reader_t* self, int index); + + /// + // Returns the value of the attribute with the specified qualified name. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_attribute_byqname)( + struct _cef_xml_reader_t* self, const cef_string_t* qualifiedName); + + /// + // Returns the value of the attribute with the specified local name and + // namespace URI. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_attribute_bylname)( + struct _cef_xml_reader_t* self, const cef_string_t* localName, + const cef_string_t* namespaceURI); + + /// + // Returns an XML representation of the current node's children. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_inner_xml)( + struct _cef_xml_reader_t* self); + + /// + // Returns an XML representation of the current node including its children. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_outer_xml)( + struct _cef_xml_reader_t* self); + + /// + // Returns the line number for the current node. + /// + int (CEF_CALLBACK *get_line_number)(struct _cef_xml_reader_t* self); + + + // Attribute nodes are not traversed by default. The below functions can be + // used to move the cursor to an attribute node. move_to_carrying_element() + // can be called afterwards to return the cursor to the carrying element. The + // depth of an attribute node will be 1 + the depth of the carrying element. + + /// + // Moves the cursor to the attribute at the specified 0-based index. Returns + // true (1) if the cursor position was set successfully. + /// + int (CEF_CALLBACK *move_to_attribute_byindex)(struct _cef_xml_reader_t* self, + int index); + + /// + // Moves the cursor to the attribute with the specified qualified name. + // Returns true (1) if the cursor position was set successfully. + /// + int (CEF_CALLBACK *move_to_attribute_byqname)(struct _cef_xml_reader_t* self, + const cef_string_t* qualifiedName); + + /// + // Moves the cursor to the attribute with the specified local name and + // namespace URI. Returns true (1) if the cursor position was set + // successfully. + /// + int (CEF_CALLBACK *move_to_attribute_bylname)(struct _cef_xml_reader_t* self, + const cef_string_t* localName, const cef_string_t* namespaceURI); + + /// + // Moves the cursor to the first attribute in the current element. Returns + // true (1) if the cursor position was set successfully. + /// + int (CEF_CALLBACK *move_to_first_attribute)(struct _cef_xml_reader_t* self); + + /// + // Moves the cursor to the next attribute in the current element. Returns true + // (1) if the cursor position was set successfully. + /// + int (CEF_CALLBACK *move_to_next_attribute)(struct _cef_xml_reader_t* self); + + /// + // Moves the cursor back to the carrying element. Returns true (1) if the + // cursor position was set successfully. + /// + int (CEF_CALLBACK *move_to_carrying_element)(struct _cef_xml_reader_t* self); + +} cef_xml_reader_t; + + +/// +// Create a new cef_xml_reader_t object. The returned object's functions can +// only be called from the thread that created the object. +/// +CEF_EXPORT cef_xml_reader_t* cef_xml_reader_create(cef_stream_reader_t* stream, + enum cef_xml_encoding_type_t encodingType, const cef_string_t* URI); + + +/// +// Structure that supports the reading of zip archives via the zlib unzip API. +// The functions of this structure should only be called on the thread that +// creates the object. +/// +typedef struct _cef_zip_reader_t +{ + // Base structure. + cef_base_t base; + + /// + // Moves the cursor to the first file in the archive. Returns true (1) if the + // cursor position was set successfully. + /// + int (CEF_CALLBACK *move_to_first_file)(struct _cef_zip_reader_t* self); + + /// + // Moves the cursor to the next file in the archive. Returns true (1) if the + // cursor position was set successfully. + /// + int (CEF_CALLBACK *move_to_next_file)(struct _cef_zip_reader_t* self); + + /// + // Moves the cursor to the specified file in the archive. If |caseSensitive| + // is true (1) then the search will be case sensitive. Returns true (1) if the + // cursor position was set successfully. + /// + int (CEF_CALLBACK *move_to_file)(struct _cef_zip_reader_t* self, + const cef_string_t* fileName, int caseSensitive); + + /// + // Closes the archive. This should be called directly to ensure that cleanup + // occurs on the correct thread. + /// + int (CEF_CALLBACK *close)(struct _cef_zip_reader_t* self); + + + // The below functions act on the file at the current cursor position. + + /// + // Returns the name of the file. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_file_name)( + struct _cef_zip_reader_t* self); + + /// + // Returns the uncompressed size of the file. + /// + long (CEF_CALLBACK *get_file_size)(struct _cef_zip_reader_t* self); + + /// + // Returns the last modified timestamp for the file. + /// + time_t (CEF_CALLBACK *get_file_last_modified)(struct _cef_zip_reader_t* self); + + /// + // Opens the file for reading of uncompressed data. A read password may + // optionally be specified. + /// + int (CEF_CALLBACK *open_file)(struct _cef_zip_reader_t* self, + const cef_string_t* password); + + /// + // Closes the file. + /// + int (CEF_CALLBACK *close_file)(struct _cef_zip_reader_t* self); + + /// + // Read uncompressed file contents into the specified buffer. Returns < 0 if + // an error occurred, 0 if at the end of file, or the number of bytes read. + /// + int (CEF_CALLBACK *read_file)(struct _cef_zip_reader_t* self, void* buffer, + size_t bufferSize); + + /// + // Returns the current offset in the uncompressed file contents. + /// + long (CEF_CALLBACK *tell)(struct _cef_zip_reader_t* self); + + /// + // Returns true (1) if at end of the file contents. + /// + int (CEF_CALLBACK *eof)(struct _cef_zip_reader_t* self); + +} cef_zip_reader_t; + + +/// +// Create a new cef_zip_reader_t object. The returned object's functions can +// only be called from the thread that created the object. +/// +CEF_EXPORT cef_zip_reader_t* cef_zip_reader_create(cef_stream_reader_t* stream); + + +/// +// Structure to implement for visiting the DOM. The functions of this structure +// will be called on the UI thread. +/// +typedef struct _cef_domvisitor_t +{ + // Base structure. + cef_base_t base; + + /// + // Method executed for visiting the DOM. The document object passed to this + // function represents a snapshot of the DOM at the time this function is + // executed. DOM objects are only valid for the scope of this function. Do not + // keep references to or attempt to access any DOM objects outside the scope + // of this function. + /// + void (CEF_CALLBACK *visit)(struct _cef_domvisitor_t* self, + struct _cef_domdocument_t* document); + +} cef_domvisitor_t; + + +/// +// Structure used to represent a DOM document. The functions of this structure +// should only be called on the UI thread. +/// +typedef struct _cef_domdocument_t +{ + // Base structure. + cef_base_t base; + + /// + // Returns the document type. + /// + enum cef_dom_document_type_t (CEF_CALLBACK *get_type)( + struct _cef_domdocument_t* self); + + /// + // Returns the root document node. + /// + struct _cef_domnode_t* (CEF_CALLBACK *get_document)( + struct _cef_domdocument_t* self); + + /// + // Returns the BODY node of an HTML document. + /// + struct _cef_domnode_t* (CEF_CALLBACK *get_body)( + struct _cef_domdocument_t* self); + + /// + // Returns the HEAD node of an HTML document. + /// + struct _cef_domnode_t* (CEF_CALLBACK *get_head)( + struct _cef_domdocument_t* self); + + /// + // Returns the title of an HTML document. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_title)( + struct _cef_domdocument_t* self); + + /// + // Returns the document element with the specified ID value. + /// + struct _cef_domnode_t* (CEF_CALLBACK *get_element_by_id)( + struct _cef_domdocument_t* self, const cef_string_t* id); + + /// + // Returns the node that currently has keyboard focus. + /// + struct _cef_domnode_t* (CEF_CALLBACK *get_focused_node)( + struct _cef_domdocument_t* self); + + /// + // Returns true (1) if a portion of the document is selected. + /// + int (CEF_CALLBACK *has_selection)(struct _cef_domdocument_t* self); + + /// + // Returns the selection start node. + /// + struct _cef_domnode_t* (CEF_CALLBACK *get_selection_start_node)( + struct _cef_domdocument_t* self); + + /// + // Returns the selection offset within the start node. + /// + int (CEF_CALLBACK *get_selection_start_offset)( + struct _cef_domdocument_t* self); + + /// + // Returns the selection end node. + /// + struct _cef_domnode_t* (CEF_CALLBACK *get_selection_end_node)( + struct _cef_domdocument_t* self); + + /// + // Returns the selection offset within the end node. + /// + int (CEF_CALLBACK *get_selection_end_offset)(struct _cef_domdocument_t* self); + + /// + // Returns the contents of this selection as markup. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_selection_as_markup)( + struct _cef_domdocument_t* self); + + /// + // Returns the contents of this selection as text. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_selection_as_text)( + struct _cef_domdocument_t* self); + + /// + // Returns the base URL for the document. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_base_url)( + struct _cef_domdocument_t* self); + + /// + // Returns a complete URL based on the document base URL and the specified + // partial URL. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_complete_url)( + struct _cef_domdocument_t* self, const cef_string_t* partialURL); + +} cef_domdocument_t; + + +/// +// Structure used to represent a DOM node. The functions of this structure +// should only be called on the UI thread. +/// +typedef struct _cef_domnode_t +{ + // Base structure. + cef_base_t base; + + /// + // Returns the type for this node. + /// + enum cef_dom_node_type_t (CEF_CALLBACK *get_type)( + struct _cef_domnode_t* self); + + /// + // Returns true (1) if this is a text node. + /// + int (CEF_CALLBACK *is_text)(struct _cef_domnode_t* self); + + /// + // Returns true (1) if this is an element node. + /// + int (CEF_CALLBACK *is_element)(struct _cef_domnode_t* self); + + /// + // Returns true (1) if this is a form control element node. + /// + int (CEF_CALLBACK *is_form_control_element)(struct _cef_domnode_t* self); + + /// + // Returns the type of this form control element node. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_form_control_element_type)( + struct _cef_domnode_t* self); + + /// + // Returns true (1) if this object is pointing to the same handle as |that| + // object. + /// + int (CEF_CALLBACK *is_same)(struct _cef_domnode_t* self, + struct _cef_domnode_t* that); + + /// + // Returns the name of this node. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_name)(struct _cef_domnode_t* self); + + /// + // Returns the value of this node. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_value)(struct _cef_domnode_t* self); + + /// + // Set the value of this node. Returns true (1) on success. + /// + int (CEF_CALLBACK *set_value)(struct _cef_domnode_t* self, + const cef_string_t* value); + + /// + // Returns the contents of this node as markup. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_as_markup)( + struct _cef_domnode_t* self); + + /// + // Returns the document associated with this node. + /// + struct _cef_domdocument_t* (CEF_CALLBACK *get_document)( + struct _cef_domnode_t* self); + + /// + // Returns the parent node. + /// + struct _cef_domnode_t* (CEF_CALLBACK *get_parent)( + struct _cef_domnode_t* self); + + /// + // Returns the previous sibling node. + /// + struct _cef_domnode_t* (CEF_CALLBACK *get_previous_sibling)( + struct _cef_domnode_t* self); + + /// + // Returns the next sibling node. + /// + struct _cef_domnode_t* (CEF_CALLBACK *get_next_sibling)( + struct _cef_domnode_t* self); + + /// + // Returns true (1) if this node has child nodes. + /// + int (CEF_CALLBACK *has_children)(struct _cef_domnode_t* self); + + /// + // Return the first child node. + /// + struct _cef_domnode_t* (CEF_CALLBACK *get_first_child)( + struct _cef_domnode_t* self); + + /// + // Returns the last child node. + /// + struct _cef_domnode_t* (CEF_CALLBACK *get_last_child)( + struct _cef_domnode_t* self); + + /// + // Add an event listener to this node for the specified event type. If + // |useCapture| is true (1) then this listener will be considered a capturing + // listener. Capturing listeners will recieve all events of the specified type + // before the events are dispatched to any other event targets beneath the + // current node in the tree. Events which are bubbling upwards through the + // tree will not trigger a capturing listener. Separate calls to this function + // can be used to register the same listener with and without capture. See + // WebCore/dom/EventNames.h for the list of supported event types. + /// + void (CEF_CALLBACK *add_event_listener)(struct _cef_domnode_t* self, + const cef_string_t* eventType, struct _cef_domevent_listener_t* listener, + int useCapture); + + + // The following functions are valid only for element nodes. + + /// + // Returns the tag name of this element. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_element_tag_name)( + struct _cef_domnode_t* self); + + /// + // Returns true (1) if this element has attributes. + /// + int (CEF_CALLBACK *has_element_attributes)(struct _cef_domnode_t* self); + + /// + // Returns true (1) if this element has an attribute named |attrName|. + /// + int (CEF_CALLBACK *has_element_attribute)(struct _cef_domnode_t* self, + const cef_string_t* attrName); + + /// + // Returns the element attribute named |attrName|. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_element_attribute)( + struct _cef_domnode_t* self, const cef_string_t* attrName); + + /// + // Returns a map of all element attributes. + /// + void (CEF_CALLBACK *get_element_attributes)(struct _cef_domnode_t* self, + cef_string_map_t attrMap); + + /// + // Set the value for the element attribute named |attrName|. Returns true (1) + // on success. + /// + int (CEF_CALLBACK *set_element_attribute)(struct _cef_domnode_t* self, + const cef_string_t* attrName, const cef_string_t* value); + + /// + // Returns the inner text of the element. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_element_inner_text)( + struct _cef_domnode_t* self); + +} cef_domnode_t; + + +/// +// Structure used to represent a DOM event. The functions of this structure +// should only be called on the UI thread. +/// +typedef struct _cef_domevent_t +{ + // Base structure. + cef_base_t base; + + /// + // Returns the event type. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_type)(struct _cef_domevent_t* self); + + /// + // Returns the event category. + /// + enum cef_dom_event_category_t (CEF_CALLBACK *get_category)( + struct _cef_domevent_t* self); + + /// + // Returns the event processing phase. + /// + enum cef_dom_event_phase_t (CEF_CALLBACK *get_phase)( + struct _cef_domevent_t* self); + + /// + // Returns true (1) if the event can bubble up the tree. + /// + int (CEF_CALLBACK *can_bubble)(struct _cef_domevent_t* self); + + /// + // Returns true (1) if the event can be canceled. + /// + int (CEF_CALLBACK *can_cancel)(struct _cef_domevent_t* self); + + /// + // Returns the document associated with this event. + /// + struct _cef_domdocument_t* (CEF_CALLBACK *get_document)( + struct _cef_domevent_t* self); + + /// + // Returns the target of the event. + /// + struct _cef_domnode_t* (CEF_CALLBACK *get_target)( + struct _cef_domevent_t* self); + + /// + // Returns the current target of the event. + /// + struct _cef_domnode_t* (CEF_CALLBACK *get_current_target)( + struct _cef_domevent_t* self); + +} cef_domevent_t; + + +/// +// Structure to implement for handling DOM events. The functions of this +// structure will be called on the UI thread. +/// +typedef struct _cef_domevent_listener_t +{ + // Base structure. + cef_base_t base; + + /// + // Called when an event is received. The event object passed to this function + // contains a snapshot of the DOM at the time this function is executed. DOM + // objects are only valid for the scope of this function. Do not keep + // references to or attempt to access any DOM objects outside the scope of + // this function. + /// + void (CEF_CALLBACK *handle_event)(struct _cef_domevent_listener_t* self, + struct _cef_domevent_t* event); + +} cef_domevent_listener_t; + + +/// +// Structure to implement for filtering response content. The functions of this +// structure will always be called on the UI thread. +/// +typedef struct _cef_content_filter_t +{ + // Base structure. + cef_base_t base; + + /// + // Set |substitute_data| to the replacement for the data in |data| if data + // should be modified. + /// + void (CEF_CALLBACK *process_data)(struct _cef_content_filter_t* self, + const void* data, int data_size, + struct _cef_stream_reader_t** substitute_data); + + /// + // Called when there is no more data to be processed. It is expected that + // whatever data was retained in the last process_data() call, it should be + // returned now by setting |remainder| if appropriate. + /// + void (CEF_CALLBACK *drain)(struct _cef_content_filter_t* self, + struct _cef_stream_reader_t** remainder); + +} cef_content_filter_t; + + +/// +// Structure used to represent drag data. The functions of this structure may be +// called on any thread. +/// +typedef struct _cef_drag_data_t +{ + // Base structure. + cef_base_t base; + + /// + // Returns true (1) if the drag data is a link. + /// + int (CEF_CALLBACK *is_link)(struct _cef_drag_data_t* self); + + /// + // Returns true (1) if the drag data is a text or html fragment. + /// + int (CEF_CALLBACK *is_fragment)(struct _cef_drag_data_t* self); + + /// + // Returns true (1) if the drag data is a file. + /// + int (CEF_CALLBACK *is_file)(struct _cef_drag_data_t* self); + + /// + // Return the link URL that is being dragged. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_link_url)( + struct _cef_drag_data_t* self); + + /// + // Return the title associated with the link being dragged. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_link_title)( + struct _cef_drag_data_t* self); + + /// + // Return the metadata, if any, associated with the link being dragged. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_link_metadata)( + struct _cef_drag_data_t* self); + + /// + // Return the plain text fragment that is being dragged. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_fragment_text)( + struct _cef_drag_data_t* self); + + /// + // Return the text/html fragment that is being dragged. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_fragment_html)( + struct _cef_drag_data_t* self); + + /// + // Return the base URL that the fragment came from. This value is used for + // resolving relative URLs and may be NULL. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_fragment_base_url)( + struct _cef_drag_data_t* self); + + /// + // Return the extension of the file being dragged out of the browser window. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_file_extension)( + struct _cef_drag_data_t* self); + + /// + // Return the name of the file being dragged out of the browser window. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_file_name)( + struct _cef_drag_data_t* self); + + /// + // Retrieve the list of file names that are being dragged into the browser + // window. + /// + int (CEF_CALLBACK *get_file_names)(struct _cef_drag_data_t* self, + cef_string_list_t names); + +} cef_drag_data_t; + + +/// +// Structure used to create and/or parse command line arguments. Arguments with +// '--', '-' and, on Windows, '/' prefixes are considered switches. Switches +// will always precede any arguments without switch prefixes. Switches can +// optionally have a value specified using the '=' delimiter (e.g. +// "-switch=value"). An argument of "--" will terminate switch parsing with all +// subsequent tokens, regardless of prefix, being interpreted as non-switch +// arguments. Switch names are considered case-insensitive. This structure can +// be used before cef_initialize() is called. +/// +typedef struct _cef_command_line_t +{ + // Base structure. + cef_base_t base; + + /// + // Initialize the command line with the specified |argc| and |argv| values. + // The first argument must be the name of the program. This function is only + // supported on non-Windows platforms. + /// + void (CEF_CALLBACK *init_from_argv)(struct _cef_command_line_t* self, + int argc, const char* const* argv); + + /// + // Initialize the command line with the string returned by calling + // GetCommandLineW(). This function is only supported on Windows. + /// + void (CEF_CALLBACK *init_from_string)(struct _cef_command_line_t* self, + const cef_string_t* command_line); + + /// + // Constructs and returns the represented command line string. Use this + // function cautiously because quoting behavior is unclear. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_command_line_string)( + struct _cef_command_line_t* self); + + /// + // Get the program part of the command line string (the first item). + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_program)( + struct _cef_command_line_t* self); + + /// + // Set the program part of the command line string (the first item). + /// + void (CEF_CALLBACK *set_program)(struct _cef_command_line_t* self, + const cef_string_t* program); + + /// + // Returns true (1) if the command line has switches. + /// + int (CEF_CALLBACK *has_switches)(struct _cef_command_line_t* self); + + /// + // Returns true (1) if the command line contains the given switch. + /// + int (CEF_CALLBACK *has_switch)(struct _cef_command_line_t* self, + const cef_string_t* name); + + /// + // Returns the value associated with the given switch. If the switch has no + // value or isn't present this function returns the NULL string. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_switch_value)( + struct _cef_command_line_t* self, const cef_string_t* name); + + /// + // Returns the map of switch names and values. If a switch has no value an + // NULL string is returned. + /// + void (CEF_CALLBACK *get_switches)(struct _cef_command_line_t* self, + cef_string_map_t switches); + + /// + // Add a switch to the end of the command line. If the switch has no value + // pass an NULL value string. + /// + void (CEF_CALLBACK *append_switch)(struct _cef_command_line_t* self, + const cef_string_t* name); + + /// + // Add a switch with the specified value to the end of the command line. + /// + void (CEF_CALLBACK *append_switch_with_value)( + struct _cef_command_line_t* self, const cef_string_t* name, + const cef_string_t* value); + + /// + // True if there are remaining command line arguments. + /// + int (CEF_CALLBACK *has_arguments)(struct _cef_command_line_t* self); + + /// + // Get the remaining command line arguments. + /// + void (CEF_CALLBACK *get_arguments)(struct _cef_command_line_t* self, + cef_string_list_t arguments); + + /// + // Add an argument to the end of the command line. + /// + void (CEF_CALLBACK *append_argument)(struct _cef_command_line_t* self, + const cef_string_t* argument); + +} cef_command_line_t; + + +/// +// Create a new cef_command_line_t instance. +/// +CEF_EXPORT cef_command_line_t* cef_command_line_create(); + + +#ifdef __cplusplus +} +#endif + +#endif // _CEF_CAPI_H diff --git a/cef/include/cef_nplugin.h b/cef/include/cef_nplugin.h new file mode 100755 index 000000000..59f314455 --- /dev/null +++ b/cef/include/cef_nplugin.h @@ -0,0 +1,129 @@ +// 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_NPLUGIN_H +#define _CEF_NPLUGIN_H + +#include "internal/cef_nplugin_types.h" + +/// +// Netscape plugins are normally built at separate DLLs that are loaded by the +// browser when needed. This interface supports the creation of plugins that +// are an embedded component of the application. Embedded plugins built using +// this interface use the same Netscape Plugin API as DLL-based plugins. +// See https://developer.mozilla.org/En/Gecko_Plugin_API_Reference for complete +// documentation on how to use the Netscape Plugin API. +// +// This class provides attribute information and entry point functions for a +// plugin. +/// +class CefPluginInfo : public cef_plugin_info_t +{ +public: + CefPluginInfo() + { + Init(); + } + virtual ~CefPluginInfo() + { + Reset(); + } + + CefPluginInfo(const CefPluginInfo& r) + { + Init(); + *this = r; + } + CefPluginInfo(const cef_plugin_info_t& r) + { + Init(); + *this = r; + } + + void Reset() + { + cef_string_clear(&unique_name); + cef_string_clear(&display_name); + cef_string_clear(&version); + cef_string_clear(&description); + cef_string_clear(&mime_types); + cef_string_clear(&file_extensions); + cef_string_clear(&type_descriptions); + Init(); + } + + void Attach(const cef_plugin_info_t& r) + { + Reset(); + *static_cast(this) = r; + } + + void Detach() + { + Init(); + } + + CefPluginInfo& operator=(const CefPluginInfo& r) + { + return operator=(static_cast(r)); + } + + CefPluginInfo& operator=(const cef_plugin_info_t& r) + { + cef_string_copy(r.unique_name.str, r.unique_name.length, &unique_name); + cef_string_copy(r.display_name.str, r.display_name.length, &display_name); + cef_string_copy(r.version.str, r.version.length, &version); + cef_string_copy(r.description.str, r.description.length, &description); + cef_string_copy(r.mime_types.str, r.mime_types.length, &mime_types); + cef_string_copy(r.file_extensions.str, r.file_extensions.length, + &file_extensions); + cef_string_copy(r.type_descriptions.str, r.type_descriptions.length, + &type_descriptions); +#if !defined(OS_POSIX) || defined(OS_MACOSX) + np_getentrypoints = r.np_getentrypoints; +#endif + np_initialize = r.np_initialize; + np_shutdown = r.np_shutdown; + return *this; + } + +protected: + void Init() + { + memset(static_cast(this), 0, sizeof(cef_plugin_info_t)); + } +}; + +/// +// Register a plugin with the system. +/// +bool CefRegisterPlugin(const CefPluginInfo& plugin_info); + +#endif // _CEF_NPLUGIN_H diff --git a/cef/include/cef_nplugin_capi.h b/cef/include/cef_nplugin_capi.h new file mode 100755 index 000000000..f3f46d080 --- /dev/null +++ b/cef/include/cef_nplugin_capi.h @@ -0,0 +1,49 @@ +// 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_NPLUGIN_CAPI_H +#define _CEF_NPLUGIN_CAPI_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "internal/cef_nplugin_types.h" + +/// +// Register a plugin with the system. Returns true (1) on success. +/// +CEF_EXPORT int cef_register_plugin(const cef_plugin_info_t* plugin_info); + +#ifdef __cplusplus +} +#endif + +#endif // _CEF_NPLUGIN_CAPI_H diff --git a/cef/include/cef_runnable.h b/cef/include/cef_runnable.h new file mode 100755 index 000000000..a311f2cc1 --- /dev/null +++ b/cef/include/cef_runnable.h @@ -0,0 +1,345 @@ +// Copyright (c) 2011 Marshall A. Greenblatt. Portions Copyright (c) +// 2006-2011 Google Inc. 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. +// +// The contents of this file are a modified extract of base/task.h + +#ifndef _CEF_RUNNABLE_H +#define _CEF_RUNNABLE_H +#pragma once + +#include "cef.h" +#ifdef BUILDING_CEF_SHARED +#include "base/tuple.h" +#else +#include "internal/cef_tuple.h" +#endif + +// CefRunnableMethodTraits ----------------------------------------------------- +// +// This traits-class is used by CefRunnableMethod to manage the lifetime of the +// callee object. By default, it is assumed that the callee supports AddRef +// and Release methods. A particular class can specialize this template to +// define other lifetime management. For example, if the callee is known to +// live longer than the CefRunnableMethod object, then a CefRunnableMethodTraits +// struct could be defined with empty RetainCallee and ReleaseCallee methods. +// +// The DISABLE_RUNNABLE_METHOD_REFCOUNT macro is provided as a convenient way +// for declaring a CefRunnableMethodTraits that disables refcounting. + +template +struct CefRunnableMethodTraits { + CefRunnableMethodTraits() { + } + + ~CefRunnableMethodTraits() { + } + + void RetainCallee(T* obj) { +#ifndef NDEBUG + // Catch NewCefRunnableMethod being called in an object's constructor. + // This isn't safe since the method can be invoked before the constructor + // completes, causing the object to be deleted. + obj->AddRef(); + obj->Release(); +#endif + obj->AddRef(); + } + + void ReleaseCallee(T* obj) { + obj->Release(); + } +}; + +// Convenience macro for declaring a CefRunnableMethodTraits that disables +// refcounting of a class. This is useful if you know that the callee +// will outlive the CefRunnableMethod object and thus do not need the ref +// counts. +// +// The invocation of DISABLE_RUNNABLE_METHOD_REFCOUNT should be done at the +// global namespace scope. Example: +// +// namespace foo { +// class Bar { +// ... +// }; +// } // namespace foo +// +// DISABLE_RUNNABLE_METHOD_REFCOUNT(foo::Bar); +// +// This is different from DISALLOW_COPY_AND_ASSIGN which is declared inside the +// class. +#define DISABLE_RUNNABLE_METHOD_REFCOUNT(TypeName) \ + template <> \ + struct CefRunnableMethodTraits { \ + void RetainCallee(TypeName* manager) {} \ + void ReleaseCallee(TypeName* manager) {} \ + } + +// CefRunnableMethod and CefRunnableFunction ---------------------------------- +// +// CefRunnable methods are a type of task that call a function on an object +// when they are run. We implement both an object and a set of +// NewCefRunnableMethod and NewCefRunnableFunction functions for convenience. +// These functions are overloaded and will infer the template types, +// simplifying calling code. +// +// The template definitions all use the following names: +// T - the class type of the object you're supplying +// this is not needed for the Static version of the call +// Method/Function - the signature of a pointer to the method or function you +// want to call +// Param - the parameter(s) to the method, possibly packed as a Tuple +// A - the first parameter (if any) to the method +// B - the second parameter (if any) to the method +// +// Put these all together and you get an object that can call a method whose +// signature is: +// R T::MyFunction([A[, B]]) +// +// Usage: +// CefPostTask(TID_UI, NewCefRunnableMethod(object, &Object::method[, a[, b]]) +// CefPostTask(TID_UI, NewCefRunnableFunction(&function[, a[, b]]) + +// CefRunnableMethod and NewCefRunnableMethod implementation ------------------ + +template +class CefRunnableMethod : public CefTask { + public: + CefRunnableMethod(T* obj, Method meth, const Params& params) + : obj_(obj), meth_(meth), params_(params) { + traits_.RetainCallee(obj_); + } + + ~CefRunnableMethod() { + T* obj = obj_; + obj_ = NULL; + if (obj) + traits_.ReleaseCallee(obj); + } + + virtual void Execute(CefThreadId threadId) { + if (obj_) + DispatchToMethod(obj_, meth_, params_); + } + + private: + T* obj_; + Method meth_; + Params params_; + CefRunnableMethodTraits traits_; + + IMPLEMENT_REFCOUNTING(CefRunnableMethod); +}; + +template +inline CefRefPtr NewCefRunnableMethod(T* object, Method method) { + return new CefRunnableMethod(object, method, MakeTuple()); +} + +template +inline CefRefPtr NewCefRunnableMethod(T* object, Method method, + const A& a) { + return new CefRunnableMethod >(object, + method, + MakeTuple(a)); +} + +template +inline CefRefPtr NewCefRunnableMethod(T* object, Method method, + const A& a, const B& b) { + return new CefRunnableMethod >(object, method, + MakeTuple(a, b)); +} + +template +inline CefRefPtr NewCefRunnableMethod(T* object, Method method, + const A& a, const B& b, + const C& c) { + return new CefRunnableMethod >(object, method, + MakeTuple(a, b, + c)); +} + +template +inline CefRefPtr NewCefRunnableMethod(T* object, Method method, + const A& a, const B& b, + const C& c, const D& d) { + return new CefRunnableMethod >(object, method, + MakeTuple(a, b, + c, + d)); +} + +template +inline CefRefPtr NewCefRunnableMethod(T* object, Method method, + const A& a, const B& b, + const C& c, const D& d, + const E& e) { + return new CefRunnableMethod >(object, + method, + MakeTuple(a, b, c, d, + e)); +} + +template +inline CefRefPtr NewCefRunnableMethod(T* object, Method method, + const A& a, const B& b, + const C& c, const D& d, + const E& e, const F& f) { + return new CefRunnableMethod >(object, + method, + MakeTuple(a, b, c, d, + e, f)); +} + +template +inline CefRefPtr NewCefRunnableMethod(T* object, Method method, + const A& a, const B& b, + const C& c, const D& d, + const E& e, const F& f, + const G& g) { + return new CefRunnableMethod >(object, + method, + MakeTuple(a, b, c, + d, e, f, + g)); +} + +// CefRunnableFunction and NewCefRunnableFunction implementation -------------- + +template +class CefRunnableFunction : public CefTask { + public: + CefRunnableFunction(Function function, const Params& params) + : function_(function), params_(params) { + } + + ~CefRunnableFunction() { + } + + virtual void Execute(CefThreadId threadId) { + if (function_) + DispatchToFunction(function_, params_); + } + + private: + Function function_; + Params params_; + + IMPLEMENT_REFCOUNTING(CefRunnableFunction); +}; + +template +inline CefRefPtr NewCefRunnableFunction(Function function) { + return new CefRunnableFunction(function, MakeTuple()); +} + +template +inline CefRefPtr NewCefRunnableFunction(Function function, + const A& a) { + return new CefRunnableFunction >(function, MakeTuple(a)); +} + +template +inline CefRefPtr NewCefRunnableFunction(Function function, + const A& a, const B& b) { + return new CefRunnableFunction >(function, + MakeTuple(a, b)); +} + +template +inline CefRefPtr NewCefRunnableFunction(Function function, + const A& a, const B& b, + const C& c) { + return new CefRunnableFunction >(function, + MakeTuple(a, b, + c)); +} + +template +inline CefRefPtr NewCefRunnableFunction(Function function, + const A& a, const B& b, + const C& c, const D& d) { + return new CefRunnableFunction >(function, + MakeTuple(a, b, + c, + d)); +} + +template +inline CefRefPtr NewCefRunnableFunction(Function function, + const A& a, const B& b, + const C& c, const D& d, + const E& e) { + return new CefRunnableFunction >(function, + MakeTuple(a, b, c, d, e)); +} + +template +inline CefRefPtr NewCefRunnableFunction(Function function, + const A& a, const B& b, + const C& c, const D& d, + const E& e, const F& f) { + return new CefRunnableFunction >(function, + MakeTuple(a, b, c, d, e, f)); +} + +template +inline CefRefPtr NewCefRunnableFunction(Function function, + const A& a, const B& b, + const C& c, const D& d, + const E& e, const F& f, + const G& g) { + return new CefRunnableFunction >( + function, MakeTuple(a, b, c, d, e, f, g)); +} + +template +inline CefRefPtr NewCefRunnableFunction(Function function, + const A& a, const B& b, + const C& c, const D& d, + const E& e, const F& f, + const G& g, const H& h) { + return new CefRunnableFunction >( + function, MakeTuple(a, b, c, d, e, f, g, h)); +} + +#endif // _CEF_RUNNABLE_H diff --git a/cef/include/cef_version.h b/cef/include/cef_version.h new file mode 100755 index 000000000..0a008fb9b --- /dev/null +++ b/cef/include/cef_version.h @@ -0,0 +1,68 @@ +// 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. +// +// --------------------------------------------------------------------------- +// +// This file is generated by the make_version_header.py tool. +// + +#ifndef _CEF_VERSION_H +#define _CEF_VERSION_H + +#define CEF_REVISION 439 +#define COPYRIGHT_YEAR 2011 + +#define CHROME_VERSION_MAJOR 17 +#define CHROME_VERSION_MINOR 0 +#define CHROME_VERSION_BUILD 963 +#define CHROME_VERSION_PATCH 15 + +#define DO_MAKE_STRING(p) #p +#define MAKE_STRING(p) DO_MAKE_STRING(p) + +#ifndef APSTUDIO_HIDDEN_SYMBOLS + +#ifdef __cplusplus +extern "C" { +#endif + +#include "internal/cef_export.h" + +/// +// Returns the CEF build revision of the libcef library. +/// +CEF_EXPORT int cef_build_revision(); + +#ifdef __cplusplus +} +#endif + +#endif // APSTUDIO_HIDDEN_SYMBOLS + +#endif // _CEF_VERSION_H diff --git a/cef/include/cef_wrapper.h b/cef/include/cef_wrapper.h new file mode 100755 index 000000000..e455ce812 --- /dev/null +++ b/cef/include/cef_wrapper.h @@ -0,0 +1,322 @@ +// Copyright (c) 2010 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. +// +// --------------------------------------------------------------------------- +// +// The contents of this file are only available to applications that link +// against the libcef_dll_wrapper target. +// + +#ifndef _CEF_WRAPPER_H +#define _CEF_WRAPPER_H + +#include "cef.h" +#include +#include + +/// +// Thread safe class for representing XML data as a structured object. This +// class should not be used with large XML documents because all data will be +// resident in memory at the same time. This implementation supports a +// restricted set of XML features: +//
+// (1) Processing instructions, whitespace and comments are ignored.
+// (2) Elements and attributes must always be referenced using the fully
+//     qualified name (ie, namespace:localname).
+// (3) Empty elements () and elements with zero-length values ()
+//     are considered the same.
+// (4) Element nodes are considered part of a value if:
+//     (a) The element node follows a non-element node at the same depth
+//         (see 5), or
+//     (b) The element node does not have a namespace and the parent node does.
+// (5) Mixed node types at the same depth are combined into a single element
+//     value as follows:
+//     (a) All node values are concatenated to form a single string value.
+//     (b) Entity reference nodes are resolved to the corresponding entity
+//         value.
+//     (c) Element nodes are represented by their outer XML string.
+// 
+/// +class CefXmlObject : public CefBase +{ +public: + typedef std::vector > ObjectVector; + typedef std::map AttributeMap; + + /// + // Create a new object with the specified name. An object name must always be + // at least one character long. + /// + CefXmlObject(const CefString& name); + virtual ~CefXmlObject(); + + /// + // Load the contents of the specified XML stream into this object. The + // existing children and attributes, if any, will first be cleared. + /// + bool Load(CefRefPtr stream, + CefXmlReader::EncodingType encodingType, + const CefString& URI, CefString* loadError); + + /// + // Set the name, children and attributes of this object to a duplicate of the + // specified object's contents. The existing children and attributes, if any, + // will first be cleared. + /// + void Set(CefRefPtr object); + + /// + // Append a duplicate of the children and attributes of the specified object + // to this object. If |overwriteAttributes| is true then any attributes in + // this object that also exist in the specified object will be overwritten + // with the new values. The name of this object is not changed. + /// + void Append(CefRefPtr object, bool overwriteAttributes); + + /// + // Return a new object with the same name, children and attributes as this + // object. The parent of the new object will be NULL. + /// + CefRefPtr Duplicate(); + + /// + // Clears this object's children and attributes. The name and parenting of + // this object are not changed. + /// + void Clear(); + + /// + // Access the object's name. An object name must always be at least one + // character long. + /// + CefString GetName(); + bool SetName(const CefString& name); + + /// + // Access the object's parent. The parent can be NULL if this object has not + // been added as the child on another object. + /// + bool HasParent(); + CefRefPtr GetParent(); + + /// + // Access the object's value. An object cannot have a value if it also has + // children. Attempting to set the value while children exist will fail. + /// + bool HasValue(); + CefString GetValue(); + bool SetValue(const CefString& value); + + /// + // Access the object's attributes. Attributes must have unique names. + /// + bool HasAttributes(); + size_t GetAttributeCount(); + bool HasAttribute(const CefString& name); + CefString GetAttributeValue(const CefString& name); + bool SetAttributeValue(const CefString& name, const CefString& value); + size_t GetAttributes(AttributeMap& attributes); + void ClearAttributes(); + + /// + // Access the object's children. Each object can only have one parent so + // attempting to add an object that already has a parent will fail. Removing a + // child will set the child's parent to NULL. Adding a child will set the + // child's parent to this object. This object's value, if any, will be cleared + // if a child is added. + /// + bool HasChildren(); + size_t GetChildCount(); + bool HasChild(CefRefPtr child); + bool AddChild(CefRefPtr child); + bool RemoveChild(CefRefPtr child); + size_t GetChildren(ObjectVector& children); + void ClearChildren(); + + /// + // Find the first child with the specified name. + /// + CefRefPtr FindChild(const CefString& name); + + /// + // Find all children with the specified name. + /// + size_t FindChildren(const CefString& name, ObjectVector& children); + +private: + void SetParent(CefXmlObject* parent); + + CefString name_; + CefXmlObject* parent_; + 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 CefReadHandler +{ +public: + /// + // Create a new object for reading an array of bytes. An optional |source| + // reference can be kept to keep the underlying data source from being + // released while the reader exists. + /// + CefByteReadHandler(const unsigned char* bytes, size_t size, + CefRefPtr source); + + /// + // Read raw binary data. + /// + virtual size_t Read(void* ptr, size_t size, size_t n); + + /// + // Seek to the specified offset position. |whence| may be any one of + // SEEK_CUR, SEEK_END or SEEK_SET. + /// + virtual int Seek(long offset, int whence); + + /// + // Return the current offset position. + /// + virtual long Tell(); + + /// + // Return non-zero if at end of file. + /// + virtual int Eof(); + +private: + const unsigned char* bytes_; + size_t size_; + size_t offset_; + CefRefPtr source_; + + IMPLEMENT_REFCOUNTING(CefByteReadHandler); + IMPLEMENT_LOCKING(CefByteReadHandler); +}; + + +/// +// Thread-safe class for accessing zip archive file contents. This class should +// not be used with large archive files because all data will be resident in +// memory at the same time. This implementation supports a restricted set of zip +// archive features: +// (1) Password-protected files are not supported. +// (2) All file names are stored and compared in lower case. +// (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 CefBase +{ +public: + /// + // Class representing a file in the archive. Accessing the file data from + // multiple threads is safe provided a reference to the File object is kept. + /// + class File : public CefBase + { + public: + /// + // Returns the read-only data contained in the file. + /// + virtual const unsigned char* GetData() =0; + + /// + // Returns the size of the data in the file. + /// + virtual size_t GetDataSize() =0; + + /// + // Returns a CefStreamReader object for streaming the contents of the file. + /// + virtual CefRefPtr GetStreamReader() =0; + }; + typedef std::map > FileMap; + + /// + // Create a new object. + /// + CefZipArchive(); + virtual ~CefZipArchive(); + + /// + // Load the contents of the specified zip archive stream into this object. + // If |overwriteExisting| is true then any files in this object that also + // exist in the specified archive will be replaced with the new files. + // Returns the number of files successfully loaded. + /// + size_t Load(CefRefPtr stream, bool overwriteExisting); + + /// + // Clears the contents of this object. + /// + void Clear(); + + /// + // Returns the number of files in the archive. + /// + size_t GetFileCount(); + + /// + // Returns true if the specified file exists and has contents. + /// + bool HasFile(const CefString& fileName); + + /// + // Returns the specified file. + /// + CefRefPtr GetFile(const CefString& fileName); + + /// + // Removes the specified file. + /// + bool RemoveFile(const CefString& fileName); + + /// + // Returns the map of all files. + /// + size_t GetFiles(FileMap& map); + +private: + FileMap contents_; + + IMPLEMENT_REFCOUNTING(CefZipArchive); + IMPLEMENT_LOCKING(CefZipArchive); +}; + +#endif // _CEF_WRAPPER_H diff --git a/cef/include/internal/cef_build.h b/cef/include/internal/cef_build.h new file mode 100755 index 000000000..150751c96 --- /dev/null +++ b/cef/include/internal/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/cef/include/internal/cef_export.h b/cef/include/internal/cef_export.h new file mode 100755 index 000000000..3a56adaf3 --- /dev/null +++ b/cef/include/internal/cef_export.h @@ -0,0 +1,54 @@ +// Copyright (c) 2009 The Chromium Embedded Framework Authors. 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_EXPORT_H +#define _CEF_EXPORT_H + +#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 +#define CEF_CALLBACK __stdcall + +#elif defined(COMPILER_GCC) + +#define CEF_EXPORT __attribute__ ((visibility("default"))) +#define CEF_CALLBACK + +#endif // COMPILER_GCC + +#endif // _CEF_EXPORT_H diff --git a/cef/include/internal/cef_mac.h b/cef/include/internal/cef_mac.h new file mode 100755 index 000000000..b949343af --- /dev/null +++ b/cef/include/internal/cef_mac.h @@ -0,0 +1,144 @@ +// Copyright (c) 2010 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_MAC_H +#define _CEF_MAC_H + +#if defined(OS_MACOSX) +#include +#include "cef_types_mac.h" +#include "cef_types_wrappers.h" + +// Atomic increment and decrement. +inline long CefAtomicIncrement(long volatile *pDest) +{ + return __sync_add_and_fetch(pDest, 1); +} +inline long CefAtomicDecrement(long volatile *pDest) +{ + return __sync_sub_and_fetch(pDest, 1); +} + +// Handle types. +#define CefWindowHandle cef_window_handle_t +#define CefCursorHandle cef_cursor_handle_t + +// Critical section wrapper. +class CefCriticalSection +{ +public: + CefCriticalSection() + { + pthread_mutexattr_init(&attr_); + pthread_mutexattr_settype(&attr_, PTHREAD_MUTEX_RECURSIVE); + pthread_mutex_init(&lock_, &attr_); + } + virtual ~CefCriticalSection() + { + pthread_mutex_destroy(&lock_); + pthread_mutexattr_destroy(&attr_); + } + void Lock() + { + pthread_mutex_lock(&lock_); + } + void Unlock() + { + pthread_mutex_unlock(&lock_); + } + + pthread_mutex_t lock_; + pthread_mutexattr_t attr_; +}; + +struct CefWindowInfoTraits { + typedef cef_window_info_t struct_type; + + static inline void init(struct_type* s) {} + + static inline void clear(struct_type* s) + { + cef_string_clear(&s->m_windowName); + } + + static inline void set(const struct_type* src, struct_type* target, bool copy) + { + target->m_View = src->m_View; + target->m_ParentView = src->m_ParentView; + cef_string_set(src->m_windowName.str, src->m_windowName.length, + &target->m_windowName, copy); + target->m_x = src->m_x; + target->m_y = src->m_y; + target->m_nWidth = src->m_nWidth; + target->m_nHeight = src->m_nHeight; + target->m_bHidden = src->m_bHidden; + } +}; + +// Class representing window information. +class CefWindowInfo : public CefStructBase +{ +public: + typedef CefStructBase parent; + + CefWindowInfo() : parent() {} + CefWindowInfo(const cef_window_info_t& r) : parent(r) {} + CefWindowInfo(const CefWindowInfo& r) : parent(r) {} + + void SetAsChild(CefWindowHandle ParentView, int x, int y, int width, + int height) + { + m_ParentView = ParentView; + m_x = x; + m_y = y; + m_nWidth = width; + m_nHeight = height; + m_bHidden = false; + } +}; + +struct CefPrintInfoTraits { + typedef cef_print_info_t struct_type; + + static inline void init(struct_type* s) {} + static inline void clear(struct_type* s) {} + + static inline void set(const struct_type* src, struct_type* target, bool copy) + { + target->m_Scale = src->m_Scale; + } +}; + +// Class representing print context information. +typedef CefStructBase CefPrintInfo; + +#endif // OS_MACOSX + +#endif // _CEF_MAC_H diff --git a/cef/include/internal/cef_nplugin_types.h b/cef/include/internal/cef_nplugin_types.h new file mode 100755 index 000000000..50943ce00 --- /dev/null +++ b/cef/include/internal/cef_nplugin_types.h @@ -0,0 +1,91 @@ +// 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_NPLUGIN_TYPES_H +#define _CEF_NPLUGIN_TYPES_H + +#include "cef_export.h" +#include "cef_string.h" +// Include path modified for CEF Binary Distribution. +#include "npapi/npapi.h" +// Include path modified for CEF Binary Distribution. +#include "npapi/nphostapi.h" + +#ifdef __cplusplus +extern "C" { +#endif + +// Netscape plugins are normally built at separate DLLs that are loaded by the +// browser when needed. This interface supports the creation of plugins that +// are an embedded component of the application. Embedded plugins built using +// this interface use the same Netscape Plugin API as DLL-based plugins. +// See https://developer.mozilla.org/En/Gecko_Plugin_API_Reference for complete +// documentation on how to use the Netscape Plugin API. + +// This structure provides attribute information and entry point functions for +// a plugin. +typedef struct _cef_plugin_info_t { + // The unique name that identifies the plugin. + cef_string_t unique_name; + + // The friendly display name of the plugin. + cef_string_t display_name; + + // The version string of the plugin. + cef_string_t version; + + // A description of the plugin. + cef_string_t description; + + // A pipe (|) delimited list of mime type values that the plugin supports. + cef_string_t mime_types; + + // A pipe (|) delimited list of extension values. Each value is associated + // with the mime type value at the same position. Multiple file extensions + // for the same mime type may be delimited with commas (,). + cef_string_t file_extensions; + + // A pipe (|) delimited list of description values. Each value is associated + // with the mime type value at the same position. + cef_string_t type_descriptions; + + // Entry point function pointers. +#if !defined(OS_POSIX) || defined(OS_MACOSX) + NP_GetEntryPointsFunc np_getentrypoints; +#endif + NP_InitializeFunc np_initialize; + NP_ShutdownFunc np_shutdown; +} cef_plugin_info_t; + +#ifdef __cplusplus +} +#endif + +#endif // _CEF_NPLUGIN_TYPES_H diff --git a/cef/include/internal/cef_ptr.h b/cef/include/internal/cef_ptr.h new file mode 100755 index 000000000..0aec0075f --- /dev/null +++ b/cef/include/internal/cef_ptr.h @@ -0,0 +1,196 @@ +// Copyright (c) 2008 Marshall A. Greenblatt. Portions Copyright (c) +// 2006-2008 Google Inc. 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_PTR_H +#define _CEF_PTR_H + +/// +// Smart pointer implementation borrowed from base/ref_counted.h +//

+// A smart pointer class for reference counted objects. Use this class instead +// of calling AddRef and Release manually on a reference counted object to +// avoid common memory leaks caused by forgetting to Release an object +// reference. Sample usage: +//

+//   class MyFoo : public CefBase {
+//    ...
+//   };
+//
+//   void some_function() {
+//     // The MyFoo object that |foo| represents starts with a single
+//     // reference.
+//     CefRefPtr<MyFoo> foo = new MyFoo();
+//     foo->Method(param);
+//     // |foo| is released when this function returns
+//   }
+//
+//   void some_other_function() {
+//     CefRefPtr<MyFoo> foo = new MyFoo();
+//     ...
+//     foo = NULL;  // explicitly releases |foo|
+//     ...
+//     if (foo)
+//       foo->Method(param);
+//   }
+// 
+// The above examples show how CefRefPtr<T> acts like a pointer to T. +// Given two CefRefPtr<T> classes, it is also possible to exchange +// references between the two objects, like so: +//
+//   {
+//     CefRefPtr<MyFoo> a = new MyFoo();
+//     CefRefPtr<MyFoo> b;
+//
+//     b.swap(a);
+//     // now, |b| references the MyFoo object, and |a| references NULL.
+//   }
+// 
+// To make both |a| and |b| in the above example reference the same MyFoo +// object, simply use the assignment operator: +//
+//   {
+//     CefRefPtr<MyFoo> a = new MyFoo();
+//     CefRefPtr<MyFoo> b;
+//
+//     b = a;
+//     // now, |a| and |b| each own a reference to the same MyFoo object.
+//     // the reference count of the underlying MyFoo object will be 2.
+//   }
+// 
+// Reference counted objects can also be passed as function parameters and +// used as function return values: +//
+//   void some_func_with_param(CefRefPtr<MyFoo> param) {
+//     // A reference is added to the MyFoo object that |param| represents
+//     // during the scope of some_func_with_param() and released when
+//     // some_func_with_param() goes out of scope.
+//   }
+//
+//   CefRefPtr<MyFoo> some_func_with_retval() {
+//     // The MyFoo object that |foox| represents starts with a single
+//     // reference.
+//     CefRefPtr<MyFoo> foox = new MyFoo();
+//
+//     // Creating the return value adds an additional reference.
+//     return foox;
+//
+//     // When some_func_with_retval() goes out of scope the original |foox|
+//     // reference is released.
+//   }
+//
+//   void and_another_function() {
+//     CefRefPtr<MyFoo> foo = new MyFoo();
+//
+//     // pass |foo| as a parameter.
+//     some_function(foo);
+//
+//     CefRefPtr<MyFoo> foo2 = some_func_with_retval();
+//     // Now, since we kept a reference to the some_func_with_retval() return
+//     // value, |foo2| is the only class pointing to the MyFoo object created
+//     in some_func_with_retval(), and it has a reference count of 1.
+//
+//     some_func_with_retval();
+//     // Now, since we didn't keep a reference to the some_func_with_retval()
+//     // return value, the MyFoo object created in some_func_with_retval()
+//     // will automatically be released.
+//   }
+// 
+// And in standard containers: +//
+//   {
+//      // Create a vector that holds MyFoo objects.
+//      std::vector<CefRefPtr<MyFoo> > MyFooVec;
+//
+//     // The MyFoo object that |foo| represents starts with a single
+//     // reference.
+//     CefRefPtr<MyFoo> foo = new MyFoo();
+//
+//     // When the MyFoo object is added to |MyFooVec| the reference count
+//     // is increased to 2.
+//     MyFooVec.push_back(foo);
+//   }
+// 
+//

+/// +template +class CefRefPtr { + public: + CefRefPtr() : ptr_(NULL) { + } + + CefRefPtr(T* p) : ptr_(p) { + if (ptr_) + ptr_->AddRef(); + } + + CefRefPtr(const CefRefPtr& r) : ptr_(r.ptr_) { + if (ptr_) + ptr_->AddRef(); + } + + ~CefRefPtr() { + if (ptr_) + ptr_->Release(); + } + + T* get() const { return ptr_; } + operator T*() const { return ptr_; } + T* operator->() const { return ptr_; } + + CefRefPtr& operator=(T* p) { + // AddRef first so that self assignment should work + if (p) + p->AddRef(); + if (ptr_ ) + ptr_ ->Release(); + ptr_ = p; + return *this; + } + + CefRefPtr& operator=(const CefRefPtr& r) { + return *this = r.ptr_; + } + + void swap(T** pp) { + T* p = ptr_; + ptr_ = *pp; + *pp = p; + } + + void swap(CefRefPtr& r) { + swap(&r.ptr_); + } + + private: + T* ptr_; +}; + +#endif // _CEF_PTR_H diff --git a/cef/include/internal/cef_string.h b/cef/include/internal/cef_string.h new file mode 100755 index 000000000..75db22b5e --- /dev/null +++ b/cef/include/internal/cef_string.h @@ -0,0 +1,112 @@ +// Copyright (c) 2010 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_STRING_H +#define _CEF_STRING_H + +// The CEF interface is built with one string type as the default. Comment out +// all but one of the CEF_STRING_TYPE_* defines below to specify the default. +// If you change the default you MUST recompile all of CEF. + +// Build with the UTF8 string type as default. +//#define CEF_STRING_TYPE_UTF8 1 + +// Build with the UTF16 string type as default. +#define CEF_STRING_TYPE_UTF16 1 + +// Build with the wide string type as default. +//#define CEF_STRING_TYPE_WIDE 1 + + +#include "cef_string_types.h" + +#ifdef __cplusplus +#include "cef_string_wrappers.h" +#if defined(CEF_STRING_TYPE_UTF16) +typedef CefStringUTF16 CefString; +#elif defined(CEF_STRING_TYPE_UTF8) +typedef CefStringUTF8 CefString; +#elif defined(CEF_STRING_TYPE_WIDE) +typedef CefStringWide CefString; +#endif +#endif // __cplusplus + +#if defined(CEF_STRING_TYPE_UTF8) +typedef char cef_char_t; +typedef cef_string_utf8_t cef_string_t; +typedef cef_string_userfree_utf8_t cef_string_userfree_t; +#define cef_string_set cef_string_utf8_set +#define cef_string_copy cef_string_utf8_copy +#define cef_string_clear cef_string_utf8_clear +#define cef_string_userfree_alloc cef_string_userfree_utf8_alloc +#define cef_string_userfree_free cef_string_userfree_utf8_free +#define cef_string_from_ascii cef_string_utf8_copy +#define cef_string_to_utf8 cef_string_utf8_copy +#define cef_string_from_utf8 cef_string_utf8_copy +#define cef_string_to_utf16 cef_string_utf8_to_utf16 +#define cef_string_from_utf16 cef_string_utf16_to_utf8 +#define cef_string_to_wide cef_string_utf8_to_wide +#define cef_string_from_wide cef_string_wide_to_utf8 +#elif defined(CEF_STRING_TYPE_UTF16) +typedef char16 cef_char_t; +typedef cef_string_userfree_utf16_t cef_string_userfree_t; +typedef cef_string_utf16_t cef_string_t; +#define cef_string_set cef_string_utf16_set +#define cef_string_copy cef_string_utf16_copy +#define cef_string_clear cef_string_utf16_clear +#define cef_string_userfree_alloc cef_string_userfree_utf16_alloc +#define cef_string_userfree_free cef_string_userfree_utf16_free +#define cef_string_from_ascii cef_string_ascii_to_utf16 +#define cef_string_to_utf8 cef_string_utf16_to_utf8 +#define cef_string_from_utf8 cef_string_utf8_to_utf16 +#define cef_string_to_utf16 cef_string_utf16_copy +#define cef_string_from_utf16 cef_string_utf16_copy +#define cef_string_to_wide cef_string_utf16_to_wide +#define cef_string_from_wide cef_string_wide_to_utf16 +#elif defined(CEF_STRING_TYPE_WIDE) +typedef wchar_t cef_char_t; +typedef cef_string_wide_t cef_string_t; +typedef cef_string_userfree_wide_t cef_string_userfree_t; +#define cef_string_set cef_string_wide_set +#define cef_string_copy cef_string_wide_copy +#define cef_string_clear cef_string_wide_clear +#define cef_string_userfree_alloc cef_string_userfree_wide_alloc +#define cef_string_userfree_free cef_string_userfree_wide_free +#define cef_string_from_ascii cef_string_ascii_to_wide +#define cef_string_to_utf8 cef_string_wide_to_utf8 +#define cef_string_from_utf8 cef_string_utf8_to_wide +#define cef_string_to_utf16 cef_string_wide_to_utf16 +#define cef_string_from_utf16 cef_string_utf16_to_wide +#define cef_string_to_wide cef_string_wide_copy +#define cef_string_from_wide cef_string_wide_copy +#else +#error Please choose a string type. +#endif + +#endif // _CEF_STRING_H diff --git a/cef/include/internal/cef_string_list.h b/cef/include/internal/cef_string_list.h new file mode 100755 index 000000000..fef0a97cc --- /dev/null +++ b/cef/include/internal/cef_string_list.h @@ -0,0 +1,87 @@ +// Copyright (c) 2009 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_STRING_LIST_H +#define _CEF_STRING_LIST_H + +#include "cef_export.h" +#include "cef_string.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/// +// CEF string maps are a set of key/value string pairs. +/// +typedef void* cef_string_list_t; + +/// +// Allocate a new string map. +/// +CEF_EXPORT cef_string_list_t cef_string_list_alloc(); + +/// +// Return the number of elements in the string list. +/// +CEF_EXPORT int cef_string_list_size(cef_string_list_t list); + +/// +// Retrieve the value at the specified zero-based string list index. Returns +// true (1) if the value was successfully retrieved. +/// +CEF_EXPORT int cef_string_list_value(cef_string_list_t list, + int index, cef_string_t* value); + +/// +// Append a new value at the end of the string list. +/// +CEF_EXPORT void cef_string_list_append(cef_string_list_t list, + const cef_string_t* value); + +/// +// Clear the string list. +/// +CEF_EXPORT void cef_string_list_clear(cef_string_list_t list); + +/// +// Free the string list. +/// +CEF_EXPORT void cef_string_list_free(cef_string_list_t list); + +/// +// Creates a copy of an existing string list. +/// +CEF_EXPORT cef_string_list_t cef_string_list_copy(cef_string_list_t list); + +#ifdef __cplusplus +} +#endif + +#endif // _CEF_STRING_LIST_H diff --git a/cef/include/internal/cef_string_map.h b/cef/include/internal/cef_string_map.h new file mode 100755 index 000000000..e20f824a1 --- /dev/null +++ b/cef/include/internal/cef_string_map.h @@ -0,0 +1,96 @@ +// Copyright (c) 2009 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_STRING_MAP_H +#define _CEF_STRING_MAP_H + +#include "cef_export.h" +#include "cef_string.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/// +// CEF string maps are a set of key/value string pairs. +/// +typedef void* cef_string_map_t; + +/// +// Allocate a new string map. +/// +CEF_EXPORT cef_string_map_t cef_string_map_alloc(); + +/// +// Return the number of elements in the string map. +/// +CEF_EXPORT int cef_string_map_size(cef_string_map_t map); + +/// +// Return the value assigned to the specified key. +/// +CEF_EXPORT int cef_string_map_find(cef_string_map_t map, + const cef_string_t* key, + cef_string_t* value); + +/// +// Return the key at the specified zero-based string map index. +/// +CEF_EXPORT int cef_string_map_key(cef_string_map_t map, int index, + cef_string_t* key); + +/// +// Return the value at the specified zero-based string map index. +/// +CEF_EXPORT int cef_string_map_value(cef_string_map_t map, int index, + cef_string_t* value); + +/// +// Append a new key/value pair at the end of the string map. +/// +CEF_EXPORT int cef_string_map_append(cef_string_map_t map, + const cef_string_t* key, + const cef_string_t* value); + +/// +// Clear the string map. +/// +CEF_EXPORT void cef_string_map_clear(cef_string_map_t map); + +/// +// Free the string map. +/// +CEF_EXPORT void cef_string_map_free(cef_string_map_t map); + + +#ifdef __cplusplus +} +#endif + +#endif // _CEF_STRING_MAP_H diff --git a/cef/include/internal/cef_string_multimap.h b/cef/include/internal/cef_string_multimap.h new file mode 100755 index 000000000..e99ae9a48 --- /dev/null +++ b/cef/include/internal/cef_string_multimap.h @@ -0,0 +1,104 @@ +// 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_STRING_MULTIMAP_H +#define _CEF_STRING_MULTIMAP_H + +#include "cef_export.h" +#include "cef_string.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/// +// CEF string multimaps are a set of key/value string pairs. +// More than one value can be assigned to a single key. +/// +typedef void* cef_string_multimap_t; + +/// +// Allocate a new string multimap. +/// +CEF_EXPORT cef_string_multimap_t cef_string_multimap_alloc(); + +/// +// Return the number of elements in the string multimap. +/// +CEF_EXPORT int cef_string_multimap_size(cef_string_multimap_t map); + +/// +// Return the number of values with the specified key. +/// +CEF_EXPORT int cef_string_multimap_find_count(cef_string_multimap_t map, + const cef_string_t* key); + +/// +// Return the value_index-th value with the specified key. +/// +CEF_EXPORT int cef_string_multimap_enumerate(cef_string_multimap_t map, + const cef_string_t* key, + int value_index, + cef_string_t* value); + +/// +// Return the key at the specified zero-based string multimap index. +/// +CEF_EXPORT int cef_string_multimap_key(cef_string_multimap_t map, int index, + cef_string_t* key); + +/// +// Return the value at the specified zero-based string multimap index. +/// +CEF_EXPORT int cef_string_multimap_value(cef_string_multimap_t map, int index, + cef_string_t* value); + +/// +// Append a new key/value pair at the end of the string multimap. +/// +CEF_EXPORT int cef_string_multimap_append(cef_string_multimap_t map, + const cef_string_t* key, + const cef_string_t* value); + +/// +// Clear the string multimap. +/// +CEF_EXPORT void cef_string_multimap_clear(cef_string_multimap_t map); + +/// +// Free the string multimap. +/// +CEF_EXPORT void cef_string_multimap_free(cef_string_multimap_t map); + + +#ifdef __cplusplus +} +#endif + +#endif // _CEF_STRING_MULTIMAP_H diff --git a/cef/include/internal/cef_string_types.h b/cef/include/internal/cef_string_types.h new file mode 100755 index 000000000..f71ffed6c --- /dev/null +++ b/cef/include/internal/cef_string_types.h @@ -0,0 +1,203 @@ +// Copyright (c) 2010 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_STRING_TYPES_T +#define _CEF_STRING_TYPES_T + +// CEF provides functions for converting between UTF-8, -16 and -32 strings. +// CEF string types are safe for reading from multiple threads but not for +// modification. It is the user's responsibility to provide synchronization if +// modifying CEF strings from multiple threads. + +#ifdef __cplusplus +extern "C" { +#endif + +#include "cef_build.h" +#include "cef_export.h" +#include + +// CEF character type definitions. wchar_t is 2 bytes on Windows and 4 bytes on +// most other platforms. + +#if defined(OS_WIN) +typedef wchar_t char16; +#else // !OS_WIN +typedef unsigned short char16; +#ifndef WCHAR_T_IS_UTF32 +#define WCHAR_T_IS_UTF32 +#endif // WCHAR_T_IS_UTF32 +#endif // !OS_WIN + + +// CEF string type definitions. Whomever allocates |str| is responsible for +// providing an appropriate |dtor| implementation that will free the string in +// the same memory space. When reusing an existing string structure make sure +// to call |dtor| for the old value before assigning new |str| and |dtor| +// values. Static strings will have a NULL |dtor| value. Using the below +// functions if you want this managed for you. + +typedef struct _cef_string_wide_t { + wchar_t* str; + size_t length; + void (*dtor)(wchar_t* str); +} cef_string_wide_t; + +typedef struct _cef_string_utf8_t { + char* str; + size_t length; + void (*dtor)(char* str); +} cef_string_utf8_t; + +typedef struct _cef_string_utf16_t { + char16* str; + size_t length; + void (*dtor)(char16* str); +} cef_string_utf16_t; + + +/// +// These functions set string values. If |copy| is true (1) the value will be +// copied instead of referenced. It is up to the user to properly manage +// the lifespan of references. +/// + +CEF_EXPORT int cef_string_wide_set(const wchar_t* src, size_t src_len, + cef_string_wide_t* output, int copy); +CEF_EXPORT int cef_string_utf8_set(const char* src, size_t src_len, + cef_string_utf8_t* output, int copy); +CEF_EXPORT int cef_string_utf16_set(const char16* src, size_t src_len, + cef_string_utf16_t* output, int copy); + + +/// +// Convenience macros for copying values. +/// + +#define cef_string_wide_copy(src, src_len, output) \ + cef_string_wide_set(src, src_len, output, true) +#define cef_string_utf8_copy(src, src_len, output) \ + cef_string_utf8_set(src, src_len, output, true) +#define cef_string_utf16_copy(src, src_len, output) \ + cef_string_utf16_set(src, src_len, output, true) + + +/// +// These functions clear string values. The structure itself is not freed. +/// + +CEF_EXPORT void cef_string_wide_clear(cef_string_wide_t* str); +CEF_EXPORT void cef_string_utf8_clear(cef_string_utf8_t* str); +CEF_EXPORT void cef_string_utf16_clear(cef_string_utf16_t* str); + + +/// +// These functions compare two string values with the same results as strcmp(). +/// + +CEF_EXPORT int cef_string_wide_cmp(const cef_string_wide_t* str1, + const cef_string_wide_t* str2); +CEF_EXPORT int cef_string_utf8_cmp(const cef_string_utf8_t* str1, + const cef_string_utf8_t* str2); +CEF_EXPORT int cef_string_utf16_cmp(const cef_string_utf16_t* str1, + const cef_string_utf16_t* str2); + + +/// +// These functions convert between UTF-8, -16, and -32 strings. They are +// potentially slow so unnecessary conversions should be avoided. The best +// possible result will always be written to |output| with the boolean return +// value indicating whether the conversion is 100% valid. +/// + +CEF_EXPORT int cef_string_wide_to_utf8(const wchar_t* src, size_t src_len, + cef_string_utf8_t* output); +CEF_EXPORT int cef_string_utf8_to_wide(const char* src, size_t src_len, + cef_string_wide_t* output); + +CEF_EXPORT int cef_string_wide_to_utf16(const wchar_t* src, size_t src_len, + cef_string_utf16_t* output); +CEF_EXPORT int cef_string_utf16_to_wide(const char16* src, size_t src_len, + cef_string_wide_t* output); + +CEF_EXPORT int cef_string_utf8_to_utf16(const char* src, size_t src_len, + cef_string_utf16_t* output); +CEF_EXPORT int cef_string_utf16_to_utf8(const char16* src, size_t src_len, + cef_string_utf8_t* output); + + +/// +// These functions convert an ASCII string, typically a hardcoded constant, to a +// Wide/UTF16 string. Use instead of the UTF8 conversion routines if you know +// the string is ASCII. +/// + +CEF_EXPORT int cef_string_ascii_to_wide(const char* src, size_t src_len, + cef_string_wide_t* output); +CEF_EXPORT int cef_string_ascii_to_utf16(const char* src, size_t src_len, + cef_string_utf16_t* output); + + + +/// +// It is sometimes necessary for the system to allocate string structures with +// the expectation that the user will free them. The userfree types act as a +// hint that the user is responsible for freeing the structure. +/// + +typedef cef_string_wide_t* cef_string_userfree_wide_t; +typedef cef_string_utf8_t* cef_string_userfree_utf8_t; +typedef cef_string_utf16_t* cef_string_userfree_utf16_t; + + +/// +// These functions allocate a new string structure. They must be freed by +// calling the associated free function. +/// + +CEF_EXPORT cef_string_userfree_wide_t cef_string_userfree_wide_alloc(); +CEF_EXPORT cef_string_userfree_utf8_t cef_string_userfree_utf8_alloc(); +CEF_EXPORT cef_string_userfree_utf16_t cef_string_userfree_utf16_alloc(); + + +/// +// These functions free the string structure allocated by the associated +// alloc function. Any string contents will first be cleared. +/// + +CEF_EXPORT void cef_string_userfree_wide_free(cef_string_userfree_wide_t str); +CEF_EXPORT void cef_string_userfree_utf8_free(cef_string_userfree_utf8_t str); +CEF_EXPORT void cef_string_userfree_utf16_free(cef_string_userfree_utf16_t str); + + +#ifdef __cplusplus +} +#endif + +#endif // _CEF_STRING_TYPES_T diff --git a/cef/include/internal/cef_string_wrappers.h b/cef/include/internal/cef_string_wrappers.h new file mode 100755 index 000000000..06fc42697 --- /dev/null +++ b/cef/include/internal/cef_string_wrappers.h @@ -0,0 +1,694 @@ +// Copyright (c) 2010 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_STRING_WRAPPERS_H +#define _CEF_STRING_WRAPPERS_H + +#include "cef_string_types.h" +#ifdef BUILDING_CEF_SHARED +#include "base/string16.h" +#endif +#include +#include + +/// +// Traits implementation for wide character strings. +/// +struct CefStringTraitsWide { + typedef wchar_t char_type; + typedef cef_string_wide_t struct_type; + typedef cef_string_userfree_wide_t userfree_struct_type; + + static inline void clear(struct_type *s) { cef_string_wide_clear(s); } + static inline int set(const char_type* src, size_t src_size, + struct_type *output, int copy) + { return cef_string_wide_set(src, src_size, output, copy); } + static inline int compare(const struct_type* s1, const struct_type* s2) + { return cef_string_wide_cmp(s1, s2); } + static inline userfree_struct_type userfree_alloc() + { return cef_string_userfree_wide_alloc(); } + static inline void userfree_free(userfree_struct_type ufs) + { return cef_string_userfree_wide_free(ufs); } + + // Conversion methods. + static inline bool from_ascii(const char* str, size_t len, struct_type *s) + { + return cef_string_ascii_to_wide(str, len, s) ? true : false; + } + static inline std::string to_string(const struct_type *s) + { + cef_string_utf8_t cstr; + memset(&cstr, 0, sizeof(cstr)); + cef_string_wide_to_utf8(s->str, s->length, &cstr); + std::string str; + if (cstr.length > 0) + str = std::string(cstr.str, cstr.length); + cef_string_utf8_clear(&cstr); + return str; + } + static inline bool from_string(const std::string& str, struct_type *s) + { + return cef_string_utf8_to_wide(str.c_str(), str.length(), s) ? true : false; + } + static inline std::wstring to_wstring(const struct_type *s) + { + return std::wstring(s->str, s->length); + } + static inline bool from_wstring(const std::wstring& str, struct_type *s) + { + return cef_string_wide_set(str.c_str(), str.length(), s, true) ? + true : false; + } +#if defined(BUILDING_CEF_SHARED) +#if defined(WCHAR_T_IS_UTF32) + static inline string16 to_string16(const struct_type *s) + { + cef_string_utf16_t cstr; + memset(&cstr, 0, sizeof(cstr)); + cef_string_wide_to_utf16(s->str, s->length, &cstr); + string16 str; + if (cstr.length > 0) + str = string16(cstr.str, cstr.length); + cef_string_utf16_clear(&cstr); + return str; + } + static inline bool from_string16(const string16& str, struct_type *s) + { + return cef_string_utf16_to_wide(str.c_str(), str.length(), s) ? + true : false; + } +#else // WCHAR_T_IS_UTF32 + static inline string16 to_string16(const struct_type *s) + { + return string16(s->str, s->length); + } + static inline bool from_string16(const string16& str, struct_type *s) + { + return cef_string_wide_set(str.c_str(), str.length(), s, true) ? + true : false; + } +#endif // WCHAR_T_IS_UTF32 +#endif // BUILDING_CEF_SHARED +}; + +/// +// Traits implementation for utf8 character strings. +/// +struct CefStringTraitsUTF8 { + typedef char char_type; + typedef cef_string_utf8_t struct_type; + typedef cef_string_userfree_utf8_t userfree_struct_type; + + static inline void clear(struct_type *s) { cef_string_utf8_clear(s); } + static inline int set(const char_type* src, size_t src_size, + struct_type *output, int copy) + { return cef_string_utf8_set(src, src_size, output, copy); } + static inline int compare(const struct_type* s1, const struct_type* s2) + { return cef_string_utf8_cmp(s1, s2); } + static inline userfree_struct_type userfree_alloc() + { return cef_string_userfree_utf8_alloc(); } + static inline void userfree_free(userfree_struct_type ufs) + { return cef_string_userfree_utf8_free(ufs); } + + // Conversion methods. + static inline bool from_ascii(const char* str, size_t len, struct_type* s) + { + return cef_string_utf8_copy(str, len, s) ? true : false; + } + static inline std::string to_string(const struct_type* s) + { + return std::string(s->str, s->length); + } + static inline bool from_string(const std::string& str, struct_type* s) + { + return cef_string_utf8_copy(str.c_str(), str.length(), s) ? true : false; + } + static inline std::wstring to_wstring(const struct_type* s) + { + cef_string_wide_t cstr; + memset(&cstr, 0, sizeof(cstr)); + cef_string_utf8_to_wide(s->str, s->length, &cstr); + std::wstring str; + if (cstr.length > 0) + str = std::wstring(cstr.str, cstr.length); + cef_string_wide_clear(&cstr); + return str; + } + static inline bool from_wstring(const std::wstring& str, struct_type* s) + { + return cef_string_wide_to_utf8(str.c_str(), str.length(), s) ? true : false; + } +#if defined(BUILDING_CEF_SHARED) + static inline string16 to_string16(const struct_type* s) + { + cef_string_utf16_t cstr; + memset(&cstr, 0, sizeof(cstr)); + cef_string_utf8_to_utf16(s->str, s->length, &cstr); + string16 str; + if (cstr.length > 0) + str = string16(cstr.str, cstr.length); + cef_string_utf16_clear(&cstr); + return str; + } + static inline bool from_string16(const string16& str, struct_type* s) + { + return cef_string_utf16_to_utf8(str.c_str(), str.length(), s) ? + true : false; + } +#endif // BUILDING_CEF_SHARED +}; + +/// +// Traits implementation for utf16 character strings. +/// +struct CefStringTraitsUTF16 { + typedef char16 char_type; + typedef cef_string_utf16_t struct_type; + typedef cef_string_userfree_utf16_t userfree_struct_type; + + static inline void clear(struct_type *s) { cef_string_utf16_clear(s); } + static inline int set(const char_type* src, size_t src_size, + struct_type *output, int copy) + { return cef_string_utf16_set(src, src_size, output, copy); } + static inline int compare(const struct_type* s1, const struct_type* s2) + { return cef_string_utf16_cmp(s1, s2); } + static inline userfree_struct_type userfree_alloc() + { return cef_string_userfree_utf16_alloc(); } + static inline void userfree_free(userfree_struct_type ufs) + { return cef_string_userfree_utf16_free(ufs); } + + // Conversion methods. + static inline bool from_ascii(const char* str, size_t len, struct_type* s) + { + return cef_string_ascii_to_utf16(str, len, s) ? true : false; + } + static inline std::string to_string(const struct_type* s) + { + cef_string_utf8_t cstr; + memset(&cstr, 0, sizeof(cstr)); + cef_string_utf16_to_utf8(s->str, s->length, &cstr); + std::string str; + if (cstr.length > 0) + str = std::string(cstr.str, cstr.length); + cef_string_utf8_clear(&cstr); + return str; + } + static inline bool from_string(const std::string& str, struct_type* s) + { + return cef_string_utf8_to_utf16(str.c_str(), str.length(), s) ? + true : false; + } +#if defined(WCHAR_T_IS_UTF32) + static inline std::wstring to_wstring(const struct_type* s) + { + cef_string_wide_t cstr; + memset(&cstr, 0, sizeof(cstr)); + cef_string_utf16_to_wide(s->str, s->length, &cstr); + std::wstring str; + if (cstr.length > 0) + str = std::wstring(cstr.str, cstr.length); + cef_string_wide_clear(&cstr); + return str; + } + static inline bool from_wstring(const std::wstring& str, struct_type* s) + { + return cef_string_wide_to_utf16(str.c_str(), str.length(), s) ? + true : false; + } +#else // WCHAR_T_IS_UTF32 + static inline std::wstring to_wstring(const struct_type* s) + { + return std::wstring(s->str, s->length); + } + static inline bool from_wstring(const std::wstring& str, struct_type* s) + { + return cef_string_utf16_set(str.c_str(), str.length(), s, true) ? + true : false; + } +#endif // WCHAR_T_IS_UTF32 +#if defined(BUILDING_CEF_SHARED) + static inline string16 to_string16(const struct_type* s) + { + return string16(s->str, s->length); + } + static inline bool from_string16(const string16& str, struct_type* s) + { + return cef_string_utf16_set(str.c_str(), str.length(), s, true) ? + true : false; + } +#endif // BUILDING_CEF_SHARED +}; + +/// +// CEF string classes can convert between all supported string types. For +// example, the CefStringWide class uses wchar_t as the underlying character +// type and provides two approaches for converting data to/from a UTF8 string +// (std::string). +//

+// 1. Implicit conversion using the assignment operator overload. +//

+//   CefStringWide aCefString;
+//   std::string aUTF8String;
+//   aCefString = aUTF8String; // Assign std::string to CefStringWide
+//   aUTF8String = aCefString; // Assign CefStringWide to std::string
+// 
+// 2. Explicit conversion using the FromString/ToString methods. +//
+//   CefStringWide aCefString;
+//   std::string aUTF8String;
+//   aCefString.FromString(aUTF8String); // Assign std::string to CefStringWide
+//   aUTF8String = aCefString.ToString(); // Assign CefStringWide to std::string
+// 
+// Conversion will only occur if the assigned value is a different string type. +// Assigning a std::string to a CefStringUTF8, for example, will copy the data +// without performing a conversion. +//

+// CEF string classes are safe for reading from multiple threads but not for +// modification. It is the user's responsibility to provide synchronization if +// modifying CEF strings from multiple threads. +/// +template +class CefStringBase { +public: + typedef typename traits::char_type char_type; + typedef typename traits::struct_type struct_type; + typedef typename traits::userfree_struct_type userfree_struct_type; + + /// + // Default constructor. + /// + CefStringBase() : string_(NULL), owner_(false) {} + + /// + // Create a new string from an existing string. Data will always be copied. + /// + CefStringBase(const CefStringBase& str) : string_(NULL), owner_(false) + { FromString(str.c_str(), str.length(), true); } + + /// + // Create a new string from an existing std::string. Data will be always + // copied. Translation will occur if necessary based on the underlying string + // type. + /// + CefStringBase(const std::string& src) : string_(NULL), owner_(false) + { FromString(src); } + CefStringBase(const char* src) : string_(NULL), owner_(false) + { FromString(std::string(src)); } + + /// + // Create a new string from an existing std::wstring. Data will be always + // copied. Translation will occur if necessary based on the underlying string + // type. + /// + CefStringBase(const std::wstring& src) : string_(NULL), owner_(false) + { FromWString(src); } + CefStringBase(const wchar_t* src) : string_(NULL), owner_(false) + { FromWString(std::wstring(src)); } + +#if (defined(BUILDING_CEF_SHARED) && defined(WCHAR_T_IS_UTF32)) + /// + // Create a new string from an existing string16. Data will be always + // copied. Translation will occur if necessary based on the underlying string + // type. + /// + CefStringBase(const string16& src) : string_(NULL), owner_(false) + { FromString16(src); } + CefStringBase(const char16* src) : string_(NULL), owner_(false) + { FromString16(string16(src)); } +#endif // BUILDING_CEF_SHARED && WCHAR_T_IS_UTF32 + + /// + // Create a new string from an existing character array. If |copy| is true + // this class will copy the data. Otherwise, this class will reference the + // existing data. Referenced data must exist for the lifetime of this class + // and will not be freed by this class. + /// + CefStringBase(const char_type* src, size_t src_len, bool copy) + : string_(NULL), owner_(false) + { FromString(src, src_len, copy); } + + /// + // Create a new string referencing an existing string structure without taking + // ownership. Referenced structures must exist for the lifetime of this class + // and will not be freed by this class. + /// + CefStringBase(const struct_type* src) : string_(NULL), owner_(false) + { + if (!src) + return; + // Reference the existing structure without taking ownership. + Attach(const_cast(src), false); + } + + virtual ~CefStringBase() { ClearAndFree(); } + + + // The following methods are named for compatibility with the standard library + // string template types. + + /// + // Return a read-only pointer to the string data. + /// + const char_type* c_str() const { return (string_ ? string_->str : NULL); } + + /// + // Return the length of the string data. + /// + size_t length() const { return (string_ ? string_->length : 0); } + + /// + // Return the length of the string data. + /// + inline size_t size() const { return length(); } + + /// + // Returns true if the string is empty. + /// + bool empty() const { return (string_ == NULL || string_->length == 0); } + + /// + // Compare this string to the specified string. + /// + int compare(const CefStringBase& str) const + { + if (empty() && str.empty()) + return 0; + if (empty()) + return -1; + if (str.empty()) + return 1; + return traits::compare(string_, str.GetStruct()); + } + + /// + // Clear the string data. + /// + void clear() + { + if (!empty()) + traits::clear(string_); + } + + + // The following methods are unique to CEF string template types. + + /// + // Returns true if this class owns the underlying string structure. + /// + bool IsOwner() const { return owner_; } + + /// + // Returns a read-only pointer to the underlying string structure. May return + // NULL if no structure is currently allocated. + /// + const struct_type* GetStruct() const { return string_; } + + /// + // Returns a writable pointer to the underlying string structure. Will never + // return NULL. + /// + struct_type* GetWritableStruct() + { + AllocIfNeeded(); + return string_; + } + + /// + // Clear the state of this class. The underlying string structure and data + // will be freed if this class owns the structure. + /// + void ClearAndFree() + { + if (!string_) + return; + if (owner_) { + clear(); + delete string_; + } + string_ = NULL; + owner_ = false; + } + + /// + // Attach to the specified string structure. If |owner| is true this class + // will take ownership of the structure. + /// + void Attach(struct_type* str, bool owner) + { + // Free the previous structure and data, if any. + ClearAndFree(); + + string_ = str; + owner_ = owner; + } + + /// + // Take ownership of the specified userfree structure's string data. The + // userfree structure itself will be freed. Only use this method with userfree + // structures. + /// + void AttachToUserFree(userfree_struct_type str) + { + // Free the previous structure and data, if any. + ClearAndFree(); + + if (!str) + return; + + AllocIfNeeded(); + owner_ = true; + memcpy(string_, str, sizeof(struct_type)); + + // Free the |str| structure but not the data. + memset(str, 0, sizeof(struct_type)); + traits::userfree_free(str); + } + + /// + // Detach from the underlying string structure. To avoid memory leaks only use + // this method if you already hold a pointer to the underlying string + // structure. + /// + void Detach() + { + string_ = NULL; + owner_ = false; + } + + /// + // Create a userfree structure and give it ownership of this class' string + // data. This class will be disassociated from the data. May return NULL if + // this string class currently contains no data. + /// + userfree_struct_type DetachToUserFree() + { + if (empty()) + return NULL; + + userfree_struct_type str = traits::userfree_alloc(); + memcpy(str, string_, sizeof(struct_type)); + + // Free this class' structure but not the data. + memset(string_, 0, sizeof(struct_type)); + ClearAndFree(); + + return str; + } + + /// + // Set this string's data to the specified character array. If |copy| is true + // this class will copy the data. Otherwise, this class will reference the + // existing data. Referenced data must exist for the lifetime of this class + // and will not be freed by this class. + /// + bool FromString(const char_type* src, size_t src_len, bool copy) + { + if (src == NULL || src_len == 0) { + clear(); + return true; + } + AllocIfNeeded(); + return traits::set(src, src_len, string_, copy) ? true : false; + } + + /// + // Set this string's data from an existing ASCII string. Data will be always + // copied. Translation will occur if necessary based on the underlying string + // type. + /// + bool FromASCII(const char* str) + { + size_t len = str ? strlen(str) : 0; + if (len == 0) { + clear(); + return true; + } + AllocIfNeeded(); + return traits::from_ascii(str, len, string_); + } + + /// + // Return this string's data as a std::string. Translation will occur if + // necessary based on the underlying string type. + /// + std::string ToString() const + { + if (empty()) + return std::string(); + return traits::to_string(string_); + } + + /// + // Set this string's data from an existing std::string. Data will be always + // copied. Translation will occur if necessary based on the underlying string + // type. + /// + bool FromString(const std::string& str) + { + if (str.empty()) { + clear(); + return true; + } + AllocIfNeeded(); + return traits::from_string(str, string_); + } + + /// + // Return this string's data as a std::wstring. Translation will occur if + // necessary based on the underlying string type. + /// + std::wstring ToWString() const + { + if (empty()) + return std::wstring(); + return traits::to_wstring(string_); + } + + /// + // Set this string's data from an existing std::wstring. Data will be always + // copied. Translation will occur if necessary based on the underlying string + // type. + /// + bool FromWString(const std::wstring& str) + { + if (str.empty()) { + clear(); + return true; + } + AllocIfNeeded(); + return traits::from_wstring(str, string_); + } +#if defined(BUILDING_CEF_SHARED) + /// + // Return this string's data as a string16. Translation will occur if + // necessary based on the underlying string type. + /// + string16 ToString16() const + { + if (empty()) + return string16(); + return traits::to_string16(string_); + } + + /// + // Set this string's data from an existing string16. Data will be always + // copied. Translation will occur if necessary based on the underlying string + // type. + /// + bool FromString16(const string16& str) + { + if (str.empty()) { + clear(); + return true; + } + AllocIfNeeded(); + return traits::from_string16(str, string_); + } +#endif // BUILDING_CEF_SHARED + + /// + // Comparison operator overloads. + /// + bool operator<(const CefStringBase& str) const + { return (compare(str) < 0); } + bool operator<=(const CefStringBase& str) const + { return (compare(str) <= 0); } + bool operator>(const CefStringBase& str) const + { return (compare(str) > 0); } + bool operator>=(const CefStringBase& str) const + { return (compare(str) >= 0); } + bool operator==(const CefStringBase& str) const + { return (compare(str) == 0); } + bool operator!=(const CefStringBase& str) const + { return (compare(str) != 0); } + + /// + // Assignment operator overloads. + /// + CefStringBase& operator=(const CefStringBase& str) + { FromString(str.c_str(), str.length(), true); return *this; } + operator std::string() const { return ToString(); } + CefStringBase& operator=(const std::string& str) + { FromString(str); return *this; } + CefStringBase& operator=(const char* str) + { FromString(std::string(str)); return *this; } + operator std::wstring() const { return ToWString(); } + CefStringBase& operator=(const std::wstring& str) + { FromWString(str); return *this; } + CefStringBase& operator=(const wchar_t* str) + { FromWString(std::wstring(str)); return *this; } +#if (defined(BUILDING_CEF_SHARED) && defined(WCHAR_T_IS_UTF32)) + operator string16() const { return ToString16(); } + CefStringBase& operator=(const string16& str) + { FromString16(str); return *this; } + CefStringBase& operator=(const char16* str) + { FromString16(string16(str)); return *this; } +#endif // BUILDING_CEF_SHARED && WCHAR_T_IS_UTF32 + +private: + // Allocate the string structure if it doesn't already exist. + void AllocIfNeeded() + { + if (string_ == NULL) { + string_ = new struct_type; + memset(string_, 0, sizeof(struct_type)); + owner_ = true; + } + } + + struct_type* string_; + bool owner_; +}; + + +typedef CefStringBase CefStringWide; +typedef CefStringBase CefStringUTF8; +typedef CefStringBase CefStringUTF16; + +#endif // _CEF_STRING_WRAPPERS_H diff --git a/cef/include/internal/cef_time.h b/cef/include/internal/cef_time.h new file mode 100755 index 000000000..11235792c --- /dev/null +++ b/cef/include/internal/cef_time.h @@ -0,0 +1,76 @@ +// 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_TIME_H +#define _CEF_TIME_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "cef_export.h" +#include + +/// +// Time information. Values should always be in UTC. +/// +typedef struct _cef_time_t +{ + int year; // Four digit year "2007" + int month; // 1-based month (values 1 = January, etc.) + int day_of_week; // 0-based day of week (0 = Sunday, etc.) + int day_of_month; // 1-based day of month (1-31) + int hour; // Hour within the current day (0-23) + int minute; // Minute within the current hour (0-59) + int second; // Second within the current minute (0-59 plus leap + // seconds which may take it up to 60). + int millisecond; // Milliseconds within the current second (0-999) +} cef_time_t; + +/// +// Converts cef_time_t to/from time_t. Returns true (1) on success and false (0) +// on failure. +/// +CEF_EXPORT int cef_time_to_timet(const cef_time_t* cef_time, time_t* time); +CEF_EXPORT int cef_time_from_timet(time_t time, cef_time_t* cef_time); + +/// +// Converts cef_time_t to/from a double which is the number of seconds since +// epoch (Jan 1, 1970). Webkit uses this format to represent time. A value of 0 +// means "not initialized". Returns true (1) on success and false (0) on +// failure. +/// +CEF_EXPORT int cef_time_to_doublet(const cef_time_t* cef_time, double* time); +CEF_EXPORT int cef_time_from_doublet(double time, cef_time_t* cef_time); + +#ifdef __cplusplus +} +#endif + +#endif // _CEF_TIME_H diff --git a/cef/include/internal/cef_tuple.h b/cef/include/internal/cef_tuple.h new file mode 100755 index 000000000..da71441de --- /dev/null +++ b/cef/include/internal/cef_tuple.h @@ -0,0 +1,1083 @@ +// Copyright (c) 2006-2011 Google Inc. 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. +// +// The contents of this file are identical to base/tuple.h + +// A Tuple is a generic templatized container, similar in concept to std::pair. +// There are classes Tuple0 to Tuple6, cooresponding to the number of elements +// it contains. The convenient MakeTuple() function takes 0 to 6 arguments, +// and will construct and return the appropriate Tuple object. The functions +// DispatchToMethod and DispatchToFunction take a function pointer or instance +// and method pointer, and unpack a tuple into arguments to the call. +// +// Tuple elements are copied by value, and stored in the tuple. See the unit +// tests for more details of how/when the values are copied. +// +// Example usage: +// // These two methods of creating a Tuple are identical. +// Tuple2 tuple_a(1, "wee"); +// Tuple2 tuple_b = MakeTuple(1, "wee"); +// +// void SomeFunc(int a, const char* b) { } +// DispatchToFunction(&SomeFunc, tuple_a); // SomeFunc(1, "wee") +// DispatchToFunction( +// &SomeFunc, MakeTuple(10, "foo")); // SomeFunc(10, "foo") +// +// struct { void SomeMeth(int a, int b, int c) { } } foo; +// DispatchToMethod(&foo, &Foo::SomeMeth, MakeTuple(1, 2, 3)); +// // foo->SomeMeth(1, 2, 3); + +#ifndef BASE_TUPLE_H__ +#define BASE_TUPLE_H__ +#pragma once + +#if defined(OS_CHROMEOS) +// To troubleshoot crosbug.com/7327. +#include "base/logging.h" +#endif +// Traits ---------------------------------------------------------------------- +// +// A simple traits class for tuple arguments. +// +// ValueType: the bare, nonref version of a type (same as the type for nonrefs). +// RefType: the ref version of a type (same as the type for refs). +// ParamType: what type to pass to functions (refs should not be constified). + +template +struct TupleTraits { + typedef P ValueType; + typedef P& RefType; + typedef const P& ParamType; +}; + +template +struct TupleTraits { + typedef P ValueType; + typedef P& RefType; + typedef P& ParamType; +}; + +template +struct TupleTypes { }; + +// Tuple ----------------------------------------------------------------------- +// +// This set of classes is useful for bundling 0 or more heterogeneous data types +// into a single variable. The advantage of this is that it greatly simplifies +// function objects that need to take an arbitrary number of parameters; see +// RunnableMethod and IPC::MessageWithTuple. +// +// Tuple0 is supplied to act as a 'void' type. It can be used, for example, +// when dispatching to a function that accepts no arguments (see the +// Dispatchers below). +// Tuple1 is rarely useful. One such use is when A is non-const ref that you +// want filled by the dispatchee, and the tuple is merely a container for that +// output (a "tier"). See MakeRefTuple and its usages. + +struct Tuple0 { + typedef Tuple0 ValueTuple; + typedef Tuple0 RefTuple; + typedef Tuple0 ParamTuple; +}; + +template +struct Tuple1 { + public: + typedef A TypeA; + + Tuple1() {} + explicit Tuple1(typename TupleTraits::ParamType a) : a(a) {} + + A a; +}; + +template +struct Tuple2 { + public: + typedef A TypeA; + typedef B TypeB; + + Tuple2() {} + Tuple2(typename TupleTraits::ParamType a, + typename TupleTraits::ParamType b) + : a(a), b(b) { + } + + A a; + B b; +}; + +template +struct Tuple3 { + public: + typedef A TypeA; + typedef B TypeB; + typedef C TypeC; + + Tuple3() {} + Tuple3(typename TupleTraits::ParamType a, + typename TupleTraits::ParamType b, + typename TupleTraits::ParamType c) + : a(a), b(b), c(c){ + } + + A a; + B b; + C c; +}; + +template +struct Tuple4 { + public: + typedef A TypeA; + typedef B TypeB; + typedef C TypeC; + typedef D TypeD; + + Tuple4() {} + Tuple4(typename TupleTraits::ParamType a, + typename TupleTraits::ParamType b, + typename TupleTraits::ParamType c, + typename TupleTraits::ParamType d) + : a(a), b(b), c(c), d(d) { + } + + A a; + B b; + C c; + D d; +}; + +template +struct Tuple5 { + public: + typedef A TypeA; + typedef B TypeB; + typedef C TypeC; + typedef D TypeD; + typedef E TypeE; + + Tuple5() {} + Tuple5(typename TupleTraits::ParamType a, + typename TupleTraits::ParamType b, + typename TupleTraits::ParamType c, + typename TupleTraits::ParamType d, + typename TupleTraits::ParamType e) + : a(a), b(b), c(c), d(d), e(e) { + } + + A a; + B b; + C c; + D d; + E e; +}; + +template +struct Tuple6 { + public: + typedef A TypeA; + typedef B TypeB; + typedef C TypeC; + typedef D TypeD; + typedef E TypeE; + typedef F TypeF; + + Tuple6() {} + Tuple6(typename TupleTraits::ParamType a, + typename TupleTraits::ParamType b, + typename TupleTraits::ParamType c, + typename TupleTraits::ParamType d, + typename TupleTraits::ParamType e, + typename TupleTraits::ParamType f) + : a(a), b(b), c(c), d(d), e(e), f(f) { + } + + A a; + B b; + C c; + D d; + E e; + F f; +}; + +template +struct Tuple7 { + public: + typedef A TypeA; + typedef B TypeB; + typedef C TypeC; + typedef D TypeD; + typedef E TypeE; + typedef F TypeF; + typedef G TypeG; + + Tuple7() {} + Tuple7(typename TupleTraits::ParamType a, + typename TupleTraits::ParamType b, + typename TupleTraits::ParamType c, + typename TupleTraits::ParamType d, + typename TupleTraits::ParamType e, + typename TupleTraits::ParamType f, + typename TupleTraits::ParamType g) + : a(a), b(b), c(c), d(d), e(e), f(f), g(g) { + } + + A a; + B b; + C c; + D d; + E e; + F f; + G g; +}; + +template +struct Tuple8 { + public: + typedef A TypeA; + typedef B TypeB; + typedef C TypeC; + typedef D TypeD; + typedef E TypeE; + typedef F TypeF; + typedef G TypeG; + typedef H TypeH; + + Tuple8() {} + Tuple8(typename TupleTraits::ParamType a, + typename TupleTraits::ParamType b, + typename TupleTraits::ParamType c, + typename TupleTraits::ParamType d, + typename TupleTraits::ParamType e, + typename TupleTraits::ParamType f, + typename TupleTraits::ParamType g, + typename TupleTraits::ParamType h) + : a(a), b(b), c(c), d(d), e(e), f(f), g(g), h(h) { + } + + A a; + B b; + C c; + D d; + E e; + F f; + G g; + H h; +}; + +// Tuple types ---------------------------------------------------------------- +// +// Allows for selection of ValueTuple/RefTuple/ParamTuple without needing the +// definitions of class types the tuple takes as parameters. + +template <> +struct TupleTypes< Tuple0 > { + typedef Tuple0 ValueTuple; + typedef Tuple0 RefTuple; + typedef Tuple0 ParamTuple; +}; + +template +struct TupleTypes< Tuple1 > { + typedef Tuple1::ValueType> ValueTuple; + typedef Tuple1::RefType> RefTuple; + typedef Tuple1::ParamType> ParamTuple; +}; + +template +struct TupleTypes< Tuple2 > { + typedef Tuple2::ValueType, + typename TupleTraits::ValueType> ValueTuple; +typedef Tuple2::RefType, + typename TupleTraits::RefType> RefTuple; + typedef Tuple2::ParamType, + typename TupleTraits::ParamType> ParamTuple; +}; + +template +struct TupleTypes< Tuple3 > { + typedef Tuple3::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType> ValueTuple; +typedef Tuple3::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType> RefTuple; + typedef Tuple3::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType> ParamTuple; +}; + +template +struct TupleTypes< Tuple4 > { + typedef Tuple4::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType> ValueTuple; +typedef Tuple4::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType> RefTuple; + typedef Tuple4::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType> ParamTuple; +}; + +template +struct TupleTypes< Tuple5 > { + typedef Tuple5::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType> ValueTuple; +typedef Tuple5::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType> RefTuple; + typedef Tuple5::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType> ParamTuple; +}; + +template +struct TupleTypes< Tuple6 > { + typedef Tuple6::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType> ValueTuple; +typedef Tuple6::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType> RefTuple; + typedef Tuple6::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType> ParamTuple; +}; + +template +struct TupleTypes< Tuple7 > { + typedef Tuple7::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType> ValueTuple; +typedef Tuple7::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType> RefTuple; + typedef Tuple7::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType> ParamTuple; +}; + +template +struct TupleTypes< Tuple8 > { + typedef Tuple8::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType> ValueTuple; +typedef Tuple8::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType> RefTuple; + typedef Tuple8::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType> ParamTuple; +}; + +// Tuple creators ------------------------------------------------------------- +// +// Helper functions for constructing tuples while inferring the template +// argument types. + +inline Tuple0 MakeTuple() { + return Tuple0(); +} + +template +inline Tuple1 MakeTuple(const A& a) { + return Tuple1(a); +} + +template +inline Tuple2 MakeTuple(const A& a, const B& b) { + return Tuple2(a, b); +} + +template +inline Tuple3 MakeTuple(const A& a, const B& b, const C& c) { + return Tuple3(a, b, c); +} + +template +inline Tuple4 MakeTuple(const A& a, const B& b, const C& c, + const D& d) { + return Tuple4(a, b, c, d); +} + +template +inline Tuple5 MakeTuple(const A& a, const B& b, const C& c, + const D& d, const E& e) { + return Tuple5(a, b, c, d, e); +} + +template +inline Tuple6 MakeTuple(const A& a, const B& b, const C& c, + const D& d, const E& e, const F& f) { + return Tuple6(a, b, c, d, e, f); +} + +template +inline Tuple7 MakeTuple(const A& a, const B& b, const C& c, + const D& d, const E& e, const F& f, + const G& g) { + return Tuple7(a, b, c, d, e, f, g); +} + +template +inline Tuple8 MakeTuple(const A& a, const B& b, + const C& c, const D& d, + const E& e, const F& f, + const G& g, const H& h) { + return Tuple8(a, b, c, d, e, f, g, h); +} + +// The following set of helpers make what Boost refers to as "Tiers" - a tuple +// of references. + +template +inline Tuple1 MakeRefTuple(A& a) { + return Tuple1(a); +} + +template +inline Tuple2 MakeRefTuple(A& a, B& b) { + return Tuple2(a, b); +} + +template +inline Tuple3 MakeRefTuple(A& a, B& b, C& c) { + return Tuple3(a, b, c); +} + +template +inline Tuple4 MakeRefTuple(A& a, B& b, C& c, D& d) { + return Tuple4(a, b, c, d); +} + +template +inline Tuple5 MakeRefTuple(A& a, B& b, C& c, D& d, E& e) { + return Tuple5(a, b, c, d, e); +} + +template +inline Tuple6 MakeRefTuple(A& a, B& b, C& c, D& d, E& e, + F& f) { + return Tuple6(a, b, c, d, e, f); +} + +template +inline Tuple7 MakeRefTuple(A& a, B& b, C& c, D& d, + E& e, F& f, G& g) { + return Tuple7(a, b, c, d, e, f, g); +} + +template +inline Tuple8 MakeRefTuple(A& a, B& b, C& c, + D& d, E& e, F& f, + G& g, H& h) { + return Tuple8(a, b, c, d, e, f, g, h); +} + +// Dispatchers ---------------------------------------------------------------- +// +// Helper functions that call the given method on an object, with the unpacked +// tuple arguments. Notice that they all have the same number of arguments, +// so you need only write: +// DispatchToMethod(object, &Object::method, args); +// This is very useful for templated dispatchers, since they don't need to know +// what type |args| is. + +// Non-Static Dispatchers with no out params. + +template +inline void DispatchToMethod(ObjT* obj, Method method, const Tuple0& arg) { + (obj->*method)(); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, const A& arg) { + (obj->*method)(arg); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, const Tuple1& arg) { + +#if defined(OS_CHROMEOS) + // To troubleshoot crosbug.com/7327. + CHECK(obj); + CHECK(&arg); + CHECK(method); +#endif + (obj->*method)(arg.a); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple2& arg) { + (obj->*method)(arg.a, arg.b); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple3& arg) { + (obj->*method)(arg.a, arg.b, arg.c); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple4& arg) { + (obj->*method)(arg.a, arg.b, arg.c, arg.d); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple5& arg) { + (obj->*method)(arg.a, arg.b, arg.c, arg.d, arg.e); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple6& arg) { + (obj->*method)(arg.a, arg.b, arg.c, arg.d, arg.e, arg.f); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple7& arg) { + (obj->*method)(arg.a, arg.b, arg.c, arg.d, arg.e, arg.f, arg.g); +} + +// Static Dispatchers with no out params. + +template +inline void DispatchToFunction(Function function, const Tuple0& arg) { + (*function)(); +} + +template +inline void DispatchToFunction(Function function, const A& arg) { + (*function)(arg); +} + +template +inline void DispatchToFunction(Function function, const Tuple1& arg) { + (*function)(arg.a); +} + +template +inline void DispatchToFunction(Function function, const Tuple2& arg) { + (*function)(arg.a, arg.b); +} + +template +inline void DispatchToFunction(Function function, const Tuple3& arg) { + (*function)(arg.a, arg.b, arg.c); +} + +template +inline void DispatchToFunction(Function function, + const Tuple4& arg) { + (*function)(arg.a, arg.b, arg.c, arg.d); +} + +template +inline void DispatchToFunction(Function function, + const Tuple5& arg) { + (*function)(arg.a, arg.b, arg.c, arg.d, arg.e); +} + +template +inline void DispatchToFunction(Function function, + const Tuple6& arg) { + (*function)(arg.a, arg.b, arg.c, arg.d, arg.e, arg.f); +} + +template +inline void DispatchToFunction(Function function, + const Tuple7& arg) { + (*function)(arg.a, arg.b, arg.c, arg.d, arg.e, arg.f, arg.g); +} + +template +inline void DispatchToFunction(Function function, + const Tuple8& arg) { + (*function)(arg.a, arg.b, arg.c, arg.d, arg.e, arg.f, arg.g, arg.h); +} + +// Dispatchers with 0 out param (as a Tuple0). + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple0& arg, Tuple0*) { + (obj->*method)(); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, const A& arg, Tuple0*) { + (obj->*method)(arg); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple1& arg, Tuple0*) { + (obj->*method)(arg.a); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple2& arg, Tuple0*) { + (obj->*method)(arg.a, arg.b); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple3& arg, Tuple0*) { + (obj->*method)(arg.a, arg.b, arg.c); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple4& arg, Tuple0*) { + (obj->*method)(arg.a, arg.b, arg.c, arg.d); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple5& arg, Tuple0*) { + (obj->*method)(arg.a, arg.b, arg.c, arg.d, arg.e); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple6& arg, Tuple0*) { + (obj->*method)(arg.a, arg.b, arg.c, arg.d, arg.e, arg.f); +} + +// Dispatchers with 1 out param. + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple0& in, + Tuple1* out) { + (obj->*method)(&out->a); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const InA& in, + Tuple1* out) { + (obj->*method)(in, &out->a); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple1& in, + Tuple1* out) { + (obj->*method)(in.a, &out->a); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple2& in, + Tuple1* out) { + (obj->*method)(in.a, in.b, &out->a); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple3& in, + Tuple1* out) { + (obj->*method)(in.a, in.b, in.c, &out->a); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple4& in, + Tuple1* out) { + (obj->*method)(in.a, in.b, in.c, in.d, &out->a); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple5& in, + Tuple1* out) { + (obj->*method)(in.a, in.b, in.c, in.d, in.e, &out->a); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple6& in, + Tuple1* out) { + (obj->*method)(in.a, in.b, in.c, in.d, in.e, in.f, &out->a); +} + +// Dispatchers with 2 out params. + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple0& in, + Tuple2* out) { + (obj->*method)(&out->a, &out->b); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const InA& in, + Tuple2* out) { + (obj->*method)(in, &out->a, &out->b); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple1& in, + Tuple2* out) { + (obj->*method)(in.a, &out->a, &out->b); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple2& in, + Tuple2* out) { + (obj->*method)(in.a, in.b, &out->a, &out->b); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple3& in, + Tuple2* out) { + (obj->*method)(in.a, in.b, in.c, &out->a, &out->b); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple4& in, + Tuple2* out) { + (obj->*method)(in.a, in.b, in.c, in.d, &out->a, &out->b); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple5& in, + Tuple2* out) { + (obj->*method)(in.a, in.b, in.c, in.d, in.e, &out->a, &out->b); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple6& in, + Tuple2* out) { + (obj->*method)(in.a, in.b, in.c, in.d, in.e, in.f, &out->a, &out->b); +} + +// Dispatchers with 3 out params. + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple0& in, + Tuple3* out) { + (obj->*method)(&out->a, &out->b, &out->c); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const InA& in, + Tuple3* out) { + (obj->*method)(in, &out->a, &out->b, &out->c); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple1& in, + Tuple3* out) { + (obj->*method)(in.a, &out->a, &out->b, &out->c); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple2& in, + Tuple3* out) { + (obj->*method)(in.a, in.b, &out->a, &out->b, &out->c); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple3& in, + Tuple3* out) { + (obj->*method)(in.a, in.b, in.c, &out->a, &out->b, &out->c); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple4& in, + Tuple3* out) { + (obj->*method)(in.a, in.b, in.c, in.d, &out->a, &out->b, &out->c); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple5& in, + Tuple3* out) { + (obj->*method)(in.a, in.b, in.c, in.d, in.e, &out->a, &out->b, &out->c); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple6& in, + Tuple3* out) { + (obj->*method)(in.a, in.b, in.c, in.d, in.e, in.f, &out->a, &out->b, &out->c); +} + +// Dispatchers with 4 out params. + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple0& in, + Tuple4* out) { + (obj->*method)(&out->a, &out->b, &out->c, &out->d); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const InA& in, + Tuple4* out) { + (obj->*method)(in, &out->a, &out->b, &out->c, &out->d); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple1& in, + Tuple4* out) { + (obj->*method)(in.a, &out->a, &out->b, &out->c, &out->d); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple2& in, + Tuple4* out) { + (obj->*method)(in.a, in.b, &out->a, &out->b, &out->c, &out->d); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple3& in, + Tuple4* out) { + (obj->*method)(in.a, in.b, in.c, &out->a, &out->b, &out->c, &out->d); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple4& in, + Tuple4* out) { + (obj->*method)(in.a, in.b, in.c, in.d, &out->a, &out->b, &out->c, &out->d); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple5& in, + Tuple4* out) { + (obj->*method)(in.a, in.b, in.c, in.d, in.e, + &out->a, &out->b, &out->c, &out->d); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple6& in, + Tuple4* out) { + (obj->*method)(in.a, in.b, in.c, in.d, in.e, in.f, + &out->a, &out->b, &out->c, &out->d); +} + +// Dispatchers with 5 out params. + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple0& in, + Tuple5* out) { + (obj->*method)(&out->a, &out->b, &out->c, &out->d, &out->e); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const InA& in, + Tuple5* out) { + (obj->*method)(in, &out->a, &out->b, &out->c, &out->d, &out->e); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple1& in, + Tuple5* out) { + (obj->*method)(in.a, &out->a, &out->b, &out->c, &out->d, &out->e); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple2& in, + Tuple5* out) { + (obj->*method)(in.a, in.b, &out->a, &out->b, &out->c, &out->d, &out->e); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple3& in, + Tuple5* out) { + (obj->*method)(in.a, in.b, in.c, &out->a, &out->b, &out->c, &out->d, &out->e); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple4& in, + Tuple5* out) { + (obj->*method)(in.a, in.b, in.c, in.d, &out->a, &out->b, &out->c, &out->d, + &out->e); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple5& in, + Tuple5* out) { + (obj->*method)(in.a, in.b, in.c, in.d, in.e, + &out->a, &out->b, &out->c, &out->d, &out->e); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, + const Tuple6& in, + Tuple5* out) { + (obj->*method)(in.a, in.b, in.c, in.d, in.e, in.f, + &out->a, &out->b, &out->c, &out->d, &out->e); +} + +#endif // BASE_TUPLE_H__ diff --git a/cef/include/internal/cef_types.h b/cef/include/internal/cef_types.h new file mode 100755 index 000000000..933f462c4 --- /dev/null +++ b/cef/include/internal/cef_types.h @@ -0,0 +1,1100 @@ +// Copyright (c) 2010 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_TYPES_H +#define _CEF_TYPES_H + +#include "cef_build.h" +#include "cef_string.h" +#include "cef_string_list.h" +#include "cef_time.h" + +// Bring in platform-specific definitions. +#if defined(OS_WIN) +#include "cef_types_win.h" +#elif defined(OS_MACOSX) +#include "cef_types_mac.h" +#elif defined(OS_LINUX) +#include "cef_types_linux.h" +#endif + +// The NSPR system headers define 64-bit as |long| when possible. In order to +// not have typedef mismatches, we do the same on LP64. +#if __LP64__ +typedef long int64; +typedef unsigned long uint64; +#else +typedef long long int64; +typedef unsigned long long uint64; +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/// +// Log severity levels. +/// +enum cef_log_severity_t +{ + LOGSEVERITY_VERBOSE = -1, + LOGSEVERITY_INFO, + LOGSEVERITY_WARNING, + LOGSEVERITY_ERROR, + LOGSEVERITY_ERROR_REPORT, + // Disables logging completely. + LOGSEVERITY_DISABLE = 99 +}; + +/// +// Initialization settings. Specify NULL or 0 to get the recommended default +// values. +/// +typedef struct _cef_settings_t +{ + /// + // Size of this structure. + /// + size_t size; + + /// + // Set to true (1) to have the message loop run in a separate thread. If + // false (0) than the CefDoMessageLoopWork() function must be called from + // your application message loop. + /// + bool multi_threaded_message_loop; + + /// + // The location where cache data will be stored on disk. If empty an + // in-memory cache will be used. HTML5 databases such as localStorage will + // only persist across sessions if a cache path is specified. + /// + cef_string_t cache_path; + + /// + // Value that will be returned as the User-Agent HTTP header. If empty the + // default User-Agent string will be used. + /// + cef_string_t user_agent; + + /// + // Value that will be inserted as the product portion of the default + // User-Agent string. If empty the Chromium product version will be used. If + // |userAgent| is specified this value will be ignored. + /// + cef_string_t product_version; + + /// + // The locale string that will be passed to WebKit. If empty the default + // locale of "en-US" will be used. + /// + cef_string_t locale; + + /// + // List of fully qualified paths to plugins (including plugin name) that will + // be loaded in addition to any plugins found in the default search paths. + /// + cef_string_list_t extra_plugin_paths; + + /// + // The directory and file name to use for the debug log. If empty, the + // default name of "debug.log" will be used and the file will be written + // to the application directory. + /// + cef_string_t log_file; + + /// + // The log severity. Only messages of this severity level or higher will be + // logged. + /// + cef_log_severity_t log_severity; + + /// + // The graphics implementation that CEF will use for rendering GPU accelerated + // content like WebGL, accelerated layers and 3D CSS. + /// + cef_graphics_implementation_t graphics_implementation; + + /// + // Quota limit for localStorage data across all origins. Default size is 5MB. + /// + unsigned int local_storage_quota; + + /// + // Quota limit for sessionStorage data per namespace. Default size is 5MB. + /// + unsigned int session_storage_quota; + + /// + // Custom flags that will be used when initializing the V8 JavaScript engine. + // The consequences of using custom flags may not be well tested. + /// + cef_string_t javascript_flags; + +#if defined(OS_WIN) + /// + // Set to true (1) to use the system proxy resolver on Windows when + // "Automatically detect settings" is checked. This setting is disabled + // by default for performance reasons. + /// + bool auto_detect_proxy_settings_enabled; +#endif +} cef_settings_t; + +/// +// Browser initialization settings. Specify NULL or 0 to get the recommended +// default values. The consequences of using custom values may not be well +// tested. +/// +typedef struct _cef_browser_settings_t +{ + /// + // Size of this structure. + /// + size_t size; + + /// + // Disable drag & drop of URLs from other windows. + /// + bool drag_drop_disabled; + + /// + // Disable default navigation resulting from drag & drop of URLs. + /// + bool load_drops_disabled; + + /// + // Disable history back/forward navigation. + /// + bool history_disabled; + + // The below values map to WebPreferences settings. + + /// + // Font settings. + /// + cef_string_t standard_font_family; + cef_string_t fixed_font_family; + cef_string_t serif_font_family; + cef_string_t sans_serif_font_family; + cef_string_t cursive_font_family; + cef_string_t fantasy_font_family; + int default_font_size; + int default_fixed_font_size; + int minimum_font_size; + int minimum_logical_font_size; + + /// + // Set to true (1) to disable loading of fonts from remote sources. + /// + bool remote_fonts_disabled; + + /// + // Default encoding for Web content. If empty "ISO-8859-1" will be used. + /// + cef_string_t default_encoding; + + /// + // Set to true (1) to attempt automatic detection of content encoding. + /// + bool encoding_detector_enabled; + + /// + // Set to true (1) to disable JavaScript. + /// + bool javascript_disabled; + + /// + // Set to true (1) to disallow JavaScript from opening windows. + /// + bool javascript_open_windows_disallowed; + + /// + // Set to true (1) to disallow JavaScript from closing windows. + /// + bool javascript_close_windows_disallowed; + + /// + // Set to true (1) to disallow JavaScript from accessing the clipboard. + /// + bool javascript_access_clipboard_disallowed; + + /// + // Set to true (1) to disable DOM pasting in the editor. DOM pasting also + // depends on |javascript_cannot_access_clipboard| being false (0). + /// + bool dom_paste_disabled; + + /// + // Set to true (1) to enable drawing of the caret position. + /// + bool caret_browsing_enabled; + + /// + // Set to true (1) to disable Java. + /// + bool java_disabled; + + /// + // Set to true (1) to disable plugins. + /// + bool plugins_disabled; + + /// + // Set to true (1) to allow access to all URLs from file URLs. + /// + bool universal_access_from_file_urls_allowed; + + /// + // Set to true (1) to allow access to file URLs from other file URLs. + /// + bool file_access_from_file_urls_allowed; + + /// + // Set to true (1) to allow risky security behavior such as cross-site + // scripting (XSS). Use with extreme care. + /// + bool web_security_disabled; + + /// + // Set to true (1) to enable console warnings about XSS attempts. + /// + bool xss_auditor_enabled; + + /// + // Set to true (1) to suppress the network load of image URLs. A cached + // image will still be rendered if requested. + /// + bool image_load_disabled; + + /// + // Set to true (1) to shrink standalone images to fit the page. + /// + bool shrink_standalone_images_to_fit; + + /// + // Set to true (1) to disable browser backwards compatibility features. + /// + bool site_specific_quirks_disabled; + + /// + // Set to true (1) to disable resize of text areas. + /// + bool text_area_resize_disabled; + + /// + // Set to true (1) to disable use of the page cache. + /// + bool page_cache_disabled; + + /// + // Set to true (1) to not have the tab key advance focus to links. + /// + bool tab_to_links_disabled; + + /// + // Set to true (1) to disable hyperlink pings ( and window.sendPing). + /// + bool hyperlink_auditing_disabled; + + /// + // Set to true (1) to enable the user style sheet for all pages. + /// + bool user_style_sheet_enabled; + + /// + // Location of the user style sheet. This must be a data URL of the form + // "data:text/css;charset=utf-8;base64,csscontent" where "csscontent" is the + // base64 encoded contents of the CSS file. + /// + cef_string_t user_style_sheet_location; + + /// + // Set to true (1) to disable style sheets. + /// + bool author_and_user_styles_disabled; + + /// + // Set to true (1) to disable local storage. + /// + bool local_storage_disabled; + + /// + // Set to true (1) to disable databases. + /// + bool databases_disabled; + + /// + // Set to true (1) to disable application cache. + /// + bool application_cache_disabled; + + /// + // Set to true (1) to disable WebGL. + /// + bool webgl_disabled; + + /// + // Set to true (1) to enable accelerated compositing. This is turned off by + // default because the current in-process GPU implementation does not + // support it correctly. + /// + bool accelerated_compositing_enabled; + + /// + // Set to true (1) to enable threaded compositing. This is currently only + // supported by the command buffer graphics implementation. + /// + bool threaded_compositing_enabled; + + /// + // Set to true (1) to disable accelerated layers. This affects features like + // 3D CSS transforms. + /// + bool accelerated_layers_disabled; + + /// + // Set to true (1) to disable accelerated video. + /// + bool accelerated_video_disabled; + + /// + // Set to true (1) to disable accelerated 2d canvas. + /// + bool accelerated_2d_canvas_disabled; + + /// + // Set to true (1) to disable accelerated drawing. + /// + bool accelerated_drawing_disabled; + + /// + // Set to true (1) to disable accelerated plugins. + /// + bool accelerated_plugins_disabled; + + /// + // Set to true (1) to disable developer tools (WebKit inspector). + /// + bool developer_tools_disabled; + + /// + // Set to true (1) to enable fullscreen mode. + /// + bool fullscreen_enabled; +} cef_browser_settings_t; + +/// +// URL component parts. +/// +typedef struct _cef_urlparts_t +{ + /// + // The complete URL specification. + /// + cef_string_t spec; + + /// + // Scheme component not including the colon (e.g., "http"). + /// + cef_string_t scheme; + + /// + // User name component. + /// + cef_string_t username; + + /// + // Password component. + /// + cef_string_t password; + + /// + // Host component. This may be a hostname, an IPv4 address or an IPv6 literal + // surrounded by square brackets (e.g., "[2001:db8::1]"). + /// + cef_string_t host; + + /// + // Port number component. + /// + cef_string_t port; + + /// + // Path component including the first slash following the host. + /// + cef_string_t path; + + /// + // Query string component (i.e., everything following the '?'). + /// + cef_string_t query; +} cef_urlparts_t; + +/// +// Cookie information. +/// +typedef struct _cef_cookie_t +{ + /// + // The cookie name. + /// + cef_string_t name; + + /// + // The cookie value. + /// + cef_string_t value; + + /// + // If |domain| is empty a host cookie will be created instead of a domain + // cookie. Domain cookies are stored with a leading "." and are visible to + // sub-domains whereas host cookies are not. + /// + cef_string_t domain; + + /// + // If |path| is non-empty only URLs at or below the path will get the cookie + // value. + /// + cef_string_t path; + + /// + // If |secure| is true the cookie will only be sent for HTTPS requests. + /// + bool secure; + + /// + // If |httponly| is true the cookie will only be sent for HTTP requests. + /// + bool httponly; + + /// + // The cookie creation date. This is automatically populated by the system on + // cookie creation. + /// + cef_time_t creation; + + /// + // The cookie last access date. This is automatically populated by the system + // on access. + /// + cef_time_t last_access; + + /// + // The cookie expiration date is only valid if |has_expires| is true. + /// + bool has_expires; + cef_time_t expires; +} cef_cookie_t; + +/// +// Storage types. +/// +enum cef_storage_type_t +{ + ST_LOCALSTORAGE = 0, + ST_SESSIONSTORAGE, +}; + +/// +// Mouse button types. +/// +enum cef_mouse_button_type_t +{ + MBT_LEFT = 0, + MBT_MIDDLE, + MBT_RIGHT, +}; + +/// +// Key types. +/// +enum cef_key_type_t +{ + KT_KEYUP = 0, + KT_KEYDOWN, + KT_CHAR, +}; + +/// +// Various browser navigation types supported by chrome. +/// +enum cef_handler_navtype_t +{ + NAVTYPE_LINKCLICKED = 0, + NAVTYPE_FORMSUBMITTED, + NAVTYPE_BACKFORWARD, + NAVTYPE_RELOAD, + NAVTYPE_FORMRESUBMITTED, + NAVTYPE_OTHER, + NAVTYPE_LINKDROPPED, +}; + +/// +// Supported error code values. See net\base\net_error_list.h for complete +// descriptions of the error codes. +/// +enum cef_handler_errorcode_t +{ + ERR_FAILED = -2, + ERR_ABORTED = -3, + ERR_INVALID_ARGUMENT = -4, + ERR_INVALID_HANDLE = -5, + ERR_FILE_NOT_FOUND = -6, + ERR_TIMED_OUT = -7, + ERR_FILE_TOO_BIG = -8, + ERR_UNEXPECTED = -9, + ERR_ACCESS_DENIED = -10, + ERR_NOT_IMPLEMENTED = -11, + ERR_CONNECTION_CLOSED = -100, + ERR_CONNECTION_RESET = -101, + ERR_CONNECTION_REFUSED = -102, + ERR_CONNECTION_ABORTED = -103, + ERR_CONNECTION_FAILED = -104, + ERR_NAME_NOT_RESOLVED = -105, + ERR_INTERNET_DISCONNECTED = -106, + ERR_SSL_PROTOCOL_ERROR = -107, + ERR_ADDRESS_INVALID = -108, + ERR_ADDRESS_UNREACHABLE = -109, + ERR_SSL_CLIENT_AUTH_CERT_NEEDED = -110, + ERR_TUNNEL_CONNECTION_FAILED = -111, + ERR_NO_SSL_VERSIONS_ENABLED = -112, + ERR_SSL_VERSION_OR_CIPHER_MISMATCH = -113, + ERR_SSL_RENEGOTIATION_REQUESTED = -114, + ERR_CERT_COMMON_NAME_INVALID = -200, + ERR_CERT_DATE_INVALID = -201, + ERR_CERT_AUTHORITY_INVALID = -202, + ERR_CERT_CONTAINS_ERRORS = -203, + ERR_CERT_NO_REVOCATION_MECHANISM = -204, + ERR_CERT_UNABLE_TO_CHECK_REVOCATION = -205, + ERR_CERT_REVOKED = -206, + ERR_CERT_INVALID = -207, + ERR_CERT_END = -208, + ERR_INVALID_URL = -300, + ERR_DISALLOWED_URL_SCHEME = -301, + ERR_UNKNOWN_URL_SCHEME = -302, + ERR_TOO_MANY_REDIRECTS = -310, + ERR_UNSAFE_REDIRECT = -311, + ERR_UNSAFE_PORT = -312, + ERR_INVALID_RESPONSE = -320, + ERR_INVALID_CHUNKED_ENCODING = -321, + ERR_METHOD_NOT_SUPPORTED = -322, + ERR_UNEXPECTED_PROXY_AUTH = -323, + ERR_EMPTY_RESPONSE = -324, + ERR_RESPONSE_HEADERS_TOO_BIG = -325, + ERR_CACHE_MISS = -400, + ERR_INSECURE_RESPONSE = -501, +}; + +/// +// "Verb" of a drag-and-drop operation as negotiated between the source and +// destination. These constants match their equivalents in WebCore's +// DragActions.h and should not be renumbered. +/// +enum cef_drag_operations_mask_t +{ + DRAG_OPERATION_NONE = 0, + DRAG_OPERATION_COPY = 1, + DRAG_OPERATION_LINK = 2, + DRAG_OPERATION_GENERIC = 4, + DRAG_OPERATION_PRIVATE = 8, + DRAG_OPERATION_MOVE = 16, + DRAG_OPERATION_DELETE = 32, + DRAG_OPERATION_EVERY = UINT_MAX +}; + +/// +// V8 access control values. +/// +enum cef_v8_accesscontrol_t +{ + V8_ACCESS_CONTROL_DEFAULT = 0, + V8_ACCESS_CONTROL_ALL_CAN_READ = 1, + V8_ACCESS_CONTROL_ALL_CAN_WRITE = 1 << 1, + V8_ACCESS_CONTROL_PROHIBITS_OVERWRITING = 1 << 2 +}; + +/// +// V8 property attribute values. +/// +enum cef_v8_propertyattribute_t +{ + V8_PROPERTY_ATTRIBUTE_NONE = 0, // Writeable, Enumerable, + // Configurable + V8_PROPERTY_ATTRIBUTE_READONLY = 1 << 0, // Not writeable + V8_PROPERTY_ATTRIBUTE_DONTENUM = 1 << 1, // Not enumerable + V8_PROPERTY_ATTRIBUTE_DONTDELETE = 1 << 2 // Not configurable +}; + +/// +// Structure representing menu information. +/// +typedef struct _cef_menu_info_t +{ + /// + // Values from the cef_handler_menutypebits_t enumeration. + /// + int typeFlags; + + /// + // If window rendering is enabled |x| and |y| will be in screen coordinates. + // Otherwise, |x| and |y| will be in view coordinates. + /// + int x; + int y; + + cef_string_t linkUrl; + cef_string_t imageUrl; + cef_string_t pageUrl; + cef_string_t frameUrl; + cef_string_t selectionText; + cef_string_t misspelledWord; + + /// + // Values from the cef_handler_menucapabilitybits_t enumeration. + /// + int editFlags; + + cef_string_t securityInfo; +} cef_menu_info_t; + +/// +// The cef_menu_info_t typeFlags value will be a combination of the +// following values. +/// +enum cef_menu_typebits_t +{ + /// + // No node is selected + /// + MENUTYPE_NONE = 0x0, + /// + // The top page is selected + /// + MENUTYPE_PAGE = 0x1, + /// + // A subframe page is selected + /// + MENUTYPE_FRAME = 0x2, + /// + // A link is selected + /// + MENUTYPE_LINK = 0x4, + /// + // An image is selected + /// + MENUTYPE_IMAGE = 0x8, + /// + // There is a textual or mixed selection that is selected + /// + MENUTYPE_SELECTION = 0x10, + /// + // An editable element is selected + /// + MENUTYPE_EDITABLE = 0x20, + /// + // A misspelled word is selected + /// + MENUTYPE_MISSPELLED_WORD = 0x40, + /// + // A video node is selected + /// + MENUTYPE_VIDEO = 0x80, + /// + // A video node is selected + /// + MENUTYPE_AUDIO = 0x100, +}; + +/// +// The cef_menu_info_t editFlags value will be a combination of the +// following values. +/// +enum cef_menu_capabilitybits_t +{ + // Values from WebContextMenuData::EditFlags in WebContextMenuData.h + MENU_CAN_DO_NONE = 0x0, + MENU_CAN_UNDO = 0x1, + MENU_CAN_REDO = 0x2, + MENU_CAN_CUT = 0x4, + MENU_CAN_COPY = 0x8, + MENU_CAN_PASTE = 0x10, + MENU_CAN_DELETE = 0x20, + MENU_CAN_SELECT_ALL = 0x40, + MENU_CAN_TRANSLATE = 0x80, + // Values unique to CEF + MENU_CAN_GO_FORWARD = 0x10000000, + MENU_CAN_GO_BACK = 0x20000000, +}; + +/// +// Supported menu ID values. +/// +enum cef_menu_id_t +{ + MENU_ID_NAV_BACK = 10, + MENU_ID_NAV_FORWARD = 11, + MENU_ID_NAV_RELOAD = 12, + MENU_ID_NAV_RELOAD_NOCACHE = 13, + MENU_ID_NAV_STOP = 14, + MENU_ID_UNDO = 20, + MENU_ID_REDO = 21, + MENU_ID_CUT = 22, + MENU_ID_COPY = 23, + MENU_ID_PASTE = 24, + MENU_ID_DELETE = 25, + MENU_ID_SELECTALL = 26, + MENU_ID_PRINT = 30, + MENU_ID_VIEWSOURCE = 31, +}; + +enum cef_paint_element_type_t +{ + PET_VIEW = 0, + PET_POPUP, +}; + +/// +// Post data elements may represent either bytes or files. +/// +enum cef_postdataelement_type_t +{ + PDE_TYPE_EMPTY = 0, + PDE_TYPE_BYTES, + PDE_TYPE_FILE, +}; + +enum cef_weburlrequest_flags_t +{ + WUR_FLAG_NONE = 0, + WUR_FLAG_SKIP_CACHE = 0x1, + WUR_FLAG_ALLOW_CACHED_CREDENTIALS = 0x2, + WUR_FLAG_ALLOW_COOKIES = 0x4, + WUR_FLAG_REPORT_UPLOAD_PROGRESS = 0x8, + WUR_FLAG_REPORT_LOAD_TIMING = 0x10, + WUR_FLAG_REPORT_RAW_HEADERS = 0x20 +}; + +enum cef_weburlrequest_state_t +{ + WUR_STATE_UNSENT = 0, + WUR_STATE_STARTED = 1, + WUR_STATE_HEADERS_RECEIVED = 2, + WUR_STATE_LOADING = 3, + WUR_STATE_DONE = 4, + WUR_STATE_ERROR = 5, + WUR_STATE_ABORT = 6, +}; + +/// +// Focus sources. +/// +enum cef_handler_focus_source_t +{ + /// + // The source is explicit navigation via the API (LoadURL(), etc). + /// + FOCUS_SOURCE_NAVIGATION = 0, + /// + // The source is a system-generated focus event. + /// + FOCUS_SOURCE_SYSTEM, + /// + // The source is a child widget of the browser window requesting focus. + /// + FOCUS_SOURCE_WIDGET, +}; + +/// +// Key event types. +/// +enum cef_handler_keyevent_type_t +{ + KEYEVENT_RAWKEYDOWN = 0, + KEYEVENT_KEYDOWN, + KEYEVENT_KEYUP, + KEYEVENT_CHAR +}; + +/// +// Key event modifiers. +/// +enum cef_handler_keyevent_modifiers_t +{ + KEY_SHIFT = 1 << 0, + KEY_CTRL = 1 << 1, + KEY_ALT = 1 << 2, + KEY_META = 1 << 3 +}; + +/// +// Structure representing a rectangle. +/// +typedef struct _cef_rect_t +{ + int x; + int y; + int width; + int height; +} cef_rect_t; + +/// +// Existing thread IDs. +/// +enum cef_thread_id_t +{ + TID_UI = 0, + TID_IO = 1, + TID_FILE = 2, +}; + +/// +// Paper type for printing. +/// +enum cef_paper_type_t +{ + PT_LETTER = 0, + PT_LEGAL, + PT_EXECUTIVE, + PT_A3, + PT_A4, + PT_CUSTOM +}; + +/// +// Paper metric information for printing. +/// +struct cef_paper_metrics +{ + enum cef_paper_type_t paper_type; + //Length and width needed if paper_type is custom_size + //Units are in inches. + double length; + double width; +}; + +/// +// Paper print margins. +/// +struct cef_print_margins +{ + //Margin size in inches for left/right/top/bottom (this is content margins). + double left; + double right; + double top; + double bottom; + //Margin size (top/bottom) in inches for header/footer. + double header; + double footer; +}; + +/// +// Page orientation for printing. +/// +enum cef_page_orientation +{ + PORTRAIT = 0, + LANDSCAPE +}; + +/// +// Printing options. +/// +typedef struct _cef_print_options_t +{ + enum cef_page_orientation page_orientation; + struct cef_paper_metrics paper_metrics; + struct cef_print_margins paper_margins; +} cef_print_options_t; + +/// +// Supported XML encoding types. The parser supports ASCII, ISO-8859-1, and +// UTF16 (LE and BE) by default. All other types must be translated to UTF8 +// before being passed to the parser. If a BOM is detected and the correct +// decoder is available then that decoder will be used automatically. +/// +enum cef_xml_encoding_type_t +{ + XML_ENCODING_NONE = 0, + XML_ENCODING_UTF8, + XML_ENCODING_UTF16LE, + XML_ENCODING_UTF16BE, + XML_ENCODING_ASCII, +}; + +/// +// XML node types. +/// +enum cef_xml_node_type_t +{ + XML_NODE_UNSUPPORTED = 0, + XML_NODE_PROCESSING_INSTRUCTION, + XML_NODE_DOCUMENT_TYPE, + XML_NODE_ELEMENT_START, + XML_NODE_ELEMENT_END, + XML_NODE_ATTRIBUTE, + XML_NODE_TEXT, + XML_NODE_CDATA, + XML_NODE_ENTITY_REFERENCE, + XML_NODE_WHITESPACE, + XML_NODE_COMMENT, +}; + +/// +// Status message types. +/// +enum cef_handler_statustype_t +{ + STATUSTYPE_TEXT = 0, + STATUSTYPE_MOUSEOVER_URL, + STATUSTYPE_KEYBOARD_FOCUS_URL, +}; + +/// +// Popup window features. +/// +typedef struct _cef_popup_features_t +{ + int x; + bool xSet; + int y; + bool ySet; + int width; + bool widthSet; + int height; + bool heightSet; + + bool menuBarVisible; + bool statusBarVisible; + bool toolBarVisible; + bool locationBarVisible; + bool scrollbarsVisible; + bool resizable; + + bool fullscreen; + bool dialog; + cef_string_list_t additionalFeatures; +} cef_popup_features_t; + +/// +// DOM document types. +/// +enum cef_dom_document_type_t +{ + DOM_DOCUMENT_TYPE_UNKNOWN = 0, + DOM_DOCUMENT_TYPE_HTML, + DOM_DOCUMENT_TYPE_XHTML, + DOM_DOCUMENT_TYPE_PLUGIN, +}; + +/// +// DOM event category flags. +/// +enum cef_dom_event_category_t +{ + DOM_EVENT_CATEGORY_UNKNOWN = 0x0, + DOM_EVENT_CATEGORY_UI = 0x1, + DOM_EVENT_CATEGORY_MOUSE = 0x2, + DOM_EVENT_CATEGORY_MUTATION = 0x4, + DOM_EVENT_CATEGORY_KEYBOARD = 0x8, + DOM_EVENT_CATEGORY_TEXT = 0x10, + DOM_EVENT_CATEGORY_COMPOSITION = 0x20, + DOM_EVENT_CATEGORY_DRAG = 0x40, + DOM_EVENT_CATEGORY_CLIPBOARD = 0x80, + DOM_EVENT_CATEGORY_MESSAGE = 0x100, + DOM_EVENT_CATEGORY_WHEEL = 0x200, + DOM_EVENT_CATEGORY_BEFORE_TEXT_INSERTED = 0x400, + DOM_EVENT_CATEGORY_OVERFLOW = 0x800, + DOM_EVENT_CATEGORY_PAGE_TRANSITION = 0x1000, + DOM_EVENT_CATEGORY_POPSTATE = 0x2000, + DOM_EVENT_CATEGORY_PROGRESS = 0x4000, + DOM_EVENT_CATEGORY_XMLHTTPREQUEST_PROGRESS = 0x8000, + DOM_EVENT_CATEGORY_WEBKIT_ANIMATION = 0x10000, + DOM_EVENT_CATEGORY_WEBKIT_TRANSITION = 0x20000, + DOM_EVENT_CATEGORY_BEFORE_LOAD = 0x40000, +}; + +/// +// DOM event processing phases. +/// +enum cef_dom_event_phase_t +{ + DOM_EVENT_PHASE_UNKNOWN = 0, + DOM_EVENT_PHASE_CAPTURING, + DOM_EVENT_PHASE_AT_TARGET, + DOM_EVENT_PHASE_BUBBLING, +}; + +/// +// DOM node types. +/// +enum cef_dom_node_type_t +{ + DOM_NODE_TYPE_UNSUPPORTED = 0, + DOM_NODE_TYPE_ELEMENT, + DOM_NODE_TYPE_ATTRIBUTE, + DOM_NODE_TYPE_TEXT, + DOM_NODE_TYPE_CDATA_SECTION, + DOM_NODE_TYPE_ENTITY_REFERENCE, + DOM_NODE_TYPE_ENTITY, + DOM_NODE_TYPE_PROCESSING_INSTRUCTIONS, + DOM_NODE_TYPE_COMMENT, + DOM_NODE_TYPE_DOCUMENT, + DOM_NODE_TYPE_DOCUMENT_TYPE, + DOM_NODE_TYPE_DOCUMENT_FRAGMENT, + DOM_NODE_TYPE_NOTATION, + DOM_NODE_TYPE_XPATH_NAMESPACE, +}; + +/// +// Proxy types. +/// +enum cef_proxy_type_t +{ + PROXY_TYPE_DIRECT = 0, + PROXY_TYPE_NAMED, + PROXY_TYPE_PAC_STRING, +}; + +/// +// Proxy information. +/// +typedef struct _cef_proxy_info_t +{ + enum cef_proxy_type_t proxyType; + cef_string_t proxyList; +} cef_proxy_info_t; + +#ifdef __cplusplus +} +#endif + +#endif // _CEF_TYPES_H diff --git a/cef/include/internal/cef_types_mac.h b/cef/include/internal/cef_types_mac.h new file mode 100755 index 000000000..0773a9772 --- /dev/null +++ b/cef/include/internal/cef_types_mac.h @@ -0,0 +1,96 @@ +// Copyright (c) 2010 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_TYPES_MAC_H +#define _CEF_TYPES_MAC_H + +#if defined(OS_MACOSX) +#include "cef_string.h" + +// Window handle. +#ifdef __cplusplus +#ifdef __OBJC__ +@class NSView; +#else +class NSView; +#endif +#define cef_window_handle_t NSView* +#else +#define cef_window_handle_t void* +#endif +#define cef_cursor_handle_t void* + +#ifdef __cplusplus +extern "C" { +#endif + +/// +// Supported graphics implementations. +/// +enum cef_graphics_implementation_t +{ + DESKTOP_IN_PROCESS = 0, + DESKTOP_IN_PROCESS_COMMAND_BUFFER, +}; + +/// +// Class representing window information. +/// +typedef struct _cef_window_info_t +{ + cef_string_t m_windowName; + int m_x; + int m_y; + int m_nWidth; + int m_nHeight; + int m_bHidden; + + // NSView pointer for the parent view. + cef_window_handle_t m_ParentView; + + // NSView pointer for the new browser view. + cef_window_handle_t m_View; +} cef_window_info_t; + +/// +// Class representing print context information. +/// +typedef struct _cef_print_info_t +{ + double m_Scale; +} cef_print_info_t; + +#ifdef __cplusplus +} +#endif + +#endif // OS_MACOSX + +#endif // _CEF_TYPES_MAC_H diff --git a/cef/include/internal/cef_types_wrappers.h b/cef/include/internal/cef_types_wrappers.h new file mode 100755 index 000000000..fa73fa2d9 --- /dev/null +++ b/cef/include/internal/cef_types_wrappers.h @@ -0,0 +1,662 @@ +// 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_TYPES_WRAPPERS_H +#define _CEF_TYPES_WRAPPERS_H + +#include "cef_string.h" +#include "cef_string_list.h" +#include "cef_types.h" + +/// +// Template class that provides common functionality for CEF structure wrapping. +/// +template +class CefStructBase : public traits::struct_type { +public: + typedef typename traits::struct_type struct_type; + + CefStructBase() : attached_to_(NULL) + { + Init(); + } + virtual ~CefStructBase() + { + // Only clear this object's data if it isn't currently attached to a + // structure. + if (!attached_to_) + Clear(this); + } + + CefStructBase(const CefStructBase& r) + { + Init(); + *this = r; + } + CefStructBase(const struct_type& r) + { + Init(); + *this = r; + } + + /// + // Clear this object's values. + /// + void Reset() + { + Clear(this); + Init(); + } + + /// + // Attach to the source structure's existing values. DetachTo() can be called + // to insert the values back into the existing structure. + /// + void AttachTo(struct_type& source) + { + // Only clear this object's data if it isn't currently attached to a + // structure. + if (!attached_to_) + Clear(this); + + // This object is now attached to the new structure. + attached_to_ = &source; + + // Transfer ownership of the values from the source structure. + memcpy(static_cast(this), &source, sizeof(struct_type)); + } + + /// + // Relinquish ownership of values to the target structure. + /// + void DetachTo(struct_type& target) + { + if (attached_to_ != &target) { + // Clear the target structure's values only if we are not currently + // attached to that structure. + Clear(&target); + } + + // Transfer ownership of the values to the target structure. + memcpy(&target, static_cast(this), sizeof(struct_type)); + + // Remove the references from this object. + Init(); + } + + /// + // Set this object's values. If |copy| is true the source structure's values + // will be copied instead of referenced. + /// + void Set(const struct_type& source, bool copy) + { + traits::set(&source, this, copy); + } + + CefStructBase& operator=(const CefStructBase& s) + { + return operator=(static_cast(s)); + } + + CefStructBase& operator=(const struct_type& s) + { + Set(s, true); + return *this; + } + +protected: + void Init() + { + memset(static_cast(this), 0, sizeof(struct_type)); + attached_to_ = NULL; + traits::init(this); + } + + static void Clear(struct_type* s) { traits::clear(s); } + + struct_type* attached_to_; +}; + + +struct CefRectTraits { + typedef cef_rect_t struct_type; + + static inline void init(struct_type* s) {} + static inline void clear(struct_type* s) {} + + static inline void set(const struct_type* src, struct_type* target, bool copy) + { + *target = *src; + } +}; + +/// +// Class representing a rectangle. +/// +class CefRect : public CefStructBase +{ +public: + typedef CefStructBase parent; + + CefRect() : parent() {} + CefRect(const cef_rect_t& r) : parent(r) {} + CefRect(const CefRect& r) : parent(r) {} + CefRect(int x, int y, int width, int height) : parent() + { + Set(x, y, width, height); + } + + bool IsEmpty() const { return width <= 0 || height <= 0; } + void Set(int x, int y, int width, int height) + { + this->x = x, this->y = y, this->width = width, this->height = height; + } +}; + +inline bool operator==(const CefRect& a, const CefRect& b) +{ + return a.x == b.x && a.y == b.y && a.width == b.width && a.height == b.height; +} + +inline bool operator!=(const CefRect& a, const CefRect& b) +{ + return !(a == b); +} + + +struct CefPrintOptionsTraits { + typedef cef_print_options_t struct_type; + + static inline void init(struct_type* s) {} + static inline void clear(struct_type* s) {} + + static inline void set(const struct_type* src, struct_type* target, bool copy) + { + *target = *src; + } +}; + +/// +// Class representing print options. +/// +typedef CefStructBase CefPrintOptions; + + + +struct CefPopupFeaturesTraits { + typedef cef_popup_features_t struct_type; + + static inline void init(struct_type* s) + { + s->menuBarVisible = true; + s->statusBarVisible = true; + s->toolBarVisible = true; + s->locationBarVisible = true; + s->scrollbarsVisible = true; + s->resizable = true; + } + + static inline void clear(struct_type* s) + { + if(s->additionalFeatures) + cef_string_list_free(s->additionalFeatures); + } + + static inline void set(const struct_type* src, struct_type* target, bool copy) + { + if(target->additionalFeatures) + cef_string_list_free(target->additionalFeatures); + target->additionalFeatures = src->additionalFeatures ? + cef_string_list_copy(src->additionalFeatures) : NULL; + + target->x = src->x; + target->xSet = src->xSet; + target->y = src->y; + target->ySet = src->ySet; + target->width = src->width; + target->widthSet = src->widthSet; + target->height = src->height; + target->heightSet = src->heightSet; + target->menuBarVisible = src->menuBarVisible; + target->statusBarVisible = src->statusBarVisible; + target->toolBarVisible = src->toolBarVisible; + target->locationBarVisible = src->locationBarVisible; + target->scrollbarsVisible = src->scrollbarsVisible; + target->resizable = src->resizable; + target->fullscreen = src->fullscreen; + target->dialog = src->dialog; + } +}; + +/// +// Class representing popup window features. +/// +typedef CefStructBase CefPopupFeatures; + + +struct CefSettingsTraits { + typedef cef_settings_t struct_type; + + static inline void init(struct_type* s) + { + s->size = sizeof(struct_type); + } + + static inline void clear(struct_type* s) + { + cef_string_clear(&s->cache_path); + cef_string_clear(&s->user_agent); + cef_string_clear(&s->product_version); + cef_string_clear(&s->locale); + if(s->extra_plugin_paths) + cef_string_list_free(s->extra_plugin_paths); + cef_string_clear(&s->log_file); + cef_string_clear(&s->javascript_flags); + } + + static inline void set(const struct_type* src, struct_type* target, bool copy) + { + target->multi_threaded_message_loop = src->multi_threaded_message_loop; + + cef_string_set(src->cache_path.str, src->cache_path.length, + &target->cache_path, copy); + cef_string_set(src->user_agent.str, src->user_agent.length, + &target->user_agent, copy); + cef_string_set(src->product_version.str, src->product_version.length, + &target->product_version, copy); + cef_string_set(src->locale.str, src->locale.length, &target->locale, copy); + + if(target->extra_plugin_paths) + cef_string_list_free(target->extra_plugin_paths); + target->extra_plugin_paths = src->extra_plugin_paths ? + cef_string_list_copy(src->extra_plugin_paths) : NULL; + + cef_string_set(src->log_file.str, src->log_file.length, &target->log_file, + copy); + target->log_severity = src->log_severity; + target->graphics_implementation = src->graphics_implementation; + target->local_storage_quota = src->local_storage_quota; + target->session_storage_quota = src->session_storage_quota; + cef_string_set(src->javascript_flags.str, src->javascript_flags.length, + &target->javascript_flags, copy); + +#if defined(OS_WIN) + target->auto_detect_proxy_settings_enabled = + src->auto_detect_proxy_settings_enabled; +#endif + } +}; + +/// +// Class representing initialization settings. +/// +typedef CefStructBase CefSettings; + + +struct CefBrowserSettingsTraits { + typedef cef_browser_settings_t struct_type; + + static inline void init(struct_type* s) + { + s->size = sizeof(struct_type); + } + + static inline void clear(struct_type* s) + { + cef_string_clear(&s->standard_font_family); + cef_string_clear(&s->fixed_font_family); + cef_string_clear(&s->serif_font_family); + cef_string_clear(&s->sans_serif_font_family); + cef_string_clear(&s->cursive_font_family); + cef_string_clear(&s->fantasy_font_family); + cef_string_clear(&s->default_encoding); + cef_string_clear(&s->user_style_sheet_location); + } + + static inline void set(const struct_type* src, struct_type* target, bool copy) + { + target->drag_drop_disabled = src->drag_drop_disabled; + target->load_drops_disabled = src->load_drops_disabled; + target->history_disabled = src->history_disabled; + + cef_string_set(src->standard_font_family.str, + src->standard_font_family.length, &target->standard_font_family, copy); + cef_string_set(src->fixed_font_family.str, src->fixed_font_family.length, + &target->fixed_font_family, copy); + cef_string_set(src->serif_font_family.str, src->serif_font_family.length, + &target->serif_font_family, copy); + cef_string_set(src->sans_serif_font_family.str, + src->sans_serif_font_family.length, &target->sans_serif_font_family, + copy); + cef_string_set(src->cursive_font_family.str, + src->cursive_font_family.length, &target->cursive_font_family, copy); + cef_string_set(src->fantasy_font_family.str, + src->fantasy_font_family.length, &target->fantasy_font_family, copy); + + target->default_font_size = src->default_font_size; + target->default_fixed_font_size = src->default_fixed_font_size; + target->minimum_font_size = src->minimum_font_size; + target->minimum_logical_font_size = src->minimum_logical_font_size; + target->remote_fonts_disabled = src->remote_fonts_disabled; + + cef_string_set(src->default_encoding.str, src->default_encoding.length, + &target->default_encoding, copy); + + target->encoding_detector_enabled = src->encoding_detector_enabled; + target->javascript_disabled = src->javascript_disabled; + target->javascript_open_windows_disallowed = + src->javascript_open_windows_disallowed; + target->javascript_close_windows_disallowed = + src->javascript_close_windows_disallowed; + target->javascript_access_clipboard_disallowed = + src->javascript_access_clipboard_disallowed; + target->dom_paste_disabled = src->dom_paste_disabled; + target->caret_browsing_enabled = src->caret_browsing_enabled; + target->java_disabled = src->java_disabled; + target->plugins_disabled = src->plugins_disabled; + target->universal_access_from_file_urls_allowed = + src->universal_access_from_file_urls_allowed; + target->file_access_from_file_urls_allowed = + src->file_access_from_file_urls_allowed; + target->web_security_disabled = src->web_security_disabled; + target->xss_auditor_enabled = src->xss_auditor_enabled; + target->image_load_disabled = src->image_load_disabled; + target->shrink_standalone_images_to_fit = + src->shrink_standalone_images_to_fit; + target->site_specific_quirks_disabled = src->site_specific_quirks_disabled; + target->text_area_resize_disabled = src->text_area_resize_disabled; + target->page_cache_disabled = src->page_cache_disabled; + target->tab_to_links_disabled = src->tab_to_links_disabled; + target->hyperlink_auditing_disabled = src->hyperlink_auditing_disabled; + target->user_style_sheet_enabled = src->user_style_sheet_enabled; + + cef_string_set(src->user_style_sheet_location.str, + src->user_style_sheet_location.length, + &target->user_style_sheet_location, copy); + + target->author_and_user_styles_disabled = + src->author_and_user_styles_disabled; + target->local_storage_disabled = src->local_storage_disabled; + target->databases_disabled = src->databases_disabled; + target->application_cache_disabled = src->application_cache_disabled; + target->webgl_disabled = src->webgl_disabled; + target->accelerated_compositing_enabled = + src->accelerated_compositing_enabled; + target->threaded_compositing_enabled = src->threaded_compositing_enabled; + target->accelerated_layers_disabled = src->accelerated_layers_disabled; + target->accelerated_video_disabled = src->accelerated_video_disabled; + target->accelerated_2d_canvas_disabled = + src->accelerated_2d_canvas_disabled; + target->accelerated_drawing_disabled = src->accelerated_drawing_disabled; + target->accelerated_plugins_disabled = src->accelerated_plugins_disabled; + target->developer_tools_disabled = src->developer_tools_disabled; + target->fullscreen_enabled = src->fullscreen_enabled; + } +}; + +/// +// Class representing browser initialization settings. +/// +typedef CefStructBase CefBrowserSettings; + + +struct CefURLPartsTraits { + typedef cef_urlparts_t struct_type; + + static inline void init(struct_type* s) {} + + static inline void clear(struct_type* s) + { + cef_string_clear(&s->spec); + cef_string_clear(&s->scheme); + cef_string_clear(&s->username); + cef_string_clear(&s->password); + cef_string_clear(&s->host); + cef_string_clear(&s->port); + cef_string_clear(&s->path); + cef_string_clear(&s->query); + } + + static inline void set(const struct_type* src, struct_type* target, bool copy) + { + cef_string_set(src->spec.str, src->spec.length, &target->spec, copy); + cef_string_set(src->scheme.str, src->scheme.length, &target->scheme, copy); + cef_string_set(src->username.str, src->username.length, &target->username, + copy); + cef_string_set(src->password.str, src->password.length, &target->password, + copy); + cef_string_set(src->host.str, src->host.length, &target->host, copy); + cef_string_set(src->port.str, src->port.length, &target->port, copy); + cef_string_set(src->path.str, src->path.length, &target->path, copy); + cef_string_set(src->query.str, src->query.length, &target->query, copy); + } +}; + +/// +// Class representing a URL's component parts. +/// +typedef CefStructBase CefURLParts; + + +struct CefTimeTraits { + typedef cef_time_t struct_type; + + static inline void init(struct_type* s) {} + + static inline void clear(struct_type* s) {} + + static inline void set(const struct_type* src, struct_type* target, bool copy) + { + *target = *src; + } +}; + +/// +// Class representing a time. +/// +class CefTime : public CefStructBase +{ +public: + typedef CefStructBase parent; + + CefTime() : parent() {} + CefTime(const cef_time_t& r) : parent(r) {} + CefTime(time_t r) : parent() { SetTimeT(r); } + CefTime(double r) : parent() { SetDoubleT(r); } + + // Converts to/from time_t. + void SetTimeT(time_t r) { + cef_time_from_timet(r, this); + } + time_t GetTimeT() const { + time_t time = 0; + cef_time_to_timet(this, &time); + return time; + } + + // Converts to/from a double which is the number of seconds since epoch + // (Jan 1, 1970). Webkit uses this format to represent time. A value of 0 + // means "not initialized". + void SetDoubleT(double r) { + cef_time_from_doublet(r, this); + } + double GetDoubleT() const { + double time = 0; + cef_time_to_doublet(this, &time); + return time; + } +}; + + +struct CefCookieTraits { + typedef cef_cookie_t struct_type; + + static inline void init(struct_type* s) {} + + static inline void clear(struct_type* s) + { + cef_string_clear(&s->name); + cef_string_clear(&s->value); + cef_string_clear(&s->domain); + cef_string_clear(&s->path); + } + + static inline void set(const struct_type* src, struct_type* target, bool copy) + { + cef_string_set(src->name.str, src->name.length, &target->name, copy); + cef_string_set(src->value.str, src->value.length, &target->value, copy); + cef_string_set(src->domain.str, src->domain.length, &target->domain, copy); + cef_string_set(src->path.str, src->path.length, &target->path, copy); + target->secure = src->secure; + target->httponly = src->httponly; + target->creation = src->creation; + target->last_access = src->last_access; + target->has_expires = src->has_expires; + target->expires = src->expires; + } +}; + +/// +// Class representing a cookie. +/// +typedef CefStructBase CefCookie; + + +struct CefMenuInfoTraits { + typedef cef_menu_info_t struct_type; + + static inline void init(struct_type* s) {} + + static inline void clear(struct_type* s) + { + cef_string_clear(&s->linkUrl); + cef_string_clear(&s->imageUrl); + cef_string_clear(&s->pageUrl); + cef_string_clear(&s->frameUrl); + cef_string_clear(&s->selectionText); + cef_string_clear(&s->misspelledWord); + cef_string_clear(&s->securityInfo); + } + + static inline void set(const struct_type* src, struct_type* target, bool copy) + { + target->typeFlags = src->typeFlags; + target->x = src->x; + target->y = src->y; + + cef_string_set(src->linkUrl.str, src->linkUrl.length, + &target->linkUrl, copy); + cef_string_set(src->imageUrl.str, src->imageUrl.length, + &target->imageUrl, copy); + cef_string_set(src->pageUrl.str, src->pageUrl.length, + &target->pageUrl, copy); + cef_string_set(src->frameUrl.str, src->frameUrl.length, + &target->frameUrl, copy); + cef_string_set(src->selectionText.str, src->selectionText.length, + &target->selectionText, copy); + cef_string_set(src->misspelledWord.str, src->misspelledWord.length, + &target->misspelledWord, copy); + cef_string_set(src->securityInfo.str, src->securityInfo.length, + &target->securityInfo, copy); + + target->editFlags = src->editFlags; + } +}; + +/// +// Class representing menu info. +/// +typedef CefStructBase CefMenuInfo; + + +struct CefProxyInfoTraits { + typedef cef_proxy_info_t struct_type; + + static inline void init(struct_type* s) {} + + static inline void clear(struct_type* s) + { + cef_string_clear(&s->proxyList); + } + + static inline void set(const struct_type* src, struct_type* target, bool copy) + { + target->proxyType = src->proxyType; + cef_string_set(src->proxyList.str, src->proxyList.length, + &target->proxyList, copy); + } +}; + +/// +// Class representing the results of proxy resolution. +/// +class CefProxyInfo : public CefStructBase +{ +public: + /// + // Use a direction connection instead of a proxy. + /// + void UseDirect() + { + proxyType = PROXY_TYPE_DIRECT; + } + + /// + // Use one or more named proxy servers specified in WinHTTP format. Each proxy + // server is of the form: + // + // ["://"][":"] + // + // Multiple values may be separated by semicolons or whitespace. For example, + // "foo1:80;foo2:80". + /// + void UseNamedProxy(const CefString& proxy_uri_list) + { + proxyType = PROXY_TYPE_NAMED; + (CefString(&proxyList)) = proxy_uri_list; + } + + /// + // Use one or more named proxy servers specified in PAC script format. For + // example, "PROXY foobar:99; SOCKS fml:2; DIRECT". + /// + void UsePacString(const CefString& pac_string) + { + proxyType = PROXY_TYPE_PAC_STRING; + (CefString(&proxyList)) = pac_string; + } + + bool IsDirect() const { return proxyType == PROXY_TYPE_DIRECT; } + bool IsNamedProxy() const { return proxyType == PROXY_TYPE_NAMED; } + bool IsPacString() const { return proxyType == PROXY_TYPE_PAC_STRING; } + + CefString ProxyList() const { return CefString(&proxyList); } +}; + +#endif // _CEF_TYPES_WRAPPERS_H diff --git a/cef/include/internal/npapi/README-TRANSFER.txt b/cef/include/internal/npapi/README-TRANSFER.txt new file mode 100755 index 000000000..4eecacab8 --- /dev/null +++ b/cef/include/internal/npapi/README-TRANSFER.txt @@ -0,0 +1,14 @@ +Files in this directory have been copied from other locations in the Chromium +source tree. They have been modified only to the extent necessary to work in +the CEF Binary Distribution directory structure. Below is a listing of the +original file locations. + +../base/basictypes.h +../build/build_config.h +../third_party/npapi/bindings/npapi.h +../third_party/npapi/bindings/npapi_extensions.h +../third_party/npapi/bindings/npfunctions.h +../third_party/npapi/bindings/nphostapi.h +../third_party/npapi/bindings/npruntime.h +../third_party/npapi/bindings/nptypes.h +../base/port.h diff --git a/cef/include/internal/npapi/basictypes.h b/cef/include/internal/npapi/basictypes.h new file mode 100755 index 000000000..97ca48571 --- /dev/null +++ b/cef/include/internal/npapi/basictypes.h @@ -0,0 +1,363 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef BASE_BASICTYPES_H_ +#define BASE_BASICTYPES_H_ +#pragma once + +#include // So we can set the bounds of our types +#include // For size_t +#include // for memcpy + +// Include path modified for CEF Binary Distribution. +#include "port.h" // Types that only need exist on certain systems + +#ifndef COMPILER_MSVC +// stdint.h is part of C99 but MSVC doesn't have it. +#include // For intptr_t. +#endif + +typedef signed char schar; +typedef signed char int8; +typedef short int16; +// TODO: Remove these type guards. These are to avoid conflicts with +// obsolete/protypes.h in the Gecko SDK. +#ifndef _INT32 +#define _INT32 +typedef int int32; +#endif + +// The NSPR system headers define 64-bit as |long| when possible, except on +// Mac OS X. In order to not have typedef mismatches, we do the same on LP64. +// +// On Mac OS X, |long long| is used for 64-bit types for compatibility with +// format macros even in the LP64 model. +#if defined(__LP64__) && !defined(OS_MACOSX) && !defined(OS_OPENBSD) +typedef long int64; +#else +typedef long long int64; +#endif + +// NOTE: unsigned types are DANGEROUS in loops and other arithmetical +// places. Use the signed types unless your variable represents a bit +// pattern (eg a hash value) or you really need the extra bit. Do NOT +// use 'unsigned' to express "this value should always be positive"; +// use assertions for this. + +typedef unsigned char uint8; +typedef unsigned short uint16; +// TODO: Remove these type guards. These are to avoid conflicts with +// obsolete/protypes.h in the Gecko SDK. +#ifndef _UINT32 +#define _UINT32 +typedef unsigned int uint32; +#endif + +// See the comment above about NSPR and 64-bit. +#if defined(__LP64__) && !defined(OS_MACOSX) && !defined(OS_OPENBSD) +typedef unsigned long uint64; +#else +typedef unsigned long long uint64; +#endif + +// A type to represent a Unicode code-point value. As of Unicode 4.0, +// such values require up to 21 bits. +// (For type-checking on pointers, make this explicitly signed, +// and it should always be the signed version of whatever int32 is.) +typedef signed int char32; + +const uint8 kuint8max = (( uint8) 0xFF); +const uint16 kuint16max = ((uint16) 0xFFFF); +const uint32 kuint32max = ((uint32) 0xFFFFFFFF); +const uint64 kuint64max = ((uint64) GG_LONGLONG(0xFFFFFFFFFFFFFFFF)); +const int8 kint8min = (( int8) 0x80); +const int8 kint8max = (( int8) 0x7F); +const int16 kint16min = (( int16) 0x8000); +const int16 kint16max = (( int16) 0x7FFF); +const int32 kint32min = (( int32) 0x80000000); +const int32 kint32max = (( int32) 0x7FFFFFFF); +const int64 kint64min = (( int64) GG_LONGLONG(0x8000000000000000)); +const int64 kint64max = (( int64) GG_LONGLONG(0x7FFFFFFFFFFFFFFF)); + +// A macro to disallow the copy constructor and operator= functions +// This should be used in the private: declarations for a class +#define DISALLOW_COPY_AND_ASSIGN(TypeName) \ + TypeName(const TypeName&); \ + void operator=(const TypeName&) + +// An older, deprecated, politically incorrect name for the above. +// NOTE: The usage of this macro was baned from our code base, but some +// third_party libraries are yet using it. +// TODO(tfarina): Figure out how to fix the usage of this macro in the +// third_party libraries and get rid of it. +#define DISALLOW_EVIL_CONSTRUCTORS(TypeName) DISALLOW_COPY_AND_ASSIGN(TypeName) + +// A macro to disallow all the implicit constructors, namely the +// default constructor, copy constructor and operator= functions. +// +// This should be used in the private: declarations for a class +// that wants to prevent anyone from instantiating it. This is +// especially useful for classes containing only static methods. +#define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \ + TypeName(); \ + DISALLOW_COPY_AND_ASSIGN(TypeName) + +// The arraysize(arr) macro returns the # of elements in an array arr. +// The expression is a compile-time constant, and therefore can be +// used in defining new arrays, for example. If you use arraysize on +// a pointer by mistake, you will get a compile-time error. +// +// One caveat is that arraysize() doesn't accept any array of an +// anonymous type or a type defined inside a function. In these rare +// cases, you have to use the unsafe ARRAYSIZE_UNSAFE() macro below. This is +// due to a limitation in C++'s template system. The limitation might +// eventually be removed, but it hasn't happened yet. + +// This template function declaration is used in defining arraysize. +// Note that the function doesn't need an implementation, as we only +// use its type. +template +char (&ArraySizeHelper(T (&array)[N]))[N]; + +// That gcc wants both of these prototypes seems mysterious. VC, for +// its part, can't decide which to use (another mystery). Matching of +// template overloads: the final frontier. +#ifndef _MSC_VER +template +char (&ArraySizeHelper(const T (&array)[N]))[N]; +#endif + +#define arraysize(array) (sizeof(ArraySizeHelper(array))) + +// ARRAYSIZE_UNSAFE performs essentially the same calculation as arraysize, +// but can be used on anonymous types or types defined inside +// functions. It's less safe than arraysize as it accepts some +// (although not all) pointers. Therefore, you should use arraysize +// whenever possible. +// +// The expression ARRAYSIZE_UNSAFE(a) is a compile-time constant of type +// size_t. +// +// ARRAYSIZE_UNSAFE catches a few type errors. If you see a compiler error +// +// "warning: division by zero in ..." +// +// when using ARRAYSIZE_UNSAFE, you are (wrongfully) giving it a pointer. +// You should only use ARRAYSIZE_UNSAFE on statically allocated arrays. +// +// The following comments are on the implementation details, and can +// be ignored by the users. +// +// ARRAYSIZE_UNSAFE(arr) works by inspecting sizeof(arr) (the # of bytes in +// the array) and sizeof(*(arr)) (the # of bytes in one array +// element). If the former is divisible by the latter, perhaps arr is +// indeed an array, in which case the division result is the # of +// elements in the array. Otherwise, arr cannot possibly be an array, +// and we generate a compiler error to prevent the code from +// compiling. +// +// Since the size of bool is implementation-defined, we need to cast +// !(sizeof(a) & sizeof(*(a))) to size_t in order to ensure the final +// result has type size_t. +// +// This macro is not perfect as it wrongfully accepts certain +// pointers, namely where the pointer size is divisible by the pointee +// size. Since all our code has to go through a 32-bit compiler, +// where a pointer is 4 bytes, this means all pointers to a type whose +// size is 3 or greater than 4 will be (righteously) rejected. + +#define ARRAYSIZE_UNSAFE(a) \ + ((sizeof(a) / sizeof(*(a))) / \ + static_cast(!(sizeof(a) % sizeof(*(a))))) + + +// Use implicit_cast as a safe version of static_cast or const_cast +// for upcasting in the type hierarchy (i.e. casting a pointer to Foo +// to a pointer to SuperclassOfFoo or casting a pointer to Foo to +// a const pointer to Foo). +// When you use implicit_cast, the compiler checks that the cast is safe. +// Such explicit implicit_casts are necessary in surprisingly many +// situations where C++ demands an exact type match instead of an +// argument type convertable to a target type. +// +// The From type can be inferred, so the preferred syntax for using +// implicit_cast is the same as for static_cast etc.: +// +// implicit_cast(expr) +// +// implicit_cast would have been part of the C++ standard library, +// but the proposal was submitted too late. It will probably make +// its way into the language in the future. +template +inline To implicit_cast(From const &f) { + return f; +} + +// The COMPILE_ASSERT macro can be used to verify that a compile time +// expression is true. For example, you could use it to verify the +// size of a static array: +// +// COMPILE_ASSERT(ARRAYSIZE_UNSAFE(content_type_names) == CONTENT_NUM_TYPES, +// content_type_names_incorrect_size); +// +// or to make sure a struct is smaller than a certain size: +// +// COMPILE_ASSERT(sizeof(foo) < 128, foo_too_large); +// +// The second argument to the macro is the name of the variable. If +// the expression is false, most compilers will issue a warning/error +// containing the name of the variable. + +template +struct CompileAssert { +}; + +#undef COMPILE_ASSERT +#define COMPILE_ASSERT(expr, msg) \ + typedef CompileAssert<(bool(expr))> msg[bool(expr) ? 1 : -1] + +// Implementation details of COMPILE_ASSERT: +// +// - COMPILE_ASSERT works by defining an array type that has -1 +// elements (and thus is invalid) when the expression is false. +// +// - The simpler definition +// +// #define COMPILE_ASSERT(expr, msg) typedef char msg[(expr) ? 1 : -1] +// +// does not work, as gcc supports variable-length arrays whose sizes +// are determined at run-time (this is gcc's extension and not part +// of the C++ standard). As a result, gcc fails to reject the +// following code with the simple definition: +// +// int foo; +// COMPILE_ASSERT(foo, msg); // not supposed to compile as foo is +// // not a compile-time constant. +// +// - By using the type CompileAssert<(bool(expr))>, we ensures that +// expr is a compile-time constant. (Template arguments must be +// determined at compile-time.) +// +// - The outer parentheses in CompileAssert<(bool(expr))> are necessary +// to work around a bug in gcc 3.4.4 and 4.0.1. If we had written +// +// CompileAssert +// +// instead, these compilers will refuse to compile +// +// COMPILE_ASSERT(5 > 0, some_message); +// +// (They seem to think the ">" in "5 > 0" marks the end of the +// template argument list.) +// +// - The array size is (bool(expr) ? 1 : -1), instead of simply +// +// ((expr) ? 1 : -1). +// +// This is to avoid running into a bug in MS VC 7.1, which +// causes ((0.0) ? 1 : -1) to incorrectly evaluate to 1. + + +// bit_cast is a template function that implements the +// equivalent of "*reinterpret_cast(&source)". We need this in +// very low-level functions like the protobuf library and fast math +// support. +// +// float f = 3.14159265358979; +// int i = bit_cast(f); +// // i = 0x40490fdb +// +// The classical address-casting method is: +// +// // WRONG +// float f = 3.14159265358979; // WRONG +// int i = * reinterpret_cast(&f); // WRONG +// +// The address-casting method actually produces undefined behavior +// according to ISO C++ specification section 3.10 -15 -. Roughly, this +// section says: if an object in memory has one type, and a program +// accesses it with a different type, then the result is undefined +// behavior for most values of "different type". +// +// This is true for any cast syntax, either *(int*)&f or +// *reinterpret_cast(&f). And it is particularly true for +// conversions betweeen integral lvalues and floating-point lvalues. +// +// The purpose of 3.10 -15- is to allow optimizing compilers to assume +// that expressions with different types refer to different memory. gcc +// 4.0.1 has an optimizer that takes advantage of this. So a +// non-conforming program quietly produces wildly incorrect output. +// +// The problem is not the use of reinterpret_cast. The problem is type +// punning: holding an object in memory of one type and reading its bits +// back using a different type. +// +// The C++ standard is more subtle and complex than this, but that +// is the basic idea. +// +// Anyways ... +// +// bit_cast<> calls memcpy() which is blessed by the standard, +// especially by the example in section 3.9 . Also, of course, +// bit_cast<> wraps up the nasty logic in one place. +// +// Fortunately memcpy() is very fast. In optimized mode, with a +// constant size, gcc 2.95.3, gcc 4.0.1, and msvc 7.1 produce inline +// code with the minimal amount of data movement. On a 32-bit system, +// memcpy(d,s,4) compiles to one load and one store, and memcpy(d,s,8) +// compiles to two loads and two stores. +// +// I tested this code with gcc 2.95.3, gcc 4.0.1, icc 8.1, and msvc 7.1. +// +// WARNING: if Dest or Source is a non-POD type, the result of the memcpy +// is likely to surprise you. + +template +inline Dest bit_cast(const Source& source) { + // Compile time assertion: sizeof(Dest) == sizeof(Source) + // A compile error here means your Dest and Source have different sizes. + typedef char VerifySizesAreEqual [sizeof(Dest) == sizeof(Source) ? 1 : -1]; + + Dest dest; + memcpy(&dest, &source, sizeof(dest)); + return dest; +} + +// Used to explicitly mark the return value of a function as unused. If you are +// really sure you don't want to do anything with the return value of a function +// that has been marked WARN_UNUSED_RESULT, wrap it with this. Example: +// +// scoped_ptr my_var = ...; +// if (TakeOwnership(my_var.get()) == SUCCESS) +// ignore_result(my_var.release()); +// +template +inline void ignore_result(const T&) { +} + +// The following enum should be used only as a constructor argument to indicate +// that the variable has static storage class, and that the constructor should +// do nothing to its state. It indicates to the reader that it is legal to +// declare a static instance of the class, provided the constructor is given +// the base::LINKER_INITIALIZED argument. Normally, it is unsafe to declare a +// static variable that has a constructor or a destructor because invocation +// order is undefined. However, IF the type can be initialized by filling with +// zeroes (which the loader does for static variables), AND the destructor also +// does nothing to the storage, AND there are no virtual methods, then a +// constructor declared as +// explicit MyClass(base::LinkerInitialized x) {} +// and invoked as +// static MyClass my_variable_name(base::LINKER_INITIALIZED); +namespace base { +enum LinkerInitialized { LINKER_INITIALIZED }; + +// Use these to declare and define a static local variable (static T;) so that +// it is leaked so that its destructors are not called at exit. If you need +// thread-safe initialization, use base/lazy_instance.h instead. +#define CR_DEFINE_STATIC_LOCAL(type, name, arguments) \ + static type& name = *new type arguments + +} // base + +#endif // BASE_BASICTYPES_H_ diff --git a/cef/include/internal/npapi/build_config.h b/cef/include/internal/npapi/build_config.h new file mode 100755 index 000000000..97b0b5aa9 --- /dev/null +++ b/cef/include/internal/npapi/build_config.h @@ -0,0 +1,148 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// This file adds defines about the platform we're currently building on. +// Operating System: +// OS_WIN / OS_MACOSX / OS_LINUX / OS_POSIX (MACOSX or LINUX) +// Compiler: +// COMPILER_MSVC / COMPILER_GCC +// Processor: +// ARCH_CPU_X86 / ARCH_CPU_X86_64 / ARCH_CPU_X86_FAMILY (X86 or X86_64) +// ARCH_CPU_32_BITS / ARCH_CPU_64_BITS + +#ifndef BUILD_BUILD_CONFIG_H_ +#define BUILD_BUILD_CONFIG_H_ + +// A set of macros to use for platform detection. +#if defined(__APPLE__) +#define OS_MACOSX 1 +#elif defined(ANDROID) +#define OS_ANDROID 1 +#elif defined(__native_client__) +#define OS_NACL 1 +#elif defined(__linux__) +#define OS_LINUX 1 +// Use TOOLKIT_GTK on linux if TOOLKIT_VIEWS isn't defined. +#if !defined(TOOLKIT_VIEWS) +#define TOOLKIT_GTK +#endif +#elif defined(_WIN32) +#define OS_WIN 1 +#define TOOLKIT_VIEWS 1 +#elif defined(__FreeBSD__) +#define OS_FREEBSD 1 +#define TOOLKIT_GTK +#elif defined(__OpenBSD__) +#define OS_OPENBSD 1 +#define TOOLKIT_GTK +#elif defined(__sun) +#define OS_SOLARIS 1 +#define TOOLKIT_GTK +#else +#error Please add support for your platform in build/build_config.h +#endif + +#if defined(USE_OPENSSL) && defined(USE_NSS) +#error Cannot use both OpenSSL and NSS +#endif + +// For access to standard BSD features, use OS_BSD instead of a +// more specific macro. +#if defined(OS_FREEBSD) || defined(OS_OPENBSD) +#define OS_BSD 1 +#endif + +// For access to standard POSIXish features, use OS_POSIX instead of a +// more specific macro. +#if defined(OS_MACOSX) || defined(OS_LINUX) || defined(OS_FREEBSD) || \ + defined(OS_OPENBSD) || defined(OS_SOLARIS) || defined(OS_ANDROID) || \ + defined(OS_NACL) +#define OS_POSIX 1 +#endif + +#if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) && \ + !defined(OS_NACL) +#define USE_X11 1 // Use X for graphics. +#endif + +// Use tcmalloc +#if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(NO_TCMALLOC) +#define USE_TCMALLOC 1 +#endif + +// Use heapchecker. +#if defined(OS_LINUX) && !defined(NO_HEAPCHECKER) +#define USE_HEAPCHECKER 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 build/build_config.h +#endif + +// Processor architecture detection. For more info on what's defined, see: +// http://msdn.microsoft.com/en-us/library/b0084kay.aspx +// http://www.agner.org/optimize/calling_conventions.pdf +// or with gcc, run: "echo | gcc -E -dM -" +#if defined(_M_X64) || defined(__x86_64__) +#define ARCH_CPU_X86_FAMILY 1 +#define ARCH_CPU_X86_64 1 +#define ARCH_CPU_64_BITS 1 +#define ARCH_CPU_LITTLE_ENDIAN 1 +#elif defined(_M_IX86) || defined(__i386__) +#define ARCH_CPU_X86_FAMILY 1 +#define ARCH_CPU_X86 1 +#define ARCH_CPU_32_BITS 1 +#define ARCH_CPU_LITTLE_ENDIAN 1 +#elif defined(__ARMEL__) +#define ARCH_CPU_ARM_FAMILY 1 +#define ARCH_CPU_ARMEL 1 +#define ARCH_CPU_32_BITS 1 +#define ARCH_CPU_LITTLE_ENDIAN 1 +#define WCHAR_T_IS_UNSIGNED 1 +#elif defined(__pnacl__) +#define ARCH_CPU_32_BITS 1 +#else +#error Please add support for your architecture in build/build_config.h +#endif + +// Type detection for wchar_t. +#if defined(OS_WIN) +#define WCHAR_T_IS_UTF16 +#elif defined(OS_POSIX) && defined(COMPILER_GCC) && \ + defined(__WCHAR_MAX__) && \ + (__WCHAR_MAX__ == 0x7fffffff || __WCHAR_MAX__ == 0xffffffff) +#define WCHAR_T_IS_UTF32 +#elif defined(OS_POSIX) && defined(COMPILER_GCC) && \ + defined(__WCHAR_MAX__) && \ + (__WCHAR_MAX__ == 0x7fff || __WCHAR_MAX__ == 0xffff) +// On Posix, we'll detect short wchar_t, but projects aren't guaranteed to +// compile in this mode (in particular, Chrome doesn't). This is intended for +// other projects using base who manage their own dependencies and make sure +// short wchar works for them. +#define WCHAR_T_IS_UTF16 +#else +#error Please add support for your compiler in build/build_config.h +#endif + +#if defined(OS_CHROMEOS) +// Single define to trigger whether CrOS fonts have BCI on. +// In that case font sizes/deltas should be adjusted. +//define CROS_FONTS_USING_BCI +#endif + +#if defined(OS_ANDROID) +// The compiler thinks std::string::const_iterator and "const char*" are +// equivalent types. +#define STD_STRING_ITERATOR_IS_CHAR_POINTER +// The compiler thinks base::string16::const_iterator and "char16*" are +// equivalent types. +#define BASE_STRING16_ITERATOR_IS_CHAR16_POINTER +#endif + +#endif // BUILD_BUILD_CONFIG_H_ diff --git a/frameworks/WebKit.framework/Versions/A/Headers/npapi.h b/cef/include/internal/npapi/npapi.h old mode 100644 new mode 100755 similarity index 89% rename from frameworks/WebKit.framework/Versions/A/Headers/npapi.h rename to cef/include/internal/npapi/npapi.h index 00c68de70..b50824374 --- a/frameworks/WebKit.framework/Versions/A/Headers/npapi.h +++ b/cef/include/internal/npapi/npapi.h @@ -42,7 +42,21 @@ #pragma pack(1) #endif +/* BEGIN GOOGLE MODIFICATIONS */ + +#ifndef __native_client__ #include "nptypes.h" +#endif + +#ifdef __native_client__ +#include +#include +#else +// Include path modified for CEF Binary Distribution. +#include "basictypes.h" +#endif /* __native_client__ */ + +/* END GOOGLE MODIFICATIONS */ #if defined(__OS2__) || defined(OS2) #ifndef XP_OS2 @@ -50,23 +64,29 @@ #endif #endif -#ifdef INCLUDE_JAVA -#include "jri.h" /* Java Runtime Interface */ -#else -#define jref void * -#define JRIEnv void -#endif - -#ifdef _WIN32 +#if defined(_WIN32) && !defined(__SYMBIAN32__) #include #ifndef XP_WIN #define XP_WIN 1 #endif #endif +/* BEGIN GOOGLE MODIFICATIONS */ +/* On Linux and Mac, be sure to set Mozilla-specific macros. */ +#if defined(USE_X11) +#if !defined(XP_UNIX) +#define XP_UNIX 1 +#endif +#if !defined(MOZ_X11) +#define MOZ_X11 1 +#endif +#endif +/* END GOOGLE MODIFICATIONS */ + #if defined(__SYMBIAN32__) #ifndef XP_SYMBIAN #define XP_SYMBIAN 1 +#undef XP_WIN #endif #endif @@ -90,9 +110,22 @@ #endif #if defined(XP_UNIX) +#include +/* BEGIN GOOGLE MODIFICATIONS */ +#if 0 +/* END GOOGLE MODIFICATIONS */ +#if defined(MOZ_X11) #include #include -#include +#endif +/* BEGIN GOOGLE MODIFICATIONS */ +#endif +/* END GOOGLE MODIFICATIONS */ +#endif + +#if defined(XP_SYMBIAN) +#include +#include #endif /*----------------------------------------------------------------------*/ @@ -100,7 +133,7 @@ /*----------------------------------------------------------------------*/ #define NP_VERSION_MAJOR 0 -#define NP_VERSION_MINOR 24 +#define NP_VERSION_MINOR 27 /* The OS/2 version of Netscape uses RC_DATA to define the @@ -149,16 +182,6 @@ RCDATA NP_INFO_ProductName { "NPAVI32 Dynamic Link Library\0" } /* Definition of Basic Types */ /*----------------------------------------------------------------------*/ -#ifndef FALSE -#define FALSE (0) -#endif -#ifndef TRUE -#define TRUE (1) -#endif -#ifndef NULL -#define NULL (0L) -#endif - typedef unsigned char NPBool; typedef int16_t NPError; typedef int16_t NPReason; @@ -263,14 +286,9 @@ typedef struct int32_t type; } NPAnyCallbackStruct; -typedef struct -{ - int32_t type; - Display* display; - Visual* visual; - Colormap colormap; - unsigned int depth; -} NPSetWindowCallbackStruct; +/* BEGIN GOOGLE MODIFICATIONS */ +typedef struct _NPSetWindowCallbackStruct NPSetWindowCallbackStruct; +/* END GOOGLE MODIFICATIONS */ typedef struct { @@ -287,7 +305,8 @@ typedef enum { #endif NPDrawingModelCoreGraphics = 1, NPDrawingModelOpenGL = 2, - NPDrawingModelCoreAnimation = 3 + NPDrawingModelCoreAnimation = 3, + NPDrawingModelInvalidatingCoreAnimation = 4 } NPDrawingModel; typedef enum { @@ -339,14 +358,14 @@ typedef enum { NPPVpluginDescriptionString, NPPVpluginWindowBool, NPPVpluginTransparentBool, - NPPVjavaClass, /* Not implemented in WebKit */ - NPPVpluginWindowSize, /* Not implemented in WebKit */ - NPPVpluginTimerInterval, /* Not implemented in WebKit */ - NPPVpluginScriptableInstance = (10 | NP_ABI_MASK), /* Not implemented in WebKit */ - NPPVpluginScriptableIID = 11, /* Not implemented in WebKit */ - NPPVjavascriptPushCallerBool = 12, /* Not implemented in WebKit */ - NPPVpluginKeepLibraryInMemory = 13, /* Not implemented in WebKit */ - NPPVpluginNeedsXEmbed = 14, /* Not implemented in WebKit */ + NPPVjavaClass, + NPPVpluginWindowSize, + NPPVpluginTimerInterval, + NPPVpluginScriptableInstance = (10 | NP_ABI_MASK), + NPPVpluginScriptableIID = 11, + NPPVjavascriptPushCallerBool = 12, + NPPVpluginKeepLibraryInMemory = 13, + NPPVpluginNeedsXEmbed = 14, /* Get the NPObject for scripting the plugin. Introduced in NPAPI minor version 14. */ @@ -357,9 +376,9 @@ typedef enum { * NPN_MemAlloc() to allocate memory for the string data. Introduced * in NPAPI minor version 15. */ - NPPVformValue = 16, /* Not implemented in WebKit */ + NPPVformValue = 16, - NPPVpluginUrlRequestsDisplayedBool = 17, /* Not implemented in WebKit */ + NPPVpluginUrlRequestsDisplayedBool = 17, /* Checks if the plugin is interested in receiving the http body of * all http requests (including failed ones, http status != 200). @@ -370,7 +389,11 @@ typedef enum { NPPVpluginNativeAccessibleAtkPlugId = 19, /* Checks to see if the plug-in would like the browser to load the "src" attribute. */ - NPPVpluginCancelSrcStream = 20 + NPPVpluginCancelSrcStream = 20, + + NPPVsupportsAdvancedKeyHandling = 21, + + NPPVpluginUsesDOMForCursorBool = 22 #if defined(XP_MACOSX) /* Used for negotiating drawing models */ @@ -381,7 +404,7 @@ typedef enum { , NPPVpluginCoreAnimationLayer = 1003 #endif -#if defined(MOZ_PLATFORM_MAEMO) && (MOZ_PLATFORM_MAEMO >= 5) +#if (MOZ_PLATFORM_MAEMO == 5) || (MOZ_PLATFORM_MAEMO == 6) , NPPVpluginWindowlessLocalBool = 2002 #endif } NPPVariable; @@ -397,11 +420,11 @@ typedef enum { NPNVasdEnabledBool, NPNVisOfflineBool, - NPNVserviceManager = (10 | NP_ABI_MASK), /* Not implemented in WebKit */ - NPNVDOMElement = (11 | NP_ABI_MASK), /* Not implemented in WebKit */ - NPNVDOMWindow = (12 | NP_ABI_MASK), /* Not implemented in WebKit */ - NPNVToolkit = (13 | NP_ABI_MASK), /* Not implemented in WebKit */ - NPNVSupportsXEmbedBool = 14, /* Not implemented in WebKit */ + NPNVserviceManager = (10 | NP_ABI_MASK), + NPNVDOMElement = (11 | NP_ABI_MASK), + NPNVDOMWindow = (12 | NP_ABI_MASK), + NPNVToolkit = (13 | NP_ABI_MASK), + NPNVSupportsXEmbedBool = 14, /* Get the NPObject wrapper for the browser window. */ NPNVWindowNPObject = 15, @@ -411,28 +434,28 @@ typedef enum { NPNVSupportsWindowless = 17, - NPNVprivateModeBool = 18 + NPNVprivateModeBool = 18, + + NPNVsupportsAdvancedKeyHandling = 21 #if defined(XP_MACOSX) /* Used for negotiating drawing models */ , NPNVpluginDrawingModel = 1000 - , NPNVcontentsScaleFactor = 1001 #ifndef NP_NO_QUICKDRAW , NPNVsupportsQuickDrawBool = 2000 #endif , NPNVsupportsCoreGraphicsBool = 2001 , NPNVsupportsOpenGLBool = 2002 , NPNVsupportsCoreAnimationBool = 2003 + , NPNVsupportsInvalidatingCoreAnimationBool = 2004 #ifndef NP_NO_CARBON , NPNVsupportsCarbonBool = 3000 /* TRUE if the browser supports the Carbon event model */ #endif , NPNVsupportsCocoaBool = 3001 /* TRUE if the browser supports the Cocoa event model */ , NPNVsupportsUpdatedCocoaTextInputBool = 3002 /* TRUE if the browser supports the updated Cocoa text input specification. */ - , NPNVsupportsCompositingCoreAnimationPluginsBool = 74656 /* TRUE if the browser supports - CA model compositing */ -#endif /* XP_MACOSX */ -#if defined(MOZ_PLATFORM_MAEMO) && (MOZ_PLATFORM_MAEMO >= 5) +#endif +#if (MOZ_PLATFORM_MAEMO == 5) || (MOZ_PLATFORM_MAEMO == 6) , NPNVSupportsWindowlessLocal = 2002 #endif } NPNVariable; @@ -469,9 +492,9 @@ typedef struct _NPWindow uint32_t width; /* Maximum window size */ uint32_t height; NPRect clipRect; /* Clipping rectangle in port coordinates */ -#if defined(XP_UNIX) || defined(XP_SYMBIAN) - void * ws_info; /* Platform-dependent additonal data */ -#endif /* XP_UNIX || XP_SYMBIAN */ +#if (defined(XP_UNIX) || defined(XP_SYMBIAN)) && !defined(XP_MACOSX) + void * ws_info; /* Platform-dependent additional data */ +#endif /* XP_UNIX */ NPWindowType type; /* Is this a window or a drawable? */ } NPWindow; @@ -518,9 +541,9 @@ typedef struct _NPPrint #if defined(XP_MACOSX) #ifndef NP_NO_CARBON typedef EventRecord NPEvent; -#else -typedef void* NPEvent; #endif +#elif defined(XP_SYMBIAN) +typedef QEvent NPEvent; #elif defined(XP_WIN) typedef struct _NPEvent { @@ -535,7 +558,10 @@ typedef struct _NPEvent uint32_t wParam; uint32_t lParam; } NPEvent; -#elif defined(XP_UNIX) +#elif defined(XP_UNIX) && defined(MOZ_X11) +/* BEGIN GOOGLE MODIFICATIONS */ +typedef union _XEvent XEvent; +/* END GOOGLE MODIFICATIONS */ typedef XEvent NPEvent; #else typedef void* NPEvent; @@ -549,8 +575,13 @@ typedef RgnHandle NPQDRegion; typedef CGPathRef NPCGRegion; #elif defined(XP_WIN) typedef HRGN NPRegion; -#elif defined(XP_UNIX) +#elif defined(XP_UNIX) && defined(MOZ_X11) +/* BEGIN GOOGLE MODIFICATIONS */ +typedef struct _XRegion *Region; +/* END GOOGLE MODIFICATIONS */ typedef Region NPRegion; +#elif defined(XP_SYMBIAN) +typedef QRegion* NPRegion; #else typedef void *NPRegion; #endif @@ -592,11 +623,7 @@ typedef struct NP_Port typedef struct NP_CGContext { CGContextRef context; -#ifdef NP_NO_CARBON - NPNSWindow *window; -#else - void *window; /* A WindowRef or NULL for the Cocoa event model. */ -#endif + void *window; /* A WindowRef under the Carbon event model. */ } NP_CGContext; /* @@ -733,6 +760,8 @@ enum NPEventType { #define NPERR_FILE_NOT_FOUND (NPERR_BASE + 11) #define NPERR_NO_DATA (NPERR_BASE + 12) #define NPERR_STREAM_NOT_SEEKABLE (NPERR_BASE + 13) +#define NPERR_TIME_RANGE_NOT_SUPPORTED (NPERR_BASE + 14) +#define NPERR_MALFORMED_SITE (NPERR_BASE + 15) /* * Values of type NPReason: @@ -755,21 +784,19 @@ enum NPEventType { #define NPVERS_HAS_STREAMOUTPUT 8 #define NPVERS_HAS_NOTIFICATION 9 #define NPVERS_HAS_LIVECONNECT 9 -#define NPVERS_WIN16_HAS_LIVECONNECT 9 #define NPVERS_68K_HAS_LIVECONNECT 11 #define NPVERS_HAS_WINDOWLESS 11 -#define NPVERS_HAS_XPCONNECT_SCRIPTING 13 /* Not implemented in WebKit */ +#define NPVERS_HAS_XPCONNECT_SCRIPTING 13 #define NPVERS_HAS_NPRUNTIME_SCRIPTING 14 -#define NPVERS_HAS_FORM_VALUES 15 /* Not implemented in WebKit; see bug 13061 */ -#define NPVERS_HAS_POPUPS_ENABLED_STATE 16 /* Not implemented in WebKit */ +#define NPVERS_HAS_FORM_VALUES 15 +#define NPVERS_HAS_POPUPS_ENABLED_STATE 16 #define NPVERS_HAS_RESPONSE_HEADERS 17 #define NPVERS_HAS_NPOBJECT_ENUM 18 #define NPVERS_HAS_PLUGIN_THREAD_ASYNC_CALL 19 #define NPVERS_HAS_ALL_NETWORK_STREAMS 20 #define NPVERS_HAS_URL_AND_AUTH_INFO 21 #define NPVERS_HAS_PRIVATE_MODE 22 -#define NPVERS_MACOSX_HAS_EVENT_MODELS 23 -#define NPVERS_HAS_CANCEL_SRC_STREAM 24 +#define NPVERS_MACOSX_HAS_COCOA_EVENTS 23 #define NPVERS_HAS_ADVANCED_KEY_HANDLING 25 #define NPVERS_HAS_URL_REDIRECT_HANDLING 26 #define NPVERS_HAS_CLEAR_SITE_DATA 27 @@ -791,11 +818,9 @@ extern "C" { /* NPP_* functions are provided by the plugin and called by the navigator. */ #if defined(XP_UNIX) -char* NPP_GetMIMEDescription(void); +const char* NPP_GetMIMEDescription(void); #endif -NPError NP_LOADDS NPP_Initialize(void); -void NP_LOADDS NPP_Shutdown(void); NPError NP_LOADDS NPP_New(NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc, char* argn[], char* argv[], NPSavedData* saved); @@ -815,7 +840,6 @@ void NP_LOADDS NPP_Print(NPP instance, NPPrint* platformPrint); int16_t NP_LOADDS NPP_HandleEvent(NPP instance, void* event); void NP_LOADDS NPP_URLNotify(NPP instance, const char* url, NPReason reason, void* notifyData); -jref NP_LOADDS NPP_GetJavaClass(void); NPError NP_LOADDS NPP_GetValue(NPP instance, NPPVariable variable, void *value); NPError NP_LOADDS NPP_SetValue(NPP instance, NPNVariable variable, void *value); NPBool NP_LOADDS NPP_GotFocus(NPP instance, NPFocusDirection direction); @@ -851,8 +875,6 @@ void* NP_LOADDS NPN_MemAlloc(uint32_t size); void NP_LOADDS NPN_MemFree(void* ptr); uint32_t NP_LOADDS NPN_MemFlush(uint32_t size); void NP_LOADDS NPN_ReloadPlugins(NPBool reloadPages); -JRIEnv* NP_LOADDS NPN_GetJavaEnv(void); -jref NP_LOADDS NPN_GetJavaPeer(NPP instance); NPError NP_LOADDS NPN_GetValue(NPP instance, NPNVariable variable, void *value); NPError NP_LOADDS NPN_SetValue(NPP instance, NPPVariable variable, @@ -884,6 +906,9 @@ uint32_t NP_LOADDS NPN_ScheduleTimer(NPP instance, uint32_t interval, NPBool void NP_LOADDS NPN_UnscheduleTimer(NPP instance, uint32_t timerID); NPError NP_LOADDS NPN_PopUpContextMenu(NPP instance, NPMenu* menu); NPBool NP_LOADDS NPN_ConvertPoint(NPP instance, double sourceX, double sourceY, NPCoordinateSpace sourceSpace, double *destX, double *destY, NPCoordinateSpace destSpace); +NPBool NP_LOADDS NPN_HandleEvent(NPP instance, void *event, NPBool handled); +NPBool NP_LOADDS NPN_UnfocusInstance(NPP instance, NPFocusDirection direction); +void NP_LOADDS NPN_URLRedirectResponse(NPP instance, void* notifyData, NPBool allow); #ifdef __cplusplus } /* end extern "C" */ diff --git a/cef/include/internal/npapi/npapi_extensions.h b/cef/include/internal/npapi/npapi_extensions.h new file mode 100755 index 000000000..144417b3e --- /dev/null +++ b/cef/include/internal/npapi/npapi_extensions.h @@ -0,0 +1,1079 @@ +/* Copyright (c) 2006-2009 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. + */ + +#ifndef _NP_EXTENSIONS_H_ +#define _NP_EXTENSIONS_H_ + +// Use the shorter include path here so that this file can be used in non- +// Chromium projects, such as the Native Client SDK. +#include "npapi.h" + +#include // For size_t + +/* + * A fake "enum" value for getting browser-implemented Pepper extensions. + * The variable returns a pointer to an NPNExtensions structure. */ +#define NPNVPepperExtensions ((NPNVariable) 4000) + +/* + * A fake "enum" value for getting plugin-implemented Pepper extensions. + * The variable returns a pointer to an NPPExtensions structure. */ +#define NPPVPepperExtensions ((NPPVariable) 4001) + +typedef void NPDeviceConfig; +typedef void NPDeviceContext; +typedef void NPUserData; + +/* unique id for each device interface */ +typedef int32_t NPDeviceID; + +/* Events -------------------------------------------------------------------*/ + +typedef enum { + NPMouseButton_None = -1, + NPMouseButton_Left = 0, + NPMouseButton_Middle = 1, + NPMouseButton_Right = 2 +} NPMouseButtons; + +typedef enum { + NPEventType_Undefined = -1, + NPEventType_MouseDown = 0, + NPEventType_MouseUp = 1, + NPEventType_MouseMove = 2, + NPEventType_MouseEnter = 3, + NPEventType_MouseLeave = 4, + NPEventType_MouseWheel = 5, + NPEventType_RawKeyDown = 6, + NPEventType_KeyDown = 7, + NPEventType_KeyUp = 8, + NPEventType_Char = 9, + NPEventType_Minimize = 10, + NPEventType_Focus = 11, + NPEventType_Device = 12 +} NPEventTypes; + +typedef enum { + NPEventModifier_ShiftKey = 1 << 0, + NPEventModifier_ControlKey = 1 << 1, + NPEventModifier_AltKey = 1 << 2, + NPEventModifier_MetaKey = 1 << 3, + NPEventModifier_IsKeyPad = 1 << 4, + NPEventModifier_IsAutoRepeat = 1 << 5, + NPEventModifier_LeftButtonDown = 1 << 6, + NPEventModifier_MiddleButtonDown = 1 << 7, + NPEventModifier_RightButtonDown = 1 << 8 +} NPEventModifiers; + +typedef struct _NPKeyEvent +{ + uint32_t modifier; + uint32_t normalizedKeyCode; +} NPKeyEvent; + +typedef struct _NPCharacterEvent +{ + uint32_t modifier; + uint16_t text[4]; + uint16_t unmodifiedText[4]; +} NPCharacterEvent; + +typedef struct _NPMouseEvent +{ + uint32_t modifier; + int32_t button; + int32_t x; + int32_t y; + int32_t clickCount; +} NPMouseEvent; + +typedef struct _NPMouseWheelEvent +{ + uint32_t modifier; + float deltaX; + float deltaY; + float wheelTicksX; + float wheelTicksY; + uint32_t scrollByPage; +} NPMouseWheelEvent; + +typedef struct _NPDeviceEvent { + uint32_t device_uid; + uint32_t subtype; + /* uint8_t generic[0]; */ +} NPDeviceEvent; + +typedef struct _NPMinimizeEvent { + int32_t value; +} NPMinimizeEvent; + +typedef struct _NPFocusEvent { + int32_t value; +} NPFocusEvent; + +typedef struct _NPPepperEvent +{ + uint32_t size; + int32_t type; + double timeStampSeconds; + union { + NPKeyEvent key; + NPCharacterEvent character; + NPMouseEvent mouse; + NPMouseWheelEvent wheel; + NPMinimizeEvent minimize; + NPFocusEvent focus; + NPDeviceEvent device; + } u; +} NPPepperEvent; + +/* 2D -----------------------------------------------------------------------*/ + +#define NPPepper2DDevice 1 + +typedef struct _NPDeviceContext2DConfig { +} NPDeviceContext2DConfig; + +typedef struct _NPDeviceContext2D +{ + /* Internal value used by the browser to identify this device. */ + void* reserved; + + /* A pointer to the pixel data. This data is 8-bit values in BGRA order in + * memory. Each row will start |stride| bytes after the previous one. + * + * THIS DATA USES PREMULTIPLIED ALPHA. This means that each color channel has + * been multiplied with the corresponding alpha, which makes compositing + * easier. If any color channels have a value greater than the alpha value, + * you'll likely get crazy colors and weird artifacts. */ + void* region; + + /* Length of each row of pixels in bytes. This may be larger than width * 4 + * if there is padding at the end of each row to help with alignment. */ + int32_t stride; + + /* The dirty region that the plugin has painted into the buffer. This + * will be initialized to the size of the plugin image in + * initializeContextPtr. The plugin can change the values to only + * update portions of the image. */ + struct { + int32_t left; + int32_t top; + int32_t right; + int32_t bottom; + } dirty; +} NPDeviceContext2D; + +typedef struct _NPDeviceBuffer { + void* ptr; + size_t size; +} NPDeviceBuffer; + +/* completion callback for flush device */ +typedef void (*NPDeviceFlushContextCallbackPtr)( + NPP instance, + NPDeviceContext* context, + NPError err, + NPUserData* userData); + +/* query single capabilities of device */ +typedef NPError ( + *NPDeviceQueryCapabilityPtr)(NPP instance, + int32_t capability, + int32_t *value); +/* query config (configuration == a set of capabilities) */ +typedef NPError ( + *NPDeviceQueryConfigPtr)(NPP instance, + const NPDeviceConfig* request, + NPDeviceConfig* obtain); +/* device initialization */ +typedef NPError (*NPDeviceInitializeContextPtr)( + NPP instance, + const NPDeviceConfig* config, + NPDeviceContext* context); +/* peek at device state */ +typedef NPError (*NPDeviceGetStateContextPtr) ( + NPP instance, + NPDeviceContext* context, + int32_t state, + intptr_t* value); +/* poke device state */ +typedef NPError (*NPDeviceSetStateContextPtr) ( + NPP instance, + NPDeviceContext* context, + int32_t state, + intptr_t value); +/* flush context, if callback, userData are NULL */ +/* this becomes a blocking call */ +typedef NPError (*NPDeviceFlushContextPtr)( + NPP instance, + NPDeviceContext* context, + NPDeviceFlushContextCallbackPtr callback, + void* userData); +/* destroy device context. Application responsible for */ +/* freeing context, if applicable */ +typedef NPError (*NPDeviceDestroyContextPtr)( + NPP instance, + NPDeviceContext* context); +/* Create a buffer associated with a particular context. The usage of the */ +/* buffer is device specific. The lifetime of the buffer is scoped with the */ +/* lifetime of the context. */ +typedef NPError (*NPDeviceCreateBufferPtr)( + NPP instance, + NPDeviceContext* context, + size_t size, + int32_t* id); +/* Destroy a buffer associated with a particular context. */ +typedef NPError (*NPDeviceDestroyBufferPtr)( + NPP instance, + NPDeviceContext* context, + int32_t id); +/* Map a buffer id to its address. */ +typedef NPError (*NPDeviceMapBufferPtr)( + NPP instance, + NPDeviceContext* context, + int32_t id, + NPDeviceBuffer* buffer); + + +/* forward decl typdef structs */ +typedef struct NPDevice NPDevice; +typedef struct NPNExtensions NPNExtensions; + +// DEPRECATED: this typedef is just for the NaCl code until they switch to NPNExtensions. +// PLEASE REMOVE THIS WHEN THE NACL CODE IS UPDATED. +typedef struct NPNExtensions NPExtensions; + + +/* New experimental device API. */ + +/* Mode for calls to NPDeviceSynchronizeContext. */ +typedef enum { + /* Get or set locally cached state without synchronizing or communicating */ + /* with the service process (or thread). */ + NPDeviceSynchronizationMode_Cached, + + /* Exchanges state with service process (or thread). Does not wait for any */ + /* progress before returning. */ + NPDeviceSynchronizationMode_Immediate, + + /* Exchanges state with service process (or thread). Blocks caller until */ + /* further progress can be made. */ + NPDeviceSynchronizationMode_Flush +} NPDeviceSynchronizationMode; + +/* Get the number of configs supported by a given device. */ +typedef NPError (*NPDeviceGetNumConfigsPtr)(NPP instance, + int32_t* numConfigs); + +/* Get attribute values from a config. NPDeviceGetConfigs might return */ +/* multiple configs. This function can be used to examine them to */ +/* find the most suitable. For example, NPDeviceGetConfigs might return one */ +/* config with antialiasing enabled and one without. This can be determined */ +/* using this function. */ +/* Inputs: */ +/* config: The config index to extract the attributes from. */ +/* attribList: Array of input config attribute / value pairs */ +/* terminated with NPAttrib_End. */ +/* Outputs: */ +/* attribList: The values paired up with each attribute are filled in */ +/* on return. */ +typedef NPError (*NPDeviceGetConfigAttribsPtr)(NPP instance, + int32_t config, + int32_t* attribList); + +/* Create a device context based on a particular device configuration and a */ +/* list config input attributes. */ +/* Inputs: */ +/* config: The device configuration to use. */ +/* attribList: NULL or an array of context specific attribute / value */ +/* pairs terminated with NPAttrib_End. */ +/* Outputs: */ +/* context: The created context. */ +typedef NPError (*NPDeviceCreateContextPtr)(NPP instance, + int32_t config, + const int32_t* attribList, + NPDeviceContext** context); + +/* Destroy a context. */ +/* Inputs: */ +/* context: The context to destroy. */ +/*typedef NPError (*NPDestroyContext)(NPP instance, */ +/* NPDeviceContext* context); */ + +/* This type should be cast to the type associated with the particular */ +/* callback type */ +typedef void (*NPDeviceGenericCallbackPtr)(void); + +/* Register a callback with a context. Callbacks are never invoked after the */ +/* associated context has been destroyed. The semantics of the particular */ +/* callback type determine which thread the callback is invoked on. It might */ +/* be the plugin thread, the thread RegisterCallback is invoked on or a */ +/* special thread created for servicing callbacks, such as an audio thread */ +/* Inputs: */ +/* callbackType: The device specific callback type */ +/* callback: The callback to invoke. The signature varies by type. Use */ +/* NULL to unregister the callback for a particular type. */ +/* callbackData: A value that is passed to the callback function. Other */ +/* callback arguments vary by type. */ +typedef NPError (*NPDeviceRegisterCallbackPtr)( + NPP instance, + NPDeviceContext* context, + int32_t callbackType, + NPDeviceGenericCallbackPtr callback, + void* callbackData); + +/* Callback for NPDeviceSynchronizeContext. */ +/* Inputs: */ +/* instance: The associated plugin instance. */ +/* context: The context that was flushed. */ +/* error: Indicates success of flush operation. */ +/* data: The completion callback data that was passed to */ +/* NPDeviceSynchronizeContext. */ +typedef void (*NPDeviceSynchronizeContextCallbackPtr)( + NPP instance, + NPDeviceContext* context, + NPError error, + void* data); + +/* Synchronize the state of a device context. Takes lists of input and output */ +/* attributes. Generally, the input attributes are copied into the context */ +/* and the output attributes are filled in the state of the context either */ +/* after (before) the synchronization depending on whether it is synchronous */ +/* (asynchronous). The get the state of the context after an asynchronous */ +/* synchronization, call this function a second time with Cached mode after */ +/* the callback has been invoked. */ +/* Inputs: */ +/* context: The context to synchronize. */ +/* mode: The type of synchronization to perform. */ +/* inputAttribList: NULL or an array of input synchronization attribute / */ +/* value pairs terminated with NPAttrib_End. */ +/* outputAttribList: NULL or an array of output synchronization */ +/* attributes / uninitialized value pairs terminated */ +/* with NPAttrib_End. */ +/* callback: NULL for synchronous operation or completion callback function */ +/* for asynchronous operation. */ +/* callbackData: Argument passed to callback function. */ +/* Outputs: */ +/* outputAttribList: The values paired up with each attribute are filled */ +/* in on return for synchronous operation. */ +typedef NPError (*NPDeviceSynchronizeContextPtr)( + NPP instance, + NPDeviceContext* context, + NPDeviceSynchronizationMode mode, + const int32_t* inputAttribList, + int32_t* outputAttribList, + NPDeviceSynchronizeContextCallbackPtr callback, + void* callbackData); + +/* All attributes shared between devices, with the exception of */ +/* NPDeviceContextAttrib_End, have bit 31 set. Device specific attributes */ +/* have the bit clear. */ +enum { + /* Used to terminate arrays of attribute / value pairs. */ + NPAttrib_End = 0, + + /* Error status of context. Non-zero means error. Shared by all devices, */ + /* though error values are device specific. */ + NPAttrib_Error = 0x80000000 +}; + +/* generic device interface */ +struct NPDevice { + NPDeviceQueryCapabilityPtr queryCapability; + NPDeviceQueryConfigPtr queryConfig; + NPDeviceInitializeContextPtr initializeContext; + NPDeviceSetStateContextPtr setStateContext; + NPDeviceGetStateContextPtr getStateContext; + NPDeviceFlushContextPtr flushContext; + NPDeviceDestroyContextPtr destroyContext; + NPDeviceCreateBufferPtr createBuffer; + NPDeviceDestroyBufferPtr destroyBuffer; + NPDeviceMapBufferPtr mapBuffer; + + /* Experimental device API */ + NPDeviceGetNumConfigsPtr getNumConfigs; + NPDeviceGetConfigAttribsPtr getConfigAttribs; + NPDeviceCreateContextPtr createContext; +/* NPDeviceDestroyContextPtr destroyContext; */ + NPDeviceRegisterCallbackPtr registerCallback; + NPDeviceSynchronizeContextPtr synchronizeContext; +/* NPDeviceCreateBufferPtr createBuffer; */ +/* NPDeviceDestroyBufferPtr destroyBuffer; */ +/* NPDeviceMapBufferPtr mapBuffer; */ +}; + +/* returns NULL if deviceID unavailable / unrecognized */ +typedef NPDevice* (*NPAcquireDevicePtr)( + NPP instance, + NPDeviceID device); + +/* Updates the number of find results for the current search term. If + * there are no matches 0 should be passed in. Only when the plugin has + * finished searching should it pass in the final count with finalResult set to + * true. */ +typedef void (*NPNumberOfFindResultsChangedPtr)( + NPP instance, + int total, + bool finalResult); + + /* Updates the index of the currently selected search item. */ +typedef void (*NPSelectedFindResultChangedPtr)( + NPP instance, + int index); + +/* Theming -----------------------------------------------------------------*/ +typedef int32_t NPWidgetID; + +typedef enum { + NPWidgetTypeScrollbar = 0 +} NPWidgetType; + +typedef struct _NPScrollbarCreateParams { + bool vertical; +} NPScrollbarCreateParams; + +typedef struct _NPRect32 +{ + uint32_t top; + uint32_t left; + uint32_t bottom; + uint32_t right; +} NPRect32; + +typedef struct _NPScrollbarTickMarks { + uint32_t count; + NPRect32* tickmarks; +} NPScrollbarTickMarks; + +typedef enum { + NPWidgetPropertyLocation = 0, // variable is NPRect*. + NPWidgetPropertyDirtyRect = 1, // Get only. variable is NPRec*. + NPWidgetPropertyScrollbarThickness = 2, // Get only. variable is int32_t*. + NPWidgetPropertyScrollbarValue = 3, // variable is int32_t*. + NPWidgetPropertyScrollbarDocumentSize = 4, // Set only. variable is int32_t*. + // Set only. variable is NPScrollbarTickMarks*. + NPWidgetPropertyScrollbarTickMarks = 5, + // Set only. variable is bool* (true for forward, false for backward). + NPWidgetPropertyScrollbarScrollByLine = 6, + // Set only. variable is bool* (true for forward, false for backward). + NPWidgetPropertyScrollbarScrollByPage = 7, + // Set only. variable is bool* (true for forward, false for backward). + NPWidgetPropertyScrollbarScrollByDocument = 8, + // Set only. variable is int32_t* (positive forward, negative backward). + NPWidgetPropertyScrollbarScrollByPixels = 9 +} NPWidgetProperty; + +// Creates a widget. If it returns NPERR_NO_ERROR then id will contain a unique +// identifer for the widget that's used for the next functions. +typedef NPError (*NPCreateWidgetPtr) ( + NPP instance, + NPWidgetType type, + void* params, // Widget specific. + NPWidgetID* id); + +// Destroys a widget. +typedef NPError (*NPDestroyWidgetPtr) ( + NPP instance, + NPWidgetID id); + +// Paint the dirty rectangle of the given widget into context. +typedef NPError (*NPPaintWidgetPtr) ( + NPP instance, + NPWidgetID id, + NPDeviceContext2D* context, + NPRect* dirty); + +// Pass in a pepper event to a plugin. It'll return true iff it uses it. +typedef bool (*NPHandleWidgetEventPtr) ( + NPP instance, + NPWidgetID id, + NPPepperEvent* event); + +// Gets a property of the widget. "value" varies depending on the variable. +typedef NPError (*NPGetWidgetPropertyPtr) ( + NPP instance, + NPWidgetID id, + NPWidgetProperty property, + void* value); + +// Sets a property of the widget. +typedef NPError (*NPSetWidgetPropertyPtr) ( + NPP instance, + NPWidgetID id, + NPWidgetProperty property, + void* value); + +typedef struct _NPWidgetExtensions { + NPCreateWidgetPtr createWidget; + NPDestroyWidgetPtr destroyWidget; + NPPaintWidgetPtr paintWidget; + NPHandleWidgetEventPtr handleWidgetEvent; + NPGetWidgetPropertyPtr getWidgetProperty; + NPSetWidgetPropertyPtr setWidgetProperty; +} NPWidgetExtensions; + +typedef NPWidgetExtensions* (*NPGetWidgetExtensionsPtr)( + NPP instance); + + +/* Supports opening files anywhere on the system after prompting the user to + * pick one. + * + * This API is asynchronous. It will return immediately and the user will be + * prompted in parallel to pick a file. The plugin may continue to receive + * events while the open file dialog is up, and may continue to paint. Plugins + * may want to ignore input events between the call and the callback to avoid + * reentrant behavior. If the return value is not NPERR_NO_ERROR, the callback + * will NOT be executed. + * + * It is an error to call BrowseForFile before a previous call has executed + * the callback. + * + * Setting the flags to "Open" requires that the file exist to allow picking. + * Setting the flags to "Save" allows selecting nonexistant files (which will + * then be created), and will prompt the user if they want to overwrite an + * existing file if it exists. + * + * The plugin may specify a comma-separated list of possible mime types in + * the "extensions" parameter. If no extensions are specified, the dialog box + * will default to allowing all extensions. The first extension in the list + * will be the default. + * + * TODO(brettw) On Windows the extensions traditionally include a text + * description with the extension in the popup, do we want to allow this? + * We should probably also allow the ability to put "All files" in the + * list on Windows. + * + * Once the user has picked a file or has canceled the dialog box, the given + * callback will be called with the results of the operation and the passed in + * "user data" pointer. If the user successfully picked a file, the filename + * will be non-NULL and will contain a pointer to an array of strings, one for + * each file picked (the first file will be file_paths[0]). This buffer will + * become invalid as soon as the call completes, so it is the plugin's + * responsibility to copy the filename(sp if it needs future access to them. + * A NULL file_paths in the callback means the user canceled the dialog box. + * + * The filename will be in UTF-8. It may not actually correspond to the actual + * file on disk on a Linux system, because we'll do our best to convert it from + * the filesystem's locale to UTF-8. Instead, the string will be appropriate for + * displaying to the user which file they picked. + * */ +typedef enum { + NPChooseFile_Open = 1, + NPChooseFile_OpenMultiple = 2, + NPChooseFile_Save = 3 +} NPChooseFileMode; +typedef void (*NPChooseFileCallback)(const char** filePaths, + uint32_t pathCount, + void* userData); +typedef NPError (*NPChooseFilePtr)( + NPP instance, + const char* mimeTypes, + NPChooseFileMode mode, + NPChooseFileCallback callback, + void* userData); + +typedef enum { + NPCursorTypePointer = 0, + NPCursorTypeCross = 1, + NPCursorTypeHand = 2, + NPCursorTypeIBeam = 3, + NPCursorTypeWait = 4, + NPCursorTypeHelp = 5, + NPCursorTypeEastResize = 6, + NPCursorTypeNorthResize = 7, + NPCursorTypeNorthEastResize = 8, + NPCursorTypeNorthWestResize = 9, + NPCursorTypeSouthResize = 10, + NPCursorTypeSouthEastResize = 11, + NPCursorTypeSouthWestResize = 12, + NPCursorTypeWestResize = 13, + NPCursorTypeNorthSouthResize = 14, + NPCursorTypeEastWestResize = 15, + NPCursorTypeNorthEastSouthWestResize = 16, + NPCursorTypeNorthWestSouthEastResize = 17, + NPCursorTypeColumnResize = 18, + NPCursorTypeRowResize = 19, + NPCursorTypeMiddlePanning = 20, + NPCursorTypeEastPanning = 21, + NPCursorTypeNorthPanning = 22, + NPCursorTypeNorthEastPanning = 23, + NPCursorTypeNorthWestPanning = 24, + NPCursorTypeSouthPanning = 25, + NPCursorTypeSouthEastPanning = 26, + NPCursorTypeSouthWestPanning = 27, + NPCursorTypeWestPanning = 28, + NPCursorTypeMove = 29, + NPCursorTypeVerticalText = 30, + NPCursorTypeCell = 31, + NPCursorTypeContextMenu = 32, + NPCursorTypeAlias = 33, + NPCursorTypeProgress = 34, + NPCursorTypeNoDrop = 35, + NPCursorTypeCopy = 36, + NPCursorTypeNone = 37, + NPCursorTypeNotAllowed = 38, + NPCursorTypeZoomIn = 39, + NPCursorTypeZoomOut = 40 +} NPCursorType; + +// Temporary SetCursor API. +typedef NPError (*NPSetCursorPtr)( + NPP instance, + NPCursorType type); + +/* unique id for each font */ +typedef int NPFontID; + +typedef enum { + NPCharsetAnsi = 0, + NPCharsetDefault = 1, + NPCharsetSymbol = 2, + NPCharsetMac = 77, + NPCharsetShiftJIS = 128, + NPCharsetHangul = 129, + NPCharsetJohab = 130, + NPCharsetGB2312 =134, + NPCharsetChineseBIG5 = 136, + NPCharsetGreek = 161, + NPCharsetTurkish = 162, + NPCharsetVietnamese = 163, + NPCharsetHebrew = 177, + NPCharsetArabic = 178, + NPCharsetBaltic = 186, + NPCharsetRussian = 204, + NPCharsetThai = 222, + NPCharsetEastEurope = 238, + NPCharsetOEM = 255 +} NPCharset; + +typedef enum { + NPPitchDefault, + NPPitchFixed +} NPPitch; + +typedef enum { + NPFamilyDefault, + NPFamilyRoman, + NPFamilyScript +} NPFamily; + +typedef struct _NPFontDescription { + const char* face; + int weight; + bool italic; + NPPitch pitch; + NPFamily family; + NPCharset charset; +} NPFontDescription; + +// Return a font which best matches the given properties. +typedef NPError (*NPMatchFontWithFallbackPtr) ( + NPP instance, + const NPFontDescription* description, + NPFontID* id); + +// Loads a specified font table for the given font. +// table: the table in *big-endian* format, or 0 for the whole font file. +// output: a buffer of size output_length that gets the data. can be 0, in +// which case output_length will be set to the required size in bytes. +// output_length: size of output, if it's not 0. +typedef NPError (*GetFontTablePtr) ( + NPP instance, + NPFontID id, + uint32_t table, + void* output, + size_t* output_length); + +// Destroys a font. +typedef NPError (*NPDestroyFontPtr) ( + NPP instance, + NPFontID id); + +typedef struct _NPFontExtensions { + NPMatchFontWithFallbackPtr matchFontWithFallback; + GetFontTablePtr getFontTable; + NPDestroyFontPtr destroyFont; +} NPFontExtensions; + +typedef NPFontExtensions* (*NPGetFontExtensionsPtr)( + NPP instance); + +/* Pepper extensions */ +struct NPNExtensions { + /* Device interface acquisition */ + NPAcquireDevicePtr acquireDevice; + /* Find */ + NPNumberOfFindResultsChangedPtr numberOfFindResultsChanged; + NPSelectedFindResultChangedPtr selectedFindResultChanged; + /* File I/O extensions */ + NPChooseFilePtr chooseFile; + /* Widget */ + NPGetWidgetExtensionsPtr getWidgetExtensions; + /* Cursor */ + NPSetCursorPtr setCursor; + /* Font */ + NPGetFontExtensionsPtr getFontExtensions; +}; + +/* 3D -----------------------------------------------------------------------*/ + +#define NPPepper3DDevice 2 + +typedef struct _NPDeviceContext3DConfig { + int32_t commandBufferSize; +} NPDeviceContext3DConfig; + +typedef enum _NPDeviceContext3DError { + // No error has ocurred. + NPDeviceContext3DError_NoError, + + // The size of a command was invalid. + NPDeviceContext3DError_InvalidSize, + + // An offset was out of bounds. + NPDeviceContext3DError_OutOfBounds, + + // A command was not recognized. + NPDeviceContext3DError_UnknownCommand, + + // The arguments to a command were invalid. + NPDeviceContext3DError_InvalidArguments, + + // The 3D context was lost, for example due to a power management event. The + // context must be destroyed and a new one created. + NPDeviceContext3DError_LostContext, + + // Any other error. + NPDeviceContext3DError_GenericError +} NPDeviceContext3DError; + +typedef struct _NPDeviceContext3D NPDeviceContext3D; + +typedef void (*NPDeviceContext3DRepaintPtr)(NPP npp, + NPDeviceContext3D* context); + +// TODO(apatrick): this need not be exposed when we switch over to the new +// device API. It's layout can also be implementation dependent. +typedef struct _NPDeviceContext3D +{ + void* reserved; + + // If true, then a flush will only complete once the get offset has advanced + // on the GPU thread. If false, then the get offset might have changed but + // the GPU thread will respond as quickly as possible without guaranteeing + // having made any progress in executing pending commands. Set to true + // to ensure that progress is made or when flushing in a loop waiting for the + // GPU to reach a certain state, for example in advancing beyond a particular + // token. Set to false when flushing to query the current state, for example + // whether an error has occurred. + bool waitForProgress; + + // Buffer in which commands are stored. + void* commandBuffer; + int32_t commandBufferSize; + + // Offset in command buffer reader has reached. Synchronized on flush. + int32_t getOffset; + + // Offset in command buffer writer has reached. Synchronized on flush. + int32_t putOffset; + + // Last processed token. Synchronized on flush. + int32_t token; + + // Callback invoked on the main thread when the context must be repainted. + // TODO(apatrick): move this out of the context struct like the rest of the + // fields. + NPDeviceContext3DRepaintPtr repaintCallback; + + // Error status. Synchronized on flush. + NPDeviceContext3DError error; +} NPDeviceContext3D; + + +/* Begin 3D specific portion of experimental device API */ + +/* Device buffer ID reserved for command buffer */ +enum { + NP3DCommandBufferId = 0 +}; + +/* 3D attributes */ +enum { + /* Example GetConfigAttribs attributes. See EGL 1.4 spec. */ + /* These may be passed to GetConfigAttribs. */ + NP3DAttrib_BufferSize = 0x3020, + NP3DAttrib_AlphaSize = 0x3021, + NP3DAttrib_BlueSize = 0x3022, + NP3DAttrib_GreenSize = 0x3023, + NP3DAttrib_RedSize = 0x3024, + NP3DAttrib_DepthSize = 0x3025, + NP3DAttrib_StencilSize = 0x3026, + NP3DAttrib_SurfaceType = 0x3033, + + /* Example CreateContext attributes. See EGL 1.4 spec. */ + /* These may be passed to CreateContext. */ + NP3DAttrib_SwapBehavior = 0x3093, + NP3DAttrib_MultisampleResolve = 0x3099, + + /* Size of command buffer in 32-bit entries. */ + /* This may be passed to CreateContext as an input or SynchronizeContext as */ + /* an output. */ + NP3DAttrib_CommandBufferSize = 0x10000000, + + /* These may be passed to SynchronizeContext. */ + + /* Offset in command buffer writer has reached. In / out.*/ + NP3DAttrib_PutOffset, + + /* Offset in command buffer reader has reached. Out only. */ + NP3DAttrib_GetOffset, + + /* Last processed token. Out only. */ + NP3DAttrib_Token +}; + +/* 3D callbacks */ +enum { + /* This callback is invoked whenever the plugin must repaint everything. */ + /* This might be because the window manager must repaint a window or */ + /* the context has been lost, for example a power management event. */ + NP3DCallback_Repaint = 1 +}; + +/* Flags for NPConfig3DOutAttrib_SurfaceType */ +enum { + NP3DSurfaceType_MultisampleResolveBox = 0x0200, + NP3DSurfaceType_SwapBehaviorPreserved = 0x0400 +}; + +/* Values for NPConfig3DInAttrib_SwapBehavior */ +enum { + NP3DSwapBehavior_Preserved = 0x3094, + NP3DSwapBehavior_Destroyed = 0x3095 +}; + +/* Values for NPConfig3DInAttrib_MultisampleResolve */ +enum { + NP3DMultisampleResolve_Default = 0x309A, + NP3DMultisampleResolve_Box = 0x309B +}; + +/* End 3D specific API */ + +/* Audio --------------------------------------------------------------------*/ + +#define NPPepperAudioDevice 3 + +/* min & max sample frame count */ +typedef enum { + NPAudioMinSampleFrameCount = 64, + NPAudioMaxSampleFrameCount = 32768 +} NPAudioSampleFrameCounts; + +/* supported sample rates */ +typedef enum { + NPAudioSampleRate44100Hz = 44100, + NPAudioSampleRate48000Hz = 48000, + NPAudioSampleRate96000Hz = 96000 +} NPAudioSampleRates; + +/* supported sample formats */ +typedef enum { + NPAudioSampleTypeInt16 = 0, + NPAudioSampleTypeFloat32 = 1 +} NPAudioSampleTypes; + +/* supported channel layouts */ +/* there is code that depends on these being the actual number of channels */ +typedef enum { + NPAudioChannelNone = 0, + NPAudioChannelMono = 1, + NPAudioChannelStereo = 2, + NPAudioChannelThree = 3, + NPAudioChannelFour = 4, + NPAudioChannelFive = 5, + NPAudioChannelFiveOne = 6, + NPAudioChannelSeven = 7, + NPAudioChannelSevenOne = 8 +} NPAudioChannels; + +/* audio context states */ +typedef enum { + NPAudioContextStateCallback = 0, + NPAudioContextStateUnderrunCounter = 1 +} NPAudioContextStates; + +/* audio context state values */ +typedef enum { + NPAudioCallbackStop = 0, + NPAudioCallbackStart = 1 +} NPAudioContextStateValues; + +/* audio query capabilities */ +typedef enum { + NPAudioCapabilitySampleRate = 0, + NPAudioCapabilitySampleType = 1, + NPAudioCapabilitySampleFrameCount = 2, + NPAudioCapabilitySampleFrameCount44100Hz = 3, + NPAudioCapabilitySampleFrameCount48000Hz = 4, + NPAudioCapabilitySampleFrameCount96000Hz = 5, + NPAudioCapabilityOutputChannelMap = 6, + NPAudioCapabilityInputChannelMap = 7 +} NPAudioCapabilities; + +typedef struct _NPDeviceContextAudio NPDeviceContextAudio; + +/* user supplied callback function */ +typedef void (*NPAudioCallback)(NPDeviceContextAudio *context); + +typedef struct _NPDeviceContextAudioConfig { + int32_t sampleRate; + int32_t sampleType; + int32_t outputChannelMap; + int32_t inputChannelMap; + int32_t sampleFrameCount; + uint32_t startThread; + uint32_t flags; + NPAudioCallback callback; + void *userData; +} NPDeviceContextAudioConfig; + +struct _NPDeviceContextAudio { + NPDeviceContextAudioConfig config; + void *outBuffer; + void *inBuffer; + void *reserved; +}; + +/* Printing related APIs ---------------------------------------------------*/ + +/* Defines a contiguous range of pages to be printed. Page numbers use a + * zero-based index. */ +typedef struct _NPPrintPageNumberRange { + int32_t firstPageNumber; + int32_t lastPageNumber; +} NPPrintPageNumberRange; + +/* Being a print operation. Returns the total number of pages to print at the + * given printableArea size and DPI. printableArea is in points (a point is 1/72 + * of an inch). The plugin is expected to remember the values of printableArea + * and printerDPI for use in subsequent print interface calls. These values + * should be cleared in printEnd. */ +typedef NPError (*NPPPrintBeginPtr) ( + NPP instance, + NPRect* printableArea, + int32_t printerDPI, + int32_t* numPages); +/* Returns the required raster dimensions for the given page. */ +typedef NPError (*NPPGetRasterDimensionsPtr) ( + NPP instance, + int32_t pageNumber, + int32_t* widthInPixels, + int32_t* heightInPixels); +/* Prints the specified page This allows the plugin to print a raster output. */ +typedef NPError (*NPPPrintPageRasterPtr) ( + NPP instance, + int32_t pageNumber, + NPDeviceContext2D* printSurface); +/* Ends the print operation */ +typedef NPError (*NPPPrintEndPtr) (NPP instance); +/* Prints the specified pages as PDF. The plugin allocates the output buffer + * pointed to by pdf_output using the browser-supplied NPN_MemAlloc function. + * The caller is expected to free the output buffer upon success.*/ +typedef NPError (*NPPrintPagesAsPDFPtr)(NPP instance, + NPPrintPageNumberRange* page_ranges, + int32_t page_range_count, + unsigned char** pdf_output, + int32_t* output_size); + + +/* TODO(sanjeevr) : Provide a vector interface for printing. We need to decide + * on a vector format that can support embedded fonts. A vector format will + * greatly reduce the size of the required output buffer. */ + +typedef struct _NPPPrintExtensions { + NPPPrintBeginPtr printBegin; + NPPGetRasterDimensionsPtr getRasterDimensions; + NPPPrintPageRasterPtr printPageRaster; + NPPPrintEndPtr printEnd; + NPPrintPagesAsPDFPtr printPagesAsPDF; +} NPPPrintExtensions; + +/* Returns NULL if the plugin does not support print extensions */ +typedef NPPPrintExtensions* (*NPPGetPrintExtensionsPtr)(NPP instance); + +/* Find ---------------------------------------------------------------------*/ + +/* Finds the given UTF-8 text starting at the current selection. The number of + * results will be updated asynchronously via numberOfFindResultsChanged. Note + * that multiple StartFind calls can happen before StopFind is called in the + * case of the search term changing. */ +typedef NPError (*NPPStartFindPtr) ( + NPP instance, + const char* text, + bool caseSensitive); + +/* Go to the next/previous result. */ +typedef NPError (*NPPSelectFindResultPtr) ( + NPP instance, + bool forward); + +/* Tells the plugin that the find operation has stopped, so it should clear + * any highlighting. */ +typedef NPError (*NPPStopFindPtr) ( + NPP instance); + +typedef struct _NPPFindExtensions { + NPPStartFindPtr startFind; + NPPSelectFindResultPtr selectFindResult; + NPPStopFindPtr stopFind; +} NPPFindExtensions; + +/* Returns NULL if the plugin does not support find extensions. */ +typedef NPPFindExtensions* (*NPPGetFindExtensionsPtr)(NPP instance); + +/* Zooms a plugin to the given factor. If text_only is true, then only the text + * should be zoomed. */ +typedef NPError (*NPPZoomPtr) ( + NPP instance, + float factor, + bool text_only); + +typedef NPError (*NPPWidgetPropertyChangedPtr) ( + NPP instance, + NPWidgetID id, + NPWidgetProperty property); + +/* type of selection */ +typedef enum { + NPSelectionTypeAny = 0, + NPSelectionTypePlainText = 1, + NPSelectionTypeHTML = 2 +} NPSelectionType; + +/* Gets the selection. NPERR_GENERIC_ERROR is returned if nothing is selected. + * 'type' is both an input and output parameter. The caller can request a + * specific type, and if the plugin can't provide it, it will return + * NPERR_GENERIC_ERROR. Or the caller can specify NPSelectionTypeAny to let the + * plugin pick the best format for the data. The result is returned in a buffer + * that's owned by the caller and which is allocated using NPN_MemAlloc. If no + * data is available, NPERR_GENERIC_ERROR is returned. */ +typedef NPError (*NPPGetSelectionPtr) ( + NPP instance, + NPSelectionType* type, + void** data); + +typedef struct _NPPExtensions { + NPPGetPrintExtensionsPtr getPrintExtensions; + NPPGetFindExtensionsPtr getFindExtensions; + NPPZoomPtr zoom; + NPPWidgetPropertyChangedPtr widgetPropertyChanged; + NPPGetSelectionPtr getSelection; +} NPPExtensions; + +#endif /* _NP_EXTENSIONS_H_ */ diff --git a/cef/include/internal/npapi/npfunctions.h b/cef/include/internal/npapi/npfunctions.h new file mode 100755 index 000000000..9f9188512 --- /dev/null +++ b/cef/include/internal/npapi/npfunctions.h @@ -0,0 +1,239 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#ifndef npfunctions_h_ +#define npfunctions_h_ + +#ifdef __OS2__ +#pragma pack(1) +#define NP_LOADDS _System +#else +#define NP_LOADDS +#endif + +#include "npapi.h" +#include "npruntime.h" + +typedef NPError (* NP_LOADDS NPP_NewProcPtr)(NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc, char* argn[], char* argv[], NPSavedData* saved); +typedef NPError (* NP_LOADDS NPP_DestroyProcPtr)(NPP instance, NPSavedData** save); +typedef NPError (* NP_LOADDS NPP_SetWindowProcPtr)(NPP instance, NPWindow* window); +typedef NPError (* NP_LOADDS NPP_NewStreamProcPtr)(NPP instance, NPMIMEType type, NPStream* stream, NPBool seekable, uint16_t* stype); +typedef NPError (* NP_LOADDS NPP_DestroyStreamProcPtr)(NPP instance, NPStream* stream, NPReason reason); +typedef int32_t (* NP_LOADDS NPP_WriteReadyProcPtr)(NPP instance, NPStream* stream); +typedef int32_t (* NP_LOADDS NPP_WriteProcPtr)(NPP instance, NPStream* stream, int32_t offset, int32_t len, void* buffer); +typedef void (* NP_LOADDS NPP_StreamAsFileProcPtr)(NPP instance, NPStream* stream, const char* fname); +typedef void (* NP_LOADDS NPP_PrintProcPtr)(NPP instance, NPPrint* platformPrint); +typedef int16_t (* NP_LOADDS NPP_HandleEventProcPtr)(NPP instance, void* event); +typedef void (* NP_LOADDS NPP_URLNotifyProcPtr)(NPP instance, const char* url, NPReason reason, void* notifyData); +/* Any NPObjects returned to the browser via NPP_GetValue should be retained + by the plugin on the way out. The browser is responsible for releasing. */ +typedef NPError (* NP_LOADDS NPP_GetValueProcPtr)(NPP instance, NPPVariable variable, void *ret_value); +typedef NPError (* NP_LOADDS NPP_SetValueProcPtr)(NPP instance, NPNVariable variable, void *value); +typedef NPBool (* NP_LOADDS NPP_GotFocusPtr)(NPP instance, NPFocusDirection direction); +typedef void (* NP_LOADDS NPP_LostFocusPtr)(NPP instance); +typedef void (* NP_LOADDS NPP_URLRedirectNotifyPtr)(NPP instance, const char* url, int32_t status, void* notifyData); +typedef NPError (* NP_LOADDS NPP_ClearSiteDataPtr)(const char* site, uint64_t flags, uint64_t maxAge); +typedef char** (* NP_LOADDS NPP_GetSitesWithDataPtr)(void); + +typedef NPError (*NPN_GetValueProcPtr)(NPP instance, NPNVariable variable, void *ret_value); +typedef NPError (*NPN_SetValueProcPtr)(NPP instance, NPPVariable variable, void *value); +typedef NPError (*NPN_GetURLNotifyProcPtr)(NPP instance, const char* url, const char* window, void* notifyData); +typedef NPError (*NPN_PostURLNotifyProcPtr)(NPP instance, const char* url, const char* window, uint32_t len, const char* buf, NPBool file, void* notifyData); +typedef NPError (*NPN_GetURLProcPtr)(NPP instance, const char* url, const char* window); +typedef NPError (*NPN_PostURLProcPtr)(NPP instance, const char* url, const char* window, uint32_t len, const char* buf, NPBool file); +typedef NPError (*NPN_RequestReadProcPtr)(NPStream* stream, NPByteRange* rangeList); +typedef NPError (*NPN_NewStreamProcPtr)(NPP instance, NPMIMEType type, const char* window, NPStream** stream); +typedef int32_t (*NPN_WriteProcPtr)(NPP instance, NPStream* stream, int32_t len, void* buffer); +typedef NPError (*NPN_DestroyStreamProcPtr)(NPP instance, NPStream* stream, NPReason reason); +typedef void (*NPN_StatusProcPtr)(NPP instance, const char* message); +/* Browser manages the lifetime of the buffer returned by NPN_UserAgent, don't + depend on it sticking around and don't free it. */ +typedef const char* (*NPN_UserAgentProcPtr)(NPP instance); +typedef void* (*NPN_MemAllocProcPtr)(uint32_t size); +typedef void (*NPN_MemFreeProcPtr)(void* ptr); +typedef uint32_t (*NPN_MemFlushProcPtr)(uint32_t size); +typedef void (*NPN_ReloadPluginsProcPtr)(NPBool reloadPages); +typedef void* (*NPN_GetJavaEnvProcPtr)(void); +typedef void* (*NPN_GetJavaPeerProcPtr)(NPP instance); +typedef void (*NPN_InvalidateRectProcPtr)(NPP instance, NPRect *rect); +typedef void (*NPN_InvalidateRegionProcPtr)(NPP instance, NPRegion region); +typedef void (*NPN_ForceRedrawProcPtr)(NPP instance); +typedef NPIdentifier (*NPN_GetStringIdentifierProcPtr)(const NPUTF8* name); +typedef void (*NPN_GetStringIdentifiersProcPtr)(const NPUTF8** names, int32_t nameCount, NPIdentifier* identifiers); +typedef NPIdentifier (*NPN_GetIntIdentifierProcPtr)(int32_t intid); +typedef bool (*NPN_IdentifierIsStringProcPtr)(NPIdentifier identifier); +typedef NPUTF8* (*NPN_UTF8FromIdentifierProcPtr)(NPIdentifier identifier); +typedef int32_t (*NPN_IntFromIdentifierProcPtr)(NPIdentifier identifier); +typedef NPObject* (*NPN_CreateObjectProcPtr)(NPP npp, NPClass *aClass); +typedef NPObject* (*NPN_RetainObjectProcPtr)(NPObject *obj); +typedef void (*NPN_ReleaseObjectProcPtr)(NPObject *obj); +typedef bool (*NPN_InvokeProcPtr)(NPP npp, NPObject* obj, NPIdentifier methodName, const NPVariant *args, uint32_t argCount, NPVariant *result); +typedef bool (*NPN_InvokeDefaultProcPtr)(NPP npp, NPObject* obj, const NPVariant *args, uint32_t argCount, NPVariant *result); +typedef bool (*NPN_EvaluateProcPtr)(NPP npp, NPObject *obj, NPString *script, NPVariant *result); +typedef bool (*NPN_GetPropertyProcPtr)(NPP npp, NPObject *obj, NPIdentifier propertyName, NPVariant *result); +typedef bool (*NPN_SetPropertyProcPtr)(NPP npp, NPObject *obj, NPIdentifier propertyName, const NPVariant *value); +typedef bool (*NPN_RemovePropertyProcPtr)(NPP npp, NPObject *obj, NPIdentifier propertyName); +typedef bool (*NPN_HasPropertyProcPtr)(NPP npp, NPObject *obj, NPIdentifier propertyName); +typedef bool (*NPN_HasMethodProcPtr)(NPP npp, NPObject *obj, NPIdentifier propertyName); +typedef void (*NPN_ReleaseVariantValueProcPtr)(NPVariant *variant); +typedef void (*NPN_SetExceptionProcPtr)(NPObject *obj, const NPUTF8 *message); +typedef void (*NPN_PushPopupsEnabledStateProcPtr)(NPP npp, NPBool enabled); +typedef void (*NPN_PopPopupsEnabledStateProcPtr)(NPP npp); +typedef bool (*NPN_EnumerateProcPtr)(NPP npp, NPObject *obj, NPIdentifier **identifier, uint32_t *count); +typedef void (*NPN_PluginThreadAsyncCallProcPtr)(NPP instance, void (*func)(void *), void *userData); +typedef bool (*NPN_ConstructProcPtr)(NPP npp, NPObject* obj, const NPVariant *args, uint32_t argCount, NPVariant *result); +typedef NPError (*NPN_GetValueForURLPtr)(NPP npp, NPNURLVariable variable, const char *url, char **value, uint32_t *len); +typedef NPError (*NPN_SetValueForURLPtr)(NPP npp, NPNURLVariable variable, const char *url, const char *value, uint32_t len); +typedef NPError (*NPN_GetAuthenticationInfoPtr)(NPP npp, const char *protocol, const char *host, int32_t port, const char *scheme, const char *realm, char **username, uint32_t *ulen, char **password, uint32_t *plen); +typedef uint32_t (*NPN_ScheduleTimerPtr)(NPP instance, uint32_t interval, NPBool repeat, void (*timerFunc)(NPP npp, uint32_t timerID)); +typedef void (*NPN_UnscheduleTimerPtr)(NPP instance, uint32_t timerID); +typedef NPError (*NPN_PopUpContextMenuPtr)(NPP instance, NPMenu* menu); +typedef NPBool (*NPN_ConvertPointPtr)(NPP instance, double sourceX, double sourceY, NPCoordinateSpace sourceSpace, double *destX, double *destY, NPCoordinateSpace destSpace); +typedef NPBool (*NPN_HandleEventPtr)(NPP instance, void *event, NPBool handled); +typedef NPBool (*NPN_UnfocusInstancePtr)(NPP instance, NPFocusDirection direction); +typedef void (*NPN_URLRedirectResponsePtr)(NPP instance, void* notifyData, NPBool allow); + +typedef struct _NPPluginFuncs { + uint16_t size; + uint16_t version; + NPP_NewProcPtr newp; + NPP_DestroyProcPtr destroy; + NPP_SetWindowProcPtr setwindow; + NPP_NewStreamProcPtr newstream; + NPP_DestroyStreamProcPtr destroystream; + NPP_StreamAsFileProcPtr asfile; + NPP_WriteReadyProcPtr writeready; + NPP_WriteProcPtr write; + NPP_PrintProcPtr print; + NPP_HandleEventProcPtr event; + NPP_URLNotifyProcPtr urlnotify; + void* javaClass; + NPP_GetValueProcPtr getvalue; + NPP_SetValueProcPtr setvalue; + NPP_GotFocusPtr gotfocus; + NPP_LostFocusPtr lostfocus; + NPP_URLRedirectNotifyPtr urlredirectnotify; + NPP_ClearSiteDataPtr clearsitedata; + NPP_GetSitesWithDataPtr getsiteswithdata; +} NPPluginFuncs; + +typedef struct _NPNetscapeFuncs { + uint16_t size; + uint16_t version; + NPN_GetURLProcPtr geturl; + NPN_PostURLProcPtr posturl; + NPN_RequestReadProcPtr requestread; + NPN_NewStreamProcPtr newstream; + NPN_WriteProcPtr write; + NPN_DestroyStreamProcPtr destroystream; + NPN_StatusProcPtr status; + NPN_UserAgentProcPtr uagent; + NPN_MemAllocProcPtr memalloc; + NPN_MemFreeProcPtr memfree; + NPN_MemFlushProcPtr memflush; + NPN_ReloadPluginsProcPtr reloadplugins; + NPN_GetJavaEnvProcPtr getJavaEnv; + NPN_GetJavaPeerProcPtr getJavaPeer; + NPN_GetURLNotifyProcPtr geturlnotify; + NPN_PostURLNotifyProcPtr posturlnotify; + NPN_GetValueProcPtr getvalue; + NPN_SetValueProcPtr setvalue; + NPN_InvalidateRectProcPtr invalidaterect; + NPN_InvalidateRegionProcPtr invalidateregion; + NPN_ForceRedrawProcPtr forceredraw; + NPN_GetStringIdentifierProcPtr getstringidentifier; + NPN_GetStringIdentifiersProcPtr getstringidentifiers; + NPN_GetIntIdentifierProcPtr getintidentifier; + NPN_IdentifierIsStringProcPtr identifierisstring; + NPN_UTF8FromIdentifierProcPtr utf8fromidentifier; + NPN_IntFromIdentifierProcPtr intfromidentifier; + NPN_CreateObjectProcPtr createobject; + NPN_RetainObjectProcPtr retainobject; + NPN_ReleaseObjectProcPtr releaseobject; + NPN_InvokeProcPtr invoke; + NPN_InvokeDefaultProcPtr invokeDefault; + NPN_EvaluateProcPtr evaluate; + NPN_GetPropertyProcPtr getproperty; + NPN_SetPropertyProcPtr setproperty; + NPN_RemovePropertyProcPtr removeproperty; + NPN_HasPropertyProcPtr hasproperty; + NPN_HasMethodProcPtr hasmethod; + NPN_ReleaseVariantValueProcPtr releasevariantvalue; + NPN_SetExceptionProcPtr setexception; + NPN_PushPopupsEnabledStateProcPtr pushpopupsenabledstate; + NPN_PopPopupsEnabledStateProcPtr poppopupsenabledstate; + NPN_EnumerateProcPtr enumerate; + NPN_PluginThreadAsyncCallProcPtr pluginthreadasynccall; + NPN_ConstructProcPtr construct; + NPN_GetValueForURLPtr getvalueforurl; + NPN_SetValueForURLPtr setvalueforurl; + NPN_GetAuthenticationInfoPtr getauthenticationinfo; + NPN_ScheduleTimerPtr scheduletimer; + NPN_UnscheduleTimerPtr unscheduletimer; + NPN_PopUpContextMenuPtr popupcontextmenu; + NPN_ConvertPointPtr convertpoint; + NPN_HandleEventPtr handleevent; + NPN_UnfocusInstancePtr unfocusinstance; + NPN_URLRedirectResponsePtr urlredirectresponse; +} NPNetscapeFuncs; + +#ifdef XP_MACOSX +/* + * Mac OS X version(s) of NP_GetMIMEDescription(const char *) + * These can be called to retreive MIME information from the plugin dynamically + * + * Note: For compatibility with Quicktime, BPSupportedMIMEtypes is another way + * to get mime info from the plugin only on OSX and may not be supported + * in furture version -- use NP_GetMIMEDescription instead + */ +enum +{ + kBPSupportedMIMETypesStructVers_1 = 1 +}; +typedef struct _BPSupportedMIMETypes +{ + SInt32 structVersion; /* struct version */ + Handle typeStrings; /* STR# formated handle, allocated by plug-in */ + Handle infoStrings; /* STR# formated handle, allocated by plug-in */ +} BPSupportedMIMETypes; +OSErr BP_GetSupportedMIMETypes(BPSupportedMIMETypes *mimeInfo, UInt32 flags); +#define NP_GETMIMEDESCRIPTION_NAME "NP_GetMIMEDescription" +typedef const char* (*NP_GetMIMEDescriptionProcPtr)(void); +typedef OSErr (*BP_GetSupportedMIMETypesProcPtr)(BPSupportedMIMETypes*, UInt32); +#endif + +#endif /* npfunctions_h_ */ diff --git a/cef/include/internal/npapi/nphostapi.h b/cef/include/internal/npapi/nphostapi.h new file mode 100755 index 000000000..d59dbe6f1 --- /dev/null +++ b/cef/include/internal/npapi/nphostapi.h @@ -0,0 +1,39 @@ +// Copyright (c) 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. + +#ifndef _NPHOSTAPI_H_ +#define _NPHOSTAPI_H_ + +// Include path modified for CEF Binary Distribution. +#include "port.h" +// Include path modified for CEF Binary Distribution. +#include "npapi.h" +// Include path modified for CEF Binary Distribution. +#include "npapi_extensions.h" +// Include path modified for CEF Binary Distribution. +#include "npfunctions.h" +// Include path modified for CEF Binary Distribution. +#include "npruntime.h" + +#ifdef __cplusplus +extern "C" { +#endif + +// +// NPAPI library entry points +// +#if defined(OS_POSIX) && !defined(OS_MACOSX) +typedef NPError (API_CALL * NP_InitializeFunc)(NPNetscapeFuncs* pNFuncs, + NPPluginFuncs* pPFuncs); +#else +typedef NPError (API_CALL * NP_InitializeFunc)(NPNetscapeFuncs* pFuncs); +typedef NPError (API_CALL * NP_GetEntryPointsFunc)(NPPluginFuncs* pFuncs); +#endif +typedef NPError (API_CALL * NP_ShutdownFunc)(void); + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _NPHOSTAPI_H_ diff --git a/frameworks/WebKit.framework/Versions/A/Headers/npruntime.h b/cef/include/internal/npapi/npruntime.h old mode 100644 new mode 100755 similarity index 98% rename from frameworks/WebKit.framework/Versions/A/Headers/npruntime.h rename to cef/include/internal/npapi/npruntime.h index 828a34093..8c4b3dfaa --- a/frameworks/WebKit.framework/Versions/A/Headers/npruntime.h +++ b/cef/include/internal/npapi/npruntime.h @@ -33,12 +33,16 @@ #ifndef _NP_RUNTIME_H_ #define _NP_RUNTIME_H_ +// BEGIN GOOGLE MODIFICATIONS #include "npapi.h" +// END GOOGLE MODIFICATIONS #ifdef __cplusplus extern "C" { #endif +#include "nptypes.h" + /* This API is used to facilitate binding code written in C to script objects. The API in this header does not assume the presence of a @@ -167,14 +171,14 @@ NP_END_MACRO #define STRINGZ_TO_NPVARIANT(_val, _v) \ NP_BEGIN_MACRO \ (_v).type = NPVariantType_String; \ - NPString str = { _val, uint32_t(strlen(_val)) }; \ + NPString str = { _val, (uint32_t)(strlen(_val)) }; \ (_v).value.stringValue = str; \ NP_END_MACRO #define STRINGN_TO_NPVARIANT(_val, _len, _v) \ NP_BEGIN_MACRO \ (_v).type = NPVariantType_String; \ - NPString str = { _val, uint32_t(_len) }; \ + NPString str = { _val, (uint32_t)(_len) }; \ (_v).value.stringValue = str; \ NP_END_MACRO diff --git a/frameworks/WebCore.framework/Versions/A/PrivateHeaders/nptypes.h b/cef/include/internal/npapi/nptypes.h old mode 100644 new mode 100755 similarity index 100% rename from frameworks/WebCore.framework/Versions/A/PrivateHeaders/nptypes.h rename to cef/include/internal/npapi/nptypes.h diff --git a/cef/include/internal/npapi/port.h b/cef/include/internal/npapi/port.h new file mode 100755 index 000000000..e1f827563 --- /dev/null +++ b/cef/include/internal/npapi/port.h @@ -0,0 +1,56 @@ +// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef BASE_PORT_H_ +#define BASE_PORT_H_ +#pragma once + +#include +// Include path modified for CEF Binary Distribution. +#include "build_config.h" + +#ifdef COMPILER_MSVC +#define GG_LONGLONG(x) x##I64 +#define GG_ULONGLONG(x) x##UI64 +#else +#define GG_LONGLONG(x) x##LL +#define GG_ULONGLONG(x) x##ULL +#endif + +// Per C99 7.8.14, define __STDC_CONSTANT_MACROS before including +// to get the INTn_C and UINTn_C macros for integer constants. It's difficult +// to guarantee any specific ordering of header includes, so it's difficult to +// guarantee that the INTn_C macros can be defined by including at +// any specific point. Provide GG_INTn_C macros instead. + +#define GG_INT8_C(x) (x) +#define GG_INT16_C(x) (x) +#define GG_INT32_C(x) (x) +#define GG_INT64_C(x) GG_LONGLONG(x) + +#define GG_UINT8_C(x) (x ## U) +#define GG_UINT16_C(x) (x ## U) +#define GG_UINT32_C(x) (x ## U) +#define GG_UINT64_C(x) GG_ULONGLONG(x) + +// It's possible for functions that use a va_list, such as StringPrintf, to +// invalidate the data in it upon use. The fix is to make a copy of the +// structure before using it and use that copy instead. va_copy is provided +// for this purpose. MSVC does not provide va_copy, so define an +// implementation here. It is not guaranteed that assignment is a copy, so the +// StringUtil.VariableArgsFunc unit test tests this capability. +#if defined(COMPILER_GCC) +#define GG_VA_COPY(a, b) (va_copy(a, b)) +#elif defined(COMPILER_MSVC) +#define GG_VA_COPY(a, b) (a = b) +#endif + +// Define an OS-neutral wrapper for shared library entry points +#if defined(OS_WIN) +#define API_CALL __stdcall +#else +#define API_CALL +#endif + +#endif // BASE_PORT_H_ diff --git a/cef/libcef_dll/cef_logging.h b/cef/libcef_dll/cef_logging.h new file mode 100755 index 000000000..67fc109ac --- /dev/null +++ b/cef/libcef_dll/cef_logging.h @@ -0,0 +1,15 @@ +// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights +// reserved. Use of this source code is governed by a BSD-style license that +// can be found in the LICENSE file. + +#ifndef _CEF_LOGGING_H +#define _CEF_LOGGING_H + +#ifdef BUILDING_CEF_SHARED +#include "base/logging.h" +#else +#include +#define DCHECK(condition) assert(condition) +#endif + +#endif // _CEF_LOGGING_H diff --git a/cef/libcef_dll/cpptoc/app_cpptoc.cc b/cef/libcef_dll/cpptoc/app_cpptoc.cc new file mode 100755 index 000000000..d9ba6e693 --- /dev/null +++ b/cef/libcef_dll/cpptoc/app_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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/app_cpptoc.h" +#include "libcef_dll/cpptoc/proxy_handler_cpptoc.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +cef_proxy_handler_t* CEF_CALLBACK app_get_proxy_handler(struct _cef_app_t* self) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefAppCppToC::Get(self)->GetProxyHandler( + ); + + // Return type: refptr_same + return CefProxyHandlerCppToC::Wrap(_retval); +} + + + +// CONSTRUCTOR - Do not edit by hand. + +CefAppCppToC::CefAppCppToC(CefApp* cls) + : CefCppToC(cls) +{ + struct_.struct_.get_proxy_handler = app_get_proxy_handler; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef/libcef_dll/cpptoc/app_cpptoc.h b/cef/libcef_dll/cpptoc/app_cpptoc.h new file mode 100755 index 000000000..3d24fb955 --- /dev/null +++ b/cef/libcef_dll/cpptoc/app_cpptoc.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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef _APP_CPPTOC_H +#define _APP_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 CefAppCppToC + : public CefCppToC +{ +public: + CefAppCppToC(CefApp* cls); + virtual ~CefAppCppToC() {} +}; + +#endif // USING_CEF_SHARED +#endif // _APP_CPPTOC_H + diff --git a/cef/libcef_dll/cpptoc/base_cpptoc.h b/cef/libcef_dll/cpptoc/base_cpptoc.h new file mode 100755 index 000000000..2206eeeaa --- /dev/null +++ b/cef/libcef_dll/cpptoc/base_cpptoc.h @@ -0,0 +1,156 @@ +// Copyright (c) 2009 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 _BASE_CPPTOC_H +#define _BASE_CPPTOC_H + +#include "include/cef.h" +#include "include/cef_capi.h" +#include "libcef_dll/cef_logging.h" + + +// CefCppToC implementation for CefBase. +class CefBaseCppToC : public CefBase +{ +public: + // Use this method to retrieve the underlying class instance from our + // own structure when the structure is passed as the required first + // parameter of a C API function call. No explicit reference counting + // is done in this case. + static CefRefPtr Get(cef_base_t* s) + { + DCHECK(s); + + // Cast our structure to the wrapper structure type. + CefBaseCppToC::Struct* wrapperStruct = + reinterpret_cast(s); + // Return the underlying object instance. + return wrapperStruct->class_->GetClass(); + } + + // Use this method to create a wrapper structure for passing our class + // instance to the other side. + static cef_base_t* Wrap(CefRefPtr c) + { + if (!c.get()) + return NULL; + + // Wrap our object with the CefCppToC class. + CefBaseCppToC* wrapper = new CefBaseCppToC(c); + // Add a reference to our wrapper object that will be released once our + // structure arrives on the other side. + wrapper->AddRef(); + // Return the structure pointer that can now be passed to the other side. + return wrapper->GetStruct(); + } + + // Use this method to retrieve the underlying class instance when receiving + // our wrapper structure back from the other side. + static CefRefPtr Unwrap(cef_base_t* s) + { + if (!s) + return NULL; + + // Cast our structure to the wrapper structure type. + CefBaseCppToC::Struct* wrapperStruct = + reinterpret_cast(s); + // Add the underlying object instance to a smart pointer. + CefRefPtr objectPtr(wrapperStruct->class_->GetClass()); + // Release the reference to our wrapper object that was added before the + // structure was passed back to us. + wrapperStruct->class_->Release(); + // Return the underlying object instance. + return objectPtr; + } + + // Structure representation with pointer to the C++ class. + struct Struct + { + cef_base_t struct_; + CefBaseCppToC* class_; + }; + + CefBaseCppToC(CefBase* cls) + : class_(cls) + { + DCHECK(cls); + + struct_.class_ = this; + + // zero the underlying structure and set base members + memset(&struct_.struct_, 0, sizeof(cef_base_t)); + struct_.struct_.size = sizeof(cef_base_t); + struct_.struct_.add_ref = struct_add_ref; + struct_.struct_.release = struct_release; + struct_.struct_.get_refct = struct_get_refct; + } + virtual ~CefBaseCppToC() {} + + CefBase* GetClass() { return class_; } + + // If returning the structure across the DLL boundary you should call + // AddRef() on this CefCppToC object. On the other side of the DLL boundary, + // call UnderlyingRelease() on the wrapping CefCToCpp object. + cef_base_t* GetStruct() { return &struct_.struct_; } + + // CefBase methods increment/decrement reference counts on both this object + // and the underlying wrapper class. + int AddRef() + { + UnderlyingAddRef(); + return refct_.AddRef(); + } + int Release() + { + UnderlyingRelease(); + 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(); } + +private: + static int CEF_CALLBACK struct_add_ref(struct _cef_base_t* base) + { + DCHECK(base); + if(!base) + return 0; + + Struct* impl = reinterpret_cast(base); + return impl->class_->AddRef(); + } + + static int CEF_CALLBACK struct_release(struct _cef_base_t* base) + { + DCHECK(base); + if(!base) + return 0; + + Struct* impl = reinterpret_cast(base); + return impl->class_->Release(); + } + + static int CEF_CALLBACK struct_get_refct(struct _cef_base_t* base) + { + DCHECK(base); + if(!base) + return 0; + + Struct* impl = reinterpret_cast(base); + return impl->class_->GetRefCt(); + } + +protected: + CefRefCount refct_; + Struct struct_; + CefBase* class_; +}; + +#endif // _BASE_CPPTOC_H diff --git a/cef/libcef_dll/cpptoc/client_cpptoc.cc b/cef/libcef_dll/cpptoc/client_cpptoc.cc new file mode 100755 index 000000000..e1f217a44 --- /dev/null +++ b/cef/libcef_dll/cpptoc/client_cpptoc.cc @@ -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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and 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/drag_handler_cpptoc.h" +#include "libcef_dll/cpptoc/find_handler_cpptoc.h" +#include "libcef_dll/cpptoc/focus_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" +#include "libcef_dll/cpptoc/v8context_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) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefClientCppToC::Get( + self)->GetLifeSpanHandler(); + + // Return type: refptr_same + return CefLifeSpanHandlerCppToC::Wrap(_retval); +} + + +cef_load_handler_t* CEF_CALLBACK client_get_load_handler( + struct _cef_client_t* self) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefClientCppToC::Get( + self)->GetLoadHandler(); + + // Return type: refptr_same + return CefLoadHandlerCppToC::Wrap(_retval); +} + + +cef_request_handler_t* CEF_CALLBACK client_get_request_handler( + struct _cef_client_t* self) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefClientCppToC::Get( + self)->GetRequestHandler(); + + // Return type: refptr_same + return CefRequestHandlerCppToC::Wrap(_retval); +} + + +cef_display_handler_t* CEF_CALLBACK client_get_display_handler( + struct _cef_client_t* self) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefClientCppToC::Get( + self)->GetDisplayHandler(); + + // Return type: refptr_same + return CefDisplayHandlerCppToC::Wrap(_retval); +} + + +cef_focus_handler_t* CEF_CALLBACK client_get_focus_handler( + struct _cef_client_t* self) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefClientCppToC::Get( + self)->GetFocusHandler(); + + // Return type: refptr_same + return CefFocusHandlerCppToC::Wrap(_retval); +} + + +cef_keyboard_handler_t* CEF_CALLBACK client_get_keyboard_handler( + struct _cef_client_t* self) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefClientCppToC::Get( + self)->GetKeyboardHandler(); + + // Return type: refptr_same + return CefKeyboardHandlerCppToC::Wrap(_retval); +} + + +cef_menu_handler_t* CEF_CALLBACK client_get_menu_handler( + struct _cef_client_t* self) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefClientCppToC::Get( + self)->GetMenuHandler(); + + // Return type: refptr_same + return CefMenuHandlerCppToC::Wrap(_retval); +} + + +cef_print_handler_t* CEF_CALLBACK client_get_print_handler( + struct _cef_client_t* self) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefClientCppToC::Get( + self)->GetPrintHandler(); + + // Return type: refptr_same + return CefPrintHandlerCppToC::Wrap(_retval); +} + + +cef_find_handler_t* CEF_CALLBACK client_get_find_handler( + struct _cef_client_t* self) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefClientCppToC::Get( + self)->GetFindHandler(); + + // Return type: refptr_same + return CefFindHandlerCppToC::Wrap(_retval); +} + + +cef_jsdialog_handler_t* CEF_CALLBACK client_get_jsdialog_handler( + struct _cef_client_t* self) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefClientCppToC::Get( + self)->GetJSDialogHandler(); + + // Return type: refptr_same + return CefJSDialogHandlerCppToC::Wrap(_retval); +} + + +cef_v8context_handler_t* CEF_CALLBACK client_get_v8context_handler( + struct _cef_client_t* self) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefClientCppToC::Get( + self)->GetV8ContextHandler(); + + // Return type: refptr_same + return CefV8ContextHandlerCppToC::Wrap(_retval); +} + + +cef_render_handler_t* CEF_CALLBACK client_get_render_handler( + struct _cef_client_t* self) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefClientCppToC::Get( + self)->GetRenderHandler(); + + // Return type: refptr_same + return CefRenderHandlerCppToC::Wrap(_retval); +} + + +cef_drag_handler_t* CEF_CALLBACK client_get_drag_handler( + struct _cef_client_t* self) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefClientCppToC::Get( + self)->GetDragHandler(); + + // Return type: refptr_same + return CefDragHandlerCppToC::Wrap(_retval); +} + + + +// 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_v8context_handler = client_get_v8context_handler; + struct_.struct_.get_render_handler = client_get_render_handler; + struct_.struct_.get_drag_handler = client_get_drag_handler; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef/libcef_dll/cpptoc/client_cpptoc.h b/cef/libcef_dll/cpptoc/client_cpptoc.h new file mode 100755 index 000000000..c04d5d5b7 --- /dev/null +++ b/cef/libcef_dll/cpptoc/client_cpptoc.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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef _CLIENT_CPPTOC_H +#define _CLIENT_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 CefClientCppToC + : public CefCppToC +{ +public: + CefClientCppToC(CefClient* cls); + virtual ~CefClientCppToC() {} +}; + +#endif // USING_CEF_SHARED +#endif // _CLIENT_CPPTOC_H + diff --git a/cef/libcef_dll/cpptoc/content_filter_cpptoc.cc b/cef/libcef_dll/cpptoc/content_filter_cpptoc.cc new file mode 100755 index 000000000..5fd8db816 --- /dev/null +++ b/cef/libcef_dll/cpptoc/content_filter_cpptoc.cc @@ -0,0 +1,113 @@ +// 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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/content_filter_cpptoc.h" +#include "libcef_dll/ctocpp/stream_reader_ctocpp.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +void CEF_CALLBACK content_filter_process_data( + struct _cef_content_filter_t* self, const void* data, int data_size, + cef_stream_reader_t** substitute_data) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: data; type: simple_byaddr + DCHECK(data); + if (!data) + return; + // Verify param: substitute_data; type: refptr_diff_byref + DCHECK(substitute_data); + if (!substitute_data) + return; + + // Translate param: substitute_data; type: refptr_diff_byref + CefRefPtr substitute_dataPtr; + if (substitute_data && *substitute_data) + substitute_dataPtr = CefStreamReaderCToCpp::Wrap(*substitute_data); + CefStreamReader* substitute_dataOrig = substitute_dataPtr.get(); + + // Execute + CefContentFilterCppToC::Get(self)->ProcessData( + data, + data_size, + substitute_dataPtr); + + // Restore param: substitute_data; type: refptr_diff_byref + if (substitute_data) { + if (substitute_dataPtr.get()) { + if (substitute_dataPtr.get() != substitute_dataOrig) { + *substitute_data = CefStreamReaderCToCpp::Unwrap(substitute_dataPtr); + } + } else { + *substitute_data = NULL; + } + } +} + + +void CEF_CALLBACK content_filter_drain(struct _cef_content_filter_t* self, + cef_stream_reader_t** remainder) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: remainder; type: refptr_diff_byref + DCHECK(remainder); + if (!remainder) + return; + + // Translate param: remainder; type: refptr_diff_byref + CefRefPtr remainderPtr; + if (remainder && *remainder) + remainderPtr = CefStreamReaderCToCpp::Wrap(*remainder); + CefStreamReader* remainderOrig = remainderPtr.get(); + + // Execute + CefContentFilterCppToC::Get(self)->Drain( + remainderPtr); + + // Restore param: remainder; type: refptr_diff_byref + if (remainder) { + if (remainderPtr.get()) { + if (remainderPtr.get() != remainderOrig) { + *remainder = CefStreamReaderCToCpp::Unwrap(remainderPtr); + } + } else { + *remainder = NULL; + } + } +} + + + +// CONSTRUCTOR - Do not edit by hand. + +CefContentFilterCppToC::CefContentFilterCppToC(CefContentFilter* cls) + : CefCppToC( + cls) +{ + struct_.struct_.process_data = content_filter_process_data; + struct_.struct_.drain = content_filter_drain; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef/libcef_dll/cpptoc/content_filter_cpptoc.h b/cef/libcef_dll/cpptoc/content_filter_cpptoc.h new file mode 100755 index 000000000..6f4582a34 --- /dev/null +++ b/cef/libcef_dll/cpptoc/content_filter_cpptoc.h @@ -0,0 +1,37 @@ +// Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights +// reserved. Use of this source code is governed by a BSD-style license that +// can be found in the LICENSE file. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef _CONTENTFILTER_CPPTOC_H +#define _CONTENTFILTER_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 CefContentFilterCppToC + : public CefCppToC +{ +public: + CefContentFilterCppToC(CefContentFilter* cls); + virtual ~CefContentFilterCppToC() {} +}; + +#endif // USING_CEF_SHARED +#endif // _CONTENTFILTER_CPPTOC_H + diff --git a/cef/libcef_dll/cpptoc/cookie_visitor_cpptoc.cc b/cef/libcef_dll/cpptoc/cookie_visitor_cpptoc.cc new file mode 100755 index 000000000..3de5d482c --- /dev/null +++ b/cef/libcef_dll/cpptoc/cookie_visitor_cpptoc.cc @@ -0,0 +1,73 @@ +// 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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/cookie_visitor_cpptoc.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +int CEF_CALLBACK cookie_visitor_visit(struct _cef_cookie_visitor_t* self, + const struct _cef_cookie_t* cookie, int count, int total, + int* deleteCookie) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: cookie; type: struct_byref_const + DCHECK(cookie); + if (!cookie) + return 0; + // Verify param: deleteCookie; type: bool_byref + DCHECK(deleteCookie); + if (!deleteCookie) + return 0; + + // Translate param: cookie; type: struct_byref_const + CefCookie cookieObj; + if (cookie) + cookieObj.Set(*cookie, false); + // Translate param: deleteCookie; type: bool_byref + bool deleteCookieBool = (deleteCookie && *deleteCookie)?true:false; + + // Execute + bool _retval = CefCookieVisitorCppToC::Get(self)->Visit( + cookieObj, + count, + total, + deleteCookieBool); + + // Restore param: deleteCookie; type: bool_byref + if (deleteCookie) + *deleteCookie = deleteCookieBool?true:false; + + // Return type: bool + return _retval; +} + + + +// CONSTRUCTOR - Do not edit by hand. + +CefCookieVisitorCppToC::CefCookieVisitorCppToC(CefCookieVisitor* cls) + : CefCppToC( + cls) +{ + struct_.struct_.visit = cookie_visitor_visit; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef/libcef_dll/cpptoc/cookie_visitor_cpptoc.h b/cef/libcef_dll/cpptoc/cookie_visitor_cpptoc.h new file mode 100755 index 000000000..e92f7b513 --- /dev/null +++ b/cef/libcef_dll/cpptoc/cookie_visitor_cpptoc.h @@ -0,0 +1,37 @@ +// Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights +// reserved. Use of this source code is governed by a BSD-style license that +// can be found in the LICENSE file. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef _COOKIEVISITOR_CPPTOC_H +#define _COOKIEVISITOR_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 CefCookieVisitorCppToC + : public CefCppToC +{ +public: + CefCookieVisitorCppToC(CefCookieVisitor* cls); + virtual ~CefCookieVisitorCppToC() {} +}; + +#endif // USING_CEF_SHARED +#endif // _COOKIEVISITOR_CPPTOC_H + diff --git a/cef/libcef_dll/cpptoc/cpptoc.h b/cef/libcef_dll/cpptoc/cpptoc.h new file mode 100755 index 000000000..ce7f8876a --- /dev/null +++ b/cef/libcef_dll/cpptoc/cpptoc.h @@ -0,0 +1,171 @@ +// Copyright (c) 2009 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 _CPPTOC_H +#define _CPPTOC_H + +#include "include/cef.h" +#include "include/cef_capi.h" +#include "libcef_dll/cef_logging.h" + + +// Wrap a C++ class with a C structure. This is used when the class +// 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 CefBase +{ +public: + // Structure representation with pointer to the C++ class. + struct Struct + { + StructName struct_; + CefCppToC* class_; + }; + + // Use this method to retrieve the underlying class instance from our + // own structure when the structure is passed as the required first + // parameter of a C API function call. No explicit reference counting + // is done in this case. + static CefRefPtr Get(StructName* s) + { + DCHECK(s); + + // Cast our structure to the wrapper structure type. + Struct* wrapperStruct = reinterpret_cast(s); + // Return the underlying object instance. + return wrapperStruct->class_->GetClass(); + } + + // Use this method to create a wrapper structure for passing our class + // instance to the other side. + static StructName* Wrap(CefRefPtr c) + { + if (!c.get()) + return NULL; + + // Wrap our object with the CefCppToC class. + ClassName* wrapper = new ClassName(c); + // Add a reference to our wrapper object that will be released once our + // structure arrives on the other side. + wrapper->AddRef(); + // Return the structure pointer that can now be passed to the other side. + return wrapper->GetStruct(); + } + + // Use this method to retrieve the underlying class instance when receiving + // our wrapper structure back from the other side. + static CefRefPtr Unwrap(StructName* s) + { + if (!s) + return NULL; + + // Cast our structure to the wrapper structure type. + Struct* wrapperStruct = reinterpret_cast(s); + // Add the underlying object instance to a smart pointer. + CefRefPtr objectPtr(wrapperStruct->class_->GetClass()); + // Release the reference to our wrapper object that was added before the + // structure was passed back to us. + wrapperStruct->class_->Release(); + // Return the underlying object instance. + return objectPtr; + } + + CefCppToC(BaseName* cls) + : class_(cls) + { + DCHECK(cls); + + struct_.class_ = this; + + // zero the underlying structure and set base members + memset(&struct_.struct_, 0, sizeof(StructName)); + struct_.struct_.base.size = sizeof(StructName); + struct_.struct_.base.add_ref = struct_add_ref; + struct_.struct_.base.release = struct_release; + struct_.struct_.base.get_refct = struct_get_refct; + +#ifndef NDEBUG + CefAtomicIncrement(&DebugObjCt); +#endif + } + virtual ~CefCppToC() + { +#ifndef NDEBUG + CefAtomicDecrement(&DebugObjCt); +#endif + } + + BaseName* GetClass() { return class_; } + + // If returning the structure across the DLL boundary you should call + // AddRef() on this CefCppToC object. On the other side of the DLL boundary, + // call UnderlyingRelease() on the wrapping CefCToCpp object. + StructName* GetStruct() { return &struct_.struct_; } + + // CefBase methods increment/decrement reference counts on both this object + // and the underlying wrapper class. + int AddRef() + { + UnderlyingAddRef(); + return refct_.AddRef(); + } + int Release() + { + UnderlyingRelease(); + 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(); } + +#ifndef NDEBUG + // Simple tracking of allocated objects. + static long DebugObjCt; +#endif + +private: + static int CEF_CALLBACK struct_add_ref(struct _cef_base_t* base) + { + DCHECK(base); + if(!base) + return 0; + + Struct* impl = reinterpret_cast(base); + return impl->class_->AddRef(); + } + + static int CEF_CALLBACK struct_release(struct _cef_base_t* base) + { + DCHECK(base); + if(!base) + return 0; + + Struct* impl = reinterpret_cast(base); + return impl->class_->Release(); + } + + static int CEF_CALLBACK struct_get_refct(struct _cef_base_t* base) + { + DCHECK(base); + if(!base) + return 0; + + Struct* impl = reinterpret_cast(base); + return impl->class_->GetRefCt(); + } + +protected: + CefRefCount refct_; + Struct struct_; + BaseName* class_; +}; + +#endif // _CPPTOC_H diff --git a/cef/libcef_dll/cpptoc/display_handler_cpptoc.cc b/cef/libcef_dll/cpptoc/display_handler_cpptoc.cc new file mode 100755 index 000000000..b385419c3 --- /dev/null +++ b/cef/libcef_dll/cpptoc/display_handler_cpptoc.cc @@ -0,0 +1,219 @@ +// 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. If making changes by +// hand only do so within the body of existing method and 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) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return; + + // Execute + 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) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return; + // Verify param: frame; type: refptr_diff + DCHECK(frame); + if (!frame) + return; + // Verify param: url; type: string_byref_const + DCHECK(url); + if (!url) + return; + + // Execute + CefDisplayHandlerCppToC::Get(self)->OnAddressChange( + CefBrowserCToCpp::Wrap(browser), + CefFrameCToCpp::Wrap(frame), + CefString(url)); +} + + +void CEF_CALLBACK display_handler_on_contents_size_change( + struct _cef_display_handler_t* self, cef_browser_t* browser, + cef_frame_t* frame, int width, int height) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return; + // Verify param: frame; type: refptr_diff + DCHECK(frame); + if (!frame) + return; + + // Execute + CefDisplayHandlerCppToC::Get(self)->OnContentsSizeChange( + CefBrowserCToCpp::Wrap(browser), + CefFrameCToCpp::Wrap(frame), + width, + height); +} + + +void CEF_CALLBACK display_handler_on_title_change( + struct _cef_display_handler_t* self, cef_browser_t* browser, + const cef_string_t* title) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return; + // Unverified params: title + + // Execute + 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) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return 0; + // Unverified params: text + + // Translate param: text; type: string_byref + CefString textStr(text); + + // Execute + bool _retval = CefDisplayHandlerCppToC::Get(self)->OnTooltip( + CefBrowserCToCpp::Wrap(browser), + textStr); + + // Return type: bool + return _retval; +} + + +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) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return; + // Unverified params: value + + // Execute + 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) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return 0; + // Unverified params: message, source + + // Execute + bool _retval = CefDisplayHandlerCppToC::Get(self)->OnConsoleMessage( + CefBrowserCToCpp::Wrap(browser), + CefString(message), + CefString(source), + line); + + // Return type: bool + return _retval; +} + + + +// 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_contents_size_change = + display_handler_on_contents_size_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/cef/libcef_dll/cpptoc/display_handler_cpptoc.h b/cef/libcef_dll/cpptoc/display_handler_cpptoc.h new file mode 100755 index 000000000..1dc36ea81 --- /dev/null +++ b/cef/libcef_dll/cpptoc/display_handler_cpptoc.h @@ -0,0 +1,37 @@ +// Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights +// reserved. Use of this source code is governed by a BSD-style license that +// can be found in the LICENSE file. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. 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/cef/libcef_dll/cpptoc/domevent_listener_cpptoc.cc b/cef/libcef_dll/cpptoc/domevent_listener_cpptoc.cc new file mode 100755 index 000000000..688f93f6b --- /dev/null +++ b/cef/libcef_dll/cpptoc/domevent_listener_cpptoc.cc @@ -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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/domevent_listener_cpptoc.h" +#include "libcef_dll/ctocpp/domevent_ctocpp.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +void CEF_CALLBACK domevent_listener_handle_event( + struct _cef_domevent_listener_t* self, cef_domevent_t* event) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: event; type: refptr_diff + DCHECK(event); + if (!event) + return; + + // Execute + CefDOMEventListenerCppToC::Get(self)->HandleEvent( + CefDOMEventCToCpp::Wrap(event)); +} + + + +// CONSTRUCTOR - Do not edit by hand. + +CefDOMEventListenerCppToC::CefDOMEventListenerCppToC(CefDOMEventListener* cls) + : CefCppToC(cls) +{ + struct_.struct_.handle_event = domevent_listener_handle_event; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef/libcef_dll/cpptoc/domevent_listener_cpptoc.h b/cef/libcef_dll/cpptoc/domevent_listener_cpptoc.h new file mode 100755 index 000000000..8b6ee09f6 --- /dev/null +++ b/cef/libcef_dll/cpptoc/domevent_listener_cpptoc.h @@ -0,0 +1,37 @@ +// Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights +// reserved. Use of this source code is governed by a BSD-style license that +// can be found in the LICENSE file. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef _DOMEVENTLISTENER_CPPTOC_H +#define _DOMEVENTLISTENER_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 CefDOMEventListenerCppToC + : public CefCppToC +{ +public: + CefDOMEventListenerCppToC(CefDOMEventListener* cls); + virtual ~CefDOMEventListenerCppToC() {} +}; + +#endif // USING_CEF_SHARED +#endif // _DOMEVENTLISTENER_CPPTOC_H + diff --git a/cef/libcef_dll/cpptoc/domvisitor_cpptoc.cc b/cef/libcef_dll/cpptoc/domvisitor_cpptoc.cc new file mode 100755 index 000000000..4133665a0 --- /dev/null +++ b/cef/libcef_dll/cpptoc/domvisitor_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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/domvisitor_cpptoc.h" +#include "libcef_dll/ctocpp/domdocument_ctocpp.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +void CEF_CALLBACK domvisitor_visit(struct _cef_domvisitor_t* self, + struct _cef_domdocument_t* document) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: document; type: refptr_diff + DCHECK(document); + if (!document) + return; + + // Execute + CefDOMVisitorCppToC::Get(self)->Visit( + CefDOMDocumentCToCpp::Wrap(document)); +} + + + +// CONSTRUCTOR - Do not edit by hand. + +CefDOMVisitorCppToC::CefDOMVisitorCppToC(CefDOMVisitor* cls) + : CefCppToC(cls) +{ + struct_.struct_.visit = domvisitor_visit; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef/libcef_dll/cpptoc/domvisitor_cpptoc.h b/cef/libcef_dll/cpptoc/domvisitor_cpptoc.h new file mode 100755 index 000000000..86c937ec0 --- /dev/null +++ b/cef/libcef_dll/cpptoc/domvisitor_cpptoc.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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef _DOMVISITOR_CPPTOC_H +#define _DOMVISITOR_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 CefDOMVisitorCppToC + : public CefCppToC +{ +public: + CefDOMVisitorCppToC(CefDOMVisitor* cls); + virtual ~CefDOMVisitorCppToC() {} +}; + +#endif // USING_CEF_SHARED +#endif // _DOMVISITOR_CPPTOC_H + diff --git a/cef/libcef_dll/cpptoc/download_handler_cpptoc.cc b/cef/libcef_dll/cpptoc/download_handler_cpptoc.cc new file mode 100755 index 000000000..61152dddc --- /dev/null +++ b/cef/libcef_dll/cpptoc/download_handler_cpptoc.cc @@ -0,0 +1,70 @@ +// 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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/download_handler_cpptoc.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +int CEF_CALLBACK download_handler_received_data( + struct _cef_download_handler_t* self, void* data, int data_size) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: data; type: simple_byaddr + DCHECK(data); + if (!data) + return 0; + + // Execute + bool _retval = CefDownloadHandlerCppToC::Get(self)->ReceivedData( + data, + data_size); + + // Return type: bool + return _retval; +} + + +void CEF_CALLBACK download_handler_complete( + struct _cef_download_handler_t* self) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + + // Execute + CefDownloadHandlerCppToC::Get(self)->Complete(); +} + + + +// CONSTRUCTOR - Do not edit by hand. + +CefDownloadHandlerCppToC::CefDownloadHandlerCppToC(CefDownloadHandler* cls) + : CefCppToC(cls) +{ + struct_.struct_.received_data = download_handler_received_data; + struct_.struct_.complete = download_handler_complete; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef/libcef_dll/cpptoc/download_handler_cpptoc.h b/cef/libcef_dll/cpptoc/download_handler_cpptoc.h new file mode 100755 index 000000000..afb0cde81 --- /dev/null +++ b/cef/libcef_dll/cpptoc/download_handler_cpptoc.h @@ -0,0 +1,37 @@ +// Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights +// reserved. Use of this source code is governed by a BSD-style license that +// can be found in the LICENSE file. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef _DOWNLOADHANDLER_CPPTOC_H +#define _DOWNLOADHANDLER_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 CefDownloadHandlerCppToC + : public CefCppToC +{ +public: + CefDownloadHandlerCppToC(CefDownloadHandler* cls); + virtual ~CefDownloadHandlerCppToC() {} +}; + +#endif // USING_CEF_SHARED +#endif // _DOWNLOADHANDLER_CPPTOC_H + diff --git a/cef/libcef_dll/cpptoc/drag_handler_cpptoc.cc b/cef/libcef_dll/cpptoc/drag_handler_cpptoc.cc new file mode 100755 index 000000000..e36e94ada --- /dev/null +++ b/cef/libcef_dll/cpptoc/drag_handler_cpptoc.cc @@ -0,0 +1,92 @@ +// Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights +// reserved. Use of this source code is governed by a BSD-style license that +// can be found in the LICENSE file. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/drag_handler_cpptoc.h" +#include "libcef_dll/ctocpp/browser_ctocpp.h" +#include "libcef_dll/ctocpp/drag_data_ctocpp.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +int CEF_CALLBACK drag_handler_on_drag_start(struct _cef_drag_handler_t* self, + cef_browser_t* browser, struct _cef_drag_data_t* dragData, + enum cef_drag_operations_mask_t mask) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return 0; + // Verify param: dragData; type: refptr_diff + DCHECK(dragData); + if (!dragData) + return 0; + + // Execute + bool _retval = CefDragHandlerCppToC::Get(self)->OnDragStart( + CefBrowserCToCpp::Wrap(browser), + CefDragDataCToCpp::Wrap(dragData), + mask); + + // Return type: bool + return _retval; +} + + +int CEF_CALLBACK drag_handler_on_drag_enter(struct _cef_drag_handler_t* self, + cef_browser_t* browser, struct _cef_drag_data_t* dragData, + enum cef_drag_operations_mask_t mask) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return 0; + // Verify param: dragData; type: refptr_diff + DCHECK(dragData); + if (!dragData) + return 0; + + // Execute + bool _retval = CefDragHandlerCppToC::Get(self)->OnDragEnter( + CefBrowserCToCpp::Wrap(browser), + CefDragDataCToCpp::Wrap(dragData), + mask); + + // Return type: bool + return _retval; +} + + + +// CONSTRUCTOR - Do not edit by hand. + +CefDragHandlerCppToC::CefDragHandlerCppToC(CefDragHandler* cls) + : CefCppToC(cls) +{ + struct_.struct_.on_drag_start = drag_handler_on_drag_start; + struct_.struct_.on_drag_enter = drag_handler_on_drag_enter; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef/libcef_dll/cpptoc/drag_handler_cpptoc.h b/cef/libcef_dll/cpptoc/drag_handler_cpptoc.h new file mode 100755 index 000000000..cb42b2439 --- /dev/null +++ b/cef/libcef_dll/cpptoc/drag_handler_cpptoc.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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef _DRAGHANDLER_CPPTOC_H +#define _DRAGHANDLER_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 CefDragHandlerCppToC + : public CefCppToC +{ +public: + CefDragHandlerCppToC(CefDragHandler* cls); + virtual ~CefDragHandlerCppToC() {} +}; + +#endif // USING_CEF_SHARED +#endif // _DRAGHANDLER_CPPTOC_H + diff --git a/cef/libcef_dll/cpptoc/find_handler_cpptoc.cc b/cef/libcef_dll/cpptoc/find_handler_cpptoc.cc new file mode 100755 index 000000000..1b562a62a --- /dev/null +++ b/cef/libcef_dll/cpptoc/find_handler_cpptoc.cc @@ -0,0 +1,64 @@ +// 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. If making changes by +// hand only do so within the body of existing method and 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) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return; + // Verify param: selectionRect; type: simple_byref_const + DCHECK(selectionRect); + if (!selectionRect) + return; + + // Translate param: selectionRect; type: simple_byref_const + CefRect selectionRectVal = selectionRect?*selectionRect:CefRect(); + + // Execute + CefFindHandlerCppToC::Get(self)->OnFindResult( + CefBrowserCToCpp::Wrap(browser), + identifier, + count, + selectionRectVal, + 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/cef/libcef_dll/cpptoc/find_handler_cpptoc.h b/cef/libcef_dll/cpptoc/find_handler_cpptoc.h new file mode 100755 index 000000000..0d5f90601 --- /dev/null +++ b/cef/libcef_dll/cpptoc/find_handler_cpptoc.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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. 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/cef/libcef_dll/cpptoc/focus_handler_cpptoc.cc b/cef/libcef_dll/cpptoc/focus_handler_cpptoc.cc new file mode 100755 index 000000000..4358486eb --- /dev/null +++ b/cef/libcef_dll/cpptoc/focus_handler_cpptoc.cc @@ -0,0 +1,104 @@ +// 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. If making changes by +// hand only do so within the body of existing method and 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" +#include "libcef_dll/ctocpp/domnode_ctocpp.h" +#include "libcef_dll/ctocpp/frame_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) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return; + + // Execute + 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, enum cef_handler_focus_source_t source) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return 0; + + // Execute + bool _retval = CefFocusHandlerCppToC::Get(self)->OnSetFocus( + CefBrowserCToCpp::Wrap(browser), + source); + + // Return type: bool + return _retval; +} + + +void CEF_CALLBACK focus_handler_on_focused_node_changed( + struct _cef_focus_handler_t* self, cef_browser_t* browser, + cef_frame_t* frame, struct _cef_domnode_t* node) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return; + // Unverified params: frame, node + + // Execute + CefFocusHandlerCppToC::Get(self)->OnFocusedNodeChanged( + CefBrowserCToCpp::Wrap(browser), + CefFrameCToCpp::Wrap(frame), + CefDOMNodeCToCpp::Wrap(node)); +} + + + +// 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; + struct_.struct_.on_focused_node_changed = + focus_handler_on_focused_node_changed; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef/libcef_dll/cpptoc/focus_handler_cpptoc.h b/cef/libcef_dll/cpptoc/focus_handler_cpptoc.h new file mode 100755 index 000000000..377b3ad6e --- /dev/null +++ b/cef/libcef_dll/cpptoc/focus_handler_cpptoc.h @@ -0,0 +1,37 @@ +// Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights +// reserved. Use of this source code is governed by a BSD-style license that +// can be found in the LICENSE file. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. 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/cef/libcef_dll/cpptoc/jsdialog_handler_cpptoc.cc b/cef/libcef_dll/cpptoc/jsdialog_handler_cpptoc.cc new file mode 100755 index 000000000..cce925780 --- /dev/null +++ b/cef/libcef_dll/cpptoc/jsdialog_handler_cpptoc.cc @@ -0,0 +1,172 @@ +// 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. If making changes by +// hand only do so within the body of existing method and 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) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return 0; + // Verify param: frame; type: refptr_diff + DCHECK(frame); + if (!frame) + return 0; + // Verify param: message; type: string_byref_const + DCHECK(message); + if (!message) + return 0; + + // Execute + bool _retval = CefJSDialogHandlerCppToC::Get(self)->OnJSAlert( + CefBrowserCToCpp::Wrap(browser), + CefFrameCToCpp::Wrap(frame), + CefString(message)); + + // Return type: bool + return _retval; +} + + +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) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return 0; + // Verify param: frame; type: refptr_diff + DCHECK(frame); + if (!frame) + return 0; + // Verify param: message; type: string_byref_const + DCHECK(message); + if (!message) + return 0; + // Verify param: retval; type: bool_byref + DCHECK(retval); + if (!retval) + return 0; + + // Translate param: retval; type: bool_byref + bool retvalBool = (retval && *retval)?true:false; + + // Execute + bool _retval = CefJSDialogHandlerCppToC::Get(self)->OnJSConfirm( + CefBrowserCToCpp::Wrap(browser), + CefFrameCToCpp::Wrap(frame), + CefString(message), + retvalBool); + + // Restore param: retval; type: bool_byref + if (retval) + *retval = retvalBool?true:false; + + // Return type: bool + return _retval; +} + + +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) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return 0; + // Verify param: frame; type: refptr_diff + DCHECK(frame); + if (!frame) + return 0; + // Verify param: message; type: string_byref_const + DCHECK(message); + if (!message) + return 0; + // Verify param: defaultValue; type: string_byref_const + DCHECK(defaultValue); + if (!defaultValue) + return 0; + // Verify param: retval; type: bool_byref + DCHECK(retval); + if (!retval) + return 0; + // Verify param: result; type: string_byref + DCHECK(result); + if (!result) + return 0; + + // Translate param: retval; type: bool_byref + bool retvalBool = (retval && *retval)?true:false; + // Translate param: result; type: string_byref + CefString resultStr(result); + + // Execute + bool _retval = CefJSDialogHandlerCppToC::Get(self)->OnJSPrompt( + CefBrowserCToCpp::Wrap(browser), + CefFrameCToCpp::Wrap(frame), + CefString(message), + CefString(defaultValue), + retvalBool, + resultStr); + + // Restore param: retval; type: bool_byref + if (retval) + *retval = retvalBool?true:false; + + // Return type: bool + return _retval; +} + + + +// 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/cef/libcef_dll/cpptoc/jsdialog_handler_cpptoc.h b/cef/libcef_dll/cpptoc/jsdialog_handler_cpptoc.h new file mode 100755 index 000000000..a1fdb66f3 --- /dev/null +++ b/cef/libcef_dll/cpptoc/jsdialog_handler_cpptoc.h @@ -0,0 +1,37 @@ +// Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights +// reserved. Use of this source code is governed by a BSD-style license that +// can be found in the LICENSE file. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. 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/cef/libcef_dll/cpptoc/keyboard_handler_cpptoc.cc b/cef/libcef_dll/cpptoc/keyboard_handler_cpptoc.cc new file mode 100755 index 000000000..ad2e6f340 --- /dev/null +++ b/cef/libcef_dll/cpptoc/keyboard_handler_cpptoc.cc @@ -0,0 +1,62 @@ +// 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. If making changes by +// hand only do so within the body of existing method and 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, int isAfterJavaScript) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return 0; + + // Execute + bool _retval = CefKeyboardHandlerCppToC::Get(self)->OnKeyEvent( + CefBrowserCToCpp::Wrap(browser), + type, + code, + modifiers, + isSystemKey?true:false, + isAfterJavaScript?true:false); + + // Return type: bool + return _retval; +} + + + +// 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/cef/libcef_dll/cpptoc/keyboard_handler_cpptoc.h b/cef/libcef_dll/cpptoc/keyboard_handler_cpptoc.h new file mode 100755 index 000000000..0d1dbc3b4 --- /dev/null +++ b/cef/libcef_dll/cpptoc/keyboard_handler_cpptoc.h @@ -0,0 +1,37 @@ +// Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights +// reserved. Use of this source code is governed by a BSD-style license that +// can be found in the LICENSE file. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. 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/cef/libcef_dll/cpptoc/life_span_handler_cpptoc.cc b/cef/libcef_dll/cpptoc/life_span_handler_cpptoc.cc new file mode 100755 index 000000000..ea2a6a8b0 --- /dev/null +++ b/cef/libcef_dll/cpptoc/life_span_handler_cpptoc.cc @@ -0,0 +1,202 @@ +// 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. If making changes by +// hand only do so within the body of existing method and 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) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: parentBrowser; type: refptr_diff + DCHECK(parentBrowser); + if (!parentBrowser) + return 0; + // Verify param: popupFeatures; type: struct_byref_const + DCHECK(popupFeatures); + if (!popupFeatures) + return 0; + // Verify param: windowInfo; type: struct_byref + DCHECK(windowInfo); + if (!windowInfo) + return 0; + // Verify param: client; type: refptr_same_byref + DCHECK(client); + if (!client) + return 0; + // Verify param: settings; type: struct_byref + DCHECK(settings); + if (!settings) + return 0; + // Unverified params: url + + // Translate param: popupFeatures; type: struct_byref_const + CefPopupFeatures popupFeaturesObj; + if (popupFeatures) + popupFeaturesObj.Set(*popupFeatures, false); + // Translate param: windowInfo; type: struct_byref + CefWindowInfo windowInfoObj; + if (windowInfo) + windowInfoObj.AttachTo(*windowInfo); + // Translate param: client; type: refptr_same_byref + CefRefPtr clientPtr; + if (client && *client) + clientPtr = CefClientCppToC::Unwrap(*client); + CefClient* clientOrig = clientPtr.get(); + // Translate param: settings; type: struct_byref + CefBrowserSettings settingsObj; + if (settings) + settingsObj.AttachTo(*settings); + + // Execute + bool _retval = CefLifeSpanHandlerCppToC::Get(self)->OnBeforePopup( + CefBrowserCToCpp::Wrap(parentBrowser), + popupFeaturesObj, + windowInfoObj, + CefString(url), + clientPtr, + settingsObj); + + // Restore param: windowInfo; type: struct_byref + if (windowInfo) + windowInfoObj.DetachTo(*windowInfo); + // Restore param: client; type: refptr_same_byref + if (client) { + if (clientPtr.get()) { + if (clientPtr.get() != clientOrig) { + *client = CefClientCppToC::Wrap(clientPtr); + } + } else { + *client = NULL; + } + } + // Restore param: settings; type: struct_byref + if (settings) + settingsObj.DetachTo(*settings); + + // Return type: bool + return _retval; +} + + +void CEF_CALLBACK life_span_handler_on_after_created( + struct _cef_life_span_handler_t* self, cef_browser_t* browser) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return; + + // Execute + CefLifeSpanHandlerCppToC::Get(self)->OnAfterCreated( + CefBrowserCToCpp::Wrap(browser)); +} + + +int CEF_CALLBACK life_span_handler_run_modal( + struct _cef_life_span_handler_t* self, cef_browser_t* browser) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return 0; + + // Execute + bool _retval = CefLifeSpanHandlerCppToC::Get(self)->RunModal( + CefBrowserCToCpp::Wrap(browser)); + + // Return type: bool + return _retval; +} + + +int CEF_CALLBACK life_span_handler_do_close( + struct _cef_life_span_handler_t* self, cef_browser_t* browser) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return 0; + + // Execute + bool _retval = CefLifeSpanHandlerCppToC::Get(self)->DoClose( + CefBrowserCToCpp::Wrap(browser)); + + // Return type: bool + return _retval; +} + + +void CEF_CALLBACK life_span_handler_on_before_close( + struct _cef_life_span_handler_t* self, cef_browser_t* browser) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return; + + // Execute + 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_.run_modal = life_span_handler_run_modal; + struct_.struct_.do_close = life_span_handler_do_close; + struct_.struct_.on_before_close = life_span_handler_on_before_close; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef/libcef_dll/cpptoc/life_span_handler_cpptoc.h b/cef/libcef_dll/cpptoc/life_span_handler_cpptoc.h new file mode 100755 index 000000000..722bf967b --- /dev/null +++ b/cef/libcef_dll/cpptoc/life_span_handler_cpptoc.h @@ -0,0 +1,37 @@ +// Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights +// reserved. Use of this source code is governed by a BSD-style license that +// can be found in the LICENSE file. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. 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/cef/libcef_dll/cpptoc/load_handler_cpptoc.cc b/cef/libcef_dll/cpptoc/load_handler_cpptoc.cc new file mode 100755 index 000000000..2f7ca596c --- /dev/null +++ b/cef/libcef_dll/cpptoc/load_handler_cpptoc.cc @@ -0,0 +1,127 @@ +// 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. If making changes by +// hand only do so within the body of existing method and 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) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return; + // Verify param: frame; type: refptr_diff + DCHECK(frame); + if (!frame) + return; + + // Execute + 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) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return; + // Verify param: frame; type: refptr_diff + DCHECK(frame); + if (!frame) + return; + + // Execute + 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) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return 0; + // Verify param: frame; type: refptr_diff + DCHECK(frame); + if (!frame) + return 0; + // Verify param: failedUrl; type: string_byref_const + DCHECK(failedUrl); + if (!failedUrl) + return 0; + // Verify param: errorText; type: string_byref + DCHECK(errorText); + if (!errorText) + return 0; + + // Translate param: errorText; type: string_byref + CefString errorTextStr(errorText); + + // Execute + bool _retval = CefLoadHandlerCppToC::Get(self)->OnLoadError( + CefBrowserCToCpp::Wrap(browser), + CefFrameCToCpp::Wrap(frame), + errorCode, + CefString(failedUrl), + errorTextStr); + + // Return type: bool + return _retval; +} + + + +// 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/cef/libcef_dll/cpptoc/load_handler_cpptoc.h b/cef/libcef_dll/cpptoc/load_handler_cpptoc.h new file mode 100755 index 000000000..c4f56c92d --- /dev/null +++ b/cef/libcef_dll/cpptoc/load_handler_cpptoc.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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. 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/cef/libcef_dll/cpptoc/menu_handler_cpptoc.cc b/cef/libcef_dll/cpptoc/menu_handler_cpptoc.cc new file mode 100755 index 000000000..491b77e3a --- /dev/null +++ b/cef/libcef_dll/cpptoc/menu_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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and 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 struct _cef_menu_info_t* menuInfo) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return 0; + // Verify param: menuInfo; type: struct_byref_const + DCHECK(menuInfo); + if (!menuInfo) + return 0; + + // Translate param: menuInfo; type: struct_byref_const + CefMenuInfo menuInfoObj; + if (menuInfo) + menuInfoObj.Set(*menuInfo, false); + + // Execute + bool _retval = CefMenuHandlerCppToC::Get(self)->OnBeforeMenu( + CefBrowserCToCpp::Wrap(browser), + menuInfoObj); + + // Return type: bool + return _retval; +} + + +void CEF_CALLBACK menu_handler_get_menu_label(struct _cef_menu_handler_t* self, + cef_browser_t* browser, enum cef_menu_id_t menuId, cef_string_t* label) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return; + // Verify param: label; type: string_byref + DCHECK(label); + if (!label) + return; + + // Translate param: label; type: string_byref + CefString labelStr(label); + + // Execute + 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_menu_id_t menuId) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return 0; + + // Execute + bool _retval = CefMenuHandlerCppToC::Get(self)->OnMenuAction( + CefBrowserCToCpp::Wrap(browser), + menuId); + + // Return type: bool + return _retval; +} + + + +// 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/cef/libcef_dll/cpptoc/menu_handler_cpptoc.h b/cef/libcef_dll/cpptoc/menu_handler_cpptoc.h new file mode 100755 index 000000000..e50f11d54 --- /dev/null +++ b/cef/libcef_dll/cpptoc/menu_handler_cpptoc.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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. 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/cef/libcef_dll/cpptoc/print_handler_cpptoc.cc b/cef/libcef_dll/cpptoc/print_handler_cpptoc.cc new file mode 100755 index 000000000..60b4417ef --- /dev/null +++ b/cef/libcef_dll/cpptoc/print_handler_cpptoc.cc @@ -0,0 +1,169 @@ +// 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. If making changes by +// hand only do so within the body of existing method and 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) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return 0; + // Verify param: printOptions; type: struct_byref + DCHECK(printOptions); + if (!printOptions) + return 0; + + // Translate param: printOptions; type: struct_byref + CefPrintOptions printOptionsObj; + if (printOptions) + printOptionsObj.AttachTo(*printOptions); + + // Execute + bool _retval = CefPrintHandlerCppToC::Get(self)->GetPrintOptions( + CefBrowserCToCpp::Wrap(browser), + printOptionsObj); + + // Restore param: printOptions; type: struct_byref + if (printOptions) + printOptionsObj.DetachTo(*printOptions); + + // Return type: bool + return _retval; +} + + +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) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return 0; + // Verify param: frame; type: refptr_diff + DCHECK(frame); + if (!frame) + return 0; + // Verify param: printInfo; type: struct_byref_const + DCHECK(printInfo); + if (!printInfo) + return 0; + // Verify param: url; type: string_byref_const + DCHECK(url); + if (!url) + return 0; + // Verify param: title; type: string_byref_const + DCHECK(title); + if (!title) + return 0; + // Verify param: topLeft; type: string_byref + DCHECK(topLeft); + if (!topLeft) + return 0; + // Verify param: topCenter; type: string_byref + DCHECK(topCenter); + if (!topCenter) + return 0; + // Verify param: topRight; type: string_byref + DCHECK(topRight); + if (!topRight) + return 0; + // Verify param: bottomLeft; type: string_byref + DCHECK(bottomLeft); + if (!bottomLeft) + return 0; + // Verify param: bottomCenter; type: string_byref + DCHECK(bottomCenter); + if (!bottomCenter) + return 0; + // Verify param: bottomRight; type: string_byref + DCHECK(bottomRight); + if (!bottomRight) + return 0; + + // Translate param: printInfo; type: struct_byref_const + CefPrintInfo printInfoObj; + if (printInfo) + printInfoObj.Set(*printInfo, false); + // Translate param: topLeft; type: string_byref + CefString topLeftStr(topLeft); + // Translate param: topCenter; type: string_byref + CefString topCenterStr(topCenter); + // Translate param: topRight; type: string_byref + CefString topRightStr(topRight); + // Translate param: bottomLeft; type: string_byref + CefString bottomLeftStr(bottomLeft); + // Translate param: bottomCenter; type: string_byref + CefString bottomCenterStr(bottomCenter); + // Translate param: bottomRight; type: string_byref + CefString bottomRightStr(bottomRight); + + // Execute + bool _retval = CefPrintHandlerCppToC::Get(self)->GetPrintHeaderFooter( + CefBrowserCToCpp::Wrap(browser), + CefFrameCToCpp::Wrap(frame), + printInfoObj, + CefString(url), + CefString(title), + currentPage, + maxPages, + topLeftStr, + topCenterStr, + topRightStr, + bottomLeftStr, + bottomCenterStr, + bottomRightStr); + + // Return type: bool + return _retval; +} + + + +// 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/cef/libcef_dll/cpptoc/print_handler_cpptoc.h b/cef/libcef_dll/cpptoc/print_handler_cpptoc.h new file mode 100755 index 000000000..35717bf65 --- /dev/null +++ b/cef/libcef_dll/cpptoc/print_handler_cpptoc.h @@ -0,0 +1,37 @@ +// Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights +// reserved. Use of this source code is governed by a BSD-style license that +// can be found in the LICENSE file. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. 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/cef/libcef_dll/cpptoc/proxy_handler_cpptoc.cc b/cef/libcef_dll/cpptoc/proxy_handler_cpptoc.cc new file mode 100755 index 000000000..6cec9f11c --- /dev/null +++ b/cef/libcef_dll/cpptoc/proxy_handler_cpptoc.cc @@ -0,0 +1,66 @@ +// 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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/proxy_handler_cpptoc.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +void CEF_CALLBACK proxy_handler_get_proxy_for_url( + struct _cef_proxy_handler_t* self, const cef_string_t* url, + struct _cef_proxy_info_t* proxy_info) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: url; type: string_byref_const + DCHECK(url); + if (!url) + return; + // Verify param: proxy_info; type: struct_byref + DCHECK(proxy_info); + if (!proxy_info) + return; + + // Translate param: proxy_info; type: struct_byref + CefProxyInfo proxy_infoObj; + if (proxy_info) + proxy_infoObj.AttachTo(*proxy_info); + + // Execute + CefProxyHandlerCppToC::Get(self)->GetProxyForUrl( + CefString(url), + proxy_infoObj); + + // Restore param: proxy_info; type: struct_byref + if (proxy_info) + proxy_infoObj.DetachTo(*proxy_info); +} + + + +// CONSTRUCTOR - Do not edit by hand. + +CefProxyHandlerCppToC::CefProxyHandlerCppToC(CefProxyHandler* cls) + : CefCppToC( + cls) +{ + struct_.struct_.get_proxy_for_url = proxy_handler_get_proxy_for_url; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef/libcef_dll/cpptoc/proxy_handler_cpptoc.h b/cef/libcef_dll/cpptoc/proxy_handler_cpptoc.h new file mode 100755 index 000000000..edeb12440 --- /dev/null +++ b/cef/libcef_dll/cpptoc/proxy_handler_cpptoc.h @@ -0,0 +1,37 @@ +// Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights +// reserved. Use of this source code is governed by a BSD-style license that +// can be found in the LICENSE file. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef _PROXYHANDLER_CPPTOC_H +#define _PROXYHANDLER_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 CefProxyHandlerCppToC + : public CefCppToC +{ +public: + CefProxyHandlerCppToC(CefProxyHandler* cls); + virtual ~CefProxyHandlerCppToC() {} +}; + +#endif // USING_CEF_SHARED +#endif // _PROXYHANDLER_CPPTOC_H + diff --git a/cef/libcef_dll/cpptoc/read_handler_cpptoc.cc b/cef/libcef_dll/cpptoc/read_handler_cpptoc.cc new file mode 100755 index 000000000..80ac42639 --- /dev/null +++ b/cef/libcef_dll/cpptoc/read_handler_cpptoc.cc @@ -0,0 +1,109 @@ +// 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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/read_handler_cpptoc.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +size_t CEF_CALLBACK read_handler_read(struct _cef_read_handler_t* self, + void* ptr, size_t size, size_t n) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: ptr; type: simple_byaddr + DCHECK(ptr); + if (!ptr) + return 0; + + // Execute + size_t _retval = CefReadHandlerCppToC::Get(self)->Read( + ptr, + size, + n); + + // Return type: simple + return _retval; +} + + +int CEF_CALLBACK read_handler_seek(struct _cef_read_handler_t* self, + long offset, int whence) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + int _retval = CefReadHandlerCppToC::Get(self)->Seek( + offset, + whence); + + // Return type: simple + return _retval; +} + + +long CEF_CALLBACK read_handler_tell(struct _cef_read_handler_t* self) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + long _retval = CefReadHandlerCppToC::Get(self)->Tell(); + + // Return type: simple + return _retval; +} + + +int CEF_CALLBACK read_handler_eof(struct _cef_read_handler_t* self) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + int _retval = CefReadHandlerCppToC::Get(self)->Eof(); + + // Return type: simple + return _retval; +} + + + +// CONSTRUCTOR - Do not edit by hand. + +CefReadHandlerCppToC::CefReadHandlerCppToC(CefReadHandler* cls) + : CefCppToC(cls) +{ + struct_.struct_.read = read_handler_read; + struct_.struct_.seek = read_handler_seek; + struct_.struct_.tell = read_handler_tell; + struct_.struct_.eof = read_handler_eof; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef/libcef_dll/cpptoc/read_handler_cpptoc.h b/cef/libcef_dll/cpptoc/read_handler_cpptoc.h new file mode 100755 index 000000000..f45ca0db7 --- /dev/null +++ b/cef/libcef_dll/cpptoc/read_handler_cpptoc.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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef _READHANDLER_CPPTOC_H +#define _READHANDLER_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 CefReadHandlerCppToC + : public CefCppToC +{ +public: + CefReadHandlerCppToC(CefReadHandler* cls); + virtual ~CefReadHandlerCppToC() {} +}; + +#endif // USING_CEF_SHARED +#endif // _READHANDLER_CPPTOC_H + diff --git a/cef/libcef_dll/cpptoc/render_handler_cpptoc.cc b/cef/libcef_dll/cpptoc/render_handler_cpptoc.cc new file mode 100755 index 000000000..01d53d346 --- /dev/null +++ b/cef/libcef_dll/cpptoc/render_handler_cpptoc.cc @@ -0,0 +1,264 @@ +// 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. If making changes by +// hand only do so within the body of existing method and 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) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return 0; + // Verify param: rect; type: simple_byref + DCHECK(rect); + if (!rect) + return 0; + + // Translate param: rect; type: simple_byref + CefRect rectVal = rect?*rect:CefRect(); + + // Execute + bool _retval = CefRenderHandlerCppToC::Get(self)->GetViewRect( + CefBrowserCToCpp::Wrap(browser), + rectVal); + + // Restore param: rect; type: simple_byref + if (rect) + *rect = rectVal; + + // Return type: bool + return _retval; +} + + +int CEF_CALLBACK render_handler_get_screen_rect( + struct _cef_render_handler_t* self, cef_browser_t* browser, + cef_rect_t* rect) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return 0; + // Verify param: rect; type: simple_byref + DCHECK(rect); + if (!rect) + return 0; + + // Translate param: rect; type: simple_byref + CefRect rectVal = rect?*rect:CefRect(); + + // Execute + bool _retval = CefRenderHandlerCppToC::Get(self)->GetScreenRect( + CefBrowserCToCpp::Wrap(browser), + rectVal); + + // Restore param: rect; type: simple_byref + if (rect) + *rect = rectVal; + + // Return type: bool + return _retval; +} + + +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) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return 0; + // Verify param: screenX; type: simple_byref + DCHECK(screenX); + if (!screenX) + return 0; + // Verify param: screenY; type: simple_byref + DCHECK(screenY); + if (!screenY) + return 0; + + // Translate param: screenX; type: simple_byref + int screenXVal = screenX?*screenX:0; + // Translate param: screenY; type: simple_byref + int screenYVal = screenY?*screenY:0; + + // Execute + bool _retval = CefRenderHandlerCppToC::Get(self)->GetScreenPoint( + CefBrowserCToCpp::Wrap(browser), + viewX, + viewY, + screenXVal, + screenYVal); + + // Restore param: screenX; type: simple_byref + if (screenX) + *screenX = screenXVal; + // Restore param: screenY; type: simple_byref + if (screenY) + *screenY = screenYVal; + + // Return type: bool + return _retval; +} + + +void CEF_CALLBACK render_handler_on_popup_show( + struct _cef_render_handler_t* self, cef_browser_t* browser, int show) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return; + + // Execute + 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) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return; + // Verify param: rect; type: simple_byref_const + DCHECK(rect); + if (!rect) + return; + + // Translate param: rect; type: simple_byref_const + CefRect rectVal = rect?*rect:CefRect(); + + // Execute + CefRenderHandlerCppToC::Get(self)->OnPopupSize( + CefBrowserCToCpp::Wrap(browser), + rectVal); +} + + +void CEF_CALLBACK render_handler_on_paint(struct _cef_render_handler_t* self, + cef_browser_t* browser, enum cef_paint_element_type_t type, + size_t dirtyRectsCount, cef_rect_t const* dirtyRects, const void* buffer) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return; + // Verify param: dirtyRects; type: simple_vec_byref_const + DCHECK(dirtyRectsCount == 0 || dirtyRects); + if (dirtyRectsCount > 0 && !dirtyRects) + return; + // Verify param: buffer; type: simple_byaddr + DCHECK(buffer); + if (!buffer) + return; + + // Translate param: dirtyRects; type: simple_vec_byref_const + std::vector dirtyRectsList; + if (dirtyRectsCount > 0) { + for (size_t i = 0; i < dirtyRectsCount; ++i) { + dirtyRectsList.push_back(dirtyRects[i]); + } + } + + // Execute + CefRenderHandlerCppToC::Get(self)->OnPaint( + CefBrowserCToCpp::Wrap(browser), + type, + dirtyRectsList, + buffer); +} + + +void CEF_CALLBACK render_handler_on_cursor_change( + struct _cef_render_handler_t* self, cef_browser_t* browser, + cef_cursor_handle_t cursor) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return; + + // Execute + 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/cef/libcef_dll/cpptoc/render_handler_cpptoc.h b/cef/libcef_dll/cpptoc/render_handler_cpptoc.h new file mode 100755 index 000000000..1304e1198 --- /dev/null +++ b/cef/libcef_dll/cpptoc/render_handler_cpptoc.h @@ -0,0 +1,37 @@ +// Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights +// reserved. Use of this source code is governed by a BSD-style license that +// can be found in the LICENSE file. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. 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/cef/libcef_dll/cpptoc/request_handler_cpptoc.cc b/cef/libcef_dll/cpptoc/request_handler_cpptoc.cc new file mode 100755 index 000000000..4fe94fe21 --- /dev/null +++ b/cef/libcef_dll/cpptoc/request_handler_cpptoc.cc @@ -0,0 +1,385 @@ +// 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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/content_filter_cpptoc.h" +#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) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return 0; + // Verify param: frame; type: refptr_diff + DCHECK(frame); + if (!frame) + return 0; + // Verify param: request; type: refptr_diff + DCHECK(request); + if (!request) + return 0; + + // Execute + bool _retval = CefRequestHandlerCppToC::Get(self)->OnBeforeBrowse( + CefBrowserCToCpp::Wrap(browser), + CefFrameCToCpp::Wrap(frame), + CefRequestCToCpp::Wrap(request), + navType, + isRedirect?true:false); + + // Return type: bool + return _retval; +} + + +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) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return 0; + // Verify param: request; type: refptr_diff + DCHECK(request); + if (!request) + return 0; + // Verify param: redirectUrl; type: string_byref + DCHECK(redirectUrl); + if (!redirectUrl) + return 0; + // Verify param: resourceStream; type: refptr_diff_byref + DCHECK(resourceStream); + if (!resourceStream) + return 0; + // Verify param: response; type: refptr_diff + DCHECK(response); + if (!response) + return 0; + + // Translate param: redirectUrl; type: string_byref + CefString redirectUrlStr(redirectUrl); + // Translate param: resourceStream; type: refptr_diff_byref + CefRefPtr resourceStreamPtr; + if (resourceStream && *resourceStream) + resourceStreamPtr = CefStreamReaderCToCpp::Wrap(*resourceStream); + CefStreamReader* resourceStreamOrig = resourceStreamPtr.get(); + + // Execute + bool _retval = CefRequestHandlerCppToC::Get(self)->OnBeforeResourceLoad( + CefBrowserCToCpp::Wrap(browser), + CefRequestCToCpp::Wrap(request), + redirectUrlStr, + resourceStreamPtr, + CefResponseCToCpp::Wrap(response), + loadFlags); + + // Restore param: resourceStream; type: refptr_diff_byref + if (resourceStream) { + if (resourceStreamPtr.get()) { + if (resourceStreamPtr.get() != resourceStreamOrig) { + *resourceStream = CefStreamReaderCToCpp::Unwrap(resourceStreamPtr); + } + } else { + *resourceStream = NULL; + } + } + + // Return type: bool + return _retval; +} + + +void CEF_CALLBACK request_handler_on_resource_redirect( + struct _cef_request_handler_t* self, cef_browser_t* browser, + const cef_string_t* old_url, cef_string_t* new_url) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return; + // Verify param: old_url; type: string_byref_const + DCHECK(old_url); + if (!old_url) + return; + // Verify param: new_url; type: string_byref + DCHECK(new_url); + if (!new_url) + return; + + // Translate param: new_url; type: string_byref + CefString new_urlStr(new_url); + + // Execute + CefRequestHandlerCppToC::Get(self)->OnResourceRedirect( + CefBrowserCToCpp::Wrap(browser), + CefString(old_url), + new_urlStr); +} + + +void CEF_CALLBACK request_handler_on_resource_response( + struct _cef_request_handler_t* self, cef_browser_t* browser, + const cef_string_t* url, struct _cef_response_t* response, + struct _cef_content_filter_t** filter) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return; + // Verify param: url; type: string_byref_const + DCHECK(url); + if (!url) + return; + // Verify param: response; type: refptr_diff + DCHECK(response); + if (!response) + return; + // Verify param: filter; type: refptr_same_byref + DCHECK(filter); + if (!filter) + return; + + // Translate param: filter; type: refptr_same_byref + CefRefPtr filterPtr; + if (filter && *filter) + filterPtr = CefContentFilterCppToC::Unwrap(*filter); + CefContentFilter* filterOrig = filterPtr.get(); + + // Execute + CefRequestHandlerCppToC::Get(self)->OnResourceResponse( + CefBrowserCToCpp::Wrap(browser), + CefString(url), + CefResponseCToCpp::Wrap(response), + filterPtr); + + // Restore param: filter; type: refptr_same_byref + if (filter) { + if (filterPtr.get()) { + if (filterPtr.get() != filterOrig) { + *filter = CefContentFilterCppToC::Wrap(filterPtr); + } + } else { + *filter = NULL; + } + } +} + + +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) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return 0; + // Verify param: url; type: string_byref_const + DCHECK(url); + if (!url) + return 0; + // Verify param: allowOSExecution; type: bool_byref + DCHECK(allowOSExecution); + if (!allowOSExecution) + return 0; + + // Translate param: allowOSExecution; type: bool_byref + bool allowOSExecutionBool = ( + allowOSExecution && *allowOSExecution)?true:false; + + // Execute + bool _retval = CefRequestHandlerCppToC::Get(self)->OnProtocolExecution( + CefBrowserCToCpp::Wrap(browser), + CefString(url), + allowOSExecutionBool); + + // Restore param: allowOSExecution; type: bool_byref + if (allowOSExecution) + *allowOSExecution = allowOSExecutionBool?true:false; + + // Return type: bool + return _retval; +} + + +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) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return 0; + // Verify param: mimeType; type: string_byref_const + DCHECK(mimeType); + if (!mimeType) + return 0; + // Verify param: fileName; type: string_byref_const + DCHECK(fileName); + if (!fileName) + return 0; + // Verify param: handler; type: refptr_same_byref + DCHECK(handler); + if (!handler) + return 0; + + // Translate param: handler; type: refptr_same_byref + CefRefPtr handlerPtr; + if (handler && *handler) + handlerPtr = CefDownloadHandlerCppToC::Unwrap(*handler); + CefDownloadHandler* handlerOrig = handlerPtr.get(); + + // Execute + bool _retval = CefRequestHandlerCppToC::Get(self)->GetDownloadHandler( + CefBrowserCToCpp::Wrap(browser), + CefString(mimeType), + CefString(fileName), + contentLength, + handlerPtr); + + // Restore param: handler; type: refptr_same_byref + if (handler) { + if (handlerPtr.get()) { + if (handlerPtr.get() != handlerOrig) { + *handler = CefDownloadHandlerCppToC::Wrap(handlerPtr); + } + } else { + *handler = NULL; + } + } + + // Return type: bool + return _retval; +} + + +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, int port, const cef_string_t* realm, + const cef_string_t* scheme, cef_string_t* username, + cef_string_t* password) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return 0; + // Verify param: host; type: string_byref_const + DCHECK(host); + if (!host) + return 0; + // Verify param: scheme; type: string_byref_const + DCHECK(scheme); + if (!scheme) + return 0; + // Verify param: username; type: string_byref + DCHECK(username); + if (!username) + return 0; + // Verify param: password; type: string_byref + DCHECK(password); + if (!password) + return 0; + // Unverified params: realm + + // Translate param: username; type: string_byref + CefString usernameStr(username); + // Translate param: password; type: string_byref + CefString passwordStr(password); + + // Execute + bool _retval = CefRequestHandlerCppToC::Get(self)->GetAuthCredentials( + CefBrowserCToCpp::Wrap(browser), + isProxy?true:false, + CefString(host), + port, + CefString(realm), + CefString(scheme), + usernameStr, + passwordStr); + + // Return type: bool + return _retval; +} + + + +// 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_resource_redirect = request_handler_on_resource_redirect; + struct_.struct_.on_resource_response = request_handler_on_resource_response; + 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/cef/libcef_dll/cpptoc/request_handler_cpptoc.h b/cef/libcef_dll/cpptoc/request_handler_cpptoc.h new file mode 100755 index 000000000..d61d80a53 --- /dev/null +++ b/cef/libcef_dll/cpptoc/request_handler_cpptoc.h @@ -0,0 +1,37 @@ +// Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights +// reserved. Use of this source code is governed by a BSD-style license that +// can be found in the LICENSE file. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. 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/cef/libcef_dll/cpptoc/scheme_handler_cpptoc.cc b/cef/libcef_dll/cpptoc/scheme_handler_cpptoc.cc new file mode 100755 index 000000000..9746185c3 --- /dev/null +++ b/cef/libcef_dll/cpptoc/scheme_handler_cpptoc.cc @@ -0,0 +1,159 @@ +// 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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/scheme_handler_cpptoc.h" +#include "libcef_dll/ctocpp/request_ctocpp.h" +#include "libcef_dll/ctocpp/response_ctocpp.h" +#include "libcef_dll/ctocpp/scheme_handler_callback_ctocpp.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +int CEF_CALLBACK scheme_handler_process_request( + struct _cef_scheme_handler_t* self, cef_request_t* request, + cef_scheme_handler_callback_t* callback) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: request; type: refptr_diff + DCHECK(request); + if (!request) + return 0; + // Verify param: callback; type: refptr_diff + DCHECK(callback); + if (!callback) + return 0; + + // Execute + bool _retval = CefSchemeHandlerCppToC::Get(self)->ProcessRequest( + CefRequestCToCpp::Wrap(request), + CefSchemeHandlerCallbackCToCpp::Wrap(callback)); + + // Return type: bool + return _retval; +} + + +void CEF_CALLBACK scheme_handler_get_response_headers( + struct _cef_scheme_handler_t* self, cef_response_t* response, + int64* response_length, cef_string_t* redirectUrl) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: response; type: refptr_diff + DCHECK(response); + if (!response) + return; + // Verify param: response_length; type: simple_byref + DCHECK(response_length); + if (!response_length) + return; + // Verify param: redirectUrl; type: string_byref + DCHECK(redirectUrl); + if (!redirectUrl) + return; + + // Translate param: response_length; type: simple_byref + int64 response_lengthVal = response_length?*response_length:0; + // Translate param: redirectUrl; type: string_byref + CefString redirectUrlStr(redirectUrl); + + // Execute + CefSchemeHandlerCppToC::Get(self)->GetResponseHeaders( + CefResponseCToCpp::Wrap(response), + response_lengthVal, + redirectUrlStr); + + // Restore param: response_length; type: simple_byref + if (response_length) + *response_length = response_lengthVal; +} + + +int CEF_CALLBACK scheme_handler_read_response( + struct _cef_scheme_handler_t* self, void* data_out, int bytes_to_read, + int* bytes_read, cef_scheme_handler_callback_t* callback) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: data_out; type: simple_byaddr + DCHECK(data_out); + if (!data_out) + return 0; + // Verify param: bytes_read; type: simple_byref + DCHECK(bytes_read); + if (!bytes_read) + return 0; + // Verify param: callback; type: refptr_diff + DCHECK(callback); + if (!callback) + return 0; + + // Translate param: bytes_read; type: simple_byref + int bytes_readVal = bytes_read?*bytes_read:0; + + // Execute + bool _retval = CefSchemeHandlerCppToC::Get(self)->ReadResponse( + data_out, + bytes_to_read, + bytes_readVal, + CefSchemeHandlerCallbackCToCpp::Wrap(callback)); + + // Restore param: bytes_read; type: simple_byref + if (bytes_read) + *bytes_read = bytes_readVal; + + // Return type: bool + return _retval; +} + + +void CEF_CALLBACK scheme_handler_cancel(struct _cef_scheme_handler_t* self) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + + // Execute + CefSchemeHandlerCppToC::Get(self)->Cancel(); +} + + + +// CONSTRUCTOR - Do not edit by hand. + +CefSchemeHandlerCppToC::CefSchemeHandlerCppToC(CefSchemeHandler* cls) + : CefCppToC( + cls) +{ + struct_.struct_.process_request = scheme_handler_process_request; + struct_.struct_.get_response_headers = scheme_handler_get_response_headers; + struct_.struct_.read_response = scheme_handler_read_response; + struct_.struct_.cancel = scheme_handler_cancel; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef/libcef_dll/cpptoc/scheme_handler_cpptoc.h b/cef/libcef_dll/cpptoc/scheme_handler_cpptoc.h new file mode 100755 index 000000000..3dc7f55e4 --- /dev/null +++ b/cef/libcef_dll/cpptoc/scheme_handler_cpptoc.h @@ -0,0 +1,37 @@ +// Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights +// reserved. Use of this source code is governed by a BSD-style license that +// can be found in the LICENSE file. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef _SCHEMEHANDLER_CPPTOC_H +#define _SCHEMEHANDLER_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 CefSchemeHandlerCppToC + : public CefCppToC +{ +public: + CefSchemeHandlerCppToC(CefSchemeHandler* cls); + virtual ~CefSchemeHandlerCppToC() {} +}; + +#endif // USING_CEF_SHARED +#endif // _SCHEMEHANDLER_CPPTOC_H + diff --git a/cef/libcef_dll/cpptoc/scheme_handler_factory_cpptoc.cc b/cef/libcef_dll/cpptoc/scheme_handler_factory_cpptoc.cc new file mode 100755 index 000000000..cb18538e7 --- /dev/null +++ b/cef/libcef_dll/cpptoc/scheme_handler_factory_cpptoc.cc @@ -0,0 +1,70 @@ +// 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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/scheme_handler_cpptoc.h" +#include "libcef_dll/cpptoc/scheme_handler_factory_cpptoc.h" +#include "libcef_dll/ctocpp/browser_ctocpp.h" +#include "libcef_dll/ctocpp/request_ctocpp.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +struct _cef_scheme_handler_t* CEF_CALLBACK scheme_handler_factory_create( + struct _cef_scheme_handler_factory_t* self, cef_browser_t* browser, + const cef_string_t* scheme_name, cef_request_t* request) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return NULL; + // Verify param: scheme_name; type: string_byref_const + DCHECK(scheme_name); + if (!scheme_name) + return NULL; + // Verify param: request; type: refptr_diff + DCHECK(request); + if (!request) + return NULL; + + // Execute + CefRefPtr _retval = CefSchemeHandlerFactoryCppToC::Get( + self)->Create( + CefBrowserCToCpp::Wrap(browser), + CefString(scheme_name), + CefRequestCToCpp::Wrap(request)); + + // Return type: refptr_same + return CefSchemeHandlerCppToC::Wrap(_retval); +} + + + +// CONSTRUCTOR - Do not edit by hand. + +CefSchemeHandlerFactoryCppToC::CefSchemeHandlerFactoryCppToC( + CefSchemeHandlerFactory* cls) + : CefCppToC(cls) +{ + struct_.struct_.create = scheme_handler_factory_create; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef/libcef_dll/cpptoc/scheme_handler_factory_cpptoc.h b/cef/libcef_dll/cpptoc/scheme_handler_factory_cpptoc.h new file mode 100755 index 000000000..f2d8fcc5d --- /dev/null +++ b/cef/libcef_dll/cpptoc/scheme_handler_factory_cpptoc.h @@ -0,0 +1,37 @@ +// Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights +// reserved. Use of this source code is governed by a BSD-style license that +// can be found in the LICENSE file. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef _SCHEMEHANDLERFACTORY_CPPTOC_H +#define _SCHEMEHANDLERFACTORY_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 CefSchemeHandlerFactoryCppToC + : public CefCppToC +{ +public: + CefSchemeHandlerFactoryCppToC(CefSchemeHandlerFactory* cls); + virtual ~CefSchemeHandlerFactoryCppToC() {} +}; + +#endif // USING_CEF_SHARED +#endif // _SCHEMEHANDLERFACTORY_CPPTOC_H + diff --git a/cef/libcef_dll/cpptoc/storage_visitor_cpptoc.cc b/cef/libcef_dll/cpptoc/storage_visitor_cpptoc.cc new file mode 100755 index 000000000..ca2f5b4d2 --- /dev/null +++ b/cef/libcef_dll/cpptoc/storage_visitor_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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/storage_visitor_cpptoc.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +int CEF_CALLBACK storage_visitor_visit(struct _cef_storage_visitor_t* self, + enum cef_storage_type_t type, const cef_string_t* origin, + const cef_string_t* key, const cef_string_t* value, int count, int total, + int* deleteData) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: origin; type: string_byref_const + DCHECK(origin); + if (!origin) + return 0; + // Verify param: key; type: string_byref_const + DCHECK(key); + if (!key) + return 0; + // Verify param: value; type: string_byref_const + DCHECK(value); + if (!value) + return 0; + // Verify param: deleteData; type: bool_byref + DCHECK(deleteData); + if (!deleteData) + return 0; + + // Translate param: deleteData; type: bool_byref + bool deleteDataBool = (deleteData && *deleteData)?true:false; + + // Execute + bool _retval = CefStorageVisitorCppToC::Get(self)->Visit( + type, + CefString(origin), + CefString(key), + CefString(value), + count, + total, + deleteDataBool); + + // Restore param: deleteData; type: bool_byref + if (deleteData) + *deleteData = deleteDataBool?true:false; + + // Return type: bool + return _retval; +} + + + +// CONSTRUCTOR - Do not edit by hand. + +CefStorageVisitorCppToC::CefStorageVisitorCppToC(CefStorageVisitor* cls) + : CefCppToC(cls) +{ + struct_.struct_.visit = storage_visitor_visit; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef/libcef_dll/cpptoc/storage_visitor_cpptoc.h b/cef/libcef_dll/cpptoc/storage_visitor_cpptoc.h new file mode 100755 index 000000000..a90b23830 --- /dev/null +++ b/cef/libcef_dll/cpptoc/storage_visitor_cpptoc.h @@ -0,0 +1,37 @@ +// Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights +// reserved. Use of this source code is governed by a BSD-style license that +// can be found in the LICENSE file. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef _STORAGEVISITOR_CPPTOC_H +#define _STORAGEVISITOR_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 CefStorageVisitorCppToC + : public CefCppToC +{ +public: + CefStorageVisitorCppToC(CefStorageVisitor* cls); + virtual ~CefStorageVisitorCppToC() {} +}; + +#endif // USING_CEF_SHARED +#endif // _STORAGEVISITOR_CPPTOC_H + diff --git a/cef/libcef_dll/cpptoc/task_cpptoc.cc b/cef/libcef_dll/cpptoc/task_cpptoc.cc new file mode 100755 index 000000000..3b6c6051d --- /dev/null +++ b/cef/libcef_dll/cpptoc/task_cpptoc.cc @@ -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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/task_cpptoc.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +void CEF_CALLBACK task_execute(struct _cef_task_t* self, + cef_thread_id_t threadId) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + + // Execute + CefTaskCppToC::Get(self)->Execute( + threadId); +} + + + +// CONSTRUCTOR - Do not edit by hand. + +CefTaskCppToC::CefTaskCppToC(CefTask* cls) + : CefCppToC(cls) +{ + struct_.struct_.execute = task_execute; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef/libcef_dll/cpptoc/task_cpptoc.h b/cef/libcef_dll/cpptoc/task_cpptoc.h new file mode 100755 index 000000000..d29d8ec9e --- /dev/null +++ b/cef/libcef_dll/cpptoc/task_cpptoc.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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef _TASK_CPPTOC_H +#define _TASK_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 CefTaskCppToC + : public CefCppToC +{ +public: + CefTaskCppToC(CefTask* cls); + virtual ~CefTaskCppToC() {} +}; + +#endif // USING_CEF_SHARED +#endif // _TASK_CPPTOC_H + diff --git a/cef/libcef_dll/cpptoc/v8accessor_cpptoc.cc b/cef/libcef_dll/cpptoc/v8accessor_cpptoc.cc new file mode 100755 index 000000000..4186ecd66 --- /dev/null +++ b/cef/libcef_dll/cpptoc/v8accessor_cpptoc.cc @@ -0,0 +1,131 @@ +// 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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/v8accessor_cpptoc.h" +#include "libcef_dll/ctocpp/v8value_ctocpp.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +int CEF_CALLBACK v8accessor_get(struct _cef_v8accessor_t* self, + const cef_string_t* name, struct _cef_v8value_t* object, + struct _cef_v8value_t** retval, cef_string_t* exception) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: name; type: string_byref_const + DCHECK(name); + if (!name) + return 0; + // Verify param: object; type: refptr_diff + DCHECK(object); + if (!object) + return 0; + // Verify param: retval; type: refptr_diff_byref + DCHECK(retval); + if (!retval) + return 0; + // Verify param: exception; type: string_byref + DCHECK(exception); + if (!exception) + return 0; + + // Translate param: retval; type: refptr_diff_byref + CefRefPtr retvalPtr; + if (retval && *retval) + retvalPtr = CefV8ValueCToCpp::Wrap(*retval); + CefV8Value* retvalOrig = retvalPtr.get(); + // Translate param: exception; type: string_byref + CefString exceptionStr(exception); + + // Execute + bool _retval = CefV8AccessorCppToC::Get(self)->Get( + CefString(name), + CefV8ValueCToCpp::Wrap(object), + retvalPtr, + exceptionStr); + + // Restore param: retval; type: refptr_diff_byref + if (retval) { + if (retvalPtr.get()) { + if (retvalPtr.get() != retvalOrig) { + *retval = CefV8ValueCToCpp::Unwrap(retvalPtr); + } + } else { + *retval = NULL; + } + } + + // Return type: bool + return _retval; +} + + +int CEF_CALLBACK v8accessor_set(struct _cef_v8accessor_t* self, + const cef_string_t* name, struct _cef_v8value_t* object, + struct _cef_v8value_t* value, cef_string_t* exception) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: name; type: string_byref_const + DCHECK(name); + if (!name) + return 0; + // Verify param: object; type: refptr_diff + DCHECK(object); + if (!object) + return 0; + // Verify param: value; type: refptr_diff + DCHECK(value); + if (!value) + return 0; + // Verify param: exception; type: string_byref + DCHECK(exception); + if (!exception) + return 0; + + // Translate param: exception; type: string_byref + CefString exceptionStr(exception); + + // Execute + bool _retval = CefV8AccessorCppToC::Get(self)->Set( + CefString(name), + CefV8ValueCToCpp::Wrap(object), + CefV8ValueCToCpp::Wrap(value), + exceptionStr); + + // Return type: bool + return _retval; +} + + + +// CONSTRUCTOR - Do not edit by hand. + +CefV8AccessorCppToC::CefV8AccessorCppToC(CefV8Accessor* cls) + : CefCppToC(cls) +{ + struct_.struct_.get = v8accessor_get; + struct_.struct_.set = v8accessor_set; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef/libcef_dll/cpptoc/v8accessor_cpptoc.h b/cef/libcef_dll/cpptoc/v8accessor_cpptoc.h new file mode 100755 index 000000000..fe8a09422 --- /dev/null +++ b/cef/libcef_dll/cpptoc/v8accessor_cpptoc.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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef _V8ACCESSOR_CPPTOC_H +#define _V8ACCESSOR_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 CefV8AccessorCppToC + : public CefCppToC +{ +public: + CefV8AccessorCppToC(CefV8Accessor* cls); + virtual ~CefV8AccessorCppToC() {} +}; + +#endif // USING_CEF_SHARED +#endif // _V8ACCESSOR_CPPTOC_H + diff --git a/cef/libcef_dll/cpptoc/v8context_handler_cpptoc.cc b/cef/libcef_dll/cpptoc/v8context_handler_cpptoc.cc new file mode 100755 index 000000000..6b5a3617e --- /dev/null +++ b/cef/libcef_dll/cpptoc/v8context_handler_cpptoc.cc @@ -0,0 +1,96 @@ +// 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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/v8context_handler_cpptoc.h" +#include "libcef_dll/ctocpp/browser_ctocpp.h" +#include "libcef_dll/ctocpp/frame_ctocpp.h" +#include "libcef_dll/ctocpp/v8context_ctocpp.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +void CEF_CALLBACK v8context_handler_on_context_created( + struct _cef_v8context_handler_t* self, cef_browser_t* browser, + cef_frame_t* frame, struct _cef_v8context_t* context) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return; + // Verify param: frame; type: refptr_diff + DCHECK(frame); + if (!frame) + return; + // Verify param: context; type: refptr_diff + DCHECK(context); + if (!context) + return; + + // Execute + CefV8ContextHandlerCppToC::Get(self)->OnContextCreated( + CefBrowserCToCpp::Wrap(browser), + CefFrameCToCpp::Wrap(frame), + CefV8ContextCToCpp::Wrap(context)); +} + + +void CEF_CALLBACK v8context_handler_on_context_released( + struct _cef_v8context_handler_t* self, cef_browser_t* browser, + cef_frame_t* frame, struct _cef_v8context_t* context) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return; + // Verify param: frame; type: refptr_diff + DCHECK(frame); + if (!frame) + return; + // Verify param: context; type: refptr_diff + DCHECK(context); + if (!context) + return; + + // Execute + CefV8ContextHandlerCppToC::Get(self)->OnContextReleased( + CefBrowserCToCpp::Wrap(browser), + CefFrameCToCpp::Wrap(frame), + CefV8ContextCToCpp::Wrap(context)); +} + + + +// CONSTRUCTOR - Do not edit by hand. + +CefV8ContextHandlerCppToC::CefV8ContextHandlerCppToC(CefV8ContextHandler* cls) + : CefCppToC(cls) +{ + struct_.struct_.on_context_created = v8context_handler_on_context_created; + struct_.struct_.on_context_released = v8context_handler_on_context_released; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef/libcef_dll/cpptoc/v8context_handler_cpptoc.h b/cef/libcef_dll/cpptoc/v8context_handler_cpptoc.h new file mode 100755 index 000000000..e5c862890 --- /dev/null +++ b/cef/libcef_dll/cpptoc/v8context_handler_cpptoc.h @@ -0,0 +1,37 @@ +// Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights +// reserved. Use of this source code is governed by a BSD-style license that +// can be found in the LICENSE file. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef _V8CONTEXTHANDLER_CPPTOC_H +#define _V8CONTEXTHANDLER_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 CefV8ContextHandlerCppToC + : public CefCppToC +{ +public: + CefV8ContextHandlerCppToC(CefV8ContextHandler* cls); + virtual ~CefV8ContextHandlerCppToC() {} +}; + +#endif // USING_CEF_SHARED +#endif // _V8CONTEXTHANDLER_CPPTOC_H + diff --git a/cef/libcef_dll/cpptoc/v8handler_cpptoc.cc b/cef/libcef_dll/cpptoc/v8handler_cpptoc.cc new file mode 100755 index 000000000..d19a271de --- /dev/null +++ b/cef/libcef_dll/cpptoc/v8handler_cpptoc.cc @@ -0,0 +1,102 @@ +// 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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/v8handler_cpptoc.h" +#include "libcef_dll/ctocpp/v8value_ctocpp.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +int CEF_CALLBACK v8handler_execute(struct _cef_v8handler_t* self, + const cef_string_t* name, struct _cef_v8value_t* object, + size_t argumentsCount, struct _cef_v8value_t* const* arguments, + struct _cef_v8value_t** retval, cef_string_t* exception) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: name; type: string_byref_const + DCHECK(name); + if (!name) + return 0; + // Verify param: object; type: refptr_diff + DCHECK(object); + if (!object) + return 0; + // Verify param: arguments; type: refptr_vec_diff_byref_const + DCHECK(argumentsCount == 0 || arguments); + if (argumentsCount > 0 && !arguments) + return 0; + // Verify param: retval; type: refptr_diff_byref + DCHECK(retval); + if (!retval) + return 0; + // Verify param: exception; type: string_byref + DCHECK(exception); + if (!exception) + return 0; + + // Translate param: arguments; type: refptr_vec_diff_byref_const + std::vector > argumentsList; + if (argumentsCount > 0) { + for (size_t i = 0; i < argumentsCount; ++i) { + argumentsList.push_back(CefV8ValueCToCpp::Wrap(arguments[i])); + } + } + // Translate param: retval; type: refptr_diff_byref + CefRefPtr retvalPtr; + if (retval && *retval) + retvalPtr = CefV8ValueCToCpp::Wrap(*retval); + CefV8Value* retvalOrig = retvalPtr.get(); + // Translate param: exception; type: string_byref + CefString exceptionStr(exception); + + // Execute + bool _retval = CefV8HandlerCppToC::Get(self)->Execute( + CefString(name), + CefV8ValueCToCpp::Wrap(object), + argumentsList, + retvalPtr, + exceptionStr); + + // Restore param: retval; type: refptr_diff_byref + if (retval) { + if (retvalPtr.get()) { + if (retvalPtr.get() != retvalOrig) { + *retval = CefV8ValueCToCpp::Unwrap(retvalPtr); + } + } else { + *retval = NULL; + } + } + + // Return type: bool + return _retval; +} + + + +// CONSTRUCTOR - Do not edit by hand. + +CefV8HandlerCppToC::CefV8HandlerCppToC(CefV8Handler* cls) + : CefCppToC(cls) +{ + struct_.struct_.execute = v8handler_execute; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef/libcef_dll/cpptoc/v8handler_cpptoc.h b/cef/libcef_dll/cpptoc/v8handler_cpptoc.h new file mode 100755 index 000000000..995232229 --- /dev/null +++ b/cef/libcef_dll/cpptoc/v8handler_cpptoc.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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef _V8HANDLER_CPPTOC_H +#define _V8HANDLER_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 CefV8HandlerCppToC + : public CefCppToC +{ +public: + CefV8HandlerCppToC(CefV8Handler* cls); + virtual ~CefV8HandlerCppToC() {} +}; + +#endif // USING_CEF_SHARED +#endif // _V8HANDLER_CPPTOC_H + diff --git a/cef/libcef_dll/cpptoc/web_urlrequest_client_cpptoc.cc b/cef/libcef_dll/cpptoc/web_urlrequest_client_cpptoc.cc new file mode 100755 index 000000000..377d1a194 --- /dev/null +++ b/cef/libcef_dll/cpptoc/web_urlrequest_client_cpptoc.cc @@ -0,0 +1,187 @@ +// 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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/web_urlrequest_client_cpptoc.h" +#include "libcef_dll/ctocpp/request_ctocpp.h" +#include "libcef_dll/ctocpp/response_ctocpp.h" +#include "libcef_dll/ctocpp/web_urlrequest_ctocpp.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +void CEF_CALLBACK web_urlrequest_client_on_state_change( + struct _cef_web_urlrequest_client_t* self, cef_web_urlrequest_t* requester, + enum cef_weburlrequest_state_t state) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: requester; type: refptr_diff + DCHECK(requester); + if (!requester) + return; + + // Execute + CefWebURLRequestClientCppToC::Get(self)->OnStateChange( + CefWebURLRequestCToCpp::Wrap(requester), + state); +} + + +void CEF_CALLBACK web_urlrequest_client_on_redirect( + struct _cef_web_urlrequest_client_t* self, cef_web_urlrequest_t* requester, + cef_request_t* request, cef_response_t* response) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: requester; type: refptr_diff + DCHECK(requester); + if (!requester) + return; + // Verify param: request; type: refptr_diff + DCHECK(request); + if (!request) + return; + // Verify param: response; type: refptr_diff + DCHECK(response); + if (!response) + return; + + // Execute + CefWebURLRequestClientCppToC::Get(self)->OnRedirect( + CefWebURLRequestCToCpp::Wrap(requester), + CefRequestCToCpp::Wrap(request), + CefResponseCToCpp::Wrap(response)); +} + + +void CEF_CALLBACK web_urlrequest_client_on_headers_received( + struct _cef_web_urlrequest_client_t* self, cef_web_urlrequest_t* requester, + cef_response_t* response) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: requester; type: refptr_diff + DCHECK(requester); + if (!requester) + return; + // Verify param: response; type: refptr_diff + DCHECK(response); + if (!response) + return; + + // Execute + CefWebURLRequestClientCppToC::Get(self)->OnHeadersReceived( + CefWebURLRequestCToCpp::Wrap(requester), + CefResponseCToCpp::Wrap(response)); +} + + +void CEF_CALLBACK web_urlrequest_client_on_progress( + struct _cef_web_urlrequest_client_t* self, cef_web_urlrequest_t* requester, + uint64 bytesSent, uint64 totalBytesToBeSent) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: requester; type: refptr_diff + DCHECK(requester); + if (!requester) + return; + + // Execute + CefWebURLRequestClientCppToC::Get(self)->OnProgress( + CefWebURLRequestCToCpp::Wrap(requester), + bytesSent, + totalBytesToBeSent); +} + + +void CEF_CALLBACK web_urlrequest_client_on_data( + struct _cef_web_urlrequest_client_t* self, cef_web_urlrequest_t* requester, + const void* data, int dataLength) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: requester; type: refptr_diff + DCHECK(requester); + if (!requester) + return; + // Verify param: data; type: simple_byaddr + DCHECK(data); + if (!data) + return; + + // Execute + CefWebURLRequestClientCppToC::Get(self)->OnData( + CefWebURLRequestCToCpp::Wrap(requester), + data, + dataLength); +} + + +void CEF_CALLBACK web_urlrequest_client_on_error( + struct _cef_web_urlrequest_client_t* self, cef_web_urlrequest_t* requester, + enum cef_handler_errorcode_t errorCode) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: requester; type: refptr_diff + DCHECK(requester); + if (!requester) + return; + + // Execute + CefWebURLRequestClientCppToC::Get(self)->OnError( + CefWebURLRequestCToCpp::Wrap(requester), + errorCode); +} + + + +// CONSTRUCTOR - Do not edit by hand. + +CefWebURLRequestClientCppToC::CefWebURLRequestClientCppToC( + CefWebURLRequestClient* cls) + : CefCppToC(cls) +{ + struct_.struct_.on_state_change = web_urlrequest_client_on_state_change; + struct_.struct_.on_redirect = web_urlrequest_client_on_redirect; + struct_.struct_.on_headers_received = + web_urlrequest_client_on_headers_received; + struct_.struct_.on_progress = web_urlrequest_client_on_progress; + struct_.struct_.on_data = web_urlrequest_client_on_data; + struct_.struct_.on_error = web_urlrequest_client_on_error; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef/libcef_dll/cpptoc/web_urlrequest_client_cpptoc.h b/cef/libcef_dll/cpptoc/web_urlrequest_client_cpptoc.h new file mode 100755 index 000000000..7d891b0d8 --- /dev/null +++ b/cef/libcef_dll/cpptoc/web_urlrequest_client_cpptoc.h @@ -0,0 +1,37 @@ +// Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights +// reserved. Use of this source code is governed by a BSD-style license that +// can be found in the LICENSE file. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef _WEBURLREQUESTCLIENT_CPPTOC_H +#define _WEBURLREQUESTCLIENT_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 CefWebURLRequestClientCppToC + : public CefCppToC +{ +public: + CefWebURLRequestClientCppToC(CefWebURLRequestClient* cls); + virtual ~CefWebURLRequestClientCppToC() {} +}; + +#endif // USING_CEF_SHARED +#endif // _WEBURLREQUESTCLIENT_CPPTOC_H + diff --git a/cef/libcef_dll/cpptoc/write_handler_cpptoc.cc b/cef/libcef_dll/cpptoc/write_handler_cpptoc.cc new file mode 100755 index 000000000..901db462b --- /dev/null +++ b/cef/libcef_dll/cpptoc/write_handler_cpptoc.cc @@ -0,0 +1,110 @@ +// 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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/write_handler_cpptoc.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +size_t CEF_CALLBACK write_handler_write(struct _cef_write_handler_t* self, + const void* ptr, size_t size, size_t n) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: ptr; type: simple_byaddr + DCHECK(ptr); + if (!ptr) + return 0; + + // Execute + size_t _retval = CefWriteHandlerCppToC::Get(self)->Write( + ptr, + size, + n); + + // Return type: simple + return _retval; +} + + +int CEF_CALLBACK write_handler_seek(struct _cef_write_handler_t* self, + long offset, int whence) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + int _retval = CefWriteHandlerCppToC::Get(self)->Seek( + offset, + whence); + + // Return type: simple + return _retval; +} + + +long CEF_CALLBACK write_handler_tell(struct _cef_write_handler_t* self) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + long _retval = CefWriteHandlerCppToC::Get(self)->Tell(); + + // Return type: simple + return _retval; +} + + +int CEF_CALLBACK write_handler_flush(struct _cef_write_handler_t* self) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + int _retval = CefWriteHandlerCppToC::Get(self)->Flush(); + + // Return type: simple + return _retval; +} + + + +// CONSTRUCTOR - Do not edit by hand. + +CefWriteHandlerCppToC::CefWriteHandlerCppToC(CefWriteHandler* cls) + : CefCppToC( + cls) +{ + struct_.struct_.write = write_handler_write; + struct_.struct_.seek = write_handler_seek; + struct_.struct_.tell = write_handler_tell; + struct_.struct_.flush = write_handler_flush; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/cef/libcef_dll/cpptoc/write_handler_cpptoc.h b/cef/libcef_dll/cpptoc/write_handler_cpptoc.h new file mode 100755 index 000000000..30e032e8b --- /dev/null +++ b/cef/libcef_dll/cpptoc/write_handler_cpptoc.h @@ -0,0 +1,37 @@ +// Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights +// reserved. Use of this source code is governed by a BSD-style license that +// can be found in the LICENSE file. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef _WRITEHANDLER_CPPTOC_H +#define _WRITEHANDLER_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 CefWriteHandlerCppToC + : public CefCppToC +{ +public: + CefWriteHandlerCppToC(CefWriteHandler* cls); + virtual ~CefWriteHandlerCppToC() {} +}; + +#endif // USING_CEF_SHARED +#endif // _WRITEHANDLER_CPPTOC_H + diff --git a/cef/libcef_dll/ctocpp/base_ctocpp.h b/cef/libcef_dll/ctocpp/base_ctocpp.h new file mode 100755 index 000000000..8a7de871e --- /dev/null +++ b/cef/libcef_dll/ctocpp/base_ctocpp.h @@ -0,0 +1,106 @@ +// Copyright (c) 2009 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 _BASE_CTOCPP_H +#define _BASE_CTOCPP_H + +#include "include/cef.h" +#include "include/cef_capi.h" +#include "libcef_dll/cef_logging.h" + + +// CefCToCpp implementation for CefBase. +class CefBaseCToCpp : public CefBase +{ +public: + // Use this method to create a wrapper class instance for a structure + // received from the other side. + static CefRefPtr Wrap(cef_base_t* s) + { + if (!s) + return NULL; + + // Wrap their structure with the CefCToCpp object. + CefBaseCToCpp* wrapper = new CefBaseCToCpp(s); + // Put the wrapper object in a smart pointer. + CefRefPtr wrapperPtr(wrapper); + // Release the reference that was added to the CefCppToC wrapper object on + // the other side before their structure was passed to us. + wrapper->UnderlyingRelease(); + // Return the smart pointer. + return wrapperPtr; + } + + // Use this method to retrieve the underlying structure from a wrapper class + // instance for return back to the other side. + static cef_base_t* Unwrap(CefRefPtr c) + { + if (!c.get()) + return NULL; + + // Cast the object to our wrapper class type. + CefBaseCToCpp* wrapper = static_cast(c.get()); + // Add a reference to the CefCppToC wrapper object on the other side that + // will be released once the structure is received. + wrapper->UnderlyingAddRef(); + // Return their original structure. + return wrapper->GetStruct(); + } + + CefBaseCToCpp(cef_base_t* str) + : struct_(str) + { + DCHECK(str); + } + virtual ~CefBaseCToCpp() {} + + // If returning the structure across the DLL boundary you should call + // UnderlyingAddRef() on this wrapping CefCToCpp object. On the other side of + // the DLL boundary, call Release() on the CefCppToC object. + cef_base_t* GetStruct() { return struct_; } + + // CefBase methods increment/decrement reference counts on both this object + // and the underlying wrapped structure. + int AddRef() + { + UnderlyingAddRef(); + return refct_.AddRef(); + } + int Release() + { + UnderlyingRelease(); + 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() + { + if(!struct_->add_ref) + return 0; + return struct_->add_ref(struct_); + } + int UnderlyingRelease() + { + if(!struct_->release) + return 0; + return struct_->release(struct_); + } + int UnderlyingGetRefCt() + { + if(!struct_->get_refct) + return 0; + return struct_->get_refct(struct_); + } + +protected: + CefRefCount refct_; + cef_base_t* struct_; +}; + + +#endif // _BASE_CTOCPP_H diff --git a/cef/libcef_dll/ctocpp/browser_ctocpp.cc b/cef/libcef_dll/ctocpp/browser_ctocpp.cc new file mode 100755 index 000000000..aad112c7d --- /dev/null +++ b/cef/libcef_dll/ctocpp/browser_ctocpp.cc @@ -0,0 +1,660 @@ +// 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. If making changes by +// hand only do so within the body of existing method and 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/ctocpp/browser_ctocpp.h" +#include "libcef_dll/ctocpp/frame_ctocpp.h" +#include "libcef_dll/transfer_util.h" + + +// STATIC METHODS - Body may be edited by hand. + +bool CefBrowser::CreateBrowser(CefWindowInfo& windowInfo, + CefRefPtr client, const CefString& url, + const CefBrowserSettings& settings) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: client; type: refptr_diff + DCHECK(client.get()); + if (!client.get()) + return false; + // Unverified params: url + + // Execute + int _retval = cef_browser_create( + &windowInfo, + CefClientCppToC::Wrap(client), + url.GetStruct(), + &settings); + + // Return type: bool + return _retval?true:false; +} + + +CefRefPtr CefBrowser::CreateBrowserSync(CefWindowInfo& windowInfo, + CefRefPtr client, const CefString& url, + const CefBrowserSettings& settings) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: client; type: refptr_diff + DCHECK(client.get()); + if (!client.get()) + return NULL; + // Unverified params: url + + // Execute + cef_browser_t* _retval = cef_browser_create_sync( + &windowInfo, + CefClientCppToC::Wrap(client), + url.GetStruct(), + &settings); + + // Return type: refptr_same + return CefBrowserCToCpp::Wrap(_retval); +} + + + +// VIRTUAL METHODS - Body may be edited by hand. + +void CefBrowserCToCpp::ParentWindowWillClose() +{ + if (CEF_MEMBER_MISSING(struct_, parent_window_will_close)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->parent_window_will_close(struct_); +} + + +void CefBrowserCToCpp::CloseBrowser() +{ + if (CEF_MEMBER_MISSING(struct_, close_browser)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->close_browser(struct_); +} + + +bool CefBrowserCToCpp::CanGoBack() +{ + if (CEF_MEMBER_MISSING(struct_, can_go_back)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->can_go_back(struct_); + + // Return type: bool + return _retval?true:false; +} + + +void CefBrowserCToCpp::GoBack() +{ + if (CEF_MEMBER_MISSING(struct_, go_back)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->go_back(struct_); +} + + +bool CefBrowserCToCpp::CanGoForward() +{ + if (CEF_MEMBER_MISSING(struct_, can_go_forward)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->can_go_forward(struct_); + + // Return type: bool + return _retval?true:false; +} + + +void CefBrowserCToCpp::GoForward() +{ + if (CEF_MEMBER_MISSING(struct_, go_forward)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->go_forward(struct_); +} + + +void CefBrowserCToCpp::Reload() +{ + if (CEF_MEMBER_MISSING(struct_, reload)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->reload(struct_); +} + + +void CefBrowserCToCpp::ReloadIgnoreCache() +{ + if (CEF_MEMBER_MISSING(struct_, reload_ignore_cache)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->reload_ignore_cache(struct_); +} + + +void CefBrowserCToCpp::StopLoad() +{ + if (CEF_MEMBER_MISSING(struct_, stop_load)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->stop_load(struct_); +} + + +void CefBrowserCToCpp::SetFocus(bool enable) +{ + if (CEF_MEMBER_MISSING(struct_, set_focus)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->set_focus(struct_, + enable); +} + + +CefWindowHandle CefBrowserCToCpp::GetWindowHandle() +{ + if (CEF_MEMBER_MISSING(struct_, get_window_handle)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_window_handle_t _retval = struct_->get_window_handle(struct_); + + // Return type: simple + return _retval; +} + + +CefWindowHandle CefBrowserCToCpp::GetOpenerWindowHandle() +{ + if (CEF_MEMBER_MISSING(struct_, get_opener_window_handle)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_window_handle_t _retval = struct_->get_opener_window_handle(struct_); + + // Return type: simple + return _retval; +} + + +bool CefBrowserCToCpp::IsPopup() +{ + if (CEF_MEMBER_MISSING(struct_, is_popup)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_popup(struct_); + + // Return type: bool + return _retval?true:false; +} + + +bool CefBrowserCToCpp::HasDocument() +{ + if (CEF_MEMBER_MISSING(struct_, has_document)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->has_document(struct_); + + // Return type: bool + return _retval?true:false; +} + + +CefRefPtr CefBrowserCToCpp::GetClient() +{ + if (CEF_MEMBER_MISSING(struct_, get_client)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_client_t* _retval = struct_->get_client(struct_); + + // Return type: refptr_diff + return CefClientCppToC::Unwrap(_retval); +} + + +CefRefPtr CefBrowserCToCpp::GetMainFrame() +{ + if (CEF_MEMBER_MISSING(struct_, get_main_frame)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_frame_t* _retval = struct_->get_main_frame(struct_); + + // Return type: refptr_same + return CefFrameCToCpp::Wrap(_retval); +} + + +CefRefPtr CefBrowserCToCpp::GetFocusedFrame() +{ + if (CEF_MEMBER_MISSING(struct_, get_focused_frame)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_frame_t* _retval = struct_->get_focused_frame(struct_); + + // Return type: refptr_same + return CefFrameCToCpp::Wrap(_retval); +} + + +CefRefPtr CefBrowserCToCpp::GetFrame(const CefString& name) +{ + if (CEF_MEMBER_MISSING(struct_, get_frame)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: name; type: string_byref_const + DCHECK(!name.empty()); + if (name.empty()) + return NULL; + + // Execute + cef_frame_t* _retval = struct_->get_frame(struct_, + name.GetStruct()); + + // Return type: refptr_same + return CefFrameCToCpp::Wrap(_retval); +} + + +void CefBrowserCToCpp::GetFrameNames(std::vector& names) +{ + if (CEF_MEMBER_MISSING(struct_, get_frame_names)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Translate param: names; type: string_vec_byref + cef_string_list_t namesList = cef_string_list_alloc(); + DCHECK(namesList); + if (namesList) + transfer_string_list_contents(names, namesList); + + // Execute + struct_->get_frame_names(struct_, + namesList); + + // Restore param:names; type: string_vec_byref + if (namesList) { + names.clear(); + transfer_string_list_contents(namesList, names); + cef_string_list_free(namesList); + } +} + + +void CefBrowserCToCpp::Find(int identifier, const CefString& searchText, + bool forward, bool matchCase, bool findNext) +{ + if (CEF_MEMBER_MISSING(struct_, find)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: searchText; type: string_byref_const + DCHECK(!searchText.empty()); + if (searchText.empty()) + return; + + // Execute + struct_->find(struct_, + identifier, + searchText.GetStruct(), + forward, + matchCase, + findNext); +} + + +void CefBrowserCToCpp::StopFinding(bool clearSelection) +{ + if (CEF_MEMBER_MISSING(struct_, stop_finding)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->stop_finding(struct_, + clearSelection); +} + + +double CefBrowserCToCpp::GetZoomLevel() +{ + if (CEF_MEMBER_MISSING(struct_, get_zoom_level)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + double _retval = struct_->get_zoom_level(struct_); + + // Return type: simple + return _retval; +} + + +void CefBrowserCToCpp::SetZoomLevel(double zoomLevel) +{ + if (CEF_MEMBER_MISSING(struct_, set_zoom_level)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->set_zoom_level(struct_, + zoomLevel); +} + + +void CefBrowserCToCpp::ClearHistory() +{ + if (CEF_MEMBER_MISSING(struct_, clear_history)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->clear_history(struct_); +} + + +void CefBrowserCToCpp::ShowDevTools() +{ + if (CEF_MEMBER_MISSING(struct_, show_dev_tools)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->show_dev_tools(struct_); +} + + +void CefBrowserCToCpp::CloseDevTools() +{ + if (CEF_MEMBER_MISSING(struct_, close_dev_tools)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->close_dev_tools(struct_); +} + + +bool CefBrowserCToCpp::IsWindowRenderingDisabled() +{ + if (CEF_MEMBER_MISSING(struct_, is_window_rendering_disabled)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_window_rendering_disabled(struct_); + + // Return type: bool + return _retval?true:false; +} + + +bool CefBrowserCToCpp::GetSize(PaintElementType type, int& width, int& height) +{ + if (CEF_MEMBER_MISSING(struct_, get_size)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->get_size(struct_, + type, + &width, + &height); + + // Return type: bool + return _retval?true:false; +} + + +void CefBrowserCToCpp::SetSize(PaintElementType type, int width, int height) +{ + if (CEF_MEMBER_MISSING(struct_, set_size)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->set_size(struct_, + type, + width, + height); +} + + +bool CefBrowserCToCpp::IsPopupVisible() +{ + if (CEF_MEMBER_MISSING(struct_, is_popup_visible)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_popup_visible(struct_); + + // Return type: bool + return _retval?true:false; +} + + +void CefBrowserCToCpp::HidePopup() +{ + if (CEF_MEMBER_MISSING(struct_, hide_popup)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->hide_popup(struct_); +} + + +void CefBrowserCToCpp::Invalidate(const CefRect& dirtyRect) +{ + if (CEF_MEMBER_MISSING(struct_, invalidate)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->invalidate(struct_, + &dirtyRect); +} + + +bool CefBrowserCToCpp::GetImage(PaintElementType type, int width, int height, + void* buffer) +{ + if (CEF_MEMBER_MISSING(struct_, get_image)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: buffer; type: simple_byaddr + DCHECK(buffer); + if (!buffer) + return false; + + // Execute + int _retval = struct_->get_image(struct_, + type, + width, + height, + buffer); + + // Return type: bool + return _retval?true:false; +} + + +void CefBrowserCToCpp::SendKeyEvent(KeyType type, int key, int modifiers, + bool sysChar, bool imeChar) +{ + if (CEF_MEMBER_MISSING(struct_, send_key_event)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->send_key_event(struct_, + type, + key, + modifiers, + sysChar, + imeChar); +} + + +void CefBrowserCToCpp::SendMouseClickEvent(int x, int y, MouseButtonType type, + bool mouseUp, int clickCount) +{ + if (CEF_MEMBER_MISSING(struct_, send_mouse_click_event)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->send_mouse_click_event(struct_, + x, + y, + type, + mouseUp, + clickCount); +} + + +void CefBrowserCToCpp::SendMouseMoveEvent(int x, int y, bool mouseLeave) +{ + if (CEF_MEMBER_MISSING(struct_, send_mouse_move_event)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->send_mouse_move_event(struct_, + x, + y, + mouseLeave); +} + + +void CefBrowserCToCpp::SendMouseWheelEvent(int x, int y, int delta) +{ + if (CEF_MEMBER_MISSING(struct_, send_mouse_wheel_event)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->send_mouse_wheel_event(struct_, + x, + y, + delta); +} + + +void CefBrowserCToCpp::SendFocusEvent(bool setFocus) +{ + if (CEF_MEMBER_MISSING(struct_, send_focus_event)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->send_focus_event(struct_, + setFocus); +} + + +void CefBrowserCToCpp::SendCaptureLostEvent() +{ + if (CEF_MEMBER_MISSING(struct_, send_capture_lost_event)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->send_capture_lost_event(struct_); +} + + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef/libcef_dll/ctocpp/browser_ctocpp.h b/cef/libcef_dll/ctocpp/browser_ctocpp.h new file mode 100755 index 000000000..de9739b20 --- /dev/null +++ b/cef/libcef_dll/ctocpp/browser_ctocpp.h @@ -0,0 +1,82 @@ +// 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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef _BROWSER_CTOCPP_H +#define _BROWSER_CTOCPP_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/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed wrapper-side only. +class CefBrowserCToCpp + : public CefCToCpp +{ +public: + CefBrowserCToCpp(cef_browser_t* str) + : CefCToCpp(str) {} + virtual ~CefBrowserCToCpp() {} + + // CefBrowser methods + virtual void ParentWindowWillClose() OVERRIDE; + 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 CefWindowHandle GetOpenerWindowHandle() OVERRIDE; + virtual bool IsPopup() OVERRIDE; + virtual bool HasDocument() 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) OVERRIDE; + virtual void StopFinding(bool clearSelection) OVERRIDE; + virtual double GetZoomLevel() OVERRIDE; + virtual void SetZoomLevel(double zoomLevel) OVERRIDE; + virtual void ClearHistory() 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) OVERRIDE; + virtual void SendKeyEvent(KeyType type, int key, int modifiers, bool sysChar, + bool imeChar) OVERRIDE; + virtual void SendMouseClickEvent(int x, int y, MouseButtonType type, + 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 +#endif // _BROWSER_CTOCPP_H + diff --git a/cef/libcef_dll/ctocpp/command_line_ctocpp.cc b/cef/libcef_dll/ctocpp/command_line_ctocpp.cc new file mode 100755 index 000000000..c66e8542c --- /dev/null +++ b/cef/libcef_dll/ctocpp/command_line_ctocpp.cc @@ -0,0 +1,322 @@ +// 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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "include/cef_version.h" +#include "libcef_dll/ctocpp/command_line_ctocpp.h" +#include "libcef_dll/transfer_util.h" + + +// STATIC METHODS - Body may be edited by hand. + +CefRefPtr CefCommandLine::CreateCommandLine() +{ + int build_revision = cef_build_revision(); + if (build_revision != CEF_REVISION) { + // The libcef build revision does not match the CEF API revision. + DCHECK(false); + return NULL; + } + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_command_line_t* _retval = cef_command_line_create(); + + // Return type: refptr_same + return CefCommandLineCToCpp::Wrap(_retval); +} + + + +// VIRTUAL METHODS - Body may be edited by hand. + +void CefCommandLineCToCpp::InitFromArgv(int argc, const char* const* argv) +{ + if (CEF_MEMBER_MISSING(struct_, init_from_argv)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: argv; type: simple_byaddr + DCHECK(argv); + if (!argv) + return; + + // Execute + struct_->init_from_argv(struct_, + argc, + argv); +} + + +void CefCommandLineCToCpp::InitFromString(const CefString& command_line) +{ + if (CEF_MEMBER_MISSING(struct_, init_from_string)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: command_line; type: string_byref_const + DCHECK(!command_line.empty()); + if (command_line.empty()) + return; + + // Execute + struct_->init_from_string(struct_, + command_line.GetStruct()); +} + + +CefString CefCommandLineCToCpp::GetCommandLineString() +{ + if (CEF_MEMBER_MISSING(struct_, get_command_line_string)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_command_line_string(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + + +CefString CefCommandLineCToCpp::GetProgram() +{ + if (CEF_MEMBER_MISSING(struct_, get_program)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_program(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + + +void CefCommandLineCToCpp::SetProgram(const CefString& program) +{ + if (CEF_MEMBER_MISSING(struct_, set_program)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: program; type: string_byref_const + DCHECK(!program.empty()); + if (program.empty()) + return; + + // Execute + struct_->set_program(struct_, + program.GetStruct()); +} + + +bool CefCommandLineCToCpp::HasSwitches() +{ + if (CEF_MEMBER_MISSING(struct_, has_switches)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->has_switches(struct_); + + // Return type: bool + return _retval?true:false; +} + + +bool CefCommandLineCToCpp::HasSwitch(const CefString& name) +{ + if (CEF_MEMBER_MISSING(struct_, has_switch)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: name; type: string_byref_const + DCHECK(!name.empty()); + if (name.empty()) + return false; + + // Execute + int _retval = struct_->has_switch(struct_, + name.GetStruct()); + + // Return type: bool + return _retval?true:false; +} + + +CefString CefCommandLineCToCpp::GetSwitchValue(const CefString& name) +{ + if (CEF_MEMBER_MISSING(struct_, get_switch_value)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: name; type: string_byref_const + DCHECK(!name.empty()); + if (name.empty()) + return CefString(); + + // Execute + cef_string_userfree_t _retval = struct_->get_switch_value(struct_, + name.GetStruct()); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + + +void CefCommandLineCToCpp::GetSwitches(SwitchMap& switches) +{ + if (CEF_MEMBER_MISSING(struct_, get_switches)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Translate param: switches; type: string_map_single_byref + cef_string_map_t switchesMap = cef_string_map_alloc(); + DCHECK(switchesMap); + if (switchesMap) + transfer_string_map_contents(switches, switchesMap); + + // Execute + struct_->get_switches(struct_, + switchesMap); + + // Restore param:switches; type: string_map_single_byref + if (switchesMap) { + switches.clear(); + transfer_string_map_contents(switchesMap, switches); + cef_string_map_free(switchesMap); + } +} + + +void CefCommandLineCToCpp::AppendSwitch(const CefString& name) +{ + if (CEF_MEMBER_MISSING(struct_, append_switch)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: name; type: string_byref_const + DCHECK(!name.empty()); + if (name.empty()) + return; + + // Execute + struct_->append_switch(struct_, + name.GetStruct()); +} + + +void CefCommandLineCToCpp::AppendSwitchWithValue(const CefString& name, + const CefString& value) +{ + if (CEF_MEMBER_MISSING(struct_, append_switch_with_value)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: name; type: string_byref_const + DCHECK(!name.empty()); + if (name.empty()) + return; + // Verify param: value; type: string_byref_const + DCHECK(!value.empty()); + if (value.empty()) + return; + + // Execute + struct_->append_switch_with_value(struct_, + name.GetStruct(), + value.GetStruct()); +} + + +bool CefCommandLineCToCpp::HasArguments() +{ + if (CEF_MEMBER_MISSING(struct_, has_arguments)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->has_arguments(struct_); + + // Return type: bool + return _retval?true:false; +} + + +void CefCommandLineCToCpp::GetArguments(ArgumentList& arguments) +{ + if (CEF_MEMBER_MISSING(struct_, get_arguments)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Translate param: arguments; type: string_vec_byref + cef_string_list_t argumentsList = cef_string_list_alloc(); + DCHECK(argumentsList); + if (argumentsList) + transfer_string_list_contents(arguments, argumentsList); + + // Execute + struct_->get_arguments(struct_, + argumentsList); + + // Restore param:arguments; type: string_vec_byref + if (argumentsList) { + arguments.clear(); + transfer_string_list_contents(argumentsList, arguments); + cef_string_list_free(argumentsList); + } +} + + +void CefCommandLineCToCpp::AppendArgument(const CefString& argument) +{ + if (CEF_MEMBER_MISSING(struct_, append_argument)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: argument; type: string_byref_const + DCHECK(!argument.empty()); + if (argument.empty()) + return; + + // Execute + struct_->append_argument(struct_, + argument.GetStruct()); +} + + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef/libcef_dll/ctocpp/command_line_ctocpp.h b/cef/libcef_dll/ctocpp/command_line_ctocpp.h new file mode 100755 index 000000000..cc8b6778c --- /dev/null +++ b/cef/libcef_dll/ctocpp/command_line_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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef _COMMANDLINE_CTOCPP_H +#define _COMMANDLINE_CTOCPP_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/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed wrapper-side only. +class CefCommandLineCToCpp + : public CefCToCpp +{ +public: + CefCommandLineCToCpp(cef_command_line_t* str) + : CefCToCpp( + str) {} + virtual ~CefCommandLineCToCpp() {} + + // CefCommandLine methods + virtual void InitFromArgv(int argc, const char* const* argv) OVERRIDE; + virtual void InitFromString(const CefString& command_line) OVERRIDE; + virtual CefString GetCommandLineString() OVERRIDE; + virtual CefString GetProgram() OVERRIDE; + virtual void SetProgram(const CefString& program) OVERRIDE; + virtual bool HasSwitches() OVERRIDE; + virtual bool HasSwitch(const CefString& name) OVERRIDE; + virtual CefString GetSwitchValue(const CefString& name) OVERRIDE; + virtual void GetSwitches(SwitchMap& switches) OVERRIDE; + virtual void AppendSwitch(const CefString& name) OVERRIDE; + virtual void AppendSwitchWithValue(const CefString& name, + const CefString& value) OVERRIDE; + virtual bool HasArguments() OVERRIDE; + virtual void GetArguments(ArgumentList& arguments) OVERRIDE; + virtual void AppendArgument(const CefString& argument) OVERRIDE; +}; + +#endif // USING_CEF_SHARED +#endif // _COMMANDLINE_CTOCPP_H + diff --git a/cef/libcef_dll/ctocpp/ctocpp.h b/cef/libcef_dll/ctocpp/ctocpp.h new file mode 100755 index 000000000..ba2e01c2a --- /dev/null +++ b/cef/libcef_dll/ctocpp/ctocpp.h @@ -0,0 +1,122 @@ +// Copyright (c) 2009 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 _CTOCPP_H +#define _CTOCPP_H + +#include "include/cef.h" +#include "include/cef_capi.h" +#include "libcef_dll/cef_logging.h" + + +// Wrap a C structure with a C++ class. This is used when the implementation +// 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 BaseName +{ +public: + // Use this method to create a wrapper class instance for a structure + // received from the other side. + static CefRefPtr Wrap(StructName* s) + { + if (!s) + return NULL; + + // Wrap their structure with the CefCToCpp object. + ClassName* wrapper = new ClassName(s); + // Put the wrapper object in a smart pointer. + CefRefPtr wrapperPtr(wrapper); + // Release the reference that was added to the CefCppToC wrapper object on + // the other side before their structure was passed to us. + wrapper->UnderlyingRelease(); + // Return the smart pointer. + return wrapperPtr; + } + + // Use this method to retrieve the underlying structure from a wrapper class + // instance for return back to the other side. + static StructName* Unwrap(CefRefPtr c) + { + if (!c.get()) + return NULL; + + // Cast the object to our wrapper class type. + ClassName* wrapper = static_cast(c.get()); + // Add a reference to the CefCppToC wrapper object on the other side that + // will be released once the structure is received. + wrapper->UnderlyingAddRef(); + // Return their original structure. + return wrapper->GetStruct(); + } + + CefCToCpp(StructName* str) + : struct_(str) + { + DCHECK(str); + +#ifndef NDEBUG + CefAtomicIncrement(&DebugObjCt); +#endif + } + virtual ~CefCToCpp() + { +#ifndef NDEBUG + CefAtomicDecrement(&DebugObjCt); +#endif + } + + // If returning the structure across the DLL boundary you should call + // UnderlyingAddRef() on this wrapping CefCToCpp object. On the other side of + // the DLL boundary, call Release() on the CefCppToC object. + StructName* GetStruct() { return struct_; } + + // CefBase methods increment/decrement reference counts on both this object + // and the underlying wrapped structure. + int AddRef() + { + UnderlyingAddRef(); + return refct_.AddRef(); + } + int Release() + { + UnderlyingRelease(); + 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() + { + if(!struct_->base.add_ref) + return 0; + return struct_->base.add_ref(&struct_->base); + } + int UnderlyingRelease() + { + if(!struct_->base.release) + return 0; + return struct_->base.release(&struct_->base); + } + int UnderlyingGetRefCt() + { + if(!struct_->base.get_refct) + return 0; + return struct_->base.get_refct(&struct_->base); + } + +#ifndef NDEBUG + // Simple tracking of allocated objects. + static long DebugObjCt; +#endif + +protected: + CefRefCount refct_; + StructName* struct_; +}; + +#endif // _CTOCPP_H diff --git a/cef/libcef_dll/ctocpp/domdocument_ctocpp.cc b/cef/libcef_dll/ctocpp/domdocument_ctocpp.cc new file mode 100755 index 000000000..e784f572e --- /dev/null +++ b/cef/libcef_dll/ctocpp/domdocument_ctocpp.cc @@ -0,0 +1,286 @@ +// 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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/ctocpp/domdocument_ctocpp.h" +#include "libcef_dll/ctocpp/domnode_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +CefDOMDocument::Type CefDOMDocumentCToCpp::GetType() +{ + if (CEF_MEMBER_MISSING(struct_, get_type)) + return DOM_DOCUMENT_TYPE_UNKNOWN; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_dom_document_type_t _retval = struct_->get_type(struct_); + + // Return type: simple + return _retval; +} + + +CefRefPtr CefDOMDocumentCToCpp::GetDocument() +{ + if (CEF_MEMBER_MISSING(struct_, get_document)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_domnode_t* _retval = struct_->get_document(struct_); + + // Return type: refptr_same + return CefDOMNodeCToCpp::Wrap(_retval); +} + + +CefRefPtr CefDOMDocumentCToCpp::GetBody() +{ + if (CEF_MEMBER_MISSING(struct_, get_body)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_domnode_t* _retval = struct_->get_body(struct_); + + // Return type: refptr_same + return CefDOMNodeCToCpp::Wrap(_retval); +} + + +CefRefPtr CefDOMDocumentCToCpp::GetHead() +{ + if (CEF_MEMBER_MISSING(struct_, get_head)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_domnode_t* _retval = struct_->get_head(struct_); + + // Return type: refptr_same + return CefDOMNodeCToCpp::Wrap(_retval); +} + + +CefString CefDOMDocumentCToCpp::GetTitle() +{ + if (CEF_MEMBER_MISSING(struct_, get_title)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_title(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + + +CefRefPtr CefDOMDocumentCToCpp::GetElementById(const CefString& id) +{ + if (CEF_MEMBER_MISSING(struct_, get_element_by_id)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: id; type: string_byref_const + DCHECK(!id.empty()); + if (id.empty()) + return NULL; + + // Execute + cef_domnode_t* _retval = struct_->get_element_by_id(struct_, + id.GetStruct()); + + // Return type: refptr_same + return CefDOMNodeCToCpp::Wrap(_retval); +} + + +CefRefPtr CefDOMDocumentCToCpp::GetFocusedNode() +{ + if (CEF_MEMBER_MISSING(struct_, get_focused_node)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_domnode_t* _retval = struct_->get_focused_node(struct_); + + // Return type: refptr_same + return CefDOMNodeCToCpp::Wrap(_retval); +} + + +bool CefDOMDocumentCToCpp::HasSelection() +{ + if (CEF_MEMBER_MISSING(struct_, has_selection)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->has_selection(struct_); + + // Return type: bool + return _retval?true:false; +} + + +CefRefPtr CefDOMDocumentCToCpp::GetSelectionStartNode() +{ + if (CEF_MEMBER_MISSING(struct_, get_selection_start_node)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_domnode_t* _retval = struct_->get_selection_start_node(struct_); + + // Return type: refptr_same + return CefDOMNodeCToCpp::Wrap(_retval); +} + + +int CefDOMDocumentCToCpp::GetSelectionStartOffset() +{ + if (CEF_MEMBER_MISSING(struct_, get_selection_start_offset)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->get_selection_start_offset(struct_); + + // Return type: simple + return _retval; +} + + +CefRefPtr CefDOMDocumentCToCpp::GetSelectionEndNode() +{ + if (CEF_MEMBER_MISSING(struct_, get_selection_end_node)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_domnode_t* _retval = struct_->get_selection_end_node(struct_); + + // Return type: refptr_same + return CefDOMNodeCToCpp::Wrap(_retval); +} + + +int CefDOMDocumentCToCpp::GetSelectionEndOffset() +{ + if (CEF_MEMBER_MISSING(struct_, get_selection_end_offset)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->get_selection_end_offset(struct_); + + // Return type: simple + return _retval; +} + + +CefString CefDOMDocumentCToCpp::GetSelectionAsMarkup() +{ + if (CEF_MEMBER_MISSING(struct_, get_selection_as_markup)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_selection_as_markup(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + + +CefString CefDOMDocumentCToCpp::GetSelectionAsText() +{ + if (CEF_MEMBER_MISSING(struct_, get_selection_as_text)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_selection_as_text(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + + +CefString CefDOMDocumentCToCpp::GetBaseURL() +{ + if (CEF_MEMBER_MISSING(struct_, get_base_url)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_base_url(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + + +CefString CefDOMDocumentCToCpp::GetCompleteURL(const CefString& partialURL) +{ + if (CEF_MEMBER_MISSING(struct_, get_complete_url)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: partialURL; type: string_byref_const + DCHECK(!partialURL.empty()); + if (partialURL.empty()) + return CefString(); + + // Execute + cef_string_userfree_t _retval = struct_->get_complete_url(struct_, + partialURL.GetStruct()); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef/libcef_dll/ctocpp/domdocument_ctocpp.h b/cef/libcef_dll/ctocpp/domdocument_ctocpp.h new file mode 100755 index 000000000..c448a83a4 --- /dev/null +++ b/cef/libcef_dll/ctocpp/domdocument_ctocpp.h @@ -0,0 +1,56 @@ +// 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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef _DOMDOCUMENT_CTOCPP_H +#define _DOMDOCUMENT_CTOCPP_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/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed wrapper-side only. +class CefDOMDocumentCToCpp + : public CefCToCpp +{ +public: + CefDOMDocumentCToCpp(cef_domdocument_t* str) + : CefCToCpp( + str) {} + virtual ~CefDOMDocumentCToCpp() {} + + // CefDOMDocument methods + 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 +#endif // _DOMDOCUMENT_CTOCPP_H + diff --git a/cef/libcef_dll/ctocpp/domevent_ctocpp.cc b/cef/libcef_dll/ctocpp/domevent_ctocpp.cc new file mode 100755 index 000000000..a02cdb946 --- /dev/null +++ b/cef/libcef_dll/ctocpp/domevent_ctocpp.cc @@ -0,0 +1,147 @@ +// 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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/ctocpp/domdocument_ctocpp.h" +#include "libcef_dll/ctocpp/domevent_ctocpp.h" +#include "libcef_dll/ctocpp/domnode_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +CefString CefDOMEventCToCpp::GetType() +{ + if (CEF_MEMBER_MISSING(struct_, get_type)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_type(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + + +CefDOMEvent::Category CefDOMEventCToCpp::GetCategory() +{ + if (CEF_MEMBER_MISSING(struct_, get_category)) + return DOM_EVENT_CATEGORY_UNKNOWN; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_dom_event_category_t _retval = struct_->get_category(struct_); + + // Return type: simple + return _retval; +} + + +CefDOMEvent::Phase CefDOMEventCToCpp::GetPhase() +{ + if (CEF_MEMBER_MISSING(struct_, get_phase)) + return DOM_EVENT_PHASE_UNKNOWN; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_dom_event_phase_t _retval = struct_->get_phase(struct_); + + // Return type: simple + return _retval; +} + + +bool CefDOMEventCToCpp::CanBubble() +{ + if (CEF_MEMBER_MISSING(struct_, can_bubble)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->can_bubble(struct_); + + // Return type: bool + return _retval?true:false; +} + + +bool CefDOMEventCToCpp::CanCancel() +{ + if (CEF_MEMBER_MISSING(struct_, can_cancel)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->can_cancel(struct_); + + // Return type: bool + return _retval?true:false; +} + + +CefRefPtr CefDOMEventCToCpp::GetDocument() +{ + if (CEF_MEMBER_MISSING(struct_, get_document)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_domdocument_t* _retval = struct_->get_document(struct_); + + // Return type: refptr_same + return CefDOMDocumentCToCpp::Wrap(_retval); +} + + +CefRefPtr CefDOMEventCToCpp::GetTarget() +{ + if (CEF_MEMBER_MISSING(struct_, get_target)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_domnode_t* _retval = struct_->get_target(struct_); + + // Return type: refptr_same + return CefDOMNodeCToCpp::Wrap(_retval); +} + + +CefRefPtr CefDOMEventCToCpp::GetCurrentTarget() +{ + if (CEF_MEMBER_MISSING(struct_, get_current_target)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_domnode_t* _retval = struct_->get_current_target(struct_); + + // Return type: refptr_same + return CefDOMNodeCToCpp::Wrap(_retval); +} + + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef/libcef_dll/ctocpp/domevent_ctocpp.h b/cef/libcef_dll/ctocpp/domevent_ctocpp.h new file mode 100755 index 000000000..75136b753 --- /dev/null +++ b/cef/libcef_dll/ctocpp/domevent_ctocpp.h @@ -0,0 +1,47 @@ +// 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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef _DOMEVENT_CTOCPP_H +#define _DOMEVENT_CTOCPP_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/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed wrapper-side only. +class CefDOMEventCToCpp + : public CefCToCpp +{ +public: + CefDOMEventCToCpp(cef_domevent_t* str) + : CefCToCpp(str) {} + virtual ~CefDOMEventCToCpp() {} + + // CefDOMEvent methods + 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 +#endif // _DOMEVENT_CTOCPP_H + diff --git a/cef/libcef_dll/ctocpp/domnode_ctocpp.cc b/cef/libcef_dll/ctocpp/domnode_ctocpp.cc new file mode 100755 index 000000000..783818660 --- /dev/null +++ b/cef/libcef_dll/ctocpp/domnode_ctocpp.cc @@ -0,0 +1,473 @@ +// 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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/domevent_listener_cpptoc.h" +#include "libcef_dll/ctocpp/domdocument_ctocpp.h" +#include "libcef_dll/ctocpp/domnode_ctocpp.h" +#include "libcef_dll/transfer_util.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +CefDOMNode::Type CefDOMNodeCToCpp::GetType() +{ + if (CEF_MEMBER_MISSING(struct_, get_type)) + return DOM_NODE_TYPE_UNSUPPORTED; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_dom_node_type_t _retval = struct_->get_type(struct_); + + // Return type: simple + return _retval; +} + + +bool CefDOMNodeCToCpp::IsText() +{ + if (CEF_MEMBER_MISSING(struct_, is_text)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_text(struct_); + + // Return type: bool + return _retval?true:false; +} + + +bool CefDOMNodeCToCpp::IsElement() +{ + if (CEF_MEMBER_MISSING(struct_, is_element)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_element(struct_); + + // Return type: bool + return _retval?true:false; +} + + +bool CefDOMNodeCToCpp::IsFormControlElement() +{ + if (CEF_MEMBER_MISSING(struct_, is_form_control_element)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_form_control_element(struct_); + + // Return type: bool + return _retval?true:false; +} + + +CefString CefDOMNodeCToCpp::GetFormControlElementType() +{ + if (CEF_MEMBER_MISSING(struct_, get_form_control_element_type)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_form_control_element_type( + struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + + +bool CefDOMNodeCToCpp::IsSame(CefRefPtr that) +{ + if (CEF_MEMBER_MISSING(struct_, is_same)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: that; type: refptr_same + DCHECK(that.get()); + if (!that.get()) + return false; + + // Execute + int _retval = struct_->is_same(struct_, + CefDOMNodeCToCpp::Unwrap(that)); + + // Return type: bool + return _retval?true:false; +} + + +CefString CefDOMNodeCToCpp::GetName() +{ + if (CEF_MEMBER_MISSING(struct_, get_name)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_name(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + + +CefString CefDOMNodeCToCpp::GetValue() +{ + if (CEF_MEMBER_MISSING(struct_, get_value)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_value(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + + +bool CefDOMNodeCToCpp::SetValue(const CefString& value) +{ + if (CEF_MEMBER_MISSING(struct_, set_value)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: value; type: string_byref_const + DCHECK(!value.empty()); + if (value.empty()) + return false; + + // Execute + int _retval = struct_->set_value(struct_, + value.GetStruct()); + + // Return type: bool + return _retval?true:false; +} + + +CefString CefDOMNodeCToCpp::GetAsMarkup() +{ + if (CEF_MEMBER_MISSING(struct_, get_as_markup)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_as_markup(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + + +CefRefPtr CefDOMNodeCToCpp::GetDocument() +{ + if (CEF_MEMBER_MISSING(struct_, get_document)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_domdocument_t* _retval = struct_->get_document(struct_); + + // Return type: refptr_same + return CefDOMDocumentCToCpp::Wrap(_retval); +} + + +CefRefPtr CefDOMNodeCToCpp::GetParent() +{ + if (CEF_MEMBER_MISSING(struct_, get_parent)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_domnode_t* _retval = struct_->get_parent(struct_); + + // Return type: refptr_same + return CefDOMNodeCToCpp::Wrap(_retval); +} + + +CefRefPtr CefDOMNodeCToCpp::GetPreviousSibling() +{ + if (CEF_MEMBER_MISSING(struct_, get_previous_sibling)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_domnode_t* _retval = struct_->get_previous_sibling(struct_); + + // Return type: refptr_same + return CefDOMNodeCToCpp::Wrap(_retval); +} + + +CefRefPtr CefDOMNodeCToCpp::GetNextSibling() +{ + if (CEF_MEMBER_MISSING(struct_, get_next_sibling)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_domnode_t* _retval = struct_->get_next_sibling(struct_); + + // Return type: refptr_same + return CefDOMNodeCToCpp::Wrap(_retval); +} + + +bool CefDOMNodeCToCpp::HasChildren() +{ + if (CEF_MEMBER_MISSING(struct_, has_children)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->has_children(struct_); + + // Return type: bool + return _retval?true:false; +} + + +CefRefPtr CefDOMNodeCToCpp::GetFirstChild() +{ + if (CEF_MEMBER_MISSING(struct_, get_first_child)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_domnode_t* _retval = struct_->get_first_child(struct_); + + // Return type: refptr_same + return CefDOMNodeCToCpp::Wrap(_retval); +} + + +CefRefPtr CefDOMNodeCToCpp::GetLastChild() +{ + if (CEF_MEMBER_MISSING(struct_, get_last_child)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_domnode_t* _retval = struct_->get_last_child(struct_); + + // Return type: refptr_same + return CefDOMNodeCToCpp::Wrap(_retval); +} + + +void CefDOMNodeCToCpp::AddEventListener(const CefString& eventType, + CefRefPtr listener, bool useCapture) +{ + if (CEF_MEMBER_MISSING(struct_, add_event_listener)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: eventType; type: string_byref_const + DCHECK(!eventType.empty()); + if (eventType.empty()) + return; + // Verify param: listener; type: refptr_diff + DCHECK(listener.get()); + if (!listener.get()) + return; + + // Execute + struct_->add_event_listener(struct_, + eventType.GetStruct(), + CefDOMEventListenerCppToC::Wrap(listener), + useCapture); +} + + +CefString CefDOMNodeCToCpp::GetElementTagName() +{ + if (CEF_MEMBER_MISSING(struct_, get_element_tag_name)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_element_tag_name(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + + +bool CefDOMNodeCToCpp::HasElementAttributes() +{ + if (CEF_MEMBER_MISSING(struct_, has_element_attributes)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->has_element_attributes(struct_); + + // Return type: bool + return _retval?true:false; +} + + +bool CefDOMNodeCToCpp::HasElementAttribute(const CefString& attrName) +{ + if (CEF_MEMBER_MISSING(struct_, has_element_attribute)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: attrName; type: string_byref_const + DCHECK(!attrName.empty()); + if (attrName.empty()) + return false; + + // Execute + int _retval = struct_->has_element_attribute(struct_, + attrName.GetStruct()); + + // Return type: bool + return _retval?true:false; +} + + +CefString CefDOMNodeCToCpp::GetElementAttribute(const CefString& attrName) +{ + if (CEF_MEMBER_MISSING(struct_, get_element_attribute)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: attrName; type: string_byref_const + DCHECK(!attrName.empty()); + if (attrName.empty()) + return CefString(); + + // Execute + cef_string_userfree_t _retval = struct_->get_element_attribute(struct_, + attrName.GetStruct()); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + + +void CefDOMNodeCToCpp::GetElementAttributes(AttributeMap& attrMap) +{ + if (CEF_MEMBER_MISSING(struct_, get_element_attributes)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Translate param: attrMap; type: string_map_single_byref + cef_string_map_t attrMapMap = cef_string_map_alloc(); + DCHECK(attrMapMap); + if (attrMapMap) + transfer_string_map_contents(attrMap, attrMapMap); + + // Execute + struct_->get_element_attributes(struct_, + attrMapMap); + + // Restore param:attrMap; type: string_map_single_byref + if (attrMapMap) { + attrMap.clear(); + transfer_string_map_contents(attrMapMap, attrMap); + cef_string_map_free(attrMapMap); + } +} + + +bool CefDOMNodeCToCpp::SetElementAttribute(const CefString& attrName, + const CefString& value) +{ + if (CEF_MEMBER_MISSING(struct_, set_element_attribute)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: attrName; type: string_byref_const + DCHECK(!attrName.empty()); + if (attrName.empty()) + return false; + // Verify param: value; type: string_byref_const + DCHECK(!value.empty()); + if (value.empty()) + return false; + + // Execute + int _retval = struct_->set_element_attribute(struct_, + attrName.GetStruct(), + value.GetStruct()); + + // Return type: bool + return _retval?true:false; +} + + +CefString CefDOMNodeCToCpp::GetElementInnerText() +{ + if (CEF_MEMBER_MISSING(struct_, get_element_inner_text)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_element_inner_text(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef/libcef_dll/ctocpp/domnode_ctocpp.h b/cef/libcef_dll/ctocpp/domnode_ctocpp.h new file mode 100755 index 000000000..5c8d50c12 --- /dev/null +++ b/cef/libcef_dll/ctocpp/domnode_ctocpp.h @@ -0,0 +1,66 @@ +// 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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef _DOMNODE_CTOCPP_H +#define _DOMNODE_CTOCPP_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/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed wrapper-side only. +class CefDOMNodeCToCpp + : public CefCToCpp +{ +public: + CefDOMNodeCToCpp(cef_domnode_t* str) + : CefCToCpp(str) {} + virtual ~CefDOMNodeCToCpp() {} + + // CefDOMNode methods + virtual Type GetType() OVERRIDE; + virtual bool IsText() OVERRIDE; + virtual bool IsElement() OVERRIDE; + virtual bool IsFormControlElement() OVERRIDE; + virtual CefString GetFormControlElementType() 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) 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) OVERRIDE; + virtual CefString GetElementInnerText() OVERRIDE; +}; + +#endif // USING_CEF_SHARED +#endif // _DOMNODE_CTOCPP_H + diff --git a/cef/libcef_dll/ctocpp/drag_data_ctocpp.cc b/cef/libcef_dll/ctocpp/drag_data_ctocpp.cc new file mode 100755 index 000000000..b6179b24d --- /dev/null +++ b/cef/libcef_dll/ctocpp/drag_data_ctocpp.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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/ctocpp/drag_data_ctocpp.h" +#include "libcef_dll/transfer_util.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +bool CefDragDataCToCpp::IsLink() +{ + if (CEF_MEMBER_MISSING(struct_, is_link)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_link(struct_); + + // Return type: bool + return _retval?true:false; +} + + +bool CefDragDataCToCpp::IsFragment() +{ + if (CEF_MEMBER_MISSING(struct_, is_fragment)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_fragment(struct_); + + // Return type: bool + return _retval?true:false; +} + + +bool CefDragDataCToCpp::IsFile() +{ + if (CEF_MEMBER_MISSING(struct_, is_file)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_file(struct_); + + // Return type: bool + return _retval?true:false; +} + + +CefString CefDragDataCToCpp::GetLinkURL() +{ + if (CEF_MEMBER_MISSING(struct_, get_link_url)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_link_url(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + + +CefString CefDragDataCToCpp::GetLinkTitle() +{ + if (CEF_MEMBER_MISSING(struct_, get_link_title)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_link_title(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + + +CefString CefDragDataCToCpp::GetLinkMetadata() +{ + if (CEF_MEMBER_MISSING(struct_, get_link_metadata)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_link_metadata(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + + +CefString CefDragDataCToCpp::GetFragmentText() +{ + if (CEF_MEMBER_MISSING(struct_, get_fragment_text)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_fragment_text(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + + +CefString CefDragDataCToCpp::GetFragmentHtml() +{ + if (CEF_MEMBER_MISSING(struct_, get_fragment_html)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_fragment_html(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + + +CefString CefDragDataCToCpp::GetFragmentBaseURL() +{ + if (CEF_MEMBER_MISSING(struct_, get_fragment_base_url)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_fragment_base_url(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + + +CefString CefDragDataCToCpp::GetFileExtension() +{ + if (CEF_MEMBER_MISSING(struct_, get_file_extension)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_file_extension(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + + +CefString CefDragDataCToCpp::GetFileName() +{ + if (CEF_MEMBER_MISSING(struct_, get_file_name)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_file_name(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + + +bool CefDragDataCToCpp::GetFileNames(std::vector& names) +{ + if (CEF_MEMBER_MISSING(struct_, get_file_names)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Translate param: names; type: string_vec_byref + cef_string_list_t namesList = cef_string_list_alloc(); + DCHECK(namesList); + if (namesList) + transfer_string_list_contents(names, namesList); + + // Execute + int _retval = struct_->get_file_names(struct_, + namesList); + + // Restore param:names; type: string_vec_byref + if (namesList) { + names.clear(); + transfer_string_list_contents(namesList, names); + cef_string_list_free(namesList); + } + + // Return type: bool + return _retval?true:false; +} + + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef/libcef_dll/ctocpp/drag_data_ctocpp.h b/cef/libcef_dll/ctocpp/drag_data_ctocpp.h new file mode 100755 index 000000000..9b867d967 --- /dev/null +++ b/cef/libcef_dll/ctocpp/drag_data_ctocpp.h @@ -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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef _DRAGDATA_CTOCPP_H +#define _DRAGDATA_CTOCPP_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/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed wrapper-side only. +class CefDragDataCToCpp + : public CefCToCpp +{ +public: + CefDragDataCToCpp(cef_drag_data_t* str) + : CefCToCpp(str) {} + virtual ~CefDragDataCToCpp() {} + + // CefDragData methods + virtual bool IsLink() OVERRIDE; + virtual bool IsFragment() OVERRIDE; + virtual bool IsFile() OVERRIDE; + virtual CefString GetLinkURL() OVERRIDE; + virtual CefString GetLinkTitle() OVERRIDE; + virtual CefString GetLinkMetadata() OVERRIDE; + virtual CefString GetFragmentText() OVERRIDE; + virtual CefString GetFragmentHtml() OVERRIDE; + virtual CefString GetFragmentBaseURL() OVERRIDE; + virtual CefString GetFileExtension() OVERRIDE; + virtual CefString GetFileName() OVERRIDE; + virtual bool GetFileNames(std::vector& names) OVERRIDE; +}; + +#endif // USING_CEF_SHARED +#endif // _DRAGDATA_CTOCPP_H + diff --git a/cef/libcef_dll/ctocpp/frame_ctocpp.cc b/cef/libcef_dll/ctocpp/frame_ctocpp.cc new file mode 100755 index 000000000..8836b9876 --- /dev/null +++ b/cef/libcef_dll/ctocpp/frame_ctocpp.cc @@ -0,0 +1,417 @@ +// 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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/domvisitor_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/stream_reader_ctocpp.h" +#include "libcef_dll/ctocpp/v8context_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +void CefFrameCToCpp::Undo() +{ + if (CEF_MEMBER_MISSING(struct_, undo)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->undo(struct_); +} + + +void CefFrameCToCpp::Redo() +{ + if (CEF_MEMBER_MISSING(struct_, redo)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->redo(struct_); +} + + +void CefFrameCToCpp::Cut() +{ + if (CEF_MEMBER_MISSING(struct_, cut)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->cut(struct_); +} + + +void CefFrameCToCpp::Copy() +{ + if (CEF_MEMBER_MISSING(struct_, copy)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->copy(struct_); +} + + +void CefFrameCToCpp::Paste() +{ + if (CEF_MEMBER_MISSING(struct_, paste)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->paste(struct_); +} + + +void CefFrameCToCpp::Delete() +{ + if (CEF_MEMBER_MISSING(struct_, del)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->del(struct_); +} + + +void CefFrameCToCpp::SelectAll() +{ + if (CEF_MEMBER_MISSING(struct_, select_all)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->select_all(struct_); +} + + +void CefFrameCToCpp::Print() +{ + if (CEF_MEMBER_MISSING(struct_, print)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->print(struct_); +} + + +void CefFrameCToCpp::ViewSource() +{ + if (CEF_MEMBER_MISSING(struct_, view_source)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->view_source(struct_); +} + + +CefString CefFrameCToCpp::GetSource() +{ + if (CEF_MEMBER_MISSING(struct_, get_source)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_source(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + + +CefString CefFrameCToCpp::GetText() +{ + if (CEF_MEMBER_MISSING(struct_, get_text)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_text(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + + +void CefFrameCToCpp::LoadRequest(CefRefPtr request) +{ + if (CEF_MEMBER_MISSING(struct_, load_request)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: request; type: refptr_same + DCHECK(request.get()); + if (!request.get()) + return; + + // Execute + struct_->load_request(struct_, + CefRequestCToCpp::Unwrap(request)); +} + + +void CefFrameCToCpp::LoadURL(const CefString& url) +{ + if (CEF_MEMBER_MISSING(struct_, load_url)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: url; type: string_byref_const + DCHECK(!url.empty()); + if (url.empty()) + return; + + // Execute + struct_->load_url(struct_, + url.GetStruct()); +} + + +void CefFrameCToCpp::LoadString(const CefString& string, const CefString& url) +{ + if (CEF_MEMBER_MISSING(struct_, load_string)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: string; type: string_byref_const + DCHECK(!string.empty()); + if (string.empty()) + return; + // Verify param: url; type: string_byref_const + DCHECK(!url.empty()); + if (url.empty()) + return; + + // Execute + struct_->load_string(struct_, + string.GetStruct(), + url.GetStruct()); +} + + +void CefFrameCToCpp::LoadStream(CefRefPtr stream, + const CefString& url) +{ + if (CEF_MEMBER_MISSING(struct_, load_stream)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: stream; type: refptr_same + DCHECK(stream.get()); + if (!stream.get()) + return; + // Verify param: url; type: string_byref_const + DCHECK(!url.empty()); + if (url.empty()) + return; + + // Execute + struct_->load_stream(struct_, + CefStreamReaderCToCpp::Unwrap(stream), + url.GetStruct()); +} + + +void CefFrameCToCpp::ExecuteJavaScript(const CefString& jsCode, + const CefString& scriptUrl, int startLine) +{ + if (CEF_MEMBER_MISSING(struct_, execute_java_script)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: jsCode; type: string_byref_const + DCHECK(!jsCode.empty()); + if (jsCode.empty()) + return; + // Unverified params: scriptUrl + + // Execute + struct_->execute_java_script(struct_, + jsCode.GetStruct(), + scriptUrl.GetStruct(), + startLine); +} + + +bool CefFrameCToCpp::IsMain() +{ + if (CEF_MEMBER_MISSING(struct_, is_main)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_main(struct_); + + // Return type: bool + return _retval?true:false; +} + + +bool CefFrameCToCpp::IsFocused() +{ + if (CEF_MEMBER_MISSING(struct_, is_focused)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_focused(struct_); + + // Return type: bool + return _retval?true:false; +} + + +CefString CefFrameCToCpp::GetName() +{ + if (CEF_MEMBER_MISSING(struct_, get_name)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_name(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + + +long long CefFrameCToCpp::GetIdentifier() +{ + if (CEF_MEMBER_MISSING(struct_, get_identifier)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + long long _retval = struct_->get_identifier(struct_); + + // Return type: simple + return _retval; +} + + +CefRefPtr CefFrameCToCpp::GetParent() +{ + if (CEF_MEMBER_MISSING(struct_, get_parent)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_frame_t* _retval = struct_->get_parent(struct_); + + // Return type: refptr_same + return CefFrameCToCpp::Wrap(_retval); +} + + +CefString CefFrameCToCpp::GetURL() +{ + if (CEF_MEMBER_MISSING(struct_, get_url)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_url(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + + +CefRefPtr CefFrameCToCpp::GetBrowser() +{ + if (CEF_MEMBER_MISSING(struct_, get_browser)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_browser_t* _retval = struct_->get_browser(struct_); + + // Return type: refptr_same + return CefBrowserCToCpp::Wrap(_retval); +} + + +void CefFrameCToCpp::VisitDOM(CefRefPtr visitor) +{ + if (CEF_MEMBER_MISSING(struct_, visit_dom)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: visitor; type: refptr_diff + DCHECK(visitor.get()); + if (!visitor.get()) + return; + + // Execute + struct_->visit_dom(struct_, + CefDOMVisitorCppToC::Wrap(visitor)); +} + + +CefRefPtr CefFrameCToCpp::GetV8Context() +{ + if (CEF_MEMBER_MISSING(struct_, get_v8context)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_v8context_t* _retval = struct_->get_v8context(struct_); + + // Return type: refptr_same + return CefV8ContextCToCpp::Wrap(_retval); +} + + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = + 0; +#endif + diff --git a/cef/libcef_dll/ctocpp/frame_ctocpp.h b/cef/libcef_dll/ctocpp/frame_ctocpp.h new file mode 100755 index 000000000..87310be79 --- /dev/null +++ b/cef/libcef_dll/ctocpp/frame_ctocpp.h @@ -0,0 +1,67 @@ +// 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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef _FRAME_CTOCPP_H +#define _FRAME_CTOCPP_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/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed wrapper-side only. +class CefFrameCToCpp + : public CefCToCpp +{ +public: + CefFrameCToCpp(cef_frame_t* str) + : CefCToCpp(str) {} + virtual ~CefFrameCToCpp() {} + + // CefFrame methods + 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) OVERRIDE; + virtual void ExecuteJavaScript(const CefString& jsCode, + const CefString& scriptUrl, int startLine) OVERRIDE; + virtual bool IsMain() OVERRIDE; + virtual bool IsFocused() OVERRIDE; + virtual CefString GetName() OVERRIDE; + virtual long long GetIdentifier() OVERRIDE; + virtual CefRefPtr GetParent() OVERRIDE; + virtual CefString GetURL() OVERRIDE; + virtual CefRefPtr GetBrowser() OVERRIDE; + virtual void VisitDOM(CefRefPtr visitor) OVERRIDE; + virtual CefRefPtr GetV8Context() OVERRIDE; +}; + +#endif // USING_CEF_SHARED +#endif // _FRAME_CTOCPP_H + diff --git a/cef/libcef_dll/ctocpp/post_data_ctocpp.cc b/cef/libcef_dll/ctocpp/post_data_ctocpp.cc new file mode 100755 index 000000000..7c6fe1dde --- /dev/null +++ b/cef/libcef_dll/ctocpp/post_data_ctocpp.cc @@ -0,0 +1,148 @@ +// 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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/ctocpp/post_data_ctocpp.h" +#include "libcef_dll/ctocpp/post_data_element_ctocpp.h" + + +// STATIC METHODS - Body may be edited by hand. + +CefRefPtr CefPostData::CreatePostData() +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_post_data_t* _retval = cef_post_data_create(); + + // Return type: refptr_same + return CefPostDataCToCpp::Wrap(_retval); +} + + + +// VIRTUAL METHODS - Body may be edited by hand. + +size_t CefPostDataCToCpp::GetElementCount() +{ + if (CEF_MEMBER_MISSING(struct_, get_element_count)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + size_t _retval = struct_->get_element_count(struct_); + + // Return type: simple + return _retval; +} + + +void CefPostDataCToCpp::GetElements(ElementVector& elements) +{ + if (CEF_MEMBER_MISSING(struct_, get_elements)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Translate param: elements; type: refptr_vec_same_byref + size_t elementsSize = elements.size(); + size_t elementsCount = std::max(GetElementCount(), elementsSize); + cef_post_data_element_t** elementsList = NULL; + if (elementsCount > 0) { + elementsList = new cef_post_data_element_t*[elementsCount]; + DCHECK(elementsList); + if (elementsList) { + memset(elementsList, 0, sizeof(cef_post_data_element_t*)*elementsCount); + } + if (elementsList && elementsSize > 0) { + for (size_t i = 0; i < elementsSize; ++i) { + elementsList[i] = CefPostDataElementCToCpp::Unwrap(elements[i]); + } + } + } + + // Execute + struct_->get_elements(struct_, + &elementsCount, + elementsList); + + // Restore param:elements; type: refptr_vec_same_byref + elements.clear(); + if (elementsCount > 0 && elementsList) { + for (size_t i = 0; i < elementsCount; ++i) { + elements.push_back(CefPostDataElementCToCpp::Wrap(elementsList[i])); + } + delete [] elementsList; + } +} + + +bool CefPostDataCToCpp::RemoveElement(CefRefPtr element) +{ + if (CEF_MEMBER_MISSING(struct_, remove_element)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: element; type: refptr_same + DCHECK(element.get()); + if (!element.get()) + return false; + + // Execute + int _retval = struct_->remove_element(struct_, + CefPostDataElementCToCpp::Unwrap(element)); + + // Return type: bool + return _retval?true:false; +} + + +bool CefPostDataCToCpp::AddElement(CefRefPtr element) +{ + if (CEF_MEMBER_MISSING(struct_, add_element)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: element; type: refptr_same + DCHECK(element.get()); + if (!element.get()) + return false; + + // Execute + int _retval = struct_->add_element(struct_, + CefPostDataElementCToCpp::Unwrap(element)); + + // Return type: bool + return _retval?true:false; +} + + +void CefPostDataCToCpp::RemoveElements() +{ + if (CEF_MEMBER_MISSING(struct_, remove_elements)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->remove_elements(struct_); +} + + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef/libcef_dll/ctocpp/post_data_ctocpp.h b/cef/libcef_dll/ctocpp/post_data_ctocpp.h new file mode 100755 index 000000000..1cc115158 --- /dev/null +++ b/cef/libcef_dll/ctocpp/post_data_ctocpp.h @@ -0,0 +1,44 @@ +// 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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef _POSTDATA_CTOCPP_H +#define _POSTDATA_CTOCPP_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/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed wrapper-side only. +class CefPostDataCToCpp + : public CefCToCpp +{ +public: + CefPostDataCToCpp(cef_post_data_t* str) + : CefCToCpp(str) {} + virtual ~CefPostDataCToCpp() {} + + // CefPostData methods + 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 +#endif // _POSTDATA_CTOCPP_H + diff --git a/cef/libcef_dll/ctocpp/post_data_element_ctocpp.cc b/cef/libcef_dll/ctocpp/post_data_element_ctocpp.cc new file mode 100755 index 000000000..848c6067f --- /dev/null +++ b/cef/libcef_dll/ctocpp/post_data_element_ctocpp.cc @@ -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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/ctocpp/post_data_element_ctocpp.h" + + +// STATIC METHODS - Body may be edited by hand. + +CefRefPtr CefPostDataElement::CreatePostDataElement() +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_post_data_element_t* _retval = cef_post_data_element_create(); + + // Return type: refptr_same + return CefPostDataElementCToCpp::Wrap(_retval); +} + + + +// VIRTUAL METHODS - Body may be edited by hand. + +void CefPostDataElementCToCpp::SetToEmpty() +{ + if (CEF_MEMBER_MISSING(struct_, set_to_empty)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->set_to_empty(struct_); +} + + +void CefPostDataElementCToCpp::SetToFile(const CefString& fileName) +{ + if (CEF_MEMBER_MISSING(struct_, set_to_file)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: fileName; type: string_byref_const + DCHECK(!fileName.empty()); + if (fileName.empty()) + return; + + // Execute + struct_->set_to_file(struct_, + fileName.GetStruct()); +} + + +void CefPostDataElementCToCpp::SetToBytes(size_t size, const void* bytes) +{ + if (CEF_MEMBER_MISSING(struct_, set_to_bytes)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: bytes; type: simple_byaddr + DCHECK(bytes); + if (!bytes) + return; + + // Execute + struct_->set_to_bytes(struct_, + size, + bytes); +} + + +CefPostDataElement::Type CefPostDataElementCToCpp::GetType() +{ + if (CEF_MEMBER_MISSING(struct_, get_type)) + return PDE_TYPE_EMPTY; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_postdataelement_type_t _retval = struct_->get_type(struct_); + + // Return type: simple + return _retval; +} + + +CefString CefPostDataElementCToCpp::GetFile() +{ + if (CEF_MEMBER_MISSING(struct_, get_file)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_file(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + + +size_t CefPostDataElementCToCpp::GetBytesCount() +{ + if (CEF_MEMBER_MISSING(struct_, get_bytes_count)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + size_t _retval = struct_->get_bytes_count(struct_); + + // Return type: simple + return _retval; +} + + +size_t CefPostDataElementCToCpp::GetBytes(size_t size, void* bytes) +{ + if (CEF_MEMBER_MISSING(struct_, get_bytes)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: bytes; type: simple_byaddr + DCHECK(bytes); + if (!bytes) + return 0; + + // Execute + size_t _retval = struct_->get_bytes(struct_, + size, + bytes); + + // Return type: simple + return _retval; +} + + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef/libcef_dll/ctocpp/post_data_element_ctocpp.h b/cef/libcef_dll/ctocpp/post_data_element_ctocpp.h new file mode 100755 index 000000000..13186689a --- /dev/null +++ b/cef/libcef_dll/ctocpp/post_data_element_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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef _POSTDATAELEMENT_CTOCPP_H +#define _POSTDATAELEMENT_CTOCPP_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/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed wrapper-side only. +class CefPostDataElementCToCpp + : public CefCToCpp +{ +public: + CefPostDataElementCToCpp(cef_post_data_element_t* str) + : CefCToCpp(str) {} + virtual ~CefPostDataElementCToCpp() {} + + // CefPostDataElement methods + 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 +#endif // _POSTDATAELEMENT_CTOCPP_H + diff --git a/cef/libcef_dll/ctocpp/request_ctocpp.cc b/cef/libcef_dll/ctocpp/request_ctocpp.cc new file mode 100755 index 000000000..b307f4e3f --- /dev/null +++ b/cef/libcef_dll/ctocpp/request_ctocpp.cc @@ -0,0 +1,292 @@ +// 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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/ctocpp/post_data_ctocpp.h" +#include "libcef_dll/ctocpp/request_ctocpp.h" +#include "libcef_dll/transfer_util.h" + + +// STATIC METHODS - Body may be edited by hand. + +CefRefPtr CefRequest::CreateRequest() +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_request_t* _retval = cef_request_create(); + + // Return type: refptr_same + return CefRequestCToCpp::Wrap(_retval); +} + + + +// VIRTUAL METHODS - Body may be edited by hand. + +CefString CefRequestCToCpp::GetURL() +{ + if (CEF_MEMBER_MISSING(struct_, get_url)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_url(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + + +void CefRequestCToCpp::SetURL(const CefString& url) +{ + if (CEF_MEMBER_MISSING(struct_, set_url)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: url; type: string_byref_const + DCHECK(!url.empty()); + if (url.empty()) + return; + + // Execute + struct_->set_url(struct_, + url.GetStruct()); +} + + +CefString CefRequestCToCpp::GetMethod() +{ + if (CEF_MEMBER_MISSING(struct_, get_method)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_method(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + + +void CefRequestCToCpp::SetMethod(const CefString& method) +{ + if (CEF_MEMBER_MISSING(struct_, set_method)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: method; type: string_byref_const + DCHECK(!method.empty()); + if (method.empty()) + return; + + // Execute + struct_->set_method(struct_, + method.GetStruct()); +} + + +CefRefPtr CefRequestCToCpp::GetPostData() +{ + if (CEF_MEMBER_MISSING(struct_, get_post_data)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_post_data_t* _retval = struct_->get_post_data(struct_); + + // Return type: refptr_same + return CefPostDataCToCpp::Wrap(_retval); +} + + +void CefRequestCToCpp::SetPostData(CefRefPtr postData) +{ + if (CEF_MEMBER_MISSING(struct_, set_post_data)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: postData; type: refptr_same + DCHECK(postData.get()); + if (!postData.get()) + return; + + // Execute + struct_->set_post_data(struct_, + CefPostDataCToCpp::Unwrap(postData)); +} + + +void CefRequestCToCpp::GetHeaderMap(HeaderMap& headerMap) +{ + if (CEF_MEMBER_MISSING(struct_, get_header_map)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Translate param: headerMap; type: string_map_multi_byref + cef_string_multimap_t headerMapMultimap = cef_string_multimap_alloc(); + DCHECK(headerMapMultimap); + if (headerMapMultimap) + transfer_string_multimap_contents(headerMap, headerMapMultimap); + + // Execute + struct_->get_header_map(struct_, + headerMapMultimap); + + // Restore param:headerMap; type: string_map_multi_byref + if (headerMapMultimap) { + headerMap.clear(); + transfer_string_multimap_contents(headerMapMultimap, headerMap); + cef_string_multimap_free(headerMapMultimap); + } +} + + +void CefRequestCToCpp::SetHeaderMap(const HeaderMap& headerMap) +{ + if (CEF_MEMBER_MISSING(struct_, set_header_map)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Translate param: headerMap; type: string_map_multi_byref_const + cef_string_multimap_t headerMapMultimap = cef_string_multimap_alloc(); + DCHECK(headerMapMultimap); + if (headerMapMultimap) + transfer_string_multimap_contents(headerMap, headerMapMultimap); + + // Execute + struct_->set_header_map(struct_, + headerMapMultimap); + + // Restore param:headerMap; type: string_map_multi_byref_const + if (headerMapMultimap) + cef_string_multimap_free(headerMapMultimap); +} + + +void CefRequestCToCpp::Set(const CefString& url, const CefString& method, + CefRefPtr postData, const HeaderMap& headerMap) +{ + if (CEF_MEMBER_MISSING(struct_, set)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: url; type: string_byref_const + DCHECK(!url.empty()); + if (url.empty()) + return; + // Verify param: method; type: string_byref_const + DCHECK(!method.empty()); + if (method.empty()) + return; + // Unverified params: postData + + // Translate param: headerMap; type: string_map_multi_byref_const + cef_string_multimap_t headerMapMultimap = cef_string_multimap_alloc(); + DCHECK(headerMapMultimap); + if (headerMapMultimap) + transfer_string_multimap_contents(headerMap, headerMapMultimap); + + // Execute + struct_->set(struct_, + url.GetStruct(), + method.GetStruct(), + CefPostDataCToCpp::Unwrap(postData), + headerMapMultimap); + + // Restore param:headerMap; type: string_map_multi_byref_const + if (headerMapMultimap) + cef_string_multimap_free(headerMapMultimap); +} + + +CefRequest::RequestFlags CefRequestCToCpp::GetFlags() +{ + if (CEF_MEMBER_MISSING(struct_, get_flags)) + return WUR_FLAG_NONE; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_weburlrequest_flags_t _retval = struct_->get_flags(struct_); + + // Return type: simple + return _retval; +} + + +void CefRequestCToCpp::SetFlags(RequestFlags flags) +{ + if (CEF_MEMBER_MISSING(struct_, set_flags)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->set_flags(struct_, + flags); +} + + +CefString CefRequestCToCpp::GetFirstPartyForCookies() +{ + if (CEF_MEMBER_MISSING(struct_, get_first_party_for_cookies)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_first_party_for_cookies(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + + +void CefRequestCToCpp::SetFirstPartyForCookies(const CefString& url) +{ + if (CEF_MEMBER_MISSING(struct_, set_first_party_for_cookies)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: url; type: string_byref_const + DCHECK(!url.empty()); + if (url.empty()) + return; + + // Execute + struct_->set_first_party_for_cookies(struct_, + url.GetStruct()); +} + + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef/libcef_dll/ctocpp/request_ctocpp.h b/cef/libcef_dll/ctocpp/request_ctocpp.h new file mode 100755 index 000000000..c156c2e35 --- /dev/null +++ b/cef/libcef_dll/ctocpp/request_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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef _REQUEST_CTOCPP_H +#define _REQUEST_CTOCPP_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/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed wrapper-side only. +class CefRequestCToCpp + : public CefCToCpp +{ +public: + CefRequestCToCpp(cef_request_t* str) + : CefCToCpp(str) {} + virtual ~CefRequestCToCpp() {} + + // CefRequest methods + 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) 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 +#endif // _REQUEST_CTOCPP_H + diff --git a/cef/libcef_dll/ctocpp/response_ctocpp.cc b/cef/libcef_dll/ctocpp/response_ctocpp.cc new file mode 100755 index 000000000..500abc12e --- /dev/null +++ b/cef/libcef_dll/ctocpp/response_ctocpp.cc @@ -0,0 +1,194 @@ +// 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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/ctocpp/response_ctocpp.h" +#include "libcef_dll/transfer_util.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +int CefResponseCToCpp::GetStatus() +{ + if (CEF_MEMBER_MISSING(struct_, get_status)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->get_status(struct_); + + // Return type: simple + return _retval; +} + + +void CefResponseCToCpp::SetStatus(int status) +{ + if (CEF_MEMBER_MISSING(struct_, set_status)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->set_status(struct_, + status); +} + + +CefString CefResponseCToCpp::GetStatusText() +{ + if (CEF_MEMBER_MISSING(struct_, get_status_text)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_status_text(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + + +void CefResponseCToCpp::SetStatusText(const CefString& statusText) +{ + if (CEF_MEMBER_MISSING(struct_, set_status_text)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: statusText; type: string_byref_const + DCHECK(!statusText.empty()); + if (statusText.empty()) + return; + + // Execute + struct_->set_status_text(struct_, + statusText.GetStruct()); +} + + +CefString CefResponseCToCpp::GetMimeType() +{ + if (CEF_MEMBER_MISSING(struct_, get_mime_type)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_mime_type(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + + +void CefResponseCToCpp::SetMimeType(const CefString& mimeType) +{ + if (CEF_MEMBER_MISSING(struct_, set_mime_type)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: mimeType; type: string_byref_const + DCHECK(!mimeType.empty()); + if (mimeType.empty()) + return; + + // Execute + struct_->set_mime_type(struct_, + mimeType.GetStruct()); +} + + +CefString CefResponseCToCpp::GetHeader(const CefString& name) +{ + if (CEF_MEMBER_MISSING(struct_, get_header)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: name; type: string_byref_const + DCHECK(!name.empty()); + if (name.empty()) + return CefString(); + + // Execute + cef_string_userfree_t _retval = struct_->get_header(struct_, + name.GetStruct()); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + + +void CefResponseCToCpp::GetHeaderMap(HeaderMap& headerMap) +{ + if (CEF_MEMBER_MISSING(struct_, get_header_map)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Translate param: headerMap; type: string_map_multi_byref + cef_string_multimap_t headerMapMultimap = cef_string_multimap_alloc(); + DCHECK(headerMapMultimap); + if (headerMapMultimap) + transfer_string_multimap_contents(headerMap, headerMapMultimap); + + // Execute + struct_->get_header_map(struct_, + headerMapMultimap); + + // Restore param:headerMap; type: string_map_multi_byref + if (headerMapMultimap) { + headerMap.clear(); + transfer_string_multimap_contents(headerMapMultimap, headerMap); + cef_string_multimap_free(headerMapMultimap); + } +} + + +void CefResponseCToCpp::SetHeaderMap(const HeaderMap& headerMap) +{ + if (CEF_MEMBER_MISSING(struct_, set_header_map)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Translate param: headerMap; type: string_map_multi_byref_const + cef_string_multimap_t headerMapMultimap = cef_string_multimap_alloc(); + DCHECK(headerMapMultimap); + if (headerMapMultimap) + transfer_string_multimap_contents(headerMap, headerMapMultimap); + + // Execute + struct_->set_header_map(struct_, + headerMapMultimap); + + // Restore param:headerMap; type: string_map_multi_byref_const + if (headerMapMultimap) + cef_string_multimap_free(headerMapMultimap); +} + + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef/libcef_dll/ctocpp/response_ctocpp.h b/cef/libcef_dll/ctocpp/response_ctocpp.h new file mode 100755 index 000000000..cd1225616 --- /dev/null +++ b/cef/libcef_dll/ctocpp/response_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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef _RESPONSE_CTOCPP_H +#define _RESPONSE_CTOCPP_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/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed wrapper-side only. +class CefResponseCToCpp + : public CefCToCpp +{ +public: + CefResponseCToCpp(cef_response_t* str) + : CefCToCpp(str) {} + virtual ~CefResponseCToCpp() {} + + // CefResponse methods + 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 +#endif // _RESPONSE_CTOCPP_H + diff --git a/cef/libcef_dll/ctocpp/scheme_handler_callback_ctocpp.cc b/cef/libcef_dll/ctocpp/scheme_handler_callback_ctocpp.cc new file mode 100755 index 000000000..9c1e7fd6d --- /dev/null +++ b/cef/libcef_dll/ctocpp/scheme_handler_callback_ctocpp.cc @@ -0,0 +1,59 @@ +// 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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/ctocpp/scheme_handler_callback_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +void CefSchemeHandlerCallbackCToCpp::HeadersAvailable() +{ + if (CEF_MEMBER_MISSING(struct_, headers_available)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->headers_available(struct_); +} + + +void CefSchemeHandlerCallbackCToCpp::BytesAvailable() +{ + if (CEF_MEMBER_MISSING(struct_, bytes_available)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->bytes_available(struct_); +} + + +void CefSchemeHandlerCallbackCToCpp::Cancel() +{ + if (CEF_MEMBER_MISSING(struct_, cancel)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->cancel(struct_); +} + + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef/libcef_dll/ctocpp/scheme_handler_callback_ctocpp.h b/cef/libcef_dll/ctocpp/scheme_handler_callback_ctocpp.h new file mode 100755 index 000000000..1514cdf9a --- /dev/null +++ b/cef/libcef_dll/ctocpp/scheme_handler_callback_ctocpp.h @@ -0,0 +1,44 @@ +// 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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef _SCHEMEHANDLERCALLBACK_CTOCPP_H +#define _SCHEMEHANDLERCALLBACK_CTOCPP_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/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed wrapper-side only. +class CefSchemeHandlerCallbackCToCpp + : public CefCToCpp +{ +public: + CefSchemeHandlerCallbackCToCpp(cef_scheme_handler_callback_t* str) + : CefCToCpp(str) {} + virtual ~CefSchemeHandlerCallbackCToCpp() {} + + // CefSchemeHandlerCallback methods + virtual void HeadersAvailable() OVERRIDE; + virtual void BytesAvailable() OVERRIDE; + virtual void Cancel() OVERRIDE; +}; + +#endif // USING_CEF_SHARED +#endif // _SCHEMEHANDLERCALLBACK_CTOCPP_H + diff --git a/cef/libcef_dll/ctocpp/stream_reader_ctocpp.cc b/cef/libcef_dll/ctocpp/stream_reader_ctocpp.cc new file mode 100755 index 000000000..98c73e515 --- /dev/null +++ b/cef/libcef_dll/ctocpp/stream_reader_ctocpp.cc @@ -0,0 +1,155 @@ +// 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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/read_handler_cpptoc.h" +#include "libcef_dll/ctocpp/stream_reader_ctocpp.h" + + +// STATIC METHODS - Body may be edited by hand. + +CefRefPtr CefStreamReader::CreateForFile( + const CefString& fileName) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: fileName; type: string_byref_const + DCHECK(!fileName.empty()); + if (fileName.empty()) + return NULL; + + // Execute + cef_stream_reader_t* _retval = cef_stream_reader_create_for_file( + fileName.GetStruct()); + + // Return type: refptr_same + return CefStreamReaderCToCpp::Wrap(_retval); +} + + +CefRefPtr CefStreamReader::CreateForData(void* data, + size_t size) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: data; type: simple_byaddr + DCHECK(data); + if (!data) + return NULL; + + // Execute + cef_stream_reader_t* _retval = cef_stream_reader_create_for_data( + data, + size); + + // Return type: refptr_same + return CefStreamReaderCToCpp::Wrap(_retval); +} + + +CefRefPtr CefStreamReader::CreateForHandler( + CefRefPtr handler) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: handler; type: refptr_diff + DCHECK(handler.get()); + if (!handler.get()) + return NULL; + + // Execute + cef_stream_reader_t* _retval = cef_stream_reader_create_for_handler( + CefReadHandlerCppToC::Wrap(handler)); + + // Return type: refptr_same + return CefStreamReaderCToCpp::Wrap(_retval); +} + + + +// VIRTUAL METHODS - Body may be edited by hand. + +size_t CefStreamReaderCToCpp::Read(void* ptr, size_t size, size_t n) +{ + if (CEF_MEMBER_MISSING(struct_, read)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: ptr; type: simple_byaddr + DCHECK(ptr); + if (!ptr) + return 0; + + // Execute + size_t _retval = struct_->read(struct_, + ptr, + size, + n); + + // Return type: simple + return _retval; +} + + +int CefStreamReaderCToCpp::Seek(long offset, int whence) +{ + if (CEF_MEMBER_MISSING(struct_, seek)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->seek(struct_, + offset, + whence); + + // Return type: simple + return _retval; +} + + +long CefStreamReaderCToCpp::Tell() +{ + if (CEF_MEMBER_MISSING(struct_, tell)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + long _retval = struct_->tell(struct_); + + // Return type: simple + return _retval; +} + + +int CefStreamReaderCToCpp::Eof() +{ + if (CEF_MEMBER_MISSING(struct_, eof)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->eof(struct_); + + // Return type: simple + return _retval; +} + + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef/libcef_dll/ctocpp/stream_reader_ctocpp.h b/cef/libcef_dll/ctocpp/stream_reader_ctocpp.h new file mode 100755 index 000000000..e9f0b7bc1 --- /dev/null +++ b/cef/libcef_dll/ctocpp/stream_reader_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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef _STREAMREADER_CTOCPP_H +#define _STREAMREADER_CTOCPP_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/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed wrapper-side only. +class CefStreamReaderCToCpp + : public CefCToCpp +{ +public: + CefStreamReaderCToCpp(cef_stream_reader_t* str) + : CefCToCpp( + str) {} + virtual ~CefStreamReaderCToCpp() {} + + // CefStreamReader methods + 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 +#endif // _STREAMREADER_CTOCPP_H + diff --git a/cef/libcef_dll/ctocpp/stream_writer_ctocpp.cc b/cef/libcef_dll/ctocpp/stream_writer_ctocpp.cc new file mode 100755 index 000000000..39911f21a --- /dev/null +++ b/cef/libcef_dll/ctocpp/stream_writer_ctocpp.cc @@ -0,0 +1,135 @@ +// 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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/write_handler_cpptoc.h" +#include "libcef_dll/ctocpp/stream_writer_ctocpp.h" + + +// STATIC METHODS - Body may be edited by hand. + +CefRefPtr CefStreamWriter::CreateForFile( + const CefString& fileName) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: fileName; type: string_byref_const + DCHECK(!fileName.empty()); + if (fileName.empty()) + return NULL; + + // Execute + cef_stream_writer_t* _retval = cef_stream_writer_create_for_file( + fileName.GetStruct()); + + // Return type: refptr_same + return CefStreamWriterCToCpp::Wrap(_retval); +} + + +CefRefPtr CefStreamWriter::CreateForHandler( + CefRefPtr handler) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: handler; type: refptr_diff + DCHECK(handler.get()); + if (!handler.get()) + return NULL; + + // Execute + cef_stream_writer_t* _retval = cef_stream_writer_create_for_handler( + CefWriteHandlerCppToC::Wrap(handler)); + + // Return type: refptr_same + return CefStreamWriterCToCpp::Wrap(_retval); +} + + + +// VIRTUAL METHODS - Body may be edited by hand. + +size_t CefStreamWriterCToCpp::Write(const void* ptr, size_t size, size_t n) +{ + if (CEF_MEMBER_MISSING(struct_, write)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: ptr; type: simple_byaddr + DCHECK(ptr); + if (!ptr) + return 0; + + // Execute + size_t _retval = struct_->write(struct_, + ptr, + size, + n); + + // Return type: simple + return _retval; +} + + +int CefStreamWriterCToCpp::Seek(long offset, int whence) +{ + if (CEF_MEMBER_MISSING(struct_, seek)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->seek(struct_, + offset, + whence); + + // Return type: simple + return _retval; +} + + +long CefStreamWriterCToCpp::Tell() +{ + if (CEF_MEMBER_MISSING(struct_, tell)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + long _retval = struct_->tell(struct_); + + // Return type: simple + return _retval; +} + + +int CefStreamWriterCToCpp::Flush() +{ + if (CEF_MEMBER_MISSING(struct_, flush)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->flush(struct_); + + // Return type: simple + return _retval; +} + + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef/libcef_dll/ctocpp/stream_writer_ctocpp.h b/cef/libcef_dll/ctocpp/stream_writer_ctocpp.h new file mode 100755 index 000000000..12083c320 --- /dev/null +++ b/cef/libcef_dll/ctocpp/stream_writer_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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef _STREAMWRITER_CTOCPP_H +#define _STREAMWRITER_CTOCPP_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/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed wrapper-side only. +class CefStreamWriterCToCpp + : public CefCToCpp +{ +public: + CefStreamWriterCToCpp(cef_stream_writer_t* str) + : CefCToCpp( + str) {} + virtual ~CefStreamWriterCToCpp() {} + + // CefStreamWriter methods + 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 +#endif // _STREAMWRITER_CTOCPP_H + diff --git a/cef/libcef_dll/ctocpp/v8context_ctocpp.cc b/cef/libcef_dll/ctocpp/v8context_ctocpp.cc new file mode 100755 index 000000000..930f1312d --- /dev/null +++ b/cef/libcef_dll/ctocpp/v8context_ctocpp.cc @@ -0,0 +1,161 @@ +// 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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/ctocpp/browser_ctocpp.h" +#include "libcef_dll/ctocpp/frame_ctocpp.h" +#include "libcef_dll/ctocpp/v8context_ctocpp.h" +#include "libcef_dll/ctocpp/v8value_ctocpp.h" + + +// STATIC METHODS - Body may be edited by hand. + +CefRefPtr CefV8Context::GetCurrentContext() +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_v8context_t* _retval = cef_v8context_get_current_context(); + + // Return type: refptr_same + return CefV8ContextCToCpp::Wrap(_retval); +} + + +CefRefPtr CefV8Context::GetEnteredContext() +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_v8context_t* _retval = cef_v8context_get_entered_context(); + + // Return type: refptr_same + return CefV8ContextCToCpp::Wrap(_retval); +} + + +bool CefV8Context::InContext() +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = cef_v8context_in_context(); + + // Return type: bool + return _retval?true:false; +} + + + +// VIRTUAL METHODS - Body may be edited by hand. + +CefRefPtr CefV8ContextCToCpp::GetBrowser() +{ + if (CEF_MEMBER_MISSING(struct_, get_browser)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_browser_t* _retval = struct_->get_browser(struct_); + + // Return type: refptr_same + return CefBrowserCToCpp::Wrap(_retval); +} + + +CefRefPtr CefV8ContextCToCpp::GetFrame() +{ + if (CEF_MEMBER_MISSING(struct_, get_frame)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_frame_t* _retval = struct_->get_frame(struct_); + + // Return type: refptr_same + return CefFrameCToCpp::Wrap(_retval); +} + + +CefRefPtr CefV8ContextCToCpp::GetGlobal() +{ + if (CEF_MEMBER_MISSING(struct_, get_global)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_v8value_t* _retval = struct_->get_global(struct_); + + // Return type: refptr_same + return CefV8ValueCToCpp::Wrap(_retval); +} + + +bool CefV8ContextCToCpp::Enter() +{ + if (CEF_MEMBER_MISSING(struct_, enter)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->enter(struct_); + + // Return type: bool + return _retval?true:false; +} + + +bool CefV8ContextCToCpp::Exit() +{ + if (CEF_MEMBER_MISSING(struct_, exit)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->exit(struct_); + + // Return type: bool + return _retval?true:false; +} + + +bool CefV8ContextCToCpp::IsSame(CefRefPtr that) +{ + if (CEF_MEMBER_MISSING(struct_, is_same)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: that; type: refptr_same + DCHECK(that.get()); + if (!that.get()) + return false; + + // Execute + int _retval = struct_->is_same(struct_, + CefV8ContextCToCpp::Unwrap(that)); + + // Return type: bool + return _retval?true:false; +} + + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef/libcef_dll/ctocpp/v8context_ctocpp.h b/cef/libcef_dll/ctocpp/v8context_ctocpp.h new file mode 100755 index 000000000..6bb23f8e9 --- /dev/null +++ b/cef/libcef_dll/ctocpp/v8context_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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef _V8CONTEXT_CTOCPP_H +#define _V8CONTEXT_CTOCPP_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/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed wrapper-side only. +class CefV8ContextCToCpp + : public CefCToCpp +{ +public: + CefV8ContextCToCpp(cef_v8context_t* str) + : CefCToCpp(str) {} + virtual ~CefV8ContextCToCpp() {} + + // CefV8Context methods + virtual CefRefPtr GetBrowser() OVERRIDE; + virtual CefRefPtr GetFrame() OVERRIDE; + virtual CefRefPtr GetGlobal() OVERRIDE; + virtual bool Enter() OVERRIDE; + virtual bool Exit() OVERRIDE; + virtual bool IsSame(CefRefPtr that) OVERRIDE; +}; + +#endif // USING_CEF_SHARED +#endif // _V8CONTEXT_CTOCPP_H + diff --git a/cef/libcef_dll/ctocpp/v8exception_ctocpp.cc b/cef/libcef_dll/ctocpp/v8exception_ctocpp.cc new file mode 100755 index 000000000..0e3241d97 --- /dev/null +++ b/cef/libcef_dll/ctocpp/v8exception_ctocpp.cc @@ -0,0 +1,149 @@ +// 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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/ctocpp/v8exception_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +CefString CefV8ExceptionCToCpp::GetMessage() +{ + if (CEF_MEMBER_MISSING(struct_, get_message)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_message(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + + +CefString CefV8ExceptionCToCpp::GetSourceLine() +{ + if (CEF_MEMBER_MISSING(struct_, get_source_line)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_source_line(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + + +CefString CefV8ExceptionCToCpp::GetScriptResourceName() +{ + if (CEF_MEMBER_MISSING(struct_, get_script_resource_name)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_script_resource_name(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + + +int CefV8ExceptionCToCpp::GetLineNumber() +{ + if (CEF_MEMBER_MISSING(struct_, get_line_number)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->get_line_number(struct_); + + // Return type: simple + return _retval; +} + + +int CefV8ExceptionCToCpp::GetStartPosition() +{ + if (CEF_MEMBER_MISSING(struct_, get_start_position)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->get_start_position(struct_); + + // Return type: simple + return _retval; +} + + +int CefV8ExceptionCToCpp::GetEndPosition() +{ + if (CEF_MEMBER_MISSING(struct_, get_end_position)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->get_end_position(struct_); + + // Return type: simple + return _retval; +} + + +int CefV8ExceptionCToCpp::GetStartColumn() +{ + if (CEF_MEMBER_MISSING(struct_, get_start_column)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->get_start_column(struct_); + + // Return type: simple + return _retval; +} + + +int CefV8ExceptionCToCpp::GetEndColumn() +{ + if (CEF_MEMBER_MISSING(struct_, get_end_column)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->get_end_column(struct_); + + // Return type: simple + return _retval; +} + + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef/libcef_dll/ctocpp/v8exception_ctocpp.h b/cef/libcef_dll/ctocpp/v8exception_ctocpp.h new file mode 100755 index 000000000..991888af8 --- /dev/null +++ b/cef/libcef_dll/ctocpp/v8exception_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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef _V8EXCEPTION_CTOCPP_H +#define _V8EXCEPTION_CTOCPP_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/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed wrapper-side only. +class CefV8ExceptionCToCpp + : public CefCToCpp +{ +public: + CefV8ExceptionCToCpp(cef_v8exception_t* str) + : CefCToCpp( + str) {} + virtual ~CefV8ExceptionCToCpp() {} + + // CefV8Exception methods + virtual CefString GetMessage() OVERRIDE; + virtual CefString GetSourceLine() OVERRIDE; + virtual CefString GetScriptResourceName() OVERRIDE; + virtual int GetLineNumber() OVERRIDE; + virtual int GetStartPosition() OVERRIDE; + virtual int GetEndPosition() OVERRIDE; + virtual int GetStartColumn() OVERRIDE; + virtual int GetEndColumn() OVERRIDE; +}; + +#endif // USING_CEF_SHARED +#endif // _V8EXCEPTION_CTOCPP_H + diff --git a/cef/libcef_dll/ctocpp/v8value_ctocpp.cc b/cef/libcef_dll/ctocpp/v8value_ctocpp.cc new file mode 100755 index 000000000..78adb9d9e --- /dev/null +++ b/cef/libcef_dll/ctocpp/v8value_ctocpp.cc @@ -0,0 +1,870 @@ +// 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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/base_cpptoc.h" +#include "libcef_dll/cpptoc/v8accessor_cpptoc.h" +#include "libcef_dll/cpptoc/v8handler_cpptoc.h" +#include "libcef_dll/ctocpp/v8context_ctocpp.h" +#include "libcef_dll/ctocpp/v8exception_ctocpp.h" +#include "libcef_dll/ctocpp/v8value_ctocpp.h" +#include "libcef_dll/transfer_util.h" + + +// STATIC METHODS - Body may be edited by hand. + +CefRefPtr CefV8Value::CreateUndefined() +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_v8value_t* _retval = cef_v8value_create_undefined(); + + // Return type: refptr_same + return CefV8ValueCToCpp::Wrap(_retval); +} + + +CefRefPtr CefV8Value::CreateNull() +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_v8value_t* _retval = cef_v8value_create_null(); + + // Return type: refptr_same + return CefV8ValueCToCpp::Wrap(_retval); +} + + +CefRefPtr CefV8Value::CreateBool(bool value) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_v8value_t* _retval = cef_v8value_create_bool( + value); + + // Return type: refptr_same + return CefV8ValueCToCpp::Wrap(_retval); +} + + +CefRefPtr CefV8Value::CreateInt(int value) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_v8value_t* _retval = cef_v8value_create_int( + value); + + // Return type: refptr_same + return CefV8ValueCToCpp::Wrap(_retval); +} + + +CefRefPtr CefV8Value::CreateDouble(double value) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_v8value_t* _retval = cef_v8value_create_double( + value); + + // Return type: refptr_same + return CefV8ValueCToCpp::Wrap(_retval); +} + + +CefRefPtr CefV8Value::CreateDate(const CefTime& date) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_v8value_t* _retval = cef_v8value_create_date( + &date); + + // Return type: refptr_same + return CefV8ValueCToCpp::Wrap(_retval); +} + + +CefRefPtr CefV8Value::CreateString(const CefString& value) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Unverified params: value + + // Execute + cef_v8value_t* _retval = cef_v8value_create_string( + value.GetStruct()); + + // Return type: refptr_same + return CefV8ValueCToCpp::Wrap(_retval); +} + + +CefRefPtr CefV8Value::CreateObject(CefRefPtr user_data) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Unverified params: user_data + + // Execute + cef_v8value_t* _retval = cef_v8value_create_object( + CefBaseCppToC::Wrap(user_data)); + + // Return type: refptr_same + return CefV8ValueCToCpp::Wrap(_retval); +} + + +CefRefPtr CefV8Value::CreateObject(CefRefPtr user_data, + CefRefPtr accessor) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Unverified params: user_data, accessor + + // Execute + cef_v8value_t* _retval = cef_v8value_create_object_with_accessor( + CefBaseCppToC::Wrap(user_data), + CefV8AccessorCppToC::Wrap(accessor)); + + // Return type: refptr_same + return CefV8ValueCToCpp::Wrap(_retval); +} + + +CefRefPtr CefV8Value::CreateArray() +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_v8value_t* _retval = cef_v8value_create_array(); + + // Return type: refptr_same + return CefV8ValueCToCpp::Wrap(_retval); +} + + +CefRefPtr CefV8Value::CreateFunction(const CefString& name, + CefRefPtr handler) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: name; type: string_byref_const + DCHECK(!name.empty()); + if (name.empty()) + return NULL; + // Verify param: handler; type: refptr_diff + DCHECK(handler.get()); + if (!handler.get()) + return NULL; + + // Execute + cef_v8value_t* _retval = cef_v8value_create_function( + name.GetStruct(), + CefV8HandlerCppToC::Wrap(handler)); + + // Return type: refptr_same + return CefV8ValueCToCpp::Wrap(_retval); +} + + + +// VIRTUAL METHODS - Body may be edited by hand. + +bool CefV8ValueCToCpp::IsUndefined() +{ + if (CEF_MEMBER_MISSING(struct_, is_undefined)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_undefined(struct_); + + // Return type: bool + return _retval?true:false; +} + + +bool CefV8ValueCToCpp::IsNull() +{ + if (CEF_MEMBER_MISSING(struct_, is_null)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_null(struct_); + + // Return type: bool + return _retval?true:false; +} + + +bool CefV8ValueCToCpp::IsBool() +{ + if (CEF_MEMBER_MISSING(struct_, is_bool)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_bool(struct_); + + // Return type: bool + return _retval?true:false; +} + + +bool CefV8ValueCToCpp::IsInt() +{ + if (CEF_MEMBER_MISSING(struct_, is_int)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_int(struct_); + + // Return type: bool + return _retval?true:false; +} + + +bool CefV8ValueCToCpp::IsDouble() +{ + if (CEF_MEMBER_MISSING(struct_, is_double)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_double(struct_); + + // Return type: bool + return _retval?true:false; +} + + +bool CefV8ValueCToCpp::IsDate() +{ + if (CEF_MEMBER_MISSING(struct_, is_date)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_date(struct_); + + // Return type: bool + return _retval?true:false; +} + + +bool CefV8ValueCToCpp::IsString() +{ + if (CEF_MEMBER_MISSING(struct_, is_string)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_string(struct_); + + // Return type: bool + return _retval?true:false; +} + + +bool CefV8ValueCToCpp::IsObject() +{ + if (CEF_MEMBER_MISSING(struct_, is_object)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_object(struct_); + + // Return type: bool + return _retval?true:false; +} + + +bool CefV8ValueCToCpp::IsArray() +{ + if (CEF_MEMBER_MISSING(struct_, is_array)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_array(struct_); + + // Return type: bool + return _retval?true:false; +} + + +bool CefV8ValueCToCpp::IsFunction() +{ + if (CEF_MEMBER_MISSING(struct_, is_function)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_function(struct_); + + // Return type: bool + return _retval?true:false; +} + + +bool CefV8ValueCToCpp::IsSame(CefRefPtr that) +{ + if (CEF_MEMBER_MISSING(struct_, is_same)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: that; type: refptr_same + DCHECK(that.get()); + if (!that.get()) + return false; + + // Execute + int _retval = struct_->is_same(struct_, + CefV8ValueCToCpp::Unwrap(that)); + + // Return type: bool + return _retval?true:false; +} + + +bool CefV8ValueCToCpp::GetBoolValue() +{ + if (CEF_MEMBER_MISSING(struct_, get_bool_value)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->get_bool_value(struct_); + + // Return type: bool + return _retval?true:false; +} + + +int CefV8ValueCToCpp::GetIntValue() +{ + if (CEF_MEMBER_MISSING(struct_, get_int_value)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->get_int_value(struct_); + + // Return type: simple + return _retval; +} + + +double CefV8ValueCToCpp::GetDoubleValue() +{ + if (CEF_MEMBER_MISSING(struct_, get_double_value)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + double _retval = struct_->get_double_value(struct_); + + // Return type: simple + return _retval; +} + + +CefTime CefV8ValueCToCpp::GetDateValue() +{ + if (CEF_MEMBER_MISSING(struct_, get_date_value)) + return CefTime(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_time_t _retval = struct_->get_date_value(struct_); + + // Return type: simple + return _retval; +} + + +CefString CefV8ValueCToCpp::GetStringValue() +{ + if (CEF_MEMBER_MISSING(struct_, get_string_value)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_string_value(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + + +bool CefV8ValueCToCpp::HasValue(const CefString& key) +{ + if (CEF_MEMBER_MISSING(struct_, has_value_bykey)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: key; type: string_byref_const + DCHECK(!key.empty()); + if (key.empty()) + return false; + + // Execute + int _retval = struct_->has_value_bykey(struct_, + key.GetStruct()); + + // Return type: bool + return _retval?true:false; +} + + +bool CefV8ValueCToCpp::HasValue(int index) +{ + if (CEF_MEMBER_MISSING(struct_, has_value_byindex)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: index; type: simple_byval + DCHECK(index >= 0); + if (index < 0) + return false; + + // Execute + int _retval = struct_->has_value_byindex(struct_, + index); + + // Return type: bool + return _retval?true:false; +} + + +bool CefV8ValueCToCpp::DeleteValue(const CefString& key) +{ + if (CEF_MEMBER_MISSING(struct_, delete_value_bykey)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: key; type: string_byref_const + DCHECK(!key.empty()); + if (key.empty()) + return false; + + // Execute + int _retval = struct_->delete_value_bykey(struct_, + key.GetStruct()); + + // Return type: bool + return _retval?true:false; +} + + +bool CefV8ValueCToCpp::DeleteValue(int index) +{ + if (CEF_MEMBER_MISSING(struct_, delete_value_byindex)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: index; type: simple_byval + DCHECK(index >= 0); + if (index < 0) + return false; + + // Execute + int _retval = struct_->delete_value_byindex(struct_, + index); + + // Return type: bool + return _retval?true:false; +} + + +CefRefPtr CefV8ValueCToCpp::GetValue(const CefString& key) +{ + if (CEF_MEMBER_MISSING(struct_, get_value_bykey)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: key; type: string_byref_const + DCHECK(!key.empty()); + if (key.empty()) + return NULL; + + // Execute + cef_v8value_t* _retval = struct_->get_value_bykey(struct_, + key.GetStruct()); + + // Return type: refptr_same + return CefV8ValueCToCpp::Wrap(_retval); +} + + +CefRefPtr CefV8ValueCToCpp::GetValue(int index) +{ + if (CEF_MEMBER_MISSING(struct_, get_value_byindex)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: index; type: simple_byval + DCHECK(index >= 0); + if (index < 0) + return NULL; + + // Execute + cef_v8value_t* _retval = struct_->get_value_byindex(struct_, + index); + + // Return type: refptr_same + return CefV8ValueCToCpp::Wrap(_retval); +} + + +bool CefV8ValueCToCpp::SetValue(const CefString& key, + CefRefPtr value, PropertyAttribute attribute) +{ + if (CEF_MEMBER_MISSING(struct_, set_value_bykey)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: key; type: string_byref_const + DCHECK(!key.empty()); + if (key.empty()) + return false; + // Verify param: value; type: refptr_same + DCHECK(value.get()); + if (!value.get()) + return false; + + // Execute + int _retval = struct_->set_value_bykey(struct_, + key.GetStruct(), + CefV8ValueCToCpp::Unwrap(value), + attribute); + + // Return type: bool + return _retval?true:false; +} + + +bool CefV8ValueCToCpp::SetValue(int index, CefRefPtr value) +{ + if (CEF_MEMBER_MISSING(struct_, set_value_byindex)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: index; type: simple_byval + DCHECK(index >= 0); + if (index < 0) + return false; + // Verify param: value; type: refptr_same + DCHECK(value.get()); + if (!value.get()) + return false; + + // Execute + int _retval = struct_->set_value_byindex(struct_, + index, + CefV8ValueCToCpp::Unwrap(value)); + + // Return type: bool + return _retval?true:false; +} + + +bool CefV8ValueCToCpp::SetValue(const CefString& key, AccessControl settings, + PropertyAttribute attribute) +{ + if (CEF_MEMBER_MISSING(struct_, set_value_byaccessor)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: key; type: string_byref_const + DCHECK(!key.empty()); + if (key.empty()) + return false; + + // Execute + int _retval = struct_->set_value_byaccessor(struct_, + key.GetStruct(), + settings, + attribute); + + // Return type: bool + return _retval?true:false; +} + + +bool CefV8ValueCToCpp::GetKeys(std::vector& keys) +{ + if (CEF_MEMBER_MISSING(struct_, get_keys)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Translate param: keys; type: string_vec_byref + cef_string_list_t keysList = cef_string_list_alloc(); + DCHECK(keysList); + if (keysList) + transfer_string_list_contents(keys, keysList); + + // Execute + int _retval = struct_->get_keys(struct_, + keysList); + + // Restore param:keys; type: string_vec_byref + if (keysList) { + keys.clear(); + transfer_string_list_contents(keysList, keys); + cef_string_list_free(keysList); + } + + // Return type: bool + return _retval?true:false; +} + + +CefRefPtr CefV8ValueCToCpp::GetUserData() +{ + if (CEF_MEMBER_MISSING(struct_, get_user_data)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_base_t* _retval = struct_->get_user_data(struct_); + + // Return type: refptr_diff + return CefBaseCppToC::Unwrap(_retval); +} + + +int CefV8ValueCToCpp::GetArrayLength() +{ + if (CEF_MEMBER_MISSING(struct_, get_array_length)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->get_array_length(struct_); + + // Return type: simple + return _retval; +} + + +CefString CefV8ValueCToCpp::GetFunctionName() +{ + if (CEF_MEMBER_MISSING(struct_, get_function_name)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_function_name(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + + +CefRefPtr CefV8ValueCToCpp::GetFunctionHandler() +{ + if (CEF_MEMBER_MISSING(struct_, get_function_handler)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_v8handler_t* _retval = struct_->get_function_handler(struct_); + + // Return type: refptr_diff + return CefV8HandlerCppToC::Unwrap(_retval); +} + + +bool CefV8ValueCToCpp::ExecuteFunction(CefRefPtr object, + const CefV8ValueList& arguments, CefRefPtr& retval, + CefRefPtr& exception, bool rethrow_exception) +{ + if (CEF_MEMBER_MISSING(struct_, execute_function)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Unverified params: object + + // Translate param: arguments; type: refptr_vec_same_byref_const + const size_t argumentsCount = arguments.size(); + cef_v8value_t** argumentsList = NULL; + if (argumentsCount > 0) { + argumentsList = new cef_v8value_t*[argumentsCount]; + DCHECK(argumentsList); + if (argumentsList) { + for (size_t i = 0; i < argumentsCount; ++i) { + argumentsList[i] = CefV8ValueCToCpp::Unwrap(arguments[i]); + } + } + } + // Translate param: retval; type: refptr_same_byref + cef_v8value_t* retvalStruct = NULL; + if(retval.get()) + retvalStruct = CefV8ValueCToCpp::Unwrap(retval); + cef_v8value_t* retvalOrig = retvalStruct; + // Translate param: exception; type: refptr_same_byref + cef_v8exception_t* exceptionStruct = NULL; + if(exception.get()) + exceptionStruct = CefV8ExceptionCToCpp::Unwrap(exception); + cef_v8exception_t* exceptionOrig = exceptionStruct; + + // Execute + int _retval = struct_->execute_function(struct_, + CefV8ValueCToCpp::Unwrap(object), + argumentsCount, + argumentsList, + &retvalStruct, + &exceptionStruct, + rethrow_exception); + + // Restore param:retval; type: refptr_same_byref + if (retvalStruct) { + if (retvalStruct != retvalOrig) { + retval = CefV8ValueCToCpp::Wrap(retvalStruct); + } + } else { + retval = NULL; + } + // Restore param:exception; type: refptr_same_byref + if (exceptionStruct) { + if (exceptionStruct != exceptionOrig) { + exception = CefV8ExceptionCToCpp::Wrap(exceptionStruct); + } + } else { + exception = NULL; + } + + // Return type: bool + return _retval?true:false; +} + + +bool CefV8ValueCToCpp::ExecuteFunctionWithContext( + CefRefPtr context, CefRefPtr object, + const CefV8ValueList& arguments, CefRefPtr& retval, + CefRefPtr& exception, bool rethrow_exception) +{ + if (CEF_MEMBER_MISSING(struct_, execute_function_with_context)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: context; type: refptr_same + DCHECK(context.get()); + if (!context.get()) + return false; + // Unverified params: object + + // Translate param: arguments; type: refptr_vec_same_byref_const + const size_t argumentsCount = arguments.size(); + cef_v8value_t** argumentsList = NULL; + if (argumentsCount > 0) { + argumentsList = new cef_v8value_t*[argumentsCount]; + DCHECK(argumentsList); + if (argumentsList) { + for (size_t i = 0; i < argumentsCount; ++i) { + argumentsList[i] = CefV8ValueCToCpp::Unwrap(arguments[i]); + } + } + } + // Translate param: retval; type: refptr_same_byref + cef_v8value_t* retvalStruct = NULL; + if(retval.get()) + retvalStruct = CefV8ValueCToCpp::Unwrap(retval); + cef_v8value_t* retvalOrig = retvalStruct; + // Translate param: exception; type: refptr_same_byref + cef_v8exception_t* exceptionStruct = NULL; + if(exception.get()) + exceptionStruct = CefV8ExceptionCToCpp::Unwrap(exception); + cef_v8exception_t* exceptionOrig = exceptionStruct; + + // Execute + int _retval = struct_->execute_function_with_context(struct_, + CefV8ContextCToCpp::Unwrap(context), + CefV8ValueCToCpp::Unwrap(object), + argumentsCount, + argumentsList, + &retvalStruct, + &exceptionStruct, + rethrow_exception); + + // Restore param:retval; type: refptr_same_byref + if (retvalStruct) { + if (retvalStruct != retvalOrig) { + retval = CefV8ValueCToCpp::Wrap(retvalStruct); + } + } else { + retval = NULL; + } + // Restore param:exception; type: refptr_same_byref + if (exceptionStruct) { + if (exceptionStruct != exceptionOrig) { + exception = CefV8ExceptionCToCpp::Wrap(exceptionStruct); + } + } else { + exception = NULL; + } + + // Return type: bool + return _retval?true:false; +} + + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef/libcef_dll/ctocpp/v8value_ctocpp.h b/cef/libcef_dll/ctocpp/v8value_ctocpp.h new file mode 100755 index 000000000..c824d03d5 --- /dev/null +++ b/cef/libcef_dll/ctocpp/v8value_ctocpp.h @@ -0,0 +1,78 @@ +// 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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef _V8VALUE_CTOCPP_H +#define _V8VALUE_CTOCPP_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/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed wrapper-side only. +class CefV8ValueCToCpp + : public CefCToCpp +{ +public: + CefV8ValueCToCpp(cef_v8value_t* str) + : CefCToCpp(str) {} + virtual ~CefV8ValueCToCpp() {} + + // CefV8Value methods + virtual bool IsUndefined() OVERRIDE; + virtual bool IsNull() OVERRIDE; + virtual bool IsBool() OVERRIDE; + virtual bool IsInt() OVERRIDE; + virtual bool IsDouble() OVERRIDE; + virtual bool IsDate() 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 CefTime GetDateValue() 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, + PropertyAttribute attribute) OVERRIDE; + virtual bool SetValue(int index, CefRefPtr value) OVERRIDE; + virtual bool SetValue(const CefString& key, AccessControl settings, + 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, + CefRefPtr& exception, bool rethrow_exception) OVERRIDE; + virtual bool ExecuteFunctionWithContext(CefRefPtr context, + CefRefPtr object, const CefV8ValueList& arguments, + CefRefPtr& retval, CefRefPtr& exception, + bool rethrow_exception) OVERRIDE; +}; + +#endif // USING_CEF_SHARED +#endif // _V8VALUE_CTOCPP_H + diff --git a/cef/libcef_dll/ctocpp/web_urlrequest_ctocpp.cc b/cef/libcef_dll/ctocpp/web_urlrequest_ctocpp.cc new file mode 100755 index 000000000..589fded3f --- /dev/null +++ b/cef/libcef_dll/ctocpp/web_urlrequest_ctocpp.cc @@ -0,0 +1,79 @@ +// 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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/web_urlrequest_client_cpptoc.h" +#include "libcef_dll/ctocpp/request_ctocpp.h" +#include "libcef_dll/ctocpp/web_urlrequest_ctocpp.h" + + +// STATIC METHODS - Body may be edited by hand. + +CefRefPtr CefWebURLRequest::CreateWebURLRequest( + CefRefPtr request, CefRefPtr client) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: request; type: refptr_same + DCHECK(request.get()); + if (!request.get()) + return NULL; + // Verify param: client; type: refptr_diff + DCHECK(client.get()); + if (!client.get()) + return NULL; + + // Execute + cef_web_urlrequest_t* _retval = cef_web_urlrequest_create( + CefRequestCToCpp::Unwrap(request), + CefWebURLRequestClientCppToC::Wrap(client)); + + // Return type: refptr_same + return CefWebURLRequestCToCpp::Wrap(_retval); +} + + + +// VIRTUAL METHODS - Body may be edited by hand. + +void CefWebURLRequestCToCpp::Cancel() +{ + if (CEF_MEMBER_MISSING(struct_, cancel)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->cancel(struct_); +} + + +CefWebURLRequest::RequestState CefWebURLRequestCToCpp::GetState() +{ + if (CEF_MEMBER_MISSING(struct_, get_state)) + return WUR_STATE_UNSENT; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_weburlrequest_state_t _retval = struct_->get_state(struct_); + + // Return type: simple + return _retval; +} + + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef/libcef_dll/ctocpp/web_urlrequest_ctocpp.h b/cef/libcef_dll/ctocpp/web_urlrequest_ctocpp.h new file mode 100755 index 000000000..4a7e01de4 --- /dev/null +++ b/cef/libcef_dll/ctocpp/web_urlrequest_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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef _WEBURLREQUEST_CTOCPP_H +#define _WEBURLREQUEST_CTOCPP_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/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed wrapper-side only. +class CefWebURLRequestCToCpp + : public CefCToCpp +{ +public: + CefWebURLRequestCToCpp(cef_web_urlrequest_t* str) + : CefCToCpp(str) {} + virtual ~CefWebURLRequestCToCpp() {} + + // CefWebURLRequest methods + virtual void Cancel() OVERRIDE; + virtual RequestState GetState() OVERRIDE; +}; + +#endif // USING_CEF_SHARED +#endif // _WEBURLREQUEST_CTOCPP_H + diff --git a/cef/libcef_dll/ctocpp/xml_reader_ctocpp.cc b/cef/libcef_dll/ctocpp/xml_reader_ctocpp.cc new file mode 100755 index 000000000..23f7351be --- /dev/null +++ b/cef/libcef_dll/ctocpp/xml_reader_ctocpp.cc @@ -0,0 +1,561 @@ +// 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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/ctocpp/stream_reader_ctocpp.h" +#include "libcef_dll/ctocpp/xml_reader_ctocpp.h" + + +// STATIC METHODS - Body may be edited by hand. + +CefRefPtr CefXmlReader::Create(CefRefPtr stream, + EncodingType encodingType, const CefString& URI) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: stream; type: refptr_same + DCHECK(stream.get()); + if (!stream.get()) + return NULL; + // Verify param: URI; type: string_byref_const + DCHECK(!URI.empty()); + if (URI.empty()) + return NULL; + + // Execute + cef_xml_reader_t* _retval = cef_xml_reader_create( + CefStreamReaderCToCpp::Unwrap(stream), + encodingType, + URI.GetStruct()); + + // Return type: refptr_same + return CefXmlReaderCToCpp::Wrap(_retval); +} + + + +// VIRTUAL METHODS - Body may be edited by hand. + +bool CefXmlReaderCToCpp::MoveToNextNode() +{ + if (CEF_MEMBER_MISSING(struct_, move_to_next_node)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->move_to_next_node(struct_); + + // Return type: bool + return _retval?true:false; +} + + +bool CefXmlReaderCToCpp::Close() +{ + if (CEF_MEMBER_MISSING(struct_, close)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->close(struct_); + + // Return type: bool + return _retval?true:false; +} + + +bool CefXmlReaderCToCpp::HasError() +{ + if (CEF_MEMBER_MISSING(struct_, has_error)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->has_error(struct_); + + // Return type: bool + return _retval?true:false; +} + + +CefString CefXmlReaderCToCpp::GetError() +{ + if (CEF_MEMBER_MISSING(struct_, get_error)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_error(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + + +CefXmlReader::NodeType CefXmlReaderCToCpp::GetType() +{ + if (CEF_MEMBER_MISSING(struct_, get_type)) + return XML_NODE_UNSUPPORTED; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_xml_node_type_t _retval = struct_->get_type(struct_); + + // Return type: simple + return _retval; +} + + +int CefXmlReaderCToCpp::GetDepth() +{ + if (CEF_MEMBER_MISSING(struct_, get_depth)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->get_depth(struct_); + + // Return type: simple + return _retval; +} + + +CefString CefXmlReaderCToCpp::GetLocalName() +{ + if (CEF_MEMBER_MISSING(struct_, get_local_name)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_local_name(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + + +CefString CefXmlReaderCToCpp::GetPrefix() +{ + if (CEF_MEMBER_MISSING(struct_, get_prefix)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_prefix(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + + +CefString CefXmlReaderCToCpp::GetQualifiedName() +{ + if (CEF_MEMBER_MISSING(struct_, get_qualified_name)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_qualified_name(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + + +CefString CefXmlReaderCToCpp::GetNamespaceURI() +{ + if (CEF_MEMBER_MISSING(struct_, get_namespace_uri)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_namespace_uri(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + + +CefString CefXmlReaderCToCpp::GetBaseURI() +{ + if (CEF_MEMBER_MISSING(struct_, get_base_uri)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_base_uri(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + + +CefString CefXmlReaderCToCpp::GetXmlLang() +{ + if (CEF_MEMBER_MISSING(struct_, get_xml_lang)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_xml_lang(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + + +bool CefXmlReaderCToCpp::IsEmptyElement() +{ + if (CEF_MEMBER_MISSING(struct_, is_empty_element)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_empty_element(struct_); + + // Return type: bool + return _retval?true:false; +} + + +bool CefXmlReaderCToCpp::HasValue() +{ + if (CEF_MEMBER_MISSING(struct_, has_value)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->has_value(struct_); + + // Return type: bool + return _retval?true:false; +} + + +CefString CefXmlReaderCToCpp::GetValue() +{ + if (CEF_MEMBER_MISSING(struct_, get_value)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_value(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + + +bool CefXmlReaderCToCpp::HasAttributes() +{ + if (CEF_MEMBER_MISSING(struct_, has_attributes)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->has_attributes(struct_); + + // Return type: bool + return _retval?true:false; +} + + +size_t CefXmlReaderCToCpp::GetAttributeCount() +{ + if (CEF_MEMBER_MISSING(struct_, get_attribute_count)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + size_t _retval = struct_->get_attribute_count(struct_); + + // Return type: simple + return _retval; +} + + +CefString CefXmlReaderCToCpp::GetAttribute(int index) +{ + if (CEF_MEMBER_MISSING(struct_, get_attribute_byindex)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: index; type: simple_byval + DCHECK(index >= 0); + if (index < 0) + return CefString(); + + // Execute + cef_string_userfree_t _retval = struct_->get_attribute_byindex(struct_, + index); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + + +CefString CefXmlReaderCToCpp::GetAttribute(const CefString& qualifiedName) +{ + if (CEF_MEMBER_MISSING(struct_, get_attribute_byqname)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: qualifiedName; type: string_byref_const + DCHECK(!qualifiedName.empty()); + if (qualifiedName.empty()) + return CefString(); + + // Execute + cef_string_userfree_t _retval = struct_->get_attribute_byqname(struct_, + qualifiedName.GetStruct()); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + + +CefString CefXmlReaderCToCpp::GetAttribute(const CefString& localName, + const CefString& namespaceURI) +{ + if (CEF_MEMBER_MISSING(struct_, get_attribute_bylname)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: localName; type: string_byref_const + DCHECK(!localName.empty()); + if (localName.empty()) + return CefString(); + // Verify param: namespaceURI; type: string_byref_const + DCHECK(!namespaceURI.empty()); + if (namespaceURI.empty()) + return CefString(); + + // Execute + cef_string_userfree_t _retval = struct_->get_attribute_bylname(struct_, + localName.GetStruct(), + namespaceURI.GetStruct()); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + + +CefString CefXmlReaderCToCpp::GetInnerXml() +{ + if (CEF_MEMBER_MISSING(struct_, get_inner_xml)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_inner_xml(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + + +CefString CefXmlReaderCToCpp::GetOuterXml() +{ + if (CEF_MEMBER_MISSING(struct_, get_outer_xml)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_outer_xml(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + + +int CefXmlReaderCToCpp::GetLineNumber() +{ + if (CEF_MEMBER_MISSING(struct_, get_line_number)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->get_line_number(struct_); + + // Return type: simple + return _retval; +} + + +bool CefXmlReaderCToCpp::MoveToAttribute(int index) +{ + if (CEF_MEMBER_MISSING(struct_, move_to_attribute_byindex)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: index; type: simple_byval + DCHECK(index >= 0); + if (index < 0) + return false; + + // Execute + int _retval = struct_->move_to_attribute_byindex(struct_, + index); + + // Return type: bool + return _retval?true:false; +} + + +bool CefXmlReaderCToCpp::MoveToAttribute(const CefString& qualifiedName) +{ + if (CEF_MEMBER_MISSING(struct_, move_to_attribute_byqname)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: qualifiedName; type: string_byref_const + DCHECK(!qualifiedName.empty()); + if (qualifiedName.empty()) + return false; + + // Execute + int _retval = struct_->move_to_attribute_byqname(struct_, + qualifiedName.GetStruct()); + + // Return type: bool + return _retval?true:false; +} + + +bool CefXmlReaderCToCpp::MoveToAttribute(const CefString& localName, + const CefString& namespaceURI) +{ + if (CEF_MEMBER_MISSING(struct_, move_to_attribute_bylname)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: localName; type: string_byref_const + DCHECK(!localName.empty()); + if (localName.empty()) + return false; + // Verify param: namespaceURI; type: string_byref_const + DCHECK(!namespaceURI.empty()); + if (namespaceURI.empty()) + return false; + + // Execute + int _retval = struct_->move_to_attribute_bylname(struct_, + localName.GetStruct(), + namespaceURI.GetStruct()); + + // Return type: bool + return _retval?true:false; +} + + +bool CefXmlReaderCToCpp::MoveToFirstAttribute() +{ + if (CEF_MEMBER_MISSING(struct_, move_to_first_attribute)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->move_to_first_attribute(struct_); + + // Return type: bool + return _retval?true:false; +} + + +bool CefXmlReaderCToCpp::MoveToNextAttribute() +{ + if (CEF_MEMBER_MISSING(struct_, move_to_next_attribute)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->move_to_next_attribute(struct_); + + // Return type: bool + return _retval?true:false; +} + + +bool CefXmlReaderCToCpp::MoveToCarryingElement() +{ + if (CEF_MEMBER_MISSING(struct_, move_to_carrying_element)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->move_to_carrying_element(struct_); + + // Return type: bool + return _retval?true:false; +} + + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef/libcef_dll/ctocpp/xml_reader_ctocpp.h b/cef/libcef_dll/ctocpp/xml_reader_ctocpp.h new file mode 100755 index 000000000..27bbdc708 --- /dev/null +++ b/cef/libcef_dll/ctocpp/xml_reader_ctocpp.h @@ -0,0 +1,70 @@ +// 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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef _XMLREADER_CTOCPP_H +#define _XMLREADER_CTOCPP_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/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed wrapper-side only. +class CefXmlReaderCToCpp + : public CefCToCpp +{ +public: + CefXmlReaderCToCpp(cef_xml_reader_t* str) + : CefCToCpp(str) {} + virtual ~CefXmlReaderCToCpp() {} + + // CefXmlReader methods + 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) 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) OVERRIDE; + virtual bool MoveToFirstAttribute() OVERRIDE; + virtual bool MoveToNextAttribute() OVERRIDE; + virtual bool MoveToCarryingElement() OVERRIDE; +}; + +#endif // USING_CEF_SHARED +#endif // _XMLREADER_CTOCPP_H + diff --git a/cef/libcef_dll/ctocpp/zip_reader_ctocpp.cc b/cef/libcef_dll/ctocpp/zip_reader_ctocpp.cc new file mode 100755 index 000000000..76d85f4b4 --- /dev/null +++ b/cef/libcef_dll/ctocpp/zip_reader_ctocpp.cc @@ -0,0 +1,245 @@ +// 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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/ctocpp/stream_reader_ctocpp.h" +#include "libcef_dll/ctocpp/zip_reader_ctocpp.h" + + +// STATIC METHODS - Body may be edited by hand. + +CefRefPtr CefZipReader::Create(CefRefPtr stream) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: stream; type: refptr_same + DCHECK(stream.get()); + if (!stream.get()) + return NULL; + + // Execute + cef_zip_reader_t* _retval = cef_zip_reader_create( + CefStreamReaderCToCpp::Unwrap(stream)); + + // Return type: refptr_same + return CefZipReaderCToCpp::Wrap(_retval); +} + + + +// VIRTUAL METHODS - Body may be edited by hand. + +bool CefZipReaderCToCpp::MoveToFirstFile() +{ + if (CEF_MEMBER_MISSING(struct_, move_to_first_file)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->move_to_first_file(struct_); + + // Return type: bool + return _retval?true:false; +} + + +bool CefZipReaderCToCpp::MoveToNextFile() +{ + if (CEF_MEMBER_MISSING(struct_, move_to_next_file)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->move_to_next_file(struct_); + + // Return type: bool + return _retval?true:false; +} + + +bool CefZipReaderCToCpp::MoveToFile(const CefString& fileName, + bool caseSensitive) +{ + if (CEF_MEMBER_MISSING(struct_, move_to_file)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: fileName; type: string_byref_const + DCHECK(!fileName.empty()); + if (fileName.empty()) + return false; + + // Execute + int _retval = struct_->move_to_file(struct_, + fileName.GetStruct(), + caseSensitive); + + // Return type: bool + return _retval?true:false; +} + + +bool CefZipReaderCToCpp::Close() +{ + if (CEF_MEMBER_MISSING(struct_, close)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->close(struct_); + + // Return type: bool + return _retval?true:false; +} + + +CefString CefZipReaderCToCpp::GetFileName() +{ + if (CEF_MEMBER_MISSING(struct_, get_file_name)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_file_name(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + + +long CefZipReaderCToCpp::GetFileSize() +{ + if (CEF_MEMBER_MISSING(struct_, get_file_size)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + long _retval = struct_->get_file_size(struct_); + + // Return type: simple + return _retval; +} + + +time_t CefZipReaderCToCpp::GetFileLastModified() +{ + if (CEF_MEMBER_MISSING(struct_, get_file_last_modified)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + time_t _retval = struct_->get_file_last_modified(struct_); + + // Return type: simple + return _retval; +} + + +bool CefZipReaderCToCpp::OpenFile(const CefString& password) +{ + if (CEF_MEMBER_MISSING(struct_, open_file)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Unverified params: password + + // Execute + int _retval = struct_->open_file(struct_, + password.GetStruct()); + + // Return type: bool + return _retval?true:false; +} + + +bool CefZipReaderCToCpp::CloseFile() +{ + if (CEF_MEMBER_MISSING(struct_, close_file)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->close_file(struct_); + + // Return type: bool + return _retval?true:false; +} + + +int CefZipReaderCToCpp::ReadFile(void* buffer, size_t bufferSize) +{ + if (CEF_MEMBER_MISSING(struct_, read_file)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: buffer; type: simple_byaddr + DCHECK(buffer); + if (!buffer) + return 0; + + // Execute + int _retval = struct_->read_file(struct_, + buffer, + bufferSize); + + // Return type: simple + return _retval; +} + + +long CefZipReaderCToCpp::Tell() +{ + if (CEF_MEMBER_MISSING(struct_, tell)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + long _retval = struct_->tell(struct_); + + // Return type: simple + return _retval; +} + + +bool CefZipReaderCToCpp::Eof() +{ + if (CEF_MEMBER_MISSING(struct_, eof)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->eof(struct_); + + // Return type: bool + return _retval?true:false; +} + + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/cef/libcef_dll/ctocpp/zip_reader_ctocpp.h b/cef/libcef_dll/ctocpp/zip_reader_ctocpp.h new file mode 100755 index 000000000..c293ece3f --- /dev/null +++ b/cef/libcef_dll/ctocpp/zip_reader_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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef _ZIPREADER_CTOCPP_H +#define _ZIPREADER_CTOCPP_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/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed wrapper-side only. +class CefZipReaderCToCpp + : public CefCToCpp +{ +public: + CefZipReaderCToCpp(cef_zip_reader_t* str) + : CefCToCpp(str) {} + virtual ~CefZipReaderCToCpp() {} + + // CefZipReader methods + 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 +#endif // _ZIPREADER_CTOCPP_H + diff --git a/cef/libcef_dll/transfer_util.cpp b/cef/libcef_dll/transfer_util.cpp new file mode 100755 index 000000000..e9d8d4e22 --- /dev/null +++ b/cef/libcef_dll/transfer_util.cpp @@ -0,0 +1,72 @@ +// Copyright (c) 2009 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 "transfer_util.h" + +void transfer_string_list_contents(cef_string_list_t fromList, + StringList& toList) +{ + int size = cef_string_list_size(fromList); + CefString value; + + for(int i = 0; i < size; i++) { + cef_string_list_value(fromList, i, value.GetWritableStruct()); + toList.push_back(value); + } +} + +void transfer_string_list_contents(const StringList& fromList, + cef_string_list_t toList) +{ + size_t size = fromList.size(); + for(size_t i = 0; i < size; ++i) + cef_string_list_append(toList, fromList[i].GetStruct()); +} + +void transfer_string_map_contents(cef_string_map_t fromMap, + StringMap& toMap) +{ + int size = cef_string_map_size(fromMap); + CefString key, value; + + for(int i = 0; i < size; ++i) { + cef_string_map_key(fromMap, i, key.GetWritableStruct()); + cef_string_map_value(fromMap, i, value.GetWritableStruct()); + + toMap.insert(std::make_pair(key, value)); + } +} + +void transfer_string_map_contents(const StringMap& fromMap, + cef_string_map_t toMap) +{ + StringMap::const_iterator it = fromMap.begin(); + for(; it != fromMap.end(); ++it) + cef_string_map_append(toMap, it->first.GetStruct(), it->second.GetStruct()); +} + +void transfer_string_multimap_contents(cef_string_multimap_t fromMap, + StringMultimap& toMap) +{ + int size = cef_string_multimap_size(fromMap); + CefString key, value; + + for(int i = 0; i < size; ++i) { + cef_string_multimap_key(fromMap, i, key.GetWritableStruct()); + cef_string_multimap_value(fromMap, i, value.GetWritableStruct()); + + toMap.insert(std::make_pair(key, value)); + } +} + +void transfer_string_multimap_contents(const StringMultimap& fromMap, + cef_string_multimap_t toMap) +{ + StringMultimap::const_iterator it = fromMap.begin(); + for(; it != fromMap.end(); ++it) { + cef_string_multimap_append(toMap, + it->first.GetStruct(), + it->second.GetStruct()); + } +} diff --git a/cef/libcef_dll/transfer_util.h b/cef/libcef_dll/transfer_util.h new file mode 100755 index 000000000..7992dd392 --- /dev/null +++ b/cef/libcef_dll/transfer_util.h @@ -0,0 +1,35 @@ +// Copyright (c) 2009 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 _TRANSFER_UTIL_H +#define _TRANSFER_UTIL_H + +#include "include/internal/cef_string_list.h" +#include "include/internal/cef_string_map.h" +#include "include/internal/cef_string_multimap.h" +#include +#include + +// Copy contents from one list type to another. +typedef std::vector StringList; +void transfer_string_list_contents(cef_string_list_t fromList, + StringList& toList); +void transfer_string_list_contents(const StringList& fromList, + cef_string_list_t toList); + +// Copy contents from one map type to another. +typedef std::map StringMap; +void transfer_string_map_contents(cef_string_map_t fromMap, + StringMap& toMap); +void transfer_string_map_contents(const StringMap& fromMap, + cef_string_map_t toMap); + +// Copy contents from one map type to another. +typedef std::multimap StringMultimap; +void transfer_string_multimap_contents(cef_string_multimap_t fromMap, + StringMultimap& toMap); +void transfer_string_multimap_contents(const StringMultimap& fromMap, + cef_string_multimap_t toMap); + +#endif // _TRANSFER_UTIL_H diff --git a/cef/libcef_dll/wrapper/cef_byte_read_handler.cc b/cef/libcef_dll/wrapper/cef_byte_read_handler.cc new file mode 100755 index 000000000..1620f9b04 --- /dev/null +++ b/cef/libcef_dll/wrapper/cef_byte_read_handler.cc @@ -0,0 +1,62 @@ +// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// reserved. Use of this source code is governed by a BSD-style license that +// can be found in the LICENSE file. + +#include "include/cef_wrapper.h" +#include "libcef_dll/cef_logging.h" + +CefByteReadHandler::CefByteReadHandler(const unsigned char* bytes, size_t size, + CefRefPtr source) + : bytes_(bytes), size_(size), offset_(0), source_(source) +{ +} + +size_t CefByteReadHandler::Read(void* ptr, size_t size, size_t n) +{ + 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; + return ret; +} + +int CefByteReadHandler::Seek(long offset, int whence) +{ + int rv = -1L; + AutoLock lock_scope(this); + switch(whence) { + case SEEK_CUR: + if(offset_ + offset > size_) + break; + offset_ += offset; + rv = 0; + break; + case SEEK_END: + if(offset > static_cast(size_)) + break; + offset_ = size_ - offset; + rv = 0; + break; + case SEEK_SET: + if(offset > static_cast(size_)) + break; + offset_ = offset; + rv = 0; + break; + } + + return rv; +} + +long CefByteReadHandler::Tell() +{ + AutoLock lock_scope(this); + return offset_; +} + +int CefByteReadHandler::Eof() +{ + AutoLock lock_scope(this); + return (offset_ >= size_); +} diff --git a/cef/libcef_dll/wrapper/cef_xml_object.cc b/cef/libcef_dll/wrapper/cef_xml_object.cc new file mode 100755 index 000000000..db6b896fa --- /dev/null +++ b/cef/libcef_dll/wrapper/cef_xml_object.cc @@ -0,0 +1,489 @@ +// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// reserved. Use of this source code is governed by a BSD-style license that +// can be found in the LICENSE file. + +#include "include/cef_wrapper.h" +#include "libcef_dll/cef_logging.h" +#include + +namespace { + +class CefXmlObjectLoader +{ +public: + CefXmlObjectLoader(CefRefPtr root_object) + : root_object_(root_object) + { + } + + bool Load(CefRefPtr stream, + CefXmlReader::EncodingType encodingType, + const CefString& URI) + { + CefRefPtr reader( + CefXmlReader::Create(stream, encodingType, URI)); + if (!reader.get()) + return false; + + bool ret = reader->MoveToNextNode(); + if (ret) { + CefRefPtr cur_object(root_object_), new_object; + CefXmlObject::ObjectVector queue; + int cur_depth, value_depth = -1; + CefXmlReader::NodeType cur_type; + std::stringstream cur_value; + bool last_has_ns = false; + + queue.push_back(root_object_); + + do { + cur_depth = reader->GetDepth(); + if (value_depth >= 0 && cur_depth > value_depth) { + // The current node has already been parsed as part of a value. + continue; + } + + cur_type = reader->GetType(); + if (cur_type == XML_NODE_ELEMENT_START) { + if (cur_depth == value_depth) { + // Add to the current value. + cur_value << std::string(reader->GetOuterXml()); + continue; + } else if(last_has_ns && reader->GetPrefix().empty()) { + if (!cur_object->HasChildren()) { + // Start a new value because the last element has a namespace and + // this element does not. + value_depth = cur_depth; + cur_value << std::string(reader->GetOuterXml()); + } else { + // Value following a child element is not allowed. + std::stringstream ss; + ss << L"Value following child element, line " << + reader->GetLineNumber(); + load_error_ = ss.str(); + ret = false; + break; + } + } else { + // Start a new element. + new_object = new CefXmlObject(reader->GetQualifiedName()); + cur_object->AddChild(new_object); + last_has_ns = !reader->GetPrefix().empty(); + + if (!reader->IsEmptyElement()) { + // The new element potentially has a value and/or children, so + // set the current object and add the object to the queue. + cur_object = new_object; + queue.push_back(cur_object); + } + + if (reader->HasAttributes() && reader->MoveToFirstAttribute()) { + // Read all object attributes. + do { + new_object->SetAttributeValue(reader->GetQualifiedName(), + reader->GetValue()); + } while(reader->MoveToNextAttribute()); + reader->MoveToCarryingElement(); + } + } + } else if(cur_type == XML_NODE_ELEMENT_END) { + if (cur_depth == value_depth) { + // Ending an element that is already in the value. + continue; + } else if (cur_depth < value_depth) { + // Done with parsing the value portion of the current element. + cur_object->SetValue(cur_value.str()); + cur_value.str(""); + value_depth = -1; + } + + // Pop the current element from the queue. + queue.pop_back(); + + if (queue.empty() || + cur_object->GetName() != reader->GetQualifiedName()) { + // Open tag without close tag or close tag without open tag should + // never occur (the parser catches this error). + DCHECK(false); + std::stringstream ss; + ss << "Mismatched end tag for " << + std::string(cur_object->GetName()) << + ", line " << reader->GetLineNumber(); + load_error_ = ss.str(); + ret = false; + break; + } + + // Set the current object to the previous object in the queue. + cur_object = queue.back().get(); + } else if(cur_type == XML_NODE_TEXT || cur_type == XML_NODE_CDATA || + cur_type == XML_NODE_ENTITY_REFERENCE) { + if (cur_depth == value_depth) { + // Add to the current value. + cur_value << std::string(reader->GetValue()); + } else if (!cur_object->HasChildren()) { + // Start a new value. + value_depth = cur_depth; + cur_value << std::string(reader->GetValue()); + } else { + // Value following a child element is not allowed. + std::stringstream ss; + ss << "Value following child element, line " << + reader->GetLineNumber(); + load_error_ = ss.str(); + ret = false; + break; + } + } + } while(reader->MoveToNextNode()); + } + + if (reader->HasError()) { + load_error_ = reader->GetError(); + return false; + } + + return ret; + } + + CefString GetLoadError() { return load_error_; } + +private: + CefString load_error_; + CefRefPtr root_object_; +}; + +} // namespace + +CefXmlObject::CefXmlObject(const CefString& name) + : name_(name), parent_(NULL) +{ +} + +CefXmlObject::~CefXmlObject() +{ +} + +bool CefXmlObject::Load(CefRefPtr stream, + CefXmlReader::EncodingType encodingType, + const CefString& URI, CefString* loadError) +{ + AutoLock lock_scope(this); + Clear(); + + CefXmlObjectLoader loader(this); + if (!loader.Load(stream, encodingType, URI)) { + if (loadError) + *loadError = loader.GetLoadError(); + return false; + } + return true; +} + +void CefXmlObject::Set(CefRefPtr object) +{ + DCHECK(object.get()); + + AutoLock lock_scope1(this); + AutoLock lock_scope2(object); + + Clear(); + name_ = object->GetName(); + Append(object, true); +} + +void CefXmlObject::Append(CefRefPtr object, + bool overwriteAttributes) +{ + DCHECK(object.get()); + + AutoLock lock_scope1(this); + AutoLock lock_scope2(object); + + if (object->HasChildren()) { + ObjectVector children; + object->GetChildren(children); + ObjectVector::const_iterator it = children.begin(); + for (; it != children.end(); ++it) + AddChild((*it)->Duplicate()); + } + + if (object->HasAttributes()) { + AttributeMap attributes; + object->GetAttributes(attributes); + AttributeMap::const_iterator it = attributes.begin(); + for (; it != attributes.end(); ++it) { + if (overwriteAttributes || !HasAttribute(it->first)) + SetAttributeValue(it->first, it->second); + } + } +} + +CefRefPtr CefXmlObject::Duplicate() +{ + CefRefPtr new_obj; + { + AutoLock lock_scope(this); + new_obj = new CefXmlObject(name_); + new_obj->Append(this, true); + } + return new_obj; +} + +void CefXmlObject::Clear() +{ + AutoLock lock_scope(this); + ClearChildren(); + ClearAttributes(); +} + +CefString CefXmlObject::GetName() +{ + CefString name; + { + AutoLock lock_scope(this); + name = name_; + } + return name; +} + +bool CefXmlObject::SetName(const CefString& name) +{ + DCHECK(!name.empty()); + if (name.empty()) + return false; + + AutoLock lock_scope(this); + name_ = name; + return true; +} + +bool CefXmlObject::HasParent() +{ + AutoLock lock_scope(this); + return (parent_ != NULL); +} + +CefRefPtr CefXmlObject::GetParent() +{ + CefRefPtr parent; + { + AutoLock lock_scope(this); + parent = parent_; + } + return parent; +} + +bool CefXmlObject::HasValue() +{ + AutoLock lock_scope(this); + return !value_.empty(); +} + +CefString CefXmlObject::GetValue() +{ + CefString value; + { + AutoLock lock_scope(this); + value = value_; + } + return value; +} + +bool CefXmlObject::SetValue(const CefString& value) +{ + AutoLock lock_scope(this); + DCHECK(children_.empty()); + if (!children_.empty()) + return false; + value_ = value; + return true; +} + +bool CefXmlObject::HasAttributes() +{ + AutoLock lock_scope(this); + return !attributes_.empty(); +} + +size_t CefXmlObject::GetAttributeCount() +{ + AutoLock lock_scope(this); + return attributes_.size(); +} + +bool CefXmlObject::HasAttribute(const CefString& name) +{ + if (name.empty()) + return false; + + AutoLock lock_scope(this); + AttributeMap::const_iterator it = attributes_.find(name); + return (it != attributes_.end()); +} + +CefString CefXmlObject::GetAttributeValue(const CefString& name) +{ + DCHECK(!name.empty()); + CefString value; + if (!name.empty()) { + AutoLock lock_scope(this); + AttributeMap::const_iterator it = attributes_.find(name); + if (it != attributes_.end()) + value = it->second; + } + return value; +} + +bool CefXmlObject::SetAttributeValue(const CefString& name, + const CefString& value) +{ + DCHECK(!name.empty()); + if (name.empty()) + return false; + + AutoLock lock_scope(this); + AttributeMap::iterator it = attributes_.find(name); + if (it != attributes_.end()) { + it->second = value; + } else { + attributes_.insert(std::make_pair(name, value)); + } + return true; +} + +size_t CefXmlObject::GetAttributes(AttributeMap& attributes) +{ + AutoLock lock_scope(this); + attributes = attributes_; + return attributes_.size(); +} + +void CefXmlObject::ClearAttributes() +{ + AutoLock lock_scope(this); + attributes_.clear(); +} + +bool CefXmlObject::HasChildren() +{ + AutoLock lock_scope(this); + return !children_.empty(); +} + +size_t CefXmlObject::GetChildCount() +{ + AutoLock lock_scope(this); + return children_.size(); +} + +bool CefXmlObject::HasChild(CefRefPtr child) +{ + DCHECK(child.get()); + + AutoLock lock_scope(this); + ObjectVector::const_iterator it = children_.begin(); + for (; it != children_.end(); ++it) { + if ((*it).get() == child.get()) + return true; + } + return false; +} + +bool CefXmlObject::AddChild(CefRefPtr child) +{ + DCHECK(child.get()); + if (!child.get()) + return false; + + AutoLock lock_scope1(child); + + DCHECK(child->GetParent() == NULL); + if (child->GetParent() != NULL) + return false; + + AutoLock lock_scope2(this); + + children_.push_back(child); + child->SetParent(this); + return true; +} + +bool CefXmlObject::RemoveChild(CefRefPtr child) +{ + DCHECK(child.get()); + + AutoLock lock_scope(this); + ObjectVector::iterator it = children_.begin(); + for (; it != children_.end(); ++it) { + if ((*it).get() == child.get()) { + children_.erase(it); + child->SetParent(NULL); + return true; + } + } + return false; +} + +size_t CefXmlObject::GetChildren(ObjectVector& children) +{ + AutoLock lock_scope(this); + children = children_; + return children_.size(); +} + +void CefXmlObject::ClearChildren() +{ + AutoLock lock_scope(this); + ObjectVector::iterator it = children_.begin(); + for (; it != children_.end(); ++it) + (*it)->SetParent(NULL); + children_.clear(); +} + +CefRefPtr CefXmlObject::FindChild(const CefString& name) +{ + DCHECK(!name.empty()); + if (name.empty()) + return NULL; + + AutoLock lock_scope(this); + ObjectVector::const_iterator it = children_.begin(); + for (; it != children_.end(); ++it) { + if((*it)->GetName() == name) + return (*it); + } + return NULL; +} + +size_t CefXmlObject::FindChildren(const CefString& name, + ObjectVector& children) +{ + DCHECK(!name.empty()); + if (name.empty()) + return 0; + + size_t ct = 0; + + AutoLock lock_scope(this); + ObjectVector::const_iterator it = children_.begin(); + for (; it != children_.end(); ++it) { + if((*it)->GetName() == name) { + children.push_back(*it); + ct++; + } + } + return ct; +} + +void CefXmlObject::SetParent(CefXmlObject* parent) +{ + AutoLock lock_scope(this); + if (parent) { + DCHECK(parent_ == NULL); + parent_ = parent; + } else { + DCHECK(parent_ != NULL); + parent_ = NULL; + } +} diff --git a/cef/libcef_dll/wrapper/cef_zip_archive.cc b/cef/libcef_dll/wrapper/cef_zip_archive.cc new file mode 100755 index 000000000..508750798 --- /dev/null +++ b/cef/libcef_dll/wrapper/cef_zip_archive.cc @@ -0,0 +1,168 @@ +// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// reserved. Use of this source code is governed by a BSD-style license that +// can be found in the LICENSE file. + +#include "include/cef_wrapper.h" +#include "libcef_dll/cef_logging.h" +#include + +#if defined(__linux__) +#include +#endif + +namespace { + +class CefZipFile : public CefZipArchive::File +{ +public: + CefZipFile(size_t size) : data_(size) {} + ~CefZipFile() {} + + // Returns the read-only data contained in the file. + virtual const unsigned char* GetData() { return &data_[0]; } + + // Returns the size of the data in the file. + virtual size_t GetDataSize() { return data_.size(); } + + // Returns a CefStreamReader object for streaming the contents of the file. + virtual CefRefPtr GetStreamReader() { + CefRefPtr handler( + new CefByteReadHandler(GetData(), GetDataSize(), this)); + return CefStreamReader::CreateForHandler(handler); + } + + std::vector* GetDataVector() { return &data_; } + +private: + std::vector data_; + + IMPLEMENT_REFCOUNTING(CefZipFile); +}; + +} // namespace + +// CefZipArchive implementation + +CefZipArchive::CefZipArchive() +{ +} + +CefZipArchive::~CefZipArchive() +{ +} + +size_t CefZipArchive::Load(CefRefPtr stream, + bool overwriteExisting) +{ + AutoLock lock_scope(this); + + CefRefPtr reader(CefZipReader::Create(stream)); + if (!reader.get()) + return 0; + + if (!reader->MoveToFirstFile()) + return 0; + + std::wstring name; + CefRefPtr contents; + FileMap::iterator it; + std::vector* data; + size_t count = 0, size, offset; + + do { + size = static_cast(reader->GetFileSize()); + if (size == 0) { + // Skip directories and empty files. + continue; + } + + if (!reader->OpenFile(CefString())) + break; + + name = reader->GetFileName(); + std::transform(name.begin(), name.end(), name.begin(), towlower); + + it = contents_.find(name); + if (it != contents_.end()) { + if (overwriteExisting) + contents_.erase(it); + else // Skip files that already exist. + continue; + } + + contents = new CefZipFile(size); + data = contents->GetDataVector(); + offset = 0; + + // Read the file contents. + do { + offset += reader->ReadFile(&(*data)[offset], size - offset); + } while (offset < size && !reader->Eof()); + + DCHECK(offset == size); + + reader->CloseFile(); + count++; + + // Add the file to the map. + contents_.insert(std::make_pair(name, contents.get())); + } while (reader->MoveToNextFile()); + + return count; +} + +void CefZipArchive::Clear() +{ + AutoLock lock_scope(this); + contents_.empty(); +} + +size_t CefZipArchive::GetFileCount() +{ + AutoLock lock_scope(this); + return contents_.size(); +} + +bool CefZipArchive::HasFile(const CefString& fileName) +{ + std::wstring str = fileName; + std::transform(str.begin(), str.end(), str.begin(), towlower); + + AutoLock lock_scope(this); + FileMap::const_iterator it = contents_.find(CefString(str)); + return (it != contents_.end()); +} + +CefRefPtr CefZipArchive::GetFile( + const CefString& fileName) +{ + std::wstring str = fileName; + std::transform(str.begin(), str.end(), str.begin(), towlower); + + AutoLock lock_scope(this); + FileMap::const_iterator it = contents_.find(CefString(str)); + if (it != contents_.end()) + return it->second; + return NULL; +} + +bool CefZipArchive::RemoveFile(const CefString& fileName) +{ + std::wstring str = fileName; + std::transform(str.begin(), str.end(), str.begin(), towlower); + + AutoLock lock_scope(this); + FileMap::iterator it = contents_.find(CefString(str)); + if (it != contents_.end()) { + contents_.erase(it); + return true; + } + return false; +} + +size_t CefZipArchive::GetFiles(FileMap& map) +{ + AutoLock lock_scope(this); + map = contents_; + return contents_.size(); +} diff --git a/cef/libcef_dll/wrapper/libcef_dll_wrapper.cc b/cef/libcef_dll/wrapper/libcef_dll_wrapper.cc new file mode 100755 index 000000000..6f2e49c22 --- /dev/null +++ b/cef/libcef_dll/wrapper/libcef_dll_wrapper.cc @@ -0,0 +1,602 @@ +// 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. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "include/cef_version.h" +#include "libcef_dll/cpptoc/app_cpptoc.h" +#include "libcef_dll/cpptoc/content_filter_cpptoc.h" +#include "libcef_dll/cpptoc/cookie_visitor_cpptoc.h" +#include "libcef_dll/cpptoc/domevent_listener_cpptoc.h" +#include "libcef_dll/cpptoc/domvisitor_cpptoc.h" +#include "libcef_dll/cpptoc/display_handler_cpptoc.h" +#include "libcef_dll/cpptoc/download_handler_cpptoc.h" +#include "libcef_dll/cpptoc/drag_handler_cpptoc.h" +#include "libcef_dll/cpptoc/find_handler_cpptoc.h" +#include "libcef_dll/cpptoc/focus_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/proxy_handler_cpptoc.h" +#include "libcef_dll/cpptoc/read_handler_cpptoc.h" +#include "libcef_dll/cpptoc/render_handler_cpptoc.h" +#include "libcef_dll/cpptoc/request_handler_cpptoc.h" +#include "libcef_dll/cpptoc/scheme_handler_cpptoc.h" +#include "libcef_dll/cpptoc/scheme_handler_factory_cpptoc.h" +#include "libcef_dll/cpptoc/storage_visitor_cpptoc.h" +#include "libcef_dll/cpptoc/task_cpptoc.h" +#include "libcef_dll/cpptoc/v8accessor_cpptoc.h" +#include "libcef_dll/cpptoc/v8context_handler_cpptoc.h" +#include "libcef_dll/cpptoc/v8handler_cpptoc.h" +#include "libcef_dll/cpptoc/web_urlrequest_client_cpptoc.h" +#include "libcef_dll/cpptoc/write_handler_cpptoc.h" +#include "libcef_dll/ctocpp/browser_ctocpp.h" +#include "libcef_dll/ctocpp/domdocument_ctocpp.h" +#include "libcef_dll/ctocpp/domevent_ctocpp.h" +#include "libcef_dll/ctocpp/domnode_ctocpp.h" +#include "libcef_dll/ctocpp/drag_data_ctocpp.h" +#include "libcef_dll/ctocpp/frame_ctocpp.h" +#include "libcef_dll/ctocpp/post_data_ctocpp.h" +#include "libcef_dll/ctocpp/post_data_element_ctocpp.h" +#include "libcef_dll/ctocpp/request_ctocpp.h" +#include "libcef_dll/ctocpp/response_ctocpp.h" +#include "libcef_dll/ctocpp/scheme_handler_callback_ctocpp.h" +#include "libcef_dll/ctocpp/stream_reader_ctocpp.h" +#include "libcef_dll/ctocpp/stream_writer_ctocpp.h" +#include "libcef_dll/ctocpp/v8context_ctocpp.h" +#include "libcef_dll/ctocpp/v8exception_ctocpp.h" +#include "libcef_dll/ctocpp/v8value_ctocpp.h" +#include "libcef_dll/ctocpp/web_urlrequest_ctocpp.h" +#include "libcef_dll/ctocpp/xml_reader_ctocpp.h" +#include "libcef_dll/ctocpp/zip_reader_ctocpp.h" + +// Define used to facilitate parsing. +#define CEF_GLOBAL + + +// GLOBAL METHODS - Body may be edited by hand. + +CEF_GLOBAL bool CefInitialize(const CefSettings& settings, + CefRefPtr application) +{ + int build_revision = cef_build_revision(); + if (build_revision != CEF_REVISION) { + // The libcef build revision does not match the CEF API revision. + DCHECK(false); + return false; + } + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Unverified params: application + + // Execute + int _retval = cef_initialize( + &settings, + CefAppCppToC::Wrap(application)); + + // Return type: bool + return _retval?true:false; +} + + +CEF_GLOBAL void CefShutdown() +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_shutdown(); + +#ifndef NDEBUG + // Check that all wrapper objects have been destroyed + DCHECK(CefBrowserCToCpp::DebugObjCt == 0); + DCHECK(CefContentFilterCppToC::DebugObjCt == 0); + DCHECK(CefCookieVisitorCppToC::DebugObjCt == 0); + DCHECK(CefDOMDocumentCToCpp::DebugObjCt == 0); + DCHECK(CefDOMEventCToCpp::DebugObjCt == 0); + DCHECK(CefDOMEventListenerCppToC::DebugObjCt == 0); + DCHECK(CefDOMNodeCToCpp::DebugObjCt == 0); + DCHECK(CefDOMVisitorCppToC::DebugObjCt == 0); + DCHECK(CefDisplayHandlerCppToC::DebugObjCt == 0); + DCHECK(CefDownloadHandlerCppToC::DebugObjCt == 0); + DCHECK(CefDragDataCToCpp::DebugObjCt == 0); + DCHECK(CefDragHandlerCppToC::DebugObjCt == 0); + DCHECK(CefFindHandlerCppToC::DebugObjCt == 0); + DCHECK(CefFocusHandlerCppToC::DebugObjCt == 0); + DCHECK(CefFrameCToCpp::DebugObjCt == 0); + DCHECK(CefJSDialogHandlerCppToC::DebugObjCt == 0); + DCHECK(CefKeyboardHandlerCppToC::DebugObjCt == 0); + DCHECK(CefLifeSpanHandlerCppToC::DebugObjCt == 0); + DCHECK(CefLoadHandlerCppToC::DebugObjCt == 0); + DCHECK(CefMenuHandlerCppToC::DebugObjCt == 0); + DCHECK(CefPostDataCToCpp::DebugObjCt == 0); + DCHECK(CefPostDataElementCToCpp::DebugObjCt == 0); + DCHECK(CefPrintHandlerCppToC::DebugObjCt == 0); + DCHECK(CefProxyHandlerCppToC::DebugObjCt == 0); + DCHECK(CefReadHandlerCppToC::DebugObjCt == 0); + DCHECK(CefRenderHandlerCppToC::DebugObjCt == 0); + DCHECK(CefRequestCToCpp::DebugObjCt == 0); + DCHECK(CefRequestHandlerCppToC::DebugObjCt == 0); + DCHECK(CefResponseCToCpp::DebugObjCt == 0); + DCHECK(CefSchemeHandlerCallbackCToCpp::DebugObjCt == 0); + DCHECK(CefSchemeHandlerCppToC::DebugObjCt == 0); + DCHECK(CefSchemeHandlerFactoryCppToC::DebugObjCt == 0); + DCHECK(CefStorageVisitorCppToC::DebugObjCt == 0); + DCHECK(CefStreamReaderCToCpp::DebugObjCt == 0); + DCHECK(CefStreamWriterCToCpp::DebugObjCt == 0); + DCHECK(CefTaskCppToC::DebugObjCt == 0); + DCHECK(CefV8AccessorCppToC::DebugObjCt == 0); + DCHECK(CefV8ContextCToCpp::DebugObjCt == 0); + DCHECK(CefV8ContextHandlerCppToC::DebugObjCt == 0); + DCHECK(CefV8ExceptionCToCpp::DebugObjCt == 0); + DCHECK(CefV8HandlerCppToC::DebugObjCt == 0); + DCHECK(CefV8ValueCToCpp::DebugObjCt == 0); + DCHECK(CefWebURLRequestCToCpp::DebugObjCt == 0); + DCHECK(CefWebURLRequestClientCppToC::DebugObjCt == 0); + DCHECK(CefWriteHandlerCppToC::DebugObjCt == 0); + DCHECK(CefXmlReaderCToCpp::DebugObjCt == 0); + DCHECK(CefZipReaderCToCpp::DebugObjCt == 0); +#endif // !NDEBUG +} + + +CEF_GLOBAL void CefDoMessageLoopWork() +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_do_message_loop_work(); +} + + +CEF_GLOBAL void CefRunMessageLoop() +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_run_message_loop(); +} + + +CEF_GLOBAL void CefQuitMessageLoop() +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_quit_message_loop(); +} + + +CEF_GLOBAL bool CefRegisterExtension(const CefString& extension_name, + const CefString& javascript_code, CefRefPtr handler) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: extension_name; type: string_byref_const + DCHECK(!extension_name.empty()); + if (extension_name.empty()) + return false; + // Verify param: javascript_code; type: string_byref_const + DCHECK(!javascript_code.empty()); + if (javascript_code.empty()) + return false; + // Unverified params: handler + + // Execute + int _retval = cef_register_extension( + extension_name.GetStruct(), + javascript_code.GetStruct(), + CefV8HandlerCppToC::Wrap(handler)); + + // Return type: bool + return _retval?true:false; +} + + +CEF_GLOBAL bool CefRegisterCustomScheme(const CefString& scheme_name, + bool is_standard, bool is_local, bool is_display_isolated) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: scheme_name; type: string_byref_const + DCHECK(!scheme_name.empty()); + if (scheme_name.empty()) + return false; + + // Execute + int _retval = cef_register_custom_scheme( + scheme_name.GetStruct(), + is_standard, + is_local, + is_display_isolated); + + // Return type: bool + return _retval?true:false; +} + + +CEF_GLOBAL bool CefRegisterSchemeHandlerFactory(const CefString& scheme_name, + const CefString& domain_name, CefRefPtr factory) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: scheme_name; type: string_byref_const + DCHECK(!scheme_name.empty()); + if (scheme_name.empty()) + return false; + // Unverified params: domain_name, factory + + // Execute + int _retval = cef_register_scheme_handler_factory( + scheme_name.GetStruct(), + domain_name.GetStruct(), + CefSchemeHandlerFactoryCppToC::Wrap(factory)); + + // Return type: bool + return _retval?true:false; +} + + +CEF_GLOBAL bool CefClearSchemeHandlerFactories() +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = cef_clear_scheme_handler_factories(); + + // Return type: bool + return _retval?true:false; +} + + +CEF_GLOBAL bool CefAddCrossOriginWhitelistEntry(const CefString& source_origin, + const CefString& target_protocol, const CefString& target_domain, + bool allow_target_subdomains) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: source_origin; type: string_byref_const + DCHECK(!source_origin.empty()); + if (source_origin.empty()) + return false; + // Verify param: target_protocol; type: string_byref_const + DCHECK(!target_protocol.empty()); + if (target_protocol.empty()) + return false; + // Verify param: target_domain; type: string_byref_const + DCHECK(!target_domain.empty()); + if (target_domain.empty()) + return false; + + // Execute + int _retval = cef_add_cross_origin_whitelist_entry( + source_origin.GetStruct(), + target_protocol.GetStruct(), + target_domain.GetStruct(), + allow_target_subdomains); + + // Return type: bool + return _retval?true:false; +} + + +CEF_GLOBAL bool CefRemoveCrossOriginWhitelistEntry( + const CefString& source_origin, const CefString& target_protocol, + const CefString& target_domain, bool allow_target_subdomains) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: source_origin; type: string_byref_const + DCHECK(!source_origin.empty()); + if (source_origin.empty()) + return false; + // Verify param: target_protocol; type: string_byref_const + DCHECK(!target_protocol.empty()); + if (target_protocol.empty()) + return false; + // Verify param: target_domain; type: string_byref_const + DCHECK(!target_domain.empty()); + if (target_domain.empty()) + return false; + + // Execute + int _retval = cef_remove_cross_origin_whitelist_entry( + source_origin.GetStruct(), + target_protocol.GetStruct(), + target_domain.GetStruct(), + allow_target_subdomains); + + // Return type: bool + return _retval?true:false; +} + + +CEF_GLOBAL bool CefClearCrossOriginWhitelist() +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = cef_clear_cross_origin_whitelist(); + + // Return type: bool + return _retval?true:false; +} + + +CEF_GLOBAL bool CefCurrentlyOn(CefThreadId threadId) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = cef_currently_on( + threadId); + + // Return type: bool + return _retval?true:false; +} + + +CEF_GLOBAL bool CefPostTask(CefThreadId threadId, CefRefPtr task) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: task; type: refptr_diff + DCHECK(task.get()); + if (!task.get()) + return false; + + // Execute + int _retval = cef_post_task( + threadId, + CefTaskCppToC::Wrap(task)); + + // Return type: bool + return _retval?true:false; +} + + +CEF_GLOBAL bool CefPostDelayedTask(CefThreadId threadId, + CefRefPtr task, long delay_ms) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: task; type: refptr_diff + DCHECK(task.get()); + if (!task.get()) + return false; + + // Execute + int _retval = cef_post_delayed_task( + threadId, + CefTaskCppToC::Wrap(task), + delay_ms); + + // Return type: bool + return _retval?true:false; +} + + +CEF_GLOBAL bool CefParseURL(const CefString& url, CefURLParts& parts) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: url; type: string_byref_const + DCHECK(!url.empty()); + if (url.empty()) + return false; + + // Execute + int _retval = cef_parse_url( + url.GetStruct(), + &parts); + + // Return type: bool + return _retval?true:false; +} + + +CEF_GLOBAL bool CefCreateURL(const CefURLParts& parts, CefString& url) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = cef_create_url( + &parts, + url.GetWritableStruct()); + + // Return type: bool + return _retval?true:false; +} + + +CEF_GLOBAL bool CefVisitAllCookies(CefRefPtr visitor) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: visitor; type: refptr_diff + DCHECK(visitor.get()); + if (!visitor.get()) + return false; + + // Execute + int _retval = cef_visit_all_cookies( + CefCookieVisitorCppToC::Wrap(visitor)); + + // Return type: bool + return _retval?true:false; +} + + +CEF_GLOBAL bool CefVisitUrlCookies(const CefString& url, bool includeHttpOnly, + CefRefPtr visitor) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: url; type: string_byref_const + DCHECK(!url.empty()); + if (url.empty()) + return false; + // Verify param: visitor; type: refptr_diff + DCHECK(visitor.get()); + if (!visitor.get()) + return false; + + // Execute + int _retval = cef_visit_url_cookies( + url.GetStruct(), + includeHttpOnly, + CefCookieVisitorCppToC::Wrap(visitor)); + + // Return type: bool + return _retval?true:false; +} + + +CEF_GLOBAL bool CefSetCookie(const CefString& url, const CefCookie& cookie) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: url; type: string_byref_const + DCHECK(!url.empty()); + if (url.empty()) + return false; + + // Execute + int _retval = cef_set_cookie( + url.GetStruct(), + &cookie); + + // Return type: bool + return _retval?true:false; +} + + +CEF_GLOBAL bool CefDeleteCookies(const CefString& url, + const CefString& cookie_name) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Unverified params: url, cookie_name + + // Execute + int _retval = cef_delete_cookies( + url.GetStruct(), + cookie_name.GetStruct()); + + // Return type: bool + return _retval?true:false; +} + + +CEF_GLOBAL bool CefSetCookiePath(const CefString& path) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Unverified params: path + + // Execute + int _retval = cef_set_cookie_path( + path.GetStruct()); + + // Return type: bool + return _retval?true:false; +} + + +CEF_GLOBAL bool CefVisitStorage(CefStorageType type, const CefString& origin, + const CefString& key, CefRefPtr visitor) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: visitor; type: refptr_diff + DCHECK(visitor.get()); + if (!visitor.get()) + return false; + // Unverified params: origin, key + + // Execute + int _retval = cef_visit_storage( + type, + origin.GetStruct(), + key.GetStruct(), + CefStorageVisitorCppToC::Wrap(visitor)); + + // Return type: bool + return _retval?true:false; +} + + +CEF_GLOBAL bool CefSetStorage(CefStorageType type, const CefString& origin, + const CefString& key, const CefString& value) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: origin; type: string_byref_const + DCHECK(!origin.empty()); + if (origin.empty()) + return false; + // Verify param: key; type: string_byref_const + DCHECK(!key.empty()); + if (key.empty()) + return false; + // Verify param: value; type: string_byref_const + DCHECK(!value.empty()); + if (value.empty()) + return false; + + // Execute + int _retval = cef_set_storage( + type, + origin.GetStruct(), + key.GetStruct(), + value.GetStruct()); + + // Return type: bool + return _retval?true:false; +} + + +CEF_GLOBAL bool CefDeleteStorage(CefStorageType type, const CefString& origin, + const CefString& key) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Unverified params: origin, key + + // Execute + int _retval = cef_delete_storage( + type, + origin.GetStruct(), + key.GetStruct()); + + // Return type: bool + return _retval?true:false; +} + + +CEF_GLOBAL bool CefSetStoragePath(CefStorageType type, const CefString& path) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Unverified params: path + + // Execute + int _retval = cef_set_storage_path( + type, + path.GetStruct()); + + // Return type: bool + return _retval?true:false; +} + + diff --git a/cef/libcef_dll/wrapper/libcef_dll_wrapper2.cc b/cef/libcef_dll/wrapper/libcef_dll_wrapper2.cc new file mode 100755 index 000000000..28943a1b8 --- /dev/null +++ b/cef/libcef_dll/wrapper/libcef_dll_wrapper2.cc @@ -0,0 +1,13 @@ +// 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_capi.h" +#include "include/cef_nplugin.h" +#include "include/cef_nplugin_capi.h" + +bool CefRegisterPlugin(const CefPluginInfo& plugin_info) +{ + return cef_register_plugin(&plugin_info)?true:false; +} diff --git a/cef/tools/README-TRANSFER.txt b/cef/tools/README-TRANSFER.txt new file mode 100755 index 000000000..b49d72db1 --- /dev/null +++ b/cef/tools/README-TRANSFER.txt @@ -0,0 +1,9 @@ +Files in this directory have been copied from other locations in the Chromium +source tree. They have been modified only to the extent necessary to work in +the CEF Binary Distribution directory structure. Below is a listing of the +original file locations. + +../build/mac/change_mach_o_flags_from_xcode.sh +../build/mac/change_mach_o_flags.py +../build/mac/strip_from_xcode +../build/mac/strip_save_dsym diff --git a/cef/tools/change_mach_o_flags.py b/cef/tools/change_mach_o_flags.py new file mode 100755 index 000000000..c2aeaec9b --- /dev/null +++ b/cef/tools/change_mach_o_flags.py @@ -0,0 +1,273 @@ +#!/usr/bin/env python +# Copyright (c) 2011 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +"""Usage: change_mach_o_flags.py [--executable-heap] [--no-pie] + +Arranges for the executable at |executable_path| to have its data (heap) +pages protected to prevent execution on Mac OS X 10.7 ("Lion"), and to have +the PIE (position independent executable) bit set to enable ASLR (address +space layout randomization). With --executable-heap or --no-pie, the +respective bits are cleared instead of set, making the heap executable or +disabling PIE/ASLR. + +This script is able to operate on thin (single-architecture) Mach-O files +and fat (universal, multi-architecture) files. When operating on fat files, +it will set or clear the bits for each architecture contained therein. + +NON-EXECUTABLE HEAP + +Traditionally in Mac OS X, 32-bit processes did not have data pages set to +prohibit execution. Although user programs could call mprotect and +mach_vm_protect to deny execution of code in data pages, the kernel would +silently ignore such requests without updating the page tables, and the +hardware would happily execute code on such pages. 64-bit processes were +always given proper hardware protection of data pages. This behavior was +controllable on a system-wide level via the vm.allow_data_exec sysctl, which +is set by default to 1. The bit with value 1 (set by default) allows code +execution on data pages for 32-bit processes, and the bit with value 2 +(clear by default) does the same for 64-bit processes. + +In Mac OS X 10.7, executables can "opt in" to having hardware protection +against code execution on data pages applied. This is done by setting a new +bit in the |flags| field of an executable's |mach_header|. When +MH_NO_HEAP_EXECUTION is set, proper protections will be applied, regardless +of the setting of vm.allow_data_exec. See xnu-1699.22.73/osfmk/vm/vm_map.c +override_nx and xnu-1699.22.73/bsd/kern/mach_loader.c load_machfile. + +The Apple toolchain has been revised to set the MH_NO_HEAP_EXECUTION when +producing executables, provided that -allow_heap_execute is not specified +at link time. Only linkers shipping with Xcode 4.0 and later (ld64-123.2 and +later) have this ability. See ld64-123.2.1/src/ld/Options.cpp +Options::reconfigureDefaults() and +ld64-123.2.1/src/ld/HeaderAndLoadCommands.hpp +HeaderAndLoadCommandsAtom::flags(). + +This script sets the MH_NO_HEAP_EXECUTION bit on Mach-O executables. It is +intended for use with executables produced by a linker that predates Apple's +modifications to set this bit itself. It is also useful for setting this bit +for non-i386 executables, including x86_64 executables. Apple's linker only +sets it for 32-bit i386 executables, presumably under the assumption that +the value of vm.allow_data_exec is set in stone. However, if someone were to +change vm.allow_data_exec to 2 or 3, 64-bit x86_64 executables would run +without hardware protection against code execution on data pages. This +script can set the bit for x86_64 executables, guaranteeing that they run +with appropriate protection even when vm.allow_data_exec has been tampered +with. + +POSITION-INDEPENDENT EXECUTABLES/ADDRESS SPACE LAYOUT RANDOMIZATION + +This script sets or clears the MH_PIE bit in an executable's Mach-O header, +enabling or disabling position independence on Mac OS X 10.5 and later. +Processes running position-independent executables have varying levels of +ASLR protection depending on the OS release. The main executable's load +address, shared library load addresess, and the heap and stack base +addresses may be randomized. Position-independent executables are produced +by supplying the -pie flag to the linker (or defeated by supplying -no_pie). +Executables linked with a deployment target of 10.7 or higher have PIE on +by default. + +This script is never strictly needed during the build to enable PIE, as all +linkers used are recent enough to support -pie. However, it's used to +disable the PIE bit as needed on already-linked executables. +""" + +import optparse +import os +import struct +import sys + + +# +FAT_MAGIC = 0xcafebabe +FAT_CIGAM = 0xbebafeca + +# +MH_MAGIC = 0xfeedface +MH_CIGAM = 0xcefaedfe +MH_MAGIC_64 = 0xfeedfacf +MH_CIGAM_64 = 0xcffaedfe +MH_EXECUTE = 0x2 +MH_PIE = 0x00200000 +MH_NO_HEAP_EXECUTION = 0x01000000 + + +class MachOError(Exception): + """A class for exceptions thrown by this module.""" + + pass + + +def CheckedSeek(file, offset): + """Seeks the file-like object at |file| to offset |offset| and raises a + MachOError if anything funny happens.""" + + file.seek(offset, os.SEEK_SET) + new_offset = file.tell() + if new_offset != offset: + raise MachOError, \ + 'seek: expected offset %d, observed %d' % (offset, new_offset) + + +def CheckedRead(file, count): + """Reads |count| bytes from the file-like |file| object, raising a + MachOError if any other number of bytes is read.""" + + bytes = file.read(count) + if len(bytes) != count: + raise MachOError, \ + 'read: expected length %d, observed %d' % (count, len(bytes)) + + return bytes + + +def ReadUInt32(file, endian): + """Reads an unsinged 32-bit integer from the file-like |file| object, + treating it as having endianness specified by |endian| (per the |struct| + module), and returns it as a number. Raises a MachOError if the proper + length of data can't be read from |file|.""" + + bytes = CheckedRead(file, 4) + + (uint32,) = struct.unpack(endian + 'I', bytes) + return uint32 + + +def ReadMachHeader(file, endian): + """Reads an entire |mach_header| structure () from the + file-like |file| object, treating it as having endianness specified by + |endian| (per the |struct| module), and returns a 7-tuple of its members + as numbers. Raises a MachOError if the proper length of data can't be read + from |file|.""" + + bytes = CheckedRead(file, 28) + + magic, cputype, cpusubtype, filetype, ncmds, sizeofcmds, flags = \ + struct.unpack(endian + '7I', bytes) + return magic, cputype, cpusubtype, filetype, ncmds, sizeofcmds, flags + + +def ReadFatArch(file): + """Reads an entire |fat_arch| structure () from the file-like + |file| object, treating it as having endianness specified by |endian| + (per the |struct| module), and returns a 5-tuple of its members as numbers. + Raises a MachOError if the proper length of data can't be read from + |file|.""" + + bytes = CheckedRead(file, 20) + + cputype, cpusubtype, offset, size, align = struct.unpack('>5I', bytes) + return cputype, cpusubtype, offset, size, align + + +def WriteUInt32(file, uint32, endian): + """Writes |uint32| as an unsinged 32-bit integer to the file-like |file| + object, treating it as having endianness specified by |endian| (per the + |struct| module).""" + + bytes = struct.pack(endian + 'I', uint32) + assert len(bytes) == 4 + + file.write(bytes) + + +def HandleMachOFile(file, options, offset=0): + """Seeks the file-like |file| object to |offset|, reads its |mach_header|, + and rewrites the header's |flags| field if appropriate. The header's + endianness is detected. Both 32-bit and 64-bit Mach-O headers are supported + (mach_header and mach_header_64). Raises MachOError if used on a header that + does not have a known magic number or is not of type MH_EXECUTE. The + MH_PIE and MH_NO_HEAP_EXECUTION bits are set or cleared in the |flags| field + according to |options| and written to |file| if any changes need to be made. + If already set or clear as specified by |options|, nothing is written.""" + + CheckedSeek(file, offset) + magic = ReadUInt32(file, '<') + if magic == MH_MAGIC or magic == MH_MAGIC_64: + endian = '<' + elif magic == MH_CIGAM or magic == MH_CIGAM_64: + endian = '>' + else: + raise MachOError, \ + 'Mach-O file at offset %d has illusion of magic' % offset + + CheckedSeek(file, offset) + magic, cputype, cpusubtype, filetype, ncmds, sizeofcmds, flags = \ + ReadMachHeader(file, endian) + assert magic == MH_MAGIC or magic == MH_MAGIC_64 + if filetype != MH_EXECUTE: + raise MachOError, \ + 'Mach-O file at offset %d is type 0x%x, expected MH_EXECUTE' % \ + (offset, filetype) + + original_flags = flags + + if options.no_heap_execution: + flags |= MH_NO_HEAP_EXECUTION + else: + flags &= ~MH_NO_HEAP_EXECUTION + + if options.pie: + flags |= MH_PIE + else: + flags &= ~MH_PIE + + if flags != original_flags: + CheckedSeek(file, offset + 24) + WriteUInt32(file, flags, endian) + + +def HandleFatFile(file, options, fat_offset=0): + """Seeks the file-like |file| object to |offset| and loops over its + |fat_header| entries, calling HandleMachOFile for each.""" + + CheckedSeek(file, fat_offset) + magic = ReadUInt32(file, '>') + assert magic == FAT_MAGIC + + nfat_arch = ReadUInt32(file, '>') + + for index in xrange(0, nfat_arch): + cputype, cpusubtype, offset, size, align = ReadFatArch(file) + assert size >= 28 + + # HandleMachOFile will seek around. Come back here after calling it, in + # case it sought. + fat_arch_offset = file.tell() + HandleMachOFile(file, options, offset) + CheckedSeek(file, fat_arch_offset) + + +def main(me, args): + parser = optparse.OptionParser('%prog [options] ') + parser.add_option('--executable-heap', action='store_false', + dest='no_heap_execution', default=True, + help='Clear the MH_NO_HEAP_EXECUTION bit') + parser.add_option('--no-pie', action='store_false', + dest='pie', default=True, + help='Clear the MH_PIE bit') + (options, loose_args) = parser.parse_args(args) + if len(loose_args) != 1: + parser.print_usage() + return 1 + + executable_path = loose_args[0] + executable_file = open(executable_path, 'rb+') + + magic = ReadUInt32(executable_file, '<') + if magic == FAT_CIGAM: + # Check FAT_CIGAM and not FAT_MAGIC because the read was little-endian. + HandleFatFile(executable_file, options) + elif magic == MH_MAGIC or magic == MH_CIGAM or \ + magic == MH_MAGIC_64 or magic == MH_CIGAM_64: + HandleMachOFile(executable_file, options) + else: + raise MachOError, '%s is not a Mach-O or fat file' % executable_file + + executable_file.close() + return 0 + + +if __name__ == '__main__': + sys.exit(main(sys.argv[0], sys.argv[1:])) diff --git a/cef/tools/change_mach_o_flags_from_xcode.sh b/cef/tools/change_mach_o_flags_from_xcode.sh new file mode 100755 index 000000000..1824f8db5 --- /dev/null +++ b/cef/tools/change_mach_o_flags_from_xcode.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# Copyright (c) 2011 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# This is a small wrapper script around change_mach_o_flags.py allowing it to +# be invoked easily from Xcode. change_mach_o_flags.py expects its arguments +# on the command line, but Xcode puts its parameters in the environment. + +set -e + +exec "$(dirname "${0}")/change_mach_o_flags.py" \ + "${@}" \ + "${BUILT_PRODUCTS_DIR}/${EXECUTABLE_PATH}" diff --git a/cef/tools/strip_from_xcode b/cef/tools/strip_from_xcode new file mode 100755 index 000000000..c26b9fb49 --- /dev/null +++ b/cef/tools/strip_from_xcode @@ -0,0 +1,62 @@ +#!/bin/bash + +# Copyright (c) 2008 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# This is a handy wrapper script that figures out how to call the strip +# utility (strip_save_dsym in this case), if it even needs to be called at all, +# and then does it. This script should be called by a post-link phase in +# targets that might generate Mach-O executables, dynamic libraries, or +# loadable bundles. +# +# An example "Strip If Needed" build phase placed after "Link Binary With +# Libraries" would do: +# exec "${XCODEPROJ_DEPTH}/build/mac/strip_from_xcode" + +if [ "${CONFIGURATION}" != "Release" ] ; then + # Only strip in release mode. + exit 0 +fi + +declare -a FLAGS + +# MACH_O_TYPE is not set for a command-line tool, so check PRODUCT_TYPE too. +# Weird. +if [ "${MACH_O_TYPE}" = "mh_execute" ] || \ + [ "${PRODUCT_TYPE}" = "com.apple.product-type.tool" ] ; then + # Strip everything (no special flags). No-op. + true +elif [ "${MACH_O_TYPE}" = "mh_dylib" ] || \ + [ "${MACH_O_TYPE}" = "mh_bundle" ]; then + # Strip debugging symbols and local symbols + FLAGS[${#FLAGS[@]}]=-S + FLAGS[${#FLAGS[@]}]=-x +elif [ "${MACH_O_TYPE}" = "staticlib" ] ; then + # Don't strip static libraries. + exit 0 +else + # Warn, but don't treat this as an error. + echo $0: warning: unrecognized MACH_O_TYPE ${MACH_O_TYPE} + exit 0 +fi + +if [ -n "${STRIPFLAGS}" ] ; then + # Pick up the standard STRIPFLAGS Xcode setting, used for "Additional Strip + # Flags". + for stripflag in "${STRIPFLAGS}" ; do + FLAGS[${#FLAGS[@]}]="${stripflag}" + done +fi + +if [ -n "${CHROMIUM_STRIP_SAVE_FILE}" ] ; then + # An Xcode project can communicate a file listing symbols to saved in this + # environment variable by setting it as a build setting. This isn't a + # standard Xcode setting. It's used in preference to STRIPFLAGS to + # eliminate quoting ambiguity concerns. + FLAGS[${#FLAGS[@]}]=-s + FLAGS[${#FLAGS[@]}]="${CHROMIUM_STRIP_SAVE_FILE}" +fi + +exec "$(dirname ${0})/strip_save_dsym" "${FLAGS[@]}" \ + "${BUILT_PRODUCTS_DIR}/${EXECUTABLE_PATH}" diff --git a/cef/tools/strip_save_dsym b/cef/tools/strip_save_dsym new file mode 100755 index 000000000..a132379d8 --- /dev/null +++ b/cef/tools/strip_save_dsym @@ -0,0 +1,341 @@ +#!/usr/bin/python + +# Copyright (c) 2011 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Usage: strip_save_dsym +# +# strip_save_dsym is a wrapper around the standard strip utility. Given an +# input Mach-O file, strip_save_dsym will save a copy of the file in a "fake" +# .dSYM bundle for debugging, and then call strip to strip the Mach-O file. +# Note that the .dSYM file is a "fake" in that it's not a self-contained +# .dSYM bundle, it just contains a copy of the original (unstripped) Mach-O +# file, and therefore contains references to object files on the filesystem. +# The generated .dSYM bundle is therefore unsuitable for debugging in the +# absence of these .o files. +# +# If a .dSYM already exists and has a newer timestamp than the Mach-O file, +# this utility does nothing. That allows strip_save_dsym to be run on a file +# that has already been stripped without trashing the .dSYM. +# +# Rationale: the "right" way to generate dSYM bundles, dsymutil, is incredibly +# slow. On the other hand, doing a file copy (which is really all that +# dsymutil does) is comparatively fast. Since we usually just want to strip +# a release-mode executable but still be able to debug it, and we don't care +# so much about generating a hermetic dSYM bundle, we'll prefer the file copy. +# If a real dSYM is ever needed, it's still possible to create one by running +# dsymutil and pointing it at the original Mach-O file inside the "fake" +# bundle, provided that the object files are available. + +import errno +import os +import re +import shutil +import subprocess +import sys +import time + +# Returns a list of architectures contained in a Mach-O file. The file can be +# a universal (fat) file, in which case there will be one list element for +# each contained architecture, or it can be a thin single-architecture Mach-O +# file, in which case the list will contain a single element identifying the +# architecture. On error, returns an empty list. Determines the architecture +# list by calling file. +def macho_archs(macho): + macho_types = ["executable", + "dynamically linked shared library", + "bundle"] + macho_types_re = "Mach-O (?:64-bit )?(?:" + "|".join(macho_types) + ")" + + file_cmd = subprocess.Popen(["/usr/bin/file", "-b", "-L", "--", macho], + stdout=subprocess.PIPE) + + archs = [] + + type_line = file_cmd.stdout.readline() + type_match = re.match("^%s (.*)$" % macho_types_re, type_line) + if type_match: + archs.append(type_match.group(1)) + return [type_match.group(1)] + else: + type_match = re.match("^Mach-O universal binary with (.*) architectures$", + type_line) + if type_match: + for i in range(0, int(type_match.group(1))): + arch_line = file_cmd.stdout.readline() + arch_match = re.match( + "^.* \(for architecture (.*)\):\t%s .*$" % macho_types_re, + arch_line) + if arch_match: + archs.append(arch_match.group(1)) + + if file_cmd.wait() != 0: + archs = [] + + if len(archs) == 0: + print >> sys.stderr, "No architectures in %s" % macho + + return archs + +# Returns a dictionary mapping architectures contained in the file as returned +# by macho_archs to the LC_UUID load command for that architecture. +# Architectures with no LC_UUID load command are omitted from the dictionary. +# Determines the UUID value by calling otool. +def macho_uuids(macho): + uuids = {} + + archs = macho_archs(macho) + if len(archs) == 0: + return uuids + + for arch in archs: + if arch == "": + continue + + otool_cmd = subprocess.Popen(["/usr/bin/otool", "-arch", arch, "-l", "-", + macho], + stdout=subprocess.PIPE) + # state 0 is when nothing UUID-related has been seen yet. State 1 is + # entered after a load command begins, but it may not be an LC_UUID load + # command. States 2, 3, and 4 are intermediate states while reading an + # LC_UUID command. State 5 is the terminal state for a successful LC_UUID + # read. State 6 is the error state. + state = 0 + uuid = "" + for otool_line in otool_cmd.stdout: + if state == 0: + if re.match("^Load command .*$", otool_line): + state = 1 + elif state == 1: + if re.match("^ cmd LC_UUID$", otool_line): + state = 2 + else: + state = 0 + elif state == 2: + if re.match("^ cmdsize 24$", otool_line): + state = 3 + else: + state = 6 + elif state == 3: + # The UUID display format changed in the version of otool shipping + # with the Xcode 3.2.2 prerelease. The new format is traditional: + # uuid 4D7135B2-9C56-C5F5-5F49-A994258E0955 + # and with Xcode 3.2.6, then line is indented one more space: + # uuid 4D7135B2-9C56-C5F5-5F49-A994258E0955 + # The old format, from cctools-750 and older's otool, breaks the UUID + # up into a sequence of bytes: + # uuid 0x4d 0x71 0x35 0xb2 0x9c 0x56 0xc5 0xf5 + # 0x5f 0x49 0xa9 0x94 0x25 0x8e 0x09 0x55 + new_uuid_match = re.match("^ {3,4}uuid (.{8}-.{4}-.{4}-.{4}-.{12})$", + otool_line) + if new_uuid_match: + uuid = new_uuid_match.group(1) + + # Skip state 4, there is no second line to read. + state = 5 + else: + old_uuid_match = re.match("^ uuid 0x(..) 0x(..) 0x(..) 0x(..) " + "0x(..) 0x(..) 0x(..) 0x(..)$", + otool_line) + if old_uuid_match: + state = 4 + uuid = old_uuid_match.group(1) + old_uuid_match.group(2) + \ + old_uuid_match.group(3) + old_uuid_match.group(4) + "-" + \ + old_uuid_match.group(5) + old_uuid_match.group(6) + "-" + \ + old_uuid_match.group(7) + old_uuid_match.group(8) + "-" + else: + state = 6 + elif state == 4: + old_uuid_match = re.match("^ 0x(..) 0x(..) 0x(..) 0x(..) " + "0x(..) 0x(..) 0x(..) 0x(..)$", + otool_line) + if old_uuid_match: + state = 5 + uuid += old_uuid_match.group(1) + old_uuid_match.group(2) + "-" + \ + old_uuid_match.group(3) + old_uuid_match.group(4) + \ + old_uuid_match.group(5) + old_uuid_match.group(6) + \ + old_uuid_match.group(7) + old_uuid_match.group(8) + else: + state = 6 + + if otool_cmd.wait() != 0: + state = 6 + + if state == 5: + uuids[arch] = uuid.upper() + + if len(uuids) == 0: + print >> sys.stderr, "No UUIDs in %s" % macho + + return uuids + +# Given a path to a Mach-O file and possible information from the environment, +# determines the desired path to the .dSYM. +def dsym_path(macho): + # If building a bundle, the .dSYM should be placed next to the bundle. Use + # WRAPPER_NAME to make this determination. If called from xcodebuild, + # WRAPPER_NAME will be set to the name of the bundle. + dsym = "" + if "WRAPPER_NAME" in os.environ: + if "BUILT_PRODUCTS_DIR" in os.environ: + dsym = os.path.join(os.environ["BUILT_PRODUCTS_DIR"], + os.environ["WRAPPER_NAME"]) + else: + dsym = os.environ["WRAPPER_NAME"] + else: + dsym = macho + + dsym += ".dSYM" + + return dsym + +# Creates a fake .dSYM bundle at dsym for macho, a Mach-O image with the +# architectures and UUIDs specified by the uuids map. +def make_fake_dsym(macho, dsym): + uuids = macho_uuids(macho) + if len(uuids) == 0: + return False + + dwarf_dir = os.path.join(dsym, "Contents", "Resources", "DWARF") + dwarf_file = os.path.join(dwarf_dir, os.path.basename(macho)) + try: + os.makedirs(dwarf_dir) + except OSError, (err, error_string): + if err != errno.EEXIST: + raise + shutil.copyfile(macho, dwarf_file) + + # info_template is the same as what dsymutil would have written, with the + # addition of the fake_dsym key. + info_template = \ +''' + + + + CFBundleDevelopmentRegion + English + CFBundleIdentifier + com.apple.xcode.dsym.%(root_name)s + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + dSYM + CFBundleSignature + ???? + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + dSYM_UUID + +%(uuid_dict)s + fake_dsym + + + +''' + + root_name = os.path.basename(dsym)[:-5] # whatever.dSYM without .dSYM + uuid_dict = "" + for arch in sorted(uuids): + uuid_dict += "\t\t\t" + arch + "\n"\ + "\t\t\t" + uuids[arch] + "\n" + info_dict = { + "root_name": root_name, + "uuid_dict": uuid_dict, + } + info_contents = info_template % info_dict + info_file = os.path.join(dsym, "Contents", "Info.plist") + info_fd = open(info_file, "w") + info_fd.write(info_contents) + info_fd.close() + + return True + +# For a Mach-O file, determines where the .dSYM bundle should be located. If +# the bundle does not exist or has a modification time older than the Mach-O +# file, calls make_fake_dsym to create a fake .dSYM bundle there, then strips +# the Mach-O file and sets the modification time on the .dSYM bundle and Mach-O +# file to be identical. +def strip_and_make_fake_dsym(macho): + dsym = dsym_path(macho) + macho_stat = os.stat(macho) + dsym_stat = None + try: + dsym_stat = os.stat(dsym) + except OSError, (err, error_string): + if err != errno.ENOENT: + raise + + if dsym_stat is None or dsym_stat.st_mtime < macho_stat.st_mtime: + # Make a .dSYM bundle + if not make_fake_dsym(macho, dsym): + return False + + # Strip the Mach-O file + remove_dsym = True + try: + strip_path = "" + if "SYSTEM_DEVELOPER_BIN_DIR" in os.environ: + strip_path = os.environ["SYSTEM_DEVELOPER_BIN_DIR"] + else: + strip_path = "/usr/bin" + strip_path = os.path.join(strip_path, "strip") + strip_cmdline = [strip_path] + sys.argv[1:] + strip_cmd = subprocess.Popen(strip_cmdline) + if strip_cmd.wait() == 0: + remove_dsym = False + finally: + if remove_dsym: + shutil.rmtree(dsym) + + # Update modification time on the Mach-O file and .dSYM bundle + now = time.time() + os.utime(macho, (now, now)) + os.utime(dsym, (now, now)) + + return True + +def main(argv=None): + if argv is None: + argv = sys.argv + + # This only supports operating on one file at a time. Look at the arguments + # to strip to figure out what the source to be stripped is. Arguments are + # processed in the same way that strip does, although to reduce complexity, + # this doesn't do all of the same checking as strip. For example, strip + # has no -Z switch and would treat -Z on the command line as an error. For + # the purposes this is needed for, that's fine. + macho = None + process_switches = True + ignore_argument = False + for arg in argv[1:]: + if ignore_argument: + ignore_argument = False + continue + if process_switches: + if arg == "-": + process_switches = False + # strip has these switches accept an argument: + if arg in ["-s", "-R", "-d", "-o", "-arch"]: + ignore_argument = True + if arg[0] == "-": + continue + if macho is None: + macho = arg + else: + print >> sys.stderr, "Too many things to strip" + return 1 + + if macho is None: + print >> sys.stderr, "Nothing to strip" + return 1 + + if not strip_and_make_fake_dsym(macho): + return 1 + + return 0 + +if __name__ == "__main__": + sys.exit(main(sys.argv)) diff --git a/docs/api.coffee b/docs/api.coffee deleted file mode 100644 index 59d41b52d..000000000 --- a/docs/api.coffee +++ /dev/null @@ -1 +0,0 @@ -# API Ideas diff --git a/docs/chris-wants.txt b/docs/chris-wants.txt deleted file mode 100644 index 61e315ad5..000000000 --- a/docs/chris-wants.txt +++ /dev/null @@ -1,8 +0,0 @@ -Want -- open raw HTML in browser tab - -- cmd-shift-p: preview markdown as HTML - -- cmd-t file finder uses project.settings.extraURLs - -- atom.process.run "shell-command", -> stdoutCallback() \ No newline at end of file diff --git a/docs/corey-wants.txt b/docs/corey-wants.txt deleted file mode 100644 index 57a8e8153..000000000 --- a/docs/corey-wants.txt +++ /dev/null @@ -1,15 +0,0 @@ -Intent -- open a folder - -- child urls of folder open in same window - -- open/save/close on project - -Want -- cmd-shift-t: reopen last closed tab - -- an extension that shows all available key commands - -- stdlib should be indepentent of atom (no events in stdlib) - - diff --git a/docs/extensions.md b/docs/extensions.md deleted file mode 100644 index 3e9952bf6..000000000 --- a/docs/extensions.md +++ /dev/null @@ -1,30 +0,0 @@ -* Project -find in project -find file in project -issues -gem scraper -npm scraper -rake runner -test runner -rails extension -ctags -treeview -tabs - -* Resource -gist resource - -* Window -gist creator/browser -thunderhorse -align -git -console - -* Editor -debugger -markdown viewer -(coffee -> java)script -surround -snippets - diff --git a/docs/sample-conf.coffee b/docs/sample-conf.coffee deleted file mode 100644 index 7f82ff68c..000000000 --- a/docs/sample-conf.coffee +++ /dev/null @@ -1,24 +0,0 @@ -# ~/.atom/settings.coffee -# ---------------------------- - -editor: - tabSize: 2 - spaces: true - -# ~/.atom/keybindings.coffee - -app: - "cmd-q": (app) -> app.quit() - "cmd-q": "quit" # optional way? -editor: - "ctrl-p": (editor) -> editor.moveUp() - "ctrl-a": (editor) -> - position = editor.cursorPosition() - position.column = 0 - editor.setCursorPosition(position) -tree: - "cmd-ctrl-n": (tree) -> tree.toggle() -window: - 'Command-O' : @open - 'Command-Ctrl-K' : @showConsole - diff --git a/docs/talk.txt b/docs/talk.txt deleted file mode 100644 index c139e045b..000000000 --- a/docs/talk.txt +++ /dev/null @@ -1,60 +0,0 @@ -vision: - -extensible - - web technology - - built-in syntactic awareness - - github integration - can serve as a community sponsor / focal point - - -real time collaboration - - github has made coding social, but it' like email - - now we can make coding social like campfire, real time - - - scenario 1: (collaborating) you're on a team. in your editor you see your teammates and can effortlessly join them in their working copy - - can message someone for help, lower barrier of interruption - - fluid pairing... easily transition from soloing to working together, without unplugging keyboards or changing desks - - benefits of pivotal, digitized - - - scenario 2: (learning / sharing) imagine two haskell programmers, or authors of a library you are pairing on, and allow you to come watch them... think of what you could learn from their conversation - - imagine search for commits involving the work "Riak" that are broadcast, now you see it working - - code instant replay... don't just read a commit, watch a commit - - - mud vs mmorpg analogy - -example: - - cascading keymaps - - command-t - - extension, example of ckm (up and down) - - vim - -theory: - parsing expression grammars and doing it in real time (NS) - - --------- -why do we need another editor? -- ease of extensibility - - javascript / web tech - web is new lingua franca has emerged in the last decade... a common language / set of patterns for application dev - - many current extensible editors are older than us - - syntactic awareness: middle ground between vim/textmate and eclipse/intelli-j/visual studio - -- collaboration - deep github integration... - github is async collaboration... this would be synchronous - - replaying the actual keystrokes of code being written or a pairing session to understand why it was done that way - --------------- -pair programming: -pros: -raid array for team knowledge -reduced ego, a sense of collective ownership -learning opportunity... someone can add value on day 1 -explaining your thinking can make it clearer -continuous code review - -cons: -handcuffed to your pair because you're using one computer -friction between starting and stopping - simple/wrote tasks might not need a pair, but how do you transition between pairing and soloing? -same physical location at the same time - diff --git a/docs/webkit.md b/docs/webkit.md deleted file mode 100644 index b3062c187..000000000 --- a/docs/webkit.md +++ /dev/null @@ -1,20 +0,0 @@ -* Get webkit source (~30 minutes) - `git clone --depth 1 https://github.com/WebKit/webkit.git` - `cd webkit` - -* Apply tmm1's patch (found at end of this document) - `patch -p1 < tmm1.patch` - -* Build webkit (~2 hours, don't let your computer go to sleep) - `Tools/Scripts/build-webkit --release` - -* Copy WebKit.framework, WebCore.framework and JavaScript.framework from `webkit/WebKitBuild/Release` to -`atom/frameworks` - -* Fix the dynamic library linking problems - `rake webkit-fix` - -# tmm1's patch -``` -Corey needs to go on the mini server and create the patch based on tmm1's changes -``` diff --git a/extensions/blank-extension/extension.coffee b/extensions/blank-extension/extension.coffee deleted file mode 100644 index bc9c36fea..000000000 --- a/extensions/blank-extension/extension.coffee +++ /dev/null @@ -1,16 +0,0 @@ -Extension = require 'extension' -Pane = require 'blank-extension/pane' - -module.exports = -class BlankExtension extends Extension - constructor: -> - atom.on 'project:open', @startup - - startup: => - #@pane = new Pane this - #@pane.show() - super - - shutdown: -> - #@pane.remove() - super diff --git a/extensions/blank-extension/images/dir-toggle.png b/extensions/blank-extension/images/dir-toggle.png deleted file mode 100644 index d14a81624..000000000 Binary files a/extensions/blank-extension/images/dir-toggle.png and /dev/null differ diff --git a/extensions/blank-extension/index.coffee b/extensions/blank-extension/index.coffee deleted file mode 100644 index 66d7ae4c3..000000000 --- a/extensions/blank-extension/index.coffee +++ /dev/null @@ -1 +0,0 @@ -module.exports = require 'blank-extension/extension' diff --git a/extensions/blank-extension/key-bindings.coffee b/extensions/blank-extension/key-bindings.coffee deleted file mode 100644 index 6a4aea179..000000000 --- a/extensions/blank-extension/key-bindings.coffee +++ /dev/null @@ -1,2 +0,0 @@ -blankextension: - 'cmd-ctrl-alt-?': (extension) -> extension.doSomething() diff --git a/extensions/blank-extension/pane.coffee b/extensions/blank-extension/pane.coffee deleted file mode 100644 index 2533dc5f9..000000000 --- a/extensions/blank-extension/pane.coffee +++ /dev/null @@ -1,14 +0,0 @@ -$ = require 'jquery' -_ = require 'underscore' - -fs = require 'fs' - -Pane = require 'pane' - -module.exports = -class BlankExtension extends Pane - position: 'left' - html: null - - constructor: -> - super diff --git a/extensions/dotatom/index.coffee b/extensions/dotatom/index.coffee deleted file mode 100644 index 47f47fa77..000000000 --- a/extensions/dotatom/index.coffee +++ /dev/null @@ -1,12 +0,0 @@ -fs = require 'fs' - -module.exports = -class Dotatom - constructor: -> - try - require "~/.atom" - catch e - console.log 'No ~/.atom module found.' - - atom.settings.load "~/.atom/settings.coffee" - atom.keybinder.load "~/.atom/key-bindings.coffee" diff --git a/extensions/filefinder/filefinder.coffee b/extensions/filefinder/filefinder.coffee deleted file mode 100644 index e0b9a0981..000000000 --- a/extensions/filefinder/filefinder.coffee +++ /dev/null @@ -1,28 +0,0 @@ -_ = require 'underscore' -fs = require 'fs' - -Extension = require 'extension' -ModalSelector = require 'modal-selector' - -module.exports = -class Filefinder extends Extension - settings: - cache: false - - cached: null - - constructor: -> - atom.on 'project:open', @startup - - startup: (@project) => - @pane = new ModalSelector @findURLs - - findURLs: => - return @cached if @settings.cache and @cached - - # always set cached, whether if we care about it or not. - @cached = _.reject @project.allURLs(), ({url}) -> - fs.isDirectory url - - toggle: -> - @pane?.toggle() diff --git a/extensions/filefinder/index.coffee b/extensions/filefinder/index.coffee deleted file mode 100644 index df2af297e..000000000 --- a/extensions/filefinder/index.coffee +++ /dev/null @@ -1 +0,0 @@ -module.exports = require 'filefinder/filefinder' diff --git a/extensions/filefinder/key-bindings.coffee b/extensions/filefinder/key-bindings.coffee deleted file mode 100644 index eb7b82a3e..000000000 --- a/extensions/filefinder/key-bindings.coffee +++ /dev/null @@ -1,3 +0,0 @@ -filefinder: - 'cmd-t': (filefinder) -> filefinder.toggle() - 'cmd-alt-t': (filefinder) -> filefinder.cached = null diff --git a/extensions/opened-urls/extension.coffee b/extensions/opened-urls/extension.coffee deleted file mode 100644 index 450fe0d25..000000000 --- a/extensions/opened-urls/extension.coffee +++ /dev/null @@ -1,28 +0,0 @@ - -Extension = require 'extension' - -module.exports = -class OpenedURLs extends Extension - storageKey: "#{$atomController.url}.openedFiles" - openedURLs: null - - constructor: -> - atom.on 'window:load', @startup - atom.on 'project:resource:open', @add - atom.on 'project:resource:close', @remove - - startup: => - super - @openedURLs = atom.storage.get @storageKey, [] - window.open url for url in @openedURLs - - add: (project, resource) => - @openedURLs.push resource.url unless resource.url in @openedURLs - - remove: (project, resource) => - if (i = @openedURLs.indexOf resource.url) > -1 - @openedURLs.splice i, 1 - - shutdown: -> - super - atom.storage.set @storageKey, @openedURLs diff --git a/extensions/opened-urls/images/dir-toggle.png b/extensions/opened-urls/images/dir-toggle.png deleted file mode 100644 index d14a81624..000000000 Binary files a/extensions/opened-urls/images/dir-toggle.png and /dev/null differ diff --git a/extensions/opened-urls/index.coffee b/extensions/opened-urls/index.coffee deleted file mode 100644 index a869c385a..000000000 --- a/extensions/opened-urls/index.coffee +++ /dev/null @@ -1 +0,0 @@ -module.exports = require 'opened-urls/extension' diff --git a/extensions/opened-urls/key-bindings.coffee b/extensions/opened-urls/key-bindings.coffee deleted file mode 100644 index 6a4aea179..000000000 --- a/extensions/opened-urls/key-bindings.coffee +++ /dev/null @@ -1,2 +0,0 @@ -blankextension: - 'cmd-ctrl-alt-?': (extension) -> extension.doSomething() diff --git a/extensions/tabs/index.coffee b/extensions/tabs/index.coffee deleted file mode 100644 index 65b5330a4..000000000 --- a/extensions/tabs/index.coffee +++ /dev/null @@ -1 +0,0 @@ -module.exports = require 'tabs/tabs' diff --git a/extensions/tabs/key-bindings.coffee b/extensions/tabs/key-bindings.coffee deleted file mode 100644 index 0d541aa77..000000000 --- a/extensions/tabs/key-bindings.coffee +++ /dev/null @@ -1,14 +0,0 @@ -tabs: - 'cmd-shift-{': (tabs) -> tabs.pane.prevTab() - 'cmd-shift-}': (tabs) -> tabs.pane.nextTab() - 'cmd-1': (tabs) -> tabs.pane.switchToTab 1 - 'cmd-2': (tabs) -> tabs.pane.switchToTab 2 - 'cmd-3': (tabs) -> tabs.pane.switchToTab 3 - 'cmd-4': (tabs) -> tabs.pane.switchToTab 4 - 'cmd-5': (tabs) -> tabs.pane.switchToTab 5 - 'cmd-6': (tabs) -> tabs.pane.switchToTab 6 - 'cmd-7': (tabs) -> tabs.pane.switchToTab 7 - 'cmd-8': (tabs) -> tabs.pane.switchToTab 8 - 'cmd-9': (tabs) -> tabs.pane.switchToTab 9 - 'cmd-shift-t': (tabs) -> tabs.toggle() - diff --git a/extensions/tabs/tabs-pane.coffee b/extensions/tabs/tabs-pane.coffee deleted file mode 100644 index de2e62dcf..000000000 --- a/extensions/tabs/tabs-pane.coffee +++ /dev/null @@ -1,59 +0,0 @@ -$ = require 'jquery' -_ = require 'underscore' - -Pane = require 'pane' - -module.exports = -class TabsPane extends Pane - position: 'top' - - constructor: -> - html = require 'tabs/tabs.html' - super html - - # Style html - css = $('').html require 'tabs/tabs.css' - $('head').append css - - # click tab - tabPane = this - $('#tabs ul li').live 'mousedown', -> - tabPane.switchToTab this - false - - nextTab: -> - @switchToTab $('#tabs ul .active').next() - - prevTab: -> - @switchToTab $('#tabs ul .active').prev() - - switchToTab: (tab) -> - tab = $("#tabs ul li").get(tab - 1) if _.isNumber tab - return if tab.length is 0 - return if $(tab).is ".active" - - path = $(tab).data 'path' - $("#tabs ul .active").removeClass("active") - $(tab).addClass 'active' - window.open path - - addTab: (path) -> - existing = $("#tabs [data-path='#{path}']") - return @switchToTab existing if existing.length - - name = _.last (path or 'untitled').split '/' - - $("#tabs ul .active").removeClass() - $("#tabs ul").append """ -
  • #{name}
  • - """ - $("#tabs ul li:last").addClass 'active' - - removeTab: (path) -> - tab = $("#tabs li[data-path='#{path}']") - if tab.hasClass("active") - nextTab = tab.next() - nextTab = tab.prev() if nextTab.length == 0 - @switchToTab nextTab if nextTab.length != 0 - - tab.remove() diff --git a/extensions/tabs/tabs.coffee b/extensions/tabs/tabs.coffee deleted file mode 100644 index 166fcd9d0..000000000 --- a/extensions/tabs/tabs.coffee +++ /dev/null @@ -1,31 +0,0 @@ -$ = require 'jquery' -fs = require 'fs' -Extension = require 'extension' -TabsPane = require 'tabs/tabs-pane' - -module.exports = -class Tabs extends Extension - project: null - - constructor: -> - atom.on 'project:open', @startup - atom.on 'project:resource:active', @focus - atom.on 'project:resource:close', @close - - startup: (@project) => - @pane = new TabsPane this - @pane.show() - super - - shutdown: -> - @pane.remove() - super - - toggle: -> - @pane?.toggle() - - focus: (project, resource) => - @pane?.addTab resource.url - - close: (project, resource) => - @pane?.removeTab resource.url diff --git a/extensions/tabs/tabs.css b/extensions/tabs/tabs.css deleted file mode 100644 index 5f9108713..000000000 --- a/extensions/tabs/tabs.css +++ /dev/null @@ -1,56 +0,0 @@ -#tabs * { - margin: 0; - padding: 0; - font: 12px "Lucida Grande", Helvetica, Arial, serif; - overflow: hidden; - -webkit-user-select: none; -} - -#tabs .clearfix:after { - visibility: hidden; - display: block; - font-size: 0; - content: " "; - clear: both; - height: 0; -} - -#tabs { - background: -webkit-gradient(linear, left top, left bottom, from(#EEEEEE), to(#D8D7D8)); - padding: 3px 0 0 0; -} - -#tabs ul { - list-style: none; - border-bottom: 1px solid #a0a0a0; -} -#tabs ul li { display: inline; } - -#tabs ul li.active a { - position: relative; - z-index: 1; - height: 8px; - - background: #eee; - padding-top: 4px; -} - -#tabs ul li a { - display: block; - float: left; - text-decoration: none; - position: relative; - height: 8px; - - padding: 3px 50px 7px; - margin: 0 -5px 0 0; - color: #222; - background: #d8d7d8; - - -webkit-border-top-right-radius: 10px 20px; - -webkit-border-top-left-radius: 10px 20px; - -webkit-box-shadow: inset 1px 1px 0 white; - - border: 1px solid #a0a0a0; - border-bottom: 0; -} diff --git a/extensions/tabs/tabs.html b/extensions/tabs/tabs.html deleted file mode 100644 index aeaf485d9..000000000 --- a/extensions/tabs/tabs.html +++ /dev/null @@ -1,5 +0,0 @@ -
    -
      -
    -
    - diff --git a/extensions/tree/images/dir-toggle.png b/extensions/tree/images/dir-toggle.png deleted file mode 100644 index d14a81624..000000000 Binary files a/extensions/tree/images/dir-toggle.png and /dev/null differ diff --git a/extensions/tree/index.coffee b/extensions/tree/index.coffee deleted file mode 100644 index bf78b0cdd..000000000 --- a/extensions/tree/index.coffee +++ /dev/null @@ -1 +0,0 @@ -module.exports = Tree = require 'tree/tree' diff --git a/extensions/tree/key-bindings.coffee b/extensions/tree/key-bindings.coffee deleted file mode 100644 index 8cc62b428..000000000 --- a/extensions/tree/key-bindings.coffee +++ /dev/null @@ -1,2 +0,0 @@ -tree: - 'cmd-ctrl-n': (tree) -> tree.pane.toggle() diff --git a/extensions/tree/tree-pane.coffee b/extensions/tree/tree-pane.coffee deleted file mode 100644 index dd93f2343..000000000 --- a/extensions/tree/tree-pane.coffee +++ /dev/null @@ -1,51 +0,0 @@ -$ = require 'jquery' -_ = require 'underscore' - -fs = require 'fs' - -Pane = require 'pane' - -module.exports = -class TreePane extends Pane - position: 'left' - tree: null - - constructor: (@tree) -> - super require "tree/tree.html" - - @render() - - $(document).on 'click', '#tree li', (event) => - $('#tree .active').removeClass 'active' - - el = $(event.currentTarget) - url = decodeURIComponent el.data 'url' - - if el.hasClass 'dir' - if el.hasClass 'open' - el.removeClass 'open' - el.find('ul').remove() - else - el.addClass 'open' - list = @createList @tree.urls url - el.append list - else - el.addClass 'active' - window.open url - - false - - render: -> - @el.find('.cwd').text _.last window.url.split '/' - fileList = @createList @tree.urls() - fileList.addClass 'files' - @el.find('.files').replaceWith fileList - - createList: (urls) -> - list = $('