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 <appcore-common.h>
25 #include <dpl/log/log.h>
26 #include <widget_model.h>
27 #include <common/scheme_action_map.h>
31 char const * const TIZEN_SCHEME = "tizen";
32 char const * const TIZEN_EXIT = "tizen://exit";
33 char const * const TIZEN_HIDE = "tizen://hide";
34 char const * const TIZEN_CHANGE_USERAGNET = "tizen://changeUA";
36 static Eina_Bool exitAppIdlerCallback(void* /*data*/)
39 return ECORE_CALLBACK_CANCEL;
43 bool SchemeSupport::HandleUri(
45 ViewModule::SchemeActionMap::NavigationContext context)
47 return ViewModule::SchemeActionMap::HandleUri(uri,
52 bool SchemeSupport::HandleTizenScheme(const char* uri,
56 LogDebug("HandleTizenScheme called");
58 LogError("Empty uri");
62 LogError("Empty window data");
66 if (strncmp(uri, TIZEN_EXIT, strlen(TIZEN_EXIT)) == 0) {
67 LogDebug("Tizen scheme: " << uri << " exit");
68 ecore_idler_add(exitAppIdlerCallback, NULL);
70 } else if (strncmp(uri, TIZEN_HIDE, strlen(TIZEN_HIDE)) == 0) {
71 LogDebug("Tizen scheme: " << uri << " hide");
72 elm_win_lower(window);
74 } else if (strncmp(uri,
75 TIZEN_CHANGE_USERAGNET,
76 strlen(TIZEN_CHANGE_USERAGNET)) == 0)
78 LogDebug("Tizen scheme: " << uri << " change UA");
79 const char* userAgentString = strstr(uri, "=");
80 if (NULL == userAgentString) {
81 LogDebug("UA string is NULL");
84 LogDebug("Setting custom user agent as: " << userAgentString);
85 ewk_view_user_agent_set(wkView, userAgentString);
92 bool SchemeSupport::filterURIByScheme(Ewk_Policy_Decision* policyDecision,
98 LogDebug("filterURIByScheme called");
99 Assert(policyDecision);
102 const char* url = ewk_policy_decision_url_get(policyDecision);
105 // There is no reason, security by scheme block null uri
110 ewk_frame_is_main_frame(ewk_policy_decision_frame_get(policyDecision));
112 using namespace ViewModule::SchemeActionMap;
113 if (HandleTizenScheme(url, window, wkView)) {
114 LogDebug("Scheme is tizen scheme");
118 NavigationContext ctx;
119 ctx = (mainFrame ? TOP_LEVEL : FRAME_LEVEL);
121 if (model->Type.Get().appType ==
122 WrtDB::APP_TYPE_TIZENWEBAPP)
125 // policy of new window should be applied,
126 // regardless level of this frame
131 return HandleUri(url, ctx);