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

Unified Diff: chrome/browser/android/webapk/webapk_installer.cc

Issue 2515293004: Chrome talks to Play to install WebAPKs. (Closed)
Patch Set: Don't use play install in webapk_installer_unittest. Created 4 years 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/android/webapk/webapk_installer.cc
diff --git a/chrome/browser/android/webapk/webapk_installer.cc b/chrome/browser/android/webapk/webapk_installer.cc
index 3e09705476b1da17ff780250ded602ab8e8ab6dd..591257fd61b5197f3e76160666a5be414d37a1fc 100644
--- a/chrome/browser/android/webapk/webapk_installer.cc
+++ b/chrome/browser/android/webapk/webapk_installer.cc
@@ -4,6 +4,8 @@
#include "chrome/browser/android/webapk/webapk_installer.h"
+#include <stdlib.h>
pkotwicz 2016/12/02 22:27:04 Do you need this include?
Xi Han 2016/12/05 17:27:54 Done.
+
#include "base/android/build_info.h"
#include "base/android/jni_android.h"
#include "base/android/jni_string.h"
@@ -13,6 +15,7 @@
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/memory/ref_counted.h"
+#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
@@ -315,6 +318,11 @@ bool WebApkInstaller::StartUpdateUsingDownloadedWebApk(
env, java_ref_, java_file_path);
}
+bool WebApkInstaller::HasGooglePlayWebApkInstallDelegate() {
+ JNIEnv* env = base::android::AttachCurrentThread();
+ return Java_WebApkInstaller_hasGooglePlayWebApkInstallDelegate(env, java_ref_);
+}
+
void WebApkInstaller::OnURLFetchComplete(const net::URLFetcher* source) {
timer_.Stop();
@@ -339,6 +347,15 @@ void WebApkInstaller::OnURLFetchComplete(const net::URLFetcher* source) {
OnFailure();
return;
}
+
+ if (HasGooglePlayWebApkInstallDelegate()) {
+ int version = 1;
+ base::StringToInt(response->version(), &version);
+ InstallOrUpdateWebApkFromGooglePlay(
+ response->package_name(), version, response->token());
pkotwicz 2016/12/02 22:27:04 Once InstallOrUpdateWebApkFromGooglePlay() returns
Xi Han 2016/12/05 17:27:54 Done.
+ return;
+ }
+
OnGotWebApkDownloadUrl(signed_download_url, response->package_name());
}
@@ -410,6 +427,29 @@ void WebApkInstaller::SendRequest(std::unique_ptr<webapk::WebApk> request_proto,
url_fetcher_->Start();
}
+void WebApkInstaller::InstallOrUpdateWebApkFromGooglePlay(
+ const std::string& package_name,
+ int version,
+ const std::string& token) {
+ webapk_package_ = package_name;
+
+ JNIEnv* env = base::android::AttachCurrentThread();
+ base::android::ScopedJavaLocalRef<jstring> java_webapk_package =
+ base::android::ConvertUTF8ToJavaString(env, webapk_package_);
+ base::android::ScopedJavaLocalRef<jstring> java_title =
+ base::android::ConvertUTF16ToJavaString(env, shortcut_info_.user_title);
+ base::android::ScopedJavaLocalRef<jstring> java_token =
+ base::android::ConvertUTF8ToJavaString(env, token);
+
+ if (task_type_ == WebApkInstaller::INSTALL) {
+ Java_WebApkInstaller_installWebApkFromPlayStoreAsyncAndMonitorInstallation(
+ env, java_ref_, java_webapk_package, version, java_title, java_token);
+ } else {
+ Java_WebApkInstaller_updateAsyncFromPlayStore(
+ env, java_ref_, java_webapk_package, version, java_title, java_token);
+ }
+}
+
void WebApkInstaller::OnGotWebApkDownloadUrl(const GURL& download_url,
const std::string& package_name) {
webapk_package_ = package_name;

Powered by Google App Engine
This is Rietveld 408576698