| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.chrome.browser.contextmenu; | 5 package org.chromium.chrome.browser.contextmenu; |
| 6 | 6 |
| 7 import android.content.Context; | 7 import android.content.Context; |
| 8 import android.net.MailTo; | 8 import android.net.MailTo; |
| 9 import android.text.TextUtils; | 9 import android.text.TextUtils; |
| 10 import android.view.ContextMenu; | 10 import android.view.ContextMenu; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 public boolean shouldShowContextMenu(ContextMenuParams params) { | 37 public boolean shouldShowContextMenu(ContextMenuParams params) { |
| 38 return params != null && (params.isAnchor() || params.isEditable() || pa
rams.isImage() | 38 return params != null && (params.isAnchor() || params.isEditable() || pa
rams.isImage() |
| 39 || params.isSelectedText() || params.isVideo()); | 39 || params.isSelectedText() || params.isVideo()); |
| 40 } | 40 } |
| 41 | 41 |
| 42 @Override | 42 @Override |
| 43 public void buildContextMenu(ContextMenu menu, Context context, ContextMenuP
arams params) { | 43 public void buildContextMenu(ContextMenu menu, Context context, ContextMenuP
arams params) { |
| 44 if (!TextUtils.isEmpty(params.getLinkUrl()) && !params.getLinkUrl().equa
ls(BLANK_URL)) { | 44 if (!TextUtils.isEmpty(params.getLinkUrl()) && !params.getLinkUrl().equa
ls(BLANK_URL)) { |
| 45 menu.setHeaderTitle(params.getLinkUrl()); | 45 menu.setHeaderTitle(params.getLinkUrl()); |
| 46 } else if (!TextUtils.isEmpty(params.getTitleText())) { | 46 } else if (!TextUtils.isEmpty(params.getTitleText())) { |
| 47 menu.setHeaderTitle(params.getTitleText()); | 47 ContextMenuTitleView title = new ContextMenuTitleView(context, param
s.getTitleText()); |
| 48 menu.setHeaderView(title); |
| 48 } | 49 } |
| 49 | 50 |
| 50 if (mMenuInflater == null) mMenuInflater = new MenuInflater(context); | 51 if (mMenuInflater == null) mMenuInflater = new MenuInflater(context); |
| 51 | 52 |
| 52 mMenuInflater.inflate(R.menu.chrome_context_menu, menu); | 53 mMenuInflater.inflate(R.menu.chrome_context_menu, menu); |
| 53 | 54 |
| 54 menu.setGroupVisible(R.id.contextmenu_group_anchor, params.isAnchor()); | 55 menu.setGroupVisible(R.id.contextmenu_group_anchor, params.isAnchor()); |
| 55 menu.setGroupVisible(R.id.contextmenu_group_image, params.isImage()); | 56 menu.setGroupVisible(R.id.contextmenu_group_image, params.isImage()); |
| 56 menu.setGroupVisible(R.id.contextmenu_group_video, params.isVideo()); | 57 menu.setGroupVisible(R.id.contextmenu_group_video, params.isVideo()); |
| 57 | 58 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 mDelegate.onSaveImageToClipboard(params.getSrcUrl()); | 156 mDelegate.onSaveImageToClipboard(params.getSrcUrl()); |
| 156 } else if (itemId == R.id.contextmenu_copy_image_url) { | 157 } else if (itemId == R.id.contextmenu_copy_image_url) { |
| 157 mDelegate.onSaveToClipboard(params.getSrcUrl(), true); | 158 mDelegate.onSaveToClipboard(params.getSrcUrl(), true); |
| 158 } else { | 159 } else { |
| 159 assert false; | 160 assert false; |
| 160 } | 161 } |
| 161 | 162 |
| 162 return true; | 163 return true; |
| 163 } | 164 } |
| 164 } | 165 } |
| OLD | NEW |