Don't offer "contact" actions in telephone number menus
authorbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 9 Apr 2014 21:31:36 +0000 (21:31 +0000)
committerbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 9 Apr 2014 21:31:36 +0000 (21:31 +0000)
<rdar://problem/16556907> and https://bugs.webkit.org/show_bug.cgi?id=131451

Reviewed by Tim Horton.

* UIProcess/mac/WebPageProxyMac.mm:
(WebKit::WebPageProxy::showTelephoneNumberMenu): Skip actions that have to do with contacts,
  and skip separators too!

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@167034 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm

index 8f7095c..ed34b47 100644 (file)
@@ -1,3 +1,14 @@
+2014-04-09  Brady Eidson  <beidson@apple.com>
+
+        Don't offer "contact" actions in telephone number menus
+        <rdar://problem/16556907> and https://bugs.webkit.org/show_bug.cgi?id=131451
+
+        Reviewed by Tim Horton.
+
+        * UIProcess/mac/WebPageProxyMac.mm:
+        (WebKit::WebPageProxy::showTelephoneNumberMenu): Skip actions that have to do with contacts,
+          and skip separators too!
+
 2014-04-09  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         Unreviewed. Fix GTK+ build after r166975.
index 65868b0..c7bb528 100644 (file)
@@ -63,6 +63,8 @@
 
 SOFT_LINK_PRIVATE_FRAMEWORK_OPTIONAL(DataDetectors)
 SOFT_LINK_CLASS(DataDetectors, DDActionsManager)
+SOFT_LINK_CLASS(DataDetectors, DDAction)
+SOFT_LINK_CLASS(DataDetectors, DDSeparatorAction)
 SOFT_LINK_CONSTANT(DataDetectors, DDBinderPhoneNumberKey, CFStringRef)
 
 typedef void* DDActionContext;
@@ -72,6 +74,10 @@ typedef void* DDActionContext;
 - (NSArray *) menuItemsForValue:(NSString *)value type:(CFStringRef)type service:(NSString *)service context:(DDActionContext *)context;
 @end
 
+@interface DDAction : NSObject
+@property (readonly) NSString *actionUTI;
+@end
+
 #define MESSAGE_CHECK(assertion) MESSAGE_CHECK_BASE(assertion, process().connection())
 
 using namespace WebCore;
@@ -653,6 +659,22 @@ void WebPageProxy::showTelephoneNumberMenu(const String& telephoneNumber, const
 
     Vector<WebContextMenuItemData> items;
     for (NSMenuItem *item in menuItems) {
+        NSDictionary *representedObject = [item representedObject];
+        if (![representedObject isKindOfClass:[NSDictionary class]])
+            continue;
+
+        DDAction *actionObject = [representedObject objectForKey:@"DDAction"];
+        if (![actionObject isKindOfClass:getDDActionClass()])
+            continue;
+
+        // Skip menu items whose actions have anything to do with contacts.
+        if ([[actionObject actionUTI] hasPrefix:@"com.apple.contact."])
+            continue;
+
+        // Skip seperator items.
+        if ([actionObject isKindOfClass:getDDSeparatorActionClass()])
+            continue;
+
         RetainPtr<NSMenuItem> retainedItem = item;
         std::function<void()> handler = [retainedItem]() {
             NSMenuItem *item = retainedItem.get();