Chromium Code Reviews| Index: chrome/browser/ui/app_list/arc/arc_app_icon.cc |
| diff --git a/chrome/browser/ui/app_list/arc/arc_app_icon.cc b/chrome/browser/ui/app_list/arc/arc_app_icon.cc |
| index f888755d4ab4f6cd8d233f51729d7ab10447a2b6..df5d812b2e6fdb5718e47572546f7c140103ebea 100644 |
| --- a/chrome/browser/ui/app_list/arc/arc_app_icon.cc |
| +++ b/chrome/browser/ui/app_list/arc/arc_app_icon.cc |
| @@ -172,6 +172,7 @@ class ArcAppIcon::DecodeRequest : public ImageDecoder::ImageRequest { |
| // ImageDecoder::ImageRequest |
| void OnImageDecoded(const SkBitmap& bitmap) override; |
| void OnDecodeImageFailed() override; |
| + |
| private: |
| base::WeakPtr<ArcAppIcon> host_; |
| int dimension_; |
| @@ -206,6 +207,8 @@ void ArcAppIcon::DecodeRequest::OnImageDecoded(const SkBitmap& bitmap) { |
| VLOG(2) << "Decoded ARC icon has unexpected dimension " |
| << bitmap.width() << "x" << bitmap.height() << ". Expected " |
| << expected_dim << "x" << "."; |
| + |
| + host_->MaybeRequestIcon(scale_factor_); |
| host_->DiscardDecodeRequest(this); |
| return; |
| } |
| @@ -214,7 +217,6 @@ void ArcAppIcon::DecodeRequest::OnImageDecoded(const SkBitmap& bitmap) { |
| image_skia.AddRepresentation(gfx::ImageSkiaRep( |
| bitmap, |
| ui::GetScaleForScaleFactor(scale_factor_))); |
| - |
| host_->Update(&image_skia); |
| host_->DiscardDecodeRequest(this); |
| } |
| @@ -225,6 +227,7 @@ void ArcAppIcon::DecodeRequest::OnDecodeImageFailed() { |
| if (!host_) |
| return; |
| + host_->MaybeRequestIcon(scale_factor_); |
| host_->DiscardDecodeRequest(this); |
| } |
| @@ -270,11 +273,15 @@ void ArcAppIcon::LoadForScaleFactor(ui::ScaleFactor scale_factor) { |
| base::Bind(&ArcAppIcon::OnIconRead, weak_ptr_factory_.GetWeakPtr())); |
| } |
| -void ArcAppIcon::RequestIcon(ui::ScaleFactor scale_factor) { |
| +void ArcAppIcon::MaybeRequestIcon(ui::ScaleFactor scale_factor) { |
| DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| ArcAppListPrefs* prefs = ArcAppListPrefs::Get(context_); |
| DCHECK(prefs); |
| + // Request for Icon has been recorded. Don't resend same request within same |
| + // user session. |
| + if (prefs->IsIconRequestRecorded(app_id_, scale_factor)) |
|
khmel
2017/03/15 01:16:55
Could you please move this logic into prefs. It wo
lgcheng
2017/03/15 19:59:31
Done.
|
| + return; |
| // ArcAppListPrefs notifies ArcAppModelBuilder via Observer when icon is ready |
| // and ArcAppModelBuilder refreshes the icon of the corresponding item by |
| // calling LoadScaleFactor. |
| @@ -317,8 +324,15 @@ void ArcAppIcon::OnIconRead( |
| std::unique_ptr<ArcAppIcon::ReadResult> read_result) { |
| DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| - if (read_result->request_to_install) |
| - RequestIcon(read_result->scale_factor); |
| + // When unsafe_icon_data is empty, there are four senarios. |
| + // 1. Default app icon path is non valid. In this case, request_to_install is |
| + // true. |
| + // 2. Fail to read default icon file. In this case request_to_install is true. |
| + // 3. Default icon file is empty. In this case request_to_install is true. |
| + // 4. Icon file for app_id_ is empty. This indicates a file corruption of some |
| + // sort of issue. We should try to request app icon. |
| + if (read_result->request_to_install || read_result->unsafe_icon_data.empty()) |
|
khmel
2017/03/15 01:16:55
Could you please move read_result->unsafe_icon_dat
lgcheng
2017/03/15 19:59:31
Done.
|
| + MaybeRequestIcon(read_result->scale_factor); |
| if (!read_result->unsafe_icon_data.empty()) { |
| decode_requests_.push_back(base::MakeUnique<DecodeRequest>( |