Commit 8cfc2b47 authored by Peter Kotwicz's avatar Peter Kotwicz Committed by Commit Bot

Android WebAPK: Remove URL parameter from WebApkInstaller API part 2/3

Google Play no longer needs the URL parameter. The URL parameter used to be
used in the notification displayed by Google Play while the WebAPK was being
installed. Google Play no longer displays a notification while a WebAPK is
being installed.

BUG=713655

Change-Id: I1e60fc47dd09a971526791ac9be3bd728a04768a
Reviewed-on: https://chromium-review.googlesource.com/647876
Commit-Queue: Peter Kotwicz <pkotwicz@chromium.org>
Reviewed-by: default avatarYaron Friedman <yfriedman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#499965}
parent 8c577b8e
......@@ -16,10 +16,9 @@ public interface GooglePlayWebApkInstallDelegate {
* @param version The version of WebAPK to install.
* @param title The title of the WebAPK to display during installation.
* @param token The token from WebAPK Minter Server.
* @param url The start URL of the WebAPK to install.
* @param callback The callback to invoke when the install completes, times out or fails.
*/
void installAsync(String packageName, int version, String title, String token, String url,
void installAsync(String packageName, int version, String title, String token,
Callback<Integer> callback);
/**
......@@ -28,9 +27,8 @@ public interface GooglePlayWebApkInstallDelegate {
* @param version The version of WebAPK to update.
* @param title The title of the WebAPK to display during update.
* @param token The token from WebAPK Minter Server.
* @param url The start URL of the WebAPK to update.
* @param callback The callback to invoke when the update completes, times out or fails.
*/
void updateAsync(String packageName, int version, String title, String token, String url,
void updateAsync(String packageName, int version, String title, String token,
Callback<Integer> callback);
}
......@@ -50,14 +50,13 @@ public class WebApkInstaller {
* @param version The version of WebAPK to install.
* @param title The title of the WebAPK to display during installation.
* @param token The token from WebAPK Server.
* @param url The start URL of the WebAPK to install.
* @param source The source (either app banner or menu) that the install of a WebAPK was
* triggered.
* @param icon The primary icon of the WebAPK to install.
*/
@CalledByNative
private void installWebApkAsync(final String packageName, int version, final String title,
String token, final String url, final int source, final Bitmap icon) {
String token, final int source, final Bitmap icon) {
// Check whether the WebAPK package is already installed. The WebAPK may have been installed
// by another Chrome version (e.g. Chrome Dev). We have to do this check because the Play
// install API fails silently if the package is already installed.
......@@ -91,7 +90,7 @@ public class WebApkInstaller {
});
}
};
mInstallDelegate.installAsync(packageName, version, title, token, url, callback);
mInstallDelegate.installAsync(packageName, version, title, token, callback);
}
private void notify(@WebApkInstallResult int result) {
......@@ -106,11 +105,10 @@ public class WebApkInstaller {
* @param version The version of WebAPK to install.
* @param title The title of the WebAPK to display during installation.
* @param token The token from WebAPK Server.
* @param url The start URL of the WebAPK to install.
*/
@CalledByNative
private void updateAsync(
String packageName, int version, String title, String token, String url) {
String packageName, int version, String title, String token) {
if (mInstallDelegate == null) {
notify(WebApkInstallResult.FAILURE);
return;
......@@ -122,7 +120,7 @@ public class WebApkInstaller {
WebApkInstaller.this.notify(result);
}
};
mInstallDelegate.updateAsync(packageName, version, title, token, url, callback);
mInstallDelegate.updateAsync(packageName, version, title, token, callback);
}
private boolean isWebApkInstalled(String packageName) {
......
......@@ -278,8 +278,7 @@ public class WebApkUpdateManager implements WebApkUpdateDataFetcher.Observer {
WebApkVersion.CURRENT_SHELL_APK_VERSION);
}
};
nativeUpdateWebApk(info.webApkPackageName(), info.manifestStartUrl(), info.shortName(),
serializedProto, callback);
nativeUpdateWebApk(info.webApkPackageName(), info.shortName(), serializedProto, callback);
}
/**
......@@ -418,6 +417,6 @@ public class WebApkUpdateManager implements WebApkUpdateDataFetcher.Observer {
int displayMode, int orientation, long themeColor, long backgroundColor,
String manifestUrl, String webApkPackage, int webApkVersion, boolean isManifestStale,
Callback<byte[]> callback);
private static native void nativeUpdateWebApk(String webApkPackage, String startUrl,
String shortName, byte[] serializedProto, WebApkUpdateCallback callback);
private static native void nativeUpdateWebApk(String webApkPackage, String shortName,
byte[] serializedProto, WebApkUpdateCallback callback);
}
......@@ -60,13 +60,11 @@ void WebApkInstallService::InstallAsync(content::WebContents* web_contents,
void WebApkInstallService::UpdateAsync(
const std::string& webapk_package,
const GURL& start_url,
const base::string16& short_name,
std::unique_ptr<std::vector<uint8_t>> serialized_proto,
const FinishCallback& finish_callback) {
WebApkInstaller::UpdateAsync(browser_context_, webapk_package, start_url,
short_name, std::move(serialized_proto),
finish_callback);
WebApkInstaller::UpdateAsync(browser_context_, webapk_package, short_name,
std::move(serialized_proto), finish_callback);
}
void WebApkInstallService::OnFinishedInstall(
......
......@@ -73,7 +73,6 @@ class WebApkInstallService : public KeyedService {
// the Google Play server to install the downloaded WebAPK. Calls
// |finish_callback| once the update completed or failed.
void UpdateAsync(const std::string& webapk_package,
const GURL& start_url,
const base::string16& short_name,
std::unique_ptr<std::vector<uint8_t>> serialized_proto,
const FinishCallback& finish_callback);
......
......@@ -214,13 +214,12 @@ void WebApkInstaller::InstallAsync(content::BrowserContext* context,
void WebApkInstaller::UpdateAsync(
content::BrowserContext* context,
const std::string& webapk_package,
const GURL& start_url,
const base::string16& short_name,
std::unique_ptr<std::vector<uint8_t>> serialized_proto,
const FinishCallback& finish_callback) {
// The installer will delete itself when it is done.
WebApkInstaller* installer = new WebApkInstaller(context);
installer->UpdateAsync(webapk_package, start_url, short_name,
installer->UpdateAsync(webapk_package, short_name,
std::move(serialized_proto), finish_callback);
}
......@@ -237,11 +236,10 @@ void WebApkInstaller::InstallAsyncForTesting(WebApkInstaller* installer,
void WebApkInstaller::UpdateAsyncForTesting(
WebApkInstaller* installer,
const std::string& webapk_package,
const GURL& start_url,
const base::string16& short_name,
std::unique_ptr<std::vector<uint8_t>> serialized_proto,
const FinishCallback& finish_callback) {
installer->UpdateAsync(webapk_package, start_url, short_name,
installer->UpdateAsync(webapk_package, short_name,
std::move(serialized_proto), finish_callback);
}
......@@ -287,8 +285,6 @@ void WebApkInstaller::InstallOrUpdateWebApk(const std::string& package_name,
base::android::ConvertUTF16ToJavaString(env, short_name_);
base::android::ScopedJavaLocalRef<jstring> java_token =
base::android::ConvertUTF8ToJavaString(env, token);
base::android::ScopedJavaLocalRef<jstring> java_url =
base::android::ConvertUTF8ToJavaString(env, start_url_.spec());
if (task_type_ == WebApkInstaller::INSTALL) {
webapk::TrackRequestTokenDuration(install_duration_timer_->Elapsed());
......@@ -296,10 +292,10 @@ void WebApkInstaller::InstallOrUpdateWebApk(const std::string& package_name,
gfx::ConvertToJavaBitmap(&install_primary_icon_);
Java_WebApkInstaller_installWebApkAsync(
env, java_ref_, java_webapk_package, version, java_title, java_token,
java_url, install_shortcut_info_->source, java_primary_icon);
install_shortcut_info_->source, java_primary_icon);
} else {
Java_WebApkInstaller_updateAsync(env, java_ref_, java_webapk_package,
version, java_title, java_token, java_url);
version, java_title, java_token);
}
}
......@@ -346,7 +342,6 @@ void WebApkInstaller::InstallAsync(const ShortcutInfo& shortcut_info,
install_shortcut_info_.reset(new ShortcutInfo(shortcut_info));
install_primary_icon_ = primary_icon;
install_badge_icon_ = badge_icon;
start_url_ = shortcut_info.url;
short_name_ = shortcut_info.short_name;
finish_callback_ = finish_callback;
task_type_ = INSTALL;
......@@ -367,12 +362,10 @@ void WebApkInstaller::InstallAsync(const ShortcutInfo& shortcut_info,
void WebApkInstaller::UpdateAsync(
const std::string& webapk_package,
const GURL& start_url,
const base::string16& short_name,
std::unique_ptr<std::vector<uint8_t>> serialized_proto,
const FinishCallback& finish_callback) {
webapk_package_ = webapk_package;
start_url_ = start_url;
short_name_ = short_name;
finish_callback_ = finish_callback;
task_type_ = UPDATE;
......
......@@ -54,7 +54,6 @@ class WebApkInstaller : public net::URLFetcherDelegate {
static void UpdateAsync(
content::BrowserContext* context,
const std::string& webapk_package,
const GURL& start_url,
const base::string16& short_name,
std::unique_ptr<std::vector<uint8_t>> serialized_proto,
const FinishCallback& callback);
......@@ -72,7 +71,6 @@ class WebApkInstaller : public net::URLFetcherDelegate {
static void UpdateAsyncForTesting(
WebApkInstaller* installer,
const std::string& webapk_package,
const GURL& start_url,
const base::string16& short_name,
std::unique_ptr<std::vector<uint8_t>> serialized_proto,
const FinishCallback& callback);
......@@ -132,7 +130,6 @@ class WebApkInstaller : public net::URLFetcherDelegate {
// the Google Play server to install the downloaded WebAPK. Calls
// |finish_callback| once the update completed or failed.
void UpdateAsync(const std::string& webapk_package,
const GURL& start_url,
const base::string16& short_name,
const std::unique_ptr<std::vector<uint8_t>> serialized_proto,
const FinishCallback& callback);
......
......@@ -124,8 +124,7 @@ class WebApkInstallerRunner {
WebApkInstaller::UpdateAsyncForTesting(
CreateWebApkInstaller(), kDownloadedWebApkPackageName,
GURL() /* start_url */, base::string16() /* short_name */,
std::move(serialized_proto_vector),
base::string16() /* short_name */, std::move(serialized_proto_vector),
base::Bind(&WebApkInstallerRunner::OnCompleted,
base::Unretained(this)));
......
......@@ -129,7 +129,6 @@ static void BuildUpdateWebApkProto(
static void UpdateWebApk(JNIEnv* env,
const JavaParamRef<jclass>& clazz,
const JavaParamRef<jstring>& java_webapk_package,
const JavaParamRef<jstring>& java_start_url,
const JavaParamRef<jstring>& java_short_name,
const JavaParamRef<jbyteArray>& java_serialized_proto,
const JavaParamRef<jobject>& java_callback) {
......@@ -148,13 +147,12 @@ static void UpdateWebApk(JNIEnv* env,
std::string webapk_package =
ConvertJavaStringToUTF8(env, java_webapk_package);
GURL start_url = GURL(ConvertJavaStringToUTF8(env, java_start_url));
base::string16 short_name = ConvertJavaStringToUTF16(env, java_short_name);
std::unique_ptr<std::vector<uint8_t>> serialized_proto =
base::MakeUnique<std::vector<uint8_t>>();
JavaByteArrayToByteVector(env, java_serialized_proto, serialized_proto.get());
WebApkInstallService::Get(profile)->UpdateAsync(
webapk_package, start_url, short_name, std::move(serialized_proto),
webapk_package, short_name, std::move(serialized_proto),
base::Bind(&OnUpdated, callback_ref));
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment