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

Unified Diff: chrome/browser/banners/app_banner_data_fetcher.cc

Issue 1092193004: Use related_applications manifest fields when showing native app banners (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/banners/app_banner_data_fetcher.cc
diff --git a/chrome/browser/banners/app_banner_data_fetcher.cc b/chrome/browser/banners/app_banner_data_fetcher.cc
index a32ba763ea3ed522bd0b827f218c4918e9d17be8..1897e8186c0b7e38c5e879d35af5272f00b255fe 100644
--- a/chrome/browser/banners/app_banner_data_fetcher.cc
+++ b/chrome/browser/banners/app_banner_data_fetcher.cc
@@ -6,6 +6,7 @@
#include "base/bind.h"
#include "base/strings/string_util.h"
+#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/banners/app_banner_metrics.h"
#include "chrome/browser/banners/app_banner_settings_helper.h"
#include "chrome/browser/bitmap_fetcher/bitmap_fetcher.h"
@@ -231,14 +232,23 @@ void AppBannerDataFetcher::RecordDidShowBanner(const std::string& event_name) {
void AppBannerDataFetcher::OnDidGetManifest(
const content::Manifest& manifest) {
content::WebContents* web_contents = GetWebContents();
- if (!is_active_ || !web_contents) {
+ if (!is_active_ || !web_contents || manifest.IsEmpty()) {
Cancel();
return;
}
- if (!IsManifestValid(manifest)) {
- if (!weak_delegate_.get()->OnInvalidManifest(this))
- Cancel();
+ if (manifest.prefer_related_applications &&
+ manifest.related_applications.size()) {
+ for (const auto& application : manifest.related_applications) {
+ std::string platform = base::UTF16ToUTF8(application.platform.string());
+ std::string id = base::UTF16ToUTF8(application.id.string());
+ if (weak_delegate_->HandleNonWebApp(platform, application.url, id))
+ return;
+ }
+ }
+
+ if (!IsManifestValidForWebApp(manifest)) {
+ Cancel();
return;
}
@@ -336,7 +346,7 @@ bool AppBannerDataFetcher::CheckIfShouldShowBanner() {
}
// static
-bool AppBannerDataFetcher::IsManifestValid(
+bool AppBannerDataFetcher::IsManifestValidForWebApp(
const content::Manifest& manifest) {
if (manifest.IsEmpty())
return false;
« no previous file with comments | « chrome/browser/banners/app_banner_data_fetcher.h ('k') | chrome/browser/banners/app_banner_data_fetcher_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698