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_scheme_support.cpp
18 * @author Krzysztof Jackiewicz (k.jackiewicz@samsung.com)
22 #include "view_logic_scheme_support.h"
24 #include <dpl/assert.h>
25 #include <dpl/log/secure_log.h>
26 #include <common/scheme_action_map.h>
27 #include <Elementary.h>
30 namespace ViewModule {
32 char const * const TIZEN_SCHEME = "tizen";
33 char const * const TIZEN_EXIT = "tizen://exit";
34 char const * const TIZEN_HIDE = "tizen://hide";
35 char const * const TIZEN_CHANGE_USERAGNET = "tizen://changeUA";
37 static Eina_Bool exitAppIdlerCallback(void* /*data*/)
40 return ECORE_CALLBACK_CANCEL;
44 bool SchemeSupport::HandleTizenScheme(const char* uri,
53 _W("Empty window data");
57 if (strncmp(uri, TIZEN_EXIT, strlen(TIZEN_EXIT)) == 0) {
59 ecore_idler_add(exitAppIdlerCallback, NULL);
61 } else if (strncmp(uri, TIZEN_HIDE, strlen(TIZEN_HIDE)) == 0) {
63 elm_win_lower(window);
65 } else if (strncmp(uri,
66 TIZEN_CHANGE_USERAGNET,
67 strlen(TIZEN_CHANGE_USERAGNET)) == 0)
69 _D("%s : change UA", uri);
70 const char* userAgentString = strstr(uri, "=");
71 if (NULL == userAgentString) {
72 _W("UA string is NULL");
75 _D("Setting custom user agent as: %s", userAgentString);
76 ewk_view_user_agent_set(wkView, userAgentString);
83 bool SchemeSupport::filterURIByScheme(Ewk_Policy_Decision* policyDecision,
89 Assert(policyDecision);
91 const char* url = ewk_policy_decision_url_get(policyDecision);
94 // There is no reason, security by scheme block null uri
99 ewk_frame_is_main_frame(ewk_policy_decision_frame_get(policyDecision));
101 using namespace ViewModule::SchemeActionMap;
102 if (HandleTizenScheme(url, window, wkView)) {
103 _D("Scheme is tizen scheme");
107 NavigationContext ctx;
108 ctx = (mainFrame ? TOP_LEVEL : FRAME_LEVEL);
111 // policy of new window should be applied,
112 // regardless level of this frame
116 return SchemeActionMap::HandleUri(url, ctx);
118 } // namespace ViewModule