Chromium Code Reviews| 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..15741306c9b0fbe1a2c1ff2fa832e715b0702d29 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. |
|
gone
2016/08/29 17:24:09
Indicate that the native side WebApkInstaller owns
Xi Han
2016/08/29 17:55:46
Done.
|
| 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); |
| + // Called once the installation is complete or failed. |
| + void OnInstallFinished(JNIEnv* env, |
| + const base::android::JavaParamRef<jobject>& obj, |
| + jboolean success); |
| + |
| + // Registers JNI hooks. |
| + static bool Register(JNIEnv* env); |
| + |
| protected: |
| // Starts installation of the downloaded WebAPK. Returns whether the install |
| // could be started. The installation may still fail if true is returned. |
| @@ -98,6 +106,9 @@ class WebApkInstaller : public net::URLFetcherDelegate { |
| const base::android::ScopedJavaLocalRef<jstring>& java_file_path, |
| const base::android::ScopedJavaLocalRef<jstring>& java_package_name); |
| + // Called when the request to install the WebAPK is sent to Google Play. |
| + void OnSuccess(); |
| + |
| private: |
| enum TaskType { |
| UNDEFINED, |
| @@ -105,6 +116,9 @@ class WebApkInstaller : public net::URLFetcherDelegate { |
| UPDATE, |
| }; |
| + // Create the Java object. |
| + void CreateJavaRef(); |
| + |
| // net::URLFetcherDelegate: |
| void OnURLFetchComplete(const net::URLFetcher* source) override; |
| @@ -139,28 +153,21 @@ class WebApkInstaller : public net::URLFetcherDelegate { |
| // Called once the WebAPK has been downloaded. Makes the downloaded WebAPK |
| // world readable and installs the WebAPK if the download was successful. |
| // |file_path| is the file path that the WebAPK was downloaded to. |
| - // |package_name| is the package name that the WebAPK should be installed at. |
| void OnWebApkDownloaded(const base::FilePath& file_path, |
| - const std::string& package_name, |
| FileDownloader::Result result); |
| // Called once the downloaded WebAPK has been made world readable. Installs |
| // the WebAPK. |
| // |file_path| is the file path that the WebAPK was downloaded to. |
| - // |package_name| is the package name that the WebAPK should be installed at. |
| // |change_permission_success| is whether the WebAPK could be made world |
| // readable. |
| void OnWebApkMadeWorldReadable(const base::FilePath& file_path, |
| - const std::string& package_name, |
| bool change_permission_success); |
| // Called when the request to the WebAPK server times out or when the WebAPK |
| // download times out. |
| void OnTimeout(); |
| - // Called when the request to install the WebAPK is sent to Google Play. |
| - void OnSuccess(); |
| - |
| // Called if a WebAPK could not be created. WebApkInstaller only tracks the |
| // WebAPK creation and the WebAPK download. It does not track the |
| // WebAPK installation. OnFailure() is not called if the WebAPK could not be |
| @@ -214,6 +221,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_; |