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

Unified Diff: webkit/glue/multi_resolution_image_resource_fetcher.cc

Issue 10828127: Use hi-resolution favicon variants if available. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: daringfireball hackfix Created 8 years, 5 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: webkit/glue/multi_resolution_image_resource_fetcher.cc
diff --git a/webkit/glue/image_resource_fetcher.cc b/webkit/glue/multi_resolution_image_resource_fetcher.cc
similarity index 59%
copy from webkit/glue/image_resource_fetcher.cc
copy to webkit/glue/multi_resolution_image_resource_fetcher.cc
index 54d141350ac9eadf2f3eccc9239e04c29d3080cd..bbb8a77d41ec6644bf91372dc6f1a6a41849b686 100644
--- a/webkit/glue/image_resource_fetcher.cc
+++ b/webkit/glue/multi_resolution_image_resource_fetcher.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "webkit/glue/image_resource_fetcher.h"
+#include "webkit/glue/multi_resolution_image_resource_fetcher.h"
#include "base/bind.h"
#include "base/bind_helpers.h"
@@ -17,46 +17,47 @@ using WebKit::WebURLResponse;
namespace webkit_glue {
-ImageResourceFetcher::ImageResourceFetcher(
+MultiResolutionImageResourceFetcher::MultiResolutionImageResourceFetcher(
const GURL& image_url,
WebFrame* frame,
int id,
- int image_size,
+ const std::vector<int>& image_sizes,
WebURLRequest::TargetType target_type,
const Callback& callback)
: callback_(callback),
id_(id),
image_url_(image_url),
- image_size_(image_size) {
+ image_sizes_(image_sizes) {
fetcher_.reset(new ResourceFetcher(
image_url, frame, target_type,
- base::Bind(&ImageResourceFetcher::OnURLFetchComplete,
+ base::Bind(&MultiResolutionImageResourceFetcher::OnURLFetchComplete,
base::Unretained(this))));
}
-ImageResourceFetcher::~ImageResourceFetcher() {
+MultiResolutionImageResourceFetcher::~MultiResolutionImageResourceFetcher() {
if (!fetcher_->completed())
fetcher_->Cancel();
}
-void ImageResourceFetcher::OnURLFetchComplete(
+void MultiResolutionImageResourceFetcher::OnURLFetchComplete(
const WebURLResponse& response,
const std::string& data) {
- SkBitmap bitmap;
+ std::vector<SkBitmap> bitmaps;
if (!response.isNull() && response.httpStatusCode() == 200) {
+fprintf(stderr, " data %x%x%x%x\n", data.data()[0], data.data()[1], data.data()[2], data.data()[3]);
// Request succeeded, try to convert it to an image.
- ImageDecoder decoder(gfx::Size(image_size_, image_size_));
- bitmap = decoder.Decode(
- reinterpret_cast<const unsigned char*>(data.data()), data.size());
+ std::vector<gfx::Size> sizes;
+ for (size_t i = 0; i < image_sizes_.size(); ++i)
+ sizes.push_back(gfx::Size(image_sizes_[i], image_sizes_[i]));
+ bitmaps = ImageDecoder::DecodeAll(reinterpret_cast<const unsigned char*>(data.data()), data.size(), sizes);
} // else case:
// If we get here, it means no image from server or couldn't decode the
- // response as an image. The delegate will see a null image, indicating
- // that an error occurred.
+ // response as an image. The delegate will see an empty vector.
// Take a reference to the callback as running the callback may lead to our
// destruction.
Callback callback = callback_;
- callback.Run(this, bitmap);
+ callback.Run(this, bitmaps);
}
} // namespace webkit_glue

Powered by Google App Engine
This is Rietveld 408576698