| Index: chrome/browser/android/webapk/webapk_installer.h
|
| diff --git a/chrome/browser/android/webapk/webapk_installer.h b/chrome/browser/android/webapk/webapk_installer.h
|
| index 396549876cf4e4c026f538952f930544f75fb3df..2c09a974061e38122c402f1aac925b37345b2d22 100644
|
| --- a/chrome/browser/android/webapk/webapk_installer.h
|
| +++ b/chrome/browser/android/webapk/webapk_installer.h
|
| @@ -26,23 +26,34 @@ namespace content {
|
| class BrowserContext;
|
| }
|
|
|
| +namespace google {
|
| +namespace protobuf {
|
| +class MessageLite;
|
| +}
|
| +}
|
| +
|
| namespace net {
|
| class URLFetcher;
|
| class URLRequestContextGetter;
|
| }
|
|
|
| namespace webapk {
|
| -class CreateWebApkRequest;
|
| +class WebApk;
|
| }
|
|
|
| // Talks to Chrome WebAPK server and Google Play to generate a WebAPK on the
|
| // server, download it, and install it.
|
| class WebApkInstaller : public net::URLFetcherDelegate {
|
| public:
|
| + // Called when either a request of creating or updating WebAPK has been sent
|
| + // or the creation process of the WebAPK on the server side fails.
|
| + // Parameters:
|
| + // - whether the request succeeds.
|
| using FinishCallback = base::Callback<void(bool)>;
|
|
|
| WebApkInstaller(const ShortcutInfo& shortcut_info,
|
| const SkBitmap& shorcut_icon);
|
| +
|
| ~WebApkInstaller() override;
|
|
|
| // Register JNI methods.
|
| @@ -59,6 +70,15 @@ class WebApkInstaller : public net::URLFetcherDelegate {
|
| net::URLRequestContextGetter* request_context_getter,
|
| const FinishCallback& callback);
|
|
|
| + // Talks to the Chrome WebAPK server to update a WebAPK on the server and to
|
| + // the Google Play server to download and install the generated WebAPK. Calls
|
| + // |callback| after the request to download and install the WebAPK is sent to
|
| + // the Google Play server.
|
| + void UpdateAsync(content::BrowserContext* browser_context,
|
| + const FinishCallback& callback,
|
| + const std::string& webapk_package,
|
| + int version);
|
| +
|
| protected:
|
| // Starts installation of the downloaded WebAPK. Returns whether the install
|
| // could be started. The installation may still fail if true is returned.
|
| @@ -78,10 +98,18 @@ class WebApkInstaller : public net::URLFetcherDelegate {
|
| void InitializeRequestContextGetterOnUIThread(
|
| content::BrowserContext* browser_context);
|
|
|
| - // Sends request to WebAPK server to create WebAPK. During a successful
|
| - // request the WebAPK server responds with the URL of the generated WebAPK.
|
| + // Sends request to WebAPK server to create WebAPK.
|
| void SendCreateWebApkRequest();
|
|
|
| + // Sends request to WebAPK server to update a WebAPK.
|
| + void SendUpdateWebApkRequest();
|
| +
|
| + // Sends a request to WebAPK server. During a successful request the
|
| + // WebAPK server responds with a URL to send to Google Play to
|
| + // download and install the generated WebAPK.
|
| + void SendRequest(
|
| + std::unique_ptr<::google::protobuf::MessageLite> request_proto);
|
| +
|
| // Called with the URL of generated WebAPK and the package name that the
|
| // WebAPK should be installed at.
|
| void OnGotWebApkDownloadUrl(const std::string& download_url,
|
| @@ -95,8 +123,8 @@ class WebApkInstaller : public net::URLFetcherDelegate {
|
| const std::string& package_name,
|
| FileDownloader::Result result);
|
|
|
| - // Populates webapk::CreateWebApkRequest and returns it.
|
| - std::unique_ptr<webapk::CreateWebApkRequest> BuildCreateWebApkRequest();
|
| + // Populate the |webapk| field of a request.
|
| + void PopulateWebApkProto(webapk::WebApk* webapk);
|
|
|
| // Called when the request to the WebAPK server times out or when the WebAPK
|
| // download times out.
|
| @@ -135,6 +163,12 @@ class WebApkInstaller : public net::URLFetcherDelegate {
|
| // WebAPK server URL.
|
| GURL server_url_;
|
|
|
| + // WebAPK package name.
|
| + std::string webapk_package_;
|
| +
|
| + // WebAPK version code.
|
| + int version_;
|
| +
|
| // Used to get |weak_ptr_| on the IO thread.
|
| base::WeakPtrFactory<WebApkInstaller> io_weak_ptr_factory_;
|
|
|
|
|