[M120 Migration] Introduces network loading API 76/308476/3
authorjiangyuwei <yuwei.jiang@samsung.com>
Tue, 26 Mar 2024 08:04:31 +0000 (16:04 +0800)
committerBot Blink <blinkbot@samsung.com>
Wed, 27 Mar 2024 06:01:02 +0000 (06:01 +0000)
1. ewk_view_resume_network_loading
2. ewk_view_suspend_network_loading
3. Fix send mojo call issue on window.open case

The api called when webbrowser launched.

Reference:
 - https://review.tizen.org/gerrit/291318/
 - https://review.tizen.org/gerrit/297667/

Change-Id: I474c919975efbe0301d82acd1ce73cca9a3c797c
Signed-off-by: jiangyuwei <yuwei.jiang@samsung.com>
16 files changed:
content/browser/renderer_host/render_widget_host_impl.cc
content/browser/renderer_host/render_widget_host_impl.h
third_party/blink/public/mojom/widget/platform_widget.mojom
third_party/blink/public/web/web_view.h
third_party/blink/renderer/core/exported/web_view_impl.cc
third_party/blink/renderer/core/exported/web_view_impl.h
third_party/blink/renderer/core/frame/web_frame_widget_impl.cc
third_party/blink/renderer/core/frame/web_frame_widget_impl.h
third_party/blink/renderer/core/page/page.cc
third_party/blink/renderer/core/page/page.h
third_party/blink/renderer/platform/widget/widget_base.cc
third_party/blink/renderer/platform/widget/widget_base.h
tizen_src/ewk/efl_integration/eweb_view.cc
tizen_src/ewk/efl_integration/eweb_view.h
tizen_src/ewk/efl_integration/public/ewk_view.cc
tizen_src/ewk/efl_integration/public/ewk_view_product.h

