dpl-wrt-dao-ro
wrt-commons-auto-save-dao-rw
wrt-commons-security-origin-dao
+ wrt-commons-certificate-dao
wrt-popup-wrt-runner
REQUIRED
)
${PROJECT_SOURCE_DIR}/src/view/common/view_logic_uri_support.cpp
${PROJECT_SOURCE_DIR}/src/view/common/view_logic_user_agent_support.cpp
${PROJECT_SOURCE_DIR}/src/view/common/view_logic_vibration_support.cpp
+ ${PROJECT_SOURCE_DIR}/src/view/common/view_logic_certificate_support.cpp
)
SET(VIEW_COMMON_INCLUDES
--- /dev/null
+/*\r
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+/**\r
+ * @file view_logic_certificate_origin_support.cpp\r
+ * @author Leerang Song (leerang.song@samsung.com)\r
+ * @version 1.0\r
+ * @brief Support certificate dao\r
+ */\r
+\r
+#include "view_logic_certificate_support.h"\r
+\r
+#include <memory>\r
+#include <Evas.h>\r
+#include <Elementary.h>\r
+#include <vconf.h>\r
+#include <dpl/log/log.h>\r
+#include <dpl/assert.h>\r
+#include <dpl/wrt-dao-ro/common_dao_types.h>\r
+#include <dpl/wrt-dao-ro/vconf_config.h>\r
+#include <wrt-commons/certificate-dao/certificate_dao.h>\r
+#include <widget_model.h>\r
+\r
+namespace ViewModule {\r
+namespace {\r
+const char* const DAEMON_EDJ_PATH = "/usr/share/edje/wrt/Daemon.edj";\r
+}\r
+\r
+class CertificateSupportImplementation\r
+{\r
+ private:\r
+ WidgetModel* m_model;\r
+ CertificateDB::CertificateDAOPtr m_certificateDAO;\r
+\r
+ public:\r
+ CertificateSupportImplementation(WidgetModel* widgetModel) :\r
+ m_model(NULL)\r
+ {\r
+ Assert(widgetModel);\r
+ m_model = widgetModel;\r
+ }\r
+\r
+ ~CertificateSupportImplementation()\r
+ {}\r
+\r
+ CertificateDB::CertificateDAO* getCertificateDAO(void)\r
+ {\r
+ Assert(m_model);\r
+ if (!m_certificateDAO) {\r
+ LogDebug("initialize CertificateDAO");\r
+ m_certificateDAO =\r
+ CertificateDB::CertificateDAOPtr(\r
+ new CertificateDB::CertificateDAO(m_model->TzPkgId.\r
+ Get()));\r
+ // initialize certificate result data. Remove allow, deny for\r
+ m_certificateDAO->removeCertificateData(\r
+ CertificateDB::RESULT_ALLOW_ONCE);\r
+ m_certificateDAO->removeCertificateData(\r
+ CertificateDB::RESULT_DENY_ONCE);\r
+ }\r
+ return m_certificateDAO.get();\r
+ }\r
+};\r
+\r
+CertificateSupport::CertificateSupport(WidgetModel* widgetModel) :\r
+ m_impl(new CertificateSupportImplementation(widgetModel))\r
+{}\r
+\r
+CertificateSupport::~CertificateSupport()\r
+{}\r
+\r
+CertificateDB::CertificateDAO* CertificateSupport::\r
+ getCertificateDAO(void)\r
+{\r
+ return m_impl->getCertificateDAO();\r
+}\r
+\r
+Evas_Object* CertificateSupportUtil::createPopup(\r
+ Evas_Object* window,\r
+ const char* bodyText,\r
+ const char* checkText,\r
+ Evas_Smart_Cb\r
+ buttonCallback,\r
+ void* data)\r
+{\r
+ LogDebug("createPopup");\r
+ Evas_Object* popup = elm_popup_add(window);\r
+\r
+ Evas_Object* label = elm_label_add(popup);\r
+ elm_object_style_set(label, "popup/default");\r
+ elm_label_line_wrap_set(label, ELM_WRAP_MIXED);\r
+ elm_object_text_set(label, bodyText);\r
+ evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, 0.0);\r
+ evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL);\r
+ evas_object_show(label);\r
+\r
+ Evas_Object* layout = elm_layout_add(popup);\r
+ elm_layout_file_set(layout, DAEMON_EDJ_PATH, "popupWithCheck");\r
+ evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);\r
+\r
+ Evas_Object* check = elm_check_add(popup);\r
+ evas_object_size_hint_align_set(check, EVAS_HINT_FILL, EVAS_HINT_FILL);\r
+ evas_object_size_hint_weight_set(check, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);\r
+ evas_object_show(check);\r
+\r
+ elm_object_part_text_set(layout, "elm.text", checkText);\r
+ elm_object_part_content_set(layout, "elm.swallow.content", label);\r
+ elm_object_part_content_set(layout, "elm.swallow.end", check);\r
+\r
+ evas_object_show(layout);\r
+ elm_object_content_set(popup, layout);\r
+ Evas_Object* btn1 = elm_button_add(popup);\r
+ elm_object_text_set(btn1, "YES");\r
+ elm_object_part_content_set(popup, "button1", btn1);\r
+ evas_object_smart_callback_add(btn1, "clicked", buttonCallback, data);\r
+ Evas_Object* btn2 = elm_button_add(popup);\r
+ elm_object_text_set(btn2, "NO");\r
+ elm_object_part_content_set(popup, "button2", btn2);\r
+ evas_object_smart_callback_add(btn2, "clicked", buttonCallback, data);\r
+ return popup;\r
+}\r
+\r
+Evas_Object* CertificateSupportUtil::getPopup(Evas_Object* button)\r
+{\r
+ Assert(button);\r
+\r
+ Evas_Object* popup = button;\r
+ while (strcmp(elm_object_widget_type_get(popup), "elm_popup")) {\r
+ popup = elm_object_parent_widget_get(popup);\r
+ if (!popup) {\r
+ return NULL;\r
+ }\r
+ }\r
+ return popup;\r
+}\r
+\r
+Evas_Object* CertificateSupportUtil::getCheck(Evas_Object* popup)\r
+{\r
+ Assert(popup);\r
+ if (strcmp(elm_object_widget_type_get(popup), "elm_popup")) {\r
+ return NULL;\r
+ }\r
+ Evas_Object* check = elm_object_part_content_get(\r
+ elm_object_content_get(popup),\r
+ "elm.swallow.end");\r
+ return check;\r
+}\r
+\r
+CertificateDB::Result CertificateSupportUtil::getResult(\r
+ Evas_Object* button)\r
+{\r
+ using namespace CertificateDB;\r
+\r
+ Assert(button);\r
+ // get popup evas_object\r
+ Evas_Object* popup = getPopup(button);\r
+ if (popup == NULL) {\r
+ return RESULT_UNKNOWN;\r
+ }\r
+ bool allow = !strcmp("YES", elm_object_text_get(button));\r
+\r
+ // get check evas_object\r
+ Evas_Object* check = getCheck(popup);\r
+ if (check == NULL) {\r
+ return RESULT_UNKNOWN;\r
+ }\r
+ if (allow) {\r
+ return elm_check_state_get(check) ? RESULT_ALLOW_ALWAYS :\r
+ RESULT_ALLOW_ONCE;\r
+ } else {\r
+ return elm_check_state_get(check) ? RESULT_DENY_ALWAYS :\r
+ RESULT_DENY_ONCE;\r
+ }\r
+}\r
+} // namespace ViewModule\r
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file view_logic_certificate_origin_support.h
+ * @author Leerang Song (leerang.song@samsung.com)
+ * @version 1.0
+ * @brief Header file for certificate
+ */
+
+#ifndef VIEW_LOGIC_CERTIFICATE_SUPPORT_H_
+#define VIEW_LOGIC_CERTIFICATE_SUPPORT_H_
+
+#include <memory>
+#include <Evas.h>
+#include <Elementary.h>
+#include <dpl/wrt-dao-ro/common_dao_types.h>
+#include <wrt-commons/certificate-dao/certificate_dao.h>
+
+class WidgetModel;
+namespace CertificateDB {
+class CertificateDAO;
+}
+
+namespace ViewModule {
+class CertificateSupportImplementation;
+
+class CertificateSupport
+{
+ public:
+ CertificateSupport(WidgetModel* widgetModel);
+ virtual ~CertificateSupport();
+ CertificateDB::CertificateDAO* getCertificateDAO();
+
+ private:
+ std::unique_ptr<CertificateSupportImplementation> m_impl;
+};
+
+namespace CertificateSupportUtil {
+class PermissionData
+{
+ public:
+ CertificateDB::CertificateDAO* m_certiDao;
+ CertificateDB::CertificateData m_certiData;
+ void* m_data;
+
+ PermissionData(
+ CertificateDB::CertificateDAO* certiDao,
+ CertificateDB::CertificateData certiData,
+ void* data) :
+ m_certiDao(certiDao),
+ m_certiData(certiData),
+ m_data(data)
+ {}
+};
+
+Evas_Object* createPopup(Evas_Object* window,
+ const char* bodyText,
+ const char* checkText,
+ Evas_Smart_Cb buttonCallback,
+ void* data);
+Evas_Object* getPopup(Evas_Object* button);
+Evas_Object* getCheck(Evas_Object* popup);
+CertificateDB::Result getResult(Evas_Object* button);
+};
+} // namespace ViewModule
+
+#endif // VIEW_LOGIC_CERTIFICATE_SUPPORT_H_
\ No newline at end of file
${PROJECT_SOURCE_DIR}/src/view/webkit/view_logic_usermedia_support.cpp
${PROJECT_SOURCE_DIR}/src/view/webkit/view_logic_web_notification_support.cpp
${PROJECT_SOURCE_DIR}/src/view/webkit/bundles/plugin_module_support.cpp
+ ${PROJECT_SOURCE_DIR}/src/view/webkit/view_logic_certificate_confirm_support.cpp
${VIEW_MODULE_SOURCES}
)
#include <common/view_logic_password_support.h>
#include <common/view_logic_security_support.h>
#include <common/view_logic_security_origin_support.h>
+#include <common/view_logic_certificate_support.h>
#include <common/view_logic_storage_support.h>
#include <common/view_logic_uri_support.h>
#include <common/view_logic_user_agent_support.h>
#include <view_logic_geolocation_support_webkit2.h>
#include <view_logic_usermedia_support.h>
#include <view_logic_web_notification_support.h>
+
+#include <view_logic_certificate_confirm_support.h>
#include "bundles/plugin_module_support.h"
#include <popup-runner/PopupInvoker.h>
ViewModule::StorageSupport::initializeStorage(m_model);
m_appsSupport->initialize(m_model);
m_securityOriginSupport.reset(new ViewModule::SecurityOriginSupport(m_model));
+ m_certificateSupport.reset(new ViewModule::CertificateSupport(m_model));
m_vibrationSupport->initialize();
}
Assert(data);
ViewLogic* This = static_cast<ViewLogic*>(data);
Assert(eventInfo);
- Ewk_Certificate_Policy_Decision* certificatePolicyDecision =
- static_cast<Ewk_Certificate_Policy_Decision*>(eventInfo);
-
- bool status = This->askUserForCertificateConfirm();
- if (!status) {
- ewk_certificate_policy_decision_allowed_set(
- certificatePolicyDecision,
- EINA_FALSE);
- } else {
- ewk_certificate_policy_decision_allowed_set(
- certificatePolicyDecision,
- EINA_TRUE);
- }
-}
-
-bool ViewLogic::askUserForCertificateConfirm()
-{
- return Wrt::Popup::PopupInvoker().askYesNo(
- CERTIFICATE_CONFIRM_REQUEST_ASK_TITLE,
- CERTIFICATE_CONFIRM_REQUEST_ASK_BODY);
+ ViewModule::CertificateConfirmSupport::certificatePermissionRequest(
+ This->m_window,
+ This->m_certificateSupport->getCertificateDAO(),
+ eventInfo);
}
void ViewLogic::authenticationChallengeRequestCallback(
class SchemeSupport;
namespace ViewModule {
class SecurityOriginSupport;
+class CertificateSupport;
}
class ViewLogic : public ViewModule::IViewModule
std::unique_ptr<ViewModule::AppsSupport> m_appsSupport;
std::unique_ptr<ViewModule::VibrationSupport> m_vibrationSupport;
std::unique_ptr<ViewModule::SecurityOriginSupport> m_securityOriginSupport;
-
+ std::unique_ptr<ViewModule::CertificateSupport> m_certificateSupport;
+
static std::map<const std::string, const Evas_Smart_Cb> m_ewkCallbacksMap;
};
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file view_logic_certificate_confirm_support.cpp
+ * @author Leerang Song (leerang.song@samsung.com)
+ */
+
+#include "view_logic_certificate_confirm_support.h"
+
+#include <string>
+#include <sstream>
+#include <dpl/log/log.h>
+#include <dpl/assert.h>
+#include <wrt-commons/certificate-dao/certificate_dao_types.h>
+#include <wrt-commons/certificate-dao/certificate_dao.h>
+#include <EWebKit2.h>
+#include <common/view_logic_certificate_support.h>
+#include <Elementary.h>
+
+namespace ViewModule {
+namespace CertificateConfirmSupport {
+using namespace CertificateDB;
+using namespace ViewModule::CertificateSupportUtil;
+
+namespace {
+const char* const CERTIFICATION_ASK_BODY =
+ "This site's security certificate is not trusted! Do you acess this site?";
+const char* const CERTIFICATION_ASK_CHECK = "Don't ask again";
+
+// function declare
+void askUserForCertificatePermission(
+ Evas_Object* window,
+ PermissionData* data);
+static void popupCallback(void* data, Evas_Object* obj, void* eventInfo);
+
+void askUserForCertificatePermission(
+ Evas_Object* window,
+ PermissionData* data)
+{
+ LogDebug("askUserForCertificatePermission called");
+ Evas_Object* popup = createPopup(window,
+ CERTIFICATION_ASK_BODY,
+ CERTIFICATION_ASK_CHECK,
+ popupCallback,
+ data);
+
+ if (popup == NULL) {
+ LogError("Fail to create popup object");
+ delete data;
+ return;
+ } else {
+ evas_object_show(popup);
+ }
+}
+
+void popupCallback(void* data, Evas_Object* obj, void* /*eventInfo*/)
+{
+ LogDebug("popupCallback");
+ Assert(data);
+ PermissionData* permData = static_cast<PermissionData*>(data);
+ Ewk_Certificate_Policy_Decision* certificatePolicyDecision =
+ static_cast<Ewk_Certificate_Policy_Decision*>(permData->m_data);
+
+ Evas_Object* popup = getPopup(obj);
+ Result result = getResult(obj);
+
+ if (result != RESULT_UNKNOWN) {
+ permData->m_certiDao->setCertificateData(permData->m_certiData,
+ result);
+ }
+ Eina_Bool ret =
+ (result == RESULT_ALLOW_ALWAYS || result == RESULT_ALLOW_ONCE) ?
+ EINA_TRUE : EINA_FALSE;
+
+ ewk_certificate_policy_decision_allowed_set(
+ certificatePolicyDecision,
+ ret);
+ delete permData;
+ evas_object_hide(popup);
+ evas_object_del(popup);
+}
+} // namespace
+
+void certificatePermissionRequest(
+ Evas_Object* window,
+ CertificateDB::CertificateDAO* certificateDAO,
+ void* data)
+{
+ LogDebug("certificationPermissionRequest called");
+ Assert(certificateDAO);
+ Assert(data);
+
+ Ewk_Certificate_Policy_Decision* certificatePolicyDecision =
+ static_cast<Ewk_Certificate_Policy_Decision*>(data);
+ ewk_certificate_policy_decision_suspend(certificatePolicyDecision);
+ Assert(certificatePolicyDecision);
+
+ CertificateData certificateData(
+ DPL::FromUTF8String(
+ ewk_certificate_policy_decision_certificate_pem_get(
+ certificatePolicyDecision)));
+
+ // check cache database
+ Result result = certificateDAO->getResult(certificateData);
+
+ if (RESULT_ALLOW_ONCE == result || RESULT_ALLOW_ALWAYS == result) {
+ LogDebug("allow");
+ ewk_certificate_policy_decision_allowed_set(
+ certificatePolicyDecision,
+ EINA_TRUE);
+ return;
+ } else if (RESULT_DENY_ONCE == result || RESULT_DENY_ALWAYS == result) {
+ LogDebug("Deny");
+ ewk_certificate_policy_decision_allowed_set(
+ certificatePolicyDecision,
+ EINA_FALSE);
+ return;
+ }
+ // ask to user
+ PermissionData* permissionData =
+ new PermissionData(certificateDAO,
+ certificateData,
+ certificatePolicyDecision);
+ askUserForCertificatePermission(window, permissionData);
+ return;
+}
+}
+} // namespace ViewModule
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file view_logic_certificate_confirm_support.h
+ * @author Leerang Song (leerang.song@samsung.com)
+ */
+
+#ifndef VIEW_LOGIC_CERTIFICATE_CONFIRM_SUPPORT_H_
+#define VIEW_LOGIC_CERTIFICATE_CONFIRM_SUPPORT_H_
+
+#include <memory.h>
+#include <Elementary.h>
+
+namespace CertificateDB {
+class CertificateDAO;
+}
+
+namespace ViewModule {
+namespace CertificateConfirmSupport {
+void certificatePermissionRequest(
+ Evas_Object* window,
+ CertificateDB::CertificateDAO* certificateDAO,
+ void* data);
+}
+} // namespace ViewModule
+
+#endif