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 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 source->GetResponseAsString(&response_string); | 411 source->GetResponseAsString(&response_string); |
412 | 412 |
413 std::unique_ptr<webapk::WebApkResponse> response( | 413 std::unique_ptr<webapk::WebApkResponse> response( |
414 new webapk::WebApkResponse); | 414 new webapk::WebApkResponse); |
415 if (!response->ParseFromString(response_string)) { | 415 if (!response->ParseFromString(response_string)) { |
416 OnFailure(); | 416 OnFailure(); |
417 return; | 417 return; |
418 } | 418 } |
419 | 419 |
420 GURL signed_download_url(response->signed_download_url()); | 420 GURL signed_download_url(response->signed_download_url()); |
| 421 // https://crbug.com/680131. The server sends an empty URL if the server does |
| 422 // not have a newer WebAPK to update to. |
| 423 if (task_type_ == UPDATE && signed_download_url.is_empty()) { |
| 424 OnSuccess(); |
| 425 return; |
| 426 } |
| 427 |
421 if (!signed_download_url.is_valid() || response->package_name().empty()) { | 428 if (!signed_download_url.is_valid() || response->package_name().empty()) { |
422 OnFailure(); | 429 OnFailure(); |
423 return; | 430 return; |
424 } | 431 } |
425 | 432 |
426 if (HasGooglePlayWebApkInstallDelegate()) { | 433 if (HasGooglePlayWebApkInstallDelegate()) { |
427 int version = 1; | 434 int version = 1; |
428 base::StringToInt(response->version(), &version); | 435 base::StringToInt(response->version(), &version); |
429 if (!InstallOrUpdateWebApkFromGooglePlay( | 436 if (!InstallOrUpdateWebApkFromGooglePlay( |
430 response->package_name(), version, response->token())) { | 437 response->package_name(), version, response->token())) { |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
615 | 622 |
616 void WebApkInstaller::OnSuccess() { | 623 void WebApkInstaller::OnSuccess() { |
617 finish_callback_.Run(true, webapk_package_); | 624 finish_callback_.Run(true, webapk_package_); |
618 delete this; | 625 delete this; |
619 } | 626 } |
620 | 627 |
621 void WebApkInstaller::OnFailure() { | 628 void WebApkInstaller::OnFailure() { |
622 finish_callback_.Run(false, webapk_package_); | 629 finish_callback_.Run(false, webapk_package_); |
623 delete this; | 630 delete this; |
624 } | 631 } |
OLD | NEW |