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/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "chrome/browser/banners/app_banner_debug_log.h" | 10 #include "chrome/browser/banners/app_banner_debug_log.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 const char kPngExtension[] = ".png"; | 33 const char kPngExtension[] = ".png"; |
34 | 34 |
35 // The requirement for now is an image/png that is at least 144x144. | 35 // The requirement for now is an image/png that is at least 144x144. |
36 const int kIconMinimumSize = 144; | 36 const int kIconMinimumSize = 144; |
37 bool DoesManifestContainRequiredIcon(const content::Manifest& manifest) { | 37 bool DoesManifestContainRequiredIcon(const content::Manifest& manifest) { |
38 for (const auto& icon : manifest.icons) { | 38 for (const auto& icon : manifest.icons) { |
39 // The type field is optional. If it isn't present, fall back on checking | 39 // The type field is optional. If it isn't present, fall back on checking |
40 // the src extension, and allow the icon if the extension ends with png. | 40 // the src extension, and allow the icon if the extension ends with png. |
41 if (!base::EqualsASCII(icon.type.string(), "image/png") && | 41 if (!base::EqualsASCII(icon.type.string(), "image/png") && |
42 !(icon.type.is_null() && | 42 !(icon.type.is_null() && |
43 base::EndsWith(icon.src.ExtractFileName(), kPngExtension, false))) | 43 base::EndsWith(icon.src.ExtractFileName(), kPngExtension, |
| 44 base::CompareCase::INSENSITIVE_ASCII))) |
44 continue; | 45 continue; |
45 | 46 |
46 for (const auto& size : icon.sizes) { | 47 for (const auto& size : icon.sizes) { |
47 if (size.IsEmpty()) // "any" | 48 if (size.IsEmpty()) // "any" |
48 return true; | 49 return true; |
49 if (size.width() >= kIconMinimumSize && size.height() >= kIconMinimumSize) | 50 if (size.width() >= kIconMinimumSize && size.height() >= kIconMinimumSize) |
50 return true; | 51 return true; |
51 } | 52 } |
52 } | 53 } |
53 | 54 |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 return false; | 428 return false; |
428 } | 429 } |
429 if (!DoesManifestContainRequiredIcon(manifest)) { | 430 if (!DoesManifestContainRequiredIcon(manifest)) { |
430 OutputDeveloperNotShownMessage(web_contents, kManifestMissingSuitableIcon); | 431 OutputDeveloperNotShownMessage(web_contents, kManifestMissingSuitableIcon); |
431 return false; | 432 return false; |
432 } | 433 } |
433 return true; | 434 return true; |
434 } | 435 } |
435 | 436 |
436 } // namespace banners | 437 } // namespace banners |
OLD | NEW |