| OLD | NEW |
| 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 #ifndef CHROME_BROWSER_ANDROID_WEBAPK_WEBAPK_INSTALLER_H_ | 5 #ifndef CHROME_BROWSER_ANDROID_WEBAPK_WEBAPK_INSTALLER_H_ |
| 6 #define CHROME_BROWSER_ANDROID_WEBAPK_WEBAPK_INSTALLER_H_ | 6 #define CHROME_BROWSER_ANDROID_WEBAPK_WEBAPK_INSTALLER_H_ |
| 7 | 7 |
| 8 #include <jni.h> | 8 #include <jni.h> |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 const base::android::ScopedJavaLocalRef<jstring>& java_file_path, | 98 const base::android::ScopedJavaLocalRef<jstring>& java_file_path, |
| 99 const base::android::ScopedJavaLocalRef<jstring>& java_package_name); | 99 const base::android::ScopedJavaLocalRef<jstring>& java_package_name); |
| 100 | 100 |
| 101 // Starts update using the downloaded WebAPK. Returns whether the updating | 101 // Starts update using the downloaded WebAPK. Returns whether the updating |
| 102 // could be started. The updating may still fail if true is returned. | 102 // could be started. The updating may still fail if true is returned. |
| 103 // |file_path| is the file path that the WebAPK was downloaded to. | 103 // |file_path| is the file path that the WebAPK was downloaded to. |
| 104 virtual bool StartUpdateUsingDownloadedWebApk( | 104 virtual bool StartUpdateUsingDownloadedWebApk( |
| 105 JNIEnv* env, | 105 JNIEnv* env, |
| 106 const base::android::ScopedJavaLocalRef<jstring>& java_file_path); | 106 const base::android::ScopedJavaLocalRef<jstring>& java_file_path); |
| 107 | 107 |
| 108 // Returns whether installing WebAPKs using Google Play is enabled. |
| 109 virtual bool HasGooglePlayWebApkInstallDelegate(); |
| 110 |
| 108 // Called when the request to install the WebAPK is sent to Google Play. | 111 // Called when the request to install the WebAPK is sent to Google Play. |
| 109 void OnSuccess(); | 112 void OnSuccess(); |
| 110 | 113 |
| 111 private: | 114 private: |
| 112 enum TaskType { | 115 enum TaskType { |
| 113 UNDEFINED, | 116 UNDEFINED, |
| 114 INSTALL, | 117 INSTALL, |
| 115 UPDATE, | 118 UPDATE, |
| 116 }; | 119 }; |
| 117 | 120 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 136 // request the WebAPK server responds with the URL of the generated WebAPK. | 139 // request the WebAPK server responds with the URL of the generated WebAPK. |
| 137 // |webapk| is the proto to send to the WebAPK server. | 140 // |webapk| is the proto to send to the WebAPK server. |
| 138 void SendUpdateWebApkRequest(std::unique_ptr<webapk::WebApk> webapk_proto); | 141 void SendUpdateWebApkRequest(std::unique_ptr<webapk::WebApk> webapk_proto); |
| 139 | 142 |
| 140 // Sends a request to WebAPK server to create/update WebAPK. During a | 143 // Sends a request to WebAPK server to create/update WebAPK. During a |
| 141 // successful request the WebAPK server responds with the URL of the generated | 144 // successful request the WebAPK server responds with the URL of the generated |
| 142 // WebAPK. | 145 // WebAPK. |
| 143 void SendRequest(std::unique_ptr<webapk::WebApk> request_proto, | 146 void SendRequest(std::unique_ptr<webapk::WebApk> request_proto, |
| 144 const GURL& server_url); | 147 const GURL& server_url); |
| 145 | 148 |
| 149 // Called when the package name of the WebAPK is available and the install |
| 150 // or update request is handled by Google Play. |
| 151 void InstallOrUpdateWebApkFromGooglePlay(const std::string& package_name, |
| 152 int version, |
| 153 const std::string& token); |
| 154 |
| 146 // Called with the URL of generated WebAPK and the package name that the | 155 // Called with the URL of generated WebAPK and the package name that the |
| 147 // WebAPK should be installed at. | 156 // WebAPK should be installed at. |
| 148 void OnGotWebApkDownloadUrl(const GURL& download_url, | 157 void OnGotWebApkDownloadUrl(const GURL& download_url, |
| 149 const std::string& package_name); | 158 const std::string& package_name); |
| 150 | 159 |
| 151 // Downloads the WebAPK from the given |download_url|. | 160 // Downloads the WebAPK from the given |download_url|. |
| 152 void DownloadWebApk(const base::FilePath& output_path, | 161 void DownloadWebApk(const base::FilePath& output_path, |
| 153 const GURL& download_url, | 162 const GURL& download_url, |
| 154 bool retry_if_fails); | 163 bool retry_if_fails); |
| 155 | 164 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 // Points to the Java Object. | 245 // Points to the Java Object. |
| 237 base::android::ScopedJavaGlobalRef<jobject> java_ref_; | 246 base::android::ScopedJavaGlobalRef<jobject> java_ref_; |
| 238 | 247 |
| 239 // Used to get |weak_ptr_|. | 248 // Used to get |weak_ptr_|. |
| 240 base::WeakPtrFactory<WebApkInstaller> weak_ptr_factory_; | 249 base::WeakPtrFactory<WebApkInstaller> weak_ptr_factory_; |
| 241 | 250 |
| 242 DISALLOW_COPY_AND_ASSIGN(WebApkInstaller); | 251 DISALLOW_COPY_AND_ASSIGN(WebApkInstaller); |
| 243 }; | 252 }; |
| 244 | 253 |
| 245 #endif // CHROME_BROWSER_ANDROID_WEBAPK_WEBAPK_INSTALLER_H_ | 254 #endif // CHROME_BROWSER_ANDROID_WEBAPK_WEBAPK_INSTALLER_H_ |
| OLD | NEW |