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

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

Issue 1066053002: [Android] Allow custom ActionMode creation via ContentViewClient (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix null check Created 5 years, 8 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/ContentViewClient.java
diff --git a/content/public/android/java/src/org/chromium/content/browser/ContentViewClient.java b/content/public/android/java/src/org/chromium/content/browser/ContentViewClient.java
index 92288ad5f57ac0a1aecdda203c611711da242eef..8775c6bbb572fd69514507e0be56fd696cb4e2da 100644
--- a/content/public/android/java/src/org/chromium/content/browser/ContentViewClient.java
+++ b/content/public/android/java/src/org/chromium/content/browser/ContentViewClient.java
@@ -10,6 +10,7 @@ import android.content.Intent;
import android.util.Log;
import android.view.ActionMode;
import android.view.KeyEvent;
+import android.view.View;
import org.chromium.content.browser.SelectActionModeCallback.ActionHandler;
@@ -83,11 +84,27 @@ public class ContentViewClient {
}
/**
- * Returns an ActionMode.Callback for in-page selection.
+ * Starts an ActionMode for in-page selection.
+ * @param view The associated View.
+ * @param actionHandler The associated ActionHandler.
+ * @param floating Whether to try creating a floating ActionMode. If this
+ * feature is unsupported, the return value will be null.
+ * @return the SelectActionMode if creation is successful, otherwise null.
*/
- public ActionMode.Callback getSelectActionModeCallback(
- Context context, ActionHandler actionHandler, boolean incognito) {
- return new SelectActionModeCallback(context, actionHandler, incognito);
+ public SelectActionMode startActionMode(
+ View view, ActionHandler actionHandler, boolean floating) {
+ if (floating) return null;
+ ActionMode.Callback callback =
+ new SelectActionModeCallback(view.getContext(), actionHandler);
+ ActionMode actionMode = view.startActionMode(callback);
+ return actionMode != null ? new SelectActionMode(actionMode) : null;
+ }
+
+ /**
+ * @return whether the client supports the creation of floating ActionMode instances.
+ */
+ public boolean supportsFloatingActionMode() {
+ return false;
}
/**

Powered by Google App Engine
This is Rietveld 408576698