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

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

Issue 2671853002: Rename best icon to best primary icon in Web app related code. (Closed)
Patch Set: Removing java changes 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 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 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 233
234 // Save the splash screen URL for the later download. 234 // Save the splash screen URL for the later download.
235 splash_screen_url_ = ManifestIconSelector::FindBestMatchingIcon( 235 splash_screen_url_ = ManifestIconSelector::FindBestMatchingIcon(
236 data.manifest.icons, ideal_splash_image_size_in_px_, 236 data.manifest.icons, ideal_splash_image_size_in_px_,
237 minimum_splash_image_size_in_px_, 237 minimum_splash_image_size_in_px_,
238 content::Manifest::Icon::IconPurpose::ANY); 238 content::Manifest::Icon::IconPurpose::ANY);
239 239
240 weak_observer_->OnUserTitleAvailable(shortcut_info_.user_title); 240 weak_observer_->OnUserTitleAvailable(shortcut_info_.user_title);
241 241
242 if (data.primary_icon) { 242 if (data.primary_icon) {
243 shortcut_info_.best_icon_url = data.primary_icon_url; 243 shortcut_info_.best_primary_icon_url = data.primary_icon_url;
244 244
245 CreateLauncherIcon(*(data.primary_icon)); 245 CreateLauncherIcon(*(data.primary_icon));
246 return; 246 return;
247 } 247 }
248 248
249 FetchFavicon(); 249 FetchFavicon();
250 } 250 }
251 251
252 void AddToHomescreenDataFetcher::FetchFavicon() { 252 void AddToHomescreenDataFetcher::FetchFavicon() {
253 if (!web_contents() || !weak_observer_) 253 if (!web_contents() || !weak_observer_)
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 void AddToHomescreenDataFetcher::CreateLauncherIconFromFaviconInBackground( 289 void AddToHomescreenDataFetcher::CreateLauncherIconFromFaviconInBackground(
290 const favicon_base::FaviconRawBitmapResult& bitmap_result) { 290 const favicon_base::FaviconRawBitmapResult& bitmap_result) {
291 DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); 291 DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread());
292 292
293 SkBitmap raw_icon; 293 SkBitmap raw_icon;
294 if (bitmap_result.is_valid()) { 294 if (bitmap_result.is_valid()) {
295 gfx::PNGCodec::Decode(bitmap_result.bitmap_data->front(), 295 gfx::PNGCodec::Decode(bitmap_result.bitmap_data->front(),
296 bitmap_result.bitmap_data->size(), &raw_icon); 296 bitmap_result.bitmap_data->size(), &raw_icon);
297 } 297 }
298 298
299 shortcut_info_.best_icon_url = bitmap_result.icon_url; 299 shortcut_info_.best_primary_icon_url = bitmap_result.icon_url;
300 CreateLauncherIconInBackground(raw_icon); 300 CreateLauncherIconInBackground(raw_icon);
301 } 301 }
302 302
303 void AddToHomescreenDataFetcher::CreateLauncherIcon(const SkBitmap& raw_icon) { 303 void AddToHomescreenDataFetcher::CreateLauncherIcon(const SkBitmap& raw_icon) {
304 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 304 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
305 content::BrowserThread::GetBlockingPool() 305 content::BrowserThread::GetBlockingPool()->PostWorkerTaskWithShutdownBehavior(
306 ->PostWorkerTaskWithShutdownBehavior( 306 FROM_HERE,
307 FROM_HERE, 307 base::Bind(&AddToHomescreenDataFetcher::CreateLauncherIconInBackground,
308 base::Bind( 308 this, raw_icon),
309 &AddToHomescreenDataFetcher::CreateLauncherIconInBackground, 309 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN);
310 this, raw_icon),
311 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN);
312 } 310 }
313 311
314 void AddToHomescreenDataFetcher::CreateLauncherIconInBackground( 312 void AddToHomescreenDataFetcher::CreateLauncherIconInBackground(
315 const SkBitmap& raw_icon) { 313 const SkBitmap& raw_icon) {
316 DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); 314 DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread());
317 315
318 SkBitmap primary_icon; 316 SkBitmap primary_icon;
319 bool is_generated = false; 317 bool is_generated = false;
320 if (weak_observer_) { 318 if (weak_observer_) {
321 primary_icon = weak_observer_->FinalizeLauncherIconInBackground( 319 primary_icon = weak_observer_->FinalizeLauncherIconInBackground(
322 raw_icon, shortcut_info_.url, &is_generated); 320 raw_icon, shortcut_info_.url, &is_generated);
323 } 321 }
324 322
325 if (is_generated) 323 if (is_generated)
326 shortcut_info_.best_icon_url = GURL(); 324 shortcut_info_.best_primary_icon_url = GURL();
327 325
328 content::BrowserThread::PostTask( 326 content::BrowserThread::PostTask(
329 content::BrowserThread::UI, FROM_HERE, 327 content::BrowserThread::UI, FROM_HERE,
330 base::Bind(&AddToHomescreenDataFetcher::NotifyObserver, this, 328 base::Bind(&AddToHomescreenDataFetcher::NotifyObserver, this,
331 primary_icon)); 329 primary_icon));
332 } 330 }
333 331
334 void AddToHomescreenDataFetcher::NotifyObserver(const SkBitmap& primary_icon) { 332 void AddToHomescreenDataFetcher::NotifyObserver(const SkBitmap& primary_icon) {
335 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 333 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
336 if (!web_contents() || !weak_observer_ || is_icon_saved_) 334 if (!web_contents() || !weak_observer_ || is_icon_saved_)
337 return; 335 return;
338 336
339 is_icon_saved_ = true; 337 is_icon_saved_ = true;
340 primary_icon_ = primary_icon; 338 primary_icon_ = primary_icon;
341 is_ready_ = true; 339 is_ready_ = true;
342 weak_observer_->OnDataAvailable(shortcut_info_, primary_icon_, badge_icon_); 340 weak_observer_->OnDataAvailable(shortcut_info_, primary_icon_, badge_icon_);
343 } 341 }
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