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

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

Issue 2791923005: Fails InstallableManager if a selected badge icon cannot be fetched. (Closed)
Patch Set: Correct the error of making badge icon required 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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 170
171 if (params.check_installable && installable_->error != NO_ERROR_DETECTED) 171 if (params.check_installable && installable_->error != NO_ERROR_DETECTED)
172 return installable_->error; 172 return installable_->error;
173 173
174 if (params.fetch_valid_primary_icon) { 174 if (params.fetch_valid_primary_icon) {
175 IconProperty& icon = icons_[ParamsForPrimaryIcon(params)]; 175 IconProperty& icon = icons_[ParamsForPrimaryIcon(params)];
176 if (icon.error != NO_ERROR_DETECTED) 176 if (icon.error != NO_ERROR_DETECTED)
177 return icon.error; 177 return icon.error;
178 } 178 }
179 179
180 // Do not report badge icon's error because badge icon is optional. 180 if (params.fetch_valid_badge_icon) {
181 IconProperty& icon = icons_[ParamsForBadgeIcon(params)];
182 if (icon.error != NO_ERROR_DETECTED)
183 return icon.error;
dominickn 2017/04/05 02:57:24 Can you edit the following error messages in insta
F 2017/04/06 15:35:35 Done.
184 }
185
181 return NO_ERROR_DETECTED; 186 return NO_ERROR_DETECTED;
182 } 187 }
183 188
184 InstallableStatusCode InstallableManager::manifest_error() const { 189 InstallableStatusCode InstallableManager::manifest_error() const {
185 return manifest_->error; 190 return manifest_->error;
186 } 191 }
187 192
188 InstallableStatusCode InstallableManager::installable_error() const { 193 InstallableStatusCode InstallableManager::installable_error() const {
189 return installable_->error; 194 return installable_->error;
190 } 195 }
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 StartNextTask(); 303 StartNextTask();
299 return; 304 return;
300 } 305 }
301 306
302 if (!manifest_->fetched) { 307 if (!manifest_->fetched) {
303 FetchManifest(); 308 FetchManifest();
304 } else if (params.check_installable && !installable_->fetched) { 309 } else if (params.check_installable && !installable_->fetched) {
305 CheckInstallable(); 310 CheckInstallable();
306 } else if (params.fetch_valid_primary_icon && 311 } else if (params.fetch_valid_primary_icon &&
307 !IsIconFetched(ParamsForPrimaryIcon(params))) { 312 !IsIconFetched(ParamsForPrimaryIcon(params))) {
308 CheckAndFetchBestIcon(ParamsForPrimaryIcon(params)); 313 CheckAndFetchBestIcon(ParamsForPrimaryIcon(params), true);
309 } else if (params.fetch_valid_badge_icon && 314 } else if (params.fetch_valid_badge_icon &&
310 !IsIconFetched(ParamsForBadgeIcon(params))) { 315 !IsIconFetched(ParamsForBadgeIcon(params))) {
311 CheckAndFetchBestIcon(ParamsForBadgeIcon(params)); 316 CheckAndFetchBestIcon(ParamsForBadgeIcon(params), false);
312 } else { 317 } else {
313 NOTREACHED(); 318 NOTREACHED();
314 } 319 }
315 } 320 }
316 321
317 void InstallableManager::FetchManifest() { 322 void InstallableManager::FetchManifest() {
318 DCHECK(!manifest_->fetched); 323 DCHECK(!manifest_->fetched);
319 324
320 content::WebContents* web_contents = GetWebContents(); 325 content::WebContents* web_contents = GetWebContents();
321 DCHECK(web_contents); 326 DCHECK(web_contents);
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 case content::ServiceWorkerCapability::NO_SERVICE_WORKER: 433 case content::ServiceWorkerCapability::NO_SERVICE_WORKER:
429 installable_->installable = false; 434 installable_->installable = false;
430 installable_->error = NO_MATCHING_SERVICE_WORKER; 435 installable_->error = NO_MATCHING_SERVICE_WORKER;
431 break; 436 break;
432 } 437 }
433 438
434 installable_->fetched = true; 439 installable_->fetched = true;
435 WorkOnTask(); 440 WorkOnTask();
436 } 441 }
437 442
438 void InstallableManager::CheckAndFetchBestIcon(const IconParams& params) { 443 void InstallableManager::CheckAndFetchBestIcon(const IconParams& params,
444 bool is_required) {
439 DCHECK(!manifest().IsEmpty()); 445 DCHECK(!manifest().IsEmpty());
440 446
441 int ideal_icon_size_in_px = std::get<0>(params); 447 int ideal_icon_size_in_px = std::get<0>(params);
442 int minimum_icon_size_in_px = std::get<1>(params); 448 int minimum_icon_size_in_px = std::get<1>(params);
443 IconPurpose icon_purpose = std::get<2>(params); 449 IconPurpose icon_purpose = std::get<2>(params);
444 450
445 IconProperty& icon = icons_[params]; 451 IconProperty& icon = icons_[params];
446 icon.fetched = true; 452 icon.fetched = true;
447 453
448 GURL icon_url = ManifestIconSelector::FindBestMatchingIcon( 454 GURL icon_url = ManifestIconSelector::FindBestMatchingIcon(
449 manifest().icons, ideal_icon_size_in_px, minimum_icon_size_in_px, 455 manifest().icons, ideal_icon_size_in_px, minimum_icon_size_in_px,
450 icon_purpose); 456 icon_purpose);
451 457
452 if (icon_url.is_empty()) { 458 if (icon_url.is_empty()) {
453 icon.error = NO_ACCEPTABLE_ICON; 459 if (is_required)
dominickn 2017/04/05 02:57:24 I misinterpreted why you did it this way the first
F 2017/04/06 15:35:35 Done. This is a much better solution!
460 icon.error = NO_ACCEPTABLE_ICON;
454 } else { 461 } else {
455 bool can_download_icon = ManifestIconDownloader::Download( 462 bool can_download_icon = ManifestIconDownloader::Download(
456 GetWebContents(), icon_url, ideal_icon_size_in_px, 463 GetWebContents(), icon_url, ideal_icon_size_in_px,
457 minimum_icon_size_in_px, 464 minimum_icon_size_in_px,
458 base::Bind(&InstallableManager::OnIconFetched, 465 base::Bind(&InstallableManager::OnIconFetched,
459 weak_factory_.GetWeakPtr(), icon_url, params)); 466 weak_factory_.GetWeakPtr(), icon_url, params));
460 if (can_download_icon) 467 if (can_download_icon)
461 return; 468 return;
462 icon.error = CANNOT_DOWNLOAD_ICON; 469 icon.error = CANNOT_DOWNLOAD_ICON;
463 } 470 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 return manifest_->url; 506 return manifest_->url;
500 } 507 }
501 508
502 const content::Manifest& InstallableManager::manifest() const { 509 const content::Manifest& InstallableManager::manifest() const {
503 return manifest_->manifest; 510 return manifest_->manifest;
504 } 511 }
505 512
506 bool InstallableManager::is_installable() const { 513 bool InstallableManager::is_installable() const {
507 return installable_->installable; 514 return installable_->installable;
508 } 515 }
OLDNEW
« no previous file with comments | « chrome/browser/installable/installable_manager.h ('k') | chrome/browser/installable/installable_manager_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698