[Touchless] Update placeholder text and add special case for first run

Bug: 954529
Change-Id: I9cba7d40d2bc024226274debf1ffc1c5e60b5241
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1574297
Reviewed-by: Matthew Jones <mdjones@chromium.org>
Reviewed-by: Justin DeWitt <dewittj@chromium.org>
Commit-Queue: Brandon Wylie <wylieb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#654064}
diff --git a/chrome/android/touchless/java/src/org/chromium/chrome/browser/touchless/OpenLastTabMediator.java b/chrome/android/touchless/java/src/org/chromium/chrome/browser/touchless/OpenLastTabMediator.java
index 68ef4f8..a27034e 100644
--- a/chrome/android/touchless/java/src/org/chromium/chrome/browser/touchless/OpenLastTabMediator.java
+++ b/chrome/android/touchless/java/src/org/chromium/chrome/browser/touchless/OpenLastTabMediator.java
@@ -8,6 +8,7 @@
 import static android.text.format.DateUtils.getRelativeTimeSpanString;
 
 import android.content.Context;
+import android.content.SharedPreferences;
 import android.graphics.Bitmap;
 
 import org.chromium.chrome.browser.favicon.LargeIconBridge;
@@ -31,6 +32,8 @@
  */
 // TODO(crbug.com/948858): Add unit tests for this behavior.
 class OpenLastTabMediator implements HistoryProvider.BrowsingHistoryObserver, FocusableComponent {
+    private static final String FIRST_LAUNCHED_KEY = "TOUCHLESS_WAS_FIRST_LAUNCHED";
+
     private final Context mContext;
     private final Profile mProfile;
     private final NativePageHost mNativePageHost;
@@ -55,6 +58,13 @@
                 ViewUtils.createDefaultRoundedIconGenerator(mContext.getResources(), false);
         mIconBridge = new LargeIconBridge(mProfile);
 
+        // Check if this is a first launch of Chrome.
+        SharedPreferences prefs =
+                mNativePageHost.getActiveTab().getActivity().getPreferences(Context.MODE_PRIVATE);
+        boolean firstLaunched = prefs.getBoolean(FIRST_LAUNCHED_KEY, true);
+        prefs.edit().putBoolean(FIRST_LAUNCHED_KEY, false).apply();
+        mModel.set(OpenLastTabProperties.OPEN_LAST_TAB_FIRST_LAUNCH, firstLaunched);
+
         // TODO(wylieb):Investigate adding an item limit to the API.
         // Query the history for everything (no API exists to only query for the most recent).
         mHistoryBridge.queryHistory("");
diff --git a/chrome/android/touchless/java/src/org/chromium/chrome/browser/touchless/OpenLastTabProperties.java b/chrome/android/touchless/java/src/org/chromium/chrome/browser/touchless/OpenLastTabProperties.java
index d89c627..3a0ccde 100644
--- a/chrome/android/touchless/java/src/org/chromium/chrome/browser/touchless/OpenLastTabProperties.java
+++ b/chrome/android/touchless/java/src/org/chromium/chrome/browser/touchless/OpenLastTabProperties.java
@@ -28,6 +28,9 @@
     public static final PropertyModel.WritableBooleanPropertyKey OPEN_LAST_TAB_LOAD_SUCCESS =
             new PropertyModel.WritableBooleanPropertyKey();
 
+    public static final PropertyModel.WritableBooleanPropertyKey OPEN_LAST_TAB_FIRST_LAUNCH =
+            new PropertyModel.WritableBooleanPropertyKey();
+
     public static final PropertyModel.WritableObjectPropertyKey<Runnable> ON_FOCUS_CALLBACK =
             new PropertyModel.WritableObjectPropertyKey<>();
 
diff --git a/chrome/android/touchless/java/src/org/chromium/chrome/browser/touchless/OpenLastTabView.java b/chrome/android/touchless/java/src/org/chromium/chrome/browser/touchless/OpenLastTabView.java
index ebc1608..e50e07d7 100644
--- a/chrome/android/touchless/java/src/org/chromium/chrome/browser/touchless/OpenLastTabView.java
+++ b/chrome/android/touchless/java/src/org/chromium/chrome/browser/touchless/OpenLastTabView.java
@@ -24,6 +24,7 @@
 // TODO(crbug.com/948858): Add render tests for this view.
 public class OpenLastTabView extends FrameLayout {
     private LinearLayout mPlaceholder;
+    private TextView mPlaceholderText;
 
     private LinearLayout mLastTabView;
     private ImageView mIconView;
@@ -42,6 +43,8 @@
         super.onFinishInflate();
 
         mPlaceholder = findViewById(R.id.placeholder);
+        mPlaceholderText = findViewById(R.id.placeholder_text);
+
         mLastTabView = findViewById(R.id.open_last_tab);
         mIconView = findViewById(R.id.favicon);
         mTitleText = findViewById(R.id.title);
@@ -60,6 +63,12 @@
         }
     }
 
