OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #include "chrome/browser/android/webapps/add_to_homescreen_data_fetcher.h" | 5 #include "chrome/browser/android/webapps/add_to_homescreen_data_fetcher.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/strings/string16.h" | 9 #include "base/strings/string16.h" |
10 #include "base/task/cancelable_task_tracker.h" | 10 #include "base/task/cancelable_task_tracker.h" |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 if (!web_contents() || !weak_observer_) return; | 228 if (!web_contents() || !weak_observer_) return; |
229 | 229 |
230 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 230 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
231 SkBitmap icon_bitmap; | 231 SkBitmap icon_bitmap; |
232 if (bitmap_result.is_valid()) { | 232 if (bitmap_result.is_valid()) { |
233 gfx::PNGCodec::Decode(bitmap_result.bitmap_data->front(), | 233 gfx::PNGCodec::Decode(bitmap_result.bitmap_data->front(), |
234 bitmap_result.bitmap_data->size(), | 234 bitmap_result.bitmap_data->size(), |
235 &icon_bitmap); | 235 &icon_bitmap); |
236 } | 236 } |
237 | 237 |
| 238 bool is_generated = false; |
238 if (weak_observer_) { | 239 if (weak_observer_) { |
239 icon_bitmap = weak_observer_->FinalizeLauncherIcon(icon_bitmap, | 240 icon_bitmap = weak_observer_->FinalizeLauncherIcon(icon_bitmap, |
240 shortcut_info_.url); | 241 shortcut_info_.url, |
| 242 &is_generated); |
241 } | 243 } |
242 | 244 |
243 content::BrowserThread::PostTask( | 245 content::BrowserThread::PostTask( |
244 content::BrowserThread::UI, | 246 content::BrowserThread::UI, |
245 FROM_HERE, | 247 FROM_HERE, |
246 base::Bind(&AddToHomescreenDataFetcher::NotifyObserver, | 248 base::Bind(&AddToHomescreenDataFetcher::NotifyObserver, |
247 this, | 249 this, |
248 icon_bitmap)); | 250 icon_bitmap, |
| 251 is_generated)); |
249 } | 252 } |
250 | 253 |
251 void AddToHomescreenDataFetcher::OnManifestIconFetched(const SkBitmap& icon) { | 254 void AddToHomescreenDataFetcher::OnManifestIconFetched(const SkBitmap& icon) { |
252 if (icon.drawsNothing()) { | 255 if (icon.drawsNothing()) { |
253 FetchFavicon(); | 256 FetchFavicon(); |
254 return; | 257 return; |
255 } | 258 } |
256 NotifyObserver(icon); | 259 NotifyObserver(icon, false); |
257 } | 260 } |
258 | 261 |
259 void AddToHomescreenDataFetcher::NotifyObserver(const SkBitmap& bitmap) { | 262 void AddToHomescreenDataFetcher::NotifyObserver(const SkBitmap& bitmap, |
| 263 bool is_generated) { |
260 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 264 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
261 if (!web_contents() || !weak_observer_ || is_icon_saved_) | 265 if (!web_contents() || !weak_observer_ || is_icon_saved_) |
262 return; | 266 return; |
263 | 267 |
264 is_icon_saved_ = true; | 268 is_icon_saved_ = true; |
265 shortcut_icon_ = bitmap; | 269 shortcut_icon_ = bitmap; |
| 270 shortcut_info_.is_icon_generated = is_generated; |
266 is_ready_ = true; | 271 is_ready_ = true; |
267 weak_observer_->OnDataAvailable(shortcut_info_, shortcut_icon_); | 272 weak_observer_->OnDataAvailable(shortcut_info_, shortcut_icon_); |
268 } | 273 } |
OLD | NEW |