Implement |capture| attr support on HTMLInputElement.
authormsu.koo <msu.koo@samsung.com>
Mon, 26 May 2014 13:34:59 +0000 (22:34 +0900)
committerYoungsoo Choi <kenshin.choi@samsung.com>
Tue, 10 Jul 2018 06:57:09 +0000 (06:57 +0000)
1) Activate |capture| attribute on WebCore.
2) Implement codes to launch the camera app from browser.

Issue: CBMM-87, CBMM-89, CBMM-101
Change-Id: I4ecc0c9812b46b4d9c8aed23152bf5597f984ef2

Conflicts:

impl/eweb_view.h

tizen_src/impl/eweb_view.cc
tizen_src/impl/eweb_view.h

index 99de3fa8f73a0e86c67e7f840ada9dc01897ee7f..3a44a7deb46dcc75be32512e0135fa9718c1836d 100644 (file)
@@ -790,11 +790,11 @@ void EWebView::ProcessAckedTouchEvent(const TouchEventWithLatencyInfo& touch,
     return;
 
   ui::EventResult result = (ack_result == INPUT_EVENT_ACK_STATE_CONSUMED) ?
-         ui::ER_HANDLED : ui::ER_UNHANDLED;
+      ui::ER_HANDLED : ui::ER_UNHANDLED;
   for (ScopedVector<ui::TouchEvent>::const_iterator iter = events.begin(),
       end = events.end(); iter != end; ++iter)  {
     scoped_ptr<ui::GestureRecognizer::Gestures> gestures(
-       gesture_recognizer_->ProcessTouchEventForGesture(*(*iter), result, this));
+        gesture_recognizer_->ProcessTouchEventForGesture(*(*iter), result, this));
     if (gestures) {
       for (size_t j = 0; j < gestures->size(); ++j) {
         ui::GestureEvent* event = gestures->get().at(j);
@@ -1614,7 +1614,18 @@ void EWebView::ShowFileChooser(const content::FileChooserParams& params) {
   RenderViewHost* render_view_host = web_contents_delegate()->web_contents()->GetRenderViewHost();
   if (!render_view_host)
     return;
-
+#if defined(OS_TIZEN_MOBILE)
+  //If capture type is camcorder, launch camera instead of file chooser.
+  if (params.capture) {
+    std::vector<base::string16>::iterator it;
+    std::vector<base::string16> accept_types = params.accept_types;
+    it = accept_types.begin();
+    base::string16 filechoosertype = *it;
+    filechooser_mode_ = params.mode;
+    LaunchCamera(filechoosertype);
+    return;
+  }
+#endif
   file_chooser_.reset(new content::FileChooserControllerEfl(render_view_host, &params));
   file_chooser_->open();
 }
@@ -1698,3 +1709,69 @@ std::string EWebView::GetErrorPage(const std::string& invalidUrl) {
     ;
    return html;
 }
+
+#if defined(OS_TIZEN_MOBILE)
+void EWebView::cameraResultCb(service_h request,
+                              service_h reply,
+                              service_result_e result,
+                             void* data)
+{
+  EWebView* webview = static_cast<EWebView*>(data);
+  if (result == SERVICE_RESULT_SUCCEEDED) {
+    int ret = -1;
+    char** filesarray;
+    int number;
+    ret =service_get_extra_data_array(reply, SERVICE_DATA_SELECTED,
+      &filesarray,&number);
+    if (filesarray) {
+      for(int i =0; i< number;i++) {
+        std::vector<ui::SelectedFileInfo> files;
+        RenderViewHost* render_view_host = webview->web_contents_delegate()->
+          web_contents()->GetRenderViewHost();
+        if (!render_view_host) {
+          return;
+        }
+        if (filesarray[i]) {
+          GURL url(filesarray[i]);
+          if (!url.is_valid()) {
+            base::FilePath path(url.SchemeIsFile() ? url.path() :
+              filesarray[i]);
+            files.push_back(ui::SelectedFileInfo(path, base::FilePath()));
+          }
+        }
+        render_view_host->FilesSelectedInChooser(files,
+          webview->filechooser_mode_);
+      }
+    }
+  } else {
+    RenderViewHost* render_view_host = webview->web_contents_delegate()->
+      web_contents()->GetRenderViewHost();
+    std::vector<ui::SelectedFileInfo> files;
+    if (render_view_host) {
+      render_view_host->FilesSelectedInChooser(files,
+        webview->filechooser_mode_);
+    }
+  }
+}
+
+bool EWebView::LaunchCamera(base::string16 mimetype)
+{
+  service_h svcHandle = 0;
+  if (service_create(&svcHandle) < 0 || !svcHandle) {
+    LOG(ERROR) << __FUNCTION__ << " Service Creation Failed ";
+    return false;
+  }
+  service_set_operation(svcHandle, SERVICE_OPERATION_CREATE_CONTENT);
+  service_set_mime(svcHandle, UTF16ToUTF8(mimetype).c_str());
+  service_add_extra_data(svcHandle, "CALLER", "Browser");
+
+  int ret = service_send_launch_request(svcHandle, cameraResultCb, this);
+  if (ret != SERVICE_ERROR_NONE) {
+    LOG(ERROR) << __FUNCTION__ << " Service Launch Failed ";
+    service_destroy(svcHandle);
+    return false;
+  }
+  service_destroy(svcHandle);
+  return true;
+}
+#endif
index 4d97fbffc35e8b351ae45e2d28699257e723d19c..f6c0ba18374af8d66c4e00289b8e63248682625c 100644 (file)
 #ifndef EWEB_VIEW_H
 #define EWEB_VIEW_H
 
+#if defined(OS_TIZEN_MOBILE)
+#include <appfw/app_service.h>
+#include <vector>
+#endif
+
 #include <map>
 #include <string>
 #include <Evas.h>
@@ -302,6 +307,10 @@ class EWebView
   static void OnTouchDown(void*, Evas*, Evas_Object*, void*);
   static void OnTouchUp(void*, Evas*, Evas_Object*, void*);
   static void OnTouchMove(void*, Evas*, Evas_Object*, void*);
+#if defined(OS_TIZEN_MOBILE)
+  static void cameraResultCb(service_h request, service_h reply,
+    service_result_e result, void* data);
+#endif
 
   void HandleTouchEvents(Ewk_Touch_Event_Type);
 
@@ -325,6 +334,9 @@ class EWebView
   virtual void DispatchCancelTouchEvent(ui::TouchEvent* event) OVERRIDE;
   virtual void DispatchGestureEvent(ui::GestureEvent*) OVERRIDE;
 
+#if defined(OS_TIZEN_MOBILE)
+  bool LaunchCamera(base::string16 mimetype);
+#endif
   content::RenderWidgetHostViewEfl* rwhv() const;
   JavaScriptDialogManagerEfl* GetJavaScriptDialogManagerEfl();
 
@@ -389,6 +401,9 @@ class EWebView
 #ifndef NDEBUG
   bool renderer_crashed_;
 #endif
+#if defined(OS_TIZEN_MOBILE)
+  content::FileChooserParams::Mode filechooser_mode_;
+#endif
 };
 
 bool IsEWebViewObject(const Evas_Object*);