[M108 Migration][Callback] Bring up ewk callbacks which are related with page loading 70/286470/4
authorv-saha <v.saha@samsung.com>
Fri, 6 Jan 2023 10:53:35 +0000 (16:23 +0530)
committerDae-Hyun Ko <dhyuna.ko@samsung.com>
Tue, 10 Jan 2023 02:03:46 +0000 (02:03 +0000)
Below functions were removed from upstream.
WebContentsObserver::DidStartProvisionalLoadForFrame
WebContentsObserver::DidCommitProvisionalLoadForFrame
WebContentsObserver::DidFailProvisionalLoad
WebContentsObserver::DidNavigateMainFrame
WebContentsObserver::DidNavigateAnyFrame

So this patch implements callbacks for page loading using newly added
fucntions:
WebContentsObserver::DidStartNavigation
WebContentsObserver::DidRedirectNavigation
WebContentsObserver::DidFinishNavigation

Reference:
https://review.tizen.org/gerrit/#/c/272795

Change-Id: Ib998156f39155b6e334dedeec50249613fd9711d
Signed-off-by: v-saha <v.saha@samsung.com>
tizen_src/ewk/efl_integration/eweb_view.cc
tizen_src/ewk/efl_integration/eweb_view.h
tizen_src/ewk/efl_integration/web_contents_delegate_efl.cc
tizen_src/ewk/efl_integration/web_contents_delegate_efl.h

