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

Side by Side Diff: chrome/browser/image_holder.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
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 // This class holds the URL to an image and the bitmap for the fetched image, 5 // This class holds the URL to an image and the bitmap for the fetched image,
6 // and has code to fetch the bitmap from the URL. 6 // and has code to fetch the bitmap from the URL.
7 7
8 #include "chrome/browser/image_holder.h" 8 #include "chrome/browser/image_holder.h"
9 9
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
11 #include "net/base/load_flags.h"
11 12
12 namespace chrome { 13 namespace chrome {
13 14
14 ImageHolder::ImageHolder(const GURL& low_dpi_url, 15 ImageHolder::ImageHolder(const GURL& low_dpi_url,
15 const GURL& high_dpi_url, 16 const GURL& high_dpi_url,
16 Profile* profile, 17 Profile* profile,
17 ImageHolderDelegate* delegate) 18 ImageHolderDelegate* delegate)
18 : low_dpi_url_(low_dpi_url), 19 : low_dpi_url_(low_dpi_url),
19 high_dpi_url_(high_dpi_url), 20 high_dpi_url_(high_dpi_url),
20 low_dpi_fetched_(false), 21 low_dpi_fetched_(false),
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 if (url.is_valid()) { 61 if (url.is_valid()) {
61 fetchers_.push_back(new chrome::BitmapFetcher(url, this)); 62 fetchers_.push_back(new chrome::BitmapFetcher(url, this));
62 DVLOG(2) << __FUNCTION__ << "Pushing bitmap " << url; 63 DVLOG(2) << __FUNCTION__ << "Pushing bitmap " << url;
63 } 64 }
64 } 65 }
65 66
66 void ImageHolder::StartFetch() { 67 void ImageHolder::StartFetch() {
67 // Now that we have queued them all, start the fetching. 68 // Now that we have queued them all, start the fetching.
68 ScopedVector<chrome::BitmapFetcher>::iterator iter; 69 ScopedVector<chrome::BitmapFetcher>::iterator iter;
69 for (iter = fetchers_.begin(); iter != fetchers_.end(); ++iter) { 70 for (iter = fetchers_.begin(); iter != fetchers_.end(); ++iter) {
70 (*iter)->Start(profile_->GetRequestContext()); 71 (*iter)->Start(
72 profile_->GetRequestContext(),
73 std::string(),
74 net::URLRequest::CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE,
75 net::LOAD_NORMAL);
71 } 76 }
72 } 77 }
73 78
74 // Method inherited from BitmapFetcher delegate. 79 // Method inherited from BitmapFetcher delegate.
75 void ImageHolder::OnFetchComplete(const GURL url, const SkBitmap* bitmap) { 80 void ImageHolder::OnFetchComplete(const GURL url, const SkBitmap* bitmap) {
76 // TODO(petewil): Should I retry if a fetch fails? 81 // TODO(petewil): Should I retry if a fetch fails?
77 // Match the bitmap to the URL to put it into the image with the correct scale 82 // Match the bitmap to the URL to put it into the image with the correct scale
78 // factor. 83 // factor.
79 if (url == low_dpi_url_) { 84 if (url == low_dpi_url_) {
80 low_dpi_fetched_ = true; 85 low_dpi_fetched_ = true;
81 if (bitmap != NULL) 86 if (bitmap != NULL)
82 image_.AddRepresentation(gfx::ImageSkiaRep(*bitmap, 1.0)); 87 image_.AddRepresentation(gfx::ImageSkiaRep(*bitmap, 1.0));
83 } else if (url == high_dpi_url_) { 88 } else if (url == high_dpi_url_) {
84 high_dpi_fetched_ = true; 89 high_dpi_fetched_ = true;
85 if (bitmap != NULL) 90 if (bitmap != NULL)
86 image_.AddRepresentation(gfx::ImageSkiaRep(*bitmap, 2.0)); 91 image_.AddRepresentation(gfx::ImageSkiaRep(*bitmap, 2.0));
87 } else { 92 } else {
88 DVLOG(2) << __FUNCTION__ << "Unmatched bitmap arrived " << url; 93 DVLOG(2) << __FUNCTION__ << "Unmatched bitmap arrived " << url;
89 } 94 }
90 95
91 // Notify callback of bitmap arrival. 96 // Notify callback of bitmap arrival.
92 delegate_->OnFetchComplete(); 97 delegate_->OnFetchComplete();
93 } 98 }
94 99
95 } // namespace chrome. 100 } // namespace chrome.
OLDNEW
« no previous file with comments | « chrome/browser/bitmap_fetcher_browsertest.cc ('k') | chrome/browser/notifications/sync_notifier/synced_notification.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698