1 opyright 2012 Samsung Electronics Co., Ltd
3 * Licensed under the Flora License, Version 1.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
7 * http://www.tizenopensource.org/license
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
18 #include "browser-settings-class.h"
19 #include "browser-settings-website-setting.h"
20 #include "browser-view.h"
22 Browser_Settings_Website_Setting::Browser_Settings_Website_Setting(Browser_Settings_Main_View *main_view)
25 ,m_details_genlist(NULL)
27 ,m_back_button_details(NULL)
28 ,m_clear_confirm_popup(NULL)
29 ,m_delete_all_website_list_confirm_popup(NULL)
30 ,m_delete_all_details_list_confirm_popup(NULL)
31 ,m_bottom_control_bar(NULL)
32 ,m_details_bottom_control_bar(NULL)
33 ,m_delete_all_website_list_conbar_item(NULL)
34 ,m_delete_all_details_conbar_item(NULL)
35 ,m_current_website_item_data(NULL)
36 ,m_current_item_data(NULL)
37 ,m_is_called_appcache_cb_flag(false)
38 ,m_is_called_webstorage_cb_flag(false)
39 ,m_is_called_webdb_cb_flag(false)
40 ,m_main_view(main_view)
42 BROWSER_LOGD("[%s]", __func__);
45 Browser_Settings_Website_Setting::~Browser_Settings_Website_Setting(void)
47 BROWSER_LOGD("[%s]", __func__);
49 for (int i = 0 ; i < m_website_setting_list.size() ; i++) {
50 if (m_website_setting_list[i])
51 delete m_website_setting_list[i];
53 m_website_setting_list.clear();
56 Eina_Bool Browser_Settings_Website_Setting::init(void)
58 BROWSER_LOGD("[%s]", __func__);
60 if (!_create_main_layout()) {
61 BROWSER_LOGE("_create_main_layout failed");
68 Evas_Object *Browser_Settings_Website_Setting::__genlist_icon_get(void *data,
69 Evas_Object *obj, const char *part)
74 BROWSER_LOGD("part = [%s]", part);
76 Browser_Geolocation_DB::geolocation_info *info = (Browser_Geolocation_DB::geolocation_info *)data;
78 if (part && strlen(part) > 0) {
79 if (!strncmp(part, "elm.icon.1", strlen("elm.icon.1"))) {
80 Evas_Object *favicon = NULL;
81 favicon = m_data_manager->get_browser_view()->get_favicon(info->url.c_str());
85 Evas_Object *default_icon = elm_icon_add(obj);
88 if (!elm_icon_file_set(default_icon, BROWSER_IMAGE_DIR"/faviconDefault.png", NULL)) {
89 BROWSER_LOGE("elm_icon_file_set is failed.\n");
92 evas_object_size_hint_aspect_set(default_icon, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
95 } else if (!strncmp(part,"elm.icon.2", strlen("elm.icon.2"))) {
96 Evas_Object *location_icon = elm_icon_add(obj);
100 if (info->geolocation) {
102 if (!elm_icon_file_set(location_icon, BROWSER_IMAGE_DIR"/I01_icon_location_allowed.png", NULL)) {
103 BROWSER_LOGE("elm_icon_file_set is failed.\n");
106 evas_object_size_hint_aspect_set(location_icon, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
107 return location_icon;
109 if (!elm_icon_file_set(location_icon, BROWSER_IMAGE_DIR"/I01_icon_location_denied.png", NULL)) {
110 BROWSER_LOGE("elm_icon_file_set is failed.\n");
113 evas_object_size_hint_aspect_set(location_icon, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
114 return location_icon;
117 } else if (!strncmp(part,"elm.icon.3", strlen("elm.icon.3"))) {
118 Evas_Object *storage_icon = elm_icon_add(obj);
122 if (!elm_icon_file_set(storage_icon, BROWSER_IMAGE_DIR"/I01_icon_web_storage.png", NULL)) {
123 BROWSER_LOGE("elm_icon_file_set is failed.\n");
126 evas_object_size_hint_aspect_set(storage_icon, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
135 char *Browser_Settings_Website_Setting::__genlist_label_get(void *data,
136 Evas_Object *obj, const char *part)
141 BROWSER_LOGD("part = [%s]", part);
143 Browser_Geolocation_DB::geolocation_info *info = (Browser_Geolocation_DB::geolocation_info *)data;
144 const char *url = info->url.c_str();
146 if (part && strlen(part) > 0) {
147 if (!strncmp(part,"elm.text", strlen("elm.text"))) {
148 if (url && strlen(url))
156 Evas_Object *Browser_Settings_Website_Setting::__details_genlist_icon_get(void *data,
157 Evas_Object *obj, const char *part)
162 BROWSER_LOGD("part = [%s]", part);
164 genlist_callback_data *callback_data = (genlist_callback_data *)data;
165 Browser_Settings_Website_Setting::menu_type type = callback_data->type;
166 Browser_Settings_Website_Setting *website_setting = NULL;
168 Browser_Geolocation_DB::geolocation_info *info =
169 (Browser_Geolocation_DB::geolocation_info *)(callback_data->user_data);
171 if (part && strlen(part) > 0) {
172 if (!strncmp(part, "elm.icon", strlen("elm.icon"))) {
173 if (type == BR_MENU_LOCATION) {
174 BROWSER_LOGD("location menu\n");
175 Evas_Object *location_icon = elm_icon_add(obj);
178 if (info->geolocation) {
180 if (!elm_icon_file_set(location_icon, BROWSER_IMAGE_DIR"/I01_icon_location_allowed_small.png", NULL)) {
181 BROWSER_LOGE("elm_icon_file_set is failed.\n");
184 evas_object_size_hint_aspect_set(location_icon, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
185 return location_icon;
187 if (!elm_icon_file_set(location_icon, BROWSER_IMAGE_DIR"/I01_icon_location_denied_small.png", NULL)) {
188 BROWSER_LOGE("elm_icon_file_set is failed.\n");
191 evas_object_size_hint_aspect_set(location_icon, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
192 return location_icon;
195 } else if (type == BR_MENU_WEB_STORAGE) {
196 BROWSER_LOGD("web storage menu.\n");
197 Evas_Object *storage_icon = elm_icon_add(obj);
201 if (!elm_icon_file_set(storage_icon, BROWSER_IMAGE_DIR"/I01_icon_web_storage_small.png", NULL)) {
202 BROWSER_LOGE("elm_icon_file_set is failed.\n");
205 evas_object_size_hint_aspect_set(storage_icon, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
209 BROWSER_LOGD("wrong menu index.\n");
217 char *Browser_Settings_Website_Setting::__details_genlist_label_get(void *data,
218 Evas_Object *obj, const char *part)
223 BROWSER_LOGD("part = [%s]", part);
224 genlist_callback_data *callback_data = (genlist_callback_data *)data;
225 Browser_Settings_Website_Setting::menu_type type = callback_data->type;
226 Browser_Settings_Website_Setting *website_setting = NULL;
228 Browser_Geolocation_DB::geolocation_info *info =
229 (Browser_Geolocation_DB::geolocation_info *)(callback_data->user_data);
230 const char *url = info->url.c_str();
232 if (part && strlen(part) > 0) {
233 if (!strncmp(part,"elm.text", strlen("elm.text"))) {
234 if (type == BR_MENU_LOCATION) {
235 BROWSER_LOGD("location menu.\n");
236 return strdup(BR_STRING_CLEAR_LOCATION_ACCESS);
237 } else if (type == BR_MENU_WEB_STORAGE) {
238 BROWSER_LOGD("web storage menu.\n");
239 return strdup(BR_STRING_CLEAR_STORED_DATA);
241 BROWSER_LOGD("wrong menu index.\n");
249 void Browser_Settings_Website_Setting::__item_selected_cb(void *data, Evas_Object *obj, void *event_info)
251 BROWSER_LOGD("[%s]", __func__);
255 Browser_Settings_Website_Setting *website_setting = (Browser_Settings_Website_Setting *)data;
256 Elm_Object_Item *it = (Elm_Object_Item *)event_info;
257 website_setting->m_current_website_item_data = NULL;
258 website_setting->m_current_website_item_data = (website_setting_item *)elm_object_item_data_get(it);
260 website_setting->_show_details_list(website_setting->m_current_website_item_data);
261 elm_genlist_item_selected_set(it, EINA_FALSE);
264 void Browser_Settings_Website_Setting::__details_item_selected_cb(void *data, Evas_Object *obj, void *event_info)
266 BROWSER_LOGD("[%s]", __func__);
270 genlist_callback_data *callback_data = (genlist_callback_data *)data;
271 Browser_Settings_Website_Setting::menu_type type = callback_data->type;
272 Browser_Settings_Website_Setting *website_setting = NULL;
273 website_setting = (Browser_Settings_Website_Setting *)(callback_data->cp);
275 website_setting->m_current_item_data = (website_setting_item *)callback_data->user_data;
276 if (type == BR_MENU_LOCATION) {
277 website_setting->_show_clear_location_confirm_popup();
278 } else if (type == BR_MENU_WEB_STORAGE) {
279 website_setting->_show_clear_web_storage_confirm_popup();
282 elm_genlist_item_selected_set(callback_data->it, EINA_FALSE);
285 Eina_Bool Browser_Settings_Website_Setting::_show_clear_location_confirm_popup(void)
287 BROWSER_LOGD("[%s]", __func__);
288 if (m_clear_confirm_popup)
289 evas_object_del(m_clear_confirm_popup);
291 m_clear_confirm_popup = elm_popup_add(m_details_genlist);
292 if (!m_clear_confirm_popup) {
293 BROWSER_LOGE("elm_popup_add failed");
297 evas_object_size_hint_weight_set(m_clear_confirm_popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
299 elm_object_text_set(m_clear_confirm_popup, BR_STRING_CLEAR_LOCATION_ACCESS_FOR_THIS_WEBSITE);
301 Evas_Object *ok_button = elm_button_add(m_clear_confirm_popup);
303 BROWSER_LOGE("elm_button_add failed");
306 elm_object_text_set(ok_button, BR_STRING_YES);
307 elm_object_part_content_set(m_clear_confirm_popup, "button1", ok_button);
308 evas_object_smart_callback_add(ok_button, "clicked", __clear_location_confirm_response_cb, this);
310 Evas_Object *cancel_button = elm_button_add(m_clear_confirm_popup);
311 elm_object_text_set(cancel_button, BR_STRING_NO);
312 elm_object_part_content_set(m_clear_confirm_popup, "button2", cancel_button);
313 evas_object_smart_callback_add(cancel_button, "clicked", __cancel_clear_location_confirm_response_cb, this);
315 evas_object_show(m_clear_confirm_popup);
320 Eina_Bool Browser_Settings_Website_Setting::_show_clear_web_storage_confirm_popup(void)
322 BROWSER_LOGD("[%s]", __func__);
323 if (m_clear_confirm_popup)
324 evas_object_del(m_clear_confirm_popup);
326 m_clear_confirm_popup = elm_popup_add(m_details_genlist);
327 if (!m_clear_confirm_popup) {
328 BROWSER_LOGE("elm_popup_add failed");
332 evas_object_size_hint_weight_set(m_clear_confirm_popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
334 elm_object_text_set(m_clear_confirm_popup, BR_STRING_DELETE_ALL_STORED_DATA_BY_THIS_WEBSITE);
336 Evas_Object *ok_button = elm_button_add(m_clear_confirm_popup);
338 BROWSER_LOGE("elm_button_add failed");
341 elm_object_text_set(ok_button, BR_STRING_YES);
342 elm_object_part_content_set(m_clear_confirm_popup, "button1", ok_button);
343 evas_object_smart_callback_add(ok_button, "clicked", __clear_web_storage_confirm_response_cb, this);
345 Evas_Object *cancel_button = elm_button_add(m_clear_confirm_popup);
346 elm_object_text_set(cancel_button, BR_STRING_NO);
347 elm_object_part_content_set(m_clear_confirm_popup, "button2", cancel_button);
348 evas_object_smart_callback_add(cancel_button, "clicked", __cancel_clear_web_storage_confirm_response_cb, this);
350 evas_object_show(m_clear_confirm_popup);
355 Eina_Bool Browser_Settings_Website_Setting::_show_delete_all_website_list_confirm_popup(void)
357 BROWSER_LOGD("[%s]", __func__);
358 if (m_delete_all_website_list_confirm_popup)
359 evas_object_del(m_delete_all_website_list_confirm_popup);
361 m_delete_all_website_list_confirm_popup = elm_popup_add(m_genlist);
362 if (!m_delete_all_website_list_confirm_popup) {
363 BROWSER_LOGE("elm_popup_add failed");
367 evas_object_size_hint_weight_set(m_delete_all_website_list_confirm_popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
369 elm_object_text_set(m_delete_all_website_list_confirm_popup, BR_STRING_DELETE_ALL_WEBSITE_DATA_AND_LOCATION_PERMISSIONS);
371 Evas_Object *ok_button = elm_button_add(m_delete_all_website_list_confirm_popup);
373 BROWSER_LOGE("elm_button_add failed");
376 elm_object_text_set(ok_button, BR_STRING_YES);
377 elm_object_part_content_set(m_delete_all_website_list_confirm_popup, "button1", ok_button);
378 evas_object_smart_callback_add(ok_button, "clicked", __delete_all_website_list_confirm_response_cb, this);
380 Evas_Object *cancel_button = elm_button_add(m_delete_all_website_list_confirm_popup);
381 elm_object_text_set(cancel_button, BR_STRING_NO);
382 elm_object_part_content_set(m_delete_all_website_list_confirm_popup, "button2", cancel_button);
383 evas_object_smart_callback_add(cancel_button, "clicked", __cancel_delete_all_website_list_confirm_response_cb, this);
385 evas_object_show(m_delete_all_website_list_confirm_popup);
390 Eina_Bool Browser_Settings_Website_Setting::_show_delete_all_details_list_confirm_popup(void)
392 BROWSER_LOGD("[%s]", __func__);
393 if (m_delete_all_details_list_confirm_popup)
394 evas_object_del(m_delete_all_details_list_confirm_popup);
396 m_delete_all_details_list_confirm_popup = elm_popup_add(m_details_genlist);
397 if (!m_delete_all_details_list_confirm_popup) {
398 BROWSER_LOGE("elm_popup_add failed");
402 evas_object_size_hint_weight_set(m_delete_all_details_list_confirm_popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
404 elm_object_text_set(m_delete_all_details_list_confirm_popup, BR_STRING_DELETE_ALL_WEBSITE_DATA_AND_LOCATION_PERMISSIONS);
406 Evas_Object *ok_button = elm_button_add(m_delete_all_details_list_confirm_popup);
408 BROWSER_LOGE("elm_button_add failed");
411 elm_object_text_set(ok_button, BR_STRING_YES);
412 elm_object_part_content_set(m_delete_all_details_list_confirm_popup, "button1", ok_button);
413 evas_object_smart_callback_add(ok_button, "clicked", __delete_all_details_list_confirm_response_cb, this);
415 Evas_Object *cancel_button = elm_button_add(m_delete_all_details_list_confirm_popup);
416 elm_object_text_set(cancel_button, BR_STRING_NO);
417 elm_object_part_content_set(m_delete_all_details_list_confirm_popup, "button2", cancel_button);
418 evas_object_smart_callback_add(cancel_button, "clicked", __cancel_delete_all_details_list_confirm_response_cb, this);
420 evas_object_show(m_delete_all_details_list_confirm_popup);
425 void Browser_Settings_Website_Setting::__clear_location_confirm_response_cb(void *data, Evas_Object *obj, void *event_info)
427 BROWSER_LOGD("[%s]", __func__);
431 Browser_Settings_Website_Setting *website_setting = (Browser_Settings_Website_Setting *)data;
432 if (website_setting->m_clear_confirm_popup) {
433 evas_object_del(website_setting->m_clear_confirm_popup);
434 website_setting->m_clear_confirm_popup = NULL;
437 Browser_Geolocation_DB geolocation_db;
439 geolocation_db.remove_geolocation_data(website_setting->m_current_item_data->url.c_str());
440 website_setting->m_current_item_data->geolocation = false;
442 if(website_setting->m_current_item_data->storage == false) {
443 website_setting->__back_button_clicked_cb(NULL, NULL, NULL);
444 website_setting->_refresh_website_list();
446 website_setting->_refresh_details_list(website_setting->m_current_item_data);
449 website_setting->show_notify_popup(BR_STRING_DELETED, 3, EINA_TRUE);
452 void Browser_Settings_Website_Setting::__cancel_clear_location_confirm_response_cb(void *data, Evas_Object *obj, void *event_info)
454 BROWSER_LOGD("[%s]", __func__);
458 Browser_Settings_Website_Setting *website_setting = (Browser_Settings_Website_Setting *)data;
459 if (website_setting->m_clear_confirm_popup) {
460 evas_object_del(website_setting->m_clear_confirm_popup);
461 website_setting->m_clear_confirm_popup = NULL;
465 void Browser_Settings_Website_Setting::__clear_web_storage_confirm_response_cb(void *data, Evas_Object *obj, void *event_info)
467 BROWSER_LOGD("[%s]", __func__);
471 Browser_Settings_Website_Setting *website_setting = (Browser_Settings_Website_Setting *)data;
472 if (website_setting->m_clear_confirm_popup) {
473 evas_object_del(website_setting->m_clear_confirm_popup);
474 website_setting->m_clear_confirm_popup = NULL;
478 Ewk_Context *ewk_context = ewk_context_default_get();
479 ewk_context_application_cache_delete(ewk_context, (Ewk_Security_Origin*)(website_setting->m_current_item_data->origin));
480 ewk_context_web_database_delete(ewk_context, (Ewk_Security_Origin*)(website_setting->m_current_item_data->origin));
481 ewk_context_web_storage_origin_delete(ewk_context, (Ewk_Security_Origin*)(website_setting->m_current_item_data->origin));
482 website_setting->m_current_item_data->storage = false;
484 if(website_setting->m_current_item_data->geolocation == false) {
485 website_setting->__back_button_clicked_cb(NULL, NULL, NULL);
486 website_setting->_refresh_website_list();
488 website_setting->_refresh_details_list(website_setting->m_current_item_data);
490 website_setting->show_notify_popup(BR_STRING_DELETED, 3, EINA_TRUE);
493 void Browser_Settings_Website_Setting::__cancel_clear_web_storage_confirm_response_cb(void *data, Evas_Object *obj, void *event_info)
495 BROWSER_LOGD("[%s]", __func__);
499 Browser_Settings_Website_Setting *website_setting = (Browser_Settings_Website_Setting *)data;
500 if (website_setting->m_clear_confirm_popup) {
501 evas_object_del(website_setting->m_clear_confirm_popup);
502 website_setting->m_clear_confirm_popup = NULL;
506 void Browser_Settings_Website_Setting::__delete_all_website_list_confirm_response_cb(void *data, Evas_Object *obj, void *event_info)
508 BROWSER_LOGD("[%s]", __func__);
512 Browser_Settings_Website_Setting *website_setting = (Browser_Settings_Website_Setting *)data;
513 if (website_setting->m_delete_all_website_list_confirm_popup) {
514 evas_object_del(website_setting->m_delete_all_website_list_confirm_popup);
515 website_setting->m_delete_all_website_list_confirm_popup = NULL;
518 /* Clear Geolocation */
519 Browser_Geolocation_DB geolocation_db;
520 geolocation_db.remove_all_geolocation_data();
522 Ewk_Context *ewk_context = ewk_context_default_get();
523 ewk_context_cache_clear(ewk_context);
524 ewk_context_web_indexed_database_delete_all(ewk_context);
525 ewk_context_application_cache_delete_all(ewk_context);
526 ewk_context_web_storage_delete_all(ewk_context);
527 ewk_context_web_database_delete_all(ewk_context);
529 website_setting->_refresh_website_list();
531 website_setting->show_notify_popup(BR_STRING_DELETED, 3, EINA_TRUE);
534 void Browser_Settings_Website_Setting::__cancel_delete_all_website_list_confirm_response_cb(void *data, Evas_Object *obj, void *event_info)
536 BROWSER_LOGD("[%s]", __func__);
540 Browser_Settings_Website_Setting *website_setting = (Browser_Settings_Website_Setting *)data;
541 if (website_setting->m_delete_all_website_list_confirm_popup) {
542 evas_object_del(website_setting->m_delete_all_website_list_confirm_popup);
543 website_setting->m_delete_all_website_list_confirm_popup = NULL;
547 void Browser_Settings_Website_Setting::__delete_all_details_list_confirm_response_cb(void *data, Evas_Object *obj, void *event_info)
549 BROWSER_LOGD("[%s]", __func__);
553 Browser_Settings_Website_Setting *website_setting = (Browser_Settings_Website_Setting *)data;
554 if (website_setting->m_delete_all_details_list_confirm_popup) {
555 evas_object_del(website_setting->m_delete_all_details_list_confirm_popup);
556 website_setting->m_delete_all_details_list_confirm_popup = NULL;
559 website_setting_item *info = website_setting->m_current_website_item_data;
560 if (info->geolocation) {
561 Browser_Geolocation_DB geolocation_db;
562 geolocation_db.remove_geolocation_data(info->url.c_str());
563 info->geolocation = false;
568 Ewk_Context *ewk_context = ewk_context_default_get();
569 ewk_context_application_cache_delete(ewk_context,
570 (Ewk_Security_Origin*)(info->origin));
571 ewk_context_web_database_delete(ewk_context,
572 (Ewk_Security_Origin*)(info->origin));
573 ewk_context_web_storage_origin_delete(ewk_context,
574 (Ewk_Security_Origin*)(info->origin));
575 info->storage = false;
578 website_setting->__back_button_clicked_cb(NULL, NULL, NULL);
579 website_setting->_refresh_website_list();
581 website_setting->show_notify_popup(BR_STRING_DELETED, 3, EINA_TRUE);
584 void Browser_Settings_Website_Setting::__cancel_delete_all_details_list_confirm_response_cb(void *data, Evas_Object *obj, void *event_info)
586 BROWSER_LOGD("[%s]", __func__);
590 Browser_Settings_Website_Setting *website_setting = (Browser_Settings_Website_Setting *)data;
591 if (website_setting->m_delete_all_details_list_confirm_popup) {
592 evas_object_del(website_setting->m_delete_all_details_list_confirm_popup);
593 website_setting->m_delete_all_details_list_confirm_popup = NULL;
596 void Browser_Settings_Website_Setting::_show_details_list(website_setting_item *item_info)
598 BROWSER_LOGD("[%s]", __func__);
602 m_details_genlist = elm_genlist_add(m_navi_bar);
603 if (!m_details_genlist) {
604 BROWSER_LOGE("elm_genlist_add failed");
608 evas_object_show(m_details_genlist);
610 m_1_text_1_icon_item_class.item_style = "1text.1icon";
611 m_1_text_1_icon_item_class.func.text_get = __details_genlist_label_get;
612 m_1_text_1_icon_item_class.func.content_get = __details_genlist_icon_get;
613 m_1_text_1_icon_item_class.func.state_get = NULL;
614 m_1_text_1_icon_item_class.func.del = NULL;
616 if (item_info->geolocation) {
617 m_location_item_callback_data.type = BR_MENU_LOCATION;
618 m_location_item_callback_data.cp = this;
619 m_location_item_callback_data.user_data = item_info;
620 m_location_item_callback_data.it = elm_genlist_item_append(m_details_genlist,
621 &m_1_text_1_icon_item_class, &m_location_item_callback_data, NULL, ELM_GENLIST_ITEM_NONE,
622 __details_item_selected_cb, &m_location_item_callback_data);
625 if (item_info->storage) {
626 m_web_storage_item_callback_data.type = BR_MENU_WEB_STORAGE;
627 m_web_storage_item_callback_data.cp = this;
628 m_web_storage_item_callback_data.user_data = item_info;
629 m_web_storage_item_callback_data.it = elm_genlist_item_append(m_details_genlist,
630 &m_1_text_1_icon_item_class, &m_web_storage_item_callback_data, NULL, ELM_GENLIST_ITEM_NONE,
631 __details_item_selected_cb, &m_web_storage_item_callback_data);
634 m_back_button_details = elm_button_add(m_details_genlist);
635 if (!m_back_button_details) {
636 BROWSER_LOGE("elm_button_add failed");
639 elm_object_style_set(m_back_button_details, "browser/bookmark_controlbar_back");
640 evas_object_show(m_back_button_details);
641 evas_object_smart_callback_add(m_back_button_details, "clicked", __back_button_clicked_cb, this);
643 Elm_Object_Item *navi_it = elm_naviframe_item_push(m_navi_bar, item_info->url.c_str(),
644 m_back_button_details, NULL, m_details_genlist, "browser_titlebar");
646 m_details_bottom_control_bar = elm_toolbar_add(m_navi_bar);
647 if (!m_details_bottom_control_bar) {
648 BROWSER_LOGE("elm_toolbar_add failed");
651 elm_object_style_set(m_details_bottom_control_bar, "browser/default");
652 elm_toolbar_shrink_mode_set(m_details_bottom_control_bar, ELM_TOOLBAR_SHRINK_EXPAND);
654 m_delete_all_details_conbar_item = elm_toolbar_item_append(m_details_bottom_control_bar,
655 NULL, BR_STRING_DELETE_ALL,
656 __delete_all_details_list_conbar_item_clicked_cb, this);
657 if (elm_genlist_items_count(m_details_genlist) == 0) {
658 elm_object_item_disabled_set(m_delete_all_details_conbar_item, EINA_TRUE);
661 Elm_Object_Item *empty_item = elm_toolbar_item_append(m_details_bottom_control_bar, NULL, NULL, NULL, NULL);
662 elm_object_item_disabled_set(empty_item, EINA_TRUE);
664 empty_item = elm_toolbar_item_append(m_details_bottom_control_bar, NULL, NULL, NULL, NULL);
665 elm_object_item_disabled_set(empty_item, EINA_TRUE);
667 evas_object_show(m_details_bottom_control_bar);
668 elm_object_item_part_content_set(navi_it, ELM_NAVIFRAME_ITEM_CONTROLBAR, m_details_bottom_control_bar);
671 void Browser_Settings_Website_Setting::_refresh_details_list(website_setting_item *item_info)
673 elm_genlist_clear(m_details_genlist);
675 if (item_info->geolocation) {
676 m_location_item_callback_data.type = BR_MENU_LOCATION;
677 m_location_item_callback_data.cp = this;
678 m_location_item_callback_data.user_data = item_info;
679 m_location_item_callback_data.it = elm_genlist_item_append(m_details_genlist,
680 &m_1_text_1_icon_item_class, &m_location_item_callback_data, NULL, ELM_GENLIST_ITEM_NONE,
681 __details_item_selected_cb, &m_location_item_callback_data);
684 if (item_info->storage) {
685 m_web_storage_item_callback_data.type = BR_MENU_WEB_STORAGE;
686 m_web_storage_item_callback_data.cp = this;
687 m_web_storage_item_callback_data.user_data = item_info;
688 m_web_storage_item_callback_data.it = elm_genlist_item_append(m_details_genlist,
689 &m_1_text_1_icon_item_class, &m_web_storage_item_callback_data, NULL, ELM_GENLIST_ITEM_NONE,
690 __details_item_selected_cb, &m_web_storage_item_callback_data);
694 void Browser_Settings_Website_Setting::__back_button_clicked_cb(void *data, Evas_Object *obj, void *event_info)
696 BROWSER_LOGD("[%s]", __func__);
698 if (elm_naviframe_bottom_item_get(m_navi_bar)
699 != elm_naviframe_top_item_get(m_navi_bar))
700 elm_naviframe_item_pop(m_navi_bar);
703 void Browser_Settings_Website_Setting::__delete_all_website_list_conbar_item_clicked_cb(void *data,
704 Evas_Object *obj, void *event_info)
706 BROWSER_LOGD("[%s]", __func__);
707 Browser_Settings_Website_Setting *website_setting = (Browser_Settings_Website_Setting *)data;
709 website_setting->_show_delete_all_website_list_confirm_popup();
712 void Browser_Settings_Website_Setting::__delete_all_details_list_conbar_item_clicked_cb(void *data,
713 Evas_Object *obj, void *event_info)
715 BROWSER_LOGD("[%s]", __func__);
716 Browser_Settings_Website_Setting *website_setting = (Browser_Settings_Website_Setting *)data;
718 website_setting->_show_delete_all_details_list_confirm_popup();
721 void Browser_Settings_Website_Setting::__application_cache_origin_get_cb(Eina_List* origins, void* user_data)
723 BROWSER_LOGD("[%s]", __func__);
724 Browser_Settings_Website_Setting *website_setting = (Browser_Settings_Website_Setting *)user_data;
726 Eina_List *list = NULL;
727 void *list_data = NULL;
729 EINA_LIST_FOREACH(origins, list, list_data) {
730 BROWSER_LOGD("list_data=%d", list_data);
732 Ewk_Security_Origin *origin = (Ewk_Security_Origin *)list_data;;
733 BROWSER_LOGD("<<< host = [%s]", ewk_security_origin_host_get(origin));
735 Eina_Bool duplicated = EINA_FALSE;
736 for (int i = 0 ; i < website_setting->m_website_setting_list.size() ; i++) {
737 if (!website_setting->m_website_setting_list[i]->url.empty()
738 && !strcmp(website_setting->m_website_setting_list[i]->url.c_str(), ewk_security_origin_host_get(origin))) {
739 duplicated = EINA_TRUE;
740 website_setting->m_website_setting_list[i]->storage = EINA_TRUE;
741 website_setting->m_website_setting_list[i]->origin = origin;
743 elm_genlist_item_update((Elm_Object_Item *)(website_setting->m_website_setting_list[i]->user_data));
749 website_setting_item *item = new(nothrow) website_setting_item;
750 item->allow = EINA_FALSE;
751 item->geolocation = EINA_FALSE;
752 item->storage = EINA_TRUE;
753 item->url = std::string(ewk_security_origin_host_get(origin));
754 item->origin = origin;
756 item->user_data = (void*)elm_genlist_item_append(website_setting->m_genlist, &website_setting->m_1_text_2_icon_item_class,
757 item, NULL, ELM_GENLIST_ITEM_NONE,
758 __item_selected_cb, website_setting);
759 website_setting->m_website_setting_list.push_back(item);
764 /* enable the deleteall button at every origin callback
765 because these callbacks are invoked asyncronously*/
766 if (website_setting->m_website_setting_list.size() > 0) {
767 if (website_setting->m_delete_all_website_list_conbar_item != NULL)
768 elm_object_item_disabled_set(website_setting->m_delete_all_website_list_conbar_item, EINA_FALSE);
771 website_setting->m_is_called_appcache_cb_flag = true;
772 if ((website_setting->m_is_called_appcache_cb_flag == true)
773 && (website_setting->m_is_called_webstorage_cb_flag == true)
774 && (website_setting->m_is_called_webdb_cb_flag == true)) {
775 if (website_setting->m_website_setting_list.size() == 0) {
776 website_setting->__back_button_clicked_cb(NULL, NULL, NULL);
781 void Browser_Settings_Website_Setting::__web_storage_origin_get_cb(Eina_List* origins, void* user_data)
783 BROWSER_LOGD("[%s]", __func__);
784 Browser_Settings_Website_Setting *website_setting = (Browser_Settings_Website_Setting *)user_data;
786 Eina_List *list = NULL;
787 void *list_data = NULL;
789 EINA_LIST_FOREACH(origins, list, list_data) {
790 BROWSER_LOGD("list_data=%d", list_data);
792 Ewk_Security_Origin *origin = (Ewk_Security_Origin *)list_data;;
793 BROWSER_LOGD("<<< host = [%s]", ewk_security_origin_host_get(origin));
795 Eina_Bool duplicated = EINA_FALSE;
796 for (int i = 0 ; i < website_setting->m_website_setting_list.size() ; i++) {
797 if (!website_setting->m_website_setting_list[i]->url.empty()
798 && !strcmp(website_setting->m_website_setting_list[i]->url.c_str(), ewk_security_origin_host_get(origin))) {
799 duplicated = EINA_TRUE;
800 website_setting->m_website_setting_list[i]->storage = EINA_TRUE;
801 website_setting->m_website_setting_list[i]->origin = origin;
803 elm_genlist_item_update((Elm_Object_Item *)(website_setting->m_website_setting_list[i]->user_data));
809 website_setting_item *item = new(nothrow) website_setting_item;
810 item->allow = EINA_FALSE;
811 item->geolocation = EINA_FALSE;
812 item->storage = EINA_TRUE;
813 item->url = std::string(ewk_security_origin_host_get(origin));
814 item->origin = origin;
816 item->user_data = (void*)elm_genlist_item_append(website_setting->m_genlist, &website_setting->m_1_text_2_icon_item_class,
817 item, NULL, ELM_GENLIST_ITEM_NONE,
818 __item_selected_cb, website_setting);
819 website_setting->m_website_setting_list.push_back(item);
824 /* enable the deleteall button at every origin callback
825 because these callbacks are invoked asyncronously*/
826 if (website_setting->m_website_setting_list.size() > 0) {
827 if (website_setting->m_delete_all_website_list_conbar_item != NULL)
828 elm_object_item_disabled_set(website_setting->m_delete_all_website_list_conbar_item, EINA_FALSE);
831 website_setting->m_is_called_webstorage_cb_flag = true;
832 if ((website_setting->m_is_called_appcache_cb_flag == true)
833 && (website_setting->m_is_called_webstorage_cb_flag == true)
834 && (website_setting->m_is_called_webdb_cb_flag == true)) {
835 if (website_setting->m_website_setting_list.size() == 0) {
836 website_setting->__back_button_clicked_cb(NULL, NULL, NULL);
841 void Browser_Settings_Website_Setting::__web_database_origin_get_cb(Eina_List* origins, void* user_data)
843 BROWSER_LOGD("[%s]", __func__);
844 Browser_Settings_Website_Setting *website_setting = (Browser_Settings_Website_Setting *)user_data;
846 Eina_List *list = NULL;
847 void *list_data = NULL;
849 EINA_LIST_FOREACH(origins, list, list_data) {
850 BROWSER_LOGD("list_data=%d", list_data);
852 Ewk_Security_Origin *origin = (Ewk_Security_Origin *)list_data;
853 BROWSER_LOGD("<<< host = [%s]", ewk_security_origin_host_get(origin));
855 Eina_Bool duplicated = EINA_FALSE;
856 for (int i = 0 ; i < website_setting->m_website_setting_list.size() ; i++) {
857 if (!website_setting->m_website_setting_list[i]->url.empty()
858 && !strcmp(website_setting->m_website_setting_list[i]->url.c_str(), ewk_security_origin_host_get(origin))) {
859 duplicated = EINA_TRUE;
860 website_setting->m_website_setting_list[i]->storage = EINA_TRUE;
861 website_setting->m_website_setting_list[i]->origin = origin;
863 elm_genlist_item_update((Elm_Object_Item *)(website_setting->m_website_setting_list[i]->user_data));
869 website_setting_item *item = new(nothrow) website_setting_item;
870 item->allow = EINA_FALSE;
871 item->geolocation = EINA_FALSE;
872 item->storage = EINA_TRUE;
873 item->url = std::string(ewk_security_origin_host_get(origin));
874 item->origin = origin;
876 item->user_data = (void*)elm_genlist_item_append(website_setting->m_genlist, &website_setting->m_1_text_2_icon_item_class,
877 item, NULL, ELM_GENLIST_ITEM_NONE,
878 __item_selected_cb, website_setting);
879 website_setting->m_website_setting_list.push_back(item);
885 /* enable the deleteall button at every origin callback
886 because these callbacks are invoked asyncronously*/
887 if (website_setting->m_website_setting_list.size() > 0) {
888 if (website_setting->m_delete_all_website_list_conbar_item != NULL)
889 elm_object_item_disabled_set(website_setting->m_delete_all_website_list_conbar_item, EINA_FALSE);
892 website_setting->m_is_called_webdb_cb_flag = true;
893 if ((website_setting->m_is_called_appcache_cb_flag == true)
894 && (website_setting->m_is_called_webstorage_cb_flag == true)
895 && (website_setting->m_is_called_webdb_cb_flag == true)) {
896 if (website_setting->m_website_setting_list.size() == 0) {
897 website_setting->__back_button_clicked_cb(NULL, NULL, NULL);
902 void Browser_Settings_Website_Setting::_website_list_get(void)
904 BROWSER_LOGD("[%s]", __func__);
905 m_is_called_appcache_cb_flag = false;
906 m_is_called_webstorage_cb_flag = false;
907 m_is_called_webdb_cb_flag = false;
908 Ewk_Context *context = ewk_context_default_get();
909 ewk_context_application_cache_origins_get(context, __application_cache_origin_get_cb, this);
910 ewk_context_web_storage_origins_get(context, __web_storage_origin_get_cb, this);
911 ewk_context_web_database_origins_get(context, __web_database_origin_get_cb, this);
913 Browser_Geolocation_DB geolocation_db;
915 geolocation_db.get_geolocation_info_list(m_geolocation_list);
917 BROWSER_LOGD("geolocation_list size=%d", m_geolocation_list.size());
919 for (int i = 0 ; i < m_geolocation_list.size() ; i++) {
920 m_geolocation_list[i]->user_data = (void* )elm_genlist_item_append(m_genlist, &m_1_text_2_icon_item_class,
921 m_geolocation_list[i], NULL, ELM_GENLIST_ITEM_NONE,
922 __item_selected_cb, this);
924 m_website_setting_list.push_back((website_setting_item *)(m_geolocation_list[i]));
928 void Browser_Settings_Website_Setting::_refresh_website_list(void)
930 BROWSER_LOGD("[%s]", __func__);
932 for (int i = 0 ; i < m_website_setting_list.size() ; i++) {
933 if (m_website_setting_list[i])
934 delete m_website_setting_list[i];
936 m_website_setting_list.clear();
937 m_geolocation_list.clear();
939 elm_genlist_clear(m_genlist);
943 if (m_website_setting_list.size() == 0) {
944 if (m_delete_all_website_list_conbar_item != NULL)
945 elm_object_item_disabled_set(m_delete_all_website_list_conbar_item, EINA_TRUE);
949 Eina_Bool Browser_Settings_Website_Setting::_create_main_layout(void)
951 BROWSER_LOGD("[%s]", __func__);
953 m_genlist = elm_genlist_add(m_navi_bar);
955 BROWSER_LOGE("elm_genlist_add failed");
959 evas_object_show(m_genlist);
961 m_back_button = elm_button_add(m_genlist);
962 if (!m_back_button) {
963 BROWSER_LOGE("elm_button_add failed");
966 elm_object_style_set(m_back_button, "browser/bookmark_controlbar_back");
967 evas_object_show(m_back_button);
968 evas_object_smart_callback_add(m_back_button, "clicked", __back_button_clicked_cb, this);
970 m_1_text_2_icon_item_class.item_style = "1text.3icon.2";
971 m_1_text_2_icon_item_class.func.text_get = __genlist_label_get;
972 m_1_text_2_icon_item_class.func.content_get = __genlist_icon_get;
973 m_1_text_2_icon_item_class.func.state_get = NULL;
974 m_1_text_2_icon_item_class.func.del = NULL;
978 Elm_Object_Item *navi_it = elm_naviframe_item_push(m_navi_bar, BR_STRING_WEBSITE_SETTINGS,
979 m_back_button, NULL, m_genlist, "browser_titlebar");
981 m_bottom_control_bar = elm_toolbar_add(m_navi_bar);
982 if (!m_bottom_control_bar) {
983 BROWSER_LOGE("elm_toolbar_add failed");
986 elm_object_style_set(m_bottom_control_bar, "browser/default");
987 elm_toolbar_shrink_mode_set(m_bottom_control_bar, ELM_TOOLBAR_SHRINK_EXPAND);
989 m_delete_all_website_list_conbar_item = elm_toolbar_item_append(m_bottom_control_bar,
990 NULL, BR_STRING_DELETE_ALL,
991 __delete_all_website_list_conbar_item_clicked_cb, this);
993 if (!m_delete_all_website_list_conbar_item) {
994 BROWSER_LOGE("elm_toolbar_item_append failed");
998 if (m_website_setting_list.size() == 0) {
999 elm_object_item_disabled_set(m_delete_all_website_list_conbar_item, EINA_TRUE);
1002 Elm_Object_Item *empty_item = elm_toolbar_item_append(m_bottom_control_bar, NULL, NULL, NULL, NULL);
1003 elm_object_item_disabled_set(empty_item, EINA_TRUE);
1005 empty_item = elm_toolbar_item_append(m_bottom_control_bar, NULL, NULL, NULL, NULL);
1006 elm_object_item_disabled_set(empty_item, EINA_TRUE);
1008 evas_object_show(m_bottom_control_bar);
1009 elm_object_item_part_content_set(navi_it, ELM_NAVIFRAME_ITEM_CONTROLBAR, m_bottom_control_bar);