| OLD | NEW |
| 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/banners/app_banner_data_fetcher.h" | 5 #include "chrome/browser/banners/app_banner_data_fetcher.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/strings/string_number_conversions.h" |
| 9 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 11 #include "chrome/browser/banners/app_banner_debug_log.h" | 12 #include "chrome/browser/banners/app_banner_debug_log.h" |
| 12 #include "chrome/browser/banners/app_banner_metrics.h" | 13 #include "chrome/browser/banners/app_banner_metrics.h" |
| 13 #include "chrome/browser/banners/app_banner_settings_helper.h" | 14 #include "chrome/browser/banners/app_banner_settings_helper.h" |
| 14 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
| 15 #include "chrome/browser/manifest/manifest_icon_downloader.h" | 16 #include "chrome/browser/manifest/manifest_icon_downloader.h" |
| 16 #include "chrome/browser/manifest/manifest_icon_selector.h" | 17 #include "chrome/browser/manifest/manifest_icon_selector.h" |
| 17 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
| 18 #include "chrome/common/chrome_switches.h" | 19 #include "chrome/common/chrome_switches.h" |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 } | 343 } |
| 343 | 344 |
| 344 OnHasServiceWorker(web_contents); | 345 OnHasServiceWorker(web_contents); |
| 345 } | 346 } |
| 346 | 347 |
| 347 void AppBannerDataFetcher::OnHasServiceWorker( | 348 void AppBannerDataFetcher::OnHasServiceWorker( |
| 348 content::WebContents* web_contents) { | 349 content::WebContents* web_contents) { |
| 349 GURL icon_url = ManifestIconSelector::FindBestMatchingIcon( | 350 GURL icon_url = ManifestIconSelector::FindBestMatchingIcon( |
| 350 web_app_data_.icons, ideal_icon_size_in_dp_, minimum_icon_size_in_dp_); | 351 web_app_data_.icons, ideal_icon_size_in_dp_, minimum_icon_size_in_dp_); |
| 351 | 352 |
| 352 if (!FetchAppIcon(web_contents, icon_url)) { | 353 if (icon_url.is_empty()) { |
| 353 OutputDeveloperNotShownMessage(web_contents, kCannotDetermineBestIcon, | 354 OutputDeveloperNotShownMessage( |
| 355 web_contents, |
| 356 base::IntToString(ManifestIconSelector::ConvertIconSizeFromDpToPx( |
| 357 minimum_icon_size_in_dp_)) + |
| 358 kNoIconMatchingRequirements, |
| 359 is_debug_mode_); |
| 360 Cancel(); |
| 361 } else if (!FetchAppIcon(web_contents, icon_url)) { |
| 362 OutputDeveloperNotShownMessage(web_contents, kCannotDownloadIcon, |
| 354 is_debug_mode_); | 363 is_debug_mode_); |
| 355 Cancel(); | 364 Cancel(); |
| 356 } | 365 } |
| 357 } | 366 } |
| 358 | 367 |
| 359 bool AppBannerDataFetcher::FetchAppIcon(content::WebContents* web_contents, | 368 bool AppBannerDataFetcher::FetchAppIcon(content::WebContents* web_contents, |
| 360 const GURL& icon_url) { | 369 const GURL& icon_url) { |
| 361 return ManifestIconDownloader::Download( | 370 return ManifestIconDownloader::Download( |
| 362 web_contents, | 371 web_contents, |
| 363 icon_url, | 372 icon_url, |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 } | 465 } |
| 457 if (!DoesManifestContainRequiredIcon(manifest)) { | 466 if (!DoesManifestContainRequiredIcon(manifest)) { |
| 458 OutputDeveloperNotShownMessage(web_contents, kManifestMissingSuitableIcon, | 467 OutputDeveloperNotShownMessage(web_contents, kManifestMissingSuitableIcon, |
| 459 is_debug_mode); | 468 is_debug_mode); |
| 460 return false; | 469 return false; |
| 461 } | 470 } |
| 462 return true; | 471 return true; |
| 463 } | 472 } |
| 464 | 473 |
| 465 } // namespace banners | 474 } // namespace banners |
| OLD | NEW |