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