[M120 Migration] Return visible entry title instead of last entry 07/317607/2 submit/tizen/20240912.160017
authorfr.fang <fr.fang@samsung.com>
Thu, 12 Sep 2024 14:33:18 +0000 (22:33 +0800)
committerBot Blink <blinkbot@samsung.com>
Thu, 12 Sep 2024 10:25:29 +0000 (10:25 +0000)
1.During navigation from one URL to another, Consider adding bookmark
for the new URL before loading is complete

The old URL's title is displayed as the new URL title is not set.
Modification to return as no title if visible entry title is not set.
Check for the main frame before requesting the title
2.Fix crash in GetTitle() call seen frequently in HbbTV OpApp testing.

References:
https://review.tizen.org/gerrit/#/c/294142

Change-Id: Iced04c6c79e62c6bfb19cb8aa03ff7e67ede936c
Signed-off-by: fr.fang <fr.fang@samsung.com>
content/browser/web_contents/web_contents_impl.cc
tizen_src/ewk/efl_integration/eweb_view.cc

index 12b3e4a0dc0332ecdc8cdd25999a1da37ecda870..910d9a5f41cc164efe1de92672eeaf313271c16f 100644 (file)
@@ -2293,10 +2293,20 @@ void WebContentsImpl::SetDisplayCutoutSafeArea(gfx::Insets insets) {
 #endif
 
 const std::u16string& WebContentsImpl::GetTitle() {
-  WebUI* our_web_ui =
-      GetRenderManager()->speculative_frame_host()
-          ? GetRenderManager()->speculative_frame_host()->web_ui()
-          : GetRenderManager()->current_frame_host()->web_ui();
+  WebUI* our_web_ui = nullptr;
+  if (GetRenderManager()) {
+    WebUI* navigating_web_ui = nullptr;
+    if (GetRenderManager()->speculative_frame_host())
+      navigating_web_ui =
+          GetRenderManager()->speculative_frame_host()->web_ui();
+    if (!navigating_web_ui) {
+      if (GetRenderManager()->current_frame_host())
+        our_web_ui = GetRenderManager()->current_frame_host()->web_ui();
+    } else {
+      our_web_ui = navigating_web_ui;
+    }
+  }
+
   if (our_web_ui) {
     // Don't override the title in view source mode.
     NavigationEntry* entry = GetController().GetVisibleEntry();
@@ -2309,6 +2319,18 @@ const std::u16string& WebContentsImpl::GetTitle() {
     }
   }
 
+#if BUILDFLAG(IS_EFL)
+  // The BrowserApp is expecting information only for the visible entry, instead
+  // of a title for last valid title of the URL. This would reflect while adding
+  // Bookmarks & other actions that require title of visible entry under
+  // proceses.
+  {
+    NavigationEntry* entry = GetController().GetVisibleEntry();
+    if (entry && entry->GetTitle().empty())
+      return std::u16string();
+  }
+#endif
+
   return GetNavigationEntryForTitle()->GetTitleForDisplay();
 }
 
index 7deb9892518600c12485704e9dfef8fc5ab06cb6..8bd2c981ef664bd6c81b82a34ba79e4504afb787 100644 (file)
@@ -2561,7 +2561,10 @@ double EWebView::GetProgressValue() {
 }
 
 const char* EWebView::GetTitle() {
-  title_ = base::UTF16ToUTF8(web_contents_->GetTitle());
+  if (web_contents_->GetPrimaryMainFrame())
+    title_ = base::UTF16ToUTF8(web_contents_->GetTitle());
+  else
+    title_.clear();
   return title_.c_str();
 }