[Merge M73] Fix isTabbedModeClassName

Change it to isTabbedModeComponentName which also allows <package
name>.Main pattern.

See internal bug b/122899279

Change-Id: Iee3f920a59101ffda334f83f286c7b2320508598
Reviewed-on: https://chromium-review.googlesource.com/c/1441647
Auto-Submit: Bo <boliu@chromium.org>
Commit-Queue: Ted Choc <tedchoc@chromium.org>
Reviewed-by: Ted Choc <tedchoc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#626955}
(cherry picked from commit 27113254b0dc15a0ab8d1bca693a7ed1dd5af8e9)

Merge approved by benmason on chat
TBR: benmason@chromium.org

Change-Id: Ica4e852943eca0014144dcd514b521ef83587dd0
Reviewed-on: https://chromium-review.googlesource.com/c/1450296
Reviewed-by: Bo <boliu@chromium.org>
Cr-Commit-Position: refs/branch-heads/3683@{#120}
Cr-Branched-From: e51029943e0a38dd794b73caaf6373d5496ae783-refs/heads/master@{#625896}
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ChromeTabbedActivity.java b/chrome/android/java/src/org/chromium/chrome/browser/ChromeTabbedActivity.java
index 5f477de..1ab4aa1 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/ChromeTabbedActivity.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/ChromeTabbedActivity.java
@@ -372,10 +372,12 @@
     /**
      * Return whether the passed in class name matches any of the supported tabbed mode activities.
      */
-    public static boolean isTabbedModeClassName(String className) {
-        return TextUtils.equals(className, ChromeTabbedActivity.class.getName())
-                || TextUtils.equals(className, MultiInstanceChromeTabbedActivity.class.getName())
-                || TextUtils.equals(className, ChromeTabbedActivity2.class.getName());
+    public static boolean isTabbedModeComponentName(String componentName) {
+        return TextUtils.equals(componentName, ChromeTabbedActivity.class.getName())
+                || TextUtils.equals(
+                        componentName, MultiInstanceChromeTabbedActivity.class.getName())
+                || TextUtils.equals(componentName, ChromeTabbedActivity2.class.getName())
+                || TextUtils.equals(componentName, BuildInfo.getInstance().packageName + ".Main");
     }
 
     /**
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/document/DocumentUtils.java b/chrome/android/java/src/org/chromium/chrome/browser/document/DocumentUtils.java
index 6bbd9b0..d4bf99c5 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/document/DocumentUtils.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/document/DocumentUtils.java
@@ -100,13 +100,13 @@
     }
 
     /**
-     * Given an AppTask retrieves the task class name.
+     * Given an AppTask retrieves the task component name.
      * @param task The app task to use.
      * @param pm The package manager to use for resolving intent.
-     * @return Fully qualified class name or null if we were not able to
+     * @return Fully qualified component name name or null if we were not able to
      * determine it.
      */
-    public static String getTaskClassName(AppTask task, PackageManager pm) {
+    public static String getTaskComponentName(AppTask task, PackageManager pm) {
         RecentTaskInfo info = getTaskInfoFromTask(task);
         if (info == null) return null;
 
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/incognito/IncognitoNotificationService.java b/chrome/android/java/src/org/chromium/chrome/browser/incognito/IncognitoNotificationService.java
index e7fccf62..9c3c9563 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/incognito/IncognitoNotificationService.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/incognito/IncognitoNotificationService.java
@@ -123,13 +123,13 @@
         for (AppTask task : manager.getAppTasks()) {
             RecentTaskInfo info = DocumentUtils.getTaskInfoFromTask(task);
             if (info == null) continue;
-            String className = DocumentUtils.getTaskClassName(task, pm);
+            String componentName = DocumentUtils.getTaskComponentName(task, pm);
 
             // It is not easily possible to distinguish between tasks sitting on top of
             // ChromeLauncherActivity, so we treat them all as likely ChromeTabbedActivities and
             // close them to be on the cautious side of things.
-            if ((ChromeTabbedActivity.isTabbedModeClassName(className)
-                    || TextUtils.equals(className, ChromeLauncherActivity.class.getName()))
+            if ((ChromeTabbedActivity.isTabbedModeComponentName(componentName)
+                        || TextUtils.equals(componentName, ChromeLauncherActivity.class.getName()))
                     && !visibleTaskIds.contains(info.id)) {
                 task.finishAndRemoveTask();
             }
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/incognito/IncognitoUtils.java b/chrome/android/java/src/org/chromium/chrome/browser/incognito/IncognitoUtils.java
index eb91a24..2e5b48a 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/incognito/IncognitoUtils.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/incognito/IncognitoUtils.java
@@ -53,9 +53,9 @@
         for (ActivityManager.AppTask task : manager.getAppTasks()) {
             ActivityManager.RecentTaskInfo info = DocumentUtils.getTaskInfoFromTask(task);
             if (info == null) continue;
-            String className = DocumentUtils.getTaskClassName(task, pm);
+            String componentName = DocumentUtils.getTaskComponentName(task, pm);
 
-            if (ChromeTabbedActivity.isTabbedModeClassName(className)) {
+            if (ChromeTabbedActivity.isTabbedModeComponentName(componentName)) {
                 tabbedModeTaskIds.add(info.id);
             }
         }