Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7647)

Unified Diff: chrome/browser/profiles/profiles_state.cc

Issue 222313005: [Profiles] Download high-res avatars using the --new-profile-management flag (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/profiles/profiles_state.cc
diff --git a/chrome/browser/profiles/profiles_state.cc b/chrome/browser/profiles/profiles_state.cc
index 282ffd3f3544b25312ce4518a7be51cf4b0faacf..2ce7489880a4a80f381e1ef450871a69355d166a 100644
--- a/chrome/browser/profiles/profiles_state.cc
+++ b/chrome/browser/profiles/profiles_state.cc
@@ -10,6 +10,8 @@
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/profiles/profile_avatar_downloader.h"
+#include "chrome/browser/profiles/profile_avatar_icon_util.h"
#include "chrome/browser/profiles/profile_info_cache.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
@@ -113,4 +115,22 @@ bool IsRegularOrGuestSession(Browser* browser) {
return profile->IsGuestSession() || !profile->IsOffTheRecord();
}
+void DownloadHighResAvatarIfNeeded(size_t icon_index) {
+ // TODO(noms): We should check whether the file already exists on disk
+ // before trying to re-download it. For now, since this is behind a flag and
+ // the resources are still changing, re-download it every time the profile
+ // avatar changes, to make sure we have the latest copy.
+ ProfileInfoCache* cache =
+ &g_browser_process->profile_manager()->GetProfileInfoCache();
+
+ // Start the download for this file. The cache takes ownership of the
+ // |avatar_downloader|, which will be deleted when the download completes, or
+ // if that never happens, when the ProfileInfoCache is destroyed.
+ ProfileAvatarDownloader* avatar_dowloader = new ProfileAvatarDownloader(
+ g_browser_process->system_request_context(),
+ icon_index,
+ cache);
+ cache->DownloadHighResAvatar(avatar_dowloader, icon_index);
+}
+
} // namespace profiles

Powered by Google App Engine
This is Rietveld 408576698