+    void setFirstLaunched(boolean firstLaunched) {
+        if (firstLaunched) {
+            mPlaceholderText.setText(R.string.open_last_tab_placeholder_first_launch);
+        }
+    }
+
     void setOpenLastTabOnClickListener(OnClickListener onClickListener) {
         mLastTabView.setOnClickListener(onClickListener);
     }
diff --git a/chrome/android/touchless/java/src/org/chromium/chrome/browser/touchless/OpenLastTabViewBinder.java b/chrome/android/touchless/java/src/org/chromium/chrome/browser/touchless/OpenLastTabViewBinder.java
index 2222034..76de593 100644
--- a/chrome/android/touchless/java/src/org/chromium/chrome/browser/touchless/OpenLastTabViewBinder.java
+++ b/chrome/android/touchless/java/src/org/chromium/chrome/browser/touchless/OpenLastTabViewBinder.java
@@ -23,6 +23,8 @@
             view.setTimestamp(model.get(OpenLastTabProperties.OPEN_LAST_TAB_TIMESTAMP));
         } else if (propertyKey == OpenLastTabProperties.OPEN_LAST_TAB_LOAD_SUCCESS) {
             view.setLoadSuccess(model.get(OpenLastTabProperties.OPEN_LAST_TAB_LOAD_SUCCESS));
+        } else if (propertyKey == OpenLastTabProperties.OPEN_LAST_TAB_FIRST_LAUNCH) {
+            view.setFirstLaunched(model.get(OpenLastTabProperties.OPEN_LAST_TAB_FIRST_LAUNCH));
         } else if (propertyKey == OpenLastTabProperties.ON_FOCUS_CALLBACK) {
             view.setOnFocusCallback(model.get(OpenLastTabProperties.ON_FOCUS_CALLBACK));
         } else if (propertyKey == OpenLastTabProperties.SHOULD_FOCUS_VIEW) {
diff --git a/chrome/android/touchless/java/strings/touchless_strings.grd b/chrome/android/touchless/java/strings/touchless_strings.grd
index 75f08ae..1048e0c 100644
--- a/chrome/android/touchless/java/strings/touchless_strings.grd
+++ b/chrome/android/touchless/java/strings/touchless_strings.grd
@@ -116,8 +116,11 @@
   </translations>
   <release seq="1">
     <messages fallback_to_english="true">
-      <message name="IDS_OPEN_LAST_TAB_PLACEHOLDER" desc="Message when user is first launching Chrome or after clearing history. [CHAR_LIMIT=NONE]">
-        Welcome to Chrome Explore
+      <message name="IDS_OPEN_LAST_TAB_PLACEHOLDER_FIRST_LAUNCH" desc="Message when user is first launching Chrome. [CHAR_LIMIT=NONE]">
+        Welcome to Chrome
+      </message>
+      <message name="IDS_OPEN_LAST_TAB_PLACEHOLDER" desc="Message after user has cleared history. [CHAR_LIMIT=NONE]">
+        Chrome
       </message>
       <message name="IDS_OPEN_LAST_TAB_JUST_NOW" desc="The present time or moment (noun). Used instead of a timestamp when the site was visited less than a minute ago. [CHAR_LIMIT=12]">
         Now