[M120 Migration][hbbtv] Audio tracks count notification
[platform/framework/web/chromium-efl.git] / tizen_src / ewk / efl_integration / web_contents_delegate_efl.cc
index 19a2a08..01f2d66 100644 (file)
@@ -138,18 +138,15 @@ WebContentsDelegateEfl::WebContentsDelegateEfl(EWebView* view)
     AutofillClientEfl::CreateForWebContents(&web_contents_);
     AutofillClientEfl* autofill_client =
         AutofillClientEfl::FromWebContents(&web_contents_);
-    autofill_client->SetEWebView(view);
+    if (autofill_client)
+      autofill_client->SetEWebView(view);
     PasswordManagerClientEfl::CreateForWebContentsWithAutofillClient(
         &web_contents_, autofill_client);
-    ContentAutofillDriverFactory::CreateForWebContentsAndDelegate(
-        &web_contents_, autofill_client,
-        base::BindRepeating(&autofill::BrowserDriverInitHook, autofill_client,
-                            EWebView::GetPlatformLocale()));
   }
 #if defined(TIZEN_AUTOFILL_FW)
   LOG(INFO) << "[Autofill] " << __FUNCTION__ << " Create AutofillRequest";
   autofill::AutofillRequestManager::GetInstance()->CreateAutofillRequest(
-      view->evas_object());
+      view->ewk_view());
 #endif
 #endif
 }
