#include <view_logic_scheme_support.h>
#include <view_logic_filesystem_support.h>
#include <view_logic_geolocation_support_webkit2.h>
+#include <view_logic_web_storage_support.h>
#include "bundles/plugin_module_support.h"
#include <EWebKit2.h>
const char * const EWK_FULLSCREEN_ENTER = "fullscreen,enterfullscreen";
const char * const EWK_FULLSCREEN_EXIT = "fullscreen,exitfullscreen";
-// DataBase Use Ask Title
-const char * const DATABASE_USE_ASK_TITLE = "Increase Database Size?";
-
// IME Callback
const char * const EWK_INPUTMETHOD_CHANGED = "inputmethod,changed";
const char * const EWK_EDITORCLIENT_IME_CLOSED = "editorclient,ime,closed";
LogDebug("databaseUsagePermissionRequestCallback called");
Assert(data);
ViewLogic* This = static_cast<ViewLogic*>(data);
- This->databaseUsagePermissionRequest(eventInfo);
- return;
- }
-void ViewLogic::databaseUsagePermissionRequest(
- void* eventInfo)
-{
- LogDebug("databaseUsagePermissionRequest called");
Assert(eventInfo);
- Ewk_Context_Exceeded_Quota* exceededQuota =
- static_cast<Ewk_Context_Exceeded_Quota*>(eventInfo);
-
- bool state = askUserForDatabaseExceedPermission(
- exceededQuota);
-
- if (true == state) {
- LogDebug("permit");
- ewk_context_web_database_exceeded_quota_new_quota_set(
- exceededQuota,
- ewk_context_web_database_exceeded_quota_expected_usage_get(
- exceededQuota)
- + 10*(1024*1024)); //10MB
- } else {
- LogDebug("deny");
- }
+ ViewModule::WebStorageSupport::webStorageCreatePermissionRequest(
+ This->m_window,
+ This->m_securityOriginSupport->getSecurityOriginDAO(),
+ eventInfo);
return;
}
-bool ViewLogic::askUserForDatabaseExceedPermission(
- Ewk_Context_Exceeded_Quota* exceededQuota)
-{
- LogDebug("askUserForDatabaseExceedPermission called");
- Ewk_Security_Origin* origin =
- ewk_context_web_database_exceeded_quota_security_origin_get(
- exceededQuota);
- char databaseUseAskTitle[180];
-
- snprintf(databaseUseAskTitle, sizeof(databaseUseAskTitle),
- "Do you want to allow %s to use up to %dMB of storage?",
- ewk_security_origin_host_get(origin),
- static_cast<int>(ewk_context_web_database_exceeded_quota_expected_usage_get(
- exceededQuota) / (1024 * 1024)));
-
- return Wrt::PopupInvoker().askYesNo(
- DATABASE_USE_ASK_TITLE,
- databaseUseAskTitle);
-}
-
void ViewLogic::fileSystemPermissionRequestCallback(
void* data,
Evas_Object* /*obj*/,
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file view_logic_web_storage_support.cpp
+ * @author Jihoon Chung (jihoon.chung@samsung.com)
+ */
+
+#include "view_logic_web_storage_support.h"
+
+#include <string>
+#include <sstream>
+#include <dpl/log/log.h>
+#include <dpl/assert.h>
+#include <wrt-commons/security-origin-dao/security_origin_dao_types.h>
+#include <wrt-commons/security-origin-dao/security_origin_dao.h>
+#include <EWebKit2.h>
+#include <common/view_logic_security_origin_support.h>
+#include <Elementary.h>
+
+namespace ViewModule {
+
+using namespace SecurityOriginDB;
+using namespace ViewModule::SecurityOriginSupportUtil;
+
+namespace {
+const char* const WEB_STORAGE_CREATE_ASK_BODY_PREFIX = "Do you want to allow ";
+const char* const WEB_STORAGE_CREATE_ASK_BODY =
+ " to use up to ";
+const char* const WEB_STORAGE_CREATE_ASK_BODY_POSTFIX =
+ "MB of storage?";
+const char* const WEB_STORAGE_CREATE_ASK_CHECK = "Don't ask again";
+
+// function declare
+void askUserForWebStorageCreatePermission(
+ Evas_Object* window,
+ PermissionData* data);
+static void popupCallback(void* data, Evas_Object* obj, void* eventInfo);
+
+void askUserForWebStorageCreatePermission(
+ Evas_Object* window,
+ PermissionData* data)
+{
+ LogDebug("askUserForWebStorageCreatePermission called");
+ PermissionData* permData = static_cast<PermissionData*>(data);
+ Ewk_Context_Exceeded_Quota* exceededQuota =
+ static_cast<Ewk_Context_Exceeded_Quota*>(permData->m_data);
+
+ std::ostringstream size;
+ size << ewk_context_web_database_exceeded_quota_expected_usage_get(exceededQuota) /
+ (1024 * 1024);
+
+ std::string body =
+ WEB_STORAGE_CREATE_ASK_BODY_PREFIX +
+ DPL::ToUTF8String(data->m_originData.origin.host) +
+ WEB_STORAGE_CREATE_ASK_BODY +
+ size.str() +
+ WEB_STORAGE_CREATE_ASK_BODY_POSTFIX;
+
+ Evas_Object* popup = createPopup(window,
+ body.c_str(),
+ WEB_STORAGE_CREATE_ASK_CHECK,
+ popupCallback,
+ data);
+
+ if (popup == NULL) {
+ LogError("Fail to create popup object");
+ delete data;
+ return;
+ } else {
+ evas_object_show(popup);
+ }
+}
+
+void popupCallback(void* data, Evas_Object* obj, void* /*eventInfo*/)
+{
+ LogDebug("popupCallback");
+ Assert(data);
+ PermissionData* permData = static_cast<PermissionData*>(data);
+ Ewk_Context_Exceeded_Quota* exceededQuota =
+ static_cast<Ewk_Context_Exceeded_Quota*>(permData->m_data);
+
+ Evas_Object* popup = getPopup(obj);
+ Result result = getResult(obj);
+
+ if (result != RESULT_UNKNOWN) {
+ permData->m_originDao->setSecurityOriginData(permData->m_originData, result);
+ }
+ if (result == RESULT_ALLOW_ALWAYS || result == RESULT_ALLOW_ONCE) {
+ ewk_context_web_database_exceeded_quota_new_quota_set(
+ exceededQuota,
+ ewk_context_web_database_exceeded_quota_expected_usage_get(
+ exceededQuota) +
+ 10*(1024*1024)); //10MB
+ }
+
+ delete permData;
+ evas_object_hide(popup);
+ evas_object_del(popup);
+}
+} // namespace
+
+void WebStorageSupport::webStorageCreatePermissionRequest(
+ Evas_Object* window,
+ SecurityOriginDAO* securityOriginDAO,
+ void* data)
+{
+ LogDebug("webStorageCreatePermissionRequest called");
+ Assert(securityOriginDAO);
+ Assert(data);
+ Ewk_Context_Exceeded_Quota* exceededQuota =
+ static_cast<Ewk_Context_Exceeded_Quota*>(data);
+ Ewk_Security_Origin* ewkOrigin =
+ ewk_context_web_database_exceeded_quota_security_origin_get(
+ exceededQuota);
+ Assert(ewkOrigin);
+
+ SecurityOriginData securityOriginData(
+ FEATURE_WEB_DATABASE,
+ Origin(
+ DPL::FromUTF8String(ewk_security_origin_protocol_get(ewkOrigin)),
+ DPL::FromUTF8String(ewk_security_origin_host_get(ewkOrigin)),
+ ewk_security_origin_port_get(ewkOrigin)));
+
+ // check cache database
+ Result result = securityOriginDAO->getResult(securityOriginData);
+ if (RESULT_ALLOW_ONCE == result || RESULT_ALLOW_ALWAYS == result) {
+ LogDebug("allow");
+ ewk_context_web_database_exceeded_quota_new_quota_set(
+ exceededQuota,
+ ewk_context_web_database_exceeded_quota_expected_usage_get(
+ exceededQuota) +
+ 10*(1024*1024)); //10MB
+ return;
+ } else if (RESULT_DENY_ONCE == result || RESULT_DENY_ALWAYS == result) {
+ LogDebug("deny");
+ return;
+ }
+
+ // ask to user
+ PermissionData* permissionData =
+ new PermissionData(securityOriginDAO,
+ securityOriginData,
+ exceededQuota);
+ askUserForWebStorageCreatePermission(window, permissionData);
+ return;
+}
+} // namespace ViewModule
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file view_logic_web_storage_support.h
+ * @author Jihoon Chung (jihoon.chung@samsung.com)
+ */
+
+#ifndef VIEW_LOGIC_WEB_STORAGE_SUPPORT_H_
+#define VIEW_LOGIC_WEB_STORAGE_SUPPORT_H_
+
+#include <memory.h>
+#include <Elementary.h>
+
+namespace SecurityOriginDB {
+ class SecurityOriginDAO;
+}
+
+namespace ViewModule {
+namespace WebStorageSupport {
+
+void webStorageCreatePermissionRequest(
+ Evas_Object* window,
+ SecurityOriginDB::SecurityOriginDAO* securityOriginDAO,
+ void* data);
+
+} // namespace WebStorageSupport
+} // namespace ViewModule
+
+#endif // VIEW_LOGIC_WEB_STORAGE_SUPPORT_H_
\ No newline at end of file