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

Side by Side Diff: chrome/browser/profiles/profile_avatar_downloader.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: msw nits Created 6 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/profiles/profile_avatar_downloader.h"
6
7 #include "base/files/file_path.h"
8 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/profiles/profile_avatar_icon_util.h"
11 #include "chrome/browser/profiles/profile_info_cache.h"
12
13 namespace {
14 const char kHighResAvatarDownloadUrlPrefix[] =
15 "http://www.gstatic.com/chrome/profile_avatars/";
16 }
17
18 ProfileAvatarDownloader::ProfileAvatarDownloader(
19 size_t icon_index,
20 ProfileInfoCache* cache)
21 : icon_index_(icon_index),
22 cache_(cache) {
23 GURL url(std::string(kHighResAvatarDownloadUrlPrefix) +
24 profiles::GetDefaultAvatarIconFileNameAtIndex(icon_index));
25 fetcher_.reset(new chrome::BitmapFetcher(url, this));
26 }
27
28 ProfileAvatarDownloader::~ProfileAvatarDownloader() {
29 }
30
31 void ProfileAvatarDownloader::Start() {
32 fetcher_->Start(g_browser_process->system_request_context());
33 }
34
35 // BitmapFetcherDelegate overrides.
36 void ProfileAvatarDownloader::OnFetchComplete(const GURL url,
37 const SkBitmap* bitmap) {
38 if (!bitmap || !cache_)
39 return;
40
41 // Decode the downloaded bitmap. Ownership of the image is taken by |cache_|.
42 gfx::Image image = gfx::Image::CreateFrom1xBitmap(*bitmap);
43 cache_->SaveAvatarImageAtPath(&image,
44 profiles::GetDefaultAvatarIconFileNameAtIndex(icon_index_),
45 profiles::GetPathOfHighResAvatarAtIndex(icon_index_));
46 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698