[M120 Migration][hbbtv] Audio tracks count notification
[platform/framework/web/chromium-efl.git] / content / public / browser / web_contents_delegate.h
index 6dc1a59..ec8def3 100644 (file)
 #include <string>
 #include <vector>
 
-#include "base/callback.h"
+#include "base/functional/callback.h"
 #include "base/memory/scoped_refptr.h"
 #include "build/build_config.h"
 #include "content/common/content_export.h"
 #include "content/public/browser/eye_dropper.h"
+#include "content/public/browser/fullscreen_types.h"
 #include "content/public/browser/invalidate_type.h"
 #include "content/public/browser/media_stream_request.h"
 #include "content/public/browser/serial_chooser.h"
@@ -122,7 +123,8 @@ class CONTENT_EXPORT WebContentsDelegate {
   // OpenURL() for these cases which does it for you).
 
   // Returns the WebContents the URL is opened in, or nullptr if the URL wasn't
-  // opened immediately.
+  // opened immediately. Note that the URL might be opened in another context
+  // when a nullptr is returned.
   virtual WebContents* OpenURLFromTab(WebContents* source,
                                       const OpenURLParams& params);
 
@@ -318,7 +320,7 @@ class CONTENT_EXPORT WebContentsDelegate {
   // CreateCustomWebContents() below to provide their own WebContents.
   virtual bool IsWebContentsCreationOverridden(
       SiteInstance* source_site_instance,
-      content::mojom::WindowContainerType window_container_type,
+      mojom::WindowContainerType window_container_type,
       const GURL& opener_url,
       const std::string& frame_name,
       const GURL& target_url);
@@ -351,6 +353,19 @@ class CONTENT_EXPORT WebContentsDelegate {
                                   const GURL& target_url,
                                   WebContents* new_contents) {}
 
+  // Notifies the embedder that a new WebContents dedicated for hosting a
+  // prerendered page has been created. `prerender_web_contents` will host an
+  // initial empty primary page and a prerendered page. The prerendered page
+  // will be activated as a primary page on prerender activation.
+  // `prerender_web_contents` is not visible until the activation.
+  //
+  // This function is called only when this delegate is
+  // PrerenderWebContentsDelegate. This delegate and `prerender_web_contents`
+  // are owned by a prerender handle. `prerender_web_contents` outlives this
+  // delegate.
+  virtual void PrerenderWebContentsCreated(
+      WebContents* prerender_web_contents) {}
+
   // Notifies the embedder that a new WebContents has been created to contain
   // the contents of a portal.
   virtual void PortalWebContentsCreated(WebContents* portal_web_contents) {}
@@ -392,23 +407,27 @@ class CONTENT_EXPORT WebContentsDelegate {
   virtual void RendererResponsive(WebContents* source,
                                   RenderWidgetHost* render_widget_host) {}
 
-  // Invoked when a primary main frame navigation occurs.
-  virtual void DidNavigatePrimaryMainFramePostCommit(WebContents* source) {}
+#if BUILDFLAG(IS_TIZEN_TV)
+  virtual void DidEdgeScrollBy(const gfx::Point& offset, bool handled) {}
+  virtual void MoveFocusToBrowser(int direction) {}
+  virtual void ShowMicOpenedNotification(bool show) {}
+#endif
+  virtual void UpdateTooltipUnderCursor(const std::u16string& text) {}
 
   // Returns a pointer to a service to manage JavaScript dialogs. May return
   // nullptr in which case dialogs aren't shown.
   virtual JavaScriptDialogManager* GetJavaScriptDialogManager(
       WebContents* source);
 
-#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_MAC) || defined(USE_EFL)
+#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_APPLE) || BUILDFLAG(IS_EFL)
   // Called when color chooser should open. Returns the opened color chooser.
   // Returns nullptr if we failed to open the color chooser. The color chooser
-  // is only supported/required for Android.
+  // is supported/required for Android or iOS.
   virtual std::unique_ptr<ColorChooser> OpenColorChooser(
       WebContents* web_contents,
       SkColor color,
       const std::vector<blink::mojom::ColorSuggestionPtr>& suggestions);
-#endif  // BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_MAC)
+#endif
 
   // Called when an eye dropper should open. Returns the eye dropper window.
   // The eye dropper is responsible for calling listener->ColorSelected() or
@@ -441,6 +460,19 @@ class CONTENT_EXPORT WebContentsDelegate {
                                base::OnceCallback<void()> on_confirm,
                                base::OnceCallback<void()> on_cancel);
 
+  // Returns whether the RFH can use Additional Windowing Controls APIs.
+  // https://github.com/ivansandrk/additional-windowing-controls/blob/main/awc-explainer.md
+  virtual bool CanUseWindowingControls(RenderFrameHost* requesting_frame);
+
+  // Sends the resizable boolean set via `window.setResizable(bool)` API to
+  // `BrowserView`. Passing std::nullopt will reset the resizable state to the
+  // default.
+  virtual void SetCanResizeFromWebAPI(absl::optional<bool> can_resize) {}
+  virtual bool GetCanResize();
+  virtual void MinimizeFromWebAPI() {}
+  virtual void MaximizeFromWebAPI() {}
+  virtual void RestoreFromWebAPI() {}
+
   // Returns whether entering fullscreen with |EnterFullscreenModeForTab()| is
   // allowed.
   virtual bool CanEnterFullscreenModeForTab(
@@ -461,16 +493,12 @@ class CONTENT_EXPORT WebContentsDelegate {
   // Called when the renderer puts a tab out of fullscreen mode.
   virtual void ExitFullscreenModeForTab(WebContents*) {}
 
-  // Returns true if the given `web_contents` is, or is transitioning to
-  // tab-fullscreen.
+  // Returns true if `web_contents` is, or is transitioning to, tab-fullscreen.
   virtual bool IsFullscreenForTabOrPending(const WebContents* web_contents);
 
-  // Overload of IsFullscreenForTabOrPending which also outputs the current or
-  // target display of the fullscreen tab. If the function returns true and
-  // `display_id` is not nullptr, the target display ID of the tab will be
-  // written to `display_id`.
-  virtual bool IsFullscreenForTabOrPending(const WebContents* web_contents,
-                                           int64_t* display_id);
+  // Returns fullscreen state information about the given `web_contents`.
+  virtual FullscreenState GetFullscreenState(
+      const WebContents* web_contents) const;
 
   // Returns the actual display mode of the top-level browsing context.
   // For example, it should return 'blink::mojom::DisplayModeFullscreen'
@@ -510,8 +538,19 @@ class CONTENT_EXPORT WebContentsDelegate {
                          int active_match_ordinal,
                          bool final_update) {}
 
-#if defined(USE_EFL)
+#if defined(TIZEN_TBM_SUPPORT)
+  virtual void DidRenderOffscreenFrame(void* buffer) {}
+#endif
+
+#if BUILDFLAG(IS_EFL)
+  virtual void DidChangeInputType(bool is_password_field) {}
+  virtual void DidReceiveNonEmtpyLayoutFrame() {}
   virtual void DidRenderFrame() {}
+  virtual void BackgroundColorReceived(int callback_id, SkColor bg_color) {}
+  virtual void OnDidChangeFocusedNodeBounds(
+      const gfx::RectF& focused_node_bounds) {}
+  virtual void OnGetMainFrameScrollbarVisible(int callback_id, bool visible) {}
+  virtual void WillDraw(int rotation, gfx::Size frame_data_output_size) {}
 #endif
 
 #if BUILDFLAG(IS_ANDROID)
@@ -554,10 +593,9 @@ class CONTENT_EXPORT WebContentsDelegate {
   // request is denied, a call should be made to |callback| with an empty list
   // of devices. |request| has the details of the request (e.g. which of audio
   // and/or video devices are requested, and lists of available devices).
-  virtual void RequestMediaAccessPermission(
-      WebContents* web_contents,
-      const MediaStreamRequest& request,
-      content::MediaResponseCallback callback);
+  virtual void RequestMediaAccessPermission(WebContents* web_contents,
+                                            const MediaStreamRequest& request,
+                                            MediaResponseCallback callback);
 
   // Checks if we have permission to access the microphone or camera. Note that
   // this does not query the user. |type| must be MEDIA_DEVICE_AUDIO_CAPTURE
@@ -616,7 +654,7 @@ class CONTENT_EXPORT WebContentsDelegate {
   // default behavior is suppressed.
   virtual bool SaveFrame(const GURL& url,
                          const Referrer& referrer,
-                         content::RenderFrameHost* rfh);
+                         RenderFrameHost* rfh);
 
   // Called when a suspicious navigation of the main frame has been blocked.
   // Allows the delegate to provide some UI to let the user know about the
@@ -648,13 +686,15 @@ class CONTENT_EXPORT WebContentsDelegate {
   // whether they will shrink the Blink's view size. Note that they are not
   // complete in the sense that there is no API to tell content to poll these
   // values again, except part of resize. But this is not needed by embedder
-  // because it's always accompanied by view size change.
+  // because it's always accompanied by view size change. The values returned
+  // by these APIs are in physical pixels (not DIPs).
   virtual int GetTopControlsHeight();
   virtual int GetTopControlsMinHeight();
   virtual int GetBottomControlsHeight();
   virtual int GetBottomControlsMinHeight();
   virtual bool ShouldAnimateBrowserControlsHeightChanges();
   virtual bool DoBrowserControlsShrinkRendererSize(WebContents* web_contents);
+  virtual int GetVirtualKeyboardHeight(WebContents* web_contents);
   // Returns true if the top controls should only expand at the top of the page,
   // so they'll only be visible if the page is scrolled to the top.
   virtual bool OnlyExpandTopControlsAtPageTop();
@@ -667,7 +707,7 @@ class CONTENT_EXPORT WebContentsDelegate {
   // Requests to print an out-of-process subframe for the specified WebContents.
   // |rect| is the rectangular area where its content resides in its parent
   // frame. |document_cookie| is a unique id for a printed document associated
-  // with a print job. |subframe_host| is the render frame host of the subframe
+  // with a print job. |subframe_host| is the RenderFrameHost of the subframe
   // to be printed.
   virtual void PrintCrossProcessSubframe(WebContents* web_contents,
                                          const gfx::Rect& rect,
@@ -678,7 +718,7 @@ class CONTENT_EXPORT WebContentsDelegate {
   // Requests to capture a paint preview of a subframe for the specified
   // WebContents. |rect| is the rectangular area where its content resides in
   // its parent frame. |guid| is a globally unique identitier for an entire
-  // paint preview. |render_frame_host| is the render frame host of the subframe
+  // paint preview. |render_frame_host| is the RenderFrameHost of the subframe
   // to be captured.
   virtual void CapturePaintPreviewOfSubframe(
       WebContents* web_contents,
@@ -696,6 +736,45 @@ class CONTENT_EXPORT WebContentsDelegate {
   // Picture-in-Picture mode has ended.
   virtual void ExitPictureInPicture() {}
 
+#if BUILDFLAG(IS_TIZEN_TV)
+  virtual void VideoPlayingStatusReceived(bool is_playing, int callback_id) {}
+  virtual void NotifyPlaybackState(int state,
+                                   int player_id,
+                                   const std::string& url,
+                                   const std::string& mime_type,
+                                   bool* media_resource_acquired,
+                                   std::string* translated_url,
+                                   std::string* drm_info) {}
+  // Notify Media State to Web browser
+  virtual void NotifyMediaStateChanged(uint32_t type,
+                                       uint32_t previous,
+                                       uint32_t current) {}
+  virtual bool IsHighBitRate() const { return false; }
+  virtual void UpdateEventData(void* data) {}
+  virtual void NotifyParentalRatingInfo(const std::string& info,
+                                        const std::string& url) {}
+  virtual void NotifyDownloadableFontInfo(const std::string& scheme_id_uri,
+                                          const std::string& value,
+                                          const std::string& data,
+                                          int type) {}
+  virtual void NotifyAudioTracksCount(int player_id, unsigned count) {}
+  virtual void NotifySubtitleState(int state, double time_stamp = 0.0) {}
+  virtual void NotifySubtitlePlay(int active_track_id,
+                                  const std::string& url,
+                                  const std::string& lang) {}
+  virtual void NotifySubtitleData(int track_id,
+                                  double time_stamp,
+                                  const std::string& data,
+                                  unsigned size) {}
+  virtual void UpdateCurrentTime(double current_time) {}
+  virtual void NotifyFirstTimeStamp(unsigned long long timestamp,
+                                    int time_base_num,
+                                    int time_base_den) {}
+  virtual void NotifyPESData(const std::string& buf,
+                             unsigned int len,
+                             int media_position) {}
+#endif
+
 #if BUILDFLAG(IS_ANDROID)
   // Updates information to determine whether a user gesture should carryover to
   // future navigations. This is needed so navigations within a certain
@@ -711,9 +790,11 @@ class CONTENT_EXPORT WebContentsDelegate {
   // indication that the cache will be used.
   virtual bool IsBackForwardCacheSupported();
 
-  // Returns true if Prerender2 (see
+  // Returns PreloadingEligibility::kEligible if Prerender2 (see
   // content/browser/preloading/prerender/README.md for details) is supported.
-  virtual bool IsPrerender2Supported(WebContents& web_contents);
+  // If it is not supported, returns the reason.
+  virtual PreloadingEligibility IsPrerender2Supported(
+      WebContents& web_contents);
 
   // Requests the delegate to replace |predecessor_contents| with
   // |portal_contents| in the container that holds |predecessor_contents|. If
@@ -738,21 +819,6 @@ class CONTENT_EXPORT WebContentsDelegate {
   // solid color is displayed instead.
   virtual bool ShouldShowStaleContentOnEviction(WebContents* source);
 
-  // Returns the user-visible WebContents that is responsible for the activity
-  // in the provided WebContents. For example, this delegate may be aware that
-  // the contents is embedded in some other contents, or hosts background
-  // activity on behalf of a user-visible tab which should be used to display
-  // dialogs and similar affordances to the user.
-  //
-  // This may be distinct from the outer web contents (for example, the
-  // responsible contents may logically "own" a contents but not currently embed
-  // it for rendering).
-  //
-  // For most delegates (where the WebContents is a tab, window or other
-  // directly user-visible feature), simply returning the contents is
-  // appropriate.
-  virtual WebContents* GetResponsibleWebContents(WebContents* web_contents);
-
   // Invoked when media playback is interrupted or completed.
   virtual void MediaWatchTimeChanged(const MediaPlayerWatchTime& watch_time) {}
 
@@ -770,6 +836,31 @@ class CONTENT_EXPORT WebContentsDelegate {
   // WebContents.
   virtual bool IsPrivileged();
 
+  // Initiates previewing the given `url` within the given `web_contents`.
+  virtual void InitiatePreview(WebContents& web_contents, const GURL& url) {}
+
+  // CloseWatcher web API support. If the currently focused frame has a
+  // CloseWatcher registered in JavaScript, the CloseWatcher should receive the
+  // next "close" operation, based on what the OS convention for closing is.
+  // This function is called when the focused frame changes or a CloseWatcher
+  // is registered/unregistered to update whether the CloseWatcher should
+  // intercept.
+  virtual void DidChangeCloseSignalInterceptStatus() {}
+
+  // Whether the WebContents is running in preview mode.
+  virtual bool IsInPreviewMode() const;
+
+  // Notify the page uses a forbidden powerful API and cannot be shown in
+  // preview mode.
+  virtual void CancelPreviewByMojoBinderPolicy(
+      const std::string& interface_name) {}
+
+#if !BUILDFLAG(IS_ANDROID)
+  // Whether the WebContents should use per PWA instanced
+  // system media controls.
+  virtual bool ShouldUseInstancedSystemMediaControls() const;
+#endif  // !BUILDFLAG(IS_ANDROID)
+
  protected:
   virtual ~WebContentsDelegate();