| OLD | NEW |
| 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/notifications/sync_notifier/image_holder.h" | 8 #include "chrome/browser/notifications/sync_notifier/image_holder.h" |
| 9 | 9 |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 if (url.is_valid()) { | 60 if (url.is_valid()) { |
| 61 fetchers_.push_back(new chrome::BitmapFetcher(url, this)); | 61 fetchers_.push_back(new chrome::BitmapFetcher(url, this)); |
| 62 DVLOG(2) << __FUNCTION__ << "Pushing bitmap " << url; | 62 DVLOG(2) << __FUNCTION__ << "Pushing bitmap " << url; |
| 63 } | 63 } |
| 64 } | 64 } |
| 65 | 65 |
| 66 void ImageHolder::StartFetch() { | 66 void ImageHolder::StartFetch() { |
| 67 // Now that we have queued them all, start the fetching. | 67 // Now that we have queued them all, start the fetching. |
| 68 ScopedVector<chrome::BitmapFetcher>::iterator iter; | 68 ScopedVector<chrome::BitmapFetcher>::iterator iter; |
| 69 for (iter = fetchers_.begin(); iter != fetchers_.end(); ++iter) { | 69 for (iter = fetchers_.begin(); iter != fetchers_.end(); ++iter) { |
| 70 (*iter)->Start(profile_->GetRequestContext()); | 70 (*iter)->Start( |
| 71 profile_->GetRequestContext(), |
| 72 "", |
| 73 net::URLRequest::CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE, |
| 74 net::LOAD_NORMAL); |
| 71 } | 75 } |
| 72 } | 76 } |
| 73 | 77 |
| 74 // Method inherited from BitmapFetcher delegate. | 78 // Method inherited from BitmapFetcher delegate. |
| 75 void ImageHolder::OnFetchComplete(const GURL url, const SkBitmap* bitmap) { | 79 void ImageHolder::OnFetchComplete(const GURL url, const SkBitmap* bitmap) { |
| 76 // TODO(petewil): Should I retry if a fetch fails? | 80 // 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 | 81 // Match the bitmap to the URL to put it into the image with the correct scale |
| 78 // factor. | 82 // factor. |
| 79 if (url == low_dpi_url_) { | 83 if (url == low_dpi_url_) { |
| 80 low_dpi_fetched_ = true; | 84 low_dpi_fetched_ = true; |
| 81 if (bitmap != NULL) | 85 if (bitmap != NULL) |
| 82 image_.AddRepresentation(gfx::ImageSkiaRep(*bitmap, 1.0)); | 86 image_.AddRepresentation(gfx::ImageSkiaRep(*bitmap, 1.0)); |
| 83 } else if (url == high_dpi_url_) { | 87 } else if (url == high_dpi_url_) { |
| 84 high_dpi_fetched_ = true; | 88 high_dpi_fetched_ = true; |
| 85 if (bitmap != NULL) | 89 if (bitmap != NULL) |
| 86 image_.AddRepresentation(gfx::ImageSkiaRep(*bitmap, 2.0)); | 90 image_.AddRepresentation(gfx::ImageSkiaRep(*bitmap, 2.0)); |
| 87 } else { | 91 } else { |
| 88 DVLOG(2) << __FUNCTION__ << "Unmatched bitmap arrived " << url; | 92 DVLOG(2) << __FUNCTION__ << "Unmatched bitmap arrived " << url; |
| 89 } | 93 } |
| 90 | 94 |
| 91 // Notify callback of bitmap arrival. | 95 // Notify callback of bitmap arrival. |
| 92 delegate_->OnFetchComplete(); | 96 delegate_->OnFetchComplete(); |
| 93 } | 97 } |
| 94 | 98 |
| 95 } // namespace notifier. | 99 } // namespace notifier. |
| OLD | NEW |