Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/tab/TabContextMenuItemDelegate.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/tab/TabContextMenuItemDelegate.java b/chrome/android/java/src/org/chromium/chrome/browser/tab/TabContextMenuItemDelegate.java |
| index bdd0ce8285a13bf88e683235e0128b310434e607..532319ad3aaefac72c8062f5c043f66310e3ea06 100644 |
| --- a/chrome/android/java/src/org/chromium/chrome/browser/tab/TabContextMenuItemDelegate.java |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/tab/TabContextMenuItemDelegate.java |
| @@ -6,7 +6,9 @@ package org.chromium.chrome.browser.tab; |
| import android.content.Context; |
| import android.content.Intent; |
| +import android.net.MailTo; |
| import android.net.Uri; |
| +import android.provider.ContactsContract; |
| import org.chromium.base.metrics.RecordUserAction; |
| import org.chromium.chrome.browser.IntentHandler; |
| @@ -17,6 +19,7 @@ import org.chromium.chrome.browser.offlinepages.OfflinePageBridge; |
| import org.chromium.chrome.browser.preferences.PrefServiceBridge; |
| import org.chromium.chrome.browser.tabmodel.TabModel.TabLaunchType; |
| import org.chromium.chrome.browser.tabmodel.document.TabDelegate; |
| +import org.chromium.chrome.browser.util.IntentUtils; |
| import org.chromium.chrome.browser.util.UrlUtilities; |
| import org.chromium.content_public.browser.LoadUrlParams; |
| import org.chromium.content_public.common.Referrer; |
| @@ -26,6 +29,7 @@ import org.chromium.ui.base.PageTransition; |
| import java.net.URI; |
| import java.util.Locale; |
| + |
| /** |
| * A default {@link ContextMenuItemDelegate} that supports the context menu functionality in Tab. |
| */ |
| @@ -75,6 +79,38 @@ public class TabContextMenuItemDelegate implements ContextMenuItemDelegate { |
| } |
| @Override |
| + public boolean supportsSendEmailMessage() { |
| + Intent intent = new Intent(Intent.ACTION_VIEW); |
| + intent.setData(Uri.parse("mailto:test@google.com")); |
|
Ted C
2017/01/04 18:40:08
Tiny nit. Let's use @example.com to not make this
ltian
2017/01/04 20:46:58
Done.
|
| + return mTab.getWindowAndroid().canResolveActivity(intent); |
| + } |
| + |
| + @Override |
| + public void onSendMessage(String url) { |
| + Intent intent = new Intent(Intent.ACTION_VIEW); |
| + intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| + intent.setData(Uri.parse(url)); |
| + IntentUtils.safeStartActivity(mTab.getActivity(), intent); |
| + } |
| + |
| + @Override |
| + public boolean supportsAddToContacts() { |
| + Intent intent = new Intent(Intent.ACTION_INSERT); |
| + intent.setType(ContactsContract.Contacts.CONTENT_TYPE); |
| + return mTab.getWindowAndroid().canResolveActivity(intent); |
| + } |
| + |
| + @Override |
| + public void onAddToContacts(String url) { |
| + Intent intent = new Intent(Intent.ACTION_INSERT); |
| + intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| + intent.setType(ContactsContract.Contacts.CONTENT_TYPE); |
| + intent.putExtra( |
| + ContactsContract.Intents.Insert.EMAIL, MailTo.parse(url).getTo().split(",")[0]); |
| + IntentUtils.safeStartActivity(mTab.getActivity(), intent); |
| + } |
| + |
| + @Override |
| public void onOpenInOtherWindow(String url, Referrer referrer) { |
| TabDelegate tabDelegate = new TabDelegate(mTab.isIncognito()); |
| LoadUrlParams loadUrlParams = new LoadUrlParams(url); |
| @@ -184,4 +220,5 @@ public class TabContextMenuItemDelegate implements ContextMenuItemDelegate { |
| } |
| return false; |
| } |
| + |
| } |