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

Side by Side Diff: chrome/browser/android/webapk/webapk_installer.cc

Issue 2634173002: Fall back to legacy add to homescreen behavior on non-GMS device or GMS isn't availabe. (Closed)
Patch Set: Nits. Created 3 years, 11 months 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 unified diff | Download patch
OLDNEW
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 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 env, java_ref_, java_file_path, java_package_name); 303 env, java_ref_, java_file_path, java_package_name);
304 } 304 }
305 305
306 bool WebApkInstaller::StartUpdateUsingDownloadedWebApk( 306 bool WebApkInstaller::StartUpdateUsingDownloadedWebApk(
307 JNIEnv* env, 307 JNIEnv* env,
308 const base::android::ScopedJavaLocalRef<jstring>& java_file_path) { 308 const base::android::ScopedJavaLocalRef<jstring>& java_file_path) {
309 return Java_WebApkInstaller_updateAsyncFromNative( 309 return Java_WebApkInstaller_updateAsyncFromNative(
310 env, java_ref_, java_file_path); 310 env, java_ref_, java_file_path);
311 } 311 }
312 312
313 bool WebApkInstaller::HasGooglePlayWebApkInstallDelegate() { 313 bool WebApkInstaller::CanUseGooglePlayInstallService() {
314 JNIEnv* env = base::android::AttachCurrentThread(); 314 JNIEnv* env = base::android::AttachCurrentThread();
315 return Java_WebApkInstaller_hasGooglePlayWebApkInstallDelegate( 315 return Java_WebApkInstaller_canUseGooglePlayInstallService(
316 env, java_ref_); 316 env, java_ref_);
317 } 317 }
318 318
319 bool WebApkInstaller::InstallOrUpdateWebApkFromGooglePlay( 319 bool WebApkInstaller::InstallOrUpdateWebApkFromGooglePlay(
320 const std::string& package_name, 320 const std::string& package_name,
321 int version, 321 int version,
322 const std::string& token) { 322 const std::string& token) {
323 webapk_package_ = package_name; 323 webapk_package_ = package_name;
324 324
325 JNIEnv* env = base::android::AttachCurrentThread(); 325 JNIEnv* env = base::android::AttachCurrentThread();
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 if (!signed_download_url.is_valid() || response->package_name().empty()) { 421 if (!signed_download_url.is_valid() || response->package_name().empty()) {
422 OnFailure(); 422 OnFailure();
423 return; 423 return;
424 } 424 }
425 425
426 if (HasGooglePlayWebApkInstallDelegate()) { 426 if (CanUseGooglePlayInstallService()) {
427 int version = 1; 427 int version = 1;
428 base::StringToInt(response->version(), &version); 428 base::StringToInt(response->version(), &version);
429 if (!InstallOrUpdateWebApkFromGooglePlay( 429 if (!InstallOrUpdateWebApkFromGooglePlay(
430 response->package_name(), version, response->token())) { 430 response->package_name(), version, response->token())) {
431 OnFailure(); 431 OnFailure();
432 } 432 }
433 return; 433 return;
434 } 434 }
435 435
436 OnGotWebApkDownloadUrl(signed_download_url, response->package_name()); 436 OnGotWebApkDownloadUrl(signed_download_url, response->package_name());
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 615
616 void WebApkInstaller::OnSuccess() { 616 void WebApkInstaller::OnSuccess() {
617 finish_callback_.Run(true, webapk_package_); 617 finish_callback_.Run(true, webapk_package_);
618 delete this; 618 delete this;
619 } 619 }
620 620
621 void WebApkInstaller::OnFailure() { 621 void WebApkInstaller::OnFailure() {
622 finish_callback_.Run(false, webapk_package_); 622 finish_callback_.Run(false, webapk_package_);
623 delete this; 623 delete this;
624 } 624 }
OLDNEW
« no previous file with comments | « chrome/browser/android/webapk/webapk_installer.h ('k') | chrome/browser/android/webapk/webapk_installer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698