@@ -115,7 +115,9 @@ static std::string ErrorCodeToString(int errorCode) {
115115 case RequestErrorType::UnsupportedSchemeError:
116116 return " unsupportedScheme" ;
117117 }
118- std::string message = " Could not find a string for errorCode: " + errorCode;
118+
119+ std::string message =
120+ " Could not find a string for errorCode: " + std::to_string (errorCode);
119121 throw std::invalid_argument (message);
120122}
121123
@@ -170,11 +172,12 @@ WebView::WebView(flutter::PluginRegistrar* registrar, int viewId,
170172 webview->HandleMethodCall (call, std::move (result));
171173 });
172174
175+ std::string url;
173176 auto initialUrl = params[flutter::EncodableValue (" initialUrl" )];
174177 if (std::holds_alternative<std::string>(initialUrl)) {
175- currentUrl_ = std::get<std::string>(initialUrl);
178+ url = std::get<std::string>(initialUrl);
176179 } else {
177- currentUrl_ = " about:blank" ;
180+ url = " about:blank" ;
178181 }
179182
180183 auto settings = params[flutter::EncodableValue (" settings" )];
@@ -207,7 +210,8 @@ WebView::WebView(flutter::PluginRegistrar* registrar, int viewId,
207210 });
208211 webViewInstance_->RegisterOnPageLoadedHandler (
209212 [this ](LWE::WebContainer* container, const std::string& url) {
210- LOG_DEBUG (" RegisterOnPageLoadedHandler(url: %s)\n " , url.c_str ());
213+ LOG_DEBUG (" RegisterOnPageLoadedHandler(url: %s)(title:%s)\n " ,
214+ url.c_str (), container->GetTitle ().c_str ());
211215 flutter::EncodableMap map;
212216 map.insert (
213217 std::make_pair<flutter::EncodableValue, flutter::EncodableValue>(
@@ -261,25 +265,29 @@ WebView::WebView(flutter::PluginRegistrar* registrar, int viewId,
261265 return true ;
262266 });
263267
264- webViewInstance_->LoadURL (currentUrl_ );
268+ webViewInstance_->LoadURL (url );
265269}
266270
267271void WebView::ApplySettings (flutter::EncodableMap settings) {
268272 for (auto const & [key, val] : settings) {
269273 if (std::holds_alternative<std::string>(key)) {
270274 std::string k = std::get<std::string>(key);
271275 if (" jsMode" == k) {
272- // TODO : Not implemented
276+ // NOTE : Not supported by LWE on Tizen.
273277 } else if (" hasNavigationDelegate" == k) {
274278 if (std::holds_alternative<bool >(val)) {
275279 hasNavigationDelegate_ = std::get<bool >(val);
276280 }
277281 } else if (" debuggingEnabled" == k) {
278- // TODO : Not implemented
282+ // NOTE : Not supported by LWE on Tizen.
279283 } else if (" gestureNavigationEnabled" == k) {
280- // TODO : Not implemented
284+ // NOTE : Not supported by LWE on Tizen.
281285 } else if (" userAgent" == k) {
282- // TODO: Not implemented
286+ if (std::holds_alternative<std::string>(val)) {
287+ auto settings = webViewInstance_->GetSettings ();
288+ settings.SetUserAgentString (std::get<std::string>(val));
289+ webViewInstance_->SetSettings (settings);
290+ }
283291 } else {
284292 throw std::invalid_argument (" Unknown WebView setting: " + k);
285293 }
@@ -739,14 +747,26 @@ void WebView::HandleMethodCall(
739747 const auto methodName = method_call.method_name ();
740748 const auto & arguments = *method_call.arguments ();
741749
742- LOG_DEBUG (" HandleMethodCall : %s \n " , methodName.c_str ());
750+ LOG_DEBUG (" WebView:: HandleMethodCall : %s \n " , methodName.c_str ());
743751
744752 if (methodName.compare (" loadUrl" ) == 0 ) {
745- currentUrl_ = ExtractStringFromMap (arguments, " url" );
746- webViewInstance_->LoadURL (GetCurrentUrl () );
753+ std::string url = ExtractStringFromMap (arguments, " url" );
754+ webViewInstance_->LoadURL (url );
747755 result->Success ();
748756 } else if (methodName.compare (" updateSettings" ) == 0 ) {
749- result->NotImplemented ();
757+ if (std::holds_alternative<flutter::EncodableMap>(arguments)) {
758+ auto settings = std::get<flutter::EncodableMap>(arguments);
759+ if (settings.size () > 0 ) {
760+ try {
761+ ApplySettings (settings);
762+ } catch (const std::invalid_argument& ex) {
763+ LOG_ERROR (" [Exception] %s\n " , ex.what ());
764+ result->Error (ex.what ());
765+ return ;
766+ }
767+ }
768+ }
769+ result->Success ();
750770 } else if (methodName.compare (" canGoBack" ) == 0 ) {
751771 result->Success (flutter::EncodableValue (webViewInstance_->CanGoBack ()));
752772 } else if (methodName.compare (" canGoForward" ) == 0 ) {
@@ -761,7 +781,7 @@ void WebView::HandleMethodCall(
761781 webViewInstance_->Reload ();
762782 result->Success ();
763783 } else if (methodName.compare (" currentUrl" ) == 0 ) {
764- result->Success (flutter::EncodableValue (GetCurrentUrl (). c_str ()));
784+ result->Success (flutter::EncodableValue (webViewInstance_-> GetURL ()));
765785 } else if (methodName.compare (" evaluateJavascript" ) == 0 ) {
766786 if (std::holds_alternative<std::string>(arguments)) {
767787 std::string jsString = std::get<std::string>(arguments);
@@ -802,11 +822,17 @@ void WebView::HandleMethodCall(
802822 webViewInstance_->ClearCache ();
803823 result->Success ();
804824 } else if (methodName.compare (" getTitle" ) == 0 ) {
805- result->NotImplemented ( );
825+ result->Success ( flutter::EncodableValue (webViewInstance_-> GetTitle ()) );
806826 } else if (methodName.compare (" scrollTo" ) == 0 ) {
807- result->NotImplemented ();
827+ int x = ExtractIntFromMap (arguments, " x" );
828+ int y = ExtractIntFromMap (arguments, " y" );
829+ webViewInstance_->ScrollTo (x, y);
830+ result->Success ();
808831 } else if (methodName.compare (" scrollBy" ) == 0 ) {
809- result->NotImplemented ();
832+ int x = ExtractIntFromMap (arguments, " x" );
833+ int y = ExtractIntFromMap (arguments, " y" );
834+ webViewInstance_->ScrollBy (x, y);
835+ result->Success ();
810836 } else if (methodName.compare (" getScrollX" ) == 0 ) {
811837 result->NotImplemented ();
812838 } else if (methodName.compare (" getScrollY" ) == 0 ) {
0 commit comments