index 279642c..246670d 100644 (file)
@@ -925,11 +925,7 @@ void EWebView::LoadData(const char* data,
 
 void EWebView::InvokeLoadError(const GURL& url,
                                int error_code,
-                               const std::string& error_description,
-                               bool is_main_frame) {
-  if (!is_main_frame)
-    return;
-
+                               const std::string& error_description) {
   std::unique_ptr<_Ewk_Error> err(
       new _Ewk_Error(error_code, url.possibly_invalid_spec().c_str(),
                      error_description.c_str()));
index 92bef08..e8a014f 100644 (file)
@@ -259,8 +259,7 @@ class EWebView {
 
   void InvokeLoadError(const GURL& url,
                        int error_code,
-                       const std::string& error_description,
-                       bool is_main_frame);
+                       const std::string& error_description);
 
   void SetViewAuthCallback(Ewk_View_Authentication_Callback callback,
                            void* user_data);
index 72bc9a5..d86cec1 100644 (file)
@@ -80,6 +80,10 @@ void WritePdfDataToFile(printing::MetafileSkia* metafile,
   delete metafile;
 }
 
+static bool IsMainFrame(RenderFrameHost* render_frame_host) {
+  return !render_frame_host->GetParent();
+}
+
 #if BUILDFLAG(IS_TIZEN) && defined(TIZEN_MULTIMEDIA_SUPPORT)
 static const MediaStreamDevice* GetRequestedVideoDevice(
     const std::string& device_id) {
@@ -191,13 +195,6 @@ void WebContentsDelegateEfl::LoadProgressChanged(double progress) {
   web_view_->SmartCallback<EWebViewCallbacks::LoadProgress>().call(&progress);
 }
 
-void WebContentsDelegateEfl::DidStartNavigation(
-    NavigationHandle* navigation_handle) {
-  if (!navigation_handle->IsInMainFrame())
-    return;
-  web_view_->SmartCallback<EWebViewCallbacks::ProvisionalLoadStarted>().call();
-}
-
 void WebContentsDelegateEfl::AddNewContents(
     WebContents* source,
     std::unique_ptr<WebContents> new_contents,
@@ -357,48 +354,45 @@ void WebContentsDelegateEfl::OnAuthRequired(const std::string& realm,
   web_view_->InvokeAuthCallback(login_delegate, url, realm);
 }
 
-void WebContentsDelegateEfl::DidStartProvisionalLoadForFrame(
-    RenderFrameHost* render_frame_host,
-    const GURL& validated_url,
-    bool is_error_page,
-    bool is_iframe_srcdoc) {
+void WebContentsDelegateEfl::DidStartNavigation(
+    NavigationHandle* navigation_handle) {
+  if (!navigation_handle->IsInMainFrame())
+    return;
   web_view_->SmartCallback<EWebViewCallbacks::ProvisionalLoadStarted>().call();
 }
 
-void WebContentsDelegateEfl::DidCommitProvisionalLoadForFrame(
-    RenderFrameHost* render_frame_host,
-    const GURL& url,
-    ui::PageTransition transition_type) {
-  web_view_->SmartCallback<EWebViewCallbacks::LoadCommitted>().call();
+void WebContentsDelegateEfl::DidRedirectNavigation(
+    NavigationHandle* navigation_handle) {
+  if (!navigation_handle->IsInMainFrame())
+    return;
+  web_view_->SmartCallback<EWebViewCallbacks::ProvisionalLoadRedirect>().call();
 }
 
-void WebContentsDelegateEfl::DidNavigateMainFrame(
-    const LoadCommittedDetails& details) {
-  // The condition checks whether the main frame navigated to a different page,
-  // not scrolled to a fragment inside the current page.
-  if (details.is_navigation_to_different_page())
-    web_view_->SmartCallback<EWebViewCallbacks::LoadStarted>().call();
-}
+void WebContentsDelegateEfl::DidFinishNavigation(
+    NavigationHandle* navigation_handle) {
+  if (!navigation_handle->HasCommitted())
+    return;
 
-void WebContentsDelegateEfl::DocumentOnLoadCompletedInMainFrame() {
-  web_view_->SmartCallback<EWebViewCallbacks::LoadFinished>().call();
-}
+  if (navigation_handle->IsInMainFrame()) {
+    web_view_->SmartCallback<EWebViewCallbacks::LoadCommitted>().call();
 
-#if !defined(EWK_BRINGUP)  // FIXME: m94 bringup
-void WebContentsDelegateEfl::DidNavigateAnyFrame(
-    RenderFrameHost* render_frame_host,
-    const LoadCommittedDetails& details,
-    const FrameNavigateParams& params) {
-  web_view_->SmartCallback<EWebViewCallbacks::ProvisionalLoadRedirect>().call();
-  static_cast<BrowserContextEfl*>(web_contents_.GetBrowserContext())
-      ->AddVisitedURLs(params.redirects);
+    if (!navigation_handle->IsSameDocument() &&
+        !navigation_handle->IsErrorPage())
+      web_view_->SmartCallback<EWebViewCallbacks::LoadStarted>().call();
+  } else if (!navigation_handle->HasSubframeNavigationEntryCommitted()) {
+    return;
+  }
+
+  if (navigation_handle->ShouldUpdateHistory())
+    static_cast<BrowserContextEfl*>(web_contents_.GetBrowserContext())
+        ->AddVisitedURLs(navigation_handle->GetRedirectChain());
 }
-#endif
 
 void WebContentsDelegateEfl::DidFinishLoad(RenderFrameHost* render_frame_host,
                                            const GURL& validated_url) {
-  if (render_frame_host->GetParent())
+  if (!IsMainFrame(render_frame_host))
     return;
+  web_view_->SmartCallback<EWebViewCallbacks::LoadFinished>().call();
 
   NavigationEntry* entry = web_contents().GetController().GetVisibleEntry();
   if (!entry)
@@ -428,6 +422,15 @@ void WebContentsDelegateEfl::DidFinishLoad(RenderFrameHost* render_frame_host,
   web_contents_.Focus();
 }
 
+void WebContentsDelegateEfl::DidFailLoad(RenderFrameHost* render_frame_host,
+                                         const GURL& validated_url,
+                                         int error_code) {
+  if (!IsMainFrame(render_frame_host))
+    return;
+
+  web_view_->InvokeLoadError(validated_url, error_code, std::string());
+}
+
 void WebContentsDelegateEfl::DidUpdateFaviconURL(
     RenderFrameHost* render_frame_host,
     const std::vector<blink::mojom::FaviconURLPtr>& candidates) {
@@ -609,23 +612,6 @@ bool WebContentsDelegateEfl::OnMessageReceived(
   return handled;
 }
 
-void WebContentsDelegateEfl::DidFailProvisionalLoad(
-    RenderFrameHost* render_frame_host,
-    const GURL& validated_url,
-    int error_code,
-    const std::u16string& error_description,
-    bool /*was_ignored_by_handler*/) {
-  DidFailLoad(render_frame_host, validated_url, error_code);
-}
-
-void WebContentsDelegateEfl::DidFailLoad(RenderFrameHost* render_frame_host,
-                                         const GURL& validated_url,
-                                         int error_code) {
-  bool is_main_frame = !render_frame_host->GetParent();
-  web_view_->InvokeLoadError(validated_url, error_code, std::string(),
-                             is_main_frame);
-}
-
 bool WebContentsDelegateEfl::Send(IPC::Message* message) {
   if (!web_contents_.GetRenderViewHost()) {
     delete message;
@@ -790,8 +776,7 @@ bool WebContentsDelegateEfl::PreHandleGestureEvent(
   return false;
 }
 
-void WebContentsDelegateEfl::TitleWasSet(NavigationEntry* entry,
-                                         bool /*explicit_set*/) {
+void WebContentsDelegateEfl::TitleWasSet(NavigationEntry* entry) {
   if (entry)
     web_view_->GetBackForwardList()->UpdateItemWithEntry(entry);
 }
index 37878c3..012c140 100644 (file)
@@ -156,52 +156,34 @@ class WebContentsDelegateEfl : public WebContentsDelegate,
   bool PreHandleGestureEvent(WebContents* source,
                              const blink::WebGestureEvent& event) override;
 
-  // IPC::Sender-----------------------------------------------------------
-  bool Send(IPC::Message* message) override;
-
   // WebContentsObserver---------------------------------------------------
-  void DidFailLoad(RenderFrameHost* render_frame_host,
-                   const GURL& validated_url,
-                   int error_code) override;
-
-  // EWK_BRINGUP: These APIs are removed in upstream.
-  void TitleWasSet(NavigationEntry* entry, bool explicit_set);
   void DidStartNavigation(NavigationHandle* navigation_handle) override;
+
+  void DidRedirectNavigation(NavigationHandle* navigation_handle) override;
+
+  void DidFinishNavigation(NavigationHandle* navigation_handle) override;
+
   void LoadProgressChanged(double progress) override;
   void DidFinishLoad(RenderFrameHost* render_frame_host,
                      const GURL& validated_url) override;
 
-  void DidStartProvisionalLoadForFrame(RenderFrameHost* render_frame_host,
-                                       const GURL& validated_url,
-                                       bool is_error_page,
-                                       bool is_iframe_srcdoc);
+  void DidFailLoad(RenderFrameHost* render_frame_host,
+                   const GURL& validated_url,
+                   int error_code) override;
 
   void DidUpdateFaviconURL(
       RenderFrameHost* render_frame_host,
       const std::vector<blink::mojom::FaviconURLPtr>& candidates) override;
 
-  void DidCommitProvisionalLoadForFrame(RenderFrameHost* render_frame_host,
-                                        const GURL& url,
-                                        ui::PageTransition transition_type);
-
-  void DidNavigateMainFrame(const LoadCommittedDetails& details);
-  void DocumentOnLoadCompletedInMainFrame();
-#if !defined(EWK_BRINGUP)  // FIXME: m94 bringup
-  void DidNavigateAnyFrame(RenderFrameHost* render_frame_host,
-                           const LoadCommittedDetails& details,
-                           const FrameNavigateParams& params);
-#endif
-  void DidFailProvisionalLoad(RenderFrameHost* render_frame_host,
-                              const GURL& validated_url,
-                              int error_code,
-                              const std::u16string& error_description,
-                              bool was_ignored_by_handler);
-  // EWK_BRINGUP end.
+  void TitleWasSet(content::NavigationEntry* entry) override;
 
   void OnAuthRequired(const std::string& realm,
                       const GURL& url,
                       LoginDelegateEfl* login_delegate);
 
+  // IPC::Sender-----------------------------------------------------------
+  bool Send(IPC::Message* message) override;
+
   void DidDownloadFavicon(bool success,
                           const GURL& icon_url,
                           const SkBitmap& bitmap);