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

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

Issue 2864243006: [Merge M59] arc: Prevent overwriting of the Chrome Play Store icon. (Closed)
Patch Set: 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::TaskTraits().MayBlock().WithPriority( 273 FROM_HERE, base::TaskTraits().MayBlock().WithPriority(
270 base::TaskPriority::BACKGROUND), 274 base::TaskPriority::BACKGROUND),
271 base::Bind(&ArcAppIcon::ReadOnFileThread, scale_factor, path, 275 base::Bind(&ArcAppIcon::ReadOnFileThread, scale_factor, path,
272 prefs->MaybeGetIconPathForDefaultApp(app_id_, scale_factor)), 276 prefs->MaybeGetIconPathForDefaultApp(app_id_, scale_factor)),
273 base::Bind(&ArcAppIcon::OnIconRead, weak_ptr_factory_.GetWeakPtr())); 277 base::Bind(&ArcAppIcon::OnIconRead, weak_ptr_factory_.GetWeakPtr()));
274 } 278 }
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 CHECK(image && !image->isNull()); 360 CHECK(image && !image->isNull());
357 361
358 std::vector<gfx::ImageSkiaRep> reps = image->image_reps(); 362 std::vector<gfx::ImageSkiaRep> reps = image->image_reps();
359 for (const auto& image_rep : reps) { 363 for (const auto& image_rep : reps) {
360 if (ui::IsSupportedScale(image_rep.scale())) { 364 if (ui::IsSupportedScale(image_rep.scale())) {
361 image_skia_.RemoveRepresentation(image_rep.scale()); 365 image_skia_.RemoveRepresentation(image_rep.scale());
362 image_skia_.AddRepresentation(image_rep); 366 image_skia_.AddRepresentation(image_rep);
363 } 367 }
364 } 368 }
365 369
366 image_ = gfx::Image(image_skia_);
367
368 observer_->OnIconUpdated(this); 370 observer_->OnIconUpdated(this);
369 } 371 }
370 372
371 void ArcAppIcon::DiscardDecodeRequest(DecodeRequest* request) { 373 void ArcAppIcon::DiscardDecodeRequest(DecodeRequest* request) {
372 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 374 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
373 375
374 auto it = std::find_if(decode_requests_.begin(), decode_requests_.end(), 376 auto it = std::find_if(decode_requests_.begin(), decode_requests_.end(),
375 [request](const std::unique_ptr<DecodeRequest>& ptr) { 377 [request](const std::unique_ptr<DecodeRequest>& ptr) {
376 return ptr.get() == request; 378 return ptr.get() == request;
377 }); 379 });
378 CHECK(it != decode_requests_.end()); 380 CHECK(it != decode_requests_.end());
379 decode_requests_.erase(it); 381 decode_requests_.erase(it);
380 } 382 }
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