#include "view_logic_scheme_support.h"
-#include <appcore-common.h>
-#include <dpl/log/log.h>
-#include <widget_model.h>
+#include <dpl/assert.h>
+#include <dpl/log/secure_log.h>
#include <common/scheme_action_map.h>
+#include <Elementary.h>
#include <EWebKit2.h>
+namespace ViewModule {
namespace {
char const * const TIZEN_SCHEME = "tizen";
char const * const TIZEN_EXIT = "tizen://exit";
char const * const TIZEN_HIDE = "tizen://hide";
-char const * const TIZEN_ORIENTATION_LANDSCAPE =
- "tizen://orientation.landscape";
-char const * const TIZEN_ORIENTATION_PORTAIT = "tizen://orientation.portrait";
-char const * const TIZEN_ORIENTATION_RESET = "tizen://orientation.reset";
char const * const TIZEN_CHANGE_USERAGNET = "tizen://changeUA";
-const int ORIENTATION_LANDSCAPE_ANGLE = 270;
-const int ORIENTATION_PORTAIT_ANGLE = 0;
-
static Eina_Bool exitAppIdlerCallback(void* /*data*/)
{
- // webapp termination
- ewk_shutdown();
elm_exit();
- return ECORE_CALLBACK_CANCEL;}
-
-} // namespace
-
-bool SchemeSupport::HandleUri(
- const char* uri,
- ViewModule::SchemeActionMap::NavigationContext context)
-{
- return ViewModule::SchemeActionMap::HandleUri(uri,
- context,
- m_type);
+ return ECORE_CALLBACK_CANCEL;
}
+} // namespace
bool SchemeSupport::HandleTizenScheme(const char* uri,
Evas_Object* window,
Evas_Object* wkView)
{
- LogInfo("HandleTizenScheme called");
if (!uri) {
- LogError("Empty uri");
+ _W("Empty uri");
return false;
}
if (!window) {
- LogError("Empty window data");
+ _W("Empty window data");
return false;
}
if (strncmp(uri, TIZEN_EXIT, strlen(TIZEN_EXIT)) == 0) {
- LogInfo("Tizen scheme: " << uri << " exit");
+ _D("%s : exit", uri);
ecore_idler_add(exitAppIdlerCallback, NULL);
return true;
} else if (strncmp(uri, TIZEN_HIDE, strlen(TIZEN_HIDE)) == 0) {
- LogInfo("Tizen scheme: " << uri << " hide");
- elm_win_lower(window);
- return true;
- } else if (strncmp(uri,
- TIZEN_ORIENTATION_LANDSCAPE,
- strlen(TIZEN_ORIENTATION_LANDSCAPE)) == 0)
- {
- LogInfo("Tizen scheme: " << uri << " orientation landscape");
- elm_win_rotation_with_resize_set(window, ORIENTATION_LANDSCAPE_ANGLE);
- return true;
- } else if (strncmp(uri,
- TIZEN_ORIENTATION_PORTAIT,
- strlen(TIZEN_ORIENTATION_PORTAIT)) == 0)
- {
- LogInfo("Tizen scheme: " << uri << " orientation portait");
- elm_win_rotation_with_resize_set(window, ORIENTATION_PORTAIT_ANGLE);
- return true;
- } else if (strncmp(uri,
- TIZEN_ORIENTATION_RESET,
- strlen(TIZEN_ORIENTATION_RESET)) == 0)
- {
- LogInfo("Tizen scheme: " << uri << " reset");
- elm_win_rotation_with_resize_set(window, ORIENTATION_PORTAIT_ANGLE);
+ _D("%s : hide", uri);
+ elm_win_withdrawn_set(window, EINA_TRUE);
return true;
} else if (strncmp(uri,
TIZEN_CHANGE_USERAGNET,
strlen(TIZEN_CHANGE_USERAGNET)) == 0)
{
- LogInfo("Tizen scheme: " << uri << " change UA");
- const char* userAgentString = strstr(uri, "=") + 1;
+ _D("%s : change UA", uri);
+ const char* userAgentString = strstr(uri, "=");
if (NULL == userAgentString) {
- LogDebug("UA string is NULL");
+ _W("UA string is NULL");
} else {
- LogDebug("Setting custom user agent as: " << userAgentString);
+ userAgentString++;
+ _D("Setting custom user agent as: %s", userAgentString);
ewk_view_user_agent_set(wkView, userAgentString);
}
return true;
bool SchemeSupport::filterURIByScheme(Ewk_Policy_Decision* policyDecision,
bool newWindow,
- WidgetModel* model,
Evas_Object* window,
Evas_Object* wkView)
{
- LogDebug("filterURIByScheme called");
+ _D("called");
Assert(policyDecision);
- Assert(model);
const char* url = ewk_policy_decision_url_get(policyDecision);
if (NULL == url) {
ewk_frame_is_main_frame(ewk_policy_decision_frame_get(policyDecision));
using namespace ViewModule::SchemeActionMap;
- if (HandleTizenScheme(url, window, wkView))
- {
- LogDebug("Scheme is tizen scheme");
+ if (HandleTizenScheme(url, window, wkView)) {
+ _D("Scheme is tizen scheme");
return false;
}
NavigationContext ctx;
ctx = (mainFrame ? TOP_LEVEL : FRAME_LEVEL);
if (newWindow) {
- if (model->Type.Get().appType ==
- WrtDB::APP_TYPE_TIZENWEBAPP)
- {
- // In case of Tizen,
- // policy of new window should be applied,
- // regardless level of this frame
- ctx = NEW_WINDOW;
- } else if (model->Type.Get().appType ==
- WrtDB::APP_TYPE_WAC20)
- {
- // In case of WAC,
- // policy of new window should be applied,
- // only top level frame (this may be changed by WAC spec)
- if (ctx == TOP_LEVEL) {
- ctx = NEW_WINDOW;
- }
- }
+ // In case of Tizen,
+ // policy of new window should be applied,
+ // regardless level of this frame
+ ctx = NEW_WINDOW;
}
- return HandleUri(url, ctx);
+ return SchemeActionMap::HandleUri(url, ctx);
}
+} // namespace ViewModule