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

Side by Side Diff: chrome/browser/ui/app_list/arc/arc_app_icon.cc

Issue 2865813002: arc: Prevent overwriting of the Chrome Play Store icon. (Closed)
Patch Set: discard image(), protect LoadImageForScaleFactor Created 3 years, 7 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/ui/app_list/arc/arc_app_icon.h ('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/ui/app_list/arc/arc_app_icon.h" 5 #include "chrome/browser/ui/app_list/arc/arc_app_icon.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 CHECK(observer_ != nullptr); 251 CHECK(observer_ != nullptr);
252 source_ = new Source(weak_ptr_factory_.GetWeakPtr(), resource_size_in_dip); 252 source_ = new Source(weak_ptr_factory_.GetWeakPtr(), resource_size_in_dip);
253 gfx::Size resource_size(resource_size_in_dip, resource_size_in_dip); 253 gfx::Size resource_size(resource_size_in_dip, resource_size_in_dip);
254 image_skia_ = gfx::ImageSkia(source_, resource_size); 254 image_skia_ = gfx::ImageSkia(source_, resource_size);
255 } 255 }
256 256
257 ArcAppIcon::~ArcAppIcon() { 257 ArcAppIcon::~ArcAppIcon() {
258 } 258 }
259 259
260 void ArcAppIcon::LoadForScaleFactor(ui::ScaleFactor scale_factor) { 260 void ArcAppIcon::LoadForScaleFactor(ui::ScaleFactor scale_factor) {
261 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(context_); 261 // We provide Play Store icon from Chrome resources and it is not expected
262 // that we have external load request.
263 DCHECK_NE(app_id_, arc::kPlayStoreAppId);
264
265 const ArcAppListPrefs* const prefs = ArcAppListPrefs::Get(context_);
262 DCHECK(prefs); 266 DCHECK(prefs);
263 267
264 base::FilePath path = prefs->GetIconPath(app_id_, scale_factor); 268 const base::FilePath path = prefs->GetIconPath(app_id_, scale_factor);
265 if (path.empty()) 269 if (path.empty())
266 return; 270 return;
267 271
268 base::PostTaskWithTraitsAndReplyWithResult( 272 base::PostTaskWithTraitsAndReplyWithResult(
269 FROM_HERE, {base::MayBlock(), base::TaskPriority::BACKGROUND}, 273 FROM_HERE, {base::MayBlock(), base::TaskPriority::BACKGROUND},
270 base::Bind(&ArcAppIcon::ReadOnFileThread, scale_factor, path, 274 base::Bind(&ArcAppIcon::ReadOnFileThread, scale_factor, path,
271 prefs->MaybeGetIconPathForDefaultApp(app_id_, scale_factor)), 275 prefs->MaybeGetIconPathForDefaultApp(app_id_, scale_factor)),
272 base::Bind(&ArcAppIcon::OnIconRead, weak_ptr_factory_.GetWeakPtr())); 276 base::Bind(&ArcAppIcon::OnIconRead, weak_ptr_factory_.GetWeakPtr()));
273 } 277 }
274 278
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 CHECK(image && !image->isNull()); 359 CHECK(image && !image->isNull());
356 360
357 std::vector<gfx::ImageSkiaRep> reps = image->image_reps(); 361 std::vector<gfx::ImageSkiaRep> reps = image->image_reps();
358 for (const auto& image_rep : reps) { 362 for (const auto& image_rep : reps) {
359 if (ui::IsSupportedScale(image_rep.scale())) { 363 if (ui::IsSupportedScale(image_rep.scale())) {
360 image_skia_.RemoveRepresentation(image_rep.scale()); 364 image_skia_.RemoveRepresentation(image_rep.scale());
361 image_skia_.AddRepresentation(image_rep); 365 image_skia_.AddRepresentation(image_rep);
362 } 366 }
363 } 367 }
364 368
365 image_ = gfx::Image(image_skia_);
366
367 observer_->OnIconUpdated(this); 369 observer_->OnIconUpdated(this);
368 } 370 }
369 371
370 void ArcAppIcon::DiscardDecodeRequest(DecodeRequest* request) { 372 void ArcAppIcon::DiscardDecodeRequest(DecodeRequest* request) {
371 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 373 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
372 374
373 auto it = std::find_if(decode_requests_.begin(), decode_requests_.end(), 375 auto it = std::find_if(decode_requests_.begin(), decode_requests_.end(),
374 [request](const std::unique_ptr<DecodeRequest>& ptr) { 376 [request](const std::unique_ptr<DecodeRequest>& ptr) {
375 return ptr.get() == request; 377 return ptr.get() == request;
376 }); 378 });
377 CHECK(it != decode_requests_.end()); 379 CHECK(it != decode_requests_.end());
378 decode_requests_.erase(it); 380 decode_requests_.erase(it);
379 } 381 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/app_list/arc/arc_app_icon.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698