X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Fdevel-api%2Fcontrols%2Fweb-view%2Fweb-view.h;h=8d33f3a9ea8389ba02977d7d639743d2c99dd88b;hp=71d05d3f54c9e0b6b6f74c31da0a0126b01af49b;hb=a76ab01e4bdaf91bbf3b2588e1a8c628a152bc6a;hpb=fbda0e1b3488d481e2e577ae1bef54db7604b68a diff --git a/dali-toolkit/devel-api/controls/web-view/web-view.h b/dali-toolkit/devel-api/controls/web-view/web-view.h index 71d05d3..8d33f3a 100644 --- a/dali-toolkit/devel-api/controls/web-view/web-view.h +++ b/dali-toolkit/devel-api/controls/web-view/web-view.h @@ -191,28 +191,37 @@ public: void GoBack(); /** - * @brief Evaluates JavaScript code represented as a string. - * - * @param[in] script The JavaScript code - */ + * @brief Evaluates JavaScript code represented as a string. + * + * @param[in] script The JavaScript code + */ void EvaluateJavaScript( const std::string& script ); /** - * @brief Adds a JavaScript interface. - * - * @param[in] exposedObjectName The name of exposed object - * @param[in] jsFunctionName The name of JavaScript function - * @param[in] callback The callback function - */ - void AddJavaScriptInterface( const std::string& exposedObjectName, const std::string& jsFunctionName, std::function< std::string(const std::string&) > callback ); - - /** - * @brief Removes a JavaScript interface. - * - * @param[in] exposedObjectName The name of exposed object - * @param[in] jsFunctionName The name of JavaScript function - */ - void RemoveJavascriptInterface( const std::string& exposedObjectName, const std::string& jsFunctionName ); + * @brief Inject a JavaScript object with a message handler into the WebView. + * + * @note The injected object will appear in the JavaScript context to be loaded next. + * + * Example: + * + * 1. Native + * + * webview.AddJavaScriptMessageHandler( "myObject", []( const std::string& message ) { + * printf( "Received a message from JS: %s", message.c_str() ); + * }); + * + * // Start WebView by loading URL + * webview.LoadUrl( url ); + * + * 2. JavaScript + * + * myObject.postMessage( "Hello World!" ); // "Received a message from JS: Hello World!" + * + * + * @param[in] exposedObjectName The name of exposed object + * @param[in] handler The callback function + */ + void AddJavaScriptMessageHandler( const std::string& exposedObjectName, std::function< void( const std::string& ) > handler ); /** * @brief Clears the history of Web.