Commit c4f8604e authored by Mohamed Heikal's avatar Mohamed Heikal Committed by Commit Bot

[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/+/1676447Reviewed-by: default avatarXi Han <hanxi@chromium.org>
Reviewed-by: default avatarHenrique Nakashima <hnakashima@chromium.org>
Reviewed-by: default avatarMohamed Heikal <mheikal@chromium.org>
Commit-Queue: Mohamed Heikal <mheikal@chromium.org>
Cr-Commit-Position: refs/heads/master@{#672228}
parent eb63acc4
......@@ -393,7 +393,7 @@ void DownloadController::OnDownloadStarted(
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);
......
......@@ -18,7 +18,7 @@ Profile* GetProfile() {
} // namespace
ProfileKey* GetMainProfileKey() {
ProfileKey* GetLastUsedProfileKey() {
ProfileKey* key = ProfileKeyStartupAccessor::GetInstance()->profile_key();
if (!key)
key = GetProfile()->GetProfileKey();
......
......@@ -9,14 +9,15 @@ class ProfileKey;
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
......
......@@ -258,7 +258,7 @@ void JNI_OfflineTestUtil_WaitForConnectivityState(
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 @@ void JNI_OfflineTestUtil_SetGCMTokenForTesting(
JNIEnv* env,
const JavaParamRef<jstring>& gcm_token) {
prefetch_prefs::SetCachedPrefetchGCMToken(
::android::GetMainProfileKey()->GetPrefs(),
::android::GetLastUsedProfileKey()->GetPrefs(),
base::android::ConvertJavaStringToUTF8(env, gcm_token));
}
......
......@@ -27,7 +27,7 @@ namespace prefetch {
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 =
......
......@@ -34,13 +34,13 @@ JNI_EXPORT void JNI_PrefetchTestBridge_EnableLimitlessPrefetching(
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 @@ JNI_EXPORT void JNI_PrefetchTestBridge_InsertIntoCachedImageFetcher(
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 @@ JNI_EXPORT void JNI_PrefetchTestBridge_AddCandidatePrefetchURL(
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);
......
......@@ -44,7 +44,7 @@ ProfileKey* ProfileKeyAndroid::FromProfileKeyAndroid(
// 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>();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment