Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "chrome/browser/manifest/manifest_icon_downloader.h" | 9 #include "chrome/browser/manifest/manifest_icon_downloader.h" |
| 10 #include "chrome/browser/manifest/manifest_icon_selector.h" | 10 #include "chrome/browser/manifest/manifest_icon_selector.h" |
| 11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 12 #include "content/public/browser/browser_context.h" | 12 #include "content/public/browser/browser_context.h" |
| 13 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
| 14 #include "content/public/browser/navigation_handle.h" | 14 #include "content/public/browser/navigation_handle.h" |
| 15 #include "content/public/browser/service_worker_context.h" | 15 #include "content/public/browser/service_worker_context.h" |
| 16 #include "content/public/browser/storage_partition.h" | 16 #include "content/public/browser/storage_partition.h" |
| 17 #include "third_party/WebKit/public/platform/WebDisplayMode.h" | 17 #include "third_party/WebKit/public/platform/WebDisplayMode.h" |
| 18 | 18 |
| 19 namespace { | 19 namespace { |
| 20 | 20 |
| 21 const char kPngExtension[] = ".png"; | 21 const char kPngExtension[] = ".png"; |
| 22 | 22 |
| 23 // This constant is the icon size on Android (48dp) multiplied by the scale | 23 // This constant is the icon size on Android (48dp) multiplied by the scale |
| 24 // factor of a Nexus 5 device (3x). For mobile and desktop platforms, a 144px | 24 // factor of a Nexus 5 device (3x). For mobile and desktop platforms, a 144px |
| 25 // icon is an approximate, appropriate lower bound. | 25 // icon is an approximate, appropriate lower bound. It is currently documented |
| 26 // as the minimum requirement for triggering banners on several web | |
| 27 // documentation pages, e.g. | |
| 28 // https://developers.google.com/web/fundamentals/engage-and-retain/app-install- banners/, | |
|
dominickn
2016/10/27 00:26:36
The links here are unnecessary (and overflow the 8
F
2016/10/27 17:49:24
Done.
| |
| 29 // https://developers.google.com/web/updates/2015/03/increasing-engagement-with- app-install-banners-in-chrome-for-android, | |
| 30 // https://googlechrome.github.io/samples/app-install-banner/ | |
| 26 // TODO(dominickn): consolidate with minimum_icon_size_in_dp across platforms. | 31 // TODO(dominickn): consolidate with minimum_icon_size_in_dp across platforms. |
| 27 const int kIconMinimumSizeInPx = 144; | 32 const int kIconMinimumSizeInPx = 144; |
| 28 | 33 |
| 29 // Returns true if |manifest| specifies a PNG icon >= 144x144px (or size "any"). | 34 // Returns true if |manifest| specifies a PNG icon >= 144x144px (or size "any"). |
| 30 bool DoesManifestContainRequiredIcon(const content::Manifest& manifest) { | 35 bool DoesManifestContainRequiredIcon(const content::Manifest& manifest) { |
| 31 for (const auto& icon : manifest.icons) { | 36 for (const auto& icon : manifest.icons) { |
| 32 // The type field is optional. If it isn't present, fall back on checking | 37 // The type field is optional. If it isn't present, fall back on checking |
| 33 // the src extension, and allow the icon if the extension ends with png. | 38 // the src extension, and allow the icon if the extension ends with png. |
| 34 if (!base::EqualsASCII(icon.type, "image/png") && | 39 if (!base::EqualsASCII(icon.type, "image/png") && |
| 35 !(icon.type.empty() && base::EndsWith( | 40 !(icon.type.empty() && base::EndsWith( |
| (...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 435 return manifest_->url; | 440 return manifest_->url; |
| 436 } | 441 } |
| 437 | 442 |
| 438 const content::Manifest& InstallableManager::manifest() const { | 443 const content::Manifest& InstallableManager::manifest() const { |
| 439 return manifest_->manifest; | 444 return manifest_->manifest; |
| 440 } | 445 } |
| 441 | 446 |
| 442 bool InstallableManager::is_installable() const { | 447 bool InstallableManager::is_installable() const { |
| 443 return installable_->installable; | 448 return installable_->installable; |
| 444 } | 449 } |
| OLD | NEW |