Fix for crash when new window is opened from ubrowser UI 85/266685/2
authorChandan Padhi <c.padhi@samsung.com>
Wed, 17 Nov 2021 07:04:45 +0000 (12:34 +0530)
committerDae-Hyun Ko <dhyuna.ko@samsung.com>
Fri, 19 Nov 2021 00:49:22 +0000 (00:49 +0000)
Currently, |create_new_window_web_contents_cb_| is static and
therefore can be run multiple times during new window launch.
However, it being of type OnceCallback results in crash when
run more than once. This commit changes this callback to type
RepeatingCallback to fix the crash issue.

Change-Id: Ifa4e07a1df5a974de98bf81d18944c00ee7227e1
Signed-off-by: Chandan Padhi <c.padhi@samsung.com>
tizen_src/chromium_impl/content/browser/web_contents/web_contents_impl_efl.cc
tizen_src/chromium_impl/content/public/browser/web_contents_efl_delegate.h
tizen_src/ewk/efl_integration/eweb_view.cc

index 2399fff6fecc649bf395d4021898bf67887ba574..2a4e06f674232bbc6e4bd0ce07c1fb6b7619d9e0 100644 (file)
@@ -218,9 +218,10 @@ void WebContentsImplEfl::HandleNewWindowRequest(
     bool create) {
   if (create) {
     scoped_refptr<SessionStorageNamespace> ssn = session_storage_namespace;
-    WebContentsEflDelegate::WebContentsCreateCallback callback = base::BindOnce(
-        &WebContentsImplEfl::HandleNewWebContentsCreate, base::Unretained(this),
-        render_process_id, route_id, main_frame_route_id, params, ssn);
+    WebContentsEflDelegate::WebContentsCreateCallback callback =
+        base::BindRepeating(&WebContentsImplEfl::HandleNewWebContentsCreate,
+                            base::Unretained(this), render_process_id, route_id,
+                            main_frame_route_id, params, ssn);
     if (efl_delegate_ && efl_delegate_->WebContentsCreateAsync(callback))
       return;
 
index fb0a4cf35f952b0405cfe03f8fc77ed8c86d5bee..148b0567327579b3b0e37025bac752928d4bde8e 100644 (file)
@@ -23,7 +23,8 @@ class CONTENT_EXPORT WebContentsEflDelegate {
   // intended to pass platform specific data to WebContents constructor. It
   // returns a pointer to new WebContents created by the function. The caller
   // is expected to take ownership of the returned object.
-  typedef base::OnceCallback<WebContents*(void*)> WebContentsCreateCallback;
+  typedef base::RepeatingCallback<WebContents*(void*)>
+      WebContentsCreateCallback;
 
   // Callback allowing the embedder to resume or block new window request. The
   // argument specifies if the request should be allowed (true) or blocked
index e0c10370f73b2b8927664e70da669188880ef660..d19ceba932ebee3460e5cb5670111891f47dc43c 100644 (file)
@@ -141,7 +141,7 @@ class WebViewAsyncRequestHitTestDataUserCallback
 int EWebView::find_request_id_counter_ = 0;
 content::WebContentsEflDelegate::WebContentsCreateCallback
     EWebView::create_new_window_web_contents_cb_ =
-        base::BindOnce(&NullCreateWebContents);
+        base::BindRepeating(&NullCreateWebContents);
 
 EWebView* EWebView::FromEvasObject(Evas_Object* eo) {
   return WebViewDelegateEwk::GetInstance().GetWebViewFromEvasObject(eo);
@@ -306,10 +306,11 @@ void EWebView::SetFocus(Eina_Bool focus) {
 
 void EWebView::CreateNewWindow(
     content::WebContentsEflDelegate::WebContentsCreateCallback cb) {
-  create_new_window_web_contents_cb_ = std::move(cb);
+  create_new_window_web_contents_cb_ = cb;
   Evas_Object* new_object = NULL;
   SmartCallback<EWebViewCallbacks::CreateNewWindow>().call(&new_object);
-  create_new_window_web_contents_cb_ = base::BindOnce(&NullCreateWebContents);
+  create_new_window_web_contents_cb_ =
+      base::BindRepeating(&NullCreateWebContents);
   DCHECK(new_object);
 }
 
@@ -2182,8 +2183,7 @@ void EWebView::HandleRendererProcessCrash() {
 }
 
 void EWebView::InitializeContent() {
-  WebContents* new_contents =
-      std::move(create_new_window_web_contents_cb_).Run(this);
+  WebContents* new_contents = create_new_window_web_contents_cb_.Run(this);
   if (!new_contents) {
     WebContents::CreateParams params(context_->browser_context());
     web_contents_.reset(