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, | 43 base::EndsWith(icon.src.ExtractFileName(), kPngExtension, false))) |
44 base::CompareCase::INSENSITIVE_ASCII))) | |
45 continue; | 44 continue; |
46 | 45 |
47 for (const auto& size : icon.sizes) { | 46 for (const auto& size : icon.sizes) { |
48 if (size.IsEmpty()) // "any" | 47 if (size.IsEmpty()) // "any" |
49 return true; | 48 return true; |
50 if (size.width() >= kIconMinimumSize && size.height() >= kIconMinimumSize) | 49 if (size.width() >= kIconMinimumSize && size.height() >= kIconMinimumSize) |
51 return true; | 50 return true; |
52 } | 51 } |
53 } | 52 } |
54 | 53 |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 return false; | 427 return false; |
429 } | 428 } |
430 if (!DoesManifestContainRequiredIcon(manifest)) { | 429 if (!DoesManifestContainRequiredIcon(manifest)) { |
431 OutputDeveloperNotShownMessage(web_contents, kManifestMissingSuitableIcon); | 430 OutputDeveloperNotShownMessage(web_contents, kManifestMissingSuitableIcon); |
432 return false; | 431 return false; |
433 } | 432 } |
434 return true; | 433 return true; |
435 } | 434 } |
436 | 435 |
437 } // namespace banners | 436 } // namespace banners |
OLD | NEW |