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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 return "mips"; | 91 return "mips"; |
92 #elif defined(__x86_64__) | 92 #elif defined(__x86_64__) |
93 return "x86_64"; | 93 return "x86_64"; |
94 #elif defined(__aarch64__) | 94 #elif defined(__aarch64__) |
95 return "arm64-v8a"; | 95 return "arm64-v8a"; |
96 #else | 96 #else |
97 #error "Unsupported target abi" | 97 #error "Unsupported target abi" |
98 #endif | 98 #endif |
99 } | 99 } |
100 | 100 |
| 101 // Populates the webapk::Image::image_data field of |image| with |icon|. |
| 102 void SetImageData(webapk::Image* image, const SkBitmap& icon) { |
| 103 std::vector<unsigned char> png_bytes; |
| 104 gfx::PNGCodec::EncodeBGRASkBitmap(icon, false, &png_bytes); |
| 105 image->set_image_data(&png_bytes.front(), png_bytes.size()); |
| 106 } |
| 107 |
101 // Populates webapk::WebApk and returns it. | 108 // Populates webapk::WebApk and returns it. |
102 // Must be called on a worker thread because it encodes an SkBitmap. | 109 // Must be called on a worker thread because it encodes an SkBitmap. |
103 std::unique_ptr<webapk::WebApk> BuildWebApkProtoInBackground( | 110 std::unique_ptr<webapk::WebApk> BuildWebApkProtoInBackground( |
104 const ShortcutInfo& shortcut_info, | 111 const ShortcutInfo& shortcut_info, |
105 const SkBitmap& shortcut_icon, | 112 const SkBitmap& primary_icon, |
| 113 const SkBitmap& badge_icon, |
106 const std::map<std::string, std::string>& icon_url_to_murmur2_hash, | 114 const std::map<std::string, std::string>& icon_url_to_murmur2_hash, |
107 bool is_manifest_stale) { | 115 bool is_manifest_stale) { |
108 DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); | 116 DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); |
109 | 117 |
110 std::unique_ptr<webapk::WebApk> webapk(new webapk::WebApk); | 118 std::unique_ptr<webapk::WebApk> webapk(new webapk::WebApk); |
111 webapk->set_manifest_url(shortcut_info.manifest_url.spec()); | 119 webapk->set_manifest_url(shortcut_info.manifest_url.spec()); |
112 webapk->set_requester_application_package( | 120 webapk->set_requester_application_package( |
113 base::android::BuildInfo::GetInstance()->package_name()); | 121 base::android::BuildInfo::GetInstance()->package_name()); |
114 webapk->set_requester_application_version(version_info::GetVersionNumber()); | 122 webapk->set_requester_application_version(version_info::GetVersionNumber()); |
115 webapk->set_android_abi(getCurrentAbi()); | 123 webapk->set_android_abi(getCurrentAbi()); |
116 webapk->set_stale_manifest(is_manifest_stale); | 124 webapk->set_stale_manifest(is_manifest_stale); |
117 | 125 |
118 webapk::WebAppManifest* web_app_manifest = webapk->mutable_manifest(); | 126 webapk::WebAppManifest* web_app_manifest = webapk->mutable_manifest(); |
119 web_app_manifest->set_name(base::UTF16ToUTF8(shortcut_info.name)); | 127 web_app_manifest->set_name(base::UTF16ToUTF8(shortcut_info.name)); |
120 web_app_manifest->set_short_name(base::UTF16ToUTF8(shortcut_info.short_name)); | 128 web_app_manifest->set_short_name(base::UTF16ToUTF8(shortcut_info.short_name)); |
121 web_app_manifest->set_start_url(shortcut_info.url.spec()); | 129 web_app_manifest->set_start_url(shortcut_info.url.spec()); |
122 web_app_manifest->set_orientation( | 130 web_app_manifest->set_orientation( |
123 content::WebScreenOrientationLockTypeToString(shortcut_info.orientation)); | 131 content::WebScreenOrientationLockTypeToString(shortcut_info.orientation)); |
124 web_app_manifest->set_display_mode( | 132 web_app_manifest->set_display_mode( |
125 content::WebDisplayModeToString(shortcut_info.display)); | 133 content::WebDisplayModeToString(shortcut_info.display)); |
126 web_app_manifest->set_background_color( | 134 web_app_manifest->set_background_color( |
127 ColorToString(shortcut_info.background_color)); | 135 ColorToString(shortcut_info.background_color)); |
128 web_app_manifest->set_theme_color(ColorToString(shortcut_info.theme_color)); | 136 web_app_manifest->set_theme_color(ColorToString(shortcut_info.theme_color)); |
129 | 137 |
130 std::string* scope = web_app_manifest->add_scopes(); | 138 std::string* scope = web_app_manifest->add_scopes(); |
131 scope->assign(GetScope(shortcut_info).spec()); | 139 scope->assign(GetScope(shortcut_info).spec()); |
132 | 140 |
133 webapk::Image* best_image = web_app_manifest->add_icons(); | 141 if (shortcut_info.best_primary_icon_url.is_empty()) { |
134 std::string best_primary_icon_url = | 142 // Update when web manifest is no longer available. |
135 shortcut_info.best_primary_icon_url.spec(); | 143 webapk::Image* best_primary_icon_image = web_app_manifest->add_icons(); |
136 best_image->set_src(best_primary_icon_url); | 144 SetImageData(best_primary_icon_image, primary_icon); |
137 auto it = icon_url_to_murmur2_hash.find(best_primary_icon_url); | 145 best_primary_icon_image->add_usages(webapk::Image::PRIMARY_ICON); |
138 if (it != icon_url_to_murmur2_hash.end()) | 146 |
139 best_image->set_hash(it->second); | 147 if (!badge_icon.drawsNothing()) { |
140 std::vector<unsigned char> png_bytes; | 148 webapk::Image* best_badge_icon_image = web_app_manifest->add_icons(); |
141 gfx::PNGCodec::EncodeBGRASkBitmap(shortcut_icon, false, &png_bytes); | 149 SetImageData(best_badge_icon_image, badge_icon); |
142 best_image->set_image_data(&png_bytes.front(), png_bytes.size()); | 150 best_badge_icon_image->add_usages(webapk::Image::BADGE_ICON); |
| 151 } |
| 152 } |
143 | 153 |
144 for (const auto& entry : icon_url_to_murmur2_hash) { | 154 for (const auto& entry : icon_url_to_murmur2_hash) { |
145 if (entry.first == shortcut_info.best_primary_icon_url.spec()) | |
146 continue; | |
147 webapk::Image* image = web_app_manifest->add_icons(); | 155 webapk::Image* image = web_app_manifest->add_icons(); |
| 156 if (entry.first == shortcut_info.best_primary_icon_url.spec()) { |
| 157 SetImageData(image, primary_icon); |
| 158 image->add_usages(webapk::Image::PRIMARY_ICON); |
| 159 } |
| 160 if (entry.first == shortcut_info.best_badge_icon_url.spec()) { |
| 161 if (shortcut_info.best_badge_icon_url != |
| 162 shortcut_info.best_primary_icon_url) { |
| 163 SetImageData(image, badge_icon); |
| 164 } |
| 165 image->add_usages(webapk::Image::BADGE_ICON); |
| 166 } |
148 image->set_src(entry.first); | 167 image->set_src(entry.first); |
149 image->set_hash(entry.second); | 168 image->set_hash(entry.second); |
150 } | 169 } |
151 | 170 |
152 return webapk; | 171 return webapk; |
153 } | 172 } |
154 | 173 |
155 // Calls the callback when the |webapk| request is created. | 174 // Calls the callback when the |webapk| request is created. |
156 void OnWebApkProtoBuilt( | 175 void OnWebApkProtoBuilt( |
157 const base::Callback<void(std::unique_ptr<webapk::WebApk>)>& callback, | 176 const base::Callback<void(std::unique_ptr<webapk::WebApk>)>& callback, |
(...skipping 12 matching lines...) Expand all Loading... |
170 | 189 |
171 WebApkInstaller::~WebApkInstaller() { | 190 WebApkInstaller::~WebApkInstaller() { |
172 JNIEnv* env = base::android::AttachCurrentThread(); | 191 JNIEnv* env = base::android::AttachCurrentThread(); |
173 Java_WebApkInstaller_destroy(env, java_ref_); | 192 Java_WebApkInstaller_destroy(env, java_ref_); |
174 java_ref_.Reset(); | 193 java_ref_.Reset(); |
175 } | 194 } |
176 | 195 |
177 // static | 196 // static |
178 void WebApkInstaller::InstallAsync(content::BrowserContext* context, | 197 void WebApkInstaller::InstallAsync(content::BrowserContext* context, |
179 const ShortcutInfo& shortcut_info, | 198 const ShortcutInfo& shortcut_info, |
180 const SkBitmap& shortcut_icon, | 199 const SkBitmap& primary_icon, |
| 200 const SkBitmap& badge_icon, |
181 const FinishCallback& finish_callback) { | 201 const FinishCallback& finish_callback) { |
182 // The installer will delete itself when it is done. | 202 // The installer will delete itself when it is done. |
183 WebApkInstaller* installer = | 203 WebApkInstaller* installer = |
184 new WebApkInstaller(context, shortcut_info, shortcut_icon); | 204 new WebApkInstaller(context, shortcut_info, primary_icon, badge_icon); |
185 installer->InstallAsync(finish_callback); | 205 installer->InstallAsync(finish_callback); |
186 } | 206 } |
187 | 207 |
188 // static | 208 // static |
189 void WebApkInstaller::UpdateAsync( | 209 void WebApkInstaller::UpdateAsync( |
190 content::BrowserContext* context, | 210 content::BrowserContext* context, |
191 const ShortcutInfo& shortcut_info, | 211 const ShortcutInfo& shortcut_info, |
192 const SkBitmap& shortcut_icon, | 212 const SkBitmap& primary_icon, |
193 const std::string& webapk_package, | 213 const std::string& webapk_package, |
194 int webapk_version, | 214 int webapk_version, |
195 const std::map<std::string, std::string>& icon_url_to_murmur2_hash, | 215 const std::map<std::string, std::string>& icon_url_to_murmur2_hash, |
196 bool is_manifest_stale, | 216 bool is_manifest_stale, |
197 const FinishCallback& finish_callback) { | 217 const FinishCallback& finish_callback) { |
198 // The installer will delete itself when it is done. | 218 // The installer will delete itself when it is done. |
199 WebApkInstaller* installer = | 219 WebApkInstaller* installer = new WebApkInstaller( |
200 new WebApkInstaller(context, shortcut_info, shortcut_icon); | 220 context, shortcut_info, primary_icon, SkBitmap()); |
201 installer->UpdateAsync(webapk_package, webapk_version, | 221 installer->UpdateAsync(webapk_package, webapk_version, |
202 icon_url_to_murmur2_hash, is_manifest_stale, | 222 icon_url_to_murmur2_hash, is_manifest_stale, |
203 finish_callback); | 223 finish_callback); |
204 } | 224 } |
205 | 225 |
206 // staic | 226 // staic |
207 void WebApkInstaller::InstallAsyncForTesting( | 227 void WebApkInstaller::InstallAsyncForTesting( |
208 WebApkInstaller* installer, | 228 WebApkInstaller* installer, |
209 const FinishCallback& finish_callback) { | 229 const FinishCallback& finish_callback) { |
210 installer->InstallAsync(finish_callback); | 230 installer->InstallAsync(finish_callback); |
(...skipping 22 matching lines...) Expand all Loading... |
233 jint result) { | 253 jint result) { |
234 OnResult(static_cast<WebApkInstallResult>(result)); | 254 OnResult(static_cast<WebApkInstallResult>(result)); |
235 } | 255 } |
236 | 256 |
237 void WebApkInstaller::BuildWebApkProtoInBackgroundForTesting( | 257 void WebApkInstaller::BuildWebApkProtoInBackgroundForTesting( |
238 const base::Callback<void(std::unique_ptr<webapk::WebApk>)>& callback, | 258 const base::Callback<void(std::unique_ptr<webapk::WebApk>)>& callback, |
239 const std::map<std::string, std::string>& icon_url_to_murmur2_hash, | 259 const std::map<std::string, std::string>& icon_url_to_murmur2_hash, |
240 bool is_manifest_stale) { | 260 bool is_manifest_stale) { |
241 base::PostTaskAndReplyWithResult( | 261 base::PostTaskAndReplyWithResult( |
242 GetBackgroundTaskRunner().get(), FROM_HERE, | 262 GetBackgroundTaskRunner().get(), FROM_HERE, |
243 base::Bind(&BuildWebApkProtoInBackground, shortcut_info_, shortcut_icon_, | 263 base::Bind(&BuildWebApkProtoInBackground, shortcut_info_, primary_icon_, |
244 icon_url_to_murmur2_hash, is_manifest_stale), | 264 badge_icon_, icon_url_to_murmur2_hash, is_manifest_stale), |
245 base::Bind(&OnWebApkProtoBuilt, callback)); | 265 base::Bind(&OnWebApkProtoBuilt, callback)); |
246 } | 266 } |
247 | 267 |
248 // static | 268 // static |
249 bool WebApkInstaller::Register(JNIEnv* env) { | 269 bool WebApkInstaller::Register(JNIEnv* env) { |
250 return RegisterNativesImpl(env); | 270 return RegisterNativesImpl(env); |
251 } | 271 } |
252 | 272 |
253 bool WebApkInstaller::CanInstallWebApks() { | 273 bool WebApkInstaller::CanInstallWebApks() { |
254 return ChromeWebApkHost::GetGooglePlayInstallState() == | 274 return ChromeWebApkHost::GetGooglePlayInstallState() == |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 DVLOG(1) << "The WebAPK installation failed."; | 312 DVLOG(1) << "The WebAPK installation failed."; |
293 webapk::TrackInstallEvent(webapk::INSTALL_FAILED); | 313 webapk::TrackInstallEvent(webapk::INSTALL_FAILED); |
294 } | 314 } |
295 } | 315 } |
296 | 316 |
297 delete this; | 317 delete this; |
298 } | 318 } |
299 | 319 |
300 WebApkInstaller::WebApkInstaller(content::BrowserContext* browser_context, | 320 WebApkInstaller::WebApkInstaller(content::BrowserContext* browser_context, |
301 const ShortcutInfo& shortcut_info, | 321 const ShortcutInfo& shortcut_info, |
302 const SkBitmap& shortcut_icon) | 322 const SkBitmap& primary_icon, |
| 323 const SkBitmap& badge_icon) |
303 : request_context_getter_( | 324 : request_context_getter_( |
304 Profile::FromBrowserContext(browser_context)->GetRequestContext()), | 325 Profile::FromBrowserContext(browser_context)->GetRequestContext()), |
305 shortcut_info_(shortcut_info), | 326 shortcut_info_(shortcut_info), |
306 shortcut_icon_(shortcut_icon), | 327 primary_icon_(primary_icon), |
| 328 badge_icon_(badge_icon), |
307 server_url_(GetServerUrl()), | 329 server_url_(GetServerUrl()), |
308 webapk_server_timeout_ms_(kWebApkDownloadUrlTimeoutMs), | 330 webapk_server_timeout_ms_(kWebApkDownloadUrlTimeoutMs), |
309 relax_updates_(false), | 331 relax_updates_(false), |
310 task_type_(UNDEFINED), | 332 task_type_(UNDEFINED), |
311 weak_ptr_factory_(this) { | 333 weak_ptr_factory_(this) { |
312 CreateJavaRef(); | 334 CreateJavaRef(); |
313 } | 335 } |
314 | 336 |
315 void WebApkInstaller::CreateJavaRef() { | 337 void WebApkInstaller::CreateJavaRef() { |
316 JNIEnv* env = base::android::AttachCurrentThread(); | 338 JNIEnv* env = base::android::AttachCurrentThread(); |
(...skipping 10 matching lines...) Expand all Loading... |
327 // We need to take the hash of the bitmap at the icon URL prior to any | 349 // We need to take the hash of the bitmap at the icon URL prior to any |
328 // transformations being applied to the bitmap (such as encoding/decoding | 350 // transformations being applied to the bitmap (such as encoding/decoding |
329 // the bitmap). The icon hash is used to determine whether the icon that | 351 // the bitmap). The icon hash is used to determine whether the icon that |
330 // the user sees matches the icon of a WebAPK that the WebAPK server | 352 // the user sees matches the icon of a WebAPK that the WebAPK server |
331 // generated for another user. (The icon can be dynamically generated.) | 353 // generated for another user. (The icon can be dynamically generated.) |
332 // | 354 // |
333 // We redownload the icon in order to take the Murmur2 hash. The redownload | 355 // We redownload the icon in order to take the Murmur2 hash. The redownload |
334 // should be fast because the icon should be in the HTTP cache. | 356 // should be fast because the icon should be in the HTTP cache. |
335 WebApkIconHasher::DownloadAndComputeMurmur2Hash( | 357 WebApkIconHasher::DownloadAndComputeMurmur2Hash( |
336 request_context_getter_, shortcut_info_.best_primary_icon_url, | 358 request_context_getter_, shortcut_info_.best_primary_icon_url, |
337 base::Bind(&WebApkInstaller::OnGotIconMurmur2Hash, | 359 base::Bind(&WebApkInstaller::OnGotPrimaryIconMurmur2Hash, |
338 weak_ptr_factory_.GetWeakPtr())); | 360 weak_ptr_factory_.GetWeakPtr())); |
339 } | 361 } |
340 | 362 |
341 void WebApkInstaller::UpdateAsync( | 363 void WebApkInstaller::UpdateAsync( |
342 const std::string& webapk_package, | 364 const std::string& webapk_package, |
343 int webapk_version, | 365 int webapk_version, |
344 const std::map<std::string, std::string>& icon_url_to_murmur2_hash, | 366 const std::map<std::string, std::string>& icon_url_to_murmur2_hash, |
345 bool is_manifest_stale, | 367 bool is_manifest_stale, |
346 const FinishCallback& finish_callback) { | 368 const FinishCallback& finish_callback) { |
347 webapk_package_ = webapk_package; | 369 webapk_package_ = webapk_package; |
348 finish_callback_ = finish_callback; | 370 finish_callback_ = finish_callback; |
349 task_type_ = UPDATE; | 371 task_type_ = UPDATE; |
350 | 372 |
351 base::PostTaskAndReplyWithResult( | 373 base::PostTaskAndReplyWithResult( |
352 GetBackgroundTaskRunner().get(), FROM_HERE, | 374 GetBackgroundTaskRunner().get(), FROM_HERE, |
353 base::Bind(&BuildWebApkProtoInBackground, shortcut_info_, shortcut_icon_, | 375 base::Bind(&BuildWebApkProtoInBackground, shortcut_info_, primary_icon_, |
354 icon_url_to_murmur2_hash, is_manifest_stale), | 376 badge_icon_, icon_url_to_murmur2_hash, is_manifest_stale), |
355 base::Bind(&WebApkInstaller::SendUpdateWebApkRequest, | 377 base::Bind(&WebApkInstaller::SendUpdateWebApkRequest, |
356 weak_ptr_factory_.GetWeakPtr(), webapk_version)); | 378 weak_ptr_factory_.GetWeakPtr(), webapk_version)); |
357 } | 379 } |
358 | 380 |
359 void WebApkInstaller::OnURLFetchComplete(const net::URLFetcher* source) { | 381 void WebApkInstaller::OnURLFetchComplete(const net::URLFetcher* source) { |
360 timer_.Stop(); | 382 timer_.Stop(); |
361 | 383 |
362 if (!source->GetStatus().is_success() || | 384 if (!source->GetStatus().is_success() || |
363 source->GetResponseCode() != net::HTTP_OK) { | 385 source->GetResponseCode() != net::HTTP_OK) { |
364 LOG(WARNING) << base::StringPrintf( | 386 LOG(WARNING) << base::StringPrintf( |
(...skipping 30 matching lines...) Expand all Loading... |
395 if (!CanInstallWebApks()) { | 417 if (!CanInstallWebApks()) { |
396 OnResult(WebApkInstallResult::FAILURE); | 418 OnResult(WebApkInstallResult::FAILURE); |
397 return; | 419 return; |
398 } | 420 } |
399 | 421 |
400 int version = 1; | 422 int version = 1; |
401 base::StringToInt(response->version(), &version); | 423 base::StringToInt(response->version(), &version); |
402 InstallOrUpdateWebApk(response->package_name(), version, response->token()); | 424 InstallOrUpdateWebApk(response->package_name(), version, response->token()); |
403 } | 425 } |
404 | 426 |
405 void WebApkInstaller::OnGotIconMurmur2Hash( | 427 void WebApkInstaller::OnGotPrimaryIconMurmur2Hash( |
406 const std::string& icon_murmur2_hash) { | 428 const std::string& primary_icon_hash) { |
407 // An empty hash indicates that |icon_hasher_| encountered an error. | 429 // An empty hash indicates an error during hash calculation. |
408 if (icon_murmur2_hash.empty()) { | 430 if (primary_icon_hash.empty()) { |
409 OnResult(WebApkInstallResult::FAILURE); | 431 OnResult(WebApkInstallResult::FAILURE); |
410 return; | 432 return; |
411 } | 433 } |
412 | 434 |
| 435 if (!shortcut_info_.best_badge_icon_url.is_empty() && |
| 436 shortcut_info_.best_badge_icon_url != |
| 437 shortcut_info_.best_primary_icon_url) { |
| 438 WebApkIconHasher::DownloadAndComputeMurmur2Hash( |
| 439 request_context_getter_, shortcut_info_.best_badge_icon_url, |
| 440 base::Bind(&WebApkInstaller::OnGotBadgeIconMurmur2Hash, |
| 441 weak_ptr_factory_.GetWeakPtr(), true, primary_icon_hash)); |
| 442 } else { |
| 443 OnGotBadgeIconMurmur2Hash(false, primary_icon_hash, ""); |
| 444 } |
| 445 } |
| 446 |
| 447 void WebApkInstaller::OnGotBadgeIconMurmur2Hash( |
| 448 bool did_fetch_badge_icon, |
| 449 const std::string& primary_icon_hash, |
| 450 const std::string& badge_icon_hash) { |
| 451 // An empty hash indicates an error during hash calculation. |
| 452 if (did_fetch_badge_icon && badge_icon_hash.empty()) { |
| 453 OnResult(WebApkInstallResult::FAILURE); |
| 454 return; |
| 455 } |
| 456 |
| 457 // Maps icon URLs to Murmur2 hashes. |
413 std::map<std::string, std::string> icon_url_to_murmur2_hash; | 458 std::map<std::string, std::string> icon_url_to_murmur2_hash; |
414 for (const std::string& icon_url : shortcut_info_.icon_urls) { | 459 for (const std::string& icon_url : shortcut_info_.icon_urls) { |
415 if (icon_url != shortcut_info_.best_primary_icon_url.spec()) | 460 if (icon_url == shortcut_info_.best_primary_icon_url.spec()) |
| 461 icon_url_to_murmur2_hash[icon_url] = primary_icon_hash; |
| 462 else if (icon_url == shortcut_info_.best_badge_icon_url.spec()) |
| 463 icon_url_to_murmur2_hash[icon_url] = badge_icon_hash; |
| 464 else |
416 icon_url_to_murmur2_hash[icon_url] = ""; | 465 icon_url_to_murmur2_hash[icon_url] = ""; |
417 else | |
418 icon_url_to_murmur2_hash[icon_url] = icon_murmur2_hash; | |
419 } | 466 } |
420 | 467 |
421 base::PostTaskAndReplyWithResult( | 468 base::PostTaskAndReplyWithResult( |
422 GetBackgroundTaskRunner().get(), FROM_HERE, | 469 GetBackgroundTaskRunner().get(), FROM_HERE, |
423 base::Bind(&BuildWebApkProtoInBackground, shortcut_info_, shortcut_icon_, | 470 base::Bind(&BuildWebApkProtoInBackground, shortcut_info_, primary_icon_, |
424 icon_url_to_murmur2_hash, false /* is_manifest_stale */), | 471 badge_icon_, icon_url_to_murmur2_hash, |
| 472 false /* is_manifest_stale */), |
425 base::Bind(&WebApkInstaller::SendCreateWebApkRequest, | 473 base::Bind(&WebApkInstaller::SendCreateWebApkRequest, |
426 weak_ptr_factory_.GetWeakPtr())); | 474 weak_ptr_factory_.GetWeakPtr())); |
427 } | 475 } |
428 | 476 |
429 void WebApkInstaller::SendCreateWebApkRequest( | 477 void WebApkInstaller::SendCreateWebApkRequest( |
430 std::unique_ptr<webapk::WebApk> webapk) { | 478 std::unique_ptr<webapk::WebApk> webapk) { |
431 SendRequest(std::move(webapk), server_url_); | 479 SendRequest(std::move(webapk), server_url_); |
432 } | 480 } |
433 | 481 |
434 void WebApkInstaller::SendUpdateWebApkRequest( | 482 void WebApkInstaller::SendUpdateWebApkRequest( |
(...skipping 16 matching lines...) Expand all Loading... |
451 net::URLFetcher::Create(server_url, net::URLFetcher::POST, this); | 499 net::URLFetcher::Create(server_url, net::URLFetcher::POST, this); |
452 url_fetcher_->SetRequestContext(request_context_getter_); | 500 url_fetcher_->SetRequestContext(request_context_getter_); |
453 std::string serialized_request; | 501 std::string serialized_request; |
454 request_proto->SerializeToString(&serialized_request); | 502 request_proto->SerializeToString(&serialized_request); |
455 url_fetcher_->SetUploadData(kProtoMimeType, serialized_request); | 503 url_fetcher_->SetUploadData(kProtoMimeType, serialized_request); |
456 url_fetcher_->SetLoadFlags( | 504 url_fetcher_->SetLoadFlags( |
457 net::LOAD_DISABLE_CACHE | net::LOAD_DO_NOT_SEND_COOKIES | | 505 net::LOAD_DISABLE_CACHE | net::LOAD_DO_NOT_SEND_COOKIES | |
458 net::LOAD_DO_NOT_SAVE_COOKIES | net::LOAD_DO_NOT_SEND_AUTH_DATA); | 506 net::LOAD_DO_NOT_SAVE_COOKIES | net::LOAD_DO_NOT_SEND_AUTH_DATA); |
459 url_fetcher_->Start(); | 507 url_fetcher_->Start(); |
460 } | 508 } |
OLD | NEW |