index 43ed9e9..474dd2d 100644 (file)
@@ -832,6 +832,20 @@ void RenderWidgetHostImpl::Init() {
   // run them here after we clear it.
   SendScreenRects();
   SynchronizeVisualProperties();
+#if BUILDFLAG(IS_TIZEN_TV)
+  if (pending_suspend_network_loading_closure_)
+    std::move(pending_suspend_network_loading_closure_).Run();
+
+  if (pending_resume_network_loading_closure_)
+    std::move(pending_resume_network_loading_closure_).Run();
+
+  if (pending_set_active_closure_)
+    std::move(pending_set_active_closure_).Run();
+
+  if (pending_set_page_focus_closure_)
+    std::move(pending_set_page_focus_closure_).Run();
+#endif
+
   // Show/Hide state is not given to the renderer while we are
   // `waiting_for_init_`, but Init() signals that the renderer is ready to
   // receive them. This call will inform the renderer that the widget is shown.
@@ -931,6 +945,10 @@ void RenderWidgetHostImpl::WasShown(
 
   DCHECK(!pending_show_params_);
   if (!waiting_for_init_) {
+    if (!blink_widget_) {
+      LOG(ERROR) << "Bind WidgetInterfaces still not finish";
+      return;
+    }
     blink_widget_->WasShown(view_->is_evicted(),
                             std::move(record_tab_switch_time_request));
   } else {
@@ -1138,8 +1156,60 @@ void RenderWidgetHostImpl::ResetLastInteractedElements() {
 void RenderWidgetHostImpl::SetFloatVideoWindowState(bool enabled) {
   blink_widget_->SetFloatVideoWindowState(enabled);
 }
-#endif
-#endif
+
+void RenderWidgetHostImpl::SuspendNetworkLoading() {
+  if (!waiting_for_init_) {
+    if (!blink_widget_) {
+      LOG(ERROR) << "Bind WidgetInterfaces still not finish";
+      return;
+    }
+    blink_widget_->SuspendNetworkLoading();
+
+    if (pending_suspend_network_loading_closure_)
+      pending_suspend_network_loading_closure_.Reset();
+  } else {
+    LOG(INFO) << "set pending SuspendNetworkLoading";
+    pending_suspend_network_loading_closure_ =
+        base::BindOnce(&RenderWidgetHostImpl::RunPendingSuspendNetworkLoading,
+                       base::Unretained(this));
+  }
+}
+
+void RenderWidgetHostImpl::RunPendingSuspendNetworkLoading() {
+  if (!blink_widget_) {
+    LOG(ERROR) << "Bind WidgetInterfaces still not finish";
+    return;
+  }
+  blink_widget_->SuspendNetworkLoading();
+}
+
+void RenderWidgetHostImpl::ResumeNetworkLoading() {
+  if (!waiting_for_init_) {
+    if (!blink_widget_) {
+      LOG(ERROR) << "Bind WidgetInterfaces still not finish";
+      return;
+    }
+    blink_widget_->ResumeNetworkLoading();
+
+    if (pending_resume_network_loading_closure_)
+      pending_resume_network_loading_closure_.Reset();
+  } else {
+    LOG(INFO) << "set pending ResumeNetworkLoading";
+    pending_resume_network_loading_closure_ =
+        base::BindOnce(&RenderWidgetHostImpl::RunPendingResumeNetworkLoading,
+                       base::Unretained(this));
+  }
+}
+
+void RenderWidgetHostImpl::RunPendingResumeNetworkLoading() {
+  if (!blink_widget_) {
+    LOG(ERROR) << "Bind WidgetInterfaces still not finish";
+    return;
+  }
+  blink_widget_->ResumeNetworkLoading();
+}
+#endif  // IS_TIZEN_TV
+#endif  // IS_EFL
 
 blink::VisualProperties RenderWidgetHostImpl::GetInitialVisualProperties() {
   blink::VisualProperties initial_props = GetVisualProperties();
@@ -1511,6 +1581,17 @@ void RenderWidgetHostImpl::FlushForTesting() {
   }
 }
 
+void RenderWidgetHostImpl::SetFocusInternal(bool focused) {
+  blink::mojom::FocusState focus_state =
+      blink::mojom::FocusState::kNotFocusedAndNotActive;
+  if (focused)
+    focus_state = blink::mojom::FocusState::kFocused;
+  else if (is_active_)
+    focus_state = blink::mojom::FocusState::kNotFocusedAndActive;
+
+  GetWidgetInputHandler()->SetFocus(focus_state);
+}
+
 void RenderWidgetHostImpl::SetPageFocus(bool focused) {
   OPTIONAL_TRACE_EVENT1("content", "RenderWidgetHostImpl::SetPageFocus",
                         "is_focused", focused);
@@ -1545,15 +1626,22 @@ void RenderWidgetHostImpl::SetPageFocus(bool focused) {
     LockKeyboard();
   }
 
-  blink::mojom::FocusState focus_state =
-      blink::mojom::FocusState::kNotFocusedAndNotActive;
-  if (focused) {
-    focus_state = blink::mojom::FocusState::kFocused;
-  } else if (is_active_) {
-    focus_state = blink::mojom::FocusState::kNotFocusedAndActive;
-  }
+#if BUILDFLAG(IS_TIZEN_TV)
+  if (!waiting_for_init_) {
+    SetFocusInternal(focused);
 
-  GetWidgetInputHandler()->SetFocus(focus_state);
+    if (pending_set_page_focus_closure_)
+      pending_set_page_focus_closure_.Reset();
+
+  } else {
+    LOG(INFO) << "set Pending SetPageFocus";
+    pending_set_page_focus_closure_ =
+        base::BindOnce(&RenderWidgetHostImpl::RunPendingSetPageFocus,
+                       base::Unretained(this), focused);
+  }
+#else
+  SetFocusInternal(focused);
+#endif
 
   // Also send page-level focus state to other SiteInstances involved in
   // rendering the current FrameTree, if this widget is for a main frame.
@@ -1567,6 +1655,12 @@ void RenderWidgetHostImpl::SetPageFocus(bool focused) {
   }
 }
 
+#if BUILDFLAG(IS_TIZEN_TV)
+void RenderWidgetHostImpl::RunPendingSetPageFocus(bool focused) {
+  SetFocusInternal(focused);
+}
+#endif
+
 void RenderWidgetHostImpl::LostCapture() {
   if (auto* touch_emulator = GetExistingTouchEmulator()) {
     touch_emulator->CancelTouch();
@@ -1575,7 +1669,31 @@ void RenderWidgetHostImpl::LostCapture() {
   GetWidgetInputHandler()->MouseCaptureLost();
 }
 
+#if BUILDFLAG(IS_TIZEN_TV)
+void RenderWidgetHostImpl::RunPendingSetActive(bool active) {
+  SetActiveInternal(active);
+}
+#endif
+
 void RenderWidgetHostImpl::SetActive(bool active) {
+#if BUILDFLAG(IS_TIZEN_TV)
+  if (!waiting_for_init_) {
+    SetActiveInternal(active);
+
+    if (pending_set_active_closure_)
+      pending_set_active_closure_.Reset();
+  } else {
+    LOG(INFO) << "set pending setActive";
+    pending_set_active_closure_ =
+        base::BindOnce(&RenderWidgetHostImpl::RunPendingSetActive,
+                       base::Unretained(this), active);
+  }
+#else
+  SetActiveInternal(active);
+#endif
+}
+
+void RenderWidgetHostImpl::SetActiveInternal(bool active) {
   is_active_ = active;
   if (blink_frame_widget_) {
     blink_frame_widget_->SetActive(active);
index d895491..d9abcd9 100644 (file)
@@ -482,8 +482,10 @@ class CONTENT_EXPORT RenderWidgetHostImpl
   void ResetLastInteractedElements();
 #if BUILDFLAG(IS_TIZEN_TV)
   void SetFloatVideoWindowState(bool enabled);
-#endif
-#endif
+  void SuspendNetworkLoading();
+  void ResumeNetworkLoading();
+#endif  // IS_TIZEN_TV
+#endif  // IS_EFL
 
 #if BUILDFLAG(IS_TIZEN)
   void PauseScheduledTasks();
@@ -518,6 +520,8 @@ class CONTENT_EXPORT RenderWidgetHostImpl
   // update. Users other than WebContents and RenderWidgetHost should use
   // Focus()/Blur().
   void SetPageFocus(bool focused);
+  void SetFocusInternal(bool focused);
+  void SetActiveInternal(bool active);
 
   // Returns true if the RenderWidgetHost thinks it is active. This
   // is different than `is_focused` but must always be true if `is_focused`
@@ -1239,6 +1243,20 @@ class CONTENT_EXPORT RenderWidgetHostImpl
   void AddPendingUserActivation(const blink::WebInputEvent& event);
   void ClearPendingUserActivation();
 
+#if BUILDFLAG(IS_TIZEN_TV)
+  // Calls the pending blink::mojom::Widget::SuspendNetworkLoading.
+  void RunPendingSuspendNetworkLoading();
+
+  // Calls the pending blink::mojom::Widget::ResumeNetworkLoading.
+  void RunPendingResumeNetworkLoading();
+
+  // Calls the pending blink::mojom::FrameWidget::setActive.
+  void RunPendingSetActive(bool active);
+
+  // Calls the pending blink::mojom::WidgetInputHandler::SetPageFocus.
+  void RunPendingSetPageFocus(bool focused);
+#endif
+
   // Dispatch any buffered FrameSink requests from the renderer if the widget
   // has a view and is the owner for the FrameSinkId assigned to it.
   void MaybeDispatchBufferedFrameSinkRequest();
@@ -1540,6 +1558,13 @@ class CONTENT_EXPORT RenderWidgetHostImpl
 
   InputRouterImpl::RequestMouseLockCallback request_mouse_callback_;
 
+#if BUILDFLAG(IS_TIZEN_TV)
+  base::OnceClosure pending_suspend_network_loading_closure_;
+  base::OnceClosure pending_resume_network_loading_closure_;
+  base::OnceClosure pending_set_active_closure_;
+  base::OnceClosure pending_set_page_focus_closure_;
+#endif
+
   // Parameters to pass to blink::mojom::Widget::WasShown after
   // `waiting_for_init_` becomes true. These are stored in a struct instead of
   // storing a callback so that they can be updated if
index 72a92f1..0f8367e 100644 (file)
@@ -179,6 +179,12 @@ interface Widget {
   [EnableIf=is_tizen_tv]
   SetFloatVideoWindowState(bool enabled);
 
+  [EnableIf=is_tizen_tv]
+  SuspendNetworkLoading();
+
+  [EnableIf=is_tizen_tv]
+  ResumeNetworkLoading();
+
   // Informs the widget that it was hidden. This allows it to reduce its
   // resource utilization, and will cancel any pending
   // RecordContentToVisibleTimeRequest that was set with WasShown or
index f637d7f..e12739b 100644 (file)
@@ -533,6 +533,14 @@ class BLINK_EXPORT WebView {
 
   // Returns the selection rect encompassing text and images.
   virtual gfx::Rect CurrentSelectionRect() const = 0;
+
+#if BUILDFLAG(IS_TIZEN_TV)
+  // Suspends loaders for the main frame and all sub-frames.
+  virtual void SuspendNetworkLoading() = 0;
+
+  // Resumes perviously suspended frame loaders.
+  virtual void ResumeNetworkLoading() = 0;
+#endif  // IS_TIZEN_TV
 #endif
 
 #if BUILDFLAG(IS_TIZEN_TV)
index b476c64..3045cba 100644 (file)
@@ -4579,7 +4579,23 @@ void WebViewImpl::SetScrollOffset(float x, float y) {
   if (auto* focused_frame = FocusedFrame())
     focused_frame->SetScrollOffset(gfx::PointF(x, y));
 }
-#endif
+
+#if BUILDFLAG(IS_TIZEN_TV)
+void WebViewImpl::SuspendNetworkLoading() {
+  if (!GetPage())
+    return;
+
+  GetPage()->SetDefersLoading(true);
+}
+
+void WebViewImpl::ResumeNetworkLoading() {
+  if (!GetPage())
+    return;
+
+  GetPage()->SetDefersLoading(false);
+}
+#endif  // IS_TIZEN_TV
+#endif  // IS_EFL
 
 #if defined(TIZEN_VIDEO_HOLE)
 bool WebViewImpl::IsVideoHoleForRender() const {
index af2b529..195da37 100644 (file)
@@ -253,7 +253,12 @@ class CORE_EXPORT WebViewImpl final : public WebView,
   void ScrollFocusedNodeIntoView() override;
   void SetScrollOffset(float x, float y) override;
   gfx::Rect CurrentSelectionRect() const override;
-#endif
+
+#if BUILDFLAG(IS_TIZEN_TV)
+  void SuspendNetworkLoading() override;
+  void ResumeNetworkLoading() override;
+#endif  // IS_TIZEN_TV
+#endif  // IS_EFL
 
   // Functions to add and remove observers for this object.
   void AddObserver(WebViewObserver* observer);
index 49630e7..beb29d0 100644 (file)
@@ -4727,8 +4727,16 @@ bool WebFrameWidgetImpl::RequestMainFrameScrollbarVisible(bool& visible) {
 void WebFrameWidgetImpl::SetFloatVideoWindowState(bool enabled) {
   View()->SetFloatVideoWindowState(enabled);
 }
-#endif
-#endif
+
+void WebFrameWidgetImpl::SuspendNetworkLoading() {
+  View()->SuspendNetworkLoading();
+}
+
+void WebFrameWidgetImpl::ResumeNetworkLoading() {
+  View()->ResumeNetworkLoading();
+}
+#endif  // IS_TIZEN_TV
+#endif  // IS_EFL
 
 #if BUILDFLAG(IS_TIZEN)
 void WebFrameWidgetImpl::SetMaxRefreshRate(uint32_t max_refresh_rate) {
index 2f28251..c327506 100644 (file)
@@ -803,6 +803,8 @@ class CORE_EXPORT WebFrameWidgetImpl
   gfx::Rect RequestSelectionRect() override;
 #if BUILDFLAG(IS_TIZEN_TV)
   void SetFloatVideoWindowState(bool enabled) override;
+  void SuspendNetworkLoading() override;
+  void ResumeNetworkLoading() override;
 #endif
 #endif
 
index ba4259a..7828edb 100644 (file)
@@ -1216,6 +1216,22 @@ void Page::UpdateLifecycle(LocalFrame& root,
 void Page::SetLongPollingGlobalTimeout(uint64_t timeout) {
   long_polling_global_timeout_ = timeout;
 }
+
+void Page::SetDefersLoading(bool defers) {
+  LOG(INFO) << "defers : " << defers
+            << " defers_loading_ : " << defers_loading_;
+  if (defers == defers_loading_)
+    return;
+
+  defers_loading_ = defers;
+  for (Frame* frame = MainFrame(); frame;
+       frame = frame->Tree().TraverseNext()) {
+    if (auto* local_frame = DynamicTo<LocalFrame>(frame)) {
+      local_frame->Loader().SetDefersLoading(defers ? LoaderFreezeMode::kStrict
+                                                    : LoaderFreezeMode::kNone);
+    }
+  }
+}
 #endif
 
 const base::UnguessableToken& Page::BrowsingContextGroupToken() {
index 47b52b8..ca98bfb 100644 (file)
@@ -348,6 +348,7 @@ class CORE_EXPORT Page final : public GarbageCollected<Page>,
   uint64_t GetLongPollingGlobalTimeout() {
     return long_polling_global_timeout_;
   }
+  void SetDefersLoading(bool defers);
 #endif
 
   void AddAutoplayFlags(int32_t flags);
@@ -655,6 +656,7 @@ class CORE_EXPORT Page final : public GarbageCollected<Page>,
   WebScopedVirtualTimePauser history_navigation_virtual_time_pauser_;
 #if BUILDFLAG(IS_EFL)
   uint64_t long_polling_global_timeout_ = 0;
+  bool defers_loading_ = false;
 #endif // IS_EFL
 
   Member<v8_compile_hints::V8CrowdsourcedCompileHintsProducer>
index 02db385..5cd531a 100644 (file)
@@ -564,7 +564,17 @@ void WidgetBase::SelectFocusedLink() {
 void WidgetBase::RequestSelectionRect(RequestSelectionRectCallback callback) {
   std::move(callback).Run(client_->RequestSelectionRect());
 }
-#endif
+
+#if BUILDFLAG(IS_TIZEN_TV)
+void WidgetBase::SuspendNetworkLoading() {
+  client_->SuspendNetworkLoading();
+}
+
+void WidgetBase::ResumeNetworkLoading() {
+  client_->ResumeNetworkLoading();
+}
+#endif  // IS_TIZEN_TV
+#endif  // IS_EFL
 
 #if BUILDFLAG(IS_TIZEN_TV)
 void WidgetBase::SetFloatVideoWindowState(bool enabled) {
index 9f3e2b1..d385fc7 100644 (file)
@@ -156,6 +156,8 @@ class PLATFORM_EXPORT WidgetBase : public mojom::blink::Widget,
       RequestMainFrameScrollbarVisibleCallback callback) override;
 #if BUILDFLAG(IS_TIZEN_TV)
   void SetFloatVideoWindowState(bool enabled) override;
+  void SuspendNetworkLoading() override;
+  void ResumeNetworkLoading() override;
 #endif // IS_TIZEN_TV
   void QueryInputType(QueryInputTypeCallback) override;
   void SelectClosestWord(uint32_t x, uint32_t y) override;
index ab7fac0..82980e4 100644 (file)
@@ -781,6 +781,20 @@ void EWebView::SetFloatVideoWindowState(bool enabled) {
 
     rwhi->SetFloatVideoWindowState(enabled);
 }
+
+void EWebView::SuspendNetworkLoading() {
+  RenderWidgetHostImpl* rwhi = static_cast<RenderWidgetHostImpl*>(
+      web_contents_->GetRenderViewHost()->GetWidget());
+
+  rwhi->SuspendNetworkLoading();
+}
+
+void EWebView::ResumeNetworkLoading() {
+  RenderWidgetHostImpl* rwhi = static_cast<RenderWidgetHostImpl*>(
+      web_contents_->GetRenderViewHost()->GetWidget());
+
+  rwhi->ResumeNetworkLoading();
+}
 #endif // IS_TIZEN_TV
 
 double EWebView::GetTextZoomFactor() const {
@@ -3085,6 +3099,11 @@ void EWebView::SendDelayedMessages(RenderViewHost* render_view_host) {
     return;
   }
 
+#if BUILDFLAG(IS_TIZEN_TV)
+  if (pending_setfocus_closure_)
+    std::move(pending_setfocus_closure_).Run();
+#endif
+
   for (auto iter = delayed_messages_.begin(); iter != delayed_messages_.end();
        ++iter) {
     IPC::Message* message = *iter;
index 6d7f069..040fc89 100644 (file)
@@ -401,6 +401,8 @@ class EWebView {
                                                int player_id,
                                                const char* url,
                                                const char* mime_type);
+  void SuspendNetworkLoading();
+  void ResumeNetworkLoading();
 #endif // IS_TIZEN_TV
   void SetSessionTimeout(uint64_t timeout);
   double GetTextZoomFactor() const;
index 97c6c20..d30fc43 100644 (file)
@@ -1645,14 +1645,26 @@ void ewk_view_widget_pepper_extension_info_set(Evas_Object* ewk_view, Ewk_Value
 #endif
 }
 
-void ewk_view_resume_network_loading(Evas_Object* ewkView)
+void ewk_view_resume_network_loading(Evas_Object* ewk_view)
 {
-  LOG_EWK_API_MOCKUP();
+#if BUILDFLAG(IS_TIZEN_TV)
+  LOG(INFO) << "view : " << ewk_view;
+  EWK_VIEW_IMPL_GET_OR_RETURN(ewk_view, impl);
+  impl->ResumeNetworkLoading();
+#else
+  LOG_EWK_API_MOCKUP("Only for Tizen TV Browser");
+#endif
 }
 
-void ewk_view_suspend_network_loading(Evas_Object* ewkView)
+void ewk_view_suspend_network_loading(Evas_Object* ewk_view)
 {
-  LOG_EWK_API_MOCKUP();
+#if BUILDFLAG(IS_TIZEN_TV)
+  LOG(INFO) << "view : " << ewk_view;
+  EWK_VIEW_IMPL_GET_OR_RETURN(ewk_view, impl);
+  impl->SuspendNetworkLoading();
+#else
+  LOG_EWK_API_MOCKUP("Only for Tizen TV Browser");
+#endif
 }
 
 void ewk_view_offscreen_rendering_enabled_set(Evas_Object* o, Eina_Bool enabled)
index 9b0eb63..2b760ac 100644 (file)
@@ -513,7 +513,7 @@ EXPORT_API Evas_Object* ewk_view_favicon_get(const Evas_Object* ewkView);
  * @param item view object to resume new url loading
  *
  */
-EXPORT_API void ewk_view_resume_network_loading(Evas_Object* ewkView);
+EXPORT_API void ewk_view_resume_network_loading(Evas_Object* ewk_view);
 
 EXPORT_API void ewk_view_poweroff_suspend(Evas_Object *item);
 
@@ -523,7 +523,7 @@ EXPORT_API void ewk_view_poweroff_suspend(Evas_Object *item);
  * @param item view object to suspend url loading
  *
  */
-EXPORT_API void ewk_view_suspend_network_loading(Evas_Object* ewkView);
+EXPORT_API void ewk_view_suspend_network_loading(Evas_Object* ewk_view);
 
 /**
  * This function should be use for browser edge scroll.