[M120 Migration]URL of _Ewk_Error set wrong
[platform/framework/web/chromium-efl.git] / tizen_src / ewk / efl_integration / eweb_view.h
index 1a8a6b0..08fc8e7 100644 (file)
 #include <locale.h>
 #include <vector>
 
-#include "base/callback.h"
 #include "base/containers/id_map.h"
+#include "base/functional/callback.h"
 #include "base/synchronization/waitable_event.h"
 #include "browser/input_picker/input_picker.h"
-#include "content/browser/renderer_host/event_with_latency_info.h"
 #include "content/browser/select_picker/select_picker_base.h"
 #include "content/browser/selection/selection_controller_efl.h"
 #include "content/browser/web_contents/web_contents_view_aura.h"
 #include "content/browser/web_contents/web_contents_view_aura_helper_efl.h"
+#include "content/common/input/event_with_latency_info.h"
 #include "content/public/browser/context_menu_params.h"
 #include "content/public/browser/navigation_controller.h"
-#include "content/public/browser/quota_permission_context.h"
 #include "content/public/browser/web_contents_delegate.h"
-#include "content/public/browser/web_contents_efl_delegate.h"
+#include "content/public/browser/webview_delegate.h"
 #include "content/public/common/input_event_ack_state.h"
 #include "content_browser_client_efl.h"
 #include "context_menu_controller_efl.h"
 #include "public/ewk_value_product.h"
 #endif
 
