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

Unified Diff: content/public/android/java/src/org/chromium/content/browser/SelectActionMode.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/SelectActionMode.java
diff --git a/content/public/android/java/src/org/chromium/content/browser/SelectActionMode.java b/content/public/android/java/src/org/chromium/content/browser/SelectActionMode.java
new file mode 100644
index 0000000000000000000000000000000000000000..776a05f7477be01cd059cd104d9b2eea857b815d
--- /dev/null
+++ b/content/public/android/java/src/org/chromium/content/browser/SelectActionMode.java
@@ -0,0 +1,51 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.content.browser;
+
+import android.util.Log;
+import android.view.ActionMode;
+
+/**
+ * An ActionMode for in-page selection. This class wraps an ActionMode created
+ * by the associated View, providing modified interaction with that ActionMode.
+ */
+public class SelectActionMode {
+ private static final String TAG = "SelectActionMode";
+
+ protected final ActionMode mActionMode;
+
+ /**
+ * Constructs a SelectActionMode instance wrapping a concrete ActionMode.
+ * @param actionMode the wrapped ActionMode.
+ */
+ public SelectActionMode(ActionMode actionMode) {
+ assert actionMode != null;
+ mActionMode = actionMode;
+ }
+
+ /**
+ * @see ActionMode#finish()
+ */
+ public void finish() {
+ mActionMode.finish();
+ }
+
+ /**
+ * @see ActionMode#invalidate()
+ */
+ public void invalidate() {
+ // Try/catch necessary for framework bug, crbug.com/446717.
+ try {
+ mActionMode.invalidate();
+ } catch (NullPointerException e) {
+ Log.w(TAG, "Ignoring NPE from ActionMode.invalidate() as workaround for L", e);
+ }
+ }
+
+ /**
+ * @see ActionMode#invalidateContentRect()
+ */
+ public void invalidateContentRect() {}
+}

Powered by Google App Engine
This is Rietveld 408576698