[Android] Rename utility method GetMainProfileKey to GetLastUsedProfileKey

Rename ::android::GetMainProfileKey to ::android::GetLastUsedProfileKey so as
to be the same as the comparable function ProfileManager::GetLastUsedProfile.

TBR=It is just a rename/refactor.

Change-Id: I78f639cd6deb90bd34e672ed782fda7373ae9b71
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1676447
Reviewed-by: Xi Han <hanxi@chromium.org>
Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
Reviewed-by: Mohamed Heikal <mheikal@chromium.org>
Commit-Queue: Mohamed Heikal <mheikal@chromium.org>
Cr-Commit-Position: refs/heads/master@{#672228}
diff --git a/chrome/browser/android/download/download_controller.cc b/chrome/browser/android/download/download_controller.cc
index 76b0fe0..28eea4b 100644
--- a/chrome/browser/android/download/download_controller.cc
+++ b/chrome/browser/android/download/download_controller.cc
@@ -393,7 +393,7 @@
   Profile* profile = Profile::FromBrowserContext(
       content::DownloadItemUtils::GetBrowserContext(download_item));
   ProfileKey* profile_key =
-      profile ? profile->GetProfileKey() : ::android::GetMainProfileKey();
+      profile ? profile->GetProfileKey() : ::android::GetLastUsedProfileKey();
 
   DownloadOfflineContentProviderFactory::GetForKey(profile_key)
       ->OnDownloadStarted(download_item);
diff --git a/chrome/browser/android/profile_key_util.cc b/chrome/browser/android/profile_key_util.cc
index 963130e..30a8746 100644
--- a/chrome/browser/android/profile_key_util.cc
+++ b/chrome/browser/android/profile_key_util.cc
@@ -18,7 +18,7 @@
 
 }  // namespace
 
