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 <map> | |
9 #include <memory> | 10 #include <memory> |
10 | 11 |
11 #include "base/android/scoped_java_ref.h" | 12 #include "base/android/scoped_java_ref.h" |
12 #include "base/callback.h" | 13 #include "base/callback.h" |
13 #include "base/macros.h" | 14 #include "base/macros.h" |
14 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
15 #include "base/timer/timer.h" | 16 #include "base/timer/timer.h" |
16 #include "chrome/browser/android/shortcut_info.h" | 17 #include "chrome/browser/android/shortcut_info.h" |
17 #include "chrome/browser/net/file_downloader.h" | 18 #include "chrome/browser/net/file_downloader.h" |
18 #include "net/url_request/url_fetcher.h" | 19 #include "net/url_request/url_fetcher.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
58 // Same as InstallAsync() but uses the passed in |request_context_getter|. | 59 // Same as InstallAsync() but uses the passed in |request_context_getter|. |
59 void InstallAsyncWithURLRequestContextGetter( | 60 void InstallAsyncWithURLRequestContextGetter( |
60 net::URLRequestContextGetter* request_context_getter, | 61 net::URLRequestContextGetter* request_context_getter, |
61 const FinishCallback& finish_callback); | 62 const FinishCallback& finish_callback); |
62 | 63 |
63 // Talks to the Chrome WebAPK server to update a WebAPK on the server and to | 64 // Talks to the Chrome WebAPK server to update a WebAPK on the server and to |
64 // the Google Play server to install the downloaded WebAPK. Calls |callback| | 65 // the Google Play server to install the downloaded WebAPK. Calls |callback| |
65 // after the request to install the WebAPK is sent to the Google Play server. | 66 // after the request to install the WebAPK is sent to the Google Play server. |
66 void UpdateAsync(content::BrowserContext* browser_context, | 67 void UpdateAsync(content::BrowserContext* browser_context, |
67 const FinishCallback& callback, | 68 const FinishCallback& callback, |
68 const std::string& icon_murmur2_hash, | |
69 const std::string& webapk_package, | 69 const std::string& webapk_package, |
70 int webapk_version); | 70 int webapk_version, |
71 bool stale_manifest, | |
72 const std::map<std::string, std::string>& icon_url_hash_map); | |
pkotwicz
2016/12/07 20:41:30
Nit: Name this |icon_url_to_murmur2_hash_map| to m
Xi Han
2016/12/09 18:40:11
Done.
| |
71 | 73 |
72 // Same as UpdateAsync() but uses the passed in |request_context_getter|. | 74 // Same as UpdateAsync() but uses the passed in |request_context_getter|. |
73 void UpdateAsyncWithURLRequestContextGetter( | 75 void UpdateAsyncWithURLRequestContextGetter( |
74 net::URLRequestContextGetter* request_context_getter, | 76 net::URLRequestContextGetter* request_context_getter, |
75 const FinishCallback& callback, | 77 const FinishCallback& callback, |
76 const std::string& icon_murmur2_hash, | |
77 const std::string& webapk_package, | 78 const std::string& webapk_package, |
78 int webapk_version); | 79 int webapk_version, |
80 bool stale_manifest, | |
81 const std::map<std::string, std::string>& icon_url_hash_map); | |
79 | 82 |
80 // Sets the timeout for the server requests. | 83 // Sets the timeout for the server requests. |
81 void SetTimeoutMs(int timeout_ms); | 84 void SetTimeoutMs(int timeout_ms); |
82 | 85 |
83 // Called once the installation is complete or failed. | 86 // Called once the installation is complete or failed. |
84 void OnInstallFinished(JNIEnv* env, | 87 void OnInstallFinished(JNIEnv* env, |
85 const base::android::JavaParamRef<jobject>& obj, | 88 const base::android::JavaParamRef<jobject>& obj, |
86 jboolean success); | 89 jboolean success); |
87 | 90 |
88 // Registers JNI hooks. | 91 // Registers JNI hooks. |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
203 | 206 |
204 // Callback to call once WebApkInstaller succeeds or fails. | 207 // Callback to call once WebApkInstaller succeeds or fails. |
205 FinishCallback finish_callback_; | 208 FinishCallback finish_callback_; |
206 | 209 |
207 // Web Manifest info. | 210 // Web Manifest info. |
208 const ShortcutInfo shortcut_info_; | 211 const ShortcutInfo shortcut_info_; |
209 | 212 |
210 // WebAPK app icon. | 213 // WebAPK app icon. |
211 const SkBitmap shortcut_icon_; | 214 const SkBitmap shortcut_icon_; |
212 | 215 |
213 // Murmur2 hash of the bitmap at the app icon URL prior to any transformations | |
214 // being applied to the bitmap (such as encoding/decoding the icon bitmap). | |
215 std::string shortcut_icon_murmur2_hash_; | |
216 | |
217 // WebAPK server URL. | 216 // WebAPK server URL. |
218 GURL server_url_; | 217 GURL server_url_; |
219 | 218 |
220 // The number of milliseconds to wait for the WebAPK download URL from the | 219 // The number of milliseconds to wait for the WebAPK download URL from the |
221 // WebAPK server. | 220 // WebAPK server. |
222 int webapk_download_url_timeout_ms_; | 221 int webapk_download_url_timeout_ms_; |
223 | 222 |
224 // The number of milliseconds to wait for the WebAPK download to complete. | 223 // The number of milliseconds to wait for the WebAPK download to complete. |
225 int download_timeout_ms_; | 224 int download_timeout_ms_; |
226 | 225 |
227 // WebAPK package name. | 226 // WebAPK package name. |
228 std::string webapk_package_; | 227 std::string webapk_package_; |
229 | 228 |
230 // WebAPK version code. | 229 // WebAPK version code. |
231 int webapk_version_; | 230 int webapk_version_; |
232 | 231 |
233 // Indicates whether the installer is for installing or updating a WebAPK. | 232 // Indicates whether the installer is for installing or updating a WebAPK. |
234 TaskType task_type_; | 233 TaskType task_type_; |
235 | 234 |
236 // Points to the Java Object. | 235 // Points to the Java Object. |
237 base::android::ScopedJavaGlobalRef<jobject> java_ref_; | 236 base::android::ScopedJavaGlobalRef<jobject> java_ref_; |
238 | 237 |
239 // Used to get |weak_ptr_|. | 238 // Used to get |weak_ptr_|. |
240 base::WeakPtrFactory<WebApkInstaller> weak_ptr_factory_; | 239 base::WeakPtrFactory<WebApkInstaller> weak_ptr_factory_; |
241 | 240 |
242 DISALLOW_COPY_AND_ASSIGN(WebApkInstaller); | 241 DISALLOW_COPY_AND_ASSIGN(WebApkInstaller); |
243 }; | 242 }; |
244 | 243 |
245 #endif // CHROME_BROWSER_ANDROID_WEBAPK_WEBAPK_INSTALLER_H_ | 244 #endif // CHROME_BROWSER_ANDROID_WEBAPK_WEBAPK_INSTALLER_H_ |
OLD | NEW |