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/android/webapk/webapk_installer.h" | 5 #include "chrome/browser/android/webapk/webapk_installer.h" |
6 | 6 |
7 #include "base/android/build_info.h" | 7 #include "base/android/build_info.h" |
8 #include "base/android/jni_android.h" | 8 #include "base/android/jni_android.h" |
9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
10 #include "base/android/path_utils.h" | 10 #include "base/android/path_utils.h" |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
102 return "mips"; | 102 return "mips"; |
103 #elif defined(__x86_64__) | 103 #elif defined(__x86_64__) |
104 return "x86_64"; | 104 return "x86_64"; |
105 #elif defined(__aarch64__) | 105 #elif defined(__aarch64__) |
106 return "arm64-v8a"; | 106 return "arm64-v8a"; |
107 #else | 107 #else |
108 #error "Unsupported target abi" | 108 #error "Unsupported target abi" |
109 #endif | 109 #endif |
110 } | 110 } |
111 | 111 |
112 // Populates the webapk::Image::image_data field of |image| with |icon|. | |
113 void SetImageData(webapk::Image* image, const SkBitmap& icon) { | |
114 std::vector<unsigned char> png_bytes; | |
115 gfx::PNGCodec::EncodeBGRASkBitmap(icon, false, &png_bytes); | |
116 image->set_image_data(&png_bytes.front(), png_bytes.size()); | |
117 } | |
118 | |
112 // Populates webapk::WebApk and returns it. | 119 // Populates webapk::WebApk and returns it. |
113 // Must be called on a worker thread because it encodes an SkBitmap. | 120 // Must be called on a worker thread because it encodes an SkBitmap. |
114 std::unique_ptr<webapk::WebApk> BuildWebApkProtoInBackground( | 121 std::unique_ptr<webapk::WebApk> BuildWebApkProtoInBackground( |
115 const ShortcutInfo& shortcut_info, | 122 const ShortcutInfo& shortcut_info, |
116 const SkBitmap& shortcut_icon, | 123 const SkBitmap& primary_icon, |
124 const SkBitmap& badge_icon, | |
117 const std::map<std::string, std::string>& icon_url_to_murmur2_hash, | 125 const std::map<std::string, std::string>& icon_url_to_murmur2_hash, |
118 bool is_manifest_stale) { | 126 bool is_manifest_stale) { |
119 DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); | 127 DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); |
120 | 128 |
121 std::unique_ptr<webapk::WebApk> webapk(new webapk::WebApk); | 129 std::unique_ptr<webapk::WebApk> webapk(new webapk::WebApk); |
122 webapk->set_manifest_url(shortcut_info.manifest_url.spec()); | 130 webapk->set_manifest_url(shortcut_info.manifest_url.spec()); |
123 webapk->set_requester_application_package( | 131 webapk->set_requester_application_package( |
124 base::android::BuildInfo::GetInstance()->package_name()); | 132 base::android::BuildInfo::GetInstance()->package_name()); |
125 webapk->set_requester_application_version(version_info::GetVersionNumber()); | 133 webapk->set_requester_application_version(version_info::GetVersionNumber()); |
126 webapk->set_android_abi(getCurrentAbi()); | 134 webapk->set_android_abi(getCurrentAbi()); |
127 webapk->set_stale_manifest(is_manifest_stale); | 135 webapk->set_stale_manifest(is_manifest_stale); |
128 | 136 |
129 webapk::WebAppManifest* web_app_manifest = webapk->mutable_manifest(); | 137 webapk::WebAppManifest* web_app_manifest = webapk->mutable_manifest(); |
130 web_app_manifest->set_name(base::UTF16ToUTF8(shortcut_info.name)); | 138 web_app_manifest->set_name(base::UTF16ToUTF8(shortcut_info.name)); |
131 web_app_manifest->set_short_name(base::UTF16ToUTF8(shortcut_info.short_name)); | 139 web_app_manifest->set_short_name(base::UTF16ToUTF8(shortcut_info.short_name)); |
132 web_app_manifest->set_start_url(shortcut_info.url.spec()); | 140 web_app_manifest->set_start_url(shortcut_info.url.spec()); |
133 web_app_manifest->set_orientation( | 141 web_app_manifest->set_orientation( |
134 content::WebScreenOrientationLockTypeToString(shortcut_info.orientation)); | 142 content::WebScreenOrientationLockTypeToString(shortcut_info.orientation)); |
135 web_app_manifest->set_display_mode( | 143 web_app_manifest->set_display_mode( |
136 content::WebDisplayModeToString(shortcut_info.display)); | 144 content::WebDisplayModeToString(shortcut_info.display)); |
137 web_app_manifest->set_background_color( | 145 web_app_manifest->set_background_color( |
138 ColorToString(shortcut_info.background_color)); | 146 ColorToString(shortcut_info.background_color)); |
139 web_app_manifest->set_theme_color(ColorToString(shortcut_info.theme_color)); | 147 web_app_manifest->set_theme_color(ColorToString(shortcut_info.theme_color)); |
140 | 148 |
141 std::string* scope = web_app_manifest->add_scopes(); | 149 std::string* scope = web_app_manifest->add_scopes(); |
142 scope->assign(GetScope(shortcut_info).spec()); | 150 scope->assign(GetScope(shortcut_info).spec()); |
143 | 151 |
144 webapk::Image* best_image = web_app_manifest->add_icons(); | 152 if (shortcut_info.best_primary_icon_url.is_empty()) { |
145 std::string best_primary_icon_url = | 153 // Update when web manifest is no longer available. |
146 shortcut_info.best_primary_icon_url.spec(); | 154 webapk::Image* best_primary_icon_image = web_app_manifest->add_icons(); |
147 best_image->set_src(best_primary_icon_url); | 155 SetImageData(best_primary_icon_image, primary_icon); |
148 auto it = icon_url_to_murmur2_hash.find(best_primary_icon_url); | 156 best_primary_icon_image->add_usages(webapk::Image::PRIMARY_ICON); |
149 if (it != icon_url_to_murmur2_hash.end()) | 157 |
150 best_image->set_hash(it->second); | 158 if (!badge_icon.drawsNothing()) { |
151 std::vector<unsigned char> png_bytes; | 159 webapk::Image* best_badge_icon_image = web_app_manifest->add_icons(); |
152 gfx::PNGCodec::EncodeBGRASkBitmap(shortcut_icon, false, &png_bytes); | 160 SetImageData(best_badge_icon_image, badge_icon); |
153 best_image->set_image_data(&png_bytes.front(), png_bytes.size()); | 161 best_badge_icon_image->add_usages(webapk::Image::BADGE_ICON); |
162 } | |
pkotwicz
2017/04/05 03:44:29
This is an elegant solution. Congrats!
F
2017/04/06 18:28:48
Thanks :)
| |
163 } | |
154 | 164 |
155 for (const auto& entry : icon_url_to_murmur2_hash) { | 165 for (const auto& entry : icon_url_to_murmur2_hash) { |
156 if (entry.first == shortcut_info.best_primary_icon_url.spec()) | |
157 continue; | |
158 webapk::Image* image = web_app_manifest->add_icons(); | 166 webapk::Image* image = web_app_manifest->add_icons(); |
167 if (entry.first == shortcut_info.best_primary_icon_url.spec()) { | |
168 SetImageData(image, primary_icon); | |
169 image->add_usages(webapk::Image::PRIMARY_ICON); | |
170 } | |
171 if (entry.first == shortcut_info.best_badge_icon_url.spec()) { | |
172 SetImageData(image, badge_icon); | |
pkotwicz
2017/04/05 03:44:29
Should we call SetImageData() only if:
shortcut_in
F
2017/04/06 18:28:48
Done.
| |
173 image->add_usages(webapk::Image::BADGE_ICON); | |
174 } | |
159 image->set_src(entry.first); | 175 image->set_src(entry.first); |
160 image->set_hash(entry.second); | 176 image->set_hash(entry.second); |
161 } | 177 } |
162 | 178 |
163 return webapk; | 179 return webapk; |
164 } | 180 } |
165 | 181 |
166 // Calls the callback when the |webapk| request is created. | 182 // Calls the callback when the |webapk| request is created. |
167 void OnWebApkProtoBuilt( | 183 void OnWebApkProtoBuilt( |
168 const base::Callback<void(std::unique_ptr<webapk::WebApk>)>& callback, | 184 const base::Callback<void(std::unique_ptr<webapk::WebApk>)>& callback, |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
213 | 229 |
214 WebApkInstaller::~WebApkInstaller() { | 230 WebApkInstaller::~WebApkInstaller() { |
215 JNIEnv* env = base::android::AttachCurrentThread(); | 231 JNIEnv* env = base::android::AttachCurrentThread(); |
216 Java_WebApkInstaller_destroy(env, java_ref_); | 232 Java_WebApkInstaller_destroy(env, java_ref_); |
217 java_ref_.Reset(); | 233 java_ref_.Reset(); |
218 } | 234 } |
219 | 235 |
220 // static | 236 // static |
221 void WebApkInstaller::InstallAsync(content::BrowserContext* context, | 237 void WebApkInstaller::InstallAsync(content::BrowserContext* context, |
222 const ShortcutInfo& shortcut_info, | 238 const ShortcutInfo& shortcut_info, |
223 const SkBitmap& shortcut_icon, | 239 const SkBitmap& primary_icon, |
240 const SkBitmap& badge_icon, | |
224 const FinishCallback& finish_callback) { | 241 const FinishCallback& finish_callback) { |
225 // The installer will delete itself when it is done. | 242 // The installer will delete itself when it is done. |
226 WebApkInstaller* installer = | 243 WebApkInstaller* installer = |
227 new WebApkInstaller(context, shortcut_info, shortcut_icon); | 244 new WebApkInstaller(context, shortcut_info, primary_icon, badge_icon); |
228 installer->InstallAsync(finish_callback); | 245 installer->InstallAsync(finish_callback); |
229 } | 246 } |
230 | 247 |
231 // static | 248 // static |
232 void WebApkInstaller::UpdateAsync( | 249 void WebApkInstaller::UpdateAsync( |
233 content::BrowserContext* context, | 250 content::BrowserContext* context, |
234 const ShortcutInfo& shortcut_info, | 251 const ShortcutInfo& shortcut_info, |
235 const SkBitmap& shortcut_icon, | 252 const SkBitmap& primary_icon, |
236 const std::string& webapk_package, | 253 const std::string& webapk_package, |
237 int webapk_version, | 254 int webapk_version, |
238 const std::map<std::string, std::string>& icon_url_to_murmur2_hash, | 255 const std::map<std::string, std::string>& icon_url_to_murmur2_hash, |
239 bool is_manifest_stale, | 256 bool is_manifest_stale, |
240 const FinishCallback& finish_callback) { | 257 const FinishCallback& finish_callback) { |
241 // The installer will delete itself when it is done. | 258 // The installer will delete itself when it is done. |
242 WebApkInstaller* installer = | 259 SkBitmap empty_badge_icon; |
243 new WebApkInstaller(context, shortcut_info, shortcut_icon); | 260 WebApkInstaller* installer = new WebApkInstaller( |
261 context, shortcut_info, primary_icon, empty_badge_icon); | |
pkotwicz
2017/04/05 03:44:29
Nit: inline the |empty_badge_icon| initialization.
F
2017/04/06 18:28:48
Done.
| |
244 installer->UpdateAsync(webapk_package, webapk_version, | 262 installer->UpdateAsync(webapk_package, webapk_version, |
245 icon_url_to_murmur2_hash, is_manifest_stale, | 263 icon_url_to_murmur2_hash, is_manifest_stale, |
246 finish_callback); | 264 finish_callback); |
247 } | 265 } |
248 | 266 |
249 // staic | 267 // staic |
250 void WebApkInstaller::InstallAsyncForTesting( | 268 void WebApkInstaller::InstallAsyncForTesting( |
251 WebApkInstaller* installer, | 269 WebApkInstaller* installer, |
252 const FinishCallback& finish_callback) { | 270 const FinishCallback& finish_callback) { |
253 installer->InstallAsync(finish_callback); | 271 installer->InstallAsync(finish_callback); |
(...skipping 23 matching lines...) Expand all Loading... | |
277 jint result) { | 295 jint result) { |
278 OnResult(static_cast<WebApkInstallResult>(result)); | 296 OnResult(static_cast<WebApkInstallResult>(result)); |
279 } | 297 } |
280 | 298 |
281 void WebApkInstaller::BuildWebApkProtoInBackgroundForTesting( | 299 void WebApkInstaller::BuildWebApkProtoInBackgroundForTesting( |
282 const base::Callback<void(std::unique_ptr<webapk::WebApk>)>& callback, | 300 const base::Callback<void(std::unique_ptr<webapk::WebApk>)>& callback, |
283 const std::map<std::string, std::string>& icon_url_to_murmur2_hash, | 301 const std::map<std::string, std::string>& icon_url_to_murmur2_hash, |
284 bool is_manifest_stale) { | 302 bool is_manifest_stale) { |
285 base::PostTaskAndReplyWithResult( | 303 base::PostTaskAndReplyWithResult( |
286 GetBackgroundTaskRunner().get(), FROM_HERE, | 304 GetBackgroundTaskRunner().get(), FROM_HERE, |
287 base::Bind(&BuildWebApkProtoInBackground, shortcut_info_, shortcut_icon_, | 305 base::Bind(&BuildWebApkProtoInBackground, shortcut_info_, primary_icon_, |
288 icon_url_to_murmur2_hash, is_manifest_stale), | 306 badge_icon_, icon_url_to_murmur2_hash, is_manifest_stale), |
289 base::Bind(&OnWebApkProtoBuilt, callback)); | 307 base::Bind(&OnWebApkProtoBuilt, callback)); |
290 } | 308 } |
291 | 309 |
292 // static | 310 // static |
293 bool WebApkInstaller::Register(JNIEnv* env) { | 311 bool WebApkInstaller::Register(JNIEnv* env) { |
294 return RegisterNativesImpl(env); | 312 return RegisterNativesImpl(env); |
295 } | 313 } |
296 | 314 |
297 void WebApkInstaller::InstallDownloadedWebApk( | 315 void WebApkInstaller::InstallDownloadedWebApk( |
298 JNIEnv* env, | 316 JNIEnv* env, |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
353 DVLOG(1) << "The WebAPK installation failed."; | 371 DVLOG(1) << "The WebAPK installation failed."; |
354 webapk::TrackInstallEvent(webapk::INSTALL_FAILED); | 372 webapk::TrackInstallEvent(webapk::INSTALL_FAILED); |
355 } | 373 } |
356 } | 374 } |
357 | 375 |
358 delete this; | 376 delete this; |
359 } | 377 } |
360 | 378 |
361 WebApkInstaller::WebApkInstaller(content::BrowserContext* browser_context, | 379 WebApkInstaller::WebApkInstaller(content::BrowserContext* browser_context, |
362 const ShortcutInfo& shortcut_info, | 380 const ShortcutInfo& shortcut_info, |
363 const SkBitmap& shortcut_icon) | 381 const SkBitmap& primary_icon, |
382 const SkBitmap& badge_icon) | |
364 : request_context_getter_( | 383 : request_context_getter_( |
365 Profile::FromBrowserContext(browser_context)->GetRequestContext()), | 384 Profile::FromBrowserContext(browser_context)->GetRequestContext()), |
366 shortcut_info_(shortcut_info), | 385 shortcut_info_(shortcut_info), |
367 shortcut_icon_(shortcut_icon), | 386 primary_icon_(primary_icon), |
387 badge_icon_(badge_icon), | |
368 server_url_(GetServerUrl()), | 388 server_url_(GetServerUrl()), |
369 webapk_download_url_timeout_ms_(kWebApkDownloadUrlTimeoutMs), | 389 webapk_download_url_timeout_ms_(kWebApkDownloadUrlTimeoutMs), |
370 download_timeout_ms_(kDownloadTimeoutMs), | 390 download_timeout_ms_(kDownloadTimeoutMs), |
371 relax_updates_(false), | 391 relax_updates_(false), |
372 webapk_version_(kDefaultWebApkVersion), | 392 webapk_version_(kDefaultWebApkVersion), |
373 task_type_(UNDEFINED), | 393 task_type_(UNDEFINED), |
374 weak_ptr_factory_(this) { | 394 weak_ptr_factory_(this) { |
375 CreateJavaRef(); | 395 CreateJavaRef(); |
376 } | 396 } |
377 | 397 |
(...skipping 12 matching lines...) Expand all Loading... | |
390 // We need to take the hash of the bitmap at the icon URL prior to any | 410 // We need to take the hash of the bitmap at the icon URL prior to any |
391 // transformations being applied to the bitmap (such as encoding/decoding | 411 // transformations being applied to the bitmap (such as encoding/decoding |
392 // the bitmap). The icon hash is used to determine whether the icon that | 412 // the bitmap). The icon hash is used to determine whether the icon that |
393 // the user sees matches the icon of a WebAPK that the WebAPK server | 413 // the user sees matches the icon of a WebAPK that the WebAPK server |
394 // generated for another user. (The icon can be dynamically generated.) | 414 // generated for another user. (The icon can be dynamically generated.) |
395 // | 415 // |
396 // We redownload the icon in order to take the Murmur2 hash. The redownload | 416 // We redownload the icon in order to take the Murmur2 hash. The redownload |
397 // should be fast because the icon should be in the HTTP cache. | 417 // should be fast because the icon should be in the HTTP cache. |
398 WebApkIconHasher::DownloadAndComputeMurmur2Hash( | 418 WebApkIconHasher::DownloadAndComputeMurmur2Hash( |
399 request_context_getter_, shortcut_info_.best_primary_icon_url, | 419 request_context_getter_, shortcut_info_.best_primary_icon_url, |
400 base::Bind(&WebApkInstaller::OnGotIconMurmur2Hash, | 420 base::Bind(&WebApkInstaller::OnGotPrimaryIconMurmur2Hash, |
401 weak_ptr_factory_.GetWeakPtr())); | 421 weak_ptr_factory_.GetWeakPtr())); |
402 } | 422 } |
403 | 423 |
404 void WebApkInstaller::UpdateAsync( | 424 void WebApkInstaller::UpdateAsync( |
405 const std::string& webapk_package, | 425 const std::string& webapk_package, |
406 int webapk_version, | 426 int webapk_version, |
407 const std::map<std::string, std::string>& icon_url_to_murmur2_hash, | 427 const std::map<std::string, std::string>& icon_url_to_murmur2_hash, |
408 bool is_manifest_stale, | 428 bool is_manifest_stale, |
409 const FinishCallback& finish_callback) { | 429 const FinishCallback& finish_callback) { |
410 webapk_package_ = webapk_package; | 430 webapk_package_ = webapk_package; |
411 webapk_version_ = webapk_version; | 431 webapk_version_ = webapk_version; |
412 finish_callback_ = finish_callback; | 432 finish_callback_ = finish_callback; |
413 task_type_ = UPDATE; | 433 task_type_ = UPDATE; |
414 | 434 |
415 base::PostTaskAndReplyWithResult( | 435 base::PostTaskAndReplyWithResult( |
416 GetBackgroundTaskRunner().get(), FROM_HERE, | 436 GetBackgroundTaskRunner().get(), FROM_HERE, |
417 base::Bind(&BuildWebApkProtoInBackground, shortcut_info_, shortcut_icon_, | 437 base::Bind(&BuildWebApkProtoInBackground, shortcut_info_, primary_icon_, |
418 icon_url_to_murmur2_hash, is_manifest_stale), | 438 badge_icon_, icon_url_to_murmur2_hash, is_manifest_stale), |
419 base::Bind(&WebApkInstaller::SendUpdateWebApkRequest, | 439 base::Bind(&WebApkInstaller::SendUpdateWebApkRequest, |
420 weak_ptr_factory_.GetWeakPtr())); | 440 weak_ptr_factory_.GetWeakPtr())); |
421 } | 441 } |
422 | 442 |
423 void WebApkInstaller::OnURLFetchComplete(const net::URLFetcher* source) { | 443 void WebApkInstaller::OnURLFetchComplete(const net::URLFetcher* source) { |
424 timer_.Stop(); | 444 timer_.Stop(); |
425 | 445 |
426 if (!source->GetStatus().is_success() || | 446 if (!source->GetStatus().is_success() || |
427 source->GetResponseCode() != net::HTTP_OK) { | 447 source->GetResponseCode() != net::HTTP_OK) { |
428 LOG(WARNING) << base::StringPrintf( | 448 LOG(WARNING) << base::StringPrintf( |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
460 int version = 1; | 480 int version = 1; |
461 base::StringToInt(response->version(), &version); | 481 base::StringToInt(response->version(), &version); |
462 InstallOrUpdateWebApkFromGooglePlay(response->package_name(), version, | 482 InstallOrUpdateWebApkFromGooglePlay(response->package_name(), version, |
463 response->token()); | 483 response->token()); |
464 return; | 484 return; |
465 } | 485 } |
466 | 486 |
467 OnGotWebApkDownloadUrl(signed_download_url, response->package_name()); | 487 OnGotWebApkDownloadUrl(signed_download_url, response->package_name()); |
468 } | 488 } |
469 | 489 |
470 void WebApkInstaller::OnGotIconMurmur2Hash( | 490 void WebApkInstaller::OnGotPrimaryIconMurmur2Hash( |
471 const std::string& icon_murmur2_hash) { | 491 const std::string& primary_icon_hash) { |
472 // An empty hash indicates that |icon_hasher_| encountered an error. | 492 // An empty hash indicates an error during hash calculation. |
473 if (icon_murmur2_hash.empty()) { | 493 if (primary_icon_hash.empty()) { |
474 OnResult(WebApkInstallResult::FAILURE); | 494 OnResult(WebApkInstallResult::FAILURE); |
475 return; | 495 return; |
476 } | 496 } |
477 | 497 |
498 if (!shortcut_info_.best_badge_icon_url.is_empty() && | |
499 shortcut_info_.best_badge_icon_url != | |
500 shortcut_info_.best_primary_icon_url) { | |
501 WebApkIconHasher::DownloadAndComputeMurmur2Hash( | |
502 request_context_getter_, shortcut_info_.best_badge_icon_url, | |
503 base::Bind(&WebApkInstaller::OnGotBadgeIconMurmur2Hash, | |
504 weak_ptr_factory_.GetWeakPtr(), true, primary_icon_hash)); | |
505 } else { | |
506 OnGotBadgeIconMurmur2Hash(false, primary_icon_hash, ""); | |
507 } | |
508 } | |
509 | |
510 void WebApkInstaller::OnGotBadgeIconMurmur2Hash( | |
511 bool did_fetch_badge_icon, | |
512 const std::string& primary_icon_hash, | |
513 const std::string& badge_icon_hash) { | |
514 // An empty hash indicates an error during hash calculation. | |
515 if (did_fetch_badge_icon && badge_icon_hash.empty()) { | |
516 OnResult(WebApkInstallResult::FAILURE); | |
517 return; | |
518 } | |
519 | |
520 // Maps icon URLs to Murmur2 hashes. | |
478 std::map<std::string, std::string> icon_url_to_murmur2_hash; | 521 std::map<std::string, std::string> icon_url_to_murmur2_hash; |
479 for (const std::string& icon_url : shortcut_info_.icon_urls) { | 522 for (const std::string& icon_url : shortcut_info_.icon_urls) { |
480 if (icon_url != shortcut_info_.best_primary_icon_url.spec()) | 523 if (icon_url == shortcut_info_.best_primary_icon_url.spec()) |
524 icon_url_to_murmur2_hash[icon_url] = primary_icon_hash; | |
525 else if (icon_url == shortcut_info_.best_badge_icon_url.spec()) | |
526 icon_url_to_murmur2_hash[icon_url] = badge_icon_hash; | |
527 else | |
481 icon_url_to_murmur2_hash[icon_url] = ""; | 528 icon_url_to_murmur2_hash[icon_url] = ""; |
482 else | |
483 icon_url_to_murmur2_hash[icon_url] = icon_murmur2_hash; | |
484 } | 529 } |
485 | 530 |
486 base::PostTaskAndReplyWithResult( | 531 base::PostTaskAndReplyWithResult( |
487 GetBackgroundTaskRunner().get(), FROM_HERE, | 532 GetBackgroundTaskRunner().get(), FROM_HERE, |
488 base::Bind(&BuildWebApkProtoInBackground, shortcut_info_, shortcut_icon_, | 533 base::Bind(&BuildWebApkProtoInBackground, shortcut_info_, primary_icon_, |
489 icon_url_to_murmur2_hash, false /* is_manifest_stale */), | 534 badge_icon_, icon_url_to_murmur2_hash, |
535 false /* is_manifest_stale */), | |
490 base::Bind(&WebApkInstaller::SendCreateWebApkRequest, | 536 base::Bind(&WebApkInstaller::SendCreateWebApkRequest, |
491 weak_ptr_factory_.GetWeakPtr())); | 537 weak_ptr_factory_.GetWeakPtr())); |
492 } | 538 } |
493 | 539 |
494 void WebApkInstaller::SendCreateWebApkRequest( | 540 void WebApkInstaller::SendCreateWebApkRequest( |
495 std::unique_ptr<webapk::WebApk> webapk) { | 541 std::unique_ptr<webapk::WebApk> webapk) { |
496 SendRequest(std::move(webapk), server_url_); | 542 SendRequest(std::move(webapk), server_url_); |
497 } | 543 } |
498 | 544 |
499 void WebApkInstaller::SendUpdateWebApkRequest( | 545 void WebApkInstaller::SendUpdateWebApkRequest( |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
608 base::android::ScopedJavaLocalRef<jstring> java_file_path = | 654 base::android::ScopedJavaLocalRef<jstring> java_file_path = |
609 base::android::ConvertUTF8ToJavaString(env, file_path.value()); | 655 base::android::ConvertUTF8ToJavaString(env, file_path.value()); |
610 if (task_type_ == INSTALL) { | 656 if (task_type_ == INSTALL) { |
611 base::android::ScopedJavaLocalRef<jstring> java_package_name = | 657 base::android::ScopedJavaLocalRef<jstring> java_package_name = |
612 base::android::ConvertUTF8ToJavaString(env, webapk_package_); | 658 base::android::ConvertUTF8ToJavaString(env, webapk_package_); |
613 InstallDownloadedWebApk(env, java_file_path, java_package_name); | 659 InstallDownloadedWebApk(env, java_file_path, java_package_name); |
614 } else if (task_type_ == UPDATE) { | 660 } else if (task_type_ == UPDATE) { |
615 UpdateUsingDownloadedWebApk(env, java_file_path); | 661 UpdateUsingDownloadedWebApk(env, java_file_path); |
616 } | 662 } |
617 } | 663 } |
OLD | NEW |