Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(69)

Unified Diff: content/public/android/java/src/org/chromium/content/browser/SelectActionModeCallback.java

Issue 258273002: Cut and Copy option should not be avilable for password field. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased because of conflict in AUTHORS file Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/public/android/java/src/org/chromium/content/browser/SelectActionModeCallback.java
diff --git a/content/public/android/java/src/org/chromium/content/browser/SelectActionModeCallback.java b/content/public/android/java/src/org/chromium/content/browser/SelectActionModeCallback.java
index c140cb60094bfc16871aa2bc992c4da05bedfe02..caf3e46316d772697ebc0592f4f31332f2d616a0 100644
--- a/content/public/android/java/src/org/chromium/content/browser/SelectActionModeCallback.java
+++ b/content/public/android/java/src/org/chromium/content/browser/SelectActionModeCallback.java
@@ -71,12 +71,18 @@ public class SelectActionModeCallback implements ActionMode.Callback {
* @return Whether or not web search is available.
*/
boolean isWebSearchAvailable();
+
+ /**
+ * @return true if the current selection is of password type.
+ */
+ boolean isSelectionPassword();
}
private final Context mContext;
private final ActionHandler mActionHandler;
private final boolean mIncognito;
private boolean mEditable;
+ private boolean mIsPasswordType;
protected SelectActionModeCallback(
Context context, ActionHandler actionHandler, boolean incognito) {
@@ -94,6 +100,7 @@ public class SelectActionModeCallback implements ActionMode.Callback {
mode.setTitle(null);
mode.setSubtitle(null);
mEditable = mActionHandler.isSelectionEditable();
+ mIsPasswordType = mActionHandler.isSelectionPassword();
createActionMenu(mode, menu);
return true;
}
@@ -101,8 +108,10 @@ public class SelectActionModeCallback implements ActionMode.Callback {
@Override
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
boolean isEditableNow = mActionHandler.isSelectionEditable();
- if (mEditable != isEditableNow) {
+ boolean isPasswordNow = mActionHandler.isSelectionPassword();
+ if (mEditable != isEditableNow || mIsPasswordType != isPasswordNow) {
mEditable = isEditableNow;
+ mIsPasswordType = isPasswordNow;
menu.clear();
createActionMenu(mode, menu);
return true;
@@ -127,6 +136,10 @@ public class SelectActionModeCallback implements ActionMode.Callback {
if (mEditable || mIncognito || !mActionHandler.isWebSearchAvailable()) {
menu.removeItem(R.id.select_action_menu_web_search);
}
+ if (mIsPasswordType) {
+ menu.removeItem(R.id.select_action_menu_copy);
+ menu.removeItem(R.id.select_action_menu_cut);
+ }
}
@Override

Powered by Google App Engine
This is Rietveld 408576698