From: msu.koo Date: Mon, 26 May 2014 13:34:59 +0000 (+0900) Subject: Implement |capture| attr support on HTMLInputElement. X-Git-Tag: submit/tizen/20190801.160004~2623 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c1691d11e551a8c482505c7d6cf01de3b81d3e61;p=platform%2Fframework%2Fweb%2Fchromium-efl.git Implement |capture| attr support on HTMLInputElement. 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 --- diff --git a/tizen_src/impl/eweb_view.cc b/tizen_src/impl/eweb_view.cc index 99de3fa8f73a..3a44a7deb46d 100644 --- a/tizen_src/impl/eweb_view.cc +++ b/tizen_src/impl/eweb_view.cc @@ -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::const_iterator iter = events.begin(), end = events.end(); iter != end; ++iter) { scoped_ptr 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::iterator it; + std::vector 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, ¶ms)); 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(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 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 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 diff --git a/tizen_src/impl/eweb_view.h b/tizen_src/impl/eweb_view.h index 4d97fbffc35e..f6c0ba18374a 100644 --- a/tizen_src/impl/eweb_view.h +++ b/tizen_src/impl/eweb_view.h @@ -20,6 +20,11 @@ #ifndef EWEB_VIEW_H #define EWEB_VIEW_H +#if defined(OS_TIZEN_MOBILE) +#include +#include +#endif + #include #include #include @@ -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*);