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

Side by Side Diff: chrome/browser/android/webapps/add_to_homescreen_data_fetcher.cc

Issue 2453423002: Send all of the icon URLs listed in Web Manifest to WebAPK Server. (Closed)
Patch Set: Nits. Created 4 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/android/webapk/webapk_update_manager.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 } 211 }
212 212
213 // Save the splash screen URL for the later download. 213 // Save the splash screen URL for the later download.
214 splash_screen_url_ = ManifestIconSelector::FindBestMatchingIcon( 214 splash_screen_url_ = ManifestIconSelector::FindBestMatchingIcon(
215 data.manifest.icons, ideal_splash_image_size_in_dp_, 215 data.manifest.icons, ideal_splash_image_size_in_dp_,
216 minimum_splash_image_size_in_dp_); 216 minimum_splash_image_size_in_dp_);
217 217
218 weak_observer_->OnUserTitleAvailable(shortcut_info_.user_title); 218 weak_observer_->OnUserTitleAvailable(shortcut_info_.user_title);
219 219
220 if (data.icon) { 220 if (data.icon) {
221 shortcut_info_.icon_url = data.icon_url; 221 shortcut_info_.best_icon_url = data.icon_url;
222 222
223 CreateLauncherIcon(*(data.icon)); 223 CreateLauncherIcon(*(data.icon));
224 return; 224 return;
225 } 225 }
226 226
227 FetchFavicon(); 227 FetchFavicon();
228 } 228 }
229 229
230 void AddToHomescreenDataFetcher::FetchFavicon() { 230 void AddToHomescreenDataFetcher::FetchFavicon() {
231 if (!web_contents() || !weak_observer_) 231 if (!web_contents() || !weak_observer_)
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 void AddToHomescreenDataFetcher::CreateLauncherIconFromFaviconInBackground( 270 void AddToHomescreenDataFetcher::CreateLauncherIconFromFaviconInBackground(
271 const favicon_base::FaviconRawBitmapResult& bitmap_result) { 271 const favicon_base::FaviconRawBitmapResult& bitmap_result) {
272 DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); 272 DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread());
273 273
274 SkBitmap raw_icon; 274 SkBitmap raw_icon;
275 if (bitmap_result.is_valid()) { 275 if (bitmap_result.is_valid()) {
276 gfx::PNGCodec::Decode(bitmap_result.bitmap_data->front(), 276 gfx::PNGCodec::Decode(bitmap_result.bitmap_data->front(),
277 bitmap_result.bitmap_data->size(), &raw_icon); 277 bitmap_result.bitmap_data->size(), &raw_icon);
278 } 278 }
279 279
280 shortcut_info_.icon_url = bitmap_result.icon_url; 280 shortcut_info_.best_icon_url = bitmap_result.icon_url;
281 CreateLauncherIconInBackground(raw_icon); 281 CreateLauncherIconInBackground(raw_icon);
282 } 282 }
283 283
284 void AddToHomescreenDataFetcher::CreateLauncherIcon(const SkBitmap& raw_icon) { 284 void AddToHomescreenDataFetcher::CreateLauncherIcon(const SkBitmap& raw_icon) {
285 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 285 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
286 content::BrowserThread::GetBlockingPool() 286 content::BrowserThread::GetBlockingPool()
287 ->PostWorkerTaskWithShutdownBehavior( 287 ->PostWorkerTaskWithShutdownBehavior(
288 FROM_HERE, 288 FROM_HERE,
289 base::Bind( 289 base::Bind(
290 &AddToHomescreenDataFetcher::CreateLauncherIconInBackground, 290 &AddToHomescreenDataFetcher::CreateLauncherIconInBackground,
291 this, raw_icon), 291 this, raw_icon),
292 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN); 292 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN);
293 } 293 }
294 294
295 void AddToHomescreenDataFetcher::CreateLauncherIconInBackground( 295 void AddToHomescreenDataFetcher::CreateLauncherIconInBackground(
296 const SkBitmap& raw_icon) { 296 const SkBitmap& raw_icon) {
297 DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); 297 DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread());
298 298
299 SkBitmap icon; 299 SkBitmap icon;
300 bool is_generated = false; 300 bool is_generated = false;
301 if (weak_observer_) { 301 if (weak_observer_) {
302 icon = weak_observer_->FinalizeLauncherIconInBackground( 302 icon = weak_observer_->FinalizeLauncherIconInBackground(
303 raw_icon, shortcut_info_.url, &is_generated); 303 raw_icon, shortcut_info_.url, &is_generated);
304 } 304 }
305 305
306 if (is_generated) 306 if (is_generated)
307 shortcut_info_.icon_url = GURL(); 307 shortcut_info_.best_icon_url = GURL();
308 308
309 content::BrowserThread::PostTask( 309 content::BrowserThread::PostTask(
310 content::BrowserThread::UI, FROM_HERE, 310 content::BrowserThread::UI, FROM_HERE,
311 base::Bind(&AddToHomescreenDataFetcher::NotifyObserver, this, icon)); 311 base::Bind(&AddToHomescreenDataFetcher::NotifyObserver, this, icon));
312 } 312 }
313 313
314 void AddToHomescreenDataFetcher::NotifyObserver(const SkBitmap& icon) { 314 void AddToHomescreenDataFetcher::NotifyObserver(const SkBitmap& icon) {
315 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 315 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
316 if (!web_contents() || !weak_observer_ || is_icon_saved_) 316 if (!web_contents() || !weak_observer_ || is_icon_saved_)
317 return; 317 return;
318 318
319 is_icon_saved_ = true; 319 is_icon_saved_ = true;
320 shortcut_icon_ = icon; 320 shortcut_icon_ = icon;
321 is_ready_ = true; 321 is_ready_ = true;
322 weak_observer_->OnDataAvailable(shortcut_info_, shortcut_icon_); 322 weak_observer_->OnDataAvailable(shortcut_info_, shortcut_icon_);
323 } 323 }
OLDNEW
« no previous file with comments | « chrome/browser/android/webapk/webapk_update_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698