Initialize Tizen 2.3
[framework/osp/web.git] / src / controls / FWebCtrl_AuthenticationChallengeImpl.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 /**
19  * @file                FWebCtrl_AuthenticationChallengeImpl.cpp
20  * @brief               The file contains the definition of _AuthenticationChallengeImpl class.
21  *
22  * The file contains the definition of _AuthenticationChallengeImpl class.
23  */
24 #include <unique_ptr.h>
25 #include <EWebKit2.h>
26 #include <FBaseErrors.h>
27 #include <FWebCtrlAuthenticationChallenge.h>
28 #include <FBase_StringConverter.h>
29 #include <FBaseSysLog.h>
30 #include "FWebCtrl_AuthenticationChallengeImpl.h"
31
32
33 using namespace Tizen::Base;
34
35
36 namespace Tizen { namespace Web { namespace Controls
37 {
38
39
40 _AuthenticationChallengeImpl::_AuthenticationChallengeImpl(void)
41         : __pAuthChallengeHandler(null)
42         , __pWebFrame(null)
43 {
44 }
45
46 _AuthenticationChallengeImpl::~_AuthenticationChallengeImpl(void)
47 {
48 }
49
50
51 void
52 _AuthenticationChallengeImpl::Process(const UserId& userId, const Tizen::Base::String& password)
53 {
54         std::unique_ptr<char[]> pUserId(_StringConverter::CopyToCharArrayN(userId));
55         std::unique_ptr<char[]> pUserPwd(_StringConverter::CopyToCharArrayN(password));
56         SysTryReturnVoidResult(NID_WEB_CTRL, pUserId.get() && pUserPwd.get(), E_SYSTEM, "[%s] A system error has been occurred. Failed to convert strings.", GetErrorMessage(E_SYSTEM));
57
58         //ewk_auth_response_ok(__pAuthChallengeHandler, pUserId, pUserPwd);
59         ewk_auth_challenge_credential_use(__pAuthChallengeHandler, pUserId.get(), pUserPwd.get());
60 }
61
62
63 void
64 _AuthenticationChallengeImpl::Cancel(void)
65 {
66         //ewk_auth_response_cancel(__pAuthChallengeHandler);
67         ewk_auth_challenge_credential_cancel(__pAuthChallengeHandler);
68         evas_object_smart_callback_call(__pWebFrame, "authentication,canceled", NULL);
69 }
70
71
72 void
73 _AuthenticationChallengeImpl::SetAuthenticationChallengeHandler(Ewk_Auth_Challenge* pAuthHandler)
74 {
75         SysTryReturnVoidResult(NID_WEB_CTRL, pAuthHandler, E_INVALID_ARG, "[%s] Invalid argument(s) is used. pAuthHandler instance is null." , GetErrorMessage(E_INVALID_ARG));
76         __pAuthChallengeHandler = pAuthHandler;
77 }
78
79
80 void
81 _AuthenticationChallengeImpl::SetWebEvasObject(Evas_Object* pObj)
82 {
83         SysTryReturnVoidResult(NID_WEB_CTRL, pObj, E_INVALID_ARG, "[%s] Invalid argument(s) is used. pAuthHandler instance is null." , GetErrorMessage(E_INVALID_ARG));
84         __pWebFrame = pObj;
85 }
86
87
88 _AuthenticationChallengeImpl*
89 _AuthenticationChallengeImpl::GetInstance(AuthenticationChallenge* pAuthChallenge)
90 {
91
92         SysTryReturn(NID_WEB_CTRL, pAuthChallenge, null, E_INVALID_ARG, "[%s] Invalid argument(s) is used. pAuthChallenge instance is null." , GetErrorMessage(E_INVALID_ARG));
93         return pAuthChallenge->__pAuthenticationChallengeImpl;
94 }
95
96
97 const _AuthenticationChallengeImpl*
98 _AuthenticationChallengeImpl::GetInstance(const AuthenticationChallenge* pAuthChallenge)
99 {
100         SysTryReturn(NID_WEB_CTRL, pAuthChallenge, null, E_INVALID_ARG, "[%s] Invalid argument(s) is used. pAuthChallenge instance is null." , GetErrorMessage(E_INVALID_ARG));
101         return pAuthChallenge->__pAuthenticationChallengeImpl;
102 }
103
104
105 }}} // Tizen::Web::Controls