2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 * @file view_logic_certificate_confirm_support.cpp
18 * @author Leerang Song (leerang.song@samsung.com)
21 #include "view_logic_certificate_confirm_support.h"
25 #include <dpl/log/log.h>
26 #include <dpl/assert.h>
27 #include <wrt-commons/certificate-dao/certificate_dao_types.h>
28 #include <wrt-commons/certificate-dao/certificate_dao.h>
30 #include <common/view_logic_certificate_support.h>
31 #include <Elementary.h>
33 namespace ViewModule {
34 namespace CertificateConfirmSupport {
35 using namespace CertificateDB;
36 using namespace ViewModule::CertificateSupportUtil;
39 const char* const CERTIFICATION_ASK_BODY =
40 "This site's security certificate is not trusted! Do you acess this site?";
41 const char* const CERTIFICATION_ASK_CHECK = "Don't ask again";
44 void askUserForCertificatePermission(
46 PermissionData* data);
47 static void popupCallback(void* data, Evas_Object* obj, void* eventInfo);
49 void askUserForCertificatePermission(
53 LogDebug("askUserForCertificatePermission called");
54 Evas_Object* popup = createPopup(window,
55 CERTIFICATION_ASK_BODY,
56 CERTIFICATION_ASK_CHECK,
61 LogError("Fail to create popup object");
65 evas_object_show(popup);
69 void popupCallback(void* data, Evas_Object* obj, void* /*eventInfo*/)
71 LogDebug("popupCallback");
73 PermissionData* permData = static_cast<PermissionData*>(data);
74 Ewk_Certificate_Policy_Decision* certificatePolicyDecision =
75 static_cast<Ewk_Certificate_Policy_Decision*>(permData->m_data);
77 Evas_Object* popup = getPopup(obj);
78 Result result = getResult(obj);
80 if (result != RESULT_UNKNOWN) {
81 permData->m_certiDao->setCertificateData(permData->m_certiData,
85 (result == RESULT_ALLOW_ALWAYS || result == RESULT_ALLOW_ONCE) ?
86 EINA_TRUE : EINA_FALSE;
88 ewk_certificate_policy_decision_allowed_set(
89 certificatePolicyDecision,
92 evas_object_hide(popup);
93 evas_object_del(popup);
97 void certificatePermissionRequest(
99 CertificateDB::CertificateDAO* certificateDAO,
102 LogDebug("certificationPermissionRequest called");
103 Assert(certificateDAO);
106 Ewk_Certificate_Policy_Decision* certificatePolicyDecision =
107 static_cast<Ewk_Certificate_Policy_Decision*>(data);
108 ewk_certificate_policy_decision_suspend(certificatePolicyDecision);
109 Assert(certificatePolicyDecision);
111 CertificateData certificateData(
113 ewk_certificate_policy_decision_certificate_pem_get(
114 certificatePolicyDecision)));
116 // check cache database
117 Result result = certificateDAO->getResult(certificateData);
119 if (RESULT_ALLOW_ONCE == result || RESULT_ALLOW_ALWAYS == result) {
121 ewk_certificate_policy_decision_allowed_set(
122 certificatePolicyDecision,
125 } else if (RESULT_DENY_ONCE == result || RESULT_DENY_ALWAYS == result) {
127 ewk_certificate_policy_decision_allowed_set(
128 certificatePolicyDecision,
133 PermissionData* permissionData =
134 new PermissionData(certificateDAO,
136 certificatePolicyDecision);
137 askUserForCertificatePermission(window, permissionData);
141 } // namespace ViewModule