summaryrefslogtreecommitdiff
path: root/Source/WebKit2/WebProcess/WebPage/WebContextMenu.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebKit2/WebProcess/WebPage/WebContextMenu.cpp')
-rw-r--r--Source/WebKit2/WebProcess/WebPage/WebContextMenu.cpp42
1 files changed, 32 insertions, 10 deletions
diff --git a/Source/WebKit2/WebProcess/WebPage/WebContextMenu.cpp b/Source/WebKit2/WebProcess/WebPage/WebContextMenu.cpp
index 3273bdc09..d21af0301 100644
--- a/Source/WebKit2/WebProcess/WebPage/WebContextMenu.cpp
+++ b/Source/WebKit2/WebProcess/WebPage/WebContextMenu.cpp
@@ -66,6 +66,32 @@ void WebContextMenu::show()
if (!view)
return;
+ Vector<WebContextMenuItemData> menuItems;
+ RefPtr<APIObject> userData;
+ menuItemsWithUserData(menuItems, userData);
+ WebHitTestResult::Data webHitTestResultData(controller->hitTestResult());
+
+ // Mark the WebPage has having a shown context menu then notify the UIProcess.
+ m_page->contextMenuShowing();
+ m_page->send(Messages::WebPageProxy::ShowContextMenu(view->contentsToWindow(controller->hitTestResult().roundedPointInInnerNodeFrame()), webHitTestResultData, menuItems, InjectedBundleUserMessageEncoder(userData.get())));
+}
+
+void WebContextMenu::itemSelected(const WebContextMenuItemData& item)
+{
+ ContextMenuItem coreItem(ActionType, static_cast<ContextMenuAction>(item.action()), item.title());
+ m_page->corePage()->contextMenuController()->contextMenuItemSelected(&coreItem);
+}
+
+void WebContextMenu::menuItemsWithUserData(Vector<WebContextMenuItemData> &menuItems, RefPtr<APIObject>& userData) const
+{
+ ContextMenuController* controller = m_page->corePage()->contextMenuController();
+ if (!controller)
+ return;
+
+ ContextMenu* menu = controller->contextMenu();
+ if (!menu)
+ return;
+
// Give the bundle client a chance to process the menu.
#if USE(CROSS_PLATFORM_CONTEXT_MENUS)
const Vector<ContextMenuItem>& coreItems = menu->items();
@@ -74,22 +100,18 @@ void WebContextMenu::show()
#endif
Vector<WebContextMenuItemData> proposedMenu = kitItems(coreItems, menu);
Vector<WebContextMenuItemData> newMenu;
- RefPtr<APIObject> userData;
RefPtr<InjectedBundleHitTestResult> hitTestResult = InjectedBundleHitTestResult::create(controller->hitTestResult());
if (m_page->injectedBundleContextMenuClient().getCustomMenuFromDefaultItems(m_page, hitTestResult.get(), proposedMenu, newMenu, userData))
proposedMenu = newMenu;
-
- WebHitTestResult::Data webHitTestResultData(controller->hitTestResult());
-
- // Mark the WebPage has having a shown context menu then notify the UIProcess.
- m_page->contextMenuShowing();
- m_page->send(Messages::WebPageProxy::ShowContextMenu(view->contentsToWindow(controller->hitTestResult().roundedPointInInnerNodeFrame()), webHitTestResultData, proposedMenu, InjectedBundleUserMessageEncoder(userData.get())));
+ menuItems = proposedMenu;
}
-void WebContextMenu::itemSelected(const WebContextMenuItemData& item)
+Vector<WebContextMenuItemData> WebContextMenu::items() const
{
- ContextMenuItem coreItem(ActionType, static_cast<ContextMenuAction>(item.action()), item.title());
- m_page->corePage()->contextMenuController()->contextMenuItemSelected(&coreItem);
+ Vector<WebContextMenuItemData> menuItems;
+ RefPtr<APIObject> userData;
+ menuItemsWithUserData(menuItems, userData);
+ return menuItems;
}
} // namespace WebKit