@@ -199,7 +196,7 @@ WebContents* WebContentsDelegateEfl::OpenURLFromTab(
       ActivateContents(source);
 
     EWebView* wv =
-        WebViewDelegateEwk::GetInstance().GetWebViewFromEvasObject(new_object);
+        WebViewDelegateEwk::GetInstance().GetEWebViewFromEwkView(new_object);
     DCHECK(wv);
     wv->SetURL(url);
     return NULL;
@@ -211,6 +208,23 @@ WebContents* WebContentsDelegateEfl::OpenURLFromTab(
   return source;
 }
 
+#if BUILDFLAG(IS_TIZEN_TV)
+void WebContentsDelegateEfl::NotifyMediaStateChanged(uint32_t type,
+                                                     uint32_t previous,
+                                                     uint32_t current) {
+  if (!web_view_) {
+    LOG(ERROR) << "web_view_ is null";
+    return;
+  }
+
+  web_view_->NotifyMediaStateChanged(type, previous, current);
+}
+
+void WebContentsDelegateEfl::GetMediaDeviceList(EnumerationCallback cb) {
+  MediaCaptureDevices::GetInstance()->GetMediaDeviceList(std::move(cb));
+}
+#endif
+
 void WebContentsDelegateEfl::NavigationStateChanged(
     WebContents* source, InvalidateTypes changed_flags) {
   // We always notfiy clients about title invalidation, even if its text
@@ -233,11 +247,11 @@ void WebContentsDelegateEfl::NavigationStateChanged(
     web_view_->ResetContextMenuController();
     auto rwhva = static_cast<RenderWidgetHostViewAura*>(
         web_contents_.GetRenderWidgetHostView());
-    if (rwhva) {
-      auto selection_controller =
-          rwhva->offscreen_helper()->GetSelectionController();
-      if (selection_controller)
+    if (rwhva && rwhva->offscreen_helper()) {
+      if (auto selection_controller =
+              rwhva->offscreen_helper()->GetSelectionController()) {
         selection_controller->ClearSelection();
+      }
     }
   }
 }
@@ -405,21 +419,22 @@ void WebContentsDelegateEfl::RequestCertificateConfirm(
     bool /*strict_enforcement*/,
     base::OnceCallback<void(CertificateRequestResultType)> callback) {
   std::string pem_certificate;
+  const GURL request_url(url);
   if (!net::X509Certificate::GetPEMEncoded(ssl_info.cert->cert_buffer(),
                                            &pem_certificate)) {
-    LOG(INFO) << "Certificate for URL: " << url.spec()
+    LOG(INFO) << "Certificate for URL: " << request_url.spec()
               << " could not be opened";
     std::move(callback).Run(content::CERTIFICATE_REQUEST_RESULT_TYPE_CANCEL);
     return;
   }
   certificate_policy_decision_.reset(new _Ewk_Certificate_Policy_Decision(
-      url, pem_certificate, is_main_frame_request, cert_error,
+      request_url, pem_certificate, is_main_frame_request, cert_error,
       std::move(callback)));
 
   web_view_->SmartCallback<EWebViewCallbacks::RequestCertificateConfirm>().call(
       certificate_policy_decision_.get());
-  LOG(INFO) << "Certificate policy decision called for URL: " << url.spec()
-            << " with cert_error: " << cert_error;
+  LOG(INFO) << "Certificate policy decision called for URL: "
+            << request_url.spec() << " with cert_error: " << cert_error;
 
   // if policy is suspended, the API takes over the policy object lifetime
   // and policy will be deleted after decision is made
@@ -440,7 +455,8 @@ void WebContentsDelegateEfl::RequestCertificateConfirm(
       // By default chromium-efl allows page to be opened with certificate
       // compromise.
       certificate_policy_decision_->SetDecision(true);
-      LOG(WARNING) << "Certificate for " << url.spec() << " was compromised";
+      LOG(WARNING) << "Certificate for " << request_url.spec()
+                   << " was compromised";
     }
   }
 }
@@ -633,7 +649,7 @@ void WebContentsDelegateEfl::RunFileChooser(
     RenderFrameHost* render_frame_host,
     scoped_refptr<FileSelectListener> listener,
     const blink::mojom::FileChooserParams& params) {
-  web_view_->ShowFileChooser(render_frame_host, params);
+  web_view_->ShowFileChooser(std::move(listener), params);
 }
 
 std::unique_ptr<ColorChooser> WebContentsDelegateEfl::OpenColorChooser(
@@ -755,10 +771,158 @@ void WebContentsDelegateEfl::UpdateTargetURL(WebContents* /*source*/,
   // Update latest hovered url.
   last_hovered_url_ = absolute_link_url;
 }
+
+void WebContentsDelegateEfl::UpdateCurrentTime(double current_time) {
+  web_view_->UpdateCurrentTime(current_time);
+}
+
+void WebContentsDelegateEfl::UpdateEventData(void* data) {
+  web_view_->UpdateEventData(data);
+}
+
+void WebContentsDelegateEfl::NotifySubtitleState(int state, double time_stamp) {
+  web_view_->NotifySubtitleState(state, time_stamp);
+}
+
+void WebContentsDelegateEfl::NotifySubtitlePlay(int active_track_id,
+                                                const std::string& url,
+                                                const std::string& lang) {
+  web_view_->NotifySubtitlePlay(active_track_id, url.c_str(), lang.c_str());
+}
+
+void WebContentsDelegateEfl::NotifySubtitleData(int track_id,
+                                                double time_stamp,
+                                                const std::string& data,
+                                                unsigned int size) {
+  web_view_->NotifySubtitleData(track_id, time_stamp, data, size);
+}
+
+void WebContentsDelegateEfl::NotifyFirstTimeStamp(unsigned long long timestamp,
+                                                  int time_base_num,
+                                                  int time_base_den) {
+  return web_view_->NotifyFirstTimeStamp(timestamp, time_base_num,
+                                         time_base_den);
+}
+
+void WebContentsDelegateEfl::NotifyPESData(const std::string& buf,
+                                           unsigned int len,
+                                           int media_position) {
+  return web_view_->NotifyPESData(buf, len, media_position);
+}
 #endif
 
 void WebContentsDelegateEfl::OnGetMainFrameScrollbarVisible(int callback_id,
                                                             bool visible) {
   web_view_->InvokeMainFrameScrollbarVisibleCallback(callback_id, visible);
 }
+
+#if BUILDFLAG(IS_TIZEN_TV)
+void WebContentsDelegateEfl::DidEdgeScrollBy(const gfx::Point& offset,
+    bool handled) {
+  if (web_view_)
+    web_view_->InvokeEdgeScrollByCallback(offset, handled);
+}
+
+void WebContentsDelegateEfl::MoveFocusToBrowser(int direction) {
+  if (web_view_) {
+    web_view_->SmartCallback<EWebViewCallbacks::AtkKeyEventNotHandled>().call(
+        &direction);
+  }
+}
+
+void WebContentsDelegateEfl::WillDraw(int new_rotation,
+                                      gfx::Size frame_data_output_size) {
+  if (web_view_) {
+    if (web_view_->GetRotationChanged()) {
+      web_view_->SetRotationChanged(false);
+      LOG(ERROR) << __func__ << " frame_data_output_size "
+                 << frame_data_output_size.ToString() << " new rotation "
+                 << new_rotation;
+      web_view_->SmartCallback<EWebViewCallbacks::RotatePrepared>().call(0);
+    }
+  }
+}
+
+bool WebContentsDelegateEfl::IsHighBitRate() const {
+  return web_view_ ? web_view_->IsHighBitRate() : false;
+}
+
+void WebContentsDelegateEfl::NotifyParentalRatingInfo(const std::string& info,
+                                                      const std::string& url) {
+  if (web_view_)
+    web_view_->NotifyParentalRatingInfo(info.c_str(), url.c_str());
+  else
+    LOG(ERROR) << "web_view_ is null";
+}
+
+void WebContentsDelegateEfl::NotifyDownloadableFontInfo(
+    const std::string& scheme_id_uri,
+    const std::string& value,
+    const std::string& data,
+    int type) {
+  if (!web_view_)
+    return;
+  web_view_->NotifyDownloadableFontInfo(scheme_id_uri.c_str(), value.c_str(),
+                                        data.c_str(), type);
+}
+
+void WebContentsDelegateEfl::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) {
+  if (!web_view_)
+    return;
+  std::vector<std::string> data = web_view_->NotifyPlaybackState(
+      state, player_id, url.empty() ? "" : url.c_str(),
+      mime_type.empty() ? "" : mime_type.c_str());
+  if (data.size()) {
+    if (media_resource_acquired)
+      *media_resource_acquired = !data.at(0).empty() ? true : false;
+    if (translated_url)
+      *translated_url = data.at(1);
+    if (drm_info)
+      *drm_info = data.at(2);
+  }
+}
+
+void WebContentsDelegateEfl::NotifyAudioTracksCount(
+    int player_id,
+    unsigned audio_tracks_count) {
+  if (web_view_)
+    web_view_->NotifyAudioTracksCount(player_id, audio_tracks_count);
+  else
+    LOG(INFO) << "web_view_ is null";
+}
+
+void WebContentsDelegateEfl::OnIsVideoPlayingGet(bool is_playing,
+                                                 int callback_id) {
+  if (web_view_)
+    web_view_->InvokeIsVideoPlayingCallback(is_playing, callback_id);
+  else
+    LOG(INFO) << "web_view_ is null";
+}
+
+void WebContentsDelegateEfl::VideoPlayingStatusReceived(bool is_playing,
+                                                        int callback_id) {
+  if (web_view_)
+    web_view_->InvokeIsVideoPlayingCallback(is_playing, callback_id);
+  else
+    LOG(INFO) << "web_view_ is null";
+}
+#endif
+
+void WebContentsDelegateEfl::UpdateTooltipUnderCursor(
+    const std::u16string& text) {
+  std::string tooltip = base::UTF16ToUTF8(text);
+  LOG(INFO) << __func__ << " " << tooltip.c_str();
+  if (tooltip.empty()) {
+    web_view_->SmartCallback<EWebViewCallbacks::TooltipTextUnset>().call();
+  } else {
+    web_view_->SmartCallback<EWebViewCallbacks::TooltipTextSet>().call(
+        tooltip.c_str());
+  }
+}
 }  // namespace content