Index: chrome/browser/android/webapk/webapk_installer.h |
diff --git a/chrome/browser/android/webapk/webapk_installer.h b/chrome/browser/android/webapk/webapk_installer.h |
index 36196692ccc4c5711ce3ba02e344a0dfbb46f665..b8feb9fc0d65337e00c3d44c8ea651c830a91cee 100644 |
--- a/chrome/browser/android/webapk/webapk_installer.h |
+++ b/chrome/browser/android/webapk/webapk_installer.h |
@@ -37,11 +37,11 @@ class WebApkIconHasher; |
// server, download it, and install it. |
class WebApkInstaller : public net::URLFetcherDelegate { |
public: |
- // Called when either a request for creating/updating a WebAPK has been sent |
- // to Google Play or the create/update process fails. |
+ // Called when the creation/updating of a WebAPK is finished or failed. |
// Parameters: |
- // - whether the request succeeds. |
- using FinishCallback = base::Callback<void(bool)>; |
+ // - whether the process succeeds. |
+ // - the package name of the WebAPK. |
+ using FinishCallback = base::Callback<void(bool, const std::string&)>; |
WebApkInstaller(const ShortcutInfo& shortcut_info, |
const SkBitmap& shorcut_icon); |
@@ -52,12 +52,12 @@ class WebApkInstaller : public net::URLFetcherDelegate { |
// Google Play to install the downloaded WebAPK. Calls |callback| after the |
// request to install the WebAPK is sent to Google Play. |
void InstallAsync(content::BrowserContext* browser_context, |
- const FinishCallback& callback); |
+ const FinishCallback& finish_callback); |
// Same as InstallAsync() but uses the passed in |request_context_getter|. |
void InstallAsyncWithURLRequestContextGetter( |
net::URLRequestContextGetter* request_context_getter, |
- const FinishCallback& callback); |
+ const FinishCallback& finish_callback); |
// Talks to the Chrome WebAPK server to update a WebAPK on the server and to |
// the Google Play server to install the downloaded WebAPK. Calls |callback| |
@@ -79,6 +79,14 @@ class WebApkInstaller : public net::URLFetcherDelegate { |
// Sets the timeout for the server requests. |
void SetTimeoutMs(int timeout_ms); |
+ // Registers JNI hooks. |
+ static bool Register(JNIEnv* env); |
+ |
+ // Called once the installation is complete or failed. |
+ void OnInstallFinished(JNIEnv* env, |
+ const base::android::JavaParamRef<jobject>& obj, |
+ jboolean success); |
+ |
protected: |
// Starts installation of the downloaded WebAPK. Returns whether the install |
// could be started. The installation may still fail if true is returned. |
@@ -105,6 +113,9 @@ class WebApkInstaller : public net::URLFetcherDelegate { |
UPDATE, |
}; |
+ // Create the Java object. |
+ void CreateJavaRef(); |
+ |
// net::URLFetcherDelegate: |
void OnURLFetchComplete(const net::URLFetcher* source) override; |
@@ -154,6 +165,9 @@ class WebApkInstaller : public net::URLFetcherDelegate { |
const std::string& package_name, |
bool change_permission_success); |
+ // A helper function called once the installation is compelete or failed. |
+ void OnInstallFinished(bool success); |
+ |
// Called when the request to the WebAPK server times out or when the WebAPK |
// download times out. |
void OnTimeout(); |
@@ -214,6 +228,9 @@ class WebApkInstaller : public net::URLFetcherDelegate { |
// Indicates whether the installer is for installing or updating a WebAPK. |
TaskType task_type_; |
+ // Points to the Java Object. |
+ base::android::ScopedJavaGlobalRef<jobject> java_ref_; |
+ |
// Used to get |weak_ptr_|. |
base::WeakPtrFactory<WebApkInstaller> weak_ptr_factory_; |