[M120 Migration][hbbtv] Audio tracks count notification
[platform/framework/web/chromium-efl.git] / tizen_src / ewk / efl_integration / web_contents_delegate_efl.h
index c99f0bc..6803af8 100644 (file)
@@ -2,58 +2,57 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#ifndef WEB_CONTENTS_DELEGATE_EFL
-#define WEB_CONTENTS_DELEGATE_EFL
+#ifndef WEB_CONTENTS_DELEGATE_EFL_H_
+#define WEB_CONTENTS_DELEGATE_EFL_H_
 
-#include <deque>
-
-#include "content/public/browser/browser_context.h"
-#include "browser/javascript_dialog_manager_efl.h"
-#include "browser_context_efl.h"
-#include "eweb_view.h"
-#include "content/public/browser/web_contents.h"
 #include "content/public/browser/web_contents_delegate.h"
-#include "content/public/browser/render_view_host.h"
-#include "content/public/browser/web_contents_observer.h"
-#include "content/browser/web_contents/web_contents_impl.h"
-#include "url/gurl.h"
-#include "browser/favicon/favicon_downloader.h"
+#include "eweb_view.h"
+#include "private/ewk_manifest_private.h"
 #include "public/ewk_view_internal.h"
-#include "ui/base/ime/text_input_type.h"
+#include "third_party/blink/public/mojom/manifest/manifest.mojom.h"
+
+#if BUILDFLAG(IS_TIZEN_TV)
+#include "third_party/blink/public/common/mediastream/media_devices.h"
+#endif
 
