Improve @IntDef inside Selection

This patch is aligning various @IntDef to some standard used with many other CLs:

1. @IntDef is first, @Retention second and related @interface third
2. there is used @Retention(RetentionPolicy.SOURCE)
3. @IntDef entries are inside @interface

BUG=919666

Change-Id: I2d9f057071bfa282809545a91d6917908e1594f5
Reviewed-on: https://chromium-review.googlesource.com/c/1480371
Reviewed-by: Pedro Amaral <amaralp@chromium.org>
Commit-Queue: Marcin Wiącek <marcin@mwiacek.com>
Cr-Commit-Position: refs/heads/master@{#636566}
diff --git a/content/public/android/java/src/org/chromium/content/browser/selection/SmartSelectionClient.java b/content/public/android/java/src/org/chromium/content/browser/selection/SmartSelectionClient.java
index 8c2aeb18..e0254e7 100644
--- a/content/public/android/java/src/org/chromium/content/browser/selection/SmartSelectionClient.java
+++ b/content/public/android/java/src/org/chromium/content/browser/selection/SmartSelectionClient.java
@@ -27,17 +27,17 @@
  */
 @JNINamespace("content")
 public class SmartSelectionClient implements SelectionClient {
-    @IntDef({CLASSIFY, SUGGEST_AND_CLASSIFY})
+    @IntDef({RequestType.CLASSIFY, RequestType.SUGGEST_AND_CLASSIFY})
     @Retention(RetentionPolicy.SOURCE)
-    private @interface RequestType {}
+    private @interface RequestType {
+        // Request to obtain the type (e.g. phone number, e-mail address) and the most
+        // appropriate operation for the selected text.
+        int CLASSIFY = 0;
 
-    // Request to obtain the type (e.g. phone number, e-mail address) and the most
-    // appropriate operation for the selected text.
-    private static final int CLASSIFY = 0;
-
-    // Request to obtain the type (e.g. phone number, e-mail address), the most
-    // appropriate operation for the selected text and a better selection boundaries.
-    private static final int SUGGEST_AND_CLASSIFY = 1;
+        // Request to obtain the type (e.g. phone number, e-mail address), the most
+        // appropriate operation for the selected text and a better selection boundaries.
+        int SUGGEST_AND_CLASSIFY = 1;
+    }
 
     // The maximal number of characters on the left and on the right from the current selection.
     // Used for surrounding text request.
@@ -88,7 +88,8 @@
 
     @Override
     public boolean requestSelectionPopupUpdates(boolean shouldSuggest) {
-        requestSurroundingText(shouldSuggest ? SUGGEST_AND_CLASSIFY : CLASSIFY);
+        requestSurroundingText(
+                shouldSuggest ? RequestType.SUGGEST_AND_CLASSIFY : RequestType.CLASSIFY);
         return true;
     }
 
@@ -139,11 +140,11 @@
         }
 
         switch (callbackData) {
-            case SUGGEST_AND_CLASSIFY:
+            case RequestType.SUGGEST_AND_CLASSIFY:
                 mProvider.sendSuggestAndClassifyRequest(text, start, end, null);
                 break;
 
-            case CLASSIFY:
+            case RequestType.CLASSIFY:
                 mProvider.sendClassifyRequest(text, start, end, null);
                 break;
 
diff --git a/content/public/android/java/src/org/chromium/content/browser/selection/SmartSelectionMetricsLogger.java b/content/public/android/java/src/org/chromium/content/browser/selection/SmartSelectionMetricsLogger.java
index 7923917..37dbe5a 100644
--- a/content/public/android/java/src/org/chromium/content/browser/selection/SmartSelectionMetricsLogger.java
+++ b/content/public/android/java/src/org/chromium/content/browser/selection/SmartSelectionMetricsLogger.java
@@ -50,10 +50,10 @@
     private SelectionIndicesConverter mConverter;
 
     // ActionType, from SmartSelectionEventTracker.SelectionEvent class.
-    @Retention(RetentionPolicy.SOURCE)
     @IntDef({ActionType.OVERTYPE, ActionType.COPY, ActionType.PASTE, ActionType.CUT,
             ActionType.SHARE, ActionType.SMART_SHARE, ActionType.DRAG, ActionType.ABANDON,
             ActionType.OTHER, ActionType.SELECT_ALL, ActionType.RESET})
+    @Retention(RetentionPolicy.SOURCE)
     public @interface ActionType {
         /** User typed over the selection. */
         int OVERTYPE = 100;
diff --git a/content/public/android/java/src/org/chromium/content/browser/selection/SmartSelectionProvider.java b/content/public/android/java/src/org/chromium/content/browser/selection/SmartSelectionProvider.java
index 2760dd1..83ad2fd5 100644
--- a/content/public/android/java/src/org/chromium/content/browser/selection/SmartSelectionProvider.java
+++ b/content/public/android/java/src/org/chromium/content/browser/selection/SmartSelectionProvider.java
@@ -30,12 +30,12 @@
 public class SmartSelectionProvider {
     private static final String TAG = "SmartSelProvider";
 
-    @IntDef({CLASSIFY, SUGGEST_AND_CLASSIFY})
+    @IntDef({RequestType.CLASSIFY, RequestType.SUGGEST_AND_CLASSIFY})
     @Retention(RetentionPolicy.SOURCE)
-    private @interface RequestType {}
-
-    private static final int CLASSIFY = 0;
-    private static final int SUGGEST_AND_CLASSIFY = 1;
+    private @interface RequestType {
+        int CLASSIFY = 0;
+        int SUGGEST_AND_CLASSIFY = 1;
+    }
 
     private SelectionClient.ResultCallback mResultCallback;
     private WindowAndroid mWindowAndroid;
@@ -60,11 +60,11 @@
 
     public void sendSuggestAndClassifyRequest(
             CharSequence text, int start, int end, Locale[] locales) {
-        sendSmartSelectionRequest(SUGGEST_AND_CLASSIFY, text, start, end, locales);
+        sendSmartSelectionRequest(RequestType.SUGGEST_AND_CLASSIFY, text, start, end, locales);
     }
 
     public void sendClassifyRequest(CharSequence text, int start, int end, Locale[] locales) {
-        sendSmartSelectionRequest(CLASSIFY, text, start, end, locales);
+        sendSmartSelectionRequest(RequestType.CLASSIFY, text, start, end, locales);
     }
 
     public void cancelAllRequests() {
@@ -118,7 +118,7 @@
     @TargetApi(Build.VERSION_CODES.O)
     private class ClassificationTask extends AsyncTask<SelectionClient.Result> {
         private final TextClassifier mTextClassifier;
-        private final int mRequestType;
+        private final @RequestType int mRequestType;
         private final CharSequence mText;
         private final int mOriginalStart;
         private final int mOriginalEnd;
@@ -141,7 +141,7 @@
 
             TextSelection textSelection = null;
 
-            if (mRequestType == SUGGEST_AND_CLASSIFY) {
+            if (mRequestType == RequestType.SUGGEST_AND_CLASSIFY) {
                 textSelection = mTextClassifier.suggestSelection(
                         mText, start, end, makeLocaleList(mLocales));
                 start = Math.max(0, textSelection.getSelectionStartIndex());