Changeset 177357 in webkit
- Timestamp:
- Dec 16, 2014 2:24:13 AM (9 years ago)
- Location:
- trunk/Tools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r177315 r177357 1 2014-12-16 Grzegorz Czajkowski <g.czajkowski@samsung.com> 2 3 [EFL] Add logging domain for MiniBrowser 4 https://bugs.webkit.org/show_bug.cgi?id=139642 5 6 Reviewed by Gyuyoung Kim. 7 8 Similarly to EWebKit2, provide logging facility for MiniBrowser 9 based on Eina Log module to have a convenient way to display 10 all/subset/none messages for EFL based libraries and MiniBrowser. 11 12 Usage: 13 1. Disable all messages: 14 EINA_LOG_LEVEL=0 ./Tools/Scripts/run-launcher --efl 15 16 2. Enable all messages: 17 EINA_LOG_LEVEL=7 ./Tools/Scripts/run-launcher --efl 18 19 3. Enable MiniBrowser and EWebkit2 messages only: 20 EINA_LOG_LEVELS="minibrowser:7,ewebkit2:7" ./Tools/Scripts/run-launcher --efl 21 22 More information and examples you can find here: 23 http://docs.enlightenment.org/auto/eet/tutorial_log_page.html 24 25 * MiniBrowser/efl/main.c: 26 (on_mouse_wheel): 27 (on_window_resize): 28 (save_page_contents_callback): 29 (script_execute_callback): 30 (on_key_down): 31 (on_download_request): 32 (on_download_finished): 33 (on_download_failed): 34 (quit): 35 (on_refresh_button_clicked): 36 (on_stop_button_clicked): 37 (navigation_button_longpress_process): 38 (on_popup_menu_item_clicked): 39 (popup_menu_populate): 40 (on_popup_menu_show): 41 (on_window_create): 42 (context_menu_item_selected_cb): 43 (context_menu_populate): 44 (on_context_menu_show): 45 (on_context_menu_hide): 46 (on_navigation_policy_decision): 47 (window_create): 48 (parse_cookies_policy): 49 (elm_main): 50 (has_scheme): 51 (list_item_label_get): 52 (on_popup_menu_hide): 53 (on_window_close): 54 (on_home_button_clicked): 55 Replace locally info() macro with newly introduced 56 one which uses Eina Log module. There is no logic change. 57 1 58 2014-12-15 Dániel Bátyai <dbatyai.u-szeged@partner.samsung.com> 2 59 -
trunk/Tools/MiniBrowser/efl/main.c
r177256 r177357 38 38 static const double LIST_ITEM_HEIGHT = 24.35; 39 39 40 #define info(format, args...) \41 do { \42 if (verbose) \43 printf(format"\n", ##args); \44 } while (0)45 46 static int verbose = 1;47 40 static Eina_List *windows = NULL; 48 41 static char *evas_engine_name = NULL; … … 71 64 // The zoom values are chosen to be like in Mozilla Firefox 3. 72 65 const static float zoomLevels[] = {0.3, 0.5, 0.67, 0.8, 0.9, 1.0, 1.1, 1.2, 1.33, 1.5, 1.7, 2.0, 2.4, 3.0}; 66 static int _log_domain_id = -1; 67 68 #define INFO(...) EINA_LOG_DOM_INFO(_log_domain_id, __VA_ARGS__) 69 #define ERROR(...) EINA_LOG_DOM_ERR(_log_domain_id, __VA_ARGS__) 73 70 74 71 static Eina_Bool … … 317 314 if (ev->z == -1 && zoom_level_set(ewk_view, window->current_zoom_level + 1)) { 318 315 window->current_zoom_level++; 319 info("Zoom in (Ctrl + 'scroll up') was pressed, zoom level became %.2f", zoomLevels[window->current_zoom_level]);316 INFO("Zoom in (Ctrl + 'scroll up') was pressed, zoom level became %.2f", zoomLevels[window->current_zoom_level]); 320 317 } else if (ev->z == 1 && zoom_level_set(ewk_view, window->current_zoom_level - 1)) { 321 318 window->current_zoom_level--; 322 info("Zoom out (Ctrl + 'scroll down') was pressed, zoom level became %.2f", zoomLevels[window->current_zoom_level]);319 INFO("Zoom out (Ctrl + 'scroll down') was pressed, zoom level became %.2f", zoomLevels[window->current_zoom_level]); 323 320 } 324 321 } … … 331 328 332 329 if (!window) { 333 info("ERROR: window is NULL.");330 ERROR("Window is NULL."); 334 331 return; 335 332 } … … 482 479 eina_strbuf_append_printf(fileNameWithMht, "%s.mht", fileName); 483 480 ef = eet_open(eina_strbuf_string_get(fileNameWithMht), EET_FILE_MODE_WRITE); 484 info("Saving file to: %s", eina_strbuf_string_get(fileNameWithMht));481 INFO("Saving file to: %s", eina_strbuf_string_get(fileNameWithMht)); 485 482 eina_strbuf_free(fileNameWithMht); 486 483 } else { 487 484 ef = eet_open(fileName, EET_FILE_MODE_WRITE); 488 info("Saving file to: %s", fileName);485 INFO("Saving file to: %s", fileName); 489 486 } 490 487 491 488 if (!ef) { 492 info("ERROR:Could not create File");489 ERROR("Could not create File"); 493 490 return; 494 491 } … … 496 493 eet_write(ef, "MHTML data", data, strlen(data), 0 /* compress */); 497 494 eet_close(ef); 498 info("SUCCESS: saved.");495 INFO("SUCCESS: saved."); 499 496 500 497 eina_stringshare_del(fileName); … … 510 507 if (return_value) { 511 508 eina_strbuf_append(text_buffer, return_value); 512 info("selected text is: %s", eina_strbuf_string_get(text_buffer));509 INFO("selected text is: %s", eina_strbuf_string_get(text_buffer)); 513 510 elm_entry_entry_set(window->search.search_field, eina_strbuf_string_get(text_buffer)); 514 511 } … … 535 532 536 533 if (!strcmp(ev->key, "Left") && altPressed) { 537 info("Back (Alt+Left) was pressed");534 INFO("Back (Alt+Left) was pressed"); 538 535 if (!ewk_view_back(ewk_view)) 539 info("Back ignored: No back history");536 INFO("Back ignored: No back history"); 540 537 } else if (!strcmp(ev->key, "Right") && altPressed) { 541 info("Forward (Alt+Right) was pressed");538 INFO("Forward (Alt+Right) was pressed"); 542 539 if (!ewk_view_forward(ewk_view)) 543 info("Forward ignored: No forward history");540 INFO("Forward ignored: No forward history"); 544 541 } else if (!strcmp(ev->key, "Home") && altPressed) { 545 info("Home (Alt+Home) was pressed");542 INFO("Home (Alt+Home) was pressed"); 546 543 ewk_view_url_set(window->ewk_view, DEFAULT_URL); 547 544 } else if (!strcmp(ev->key, "F3")) { 548 545 currentEncoding = (currentEncoding + 1) % (sizeof(encodings) / sizeof(encodings[0])); 549 info("Set encoding (F3) pressed. New encoding to %s", encodings[currentEncoding]);546 INFO("Set encoding (F3) pressed. New encoding to %s", encodings[currentEncoding]); 550 547 ewk_view_custom_encoding_set(ewk_view, encodings[currentEncoding]); 551 548 } else if ((!strcmp(ev->key, "F5") && ctrlPressed) || (!strcmp(ev->key, "r") && (shiftPressed & ctrlPressed))) { 552 info("Reload ignoring cache (Ctrl+F5 or Ctrl+Shift+r) was pressed, reloading and bypassing cache...");549 INFO("Reload ignoring cache (Ctrl+F5 or Ctrl+Shift+r) was pressed, reloading and bypassing cache..."); 553 550 ewk_view_reload_bypass_cache(ewk_view); 554 551 } else if (!strcmp(ev->key, "F5") || (!strcmp(ev->key, "r") && ctrlPressed)) { 555 info("Reload (F5 or Ctrl+r) was pressed, reloading...");552 INFO("Reload (F5 or Ctrl+r) was pressed, reloading..."); 556 553 ewk_view_reload(ewk_view); 557 554 } else if (!strcmp(ev->key, "F6")) { 558 info("Stop (F6) was pressed, stop loading.");555 INFO("Stop (F6) was pressed, stop loading."); 559 556 ewk_view_stop(ewk_view); 560 557 } else if (!strcmp(ev->key, "F7")) { … … 562 559 mode = (++mode) % (EWK_PAGINATION_MODE_BOTTOM_TO_TOP + 1); 563 560 if (ewk_view_pagination_mode_set(ewk_view, mode)) 564 info("Change Pagination Mode (F7) was pressed, changed to: %d", mode);561 INFO("Change Pagination Mode (F7) was pressed, changed to: %d", mode); 565 562 else 566 info("Change Pagination Mode (F7) was pressed, but NOT changed!");563 INFO("Change Pagination Mode (F7) was pressed, but NOT changed!"); 567 564 } else if (!strcmp(ev->key, "F11")) { 568 info("Fullscreen (F11) was pressed, toggling window/fullscreen.");565 INFO("Fullscreen (F11) was pressed, toggling window/fullscreen."); 569 566 elm_win_fullscreen_set(window->elm_window, !elm_win_fullscreen_get(window->elm_window)); 570 567 } else if (!strcmp(ev->key, "n") && ctrlPressed) { 571 info("Create new window (Ctrl+n) was pressed.");568 INFO("Create new window (Ctrl+n) was pressed."); 572 569 Browser_Window *window = window_create(NULL, 0, 0); 573 570 ewk_view_url_set(window->ewk_view, DEFAULT_URL); … … 575 572 windows = eina_list_append(windows, window); 576 573 } else if (!strcmp(ev->key, "i") && ctrlPressed) { 577 info("Show Inspector (Ctrl+i) was pressed.");574 INFO("Show Inspector (Ctrl+i) was pressed."); 578 575 ewk_view_inspector_show(ewk_view); 579 576 } else if (!strcmp(ev->key, "f") && ctrlPressed) { 580 info("Show Search Box (Ctrl+f) was pressed.");577 INFO("Show Search Box (Ctrl+f) was pressed."); 581 578 const char get_data_script[] = "window.getSelection().toString();"; 582 579 ewk_view_script_execute(ewk_view, get_data_script, script_execute_callback, (void*)(window)); … … 593 590 if (zoom_level_set(ewk_view, window->current_zoom_level - 1)) 594 591 window->current_zoom_level--; 595 info("Zoom out (Ctrl + '-') was pressed, zoom level became %.2f", zoomLevels[window->current_zoom_level]);592 INFO("Zoom out (Ctrl + '-') was pressed, zoom level became %.2f", zoomLevels[window->current_zoom_level]); 596 593 } else if (ctrlPressed && (!strcmp(ev->key, "equal") || !strcmp(ev->key, "KP_Add"))) { 597 594 if (zoom_level_set(ewk_view, window->current_zoom_level + 1)) 598 595 window->current_zoom_level++; 599 info("Zoom in (Ctrl + '+') was pressed, zoom level became %.2f", zoomLevels[window->current_zoom_level]);596 INFO("Zoom in (Ctrl + '+') was pressed, zoom level became %.2f", zoomLevels[window->current_zoom_level]); 600 597 } else if (ctrlPressed && !strcmp(ev->key, "0")) { 601 598 if (zoom_level_set(ewk_view, DEFAULT_ZOOM_LEVEL)) 602 599 window->current_zoom_level = DEFAULT_ZOOM_LEVEL; 603 info("Zoom to default (Ctrl + '0') was pressed, zoom level became %.2f", zoomLevels[window->current_zoom_level]);600 INFO("Zoom to default (Ctrl + '0') was pressed, zoom level became %.2f", zoomLevels[window->current_zoom_level]); 604 601 } else if (ctrlPressed && !strcmp(ev->key, "s")) { 605 602 Eina_Strbuf *default_file = eina_strbuf_new(); … … 607 604 const char *title = ewk_view_title_get(window->ewk_view); 608 605 eina_strbuf_append_printf(default_file, "%s/%s.mht", home_path ? home_path : "/home", title ? title : "title"); 609 info("Pressed (CTRL + S) : Saving Current Page.");606 INFO("Pressed (CTRL + S) : Saving Current Page."); 610 607 Eina_Stringshare *save_file_name = show_file_entry_dialog(window, "SAVE", eina_strbuf_string_get(default_file)); 611 608 if (!save_file_name) … … 620 617 Eina_Strbuf *uri_path = eina_strbuf_new(); 621 618 eina_strbuf_append_printf(uri_path, "file://%s", open_file_name); 622 info("pressed (CTRL + L) : Loading Page %s", eina_strbuf_string_get(uri_path));619 INFO("pressed (CTRL + L) : Loading Page %s", eina_strbuf_string_get(uri_path)); 623 620 ewk_view_url_set(ewk_view, eina_strbuf_string_get(uri_path)); 624 621 eina_strbuf_free(uri_path); … … 760 757 url = eina_strbuf_string_steal(destination_path); 761 758 if (mkstemp(url) == -1) { 762 info("ERROR:Could not generate a unique file name.");759 ERROR("Could not generate a unique file name."); 763 760 return; 764 761 } … … 767 764 768 765 ewk_download_job_destination_set(download, eina_strbuf_string_get(destination_path)); 769 info("Downloading: %s", eina_strbuf_string_get(destination_path));766 INFO("Downloading: %s", eina_strbuf_string_get(destination_path)); 770 767 eina_strbuf_free(destination_path); 771 768 eina_stringshare_del(save_file_path); … … 849 846 { 850 847 Ewk_Download_Job *download = (Ewk_Download_Job *)event_info; 851 info("Download finished: %s", ewk_download_job_destination_get(download));848 INFO("Download finished: %s", ewk_download_job_destination_get(download)); 852 849 } 853 850 … … 855 852 on_download_failed(void *user_data, Evas_Object *ewk_view, void *event_info) 856 853 { 857 info("Download failed!");854 INFO("Download failed!"); 858 855 } 859 856 … … 988 985 quit(Eina_Bool success, const char *msg) 989 986 { 987 if (msg) 988 success ? INFO(msg) : ERROR(msg); 989 990 eina_log_domain_unregister(_log_domain_id); 990 991 ewk_shutdown(); 991 992 elm_shutdown(); 992 993 if (msg)994 fputs(msg, (success) ? stdout : stderr);995 993 996 994 if (!success) … … 1182 1180 Eina_Bool ctrlPressed = evas_key_modifier_is_set(evas_key_modifier_get(evas), "Control"); 1183 1181 if (ctrlPressed) { 1184 info("Reloading and bypassing cache...");1182 INFO("Reloading and bypassing cache..."); 1185 1183 ewk_view_reload_bypass_cache(window->ewk_view); 1186 1184 } else { 1187 info("Reloading...");1185 INFO("Reloading..."); 1188 1186 ewk_view_reload(window->ewk_view); 1189 1187 } … … 1195 1193 Browser_Window *window = (Browser_Window *)user_data; 1196 1194 1197 info("Stop was Pressed. Aborting load...");1195 INFO("Stop was Pressed. Aborting load..."); 1198 1196 ewk_view_stop(window->ewk_view); 1199 1197 } … … 1255 1253 1256 1254 item_count = eina_list_count(window->history.history_list_items); 1257 info("navigation_button_longpress_process : Item count = %d forward_navigation_enabled = %d", item_count, forward_navigation_enabled);1255 INFO("navigation_button_longpress_process : Item count = %d forward_navigation_enabled = %d", item_count, forward_navigation_enabled); 1258 1256 1259 1257 EINA_LIST_FOREACH(window->history.history_list_items, l, data) { 1260 1258 title = ewk_back_forward_list_item_title_get(data); 1261 info(" title = %s", title);1259 INFO(" title = %s", title); 1262 1260 elm_genlist_item_append(window->history.history_list, list_item, (void *)(title), NULL, ELM_GENLIST_ITEM_NONE, on_list_item_select, data); 1263 1261 } … … 1496 1494 Elm_Object_Item *item = (Elm_Object_Item *)event_info; 1497 1495 1498 info("Selected popup menu index: %u", elm_menu_item_index_get(item));1496 INFO("Selected popup menu index: %u", elm_menu_item_index_get(item)); 1499 1497 ewk_popup_menu_selected_index_set(window->popup.ewk_menu, elm_menu_item_index_get(item)); 1500 1498 … … 1530 1528 break; 1531 1529 default: 1532 info("Unrecognized popup menu item type!");1530 INFO("Unrecognized popup menu item type!"); 1533 1531 break; 1534 1532 } … … 1549 1547 popup_menu_populate(window->popup.elm_menu, ewk_menu, window); 1550 1548 1551 info("Showing popup menu at (%d, %d)", rect.x, rect.y);1549 INFO("Showing popup menu at (%d, %d)", rect.x, rect.y); 1552 1550 elm_menu_move(window->popup.elm_menu, rect.x, rect.y); 1553 1551 evas_object_show(window->popup.elm_menu); … … 1681 1679 windows = eina_list_append(windows, window); 1682 1680 1683 info("minibrowser: location(%d,%d) size=(%d,%d)", x, y, width, height);1681 INFO("minibrowser: location(%d,%d) size=(%d,%d)", x, y, width, height); 1684 1682 1685 1683 return new_view; … … 1697 1695 { 1698 1696 if (!data) { 1699 info("ERROR: context menu callback data is NULL.");1697 ERROR("Context menu callback data is NULL."); 1700 1698 return; 1701 1699 } 1702 1700 1703 1701 Ewk_Context_Menu_Item *ewk_item = (Ewk_Context_Menu_Item *)data; 1704 info("Selected context menu item: %s.", ewk_context_menu_item_title_get(ewk_item));1702 INFO("Selected context menu item: %s.", ewk_context_menu_item_title_get(ewk_item)); 1705 1703 ewk_context_menu_item_select(ewk_context_menu_item_parent_menu_get(ewk_item), ewk_item); 1706 1704 ewk_context_menu_hide(ewk_context_menu_item_parent_menu_get(ewk_item)); … … 1711 1709 { 1712 1710 if (!context_menu || !ewk_menu) { 1713 info("ERROR: necessary objects are NULL.");1711 ERROR("Necessary objects are NULL."); 1714 1712 return; 1715 1713 } … … 1753 1751 1754 1752 if (!window || !menu) { 1755 info("ERROR: necessary objects are NULL.");1753 ERROR("Necessary objects are NULL."); 1756 1754 return EINA_FALSE; 1757 1755 } … … 1760 1758 1761 1759 if (!window->context_menu.elm_menu) { 1762 info("ERROR: could not create menu widget.");1760 ERROR("Could not create menu widget."); 1763 1761 return EINA_FALSE; 1764 1762 } … … 1768 1766 context_menu_populate(window->context_menu.elm_menu, menu, NULL); 1769 1767 1770 info("Showing context menu at (%d, %d).", x, y);1768 INFO("Showing context menu at (%d, %d).", x, y); 1771 1769 elm_menu_move(window->context_menu.elm_menu, x, y); 1772 1770 evas_object_show(window->context_menu.elm_menu); … … 1781 1779 1782 1780 if (!window || !window->context_menu.elm_menu) { 1783 info("ERROR: necessary objects are NULL.");1781 ERROR("Necessary objects are NULL."); 1784 1782 return EINA_FALSE; 1785 1783 } … … 1970 1968 ewk_view_url_set(window->ewk_view, ewk_url_request_url_get(ewk_navigation_policy_request_get(decision))); 1971 1969 windows = eina_list_append(windows, window); 1972 info("Mouse middle button pressed, open link in new window");1970 INFO("Mouse middle button pressed, open link in new window"); 1973 1971 1974 1972 ewk_navigation_policy_decision_reject(decision); … … 2010 2008 Browser_Window *window = calloc(1, sizeof(Browser_Window)); 2011 2009 if (!window) { 2012 info("ERROR: could not create browser window.");2010 ERROR("Could not create browser window."); 2013 2011 return NULL; 2014 2012 } … … 2255 2253 ewk_settings_frame_flattening_enabled_set(settings, frame_flattening_enabled); 2256 2254 ewk_settings_local_storage_enabled_set(settings, local_storage_enabled); 2257 info("HTML5 local storage is %s for this view.", local_storage_enabled ? "enabled" : "disabled");2255 INFO("HTML5 local storage is %s for this view.", local_storage_enabled ? "enabled" : "disabled"); 2258 2256 elm_win_fullscreen_set(window->elm_window, fullscreen_enabled); 2259 2257 ewk_settings_developer_extras_enabled_set(settings, EINA_TRUE); … … 2314 2312 return EWK_COOKIE_ACCEPT_POLICY_NEVER; 2315 2313 if (strcmp(input_string, "no-third-party")) 2316 info("Unrecognized type for cookies policy: %s.", input_string);2314 INFO("Unrecognized type for cookies policy: %s.", input_string); 2317 2315 return EWK_COOKIE_ACCEPT_POLICY_NO_THIRD_PARTY; 2318 2316 } … … 2379 2377 return EXIT_FAILURE; 2380 2378 2379 _log_domain_id = eina_log_domain_register("minibrowser", EINA_COLOR_YELLOW); 2380 2381 2381 ewk_view_smart_class_set(miniBrowserViewSmartClass()); 2382 2382 … … 2385 2385 2386 2386 if (args < 0) 2387 return quit(EINA_FALSE, " ERROR: could not parse options.\n");2387 return quit(EINA_FALSE, "Could not parse options."); 2388 2388 2389 2389 if (quitOption) … … 2425 2425 window = window_create(NULL, 0, 0); 2426 2426 if (!window) 2427 return quit(EINA_FALSE, " ERROR: could not create browser window.\n");2427 return quit(EINA_FALSE, "Could not create browser window."); 2428 2428 2429 2429 if (args < argc) {
Note: See TracChangeset
for help on using the changeset viewer.