summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunghwan <junghwan.kang@samsung.com>2012-09-04 15:59:36 +0900
committerJunghwan <junghwan.kang@samsung.com>2012-09-04 16:03:58 +0900
commit4e2d448220ac0518223e4f90063f8a37de6f48a1 (patch)
tree6fc6cdaaad0fddea08c939d6e5c9bbaa640bd926
parent695063683e3f8dd6f4b554365a40043f97fe0c3b (diff)
downloadorg.tizen.browser-4e2d448220ac0518223e4f90063f8a37de6f48a1.tar.gz
org.tizen.browser-4e2d448220ac0518223e4f90063f8a37de6f48a1.tar.bz2
org.tizen.browser-4e2d448220ac0518223e4f90063f8a37de6f48a1.zip
Add customized application context menu view
[Title] Add customized application context menu view [Issue#] S1-7846 [Problem] As per UI share option should be in pop up [Cause] UX changed [Solution] Add customized application context menu view [Team] Browser UI [Developer] junghwan kang (junghwan.kang) [Request] N/A Change-Id: Ia5921f557f25e442a73878fbdf57bdb55f1b7ed1
-rwxr-xr-xsrc/browser-common-view.cpp11
-rwxr-xr-xsrc/browser-common-view.h1
-rwxr-xr-xsrc/browser-view/browser-context-menu.cpp601
-rwxr-xr-xsrc/browser-view/browser-context-menu.h54
-rwxr-xr-xsrc/browser-view/browser-view.cpp27
-rwxr-xr-xsrc/browser-view/browser-view.h1
-rwxr-xr-xsrc/include/browser-string.h4
7 files changed, 659 insertions, 40 deletions
diff --git a/src/browser-common-view.cpp b/src/browser-common-view.cpp
index 2853edf..3fe7b69 100755
--- a/src/browser-common-view.cpp
+++ b/src/browser-common-view.cpp
@@ -177,6 +177,17 @@ void Browser_Common_View::show_notify_popup(const char *msg, int timeout, Eina_B
evas_object_show(m_selection_info);
}
+Eina_Bool Browser_Common_View::find_word_with_text(const char *text_to_find)
+{
+ BROWSER_LOGD("[%s], text_to_find[%s]", __func__, text_to_find);
+
+ if (!text_to_find)
+ return EINA_FALSE;
+
+ Browser_View *browser_view = m_data_manager->get_browser_view();
+ return browser_view->launch_find_word_with_text(text_to_find);;
+}
+
/* Capture snapshot with current focused ewk view. */
Evas_Object *Browser_Common_View::_capture_snapshot(Browser_Window *window, float scale)
{
diff --git a/src/browser-common-view.h b/src/browser-common-view.h
index 56b7842..80cfa14 100755
--- a/src/browser-common-view.h
+++ b/src/browser-common-view.h
@@ -49,6 +49,7 @@ public:
void show_msg_popup(const char *title, const char *msg, int timeout);
void show_notify_popup(const char *msg, int timeout = 0, Eina_Bool has_control_bar = EINA_FALSE);
void hide_notify_popup(void);
+ Eina_Bool find_word_with_text(const char *text_to_find);
protected:
Evas_Object *_capture_snapshot(Browser_Window *window, float scale);
void _set_navigationbar_title(const char *title);
diff --git a/src/browser-view/browser-context-menu.cpp b/src/browser-view/browser-context-menu.cpp
index be719d3..7764024 100755
--- a/src/browser-view/browser-context-menu.cpp
+++ b/src/browser-view/browser-context-menu.cpp
@@ -39,7 +39,7 @@ void Browser_Context_Menu::init(Evas_Object *ewk_view)
m_ewk_view = ewk_view;
- evas_object_smart_callback_add(ewk_view, "contextmenu,customize", __get_context_menu_from_proposed_context_menu_cb, NULL);
+ evas_object_smart_callback_add(ewk_view, "contextmenu,customize", __get_context_menu_from_proposed_context_menu_cb, this);
evas_object_smart_callback_add(ewk_view, "contextmenu,selected", __custom_context_menu_item_selected_cb, this);
}
@@ -54,33 +54,596 @@ void Browser_Context_Menu::deinit(void)
}
}
+Eina_Bool Browser_Context_Menu::launch_context_menu(Ewk_Context_Menu *menu)
+{
+ BROWSER_LOGD("[%s]", __func__);
+
+ if (!menu)
+ return EINA_FALSE;
+
+ switch (_check_context_menu_mode(menu)) {
+ case CUSTOM_CONTEXT_MENU_TEXT_ONLY_MODE:
+ _append_text_only_mode_context_menu(menu);
+ break;
+
+ case CUSTOM_CONTEXT_MENU_HYPERLINK_ONLY_MODE:
+ _append_hyperlink_only_mode_context_menu(menu);
+ break;
+
+ case CUSTOM_CONTEXT_MENU_TEXT_WITH_HYPERLINK_MODE:
+ _append_text_with_hyperlink_mode_context_menu(menu);
+ break;
+
+ case CUSTOM_CONTEXT_MENU_IMAGE_ONLY_MODE:
+ _append_image_only_mode_context_menu(menu);
+ break;
+
+ case CUSTOM_CONTEXT_MENU_IMAGE_WITH_HYPERLINK_MODE:
+ _append_image_with_hyperlink_mode_context_menu(menu);
+ break;
+
+ case CUSTOM_CONTEXT_MENU_TEXT_AND_IMAGE_SELECTION_MODE:
+ /* To do */
+ break;
+
+ default:
+ _append_normal_mode_context_menu(menu);
+ break;
+ }
+}
+
void Browser_Context_Menu::__get_context_menu_from_proposed_context_menu_cb(void *data, Evas_Object *obj, void *event_info)
{
BROWSER_LOGD("[%s]", __func__);
if (!event_info)
return;
+ if (!data)
+ return;
+
Ewk_Context_Menu *menu = static_cast<Ewk_Context_Menu*>(event_info);
+ Browser_Context_Menu *context_menu = static_cast<Browser_Context_Menu *>(data);
+ context_menu->launch_context_menu(menu);
+}
+
+void Browser_Context_Menu::__custom_context_menu_item_selected_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ BROWSER_LOGD("[%s]", __func__);
+ if (!event_info)
+ return;
+
+ Ewk_Context_Menu_Item* item = static_cast<Ewk_Context_Menu_Item*>(event_info);
+ Browser_Context_Menu *context_menu = static_cast<Browser_Context_Menu *>(data);
+
+ std::string link_url_string = ewk_context_menu_item_link_url_get(item);
+ BROWSER_LOGD("link url=[%s]", link_url_string.c_str());
+ std::string image_url_string = ewk_context_menu_item_image_url_get(item);
+ BROWSER_LOGD("image url=[%s]", image_url_string.c_str());
+
+ const char *selected_text = ewk_view_text_selection_text_get(context_menu->m_ewk_view);
+
+ Ewk_Context_Menu_Item_Tag tag = ewk_context_menu_item_tag_get(item);
+ switch (tag) {
+ case CUSTOM_CONTEXT_MENU_ITEM_TEXT_SHARE_TAG:
+ BROWSER_LOGD("Share selected text[%s]", selected_text);
+ if (selected_text && strlen(selected_text) > 0)
+ context_menu->_show_share_popup(selected_text);
+ break;
+ case CUSTOM_CONTEXT_MENU_ITEM_FIND_ON_TAG:
+ BROWSER_LOGD("Find selected text[%s] on the page", selected_text);
+ if (selected_text && strlen(selected_text) > 0)
+ context_menu->find_word_with_text(selected_text);
+ break;
+ case CUSTOM_CONTEXT_MENU_ITEM_LINK_SHARE_TAG:
+ BROWSER_LOGD("Share popup for link show");
+ context_menu->_show_share_popup(link_url_string.c_str());
+ break;
+ case CUSTOM_CONTEXT_MENU_ITEM_IMAGE_SHARE_TAG:
+ BROWSER_LOGD("Share popup for image show");
+ context_menu->_show_share_popup(image_url_string.c_str());
+ break;
+ case CUSTOM_CONTEXT_MENU_ITEM_SELECTION_MODE_FROM_TEXT_WITH_HYPERLINK_TAG:
+ {
+ /* FIXME - put text selection mode activating code when it is ready */
+ Evas_Object *ewk_view = context_menu->m_ewk_view;
+ Ewk_View_Smart_Data *smart_data = 0;
+ int pressed_x = context_menu->get_pressed_position_x();
+ int pressed_y = context_menu->get_pressed_position_y();
+
+ if (!ewk_view) {
+ BROWSER_LOGD("ewk_view is NULL");
+ break;
+ }
+ smart_data = (Ewk_View_Smart_Data *)evas_object_smart_data_get(ewk_view);
+ if (!smart_data) {
+ BROWSER_LOGD("smart_Data is NULL");
+ break;
+ }
+ if (smart_data->api->text_selection_down(smart_data, pressed_x, pressed_y) == EINA_FALSE)
+ BROWSER_LOGD("text_selection_down failed");
+
+ if (smart_data->api->text_selection_up(smart_data, pressed_x, pressed_y) == EINA_FALSE)
+ BROWSER_LOGD("text_selection_up failed");
+
+ break;
+ }
+ case CUSTOM_CONTEXT_MENU_ITEM_SELECTION_MODE_FROM_TEXT_TAG:
+ case CUSTOM_CONTEXT_MENU_ITEM_SELECTION_MODE_FROM_IMAGE_TAG:
+ case CUSTOM_CONTEXT_MENU_ITEM_SELECTION_MODE_FROM_IMAGE_WITH_HYPERLINK_TAG:
+ /* FIXME - put text selection mode activating code when it is ready */
+ BROWSER_LOGD("Selection mode");
+ break;
+ default:
+ break;
+ }
+}
+
+Eina_Bool Browser_Context_Menu::_check_context_menu_mode(Ewk_Context_Menu *menu)
+{
+ BROWSER_LOGD("[%s]", __func__);
+
+ if (!menu)
+ return EINA_FALSE;
+
+ int count = ewk_context_menu_item_count(menu);
+
+ Eina_Bool has_text = EINA_FALSE;
+ Eina_Bool has_image = EINA_FALSE;
+ Eina_Bool has_hyperlink = EINA_FALSE;
+
Ewk_Context_Menu_Item *item;
Ewk_Context_Menu_Item_Tag tag;
+
+ for (int i = 0; i < count; i++) {
+ item = ewk_context_menu_nth_item_get(menu, i);
+ tag = ewk_context_menu_item_tag_get(item);
+ BROWSER_LOGD("tag[%d]", tag);
+
+ if ((tag == EWK_CONTEXT_MENU_ITEM_TAG_COPY)
+ || (tag == EWK_CONTEXT_MENU_ITEM_TAG_CUT)
+ || (tag == EWK_CONTEXT_MENU_ITEM_TAG_PASTE)
+ || (tag == EWK_CONTEXT_MENU_ITEM_TAG_SELECT_ALL)
+ || (tag == EWK_CONTEXT_MENU_ITEM_TAG_SEARCH_WEB)
+ || (tag == EWK_CONTEXT_MENU_ITEM_TAG_SELECT_WORD))
+ has_text = EINA_TRUE;
+
+ if ((tag == EWK_CONTEXT_MENU_ITEM_TAG_OPEN_LINK)
+ || (tag == EWK_CONTEXT_MENU_ITEM_TAG_OPEN_LINK_IN_NEW_WINDOW)
+ || (tag == EWK_CONTEXT_MENU_ITEM_TAG_DOWNLOAD_LINK_TO_DISK)
+ || (tag == EWK_CONTEXT_MENU_ITEM_TAG_COPY_LINK_TO_CLIPBOARD))
+ has_hyperlink = EINA_TRUE;
+
+ if ((tag == EWK_CONTEXT_MENU_ITEM_TAG_COPY_IMAGE_TO_CLIPBOARD)
+ || (tag == EWK_CONTEXT_MENU_ITEM_TAG_DOWNLOAD_IMAGE_TO_DISK)
+ || (tag == EWK_CONTEXT_MENU_ITEM_TAG_OPEN_FRAME_IN_NEW_WINDOW)
+ || (tag == EWK_CONTEXT_MENU_ITEM_TAG_OPEN_IMAGE_IN_NEW_WINDOW))
+ has_image = EINA_TRUE;
+ }
+
+ if (has_text == EINA_TRUE && has_hyperlink == EINA_FALSE && has_image == EINA_FALSE) {
+ BROWSER_LOGD("CUSTOM_CONTEXT_MENU_TEXT_ONLY_MODE");
+ return CUSTOM_CONTEXT_MENU_TEXT_ONLY_MODE;
+ } else if (has_text == EINA_TRUE && has_hyperlink == EINA_FALSE && has_image == EINA_TRUE) {
+ BROWSER_LOGD("CUSTOM_CONTEXT_MENU_TEXT_AND_IMAGE_SELECTION_MODE");
+ return CUSTOM_CONTEXT_MENU_TEXT_AND_IMAGE_SELECTION_MODE;
+ } else if (has_text == EINA_TRUE && has_hyperlink == EINA_TRUE && has_image == EINA_TRUE) {
+ BROWSER_LOGD("CUSTOM_CONTEXT_MENU_TEXT_WITH_HYPERLINK_MODE");
+ return CUSTOM_CONTEXT_MENU_TEXT_WITH_HYPERLINK_MODE;
+ } else if (has_text == EINA_FALSE && has_hyperlink == EINA_TRUE && has_image == EINA_FALSE) {
+ BROWSER_LOGD("CUSTOM_CONTEXT_MENU_HYPERLINK_ONLY_MODE");
+ return CUSTOM_CONTEXT_MENU_HYPERLINK_ONLY_MODE;
+ } else if (has_text == EINA_FALSE && has_hyperlink == EINA_FALSE && has_image == EINA_TRUE){
+ BROWSER_LOGD("CUSTOM_CONTEXT_MENU_IMAGE_ONLY_MODE");
+ return CUSTOM_CONTEXT_MENU_IMAGE_ONLY_MODE;
+ } else if (has_text == EINA_FALSE && has_hyperlink == EINA_TRUE && has_image == EINA_TRUE){
+ BROWSER_LOGD("CUSTOM_CONTEXT_MENU_IMAGE_WITH_HYPERLINK_MODE");
+ return CUSTOM_CONTEXT_MENU_IMAGE_WITH_HYPERLINK_MODE;
+ } else{
+ BROWSER_LOGD("CUSTOM_CONTEXT_MENU_MODE_INDEX_END");
+ return CUSTOM_CONTEXT_MENU_MODE_INDEX_END;
+ }
+}
+
+Eina_Bool Browser_Context_Menu::_append_text_only_mode_context_menu(Ewk_Context_Menu *menu)
+{
+ BROWSER_LOGD("[%s]", __func__);
+
+ if (!menu)
+ return EINA_FALSE;
+
+ Ewk_Context_Menu_Item *item;
+ Ewk_Context_Menu_Item_Tag tag;
+ int index = 0;
int count = ewk_context_menu_item_count(menu);
+ int *custom_context_menu_array = NULL;
+
+ if (count == 0)
+ return EINA_FALSE;
+ custom_context_menu_array = (int *)malloc(sizeof(int) * count);
+ if (!custom_context_menu_array)
+ return EINA_FALSE;
+
+ memset(custom_context_menu_array, 0x00, sizeof(int) * count);
+
+ /* To re-arrange menu order to follow UX guideline
+ : copy menu would be best if it's at the first in context menu */
+ for (int i = 0; i < count; i++) {
+ item = ewk_context_menu_nth_item_get(menu, i);
+ tag = ewk_context_menu_item_tag_get(item);
+
+ if (tag == EWK_CONTEXT_MENU_ITEM_TAG_COPY) {
+ custom_context_menu_array[index++] = EWK_CONTEXT_MENU_ITEM_TAG_COPY;
+ ewk_context_menu_item_remove(menu, item);
+ }
+ }
+#if 0
for (int i = 0; i < count; i++) {
+ item = ewk_context_menu_nth_item_get(menu, i);
+ tag = ewk_context_menu_item_tag_get(item);
+
+ if (tag == EWK_CONTEXT_MENU_ITEM_TAG_CUT) {
+ custom_context_menu_array[index++] = EWK_CONTEXT_MENU_ITEM_TAG_CUT;
+ ewk_context_menu_item_remove(menu, item);
+ }
+ }
+#endif
+
+ for (int i = index; i < count; i++) {
item = ewk_context_menu_nth_item_get(menu, 0);
tag = ewk_context_menu_item_tag_get(item);
+
+ custom_context_menu_array[index++] = tag;
ewk_context_menu_item_remove(menu, item);
+ }
+
+ for (int i = 0; i < count; i++) {
+ tag = custom_context_menu_array[i];
+
+ switch (tag) {
+ case EWK_CONTEXT_MENU_ITEM_TAG_CUT:
+ ewk_context_menu_item_append_as_action(menu, tag, BR_STRING_CTXMENU_CUT, true);
+ break;
+ case EWK_CONTEXT_MENU_ITEM_TAG_PASTE:
+ ewk_context_menu_item_append_as_action(menu, tag, BR_STRING_CTXMENU_PASTE, true);
+ break;
+ case EWK_CONTEXT_MENU_ITEM_TAG_COPY:
+ ewk_context_menu_item_append_as_action(menu, tag, BR_STRING_CTXMENU_COPY, true);
+ ewk_context_menu_item_append_as_action(menu, CUSTOM_CONTEXT_MENU_ITEM_FIND_ON_TAG, BR_STRING_CTXMENI_FIND_ON_PAGE, true);
+ ewk_context_menu_item_append_as_action(menu, CUSTOM_CONTEXT_MENU_ITEM_TEXT_SHARE_TAG, BR_STRING_CTXMENU_SHARE, true);
+ break;
+ case EWK_CONTEXT_MENU_ITEM_TAG_SELECT_ALL:
+ ewk_context_menu_item_append_as_action(menu, tag, BR_STRING_SELECT_ALL, true);
+ break;
+ case EWK_CONTEXT_MENU_ITEM_TAG_SELECT_WORD:
+ ewk_context_menu_item_append_as_action(menu, tag, BR_STRING_CTXMENU_SELECT_WORD, true);
+ break;
+ default:
+ break;
+ }
+ }
+
+ if (custom_context_menu_array)
+ free(custom_context_menu_array);
+ custom_context_menu_array = NULL;
+
+ return EINA_TRUE;
+}
+
+Eina_Bool Browser_Context_Menu::_append_text_with_hyperlink_mode_context_menu(Ewk_Context_Menu *menu)
+{
+ BROWSER_LOGD("[%s]", __func__);
+
+ if (!menu)
+ return EINA_FALSE;
+
+ return _append_hyperlink_only_mode_context_menu(menu);
+}
+
+Eina_Bool Browser_Context_Menu::_append_hyperlink_only_mode_context_menu(Ewk_Context_Menu *menu)
+{
+ BROWSER_LOGD("[%s]", __func__);
+
+ if (!menu)
+ return EINA_FALSE;
+
+ Ewk_Context_Menu_Item *item;
+ Ewk_Context_Menu_Item_Tag tag;
+ int index = 0;
+ int count = ewk_context_menu_item_count(menu);
+ int *custom_context_menu_array = (int *)malloc(sizeof(int) * count);
+
+ if (count == 0)
+ return EINA_FALSE;
+
+ if (!custom_context_menu_array)
+ return EINA_FALSE;
+
+ memset(custom_context_menu_array, 0x00, sizeof(int) * count);
+
+ /* To re-arrange menu order to follow UX guideline
+ : "Open in new window" menu would be best if it's at the first in context menu */
+ for (int i = 0; i < count; i++) {
+ item = ewk_context_menu_nth_item_get(menu, i);
+ tag = ewk_context_menu_item_tag_get(item);
+
+ if (tag == EWK_CONTEXT_MENU_ITEM_TAG_OPEN_LINK) {
+ custom_context_menu_array[index++] = EWK_CONTEXT_MENU_ITEM_TAG_OPEN_LINK;
+ ewk_context_menu_item_remove(menu, item);
+ }
+ }
+
+ for (int i = 0; i < count; i++) {
+ item = ewk_context_menu_nth_item_get(menu, i);
+ tag = ewk_context_menu_item_tag_get(item);
+
+ if (tag == EWK_CONTEXT_MENU_ITEM_TAG_OPEN_LINK_IN_NEW_WINDOW) {
+ custom_context_menu_array[index++] = EWK_CONTEXT_MENU_ITEM_TAG_OPEN_LINK_IN_NEW_WINDOW;
+ ewk_context_menu_item_remove(menu, item);
+ }
+ }
+
+ for (int i = 0; i < count; i++) {
+ item = ewk_context_menu_nth_item_get(menu, i);
+ tag = ewk_context_menu_item_tag_get(item);
+
+ if (tag == EWK_CONTEXT_MENU_ITEM_TAG_COPY_LINK_TO_CLIPBOARD) {
+ custom_context_menu_array[index++] = EWK_CONTEXT_MENU_ITEM_TAG_COPY_LINK_TO_CLIPBOARD;
+ ewk_context_menu_item_remove(menu, item);
+ }
+ }
+
+ for (int i = index; i < count; i++) {
+ item = ewk_context_menu_nth_item_get(menu, 0);
+ tag = ewk_context_menu_item_tag_get(item);
+
+ custom_context_menu_array[index++] = tag;
+ ewk_context_menu_item_remove(menu, item);
+ }
+
+ for (int i = 0; i < count; i++) {
+ tag = custom_context_menu_array[i];
+
+ switch (tag) {
+
+ case EWK_CONTEXT_MENU_ITEM_TAG_OPEN_LINK:
+ ewk_context_menu_item_append_as_action(menu, tag, BR_STRING_CTXMENU_OPEN, true);
+ break;
+
+ case EWK_CONTEXT_MENU_ITEM_TAG_OPEN_LINK_IN_NEW_WINDOW:
+ ewk_context_menu_item_append_as_action(menu, tag, BR_STRING_CTXMENU_OPEN_LINK_IN_NEW_WINDOW, true);
+ break;
+ case EWK_CONTEXT_MENU_ITEM_TAG_COPY_LINK_TO_CLIPBOARD:
+ ewk_context_menu_item_append_as_action(menu, tag, BR_STRING_CTXMENU_COPY_LINK_LOCATION, true);
+ ewk_context_menu_item_append_as_action(menu, CUSTOM_CONTEXT_MENU_ITEM_LINK_SHARE_TAG, BR_STRING_CTXMENU_SHARE, true);
+ ewk_context_menu_item_append_as_action(menu, CUSTOM_CONTEXT_MENU_ITEM_SELECTION_MODE_FROM_TEXT_WITH_HYPERLINK_TAG, BR_STRING_CTXMENU_SELECTION_MODE, true);
+ break;
+#if 0
+ case EWK_CONTEXT_MENU_ITEM_TAG_DOWNLOAD_LINK_TO_DISK:
+ ewk_context_menu_item_append_as_action(menu, tag, BR_STRING_CTXMENU_SAVE_LINK, true);
+ break;
+#endif
+ default:
+ break;
+ }
+ }
+
+ if (custom_context_menu_array)
+ free(custom_context_menu_array);
+ custom_context_menu_array = NULL;
+
+ return EINA_TRUE;
+}
+
+Eina_Bool Browser_Context_Menu::_append_image_only_mode_context_menu(Ewk_Context_Menu *menu)
+{
+ BROWSER_LOGD("[%s]", __func__);
+
+ if (!menu)
+ return EINA_FALSE;
+
+ Ewk_Context_Menu_Item *item;
+ Ewk_Context_Menu_Item_Tag tag;
+ int index = 0;
+ int count = ewk_context_menu_item_count(menu);
+ int *custom_context_menu_array = (int *)malloc(sizeof(int) * count);
+
+ if (count == 0)
+ return EINA_FALSE;
+
+ if (!custom_context_menu_array)
+ return EINA_FALSE;
+
+ memset(custom_context_menu_array, 0x00, sizeof(int) * count);
+
+ /* To re-arrange menu order to follow UX guideline
+ : "Copy image" menu would be best if it's at the first in context menu */
+ for (int i = 0; i < count; i++) {
+ item = ewk_context_menu_nth_item_get(menu, i);
+ tag = ewk_context_menu_item_tag_get(item);
+
+ if (tag == EWK_CONTEXT_MENU_ITEM_TAG_COPY_IMAGE_TO_CLIPBOARD) {
+ custom_context_menu_array[index++] = EWK_CONTEXT_MENU_ITEM_TAG_COPY_IMAGE_TO_CLIPBOARD;
+ ewk_context_menu_item_remove(menu, item);
+ }
+ }
+
+ for (int i = index; i < count; i++) {
+ item = ewk_context_menu_nth_item_get(menu, 0);
+ tag = ewk_context_menu_item_tag_get(item);
+
+ custom_context_menu_array[index++] = tag;
+ ewk_context_menu_item_remove(menu, item);
+ }
+
+ for (int i = 0; i < count; i++) {
+ tag = custom_context_menu_array[i];
+
+ switch (tag) {
+ case EWK_CONTEXT_MENU_ITEM_TAG_COPY_IMAGE_TO_CLIPBOARD:
+ ewk_context_menu_item_append_as_action(menu, tag, BR_STRING_CTXMENU_COPY_IMAGE, true);
+ break;
+ case EWK_CONTEXT_MENU_ITEM_TAG_OPEN_IMAGE_IN_NEW_WINDOW:
+ ewk_context_menu_item_append_as_action(menu, tag, BR_STRING_CTXMENU_OPEN_IMAGE_IN_NEW_WINDOW, true);
+ break;
+ case EWK_CONTEXT_MENU_ITEM_TAG_DOWNLOAD_IMAGE_TO_DISK:
+ ewk_context_menu_item_append_as_action(menu, tag, BR_STRING_CTXMENU_SAVE_IMAGE, true);
+ ewk_context_menu_item_append_as_action(menu, CUSTOM_CONTEXT_MENU_ITEM_IMAGE_SHARE_TAG, BR_STRING_CTXMENU_SHARE_IMAGE, true);
+ ewk_context_menu_item_append_as_action(menu, CUSTOM_CONTEXT_MENU_ITEM_SELECTION_MODE_FROM_IMAGE_TAG, BR_STRING_CTXMENU_SELECTION_MODE, true);
+ break;
+ default:
+ break;
+ }
+ }
+
+ if (custom_context_menu_array)
+ free(custom_context_menu_array);
+ custom_context_menu_array = NULL;
+
+ return EINA_TRUE;
+}
+
+Eina_Bool Browser_Context_Menu::_append_image_with_hyperlink_mode_context_menu(Ewk_Context_Menu *menu)
+{
+ BROWSER_LOGD("[%s]", __func__);
+
+ if (!menu)
+ return EINA_FALSE;
+
+ Ewk_Context_Menu_Item *item;
+ Ewk_Context_Menu_Item_Tag tag;
+ int index = 0;
+ int count = ewk_context_menu_item_count(menu);
+ int *custom_context_menu_array = (int *)malloc(sizeof(int) * count);
+
+ if (count == 0)
+ return EINA_FALSE;
+
+ if (!custom_context_menu_array)
+ return EINA_FALSE;
+
+ memset(custom_context_menu_array, 0x00, sizeof(int) * count);
+
+ /* To re-arrange menu order to follow UX guideline
+ : "Open in new window" menu would be best if it's at the first in context menu */
+ for (int i = 0; i < count; i++) {
+ item = ewk_context_menu_nth_item_get(menu, i);
+ tag = ewk_context_menu_item_tag_get(item);
+
+ if (tag == EWK_CONTEXT_MENU_ITEM_TAG_OPEN_LINK_IN_NEW_WINDOW) {
+ custom_context_menu_array[index++] = EWK_CONTEXT_MENU_ITEM_TAG_OPEN_LINK_IN_NEW_WINDOW;
+ ewk_context_menu_item_remove(menu, item);
+ }
+ }
+
+ for (int i = 0; i < count; i++) {
+ item = ewk_context_menu_nth_item_get(menu, i);
+ tag = ewk_context_menu_item_tag_get(item);
+
+ if (tag == EWK_CONTEXT_MENU_ITEM_TAG_COPY_LINK_TO_CLIPBOARD) {
+ custom_context_menu_array[index++] = EWK_CONTEXT_MENU_ITEM_TAG_COPY_LINK_TO_CLIPBOARD;
+ ewk_context_menu_item_remove(menu, item);
+ }
+ }
+
+ for (int i = 0; i < count; i++) {
+ item = ewk_context_menu_nth_item_get(menu, i);
+ tag = ewk_context_menu_item_tag_get(item);
+
+ if (tag == EWK_CONTEXT_MENU_ITEM_TAG_COPY_IMAGE_TO_CLIPBOARD) {
+ custom_context_menu_array[index++] = EWK_CONTEXT_MENU_ITEM_TAG_COPY_IMAGE_TO_CLIPBOARD;
+ ewk_context_menu_item_remove(menu, item);
+ }
+ }
+
+ for (int i = index; i < count; i++) {
+ item = ewk_context_menu_nth_item_get(menu, 0);
+ tag = ewk_context_menu_item_tag_get(item);
+
+ custom_context_menu_array[index++] = tag;
+ ewk_context_menu_item_remove(menu, item);
+ }
+
+ for (int i = 0; i < count; i++) {
+ tag = custom_context_menu_array[i];
switch (tag) {
case EWK_CONTEXT_MENU_ITEM_TAG_OPEN_LINK_IN_NEW_WINDOW:
ewk_context_menu_item_append_as_action(menu, tag, BR_STRING_CTXMENU_OPEN_LINK_IN_NEW_WINDOW, true);
break;
+ case EWK_CONTEXT_MENU_ITEM_TAG_COPY_LINK_TO_CLIPBOARD:
+ ewk_context_menu_item_append_as_action(menu, tag, BR_STRING_CTXMENU_COPY_LINK_LOCATION, true);
+ ewk_context_menu_item_append_as_action(menu, CUSTOM_CONTEXT_MENU_ITEM_TEXT_SHARE_TAG, BR_STRING_CTXMENU_SHARE, true);
+ break;
+ case EWK_CONTEXT_MENU_ITEM_TAG_COPY_IMAGE_TO_CLIPBOARD:
+ ewk_context_menu_item_append_as_action(menu, tag, BR_STRING_CTXMENU_COPY_IMAGE, true);
+ break;
+ case EWK_CONTEXT_MENU_ITEM_TAG_OPEN_IMAGE_IN_NEW_WINDOW:
+ ewk_context_menu_item_append_as_action(menu, tag, BR_STRING_CTXMENU_OPEN_IMAGE_IN_NEW_WINDOW, true);
+ break;
+ case EWK_CONTEXT_MENU_ITEM_TAG_DOWNLOAD_IMAGE_TO_DISK:
+ ewk_context_menu_item_append_as_action(menu, tag, BR_STRING_CTXMENU_SAVE_IMAGE, true);
+ ewk_context_menu_item_append_as_action(menu, CUSTOM_CONTEXT_MENU_ITEM_LINK_SHARE_TAG, BR_STRING_CTXMENU_SHARE_IMAGE, true);
+ ewk_context_menu_item_append_as_action(menu, CUSTOM_CONTEXT_MENU_ITEM_SELECTION_MODE_FROM_IMAGE_TAG, BR_STRING_CTXMENU_SELECTION_MODE, true);
+ break;
+ default:
+ break;
+ }
+ }
+
+ if (custom_context_menu_array)
+ free(custom_context_menu_array);
+ custom_context_menu_array = NULL;
+
+ return EINA_TRUE;
+}
+
+Eina_Bool Browser_Context_Menu::_append_text_and_image_selection_mode_context_menu(Ewk_Context_Menu *menu)
+{
+ BROWSER_LOGD("[%s]", __func__);
+
+ if (!menu)
+ return EINA_FALSE;
+
+ return EINA_FALSE;
+}
+
+Eina_Bool Browser_Context_Menu::_append_normal_mode_context_menu(Ewk_Context_Menu *menu)
+{
+ BROWSER_LOGD("[%s]", __func__);
+
+ if (!menu)
+ return EINA_FALSE;
+
+ Ewk_Context_Menu_Item *item;
+ Ewk_Context_Menu_Item_Tag tag;
+ bool show_hyperlink_item_flag = false;
+ bool show_imagemode_flag = false;
+ int count = ewk_context_menu_item_count(menu);
+
+ for (int i = 0; i < count; i++) {
+ item = ewk_context_menu_nth_item_get(menu, 0);
+ tag = ewk_context_menu_item_tag_get(item);
+ ewk_context_menu_item_remove(menu, item);
+
+ switch (tag) {
+ case EWK_CONTEXT_MENU_ITEM_TAG_OPEN_LINK:
+ ewk_context_menu_item_append_as_action(menu, tag, BR_STRING_CTXMENU_OPEN, true);
+ break;
+ case EWK_CONTEXT_MENU_ITEM_TAG_OPEN_LINK_IN_NEW_WINDOW:
+ ewk_context_menu_item_append_as_action(menu, tag, BR_STRING_CTXMENU_OPEN_LINK_IN_NEW_WINDOW, true);
+ ewk_context_menu_item_append_as_action(menu, CUSTOM_CONTEXT_MENU_ITEM_LINK_SHARE_TAG, BR_STRING_CTXMENU_SHARE_LINK, true);
+ show_hyperlink_item_flag = true;
+ break;
case EWK_CONTEXT_MENU_ITEM_TAG_DOWNLOAD_LINK_TO_DISK:
- ewk_context_menu_item_append_as_action(menu, tag, BR_STRING_CTXMENU_DOWNLOAD_LINKED_FILE, true);
+ ewk_context_menu_item_append_as_action(menu, tag, BR_STRING_CTXMENU_SAVE_LINK, true);
break;
case EWK_CONTEXT_MENU_ITEM_TAG_OPEN_IMAGE_IN_NEW_WINDOW:
ewk_context_menu_item_append_as_action(menu, tag, BR_STRING_CTXMENU_OPEN_IMAGE_IN_NEW_WINDOW, true);
break;
case EWK_CONTEXT_MENU_ITEM_TAG_DOWNLOAD_IMAGE_TO_DISK:
- ewk_context_menu_item_append_as_action(menu, tag, BR_STRING_CTXMENU_SAVE_IMAGE_AS, true);
+ ewk_context_menu_item_append_as_action(menu, tag, BR_STRING_CTXMENU_SAVE_IMAGE, true);
+ ewk_context_menu_item_append_as_action(menu, CUSTOM_CONTEXT_MENU_ITEM_IMAGE_SHARE_TAG, BR_STRING_CTXMENU_SHARE_IMAGE_URL, true);
+ show_imagemode_flag = true;
break;
case EWK_CONTEXT_MENU_ITEM_TAG_COPY_IMAGE_TO_CLIPBOARD:
ewk_context_menu_item_append_as_action(menu, tag, BR_STRING_CTXMENU_COPY_IMAGE, true);
@@ -96,7 +659,6 @@ void Browser_Context_Menu::__get_context_menu_from_proposed_context_menu_cb(void
break;
case EWK_CONTEXT_MENU_ITEM_TAG_COPY:
ewk_context_menu_item_append_as_action(menu, tag, BR_STRING_CTXMENU_COPY, true);
- ewk_context_menu_item_append_as_action(menu, CustomContextMenuItemSelectedTextShareTag, BR_STRING_CTXMENU_SHARE, true);
break;
case EWK_CONTEXT_MENU_ITEM_TAG_SELECT_ALL:
ewk_context_menu_item_append_as_action(menu, tag, BR_STRING_SELECT_ALL, true);
@@ -106,35 +668,14 @@ void Browser_Context_Menu::__get_context_menu_from_proposed_context_menu_cb(void
break;
default:
break;
- }
}
}
-void Browser_Context_Menu::__custom_context_menu_item_selected_cb(void *data, Evas_Object *obj, void *event_info)
-{
- BROWSER_LOGD("[%s]", __func__);
- if (!event_info)
- return;
-
- Ewk_Context_Menu_Item* item = static_cast<Ewk_Context_Menu_Item*>(event_info);
- Browser_Context_Menu *context_menu = static_cast<Browser_Context_Menu *>(data);
+ /* if the tag is hyperlink text, show text selection mode menu */
+ if ((show_hyperlink_item_flag == true) && (show_imagemode_flag == false))
+ ewk_context_menu_item_append_as_action(menu, CUSTOM_CONTEXT_MENU_ITEM_SELECTION_MODE_FROM_TEXT_TAG, BR_STRING_CTXMENU_SELECTION_MODE, true);
- std::string link_url_string = ewk_context_menu_item_link_url_get(item);
- BROWSER_LOGD("link url=[%s]", link_url_string.c_str());
- std::string image_url_string = ewk_context_menu_item_image_url_get(item);
- BROWSER_LOGD("image url=[%s]", image_url_string.c_str());
- const char *selected_text = ewk_view_text_selection_text_get(context_menu->m_ewk_view);
-
- Ewk_Context_Menu_Item_Tag tag = ewk_context_menu_item_tag_get(item);
- switch (tag) {
- case CustomContextMenuItemSelectedTextShareTag:
- BROWSER_LOGD("Share selected text[%s]", selected_text);
- if (selected_text && strlen(selected_text) > 0)
- context_menu->_show_share_popup(selected_text);
- break;
-
- default:
- break;
- }
+ return EINA_TRUE;
}
+
diff --git a/src/browser-view/browser-context-menu.h b/src/browser-view/browser-context-menu.h
index 821438e..fb5252b 100755
--- a/src/browser-view/browser-context-menu.h
+++ b/src/browser-view/browser-context-menu.h
@@ -30,22 +30,62 @@ public:
Browser_Context_Menu(Browser_View *browser_view);
~Browser_Context_Menu(void);
- Eina_Bool init(void) {}
+ Eina_Bool init(void) { return EINA_TRUE; }
void init(Evas_Object *ewk_view);
void deinit(void);
+ Eina_Bool launch_context_menu(Ewk_Context_Menu *menu);
+ int get_pressed_position_x(void) { return m_pressed_x; }
+ int get_pressed_position_y(void) { return m_pressed_y; }
+ void set_pressed_position_x(int pressed_x) { m_pressed_x = pressed_x; }
+ void set_pressed_position_y(int pressed_y) { m_pressed_y = pressed_y; }
+
+ typedef enum _custom_context_menu_mode {
+ CUSTOM_CONTEXT_MENU_MODE_INDEX_START = 0,
+ CUSTOM_CONTEXT_MENU_TEXT_ONLY_MODE,
+ CUSTOM_CONTEXT_MENU_TEXT_WITH_HYPERLINK_MODE,
+ CUSTOM_CONTEXT_MENU_IMAGE_ONLY_MODE,
+ CUSTOM_CONTEXT_MENU_IMAGE_WITH_HYPERLINK_MODE,
+ CUSTOM_CONTEXT_MENU_HYPERLINK_ONLY_MODE,
+ CUSTOM_CONTEXT_MENU_TEXT_AND_IMAGE_SELECTION_MODE,
+
+ CUSTOM_CONTEXT_MENU_MODE_INDEX_END
+
+ } custom_context_menu_mode;
+
+ typedef enum _custom_context_menu_item_tag {
+ CUSTOM_CONTEXT_MENU_ITEM_BASE_TAG = EWK_CONTEXT_MENU_ITEM_BASE_APPLICATION_TAG,
+ CUSTOM_CONTEXT_MENU_ITEM_LINK_SHARE_TAG,
+ CUSTOM_CONTEXT_MENU_ITEM_IMAGE_SHARE_TAG,
+ CUSTOM_CONTEXT_MENU_ITEM_TEXT_SHARE_TAG,
+ CUSTOM_CONTEXT_MENU_ITEM_FIND_ON_TAG,
+ CUSTOM_CONTEXT_MENU_ITEM_SELECTION_MODE_FROM_TEXT_TAG,
+ CUSTOM_CONTEXT_MENU_ITEM_SELECTION_MODE_FROM_IMAGE_TAG,
+ CUSTOM_CONTEXT_MENU_ITEM_SELECTION_MODE_FROM_TEXT_WITH_HYPERLINK_TAG,
+ CUSTOM_CONTEXT_MENU_ITEM_SELECTION_MODE_FROM_IMAGE_WITH_HYPERLINK_TAG,
+#if defined(FEATURE_SEARCH_SELECTED_WORD_IN_WEB) && defined(FEATURE_TEXT_READER) && !defined(TIZEN_PUBLIC)
+ CUSTOM_CONTEXT_MENU_ITEM_SEARCH_THE_WEB_IN_READER_VIEW_TAG,
+#endif
+ CUSTOM_CONTEXT_MENU_ITEM_TAG_INDEX_END
+
+ } custom_context_menu_item_tag;
- enum {
- CustomContextMenuItemBaseApplicationTag = EWK_CONTEXT_MENU_ITEM_BASE_APPLICATION_TAG,
- CustomContextMenuItemImageSendViaMessageTag,
- CustomContextMenuItemImageSendViaEmailTag,
- CustomContextMenuItemSelectedTextShareTag
- };
private:
static void __get_context_menu_from_proposed_context_menu_cb(void *data, Evas_Object *obj, void *event_info);
static void __custom_context_menu_item_selected_cb(void *data, Evas_Object *obj, void *event_info);
+ Eina_Bool _check_context_menu_mode(Ewk_Context_Menu *menu);
+ Eina_Bool _append_text_only_mode_context_menu(Ewk_Context_Menu *menu);
+ Eina_Bool _append_text_with_hyperlink_mode_context_menu(Ewk_Context_Menu *menu);
+ Eina_Bool _append_hyperlink_only_mode_context_menu(Ewk_Context_Menu *menu);
+ Eina_Bool _append_image_only_mode_context_menu(Ewk_Context_Menu *menu);
+ Eina_Bool _append_image_with_hyperlink_mode_context_menu(Ewk_Context_Menu *menu);
+ Eina_Bool _append_text_and_image_selection_mode_context_menu(Ewk_Context_Menu *menu);
+ Eina_Bool _append_normal_mode_context_menu(Ewk_Context_Menu *menu);
+
Browser_View *m_browser_view;
Evas_Object *m_ewk_view;
+ int m_pressed_x;
+ int m_pressed_y;
};
#endif /* BROWSER_CONTEXT_MENU_H */
diff --git a/src/browser-view/browser-view.cpp b/src/browser-view/browser-view.cpp
index 9489ba0..949f4d1 100755
--- a/src/browser-view/browser-view.cpp
+++ b/src/browser-view/browser-view.cpp
@@ -1273,6 +1273,9 @@ void Browser_View::__ewk_view_mouse_down_cb(void* data, Evas* evas, Evas_Object*
Evas_Object *main_layout = browser_view->m_main_layout;
Evas_Object *ewk_view = browser_view->m_focused_window->m_ewk_view;
+ browser_view->m_context_menu->set_pressed_position_x(event.output.x);
+ browser_view->m_context_menu->set_pressed_position_y(event.output.y);
+
#if defined(FEATURE_MOST_VISITED_SITES)
if (browser_view->is_most_visited_sites_running())
return;
@@ -1980,8 +1983,6 @@ Eina_Bool Browser_View::_show_scissorbox_view(void)
{
BROWSER_LOGD("[%s]", __func__);
-// _hide_scroller_url_layout();
-
ecore_idler_add(__show_scissorbox_view_idler_cb, this);
return EINA_TRUE;
@@ -3739,6 +3740,28 @@ Eina_Bool Browser_View::_is_loading(void)
return EINA_TRUE;
}
+Eina_Bool Browser_View::launch_find_word_with_text(const char *text_to_find)
+{
+ BROWSER_LOGD("\n");
+
+ if (_get_edit_mode() == BR_FIND_WORD_MODE)
+ return EINA_FALSE;
+
+ _navigationbar_visible_set_signal(EINA_TRUE);
+ _set_edit_mode(BR_FIND_WORD_MODE);
+
+ if (!text_to_find || !strlen(text_to_find))
+ elm_object_focus_set(m_find_word_edit_field, EINA_TRUE);
+ else
+ elm_object_focus_set(m_find_word_edit_field, EINA_FALSE);
+ edje_object_part_text_set(elm_layout_edje_get(m_option_header_find_word_layout), "elm.index_text", "0/0");
+
+ Evas_Object *find_word_edit_field_entry = br_elm_editfield_entry_get(m_find_word_edit_field);
+ elm_entry_entry_set(find_word_edit_field_entry, text_to_find);
+
+ return EINA_TRUE;
+}
+
#if defined(HORIZONTAL_UI)
Eina_Bool Browser_View::is_available_to_rotate(void)
{
diff --git a/src/browser-view/browser-view.h b/src/browser-view/browser-view.h
index bfdba80..c53761f 100755
--- a/src/browser-view/browser-view.h
+++ b/src/browser-view/browser-view.h
@@ -89,6 +89,7 @@ public:
Evas_Object *get_favicon(const char *url);
void delete_non_user_created_windows(void);
Eina_Bool _is_loading(void);
+ Eina_Bool launch_find_word_with_text(const char *text_to_find);
private:
typedef enum _homepage_mode {
#if defined(FEATURE_MOST_VISITED_SITES)
diff --git a/src/include/browser-string.h b/src/include/browser-string.h
index 482c068..d42a9b3 100755
--- a/src/include/browser-string.h
+++ b/src/include/browser-string.h
@@ -231,6 +231,7 @@
#define BR_STRING_CTXMENU_SAVE_IMAGE_AS _("Save image as")
#define BR_STRING_CTXMENU_COPY_IMAGE _("IDS_BR_OPT_COPY_IMAGE")
#define BR_STRING_CTXMENU_SAVE_IMAGE _("IDS_BR_OPT_SAVE_IMAGE")
+#define BR_STRING_CTXMENU_SHARE_IMAGE _("Share image")
#define BR_STRING_CTXMENU_COPY_MEDIA dgettext("sys_string", "IDS_COM_BODY_COPY")
#define BR_STRING_CTXMENU_SEND_IMAGE_VIA_EMAIL _("IDS_BR_OPT_SEND_VIA_EMAIL")
#define BR_STRING_CTXMENU_SEND_IMAGE_VIA_MESSAGE _("IDS_BR_OPT_SEND_VIA_MESSAGE")
@@ -250,6 +251,7 @@
#define BR_STRING_CTXMENU_SEARCH dgettext("sys_string", "IDS_COM_BODY_SEARCH")
#define BR_STRING_CTXMENU_SHARE dgettext("sys_string", "IDS_COM_BUTTON_SHARE")
#define BR_STRING_CTXMENU_DELETE dgettext("sys_string", "IDS_COM_BODY_DELETE")
+#define BR_STRING_CTXMENI_FIND_ON_PAGE _("IDS_BR_OPT_FIND_ON_PAGE")
#define BR_STRING_CTXMENU_PASTE_AND_GO _("Paste & Go")
#define BR_STRING_CTXMENU_SHARE_IMAGE_URL _("Share image URL")
#define BR_STRING_CTXMENU_SHARE_LINK _("IDS_BR_BODY_SHARE_LINK")
@@ -294,6 +296,6 @@
#define BR_STRING_CTXMENU_SPEECH _("Speech")
#define BR_STRING_CTXMENU_START_SPEAKING _("Start speaking")
#define BR_STRING_CTXMENU_STOP_SPEAKING _("Stop speaking")
-#define BR_STRING_CTXMENU_TEXT_SELECTION_MODE _("Text selection mode")
+#define BR_STRING_CTXMENU_SELECTION_MODE _("Selection mode")
#endif /* BROWSER_STRING_H */