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

Side by Side Diff: chrome/browser/installable/installable_manager.cc

Issue 2773353002: Make minimum PWA icon size the same accross all device densities
Patch Set: Merge branch 'master' into min_size Created 3 years, 8 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/installable/installable_manager.h" 5 #include "chrome/browser/installable/installable_manager.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "chrome/browser/manifest/manifest_icon_downloader.h" 10 #include "chrome/browser/manifest/manifest_icon_downloader.h"
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 tasks_.push_back({params, callback}); 135 tasks_.push_back({params, callback});
136 if (is_active_) 136 if (is_active_)
137 return; 137 return;
138 138
139 is_active_ = true; 139 is_active_ = true;
140 StartNextTask(); 140 StartNextTask();
141 } 141 }
142 142
143 InstallableManager::IconParams InstallableManager::ParamsForPrimaryIcon( 143 InstallableManager::IconParams InstallableManager::ParamsForPrimaryIcon(
144 const InstallableParams& params) const { 144 const InstallableParams& params) const {
145 return std::make_tuple(params.ideal_primary_icon_size_in_px, 145 return std::make_pair(params.ideal_primary_icon_size_in_px, IconPurpose::ANY);
146 params.minimum_primary_icon_size_in_px,
147 IconPurpose::ANY);
148 } 146 }
149 147
150 InstallableManager::IconParams InstallableManager::ParamsForBadgeIcon( 148 InstallableManager::IconParams InstallableManager::ParamsForBadgeIcon(
151 const InstallableParams& params) const { 149 const InstallableParams& params) const {
152 return std::make_tuple(params.ideal_badge_icon_size_in_px, 150 return std::make_pair(params.ideal_badge_icon_size_in_px, IconPurpose::BADGE);
153 params.minimum_badge_icon_size_in_px,
154 IconPurpose::BADGE);
155 } 151 }
156 152
157 bool InstallableManager::IsIconFetched(const IconParams& params) const { 153 bool InstallableManager::IsIconFetched(const IconParams& params) const {
158 const auto it = icons_.find(params); 154 const auto it = icons_.find(params);
159 return it != icons_.end() && it->second.fetched; 155 return it != icons_.end() && it->second.fetched;
160 } 156 }
161 157
162 void InstallableManager::SetIconFetched(const IconParams& params) { 158 void InstallableManager::SetIconFetched(const IconParams& params) {
163 icons_[params].fetched = true; 159 icons_[params].fetched = true;
164 } 160 }
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 break; 427 break;
432 } 428 }
433 429
434 installable_->fetched = true; 430 installable_->fetched = true;
435 WorkOnTask(); 431 WorkOnTask();
436 } 432 }
437 433
438 void InstallableManager::CheckAndFetchBestIcon(const IconParams& params) { 434 void InstallableManager::CheckAndFetchBestIcon(const IconParams& params) {
439 DCHECK(!manifest().IsEmpty()); 435 DCHECK(!manifest().IsEmpty());
440 436
441 int ideal_icon_size_in_px = std::get<0>(params); 437 int ideal_icon_size_in_px = params.first;
442 int minimum_icon_size_in_px = std::get<1>(params); 438 IconPurpose icon_purpose = params.second;
443 IconPurpose icon_purpose = std::get<2>(params); 439
440 int minimum_icon_size_in_px = (icon_purpose == IconPurpose::BADGE)
Xi Han 2017/04/03 18:24:58 If the |icon_purpose| == IconPurpose::BADGE, I thi
pkotwicz 2017/04/05 04:29:07 kIconMinimumSizeInPx is 144px. Badges are smaller
Xi Han 2017/04/05 15:19:27 I see, thanks!
441 ? ideal_icon_size_in_px
442 : kIconMinimumSizeInPx;
444 443
445 IconProperty& icon = icons_[params]; 444 IconProperty& icon = icons_[params];
446 icon.fetched = true; 445 icon.fetched = true;
447 446
448 GURL icon_url = ManifestIconSelector::FindBestMatchingIcon( 447 GURL icon_url = ManifestIconSelector::FindBestMatchingIcon(
449 manifest().icons, ideal_icon_size_in_px, minimum_icon_size_in_px, 448 manifest().icons, ideal_icon_size_in_px, minimum_icon_size_in_px,
450 icon_purpose); 449 icon_purpose);
451 450
452 if (icon_url.is_empty()) { 451 if (icon_url.is_empty()) {
453 icon.error = NO_ACCEPTABLE_ICON; 452 icon.error = NO_ACCEPTABLE_ICON;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 return manifest_->url; 498 return manifest_->url;
500 } 499 }
501 500
502 const content::Manifest& InstallableManager::manifest() const { 501 const content::Manifest& InstallableManager::manifest() const {
503 return manifest_->manifest; 502 return manifest_->manifest;
504 } 503 }
505 504
506 bool InstallableManager::is_installable() const { 505 bool InstallableManager::is_installable() const {
507 return installable_->installable; 506 return installable_->installable;
508 } 507 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698