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( ...@@ -393,7 +393,7 @@ void DownloadController::OnDownloadStarted(
Profile* profile = Profile::FromBrowserContext( Profile* profile = Profile::FromBrowserContext(
content::DownloadItemUtils::GetBrowserContext(download_item)); content::DownloadItemUtils::GetBrowserContext(download_item));
ProfileKey* profile_key = ProfileKey* profile_key =
profile ? profile->GetProfileKey() : ::android::GetMainProfileKey(); profile ? profile->GetProfileKey() : ::android::GetLastUsedProfileKey();
DownloadOfflineContentProviderFactory::GetForKey(profile_key) DownloadOfflineContentProviderFactory::GetForKey(profile_key)
->OnDownloadStarted(download_item); ->OnDownloadStarted(download_item);
......
...@@ -18,7 +18,7 @@ Profile* GetProfile() { ...@@ -18,7 +18,7 @@ Profile* GetProfile() {
} // namespace } // namespace
ProfileKey* GetMainProfileKey() { ProfileKey* GetLastUsedProfileKey() {
ProfileKey* key = ProfileKeyStartupAccessor::GetInstance()->profile_key(); ProfileKey* key = ProfileKeyStartupAccessor::GetInstance()->profile_key();
if (!key) if (!key)
key = GetProfile()->GetProfileKey(); key = GetProfile()->GetProfileKey();
......
...@@ -9,14 +9,15 @@ class ProfileKey; ...@@ -9,14 +9,15 @@ class ProfileKey;
namespace android { namespace android {
// This gets the profile key belonging to the main profile on android. This // This gets the profile key belonging to the last used profile on android, (or
// works in both reduced mode and full browser mode. // 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 // BE WARNED you should only use this if it would have been acceptable to use
// ProfileManager::GetLastUsedProfile() in the same context. If your usecase // ProfileManager::GetLastUsedProfile() in the same context. If your usecase
// cares about different profiles and their keys, then you should plumb through // cares about different profiles and their keys, then you should plumb through
// the correct key instead. // the correct key instead.
ProfileKey* GetMainProfileKey(); ProfileKey* GetLastUsedProfileKey();
} // namespace android } // namespace android
......
...@@ -258,7 +258,7 @@ void JNI_OfflineTestUtil_WaitForConnectivityState( ...@@ -258,7 +258,7 @@ void JNI_OfflineTestUtil_WaitForConnectivityState(
void JNI_OfflineTestUtil_SetPrefetchingEnabledByServer( void JNI_OfflineTestUtil_SetPrefetchingEnabledByServer(
JNIEnv* env, JNIEnv* env,
const jboolean enabled) { const jboolean enabled) {
ProfileKey* key = ::android::GetMainProfileKey(); ProfileKey* key = ::android::GetLastUsedProfileKey();
prefetch_prefs::SetEnabledByServer(key->GetPrefs(), enabled); prefetch_prefs::SetEnabledByServer(key->GetPrefs(), enabled);
if (!enabled) { if (!enabled) {
...@@ -270,7 +270,7 @@ void JNI_OfflineTestUtil_SetGCMTokenForTesting( ...@@ -270,7 +270,7 @@ void JNI_OfflineTestUtil_SetGCMTokenForTesting(
JNIEnv* env, JNIEnv* env,
const JavaParamRef<jstring>& gcm_token) { const JavaParamRef<jstring>& gcm_token) {
prefetch_prefs::SetCachedPrefetchGCMToken( prefetch_prefs::SetCachedPrefetchGCMToken(
::android::GetMainProfileKey()->GetPrefs(), ::android::GetLastUsedProfileKey()->GetPrefs(),
base::android::ConvertJavaStringToUTF8(env, gcm_token)); base::android::ConvertJavaStringToUTF8(env, gcm_token));
} }
......
...@@ -27,7 +27,7 @@ namespace prefetch { ...@@ -27,7 +27,7 @@ namespace prefetch {
static jboolean JNI_PrefetchBackgroundTask_StartPrefetchTask( static jboolean JNI_PrefetchBackgroundTask_StartPrefetchTask(
JNIEnv* env, JNIEnv* env,
const JavaParamRef<jobject>& jcaller) { const JavaParamRef<jobject>& jcaller) {
ProfileKey* profile_key = ::android::GetMainProfileKey(); ProfileKey* profile_key = ::android::GetLastUsedProfileKey();
DCHECK(profile_key); DCHECK(profile_key);
PrefetchService* prefetch_service = PrefetchService* prefetch_service =
......
...@@ -34,13 +34,13 @@ JNI_EXPORT void JNI_PrefetchTestBridge_EnableLimitlessPrefetching( ...@@ -34,13 +34,13 @@ JNI_EXPORT void JNI_PrefetchTestBridge_EnableLimitlessPrefetching(
JNIEnv* env, JNIEnv* env,
jboolean enable) { jboolean enable) {
prefetch_prefs::SetLimitlessPrefetchingEnabled( prefetch_prefs::SetLimitlessPrefetchingEnabled(
::android::GetMainProfileKey()->GetPrefs(), enable != 0); ::android::GetLastUsedProfileKey()->GetPrefs(), enable != 0);
} }
JNI_EXPORT jboolean JNI_EXPORT jboolean
JNI_PrefetchTestBridge_IsLimitlessPrefetchingEnabled(JNIEnv* env) { JNI_PrefetchTestBridge_IsLimitlessPrefetchingEnabled(JNIEnv* env) {
return static_cast<jboolean>(prefetch_prefs::IsLimitlessPrefetchingEnabled( return static_cast<jboolean>(prefetch_prefs::IsLimitlessPrefetchingEnabled(
::android::GetMainProfileKey()->GetPrefs())); ::android::GetLastUsedProfileKey()->GetPrefs()));
} }
JNI_EXPORT void JNI_PrefetchTestBridge_SkipNTPSuggestionsAPIKeyCheck( JNI_EXPORT void JNI_PrefetchTestBridge_SkipNTPSuggestionsAPIKeyCheck(
...@@ -54,7 +54,7 @@ JNI_EXPORT void JNI_PrefetchTestBridge_InsertIntoCachedImageFetcher( ...@@ -54,7 +54,7 @@ JNI_EXPORT void JNI_PrefetchTestBridge_InsertIntoCachedImageFetcher(
const JavaParamRef<jstring>& j_url, const JavaParamRef<jstring>& j_url,
const JavaParamRef<jbyteArray>& j_image_data) { const JavaParamRef<jbyteArray>& j_image_data) {
image_fetcher::ImageFetcherService* service = image_fetcher::ImageFetcherService* service =
ImageFetcherServiceFactory::GetForKey(::android::GetMainProfileKey()); ImageFetcherServiceFactory::GetForKey(::android::GetLastUsedProfileKey());
DCHECK(service); DCHECK(service);
scoped_refptr<image_fetcher::ImageCache> cache = scoped_refptr<image_fetcher::ImageCache> cache =
service->ImageCacheForTesting(); service->ImageCacheForTesting();
...@@ -86,7 +86,7 @@ JNI_EXPORT void JNI_PrefetchTestBridge_AddCandidatePrefetchURL( ...@@ -86,7 +86,7 @@ JNI_EXPORT void JNI_PrefetchTestBridge_AddCandidatePrefetchURL(
PrefetchURL(url.spec(), url, title, GURL(thumbnail_url), PrefetchURL(url.spec(), url, title, GURL(thumbnail_url),
GURL(favicon_url), snippet, attribution)}; GURL(favicon_url), snippet, attribution)};
PrefetchServiceFactory::GetForKey(::android::GetMainProfileKey()) PrefetchServiceFactory::GetForKey(::android::GetLastUsedProfileKey())
->GetPrefetchDispatcher() ->GetPrefetchDispatcher()
->AddCandidatePrefetchURLs(kSuggestedArticlesNamespace, ->AddCandidatePrefetchURLs(kSuggestedArticlesNamespace,
new_candidate_urls); new_candidate_urls);
......
...@@ -44,7 +44,7 @@ ProfileKey* ProfileKeyAndroid::FromProfileKeyAndroid( ...@@ -44,7 +44,7 @@ ProfileKey* ProfileKeyAndroid::FromProfileKeyAndroid(
// static // static
ScopedJavaLocalRef<jobject> ProfileKeyAndroid::GetLastUsedProfileKey( ScopedJavaLocalRef<jobject> ProfileKeyAndroid::GetLastUsedProfileKey(
JNIEnv* env) { JNIEnv* env) {
ProfileKey* key = ::android::GetMainProfileKey(); ProfileKey* key = ::android::GetLastUsedProfileKey();
if (key == nullptr) { if (key == nullptr) {
NOTREACHED() << "ProfileKey not found."; NOTREACHED() << "ProfileKey not found.";
return ScopedJavaLocalRef<jobject>(); 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