| 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 <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "chrome/browser/android/webapk/webapk_installer.h" |
| 15 #include "components/keyed_service/core/keyed_service.h" | 16 #include "components/keyed_service/core/keyed_service.h" |
| 16 #include "url/gurl.h" | 17 #include "url/gurl.h" |
| 17 | 18 |
| 18 namespace content { | 19 namespace content { |
| 19 class BrowserContext; | 20 class BrowserContext; |
| 20 } | 21 } |
| 21 | 22 |
| 22 struct ShortcutInfo; | 23 struct ShortcutInfo; |
| 23 class SkBitmap; | 24 class SkBitmap; |
| 24 | 25 |
| 25 // Service which talks to Chrome WebAPK server and Google Play to generate a | 26 // Service which talks to Chrome WebAPK server and Google Play to generate a |
| 26 // WebAPK on the server, download it, and install it. | 27 // WebAPK on the server, download it, and install it. |
| 27 class WebApkInstallService : public KeyedService { | 28 class WebApkInstallService : public KeyedService { |
| 28 public: | 29 public: |
| 29 // Called when the creation/updating of a WebAPK is finished or failed. | 30 using FinishCallback = WebApkInstaller::FinishCallback; |
| 30 // Parameters: | 31 using FinishCallbackData = WebApkInstaller::FinishCallbackData; |
| 31 // - whether the process succeeds. | |
| 32 // - the package name of the WebAPK. | |
| 33 using FinishCallback = base::Callback<void(bool, const std::string&)>; | |
| 34 | 32 |
| 35 static WebApkInstallService* Get(content::BrowserContext* browser_context); | 33 static WebApkInstallService* Get(content::BrowserContext* browser_context); |
| 36 | 34 |
| 37 explicit WebApkInstallService(content::BrowserContext* browser_context); | 35 explicit WebApkInstallService(content::BrowserContext* browser_context); |
| 38 ~WebApkInstallService() override; | 36 ~WebApkInstallService() override; |
| 39 | 37 |
| 40 // Returns whether an install for |web_manifest_url| is in progress. | 38 // Returns whether an install for |web_manifest_url| is in progress. |
| 41 bool IsInstallInProgress(const GURL& web_manifest_url); | 39 bool IsInstallInProgress(const GURL& web_manifest_url); |
| 42 | 40 |
| 43 // Talks to the Chrome WebAPK server to generate a WebAPK on the server and to | 41 // Talks to the Chrome WebAPK server to generate a WebAPK on the server and to |
| (...skipping 13 matching lines...) Expand all Loading... |
| 57 int webapk_version, | 55 int webapk_version, |
| 58 const std::map<std::string, std::string>& icon_url_to_murmur2_hash, | 56 const std::map<std::string, std::string>& icon_url_to_murmur2_hash, |
| 59 bool is_manifest_stale, | 57 bool is_manifest_stale, |
| 60 const FinishCallback& finish_callback); | 58 const FinishCallback& finish_callback); |
| 61 | 59 |
| 62 private: | 60 private: |
| 63 // Called once the install/update completed or failed. | 61 // Called once the install/update completed or failed. |
| 64 void OnFinishedInstall(const GURL& web_manifest_url, | 62 void OnFinishedInstall(const GURL& web_manifest_url, |
| 65 const FinishCallback& finish_callback, | 63 const FinishCallback& finish_callback, |
| 66 bool success, | 64 bool success, |
| 67 const std::string& webapk_package_name); | 65 const FinishCallbackData& data); |
| 68 | 66 |
| 69 content::BrowserContext* browser_context_; | 67 content::BrowserContext* browser_context_; |
| 70 | 68 |
| 71 // In progress installs. | 69 // In progress installs. |
| 72 std::set<GURL> installs_; | 70 std::set<GURL> installs_; |
| 73 | 71 |
| 74 // Used to get |weak_ptr_|. | 72 // Used to get |weak_ptr_|. |
| 75 base::WeakPtrFactory<WebApkInstallService> weak_ptr_factory_; | 73 base::WeakPtrFactory<WebApkInstallService> weak_ptr_factory_; |
| 76 | 74 |
| 77 DISALLOW_COPY_AND_ASSIGN(WebApkInstallService); | 75 DISALLOW_COPY_AND_ASSIGN(WebApkInstallService); |
| 78 }; | 76 }; |
| 79 | 77 |
| 80 #endif // CHROME_BROWSER_ANDROID_WEBAPK_WEBAPK_INSTALL_SERVICE_H_ | 78 #endif // CHROME_BROWSER_ANDROID_WEBAPK_WEBAPK_INSTALL_SERVICE_H_ |
| OLD | NEW |