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*/)
41 return ECORE_CALLBACK_CANCEL;
45 bool SchemeSupport::HandleUri(
47 ViewModule::SchemeActionMap::NavigationContext context)
49 return ViewModule::SchemeActionMap::HandleUri(uri,
54 bool SchemeSupport::HandleTizenScheme(const char* uri,
58 LogDebug("HandleTizenScheme called");
60 LogError("Empty uri");
64 LogError("Empty window data");
68 if (strncmp(uri, TIZEN_EXIT, strlen(TIZEN_EXIT)) == 0) {
69 LogDebug("Tizen scheme: " << uri << " exit");
70 ecore_idler_add(exitAppIdlerCallback, NULL);
72 } else if (strncmp(uri, TIZEN_HIDE, strlen(TIZEN_HIDE)) == 0) {
73 LogDebug("Tizen scheme: " << uri << " hide");
74 elm_win_lower(window);
76 } else if (strncmp(uri,
77 TIZEN_CHANGE_USERAGNET,
78 strlen(TIZEN_CHANGE_USERAGNET)) == 0)
80 LogDebug("Tizen scheme: " << uri << " change UA");
81 const char* userAgentString = strstr(uri, "=");
82 if (NULL == userAgentString) {
83 LogDebug("UA string is NULL");
86 LogDebug("Setting custom user agent as: " << userAgentString);
87 ewk_view_user_agent_set(wkView, userAgentString);
94 bool SchemeSupport::filterURIByScheme(Ewk_Policy_Decision* policyDecision,
100 LogDebug("filterURIByScheme called");
101 Assert(policyDecision);
104 const char* url = ewk_policy_decision_url_get(policyDecision);
107 // There is no reason, security by scheme block null uri
112 ewk_frame_is_main_frame(ewk_policy_decision_frame_get(policyDecision));
114 using namespace ViewModule::SchemeActionMap;
115 if (HandleTizenScheme(url, window, wkView)) {
116 LogDebug("Scheme is tizen scheme");
120 NavigationContext ctx;
121 ctx = (mainFrame ? TOP_LEVEL : FRAME_LEVEL);
123 if (model->Type.Get().appType ==
124 WrtDB::APP_TYPE_TIZENWEBAPP)
127 // policy of new window should be applied,
128 // regardless level of this frame
133 return HandleUri(url, ctx);