+#if BUILDFLAG(IS_TIZEN_TV)
+#include "third_party/blink/public/common/mediastream/media_devices.h"
+#endif
+
 namespace aura {
 namespace client {
 class FocusClient;
@@ -85,9 +88,12 @@ class _Ewk_App_Control;
 class _Ewk_Policy_Decision;
 class _Ewk_Hit_Test;
 class Ewk_Context;
-class WebViewEvasEventHandler;
 class _Ewk_Quota_Permission_Request;
 
+#if BUILDFLAG(IS_TIZEN_TV)
+struct _Ewk_File_Chooser_Request;
+#endif
+
 #if defined(TIZEN_ATK_SUPPORT)
 class EWebAccessibility;
 #endif
@@ -288,13 +294,52 @@ class DidChangeThemeColorCallback {
   void* user_data_;
 };
 
+#if BUILDFLAG(IS_TIZEN_TV)
+class GetMediaDeviceCallback {
+ public:
+  GetMediaDeviceCallback() : func_(nullptr), user_data_(nullptr) {}
+
+  void Set(Ewk_Media_Device_List_Get_Callback func, void* user_data) {
+    func_ = func;
+    user_data_ = user_data;
+  }
+
+  void Run(EwkMediaDeviceInfo* device_list, int size) {
+    if (func_) {
+      (func_)(device_list, size, user_data_);
+    }
+  }
+
+ private:
+  Ewk_Media_Device_List_Get_Callback func_;
+  void* user_data_;
+};
+#endif
+
+#if BUILDFLAG(IS_TIZEN_TV)
+class IsVideoPlayingCallback {
+ public:
+  IsVideoPlayingCallback(Ewk_Is_Video_Playing_Callback func, void* user_data)
+      : func_(func), user_data_(user_data) {}
+  void Run(Evas_Object* obj, bool isplaying) {
+    if (func_) {
+      (func_)(obj, isplaying ? EINA_TRUE : EINA_FALSE, user_data_);
+    }
+  }
+
+ private:
+  Ewk_Is_Video_Playing_Callback func_;
+  void* user_data_;
+};
+#endif
+
 class WebViewAsyncRequestHitTestDataCallback;
 class JavaScriptDialogManagerEfl;
 class PermissionPopupManager;
 
 class EWebView {
  public:
-  static EWebView* FromEvasObject(Evas_Object* eo);
+  static EWebView* FromEwkView(Evas_Object* ewk_view);
 
   EWebView(Ewk_Context*, Evas_Object* smart_object);
   ~EWebView();
@@ -303,22 +348,22 @@ class EWebView {
   // call this once after created and before use
   void Initialize();
 
-  bool CreateNewWindow(
-      content::WebContentsEflDelegate::WebContentsCreateCallback);
+  bool CreateNewWindow(content::WebViewDelegate::WebContentsCreateCallback);
   static Evas_Object* GetHostWindowDelegate(const content::WebContents*);
 
   content::WebContentsViewAura* wcva() const;
   content::RenderWidgetHostViewAura* rwhva() const;
   Ewk_Context* context() const { return context_.get(); }
-  Evas_Object* evas_object() const { return evas_object_; }
-  Evas_Object* native_view() const { return native_view_; }
+  Evas_Object* ewk_view() const { return ewk_view_; }
+  Evas_Object* efl_main_layout() const { return efl_main_layout_; }
   Evas_Object* GetElmWindow() const;
-  Evas* GetEvas() const { return evas_object_evas_get(evas_object_); }
+  Evas* GetEvas() const { return evas_object_evas_get(ewk_view_); }
   PermissionPopupManager* GetPermissionPopupManager() const {
     return permission_popup_manager_.get();
   }
 
   content::WebContents& web_contents() const { return *web_contents_.get(); }
+  content::WebContentsViewAura* GetWebContentsViewAura() const;
 
 #if defined(TIZEN_ATK_SUPPORT)
   EWebAccessibility& eweb_accessibility() const {
@@ -328,7 +373,7 @@ class EWebView {
 
   template <EWebViewCallbacks::CallbackType callbackType>
   EWebViewCallbacks::CallBack<callbackType> SmartCallback() const {
-    return EWebViewCallbacks::CallBack<callbackType>(evas_object_);
+    return EWebViewCallbacks::CallBack<callbackType>(ewk_view_);
   }
 
   // ewk_view api
@@ -346,6 +391,19 @@ class EWebView {
   void Suspend();
   void Resume();
   void Stop();
+#if BUILDFLAG(IS_TIZEN_TV)
+  void SetFloatVideoWindowState(bool enabled);
+  void NotifyDownloadableFontInfo(const char* scheme_id_uri,
+                                  const char* value,
+                                  const char* data,
+                                  int type);
+  std::vector<std::string> NotifyPlaybackState(int state,
+                                               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;
   void SetTextZoomFactor(double text_zoom_factor);
@@ -361,6 +419,8 @@ class EWebView {
   void SetTouchEventsEnabled(bool enabled);
   bool MouseEventsEnabled() const;
   void SetMouseEventsEnabled(bool enabled);
+  void SendKeyEvent(Evas_Object* ewk_view, void* key_event, bool is_press);
+  bool SetKeyEventsEnabled(bool enabled);
   void HandleTouchEvents(Ewk_Touch_Event_Type type,
                          const Eina_List* points,
                          const Evas_Modifier* modifiers);
@@ -515,10 +575,9 @@ class EWebView {
 
   void SetViewLoadErrorPageCallback(Ewk_View_Error_Page_Load_Callback callback,
                                     void* user_data);
-  const char* InvokeViewLoadErrorPageCallback(
-      const GURL& url,
-      int error_code,
-      const std::string& error_description);
+  const char* InvokeViewLoadErrorPageCallback(const GURL& url,
+                                              int error_code,
+                                              bool is_cancellation);
   bool IsLoadErrorPageCallbackSet() const;
   void SetViewUnfocusAllowCallback(Ewk_View_Unfocus_Allow_Callback callback,
                                    void* user_data);
@@ -577,14 +636,16 @@ class EWebView {
   void JavaScriptPromptReply(const char* result);
   void set_renderer_crashed();
   void GetPageScaleRange(double* min_scale, double* max_scale);
-  void SetDrawsTransparentBackground(bool enabled);
+  bool SetDrawsTransparentBackground(bool enabled);
+  bool GetDrawsTransparentBackground();
+  bool SetBackgroundColor(int red, int green, int blue, int alpha);
   bool GetBackgroundColor(Ewk_View_Background_Color_Get_Callback callback,
                           void* user_data);
   void OnGetBackgroundColor(int callback_id, SkColor bg_color);
 
   void GetSessionData(const char** data, unsigned* length) const;
   bool RestoreFromSessionData(const char* data, unsigned length);
-  void ShowFileChooser(content::RenderFrameHost* render_frame_host,
+  void ShowFileChooser(scoped_refptr<content::FileSelectListener> listener,
                        const blink::mojom::FileChooserParams&);
   void SetBrowserFont();
   bool IsDragging() const;
@@ -614,13 +675,13 @@ class EWebView {
   void SetQuotaPermissionRequestCallback(
       Ewk_Quota_Permission_Request_Callback callback,
       void* user_data);
+#if !defined(EWK_BRINGUP)  // FIXME: m114 bringup
   void InvokeQuotaPermissionRequest(
       _Ewk_Quota_Permission_Request* request,
       content::QuotaPermissionContext::PermissionCallback cb);
   void QuotaRequestReply(const _Ewk_Quota_Permission_Request* request,
                          bool allow);
   void QuotaRequestCancel(const _Ewk_Quota_Permission_Request* request);
-#if !defined(EWK_BRINGUP)  // FIXME: m67 bringup
   void SetViewMode(blink::WebViewMode view_mode);
 #endif
   gfx::Point GetContextMenuPosition() const;
@@ -688,6 +749,16 @@ class EWebView {
   void ReplyBeforeUnloadConfirmPanel(Eina_Bool result);
   void SyncAcceptLanguages(const std::string& accept_languages);
 
+#if BUILDFLAG(IS_TIZEN_TV)
+  //Browser edge scroll
+  bool EdgeScrollBy(int delta_x, int delta_y);
+  void GetMousePosition(gfx::Point&);
+  void InvokeEdgeScrollByCallback(const gfx::Point&, bool);
+  // notify web browser video playing status
+  bool IsVideoPlaying(Ewk_Is_Video_Playing_Callback callback, void* user_data);
+  void InvokeIsVideoPlayingCallback(bool is_playing, int callback_id);
+#endif
+
   void OnOverscrolled(const gfx::Vector2dF& accumulated_overscroll,
                       const gfx::Vector2dF& latest_overscroll_delta);
 
@@ -729,6 +800,37 @@ class EWebView {
   bool RWIInfoShowed() { return rwi_info_showed_; }
   GURL RWIURL() { return rwi_gurl_; }
   void OnDialogClosed();
+  void NotifyMediaStateChanged(uint32_t type,
+                               uint32_t previous,
+                               uint32_t current);
+  void SetHighBitRate(Eina_Bool is_high_bitrate);
+  bool IsHighBitRate() const { return is_high_bitrate_; }
+  void NotifyFirstTimeStamp(unsigned long long timestamp,
+                            int time_base_num,
+                            int time_base_den);
+  void NotifyPESData(const std::string& buf,
+                     unsigned int len,
+                     int media_position);
+  void SetPreferSubtitleLang(const char* lang_list);
+  void NotifySubtitleState(int state, double time_stamp);
+  void NotifySubtitlePlay(int active_track_id,
+                          const char* url,
+                          const char* lang);
+  void NotifySubtitleData(int track_id,
+                          double time_stamp,
+                          const std::string& data,
+                          unsigned int size);
+  void UpdateCurrentTime(double current_time);
+  void UpdateEventData(void* data);
+  double GetCurrentTime() { return current_time_; }
+  void GetMediaDeviceList(Ewk_Media_Device_List_Get_Callback callback,
+                          void* userData);
+  using MediaDeviceEnumeration =
+      std::array<blink::WebMediaDeviceInfoArray, NUM_MEDIA_DEVICE_TYPES>;
+  void OnDeviceListed(const MediaDeviceEnumeration& devices);
+  void SetTranslatedURL(const char* url);
+  void NotifyParentalRatingInfo(const char* info, const char* url);
+  void SetParentalRatingResult(const char* info, bool is_pass);
 #endif  // IS_TIZEN_TV
 
   void SetDidChangeThemeColorCallback(
@@ -758,15 +860,7 @@ class EWebView {
   void InitInspectorServer();
 
   void RunPendingSetFocus(Eina_Bool focus);
-#endif
-
-#if BUILDFLAG(IS_TIZEN) && !defined(EWK_BRINGUP)
-  static void cameraResultCb(service_h request,
-                             service_h reply,
-                             service_result_e result,
-                             void* data);
-
-  bool LaunchCamera(std::u16string mimetype);
+  void SetFocusInternal(Eina_Bool focus);
 #endif
 
   JavaScriptDialogManagerEfl* GetJavaScriptDialogManagerEfl();
@@ -791,8 +885,6 @@ class EWebView {
                       const base::FilePath& file_path,
                       int64_t file_size);
 
-  static void OnViewFocusIn(void* data, Evas*, Evas_Object*, void*);
-  static void OnViewFocusOut(void* data, Evas*, Evas_Object*, void*);
   static void VisibleContentChangedCallback(void* user_data,
                                             Evas_Object* object,
                                             void* event_info);
@@ -808,16 +900,17 @@ class EWebView {
 
   static Eina_Bool DelayedPopulateAndShowContextMenu(void* data);
 
-  scoped_refptr<WebViewEvasEventHandler> evas_event_handler_;
   scoped_refptr<Ewk_Context> context_;
   std::unique_ptr<content::WebContents> web_contents_;
   std::unique_ptr<content::WebContentsDelegateEfl> web_contents_delegate_;
+  std::unique_ptr<content::WebViewDelegate> webview_delegate_;
   std::string pending_url_request_;
   std::unique_ptr<Ewk_Settings> settings_;
   std::unique_ptr<_Ewk_Frame> frame_;
   std::unique_ptr<_Ewk_Policy_Decision> window_policy_;
-  Evas_Object* evas_object_;
-  Evas_Object* native_view_;
+  Evas_Object* ewk_view_;
+  Evas_Object* efl_main_layout_;
+  bool key_events_enabled_ = true;
   bool mouse_events_enabled_;
   double text_zoom_factor_;
   mutable std::string user_agent_;
@@ -826,7 +919,9 @@ class EWebView {
   std::string selected_text_cached_;
 
   std::unique_ptr<content::ContextMenuControllerEfl> context_menu_;
-#if !defined(EWK_BRINGUP)  // FIXME: m71 bringup
+#if BUILDFLAG(IS_TIZEN_TV)
+  std::unique_ptr<_Ewk_File_Chooser_Request> file_chooser_request_;
+#else
   std::unique_ptr<content::FileChooserControllerEfl> file_chooser_;
 #endif
   std::unique_ptr<content::PopupControllerEfl> popup_controller_;
@@ -842,6 +937,10 @@ class EWebView {
       MHTMLCallbackDetails;
   base::IDMap<MHTMLCallbackDetails*> mhtml_callback_map_;
 
+#if BUILDFLAG(IS_TIZEN_TV)
+  base::IDMap<IsVideoPlayingCallback*> is_video_playing_callback_map_;
+#endif
+
   typedef WebViewCallback<Ewk_View_Main_Frame_Scrollbar_Visible_Get_Callback,
                           bool>
       MainFrameScrollbarVisibleGetCallback;
@@ -850,6 +949,10 @@ class EWebView {
 
   base::IDMap<BackgroundColorGetCallback*> background_color_get_callback_map_;
 
+#if BUILDFLAG(IS_TIZEN_TV)
+  GetMediaDeviceCallback device_cb_;
+#endif
+
   gfx::Size contents_size_;
   double progress_;
   mutable std::string title_;
@@ -908,29 +1011,43 @@ class EWebView {
       long long>
       exceeded_indexed_db_quota_callback_;
   std::unique_ptr<Ewk_Security_Origin> exceeded_indexed_db_quota_origin_;
-
+#if !defined(EWK_BRINGUP)  // FIXME: m114 bringup
   std::map<const _Ewk_Quota_Permission_Request*,
            content::QuotaPermissionContext::PermissionCallback>
       quota_permission_request_map_;
-
+#endif
 #if BUILDFLAG(IS_TIZEN)
-  blink::mojom::FileChooserParams::Mode filechooser_mode_;
+  blink::mojom::FileChooserParams::Mode filechooser_mode_ =
+      blink::mojom::FileChooserParams::Mode::kOpen;
   Ecore_Event_Handler* window_rotate_handler_ = nullptr;
 #endif
 
   bool is_initialized_;
 
 #if BUILDFLAG(IS_TIZEN_TV)
+  bool is_processing_edge_scroll_;
   bool use_early_rwi_;
   bool rwi_info_showed_;
   GURL rwi_gurl_;
+  bool is_high_bitrate_ = false;
 
   base::OnceClosure pending_setfocus_closure_;
+
+  enum PlaybackState {
+    kPlaybackLoad = 0,
+    // kPlaybackReady: player with both audio and video starts prepare and will
+    // acquire audio and video resources (if they are not already taken)
+    kPlaybackReady,
+    kPlaybackStart,
+    kPlaybackFinish,
+    kPlaybackStop,
+  };
+  double current_time_ = 0.0;
 #endif
 
   std::unique_ptr<_Ewk_Back_Forward_List> back_forward_list_;
 
-  static content::WebContentsEflDelegate::WebContentsCreateCallback
+  static content::WebViewDelegate::WebContentsCreateCallback
       create_new_window_web_contents_cb_;
 
 #if defined(TIZEN_VIDEO_HOLE)
@@ -959,11 +1076,15 @@ class EWebView {
   std::unique_ptr<EWebAccessibility> eweb_accessibility_;
   bool lazy_initialize_atk_ = false;
 #endif
+#if defined(TIZEN_PEPPER_EXTENSIONS)
+  content::ExtensionSystemDelegateManager::RenderFrameID render_frame_id_;
+#endif
 #if defined(TIZEN_VIDEO_HOLE)
   bool pending_video_hole_setting_ = false;
 #endif
 
   Ecore_Timer* delayed_show_context_menu_timer_ = nullptr;
+  base::WeakPtrFactory<EWebView> weak_factory_{this};
 };
 
 const unsigned int g_default_tilt_motion_sensitivity = 3;