diff --git a/addons/gdcef/demos/2D/CEF.gd b/addons/gdcef/demos/2D/CEF.gd index d3cdff6..97ea241 100644 --- a/addons/gdcef/demos/2D/CEF.gd +++ b/addons/gdcef/demos/2D/CEF.gd @@ -322,6 +322,7 @@ func _ready(): # {"log_file", resource_path / "debug.log"} # {log_severity", "warning"} # {"remote_debugging_port", 7777} + # {"remote_allow_origin", "*"} # {"exception_stack_size", 5} # {"enable_media_stream", false} # @@ -334,7 +335,9 @@ func _ready(): if !$CEF.initialize({ "incognito":true, "locale":"en-US", - "enable_media_stream": true + "enable_media_stream": true, + "remote_debugging_port": 7777, + "remote_allow_origin": "*" }): $Panel/VBox/HBox2/Info.set_text($CEF.get_error()) push_error($CEF.get_error()) diff --git a/addons/gdcef/doc/API.md b/addons/gdcef/doc/API.md index 105983c..d16a19c 100644 --- a/addons/gdcef/doc/API.md +++ b/addons/gdcef/doc/API.md @@ -38,25 +38,28 @@ Depending for `entry` concerning the `get_version_part`: Since Godot `_init` does not accept passing arguments, you have to use `initialize` function instead. You also have to pass a Godot dictionary to configurate the behavior for CEF. Default values are: -- `{"artifcats":CEF_ARTIFACTS_FOLDER}` Path where the build CEF artifcats are stored. They are +- `{"artifcats": CEF_ARTIFACTS_FOLDER}` Path where the build CEF artifcats are stored. They are needed to make CEF running and therefore your application. Fort this section, we will give the name `cef_folder_path` to the result. The default value is given during the compilation with the build.py script. You can specify either a local path or a global path or a Godot path (starting with `"res://"`). -- `{"exported_artifcats":application_real_path()}` Path where the build CEF artifcats are stored +- `{"exported_artifcats": application_real_path()}` Path where the build CEF artifcats are stored when the Godot application is exported. Artifcats are needed to make CEF running and therefore your application. It defines `cef_folder_path`. -- `{"incognito":false}` : In incognito mode cache directories not used and in-memory caches are +- `{"incognito": false}` : In incognito mode cache directories not used and in-memory caches are used instead and no data is persisted to disk. -- `{"cache_path":cef_folder_path / "cache"}` : Folder path where to store CEF caches. -- `{"root_cache_path":cef_folder_path / "cache"}` -- `{"browser_subprocess_path":cef_folder_path / SUBPROCESS_NAME }` : canonical path to the CEF +- `{"cache_path": cef_folder_path / "cache"}` : Folder path where to store CEF caches. +- `{"root_cache_path": cef_folder_path / "cache"}` +- `{"browser_subprocess_path": cef_folder_path / SUBPROCESS_NAME }` : canonical path to the CEF subprocess called during the `initialize()` function. The default name is determined during the compilation done with the build.py script. -- `{"log_file":cef_folder_path / "debug.log"}` : Where to store logs. -- `{log_severity":"warning"}` : Verbosity control of logs. Choose between `"verbose"`, `"info"`, +- `{"log_file": cef_folder_path / "debug.log"}` : Where to store logs. +- `{"log_severity": "warning"}` : Verbosity control of logs. Choose between `"verbose"`, `"info"`, `"warning"`, `"error"`, `"fatal"`. -- `{"remote_debugging_port":7777}` : the port for debbuging CEF. +- `{"remote_allow_origin": "*"}` : to allow debug connections from all origins. +- `{"remote_debugging_port":7777}` : the port for debbuging gdcef from a Chrome browser. + From Chrome URL, type: `http://localhost:7777` you will see list of link. Click on one and you will + see your page for debugging. See this [screenshot](pics/debug.png). - `{"exception_stack_size":5}` - `{"locale":"en-US"}` : Select your language. - `{"enable_media_stream", false}` : allow CEF to access to your camera and microphones. diff --git a/addons/gdcef/doc/architecture.md b/addons/gdcef/doc/architecture.md index bb15a24..312c861 100644 --- a/addons/gdcef/doc/architecture.md +++ b/addons/gdcef/doc/architecture.md @@ -12,7 +12,7 @@ been created to wrap the CEF C++ API to be usable from Godot scripts. Derived from Godot Nodes, it allows instances of these classes to be attached inside to the scene-graph as depicted by the following picture. -![CEFnode](scenegraph/cef.png) +![CEFnode](pics/cef.png) See this [document](https://docs.godotengine.org/en/stable/classes/class_node.html) diff --git a/addons/gdcef/doc/detailsdesign.md b/addons/gdcef/doc/detailsdesign.md index 156a6ee..ef8f2b5 100644 --- a/addons/gdcef/doc/detailsdesign.md +++ b/addons/gdcef/doc/detailsdesign.md @@ -289,7 +289,7 @@ and the entry function for the module. To use the native module inside Godot, ensure libraries are correctly loaded into your project. Then create a `GDCEF` node in the scene graph. -![CEFnode](scenegraph/cef.png) +![CEFnode](pics/cef.png) **Beware:** In Linux, you will have to write something like: ``` diff --git a/addons/gdcef/doc/installation.md b/addons/gdcef/doc/installation.md index 16f21f0..b854319 100644 --- a/addons/gdcef/doc/installation.md +++ b/addons/gdcef/doc/installation.md @@ -150,3 +150,15 @@ information): ``` $CEF.initialize({"artifacts": "res://cef_artifacts/", ... }) ``` + +## Debug gdcef + +In your gd script, when init CEF. Pass the following settings: + +``` +$CEF.initialize({"remote_debugging_port": 7777, "remote_allow_origin": "*", ... }) +``` + +Open a Chrome browser and type in the URL: `http://localhost:7777`. You will see something like this: + +![Debug](pics/debug.png) diff --git a/addons/gdcef/doc/scenegraph/cef.png b/addons/gdcef/doc/pics/cef.png similarity index 100% rename from addons/gdcef/doc/scenegraph/cef.png rename to addons/gdcef/doc/pics/cef.png diff --git a/addons/gdcef/doc/pics/debug.png b/addons/gdcef/doc/pics/debug.png new file mode 100644 index 0000000..758408f Binary files /dev/null and b/addons/gdcef/doc/pics/debug.png differ diff --git a/addons/gdcef/gdcef/src/gdcef.cpp b/addons/gdcef/gdcef/src/gdcef.cpp index 09ab2a3..573baff 100644 --- a/addons/gdcef/gdcef/src/gdcef.cpp +++ b/addons/gdcef/gdcef/src/gdcef.cpp @@ -163,6 +163,7 @@ bool GDCef::initialize(godot::Dictionary config) // because we cannot access to it, we have to configure CEF directly. configureCEF(cef_folder_path, m_cef_settings, m_window_info, config); m_enable_media_stream = getConfig(config, "enable_media_stream", false); + m_remote_allow_origin = getConfig(config, "remote_allow_origin", std::string{}); // This function should be called on the main application thread to // initialize the CEF browser process. A return value of true indicates @@ -334,8 +335,8 @@ static void configureCEF(fs::path const& folder, CefSettings& cef_settings, cef_settings.command_line_args_disabled = true; // Set to a value between 1024 and 65535 to enable remote debugging on the - // specified port. For example, if 8080 is specified the remote debugging - // URL will be http://localhost:8080. CEF can be remotely debugged from any + // specified port. For example, if 7777 is specified the remote debugging + // URL will be http://localhost:7777. CEF can be remotely debugged from any // CEF or Chrome browser window. Also configurable using the // "remote-debugging-port" command-line switch. cef_settings.remote_debugging_port = @@ -546,4 +547,12 @@ void GDCef::Impl::OnBeforeCommandLineProcessing(const CefString& ProcessType, GDCEF_DEBUG_VAL("Allow enable-media-stream"); command_line->AppendSwitch("enable-media-stream"); } + + // To be usable with cef_settings.remote_debugging_port. + // Set to "*". + if (!m_owner.m_remote_allow_origin.empty()) + { + command_line->AppendSwitchWithValue( + "remote-allow-origins", m_owner.m_remote_allow_origin.c_str()); + } } diff --git a/addons/gdcef/gdcef/src/gdcef.hpp b/addons/gdcef/gdcef/src/gdcef.hpp index b09b47c..b9a51e8 100644 --- a/addons/gdcef/gdcef/src/gdcef.hpp +++ b/addons/gdcef/gdcef/src/gdcef.hpp @@ -302,6 +302,8 @@ class GDCef : public godot::Node mutable std::stringstream m_error; //! \brief Allow accessing to camera and microphones bool m_enable_media_stream = false; + //! \brief To be usable with cef_settings.remote_debugging_port. + std::string m_remote_allow_origin; }; # if !defined(_WIN32)