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

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

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