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

Side by Side Diff: chrome/browser/profiles/profile_avatar_downloader.cc

Issue 263563003: Add referrer & load flag support to BitmapFetcher class. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: include another missing header 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
« no previous file with comments | « chrome/browser/notifications/sync_notifier/synced_notification.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/profiles/profile_avatar_downloader.h" 5 #include "chrome/browser/profiles/profile_avatar_downloader.h"
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "chrome/browser/browser_process.h" 8 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/profiles/profile_avatar_icon_util.h" 10 #include "chrome/browser/profiles/profile_avatar_icon_util.h"
11 #include "chrome/browser/profiles/profile_info_cache.h" 11 #include "chrome/browser/profiles/profile_info_cache.h"
12 #include "net/base/load_flags.h"
12 13
13 namespace { 14 namespace {
14 const char kHighResAvatarDownloadUrlPrefix[] = 15 const char kHighResAvatarDownloadUrlPrefix[] =
15 "http://www.gstatic.com/chrome/profile_avatars/"; 16 "http://www.gstatic.com/chrome/profile_avatars/";
16 } 17 }
17 18
18 ProfileAvatarDownloader::ProfileAvatarDownloader( 19 ProfileAvatarDownloader::ProfileAvatarDownloader(
19 size_t icon_index, 20 size_t icon_index,
20 ProfileInfoCache* cache) 21 ProfileInfoCache* cache)
21 : icon_index_(icon_index), 22 : icon_index_(icon_index),
22 cache_(cache) { 23 cache_(cache) {
23 GURL url(std::string(kHighResAvatarDownloadUrlPrefix) + 24 GURL url(std::string(kHighResAvatarDownloadUrlPrefix) +
24 profiles::GetDefaultAvatarIconFileNameAtIndex(icon_index)); 25 profiles::GetDefaultAvatarIconFileNameAtIndex(icon_index));
25 fetcher_.reset(new chrome::BitmapFetcher(url, this)); 26 fetcher_.reset(new chrome::BitmapFetcher(url, this));
26 } 27 }
27 28
28 ProfileAvatarDownloader::~ProfileAvatarDownloader() { 29 ProfileAvatarDownloader::~ProfileAvatarDownloader() {
29 } 30 }
30 31
31 void ProfileAvatarDownloader::Start() { 32 void ProfileAvatarDownloader::Start() {
32 // In unit tests, the browser process can return a NULL request context. 33 // In unit tests, the browser process can return a NULL request context.
33 net::URLRequestContextGetter* request_context = 34 net::URLRequestContextGetter* request_context =
34 g_browser_process->system_request_context(); 35 g_browser_process->system_request_context();
35 if (request_context) 36 if (request_context)
36 fetcher_->Start(request_context); 37 fetcher_->Start(
38 request_context,
39 std::string(),
40 net::URLRequest::CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE,
41 net::LOAD_NORMAL);
37 } 42 }
38 43
39 // BitmapFetcherDelegate overrides. 44 // BitmapFetcherDelegate overrides.
40 void ProfileAvatarDownloader::OnFetchComplete(const GURL url, 45 void ProfileAvatarDownloader::OnFetchComplete(const GURL url,
41 const SkBitmap* bitmap) { 46 const SkBitmap* bitmap) {
42 if (!bitmap || !cache_) 47 if (!bitmap || !cache_)
43 return; 48 return;
44 49
45 // Decode the downloaded bitmap. Ownership of the image is taken by |cache_|. 50 // Decode the downloaded bitmap. Ownership of the image is taken by |cache_|.
46 gfx::Image image = gfx::Image::CreateFrom1xBitmap(*bitmap); 51 gfx::Image image = gfx::Image::CreateFrom1xBitmap(*bitmap);
47 cache_->SaveAvatarImageAtPath(&image, 52 cache_->SaveAvatarImageAtPath(&image,
48 profiles::GetDefaultAvatarIconFileNameAtIndex(icon_index_), 53 profiles::GetDefaultAvatarIconFileNameAtIndex(icon_index_),
49 profiles::GetPathOfHighResAvatarAtIndex(icon_index_)); 54 profiles::GetPathOfHighResAvatarAtIndex(icon_index_));
50 } 55 }
OLDNEW
« no previous file with comments | « chrome/browser/notifications/sync_notifier/synced_notification.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698