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

Unified Diff: chrome/browser/android/webapk/webapk_installer.cc

Issue 2453423002: Send all of the icon URLs listed in Web Manifest to WebAPK Server. (Closed)
Patch Set: Remove best_icon_url and best_icon_hash from metadata, but add all icon urls and icon hashs in. Created 4 years, 1 month 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/android/webapk/webapk_installer.cc
diff --git a/chrome/browser/android/webapk/webapk_installer.cc b/chrome/browser/android/webapk/webapk_installer.cc
index 175969f0a1107d157216b653ba12912cd702968c..d85762123170eceafac7d2ba662857ae64b03672 100644
--- a/chrome/browser/android/webapk/webapk_installer.cc
+++ b/chrome/browser/android/webapk/webapk_installer.cc
@@ -100,6 +100,9 @@ std::unique_ptr<webapk::WebApk> BuildWebApkProtoInBackground(
base::android::BuildInfo::GetInstance()->package_name());
webapk->set_requester_application_version(version_info::GetVersionNumber());
+ if (shortcut_icon_murmur2_hash.empty())
pkotwicz 2016/11/11 21:04:19 An empty |shortcut_icon_murmur2_hash| shouldn't ha
Xi Han 2016/11/14 19:36:10 Yes, I will wait for Glenn to add this new attribu
+ return webapk;
+
webapk::WebAppManifest* web_app_manifest = webapk->mutable_manifest();
web_app_manifest->set_name(base::UTF16ToUTF8(shortcut_info.name));
web_app_manifest->set_short_name(
@@ -116,12 +119,19 @@ std::unique_ptr<webapk::WebApk> BuildWebApkProtoInBackground(
std::string* scope = web_app_manifest->add_scopes();
scope->assign(GetScope(shortcut_info).spec());
pkotwicz 2016/11/11 21:04:19 Nit: Add a new line for clarity
Xi Han 2016/11/14 19:36:10 Done.
- webapk::Image* image = web_app_manifest->add_icons();
- image->set_src(shortcut_info.icon_url.spec());
- image->set_hash(shortcut_icon_murmur2_hash);
+ webapk::Image* best_image = web_app_manifest->add_icons();
+ best_image->set_src(shortcut_info.best_icon_url.spec());
+ best_image->set_hash(shortcut_icon_murmur2_hash);
std::vector<unsigned char> png_bytes;
gfx::PNGCodec::EncodeBGRASkBitmap(shortcut_icon, false, &png_bytes);
- image->set_image_data(&png_bytes.front(), png_bytes.size());
+ best_image->set_image_data(&png_bytes.front(), png_bytes.size());
+
+ for (const GURL& icon_url : shortcut_info.icon_urls) {
+ if (icon_url == shortcut_info.best_icon_url)
+ continue;
+ webapk::Image* image = web_app_manifest->add_icons();
+ image->set_src(icon_url.spec());
+ }
return webapk;
}
@@ -311,7 +321,7 @@ void WebApkInstaller::OnURLFetchComplete(const net::URLFetcher* source) {
void WebApkInstaller::DownloadAppIconAndComputeMurmur2Hash() {
// Safeguard. WebApkIconHasher crashes if asked to fetch an invalid URL.
- if (!shortcut_info_.icon_url.is_valid()) {
+ if (!shortcut_info_.best_icon_url.is_valid()) {
OnFailure();
return;
}
@@ -322,7 +332,7 @@ void WebApkInstaller::DownloadAppIconAndComputeMurmur2Hash() {
icon_hasher_.reset(new WebApkIconHasher());
icon_hasher_->DownloadAndComputeMurmur2Hash(
- request_context_getter_, shortcut_info_.icon_url,
+ request_context_getter_, shortcut_info_.best_icon_url,
base::Bind(&WebApkInstaller::OnGotIconMurmur2Hash,
weak_ptr_factory_.GetWeakPtr()));
}

Powered by Google App Engine
This is Rietveld 408576698