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 <map> |
10 #include <memory> | 10 #include <memory> |
(...skipping 25 matching lines...) Expand all Loading... |
36 | 36 |
37 // Talks to Chrome WebAPK server and Google Play to generate a WebAPK on the | 37 // Talks to Chrome WebAPK server and Google Play to generate a WebAPK on the |
38 // server, download it, and install it. The native WebApkInstaller owns the | 38 // server, download it, and install it. The native WebApkInstaller owns the |
39 // Java WebApkInstaller counterpart. | 39 // Java WebApkInstaller counterpart. |
40 class WebApkInstaller : public net::URLFetcherDelegate { | 40 class WebApkInstaller : public net::URLFetcherDelegate { |
41 public: | 41 public: |
42 // Called when the creation/updating of a WebAPK is finished or failed. | 42 // Called when the creation/updating of a WebAPK is finished or failed. |
43 // Parameters: | 43 // Parameters: |
44 // - whether the process succeeds. | 44 // - whether the process succeeds. |
45 // - the package name of the WebAPK. | 45 // - the package name of the WebAPK. |
46 using FinishCallback = base::Callback<void(bool, const std::string&)>; | 46 // - true if Chrome received a "request updates less frequently" directive |
| 47 // from the WebAPK server. |
| 48 using FinishCallback = base::Callback<void(bool, bool, const std::string&)>; |
47 | 49 |
48 ~WebApkInstaller() override; | 50 ~WebApkInstaller() override; |
49 | 51 |
50 // Creates a self-owned WebApkInstaller instance and talks to the Chrome | 52 // Creates a self-owned WebApkInstaller instance and talks to the Chrome |
51 // WebAPK server to generate a WebAPK on the server and to Google Play to | 53 // WebAPK server to generate a WebAPK on the server and to Google Play to |
52 // install the downloaded WebAPK. Calls |callback| once the install completed | 54 // install the downloaded WebAPK. Calls |callback| once the install completed |
53 // or failed. | 55 // or failed. |
54 static void InstallAsync(content::BrowserContext* context, | 56 static void InstallAsync(content::BrowserContext* context, |
55 const ShortcutInfo& shortcut_info, | 57 const ShortcutInfo& shortcut_info, |
56 const SkBitmap& shortcut_icon, | 58 const SkBitmap& shortcut_icon, |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 // The number of milliseconds to wait for the WebAPK download URL from the | 265 // The number of milliseconds to wait for the WebAPK download URL from the |
264 // WebAPK server. | 266 // WebAPK server. |
265 int webapk_download_url_timeout_ms_; | 267 int webapk_download_url_timeout_ms_; |
266 | 268 |
267 // The number of milliseconds to wait for the WebAPK download to complete. | 269 // The number of milliseconds to wait for the WebAPK download to complete. |
268 int download_timeout_ms_; | 270 int download_timeout_ms_; |
269 | 271 |
270 // WebAPK package name. | 272 // WebAPK package name. |
271 std::string webapk_package_; | 273 std::string webapk_package_; |
272 | 274 |
| 275 // Whether the server wants the WebAPK to request updates less frequently. |
| 276 bool relax_updates_; |
| 277 |
273 // WebAPK version code. | 278 // WebAPK version code. |
274 int webapk_version_; | 279 int webapk_version_; |
275 | 280 |
276 // Indicates whether the installer is for installing or updating a WebAPK. | 281 // Indicates whether the installer is for installing or updating a WebAPK. |
277 TaskType task_type_; | 282 TaskType task_type_; |
278 | 283 |
279 // Points to the Java Object. | 284 // Points to the Java Object. |
280 base::android::ScopedJavaGlobalRef<jobject> java_ref_; | 285 base::android::ScopedJavaGlobalRef<jobject> java_ref_; |
281 | 286 |
282 // Used to get |weak_ptr_|. | 287 // Used to get |weak_ptr_|. |
283 base::WeakPtrFactory<WebApkInstaller> weak_ptr_factory_; | 288 base::WeakPtrFactory<WebApkInstaller> weak_ptr_factory_; |
284 | 289 |
285 DISALLOW_COPY_AND_ASSIGN(WebApkInstaller); | 290 DISALLOW_COPY_AND_ASSIGN(WebApkInstaller); |
286 }; | 291 }; |
287 | 292 |
288 #endif // CHROME_BROWSER_ANDROID_WEBAPK_WEBAPK_INSTALLER_H_ | 293 #endif // CHROME_BROWSER_ANDROID_WEBAPK_WEBAPK_INSTALLER_H_ |
OLD | NEW |