1
1
2
+ #include " webview.h"
3
+
4
+ #include < Ecore_IMF_Evas.h>
5
+ #include < Ecore_Input_Evas.h>
2
6
#include < flutter/method_channel.h>
3
- #include < flutter/plugin_registrar.h>
4
- #include < flutter/standard_method_codec.h>
5
- #include < flutter/standard_message_codec.h>
6
7
#include < flutter_platform_view.h>
7
8
#include < flutter_texture_registrar.h>
8
- #include " webview_flutter_tizen_plugin.h"
9
- #include " webview.h"
10
9
11
10
#include < map>
12
11
#include < memory>
18
17
#include " lwe/PlatformIntegrationData.h"
19
18
#include " webview_factory.h"
20
19
21
- #include < Ecore_Input_Evas.h>
22
- #include < Ecore_IMF_Evas.h>
23
-
24
-
25
20
#define LWE_EXPORT
26
21
extern " C" size_t LWE_EXPORT createWebViewInstance (
27
22
unsigned x, unsigned y, unsigned width, unsigned height,
@@ -64,12 +59,12 @@ WebView::WebView(flutter::PluginRegistrar* registrar, int viewId,
64
59
FlutterTextureRegistrar* textureRegistrar, double width,
65
60
double height, const std::string initialUrl)
66
61
: PlatformView(registrar, viewId),
67
- tbmSurface_(nullptr ),
68
62
textureRegistrar_(textureRegistrar),
69
63
webViewInstance_(nullptr ),
70
64
currentUrl_(initialUrl),
71
65
width_(width),
72
- height_(height) {
66
+ height_(height),
67
+ tbmSurface_(nullptr ) {
73
68
SetTextureId (FlutterRegisterExternalTexture (textureRegistrar_));
74
69
InitWebView ();
75
70
auto channel =
@@ -473,7 +468,9 @@ void WebView::InitWebView() {
473
468
}
474
469
float scaleFactor = 1 ;
475
470
476
- webViewInstance_ = (LWE::WebContainer*)createWebViewInstance (0 ,0 ,width_, height_,scaleFactor, " SamsungOneUI" , " ko-KR" , " Asia/Seoul" ,[this ]() -> LWE::WebContainer::ExternalImageInfo {
471
+ webViewInstance_ = (LWE::WebContainer*)createWebViewInstance (
472
+ 0 , 0 , width_, height_, scaleFactor, " SamsungOneUI" , " ko-KR" , " Asia/Seoul" ,
473
+ [this ]() -> LWE::WebContainer::ExternalImageInfo {
477
474
LWE::WebContainer::ExternalImageInfo result;
478
475
tbmSurface_ = tbm_surface_create (width_, height_, TBM_FORMAT_ARGB8888);
479
476
tbm_surface_info_s tbmSurfaceInfo;
@@ -482,7 +479,8 @@ void WebView::InitWebView() {
482
479
result.imageAddress = (void *)tbmSurface_;
483
480
}
484
481
return result;
485
- }, [this ](LWE::WebContainer* c) {
482
+ },
483
+ [this ](LWE::WebContainer* c) {
486
484
FlutterMarkExternalTextureFrameAvailable (textureRegistrar_,
487
485
GetTextureId (), tbmSurface_);
488
486
tbm_surface_destroy (tbmSurface_);
@@ -528,7 +526,19 @@ void WebView::HandleMethodCall(
528
526
} else if (methodName.compare (" currentUrl" ) == 0 ) {
529
527
result->Success (flutter::EncodableValue (GetCurrentUrl ().c_str ()));
530
528
} else if (methodName.compare (" evaluateJavascript" ) == 0 ) {
531
- result->NotImplemented ();
529
+ if (std::holds_alternative<std::string>(arguments)) {
530
+ std::string jsString = std::get<std::string>(arguments);
531
+ webViewInstance_->EvaluateJavaScript (
532
+ jsString, [res = result.release ()](std::string value) {
533
+ LOG_DEBUG (" value: %s\n " , value.c_str ());
534
+ if (res) {
535
+ res->Success (flutter::EncodableValue (value));
536
+ delete res;
537
+ }
538
+ });
539
+ } else {
540
+ result->Error (" Invalid Arguments" , " Invalid Arguments" );
541
+ }
532
542
} else if (methodName.compare (" addJavascriptChannels" ) == 0 ) {
533
543
result->NotImplemented ();
534
544
} else if (methodName.compare (" removeJavascriptChannels" ) == 0 ) {
0 commit comments