| 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_INSTALL_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_ANDROID_WEBAPK_WEBAPK_INSTALL_SERVICE_H_ |
| 6 #define CHROME_BROWSER_ANDROID_WEBAPK_WEBAPK_INSTALL_SERVICE_H_ | 6 #define CHROME_BROWSER_ANDROID_WEBAPK_WEBAPK_INSTALL_SERVICE_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <set> | 10 #include <set> |
| 11 #include <string> | 11 #include <string> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/callback.h" | 14 #include "base/callback.h" |
| 15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
| 17 #include "base/strings/string16.h" | 17 #include "base/strings/string16.h" |
| 18 #include "components/keyed_service/core/keyed_service.h" | 18 #include "components/keyed_service/core/keyed_service.h" |
| 19 #include "url/gurl.h" | 19 #include "url/gurl.h" |
| 20 | 20 |
| 21 namespace base { |
| 22 class FilePath; |
| 23 } |
| 24 |
| 21 namespace content { | 25 namespace content { |
| 22 class BrowserContext; | 26 class BrowserContext; |
| 23 } | 27 } |
| 24 | 28 |
| 25 struct ShortcutInfo; | 29 struct ShortcutInfo; |
| 26 class SkBitmap; | 30 class SkBitmap; |
| 27 | 31 |
| 28 // A Java counterpart will be generated for this enum. | 32 // A Java counterpart will be generated for this enum. |
| 29 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.chrome.browser.webapps | 33 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.chrome.browser.webapps |
| 30 enum class WebApkInstallResult { | 34 enum class WebApkInstallResult { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 59 | 63 |
| 60 // Talks to the Chrome WebAPK server to generate a WebAPK on the server and to | 64 // Talks to the Chrome WebAPK server to generate a WebAPK on the server and to |
| 61 // Google Play to install the downloaded WebAPK. Calls |callback| once the | 65 // Google Play to install the downloaded WebAPK. Calls |callback| once the |
| 62 // install completed or failed. | 66 // install completed or failed. |
| 63 void InstallAsync(const ShortcutInfo& shortcut_info, | 67 void InstallAsync(const ShortcutInfo& shortcut_info, |
| 64 const SkBitmap& primary_icon, | 68 const SkBitmap& primary_icon, |
| 65 const SkBitmap& badge_icon, | 69 const SkBitmap& badge_icon, |
| 66 const FinishCallback& finish_callback); | 70 const FinishCallback& finish_callback); |
| 67 | 71 |
| 68 // Talks to the Chrome WebAPK server to update a WebAPK on the server and to | 72 // Talks to the Chrome WebAPK server to update a WebAPK on the server and to |
| 69 // the Google Play server to install the downloaded WebAPK. Calls | 73 // the Google Play server to install the downloaded WebAPK. |
| 70 // |finish_callback| once the update completed or failed. | 74 // |update_request_file_path| is the path of the file with the update request. |
| 71 void UpdateAsync(const std::string& webapk_package, | 75 // Calls |finish_callback| once the update completed or failed. |
| 72 const GURL& start_url, | 76 void UpdateAsync(const base::FilePath& update_request_file, |
| 73 const base::string16& short_name, | |
| 74 std::unique_ptr<std::vector<uint8_t>> serialized_proto, | |
| 75 const FinishCallback& finish_callback); | 77 const FinishCallback& finish_callback); |
| 76 | 78 |
| 77 private: | 79 private: |
| 78 // Called once the install/update completed or failed. | 80 // Called once the install/update completed or failed. |
| 79 void OnFinishedInstall(const GURL& web_manifest_url, | 81 void OnFinishedInstall(const GURL& web_manifest_url, |
| 80 const FinishCallback& finish_callback, | 82 const FinishCallback& finish_callback, |
| 81 WebApkInstallResult result, | 83 WebApkInstallResult result, |
| 82 bool relax_updates, | 84 bool relax_updates, |
| 83 const std::string& webapk_package_name); | 85 const std::string& webapk_package_name); |
| 84 | 86 |
| 85 content::BrowserContext* browser_context_; | 87 content::BrowserContext* browser_context_; |
| 86 | 88 |
| 87 // In progress installs. | 89 // In progress installs. |
| 88 std::set<GURL> installs_; | 90 std::set<GURL> installs_; |
| 89 | 91 |
| 90 // Used to get |weak_ptr_|. | 92 // Used to get |weak_ptr_|. |
| 91 base::WeakPtrFactory<WebApkInstallService> weak_ptr_factory_; | 93 base::WeakPtrFactory<WebApkInstallService> weak_ptr_factory_; |
| 92 | 94 |
| 93 DISALLOW_COPY_AND_ASSIGN(WebApkInstallService); | 95 DISALLOW_COPY_AND_ASSIGN(WebApkInstallService); |
| 94 }; | 96 }; |
| 95 | 97 |
| 96 #endif // CHROME_BROWSER_ANDROID_WEBAPK_WEBAPK_INSTALL_SERVICE_H_ | 98 #endif // CHROME_BROWSER_ANDROID_WEBAPK_WEBAPK_INSTALL_SERVICE_H_ |
| OLD | NEW |