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

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

Issue 2746723002: [WebAPK] Refactor "unsigned sources" installation path (Closed)
Patch Set: Merge branch 'start0' into start Created 3 years, 9 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 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 base::Bind(&BuildWebApkProtoInBackground, shortcut_info_, shortcut_icon_, 286 base::Bind(&BuildWebApkProtoInBackground, shortcut_info_, shortcut_icon_,
287 icon_url_to_murmur2_hash, is_manifest_stale), 287 icon_url_to_murmur2_hash, is_manifest_stale),
288 base::Bind(&OnWebApkProtoBuilt, callback)); 288 base::Bind(&OnWebApkProtoBuilt, callback));
289 } 289 }
290 290
291 // static 291 // static
292 bool WebApkInstaller::Register(JNIEnv* env) { 292 bool WebApkInstaller::Register(JNIEnv* env) {
293 return RegisterNativesImpl(env); 293 return RegisterNativesImpl(env);
294 } 294 }
295 295
296 bool WebApkInstaller::StartInstallingDownloadedWebApk( 296 void WebApkInstaller::InstallDownloadedWebApk(
297 JNIEnv* env, 297 JNIEnv* env,
298 const base::android::ScopedJavaLocalRef<jstring>& java_file_path, 298 const base::android::ScopedJavaLocalRef<jstring>& java_file_path,
299 const base::android::ScopedJavaLocalRef<jstring>& java_package_name) { 299 const base::android::ScopedJavaLocalRef<jstring>& java_package_name) {
300 return Java_WebApkInstaller_installAsyncAndMonitorInstallationFromNative( 300 Java_WebApkInstaller_installDownloadedWebApkAsync(
301 env, java_ref_, java_file_path, java_package_name); 301 env, java_ref_, java_file_path, java_package_name);
302 } 302 }
303 303
304 bool WebApkInstaller::StartUpdateUsingDownloadedWebApk( 304 void WebApkInstaller::UpdateUsingDownloadedWebApk(
305 JNIEnv* env, 305 JNIEnv* env,
306 const base::android::ScopedJavaLocalRef<jstring>& java_file_path) { 306 const base::android::ScopedJavaLocalRef<jstring>& java_file_path) {
307 return Java_WebApkInstaller_updateAsyncFromNative(env, java_ref_, 307 Java_WebApkInstaller_updateUsingDownloadedWebApkAsync(env, java_ref_,
308 java_file_path); 308 java_file_path);
309 } 309 }
310 310
311 bool WebApkInstaller::CanUseGooglePlayInstallService() { 311 bool WebApkInstaller::CanUseGooglePlayInstallService() {
312 JNIEnv* env = base::android::AttachCurrentThread(); 312 JNIEnv* env = base::android::AttachCurrentThread();
313 return Java_WebApkInstaller_canUseGooglePlayInstallService(env, java_ref_); 313 return Java_WebApkInstaller_canUseGooglePlayInstallService(env, java_ref_);
314 } 314 }
315 315
316 void WebApkInstaller::InstallOrUpdateWebApkFromGooglePlay( 316 void WebApkInstaller::InstallOrUpdateWebApkFromGooglePlay(
317 const std::string& package_name, 317 const std::string& package_name,
318 int version, 318 int version,
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 if (!change_permission_success) { 598 if (!change_permission_success) {
599 OnFailure(); 599 OnFailure();
600 return; 600 return;
601 } 601 }
602 602
603 JNIEnv* env = base::android::AttachCurrentThread(); 603 JNIEnv* env = base::android::AttachCurrentThread();
604 base::android::ScopedJavaLocalRef<jstring> java_file_path = 604 base::android::ScopedJavaLocalRef<jstring> java_file_path =
605 base::android::ConvertUTF8ToJavaString(env, file_path.value()); 605 base::android::ConvertUTF8ToJavaString(env, file_path.value());
606 base::android::ScopedJavaLocalRef<jstring> java_package_name = 606 base::android::ScopedJavaLocalRef<jstring> java_package_name =
607 base::android::ConvertUTF8ToJavaString(env, webapk_package_); 607 base::android::ConvertUTF8ToJavaString(env, webapk_package_);
608 bool success = false;
609 if (task_type_ == INSTALL) { 608 if (task_type_ == INSTALL) {
610 success = 609 InstallDownloadedWebApk(env, java_file_path, java_package_name);
611 StartInstallingDownloadedWebApk(env, java_file_path, java_package_name); 610 return;
dominickn 2017/03/13 23:13:37 Nit: move the webapk_package_ conversion into the
612 } else if (task_type_ == UPDATE) {
613 success = StartUpdateUsingDownloadedWebApk(env, java_file_path);
614 if (success) {
615 // Since WebApkInstaller doesn't listen to WebAPKs' update events
616 // we call OnSuccess() as long as the update started successfully.
617 OnSuccess();
618 return;
619 }
620 } 611 }
621 if (!success) 612 UpdateUsingDownloadedWebApk(env, java_file_path);
622 OnFailure();
623 } 613 }
624 614
625 void WebApkInstaller::OnTimeout() { 615 void WebApkInstaller::OnTimeout() {
626 OnFailure(); 616 OnFailure();
627 } 617 }
628 618
629 void WebApkInstaller::OnSuccess() { 619 void WebApkInstaller::OnSuccess() {
630 finish_callback_.Run(true, relax_updates_, webapk_package_); 620 finish_callback_.Run(true, relax_updates_, webapk_package_);
631 delete this; 621 delete this;
632 } 622 }
633 623
634 void WebApkInstaller::OnFailure() { 624 void WebApkInstaller::OnFailure() {
635 finish_callback_.Run(false, relax_updates_, webapk_package_); 625 finish_callback_.Run(false, relax_updates_, webapk_package_);
636 delete this; 626 delete this;
637 } 627 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698