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

Unified Diff: components/image_fetcher/image_data_fetcher.cc

Issue 2687873002: Use mime type for image extension (Closed)
Patch Set: Created 3 years, 10 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: components/image_fetcher/image_data_fetcher.cc
diff --git a/components/image_fetcher/image_data_fetcher.cc b/components/image_fetcher/image_data_fetcher.cc
index e82c36751dfec9d43909a5a98fca1e5af81d25f6..e3818f14bf4fdafa3c607380f8fc344bbf60333b 100644
--- a/components/image_fetcher/image_data_fetcher.cc
+++ b/components/image_fetcher/image_data_fetcher.cc
@@ -5,6 +5,7 @@
#include "components/image_fetcher/image_data_fetcher.h"
#include "net/base/load_flags.h"
+#include "net/http/http_response_headers.h"
#include "net/url_request/url_fetcher.h"
#include "net/url_request/url_request.h"
#include "net/url_request/url_request_context_getter.h"
@@ -77,11 +78,15 @@ void ImageDataFetcher::OnURLFetchComplete(const net::URLFetcher* source) {
auto request_iter = pending_requests_.find(source);
DCHECK(request_iter != pending_requests_.end());
+ std::string mime_type;
+ if (source->GetResponseHeaders())
Marc Treib 2017/02/09 12:34:45 nit: braces please
gambard 2017/02/09 13:44:11 Done.
+ source->GetResponseHeaders()->GetMimeType(&mime_type);
+
std::string image_data;
if (source->GetStatus().status() == net::URLRequestStatus::SUCCESS) {
source->GetResponseAsString(&image_data);
}
- request_iter->second->callback.Run(image_data);
+ request_iter->second->callback.Run(image_data, mime_type);
// Remove the finished request.
pending_requests_.erase(request_iter);

Powered by Google App Engine
This is Rietveld 408576698