OLD | NEW |
---|---|
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 #import "components/image_fetcher/ios/ios_image_data_fetcher_wrapper.h" | 5 #import "components/image_fetcher/ios/ios_image_data_fetcher_wrapper.h" |
6 | 6 |
7 #import "base/mac/bind_objc_block.h" | 7 #import "base/mac/bind_objc_block.h" |
8 #import "base/mac/scoped_nsobject.h" | 8 #import "base/mac/scoped_nsobject.h" |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "base/task_runner.h" | 10 #include "base/task_runner.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
79 : task_runner_(task_runner), | 79 : task_runner_(task_runner), |
80 image_data_fetcher_(url_request_context_getter) { | 80 image_data_fetcher_(url_request_context_getter) { |
81 DCHECK(task_runner_.get()); | 81 DCHECK(task_runner_.get()); |
82 } | 82 } |
83 | 83 |
84 IOSImageDataFetcherWrapper::~IOSImageDataFetcherWrapper() {} | 84 IOSImageDataFetcherWrapper::~IOSImageDataFetcherWrapper() {} |
85 | 85 |
86 void IOSImageDataFetcherWrapper::FetchImageDataWebpDecoded( | 86 void IOSImageDataFetcherWrapper::FetchImageDataWebpDecoded( |
87 const GURL& image_url, | 87 const GURL& image_url, |
88 IOSImageDataFetcherCallback callback) { | 88 IOSImageDataFetcherCallback callback) { |
89 IOSImageDataFetcherWrapper::FetchImageDataWebpDecoded( | |
90 image_url, callback, std::string(), | |
91 net::URLRequest::CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE); | |
Marc Treib
2017/02/03 14:10:30
...and a second place where it's baked in.
IMO thi
gambard
2017/02/03 14:56:47
I have changed the interface. Maybe it makes more
Marc Treib
2017/02/03 15:06:45
Yep, I think that's a bit better, thanks!
At some
gambard
2017/02/03 15:11:14
Actually no :)
There are two usages of image fetch
| |
92 } | |
93 void IOSImageDataFetcherWrapper::FetchImageDataWebpDecoded( | |
Marc Treib
2017/02/03 14:10:30
nit: empty line before
gambard
2017/02/03 14:56:47
Done.
| |
94 const GURL& image_url, | |
95 IOSImageDataFetcherCallback callback, | |
96 const std::string& referrer, | |
97 net::URLRequest::ReferrerPolicy referrer_policy) { | |
89 DCHECK(callback); | 98 DCHECK(callback); |
90 | 99 |
91 scoped_refptr<base::TaskRunner> task_runner = task_runner_; | 100 scoped_refptr<base::TaskRunner> task_runner = task_runner_; |
92 ImageDataFetcher::ImageDataFetcherCallback local_callback = | 101 ImageDataFetcher::ImageDataFetcherCallback local_callback = |
93 base::BindBlockArc(^(const std::string& image_data) { | 102 base::BindBlockArc(^(const std::string& image_data) { |
94 // Create a NSData from the returned data and notify the callback. | 103 // Create a NSData from the returned data and notify the callback. |
95 NSData* data = | 104 NSData* data = |
96 [NSData dataWithBytes:image_data.data() length:image_data.size()]; | 105 [NSData dataWithBytes:image_data.data() length:image_data.size()]; |
97 | 106 |
98 if (data.length < 12 || | 107 if (data.length < 12 || |
99 image_data.compare(0, 4, kWEBPFirstMagicPattern) != 0 || | 108 image_data.compare(0, 4, kWEBPFirstMagicPattern) != 0 || |
100 image_data.compare(8, 4, kWEBPSecondMagicPattern) != 0) { | 109 image_data.compare(8, 4, kWEBPSecondMagicPattern) != 0) { |
101 callback(data); | 110 callback(data); |
102 return; | 111 return; |
103 } | 112 } |
104 | 113 |
105 // The image is a webp image. | 114 // The image is a webp image. |
106 base::PostTaskAndReplyWithResult(task_runner.get(), FROM_HERE, | 115 base::PostTaskAndReplyWithResult(task_runner.get(), FROM_HERE, |
107 base::Bind(&DecodeWebpImage, data), | 116 base::Bind(&DecodeWebpImage, data), |
108 base::BindBlockArc(callback)); | 117 base::BindBlockArc(callback)); |
109 }); | 118 }); |
110 image_data_fetcher_.FetchImageData(image_url, local_callback); | 119 image_data_fetcher_.FetchImageData(image_url, local_callback, referrer, |
120 referrer_policy); | |
111 } | 121 } |
112 | 122 |
113 void IOSImageDataFetcherWrapper::SetDataUseServiceName( | 123 void IOSImageDataFetcherWrapper::SetDataUseServiceName( |
114 DataUseServiceName data_use_service_name) { | 124 DataUseServiceName data_use_service_name) { |
115 image_data_fetcher_.SetDataUseServiceName(data_use_service_name); | 125 image_data_fetcher_.SetDataUseServiceName(data_use_service_name); |
116 } | 126 } |
117 | 127 |
118 } // namespace image_fetcher | 128 } // namespace image_fetcher |
OLD | NEW |