-ProfileKey* GetMainProfileKey() {
+ProfileKey* GetLastUsedProfileKey() {
   ProfileKey* key = ProfileKeyStartupAccessor::GetInstance()->profile_key();
   if (!key)
     key = GetProfile()->GetProfileKey();
diff --git a/chrome/browser/android/profile_key_util.h b/chrome/browser/android/profile_key_util.h
index 17c0226..3bc5f51 100644
--- a/chrome/browser/android/profile_key_util.h
+++ b/chrome/browser/android/profile_key_util.h
@@ -9,14 +9,15 @@
 
 namespace android {
 
-// This gets the profile key belonging to the main profile on android. This
-// works in both reduced mode and full browser mode.
+// This gets the profile key belonging to the last used profile on android, (or
+// the "main" one in reduced mode). This works in both reduced mode and full
+// browser mode.
 //
 // BE WARNED you should only use this if it would have been acceptable to use
 // ProfileManager::GetLastUsedProfile() in the same context. If your usecase
 // cares about different profiles and their keys, then you should plumb through
 // the correct key instead.
-ProfileKey* GetMainProfileKey();
+ProfileKey* GetLastUsedProfileKey();
 
 }  // namespace android
 
diff --git a/chrome/browser/offline_pages/android/offline_test_util_jni.cc b/chrome/browser/offline_pages/android/offline_test_util_jni.cc
index 2f76339..3ff4dc2 100644
--- a/chrome/browser/offline_pages/android/offline_test_util_jni.cc
+++ b/chrome/browser/offline_pages/android/offline_test_util_jni.cc
@@ -258,7 +258,7 @@
 void JNI_OfflineTestUtil_SetPrefetchingEnabledByServer(
     JNIEnv* env,
     const jboolean enabled) {
-  ProfileKey* key = ::android::GetMainProfileKey();
+  ProfileKey* key = ::android::GetLastUsedProfileKey();
 
   prefetch_prefs::SetEnabledByServer(key->GetPrefs(), enabled);
   if (!enabled) {
@@ -270,7 +270,7 @@
     JNIEnv* env,
     const JavaParamRef<jstring>& gcm_token) {
   prefetch_prefs::SetCachedPrefetchGCMToken(
-      ::android::GetMainProfileKey()->GetPrefs(),
+      ::android::GetLastUsedProfileKey()->GetPrefs(),
       base::android::ConvertJavaStringToUTF8(env, gcm_token));
 }
 
diff --git a/chrome/browser/offline_pages/android/prefetch_background_task_android.cc b/chrome/browser/offline_pages/android/prefetch_background_task_android.cc
index bb8abe7..eeeec54 100644
--- a/chrome/browser/offline_pages/android/prefetch_background_task_android.cc
+++ b/chrome/browser/offline_pages/android/prefetch_background_task_android.cc
@@ -27,7 +27,7 @@
 static jboolean JNI_PrefetchBackgroundTask_StartPrefetchTask(
     JNIEnv* env,
     const JavaParamRef<jobject>& jcaller) {
-  ProfileKey* profile_key = ::android::GetMainProfileKey();
+  ProfileKey* profile_key = ::android::GetLastUsedProfileKey();
   DCHECK(profile_key);
 
   PrefetchService* prefetch_service =
diff --git a/chrome/browser/offline_pages/android/prefetch_test_bridge.cc b/chrome/browser/offline_pages/android/prefetch_test_bridge.cc
index ca7eac9..128c86e 100644
--- a/chrome/browser/offline_pages/android/prefetch_test_bridge.cc
+++ b/chrome/browser/offline_pages/android/prefetch_test_bridge.cc
@@ -34,13 +34,13 @@
     JNIEnv* env,
     jboolean enable) {
   prefetch_prefs::SetLimitlessPrefetchingEnabled(
-      ::android::GetMainProfileKey()->GetPrefs(), enable != 0);
+      ::android::GetLastUsedProfileKey()->GetPrefs(), enable != 0);
 }
 
 JNI_EXPORT jboolean
 JNI_PrefetchTestBridge_IsLimitlessPrefetchingEnabled(JNIEnv* env) {
   return static_cast<jboolean>(prefetch_prefs::IsLimitlessPrefetchingEnabled(
-      ::android::GetMainProfileKey()->GetPrefs()));
+      ::android::GetLastUsedProfileKey()->GetPrefs()));
 }
 
 JNI_EXPORT void JNI_PrefetchTestBridge_SkipNTPSuggestionsAPIKeyCheck(
@@ -54,7 +54,7 @@
     const JavaParamRef<jstring>& j_url,
     const JavaParamRef<jbyteArray>& j_image_data) {
   image_fetcher::ImageFetcherService* service =
-      ImageFetcherServiceFactory::GetForKey(::android::GetMainProfileKey());
+      ImageFetcherServiceFactory::GetForKey(::android::GetLastUsedProfileKey());
   DCHECK(service);
   scoped_refptr<image_fetcher::ImageCache> cache =
       service->ImageCacheForTesting();
@@ -86,7 +86,7 @@
       PrefetchURL(url.spec(), url, title, GURL(thumbnail_url),
                   GURL(favicon_url), snippet, attribution)};
 
-  PrefetchServiceFactory::GetForKey(::android::GetMainProfileKey())
+  PrefetchServiceFactory::GetForKey(::android::GetLastUsedProfileKey())
       ->GetPrefetchDispatcher()
       ->AddCandidatePrefetchURLs(kSuggestedArticlesNamespace,
                                  new_candidate_urls);
diff --git a/chrome/browser/profiles/profile_key_android.cc b/chrome/browser/profiles/profile_key_android.cc
index d67e4d8..4fdc25e 100644
--- a/chrome/browser/profiles/profile_key_android.cc
+++ b/chrome/browser/profiles/profile_key_android.cc
@@ -44,7 +44,7 @@
 // static
 ScopedJavaLocalRef<jobject> ProfileKeyAndroid::GetLastUsedProfileKey(
     JNIEnv* env) {
-  ProfileKey* key = ::android::GetMainProfileKey();
+  ProfileKey* key = ::android::GetLastUsedProfileKey();
   if (key == nullptr) {
     NOTREACHED() << "ProfileKey not found.";
     return ScopedJavaLocalRef<jobject>();