-class DidPrintPagesParams;
-class Ewk_Wrt_Message_Data;
 class JavaScriptDialogManagerEfl;
 
 namespace content {
 
-class WebContentsDelegateEfl : public WebContentsDelegate,
-                               public WebContentsObserver,
-                               public IPC::Sender {
+class WebContentsObserverEfl;
+
+class WebContentsDelegateEfl : public WebContentsDelegate {
  public:
   WebContentsDelegateEfl(EWebView*);
-  ~WebContentsDelegateEfl() override;
+  ~WebContentsDelegateEfl();
 
-  // Overridden from WebContentsDelegate:
+  WebContentsDelegateEfl(const WebContentsDelegateEfl&) = delete;
+  WebContentsDelegateEfl& operator=(const WebContentsDelegateEfl&) = delete;
+
+  // WebContentsDelegate overrides.
   WebContents* OpenURLFromTab(WebContents* source,
                               const OpenURLParams& params) override;
   void NavigationStateChanged(WebContents* source,
                               InvalidateTypes changed_flags) override;
-  void LoadingStateChanged(WebContents* source,
-                           bool to_different_document) override;
+
+  void AddNewContents(WebContents* source,
+                      std::unique_ptr<WebContents> new_contents,
+                      const GURL& target_url,
+                      WindowOpenDisposition disposition,
+                      const blink::mojom::WindowFeatures& window_features,
+                      bool user_gesture,
+                      bool* was_blocked) override;
   bool ShouldCreateWebContents(
       WebContents* web_contents,
       RenderFrameHost* opener,
       SiteInstance* source_site_instance,
-      int32_t route_id,
-      int32_t main_frame_route_id,
-      int32_t main_frame_widget_route_id,
       mojom::WindowContainerType window_container_type,
       const GURL& opener_url,
       const std::string& frame_name,
       const GURL& target_url,
       const std::string& partition_id,
       SessionStorageNamespace* session_storage_namespace);
+
   void CloseContents(WebContents* source) override;
   void EnterFullscreenModeForTab(
       RenderFrameHost* requesting_frame,
@@ -61,65 +60,64 @@ class WebContentsDelegateEfl : public WebContentsDelegate,
   void ExitFullscreenModeForTab(WebContents* web_contents) override;
   bool IsFullscreenForTabOrPending(const WebContents* web_contents) override;
 
-#if defined(TIZEN_MULTIMEDIA_SUPPORT)
-  virtual bool CheckMediaAccessPermission(WebContents* web_contents,
-                                          const GURL& security_origin,
-                                          MediaStreamType type) override;
-
-  virtual void RequestMediaAccessPermission(
-      WebContents* web_contents,
-      const MediaStreamRequest& request,
-      MediaResponseCallback callback) override;
-
-  void RequestMediaAccessAllow(const MediaStreamRequest& request,
-                               MediaResponseCallback callback);
-
-  void RequestMediaAccessDeny(const MediaStreamRequest& request,
-                              MediaResponseCallback callback);
-#endif
-  void RegisterProtocolHandler(RenderFrameHost* host,
-                               const std::string& protocol,
-                               const GURL& url,
-                               bool user_gesture) override;
-  void UnregisterProtocolHandler(RenderFrameHost* host,
-                                 const std::string& protocol,
-                                 const GURL& url,
-                                 bool user_gesture) override;
   void FindReply(WebContents* web_contents,
                  int request_id,
                  int number_of_matches,
                  const gfx::Rect& selection_rect,
                  int active_match_ordinal,
                  bool final_update) override;
-
+#if defined(TIZEN_TBM_SUPPORT)
+  void DidRenderOffscreenFrame(void* buffer) override;
+#endif
   void DidRenderFrame() override;
+  void DidChangeInputType(bool is_password_input) override;
+
+  void OnGetMainFrameScrollbarVisible(int callback_id, bool visible) override;
+
+#if BUILDFLAG(IS_TIZEN_TV)
+  //Browser edge scroll
+  void DidEdgeScrollBy(const gfx::Point& offset, bool handled) override;
+  void MoveFocusToBrowser(int direction) override;
+  void NotifyDownloadableFontInfo(const std::string& scheme_id_uri,
+                                  const std::string& value,
+                                  const std::string& data,
+                                  int type) override;
+  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) override;
+  void NotifyParentalRatingInfo(const std::string& info,
+                                const std::string& url) override;
+  void NotifyAudioTracksCount(int player_id,
+                              unsigned audio_tracks_count) override;
+  void WillDraw(int rotation, gfx::Size frame_data_output_size) override;
+#endif
+  void UpdateTooltipUnderCursor(const std::u16string& text) override;
 
   void RequestCertificateConfirm(
       WebContents* web_contents,
       int cert_error,
       const net::SSLInfo& ssl_info,
       const GURL& url,
-      bool overridable,
+      bool is_main_frame_request,
       bool strict_enforcement,
       base::OnceCallback<void(CertificateRequestResultType)> callback);
 
   JavaScriptDialogManager* GetJavaScriptDialogManager(
       WebContents* source) override;
-
+  void ActivateContents(WebContents* contents) override;
   void OnUpdateSettings(const Ewk_Settings* settings);
   void SetContentSecurityPolicy(const std::string& policy,
                                 Ewk_CSP_Header_Type header_type);
 
-  void DidFirstVisuallyNonEmptyPaint() override;
-  void DidStartLoading() override;
+  void BackgroundColorReceived(int callback_id, SkColor bg_color) override;
+
+  void DidFirstVisuallyNonEmptyPaint();
+  void DidStartLoading();
 
-  bool OnMessageReceived(const IPC::Message& message,
-                         RenderFrameHost* render_frame_host) override;
-  void OnPrintedMetafileReceived(const DidPrintPagesParams& params);
-  void NavigationEntryCommitted(
-      const LoadCommittedDetails& load_details) override;
-  void RenderViewCreated(RenderViewHost* render_view_host);
-  void RenderProcessGone(base::TerminationStatus status) override;
   bool DidAddMessageToConsole(WebContents* source,
                               blink::mojom::ConsoleMessageLevel level,
                               const std::u16string& message,
@@ -131,104 +129,102 @@ class WebContentsDelegateEfl : public WebContentsDelegate,
   std::unique_ptr<ColorChooser> OpenColorChooser(
       WebContents* web_contents,
       SkColor color,
-      const std::vector<blink::mojom::ColorSuggestionPtr>& suggestions)
-      override;
-#if !defined(EWK_BRINGUP)  // FIXME: m76 bringup
-  void OpenDateTimeDialog(ui::TextInputType dialog_type,
-                          double dialog_value,
-                          double min,
-                          double max,
-                          double step,
-                          const std::vector<DateTimeSuggestion>& suggestions);
-#endif
+      const std::vector<blink::mojom::ColorSuggestionPtr>& suggestions);
   bool PreHandleGestureEvent(WebContents* source,
                              const blink::WebGestureEvent& event) override;
+  void VisibleSecurityStateChanged(WebContents* source) override;
+  EWebView* web_view() const { return web_view_; }
+  WebContents& web_contents() const { return web_contents_; }
 
-  // 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 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 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 OnAuthRequired(net::URLRequest* request,
-                      const std::string& realm,
+  void RequestManifestInfo(Ewk_View_Request_Manifest_Callback callback,
+                           void* user_data);
+  void OnAuthRequired(const std::string& realm,
+                      const GURL& url,
                       LoginDelegateEfl* login_delegate);
 
-  void DidDownloadFavicon(bool success,
-                          const GURL& icon_url,
-                          const SkBitmap& bitmap);
+#if defined(TIZEN_MULTIMEDIA)
+  bool CheckMediaAccessPermission(RenderFrameHost* render_frame_host,
+                                  const GURL& security_origin,
+                                  blink::mojom::MediaStreamType type) override;
 
-  EWebView* web_view() const { return web_view_; }
-  WebContents& web_contents() const { return web_contents_; }
+  void RequestMediaAccessPermission(WebContents* web_contents,
+                                    const MediaStreamRequest& request,
+                                    MediaResponseCallback callback) override;
 
- private:
-  void OnGetContentSecurityPolicy(IPC::Message* reply_msg);
-  void OnWrtPluginMessage(const Ewk_Wrt_Message_Data& data);
-  void OnWrtPluginSyncMessage(const Ewk_Wrt_Message_Data& data,
-                              IPC::Message* reply);
+  void RequestMediaAccessAllow(const MediaStreamRequest& request,
+                               MediaResponseCallback callback);
+
+  void RequestMediaAccessDeny(const MediaStreamRequest& request,
+                              MediaResponseCallback callback);
+#endif
 
+#if BUILDFLAG(IS_TIZEN_TV)
+  void UpdateTargetURL(WebContents* source, const GURL& url) override;
+  void ShowInspectorPortInfo();
+  void NotifyFirstTimeStamp(unsigned long long timestamp,
+                            int time_base_num,
+                            int time_base_den) override;
+  void NotifyPESData(const std::string& buf,
+                     unsigned int len,
+                     int media_position) override;
+  void UpdateCurrentTime(double current_time) override;
+  void UpdateEventData(void* data) override;
+  void NotifySubtitleState(int state, double time_stamp) override;
+  void NotifySubtitlePlay(int active_track_id,
+                          const std::string& url,
+                          const std::string& lang) override;
+  void NotifySubtitleData(int track_id,
+                          double time_stamp,
+                          const std::string& data,
+                          unsigned int size) override;
+  void NotifyMediaStateChanged(uint32_t type,
+                               uint32_t previous,
+                               uint32_t current) override;
+  bool IsHighBitRate() const override;
+  using MediaDeviceEnumeration =
+      std::array<blink::WebMediaDeviceInfoArray, NUM_MEDIA_DEVICE_TYPES>;
+  using EnumerationCallback =
+      base::OnceCallback<void(const MediaDeviceEnumeration&)>;
+  void GetMediaDeviceList(EnumerationCallback cb);
+  void VideoPlayingStatusReceived(bool is_playing, int callback_id) override;
+#endif
+
+#if defined(TIZEN_AUTOFILL)
+  void UpdateAutofillIfRequired();
+#endif
+
+#if defined(TIZEN_AUTOFILL_FW)
+  void ResetLastInteractedElements();
+#endif
+
+ private:
+  void OnDidGetManifest(Ewk_View_Request_Manifest_Callback callback,
+                        void* user_data,
+                        const GURL& manifest_url,
+                        blink::mojom::ManifestPtr manifest);
+#if BUILDFLAG(IS_TIZEN_TV)
+  void OnIsVideoPlayingGet(bool is_playing, int callback_id);
+#endif
+  void OnDidChangeFocusedNodeBounds(const gfx::RectF& focused_node_bounds);
   EWebView* web_view_;
-  bool is_fullscreen_;
+  bool is_fullscreen_ = false;
   WebContents& web_contents_;
+#if BUILDFLAG(IS_TIZEN_TV)
+  std::string last_hovered_url_;
+#endif
 
-  bool did_render_frame_;
-  bool did_first_visually_non_empty_paint_;
-
-  struct ContentSecurityPolicy {
-    ContentSecurityPolicy(const std::string& p, Ewk_CSP_Header_Type type)
-        : policy(p), header_type(type) {}
-    std::string policy;
-    Ewk_CSP_Header_Type header_type;
-  };
+  bool did_render_frame_ = false;
+  bool did_first_visually_non_empty_paint_ = false;
 
+  std::unique_ptr<WebContentsObserverEfl> contents_observer_;
+  void* ime_window_ = nullptr;
   GURL last_visible_url_;
 
-  std::unique_ptr<ContentSecurityPolicy> pending_content_security_policy_;
-  bool document_created_;
-  JavaScriptDialogManagerEfl* dialog_manager_;
-  std::unique_ptr<FaviconDownloader> favicon_downloader_;
-  base::WeakPtrFactory<WebContentsDelegateEfl> weak_ptr_factory_;
+  JavaScriptDialogManagerEfl* dialog_manager_ = nullptr;
+  int rotation_ = -1;
   std::unique_ptr<_Ewk_Certificate_Policy_Decision>
       certificate_policy_decision_;
-
-  DISALLOW_COPY_AND_ASSIGN(WebContentsDelegateEfl);
 };
 }
 
-#endif
+#endif  // WEB_CONTENTS_DELEGATE_EFL_H_