Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(288)

Side by Side Diff: chrome/browser/android/webapk/webapk_install_service.h

Issue 2733543002: [Android:WebAPK] Don't add webapp to homescreen if WebAPK install times out part 1/3 (Closed)
Patch Set: Merge branch 'start' into refactor_shortcut_helper3 Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
16 #include "components/keyed_service/core/keyed_service.h" 15 #include "components/keyed_service/core/keyed_service.h"
17 #include "url/gurl.h" 16 #include "url/gurl.h"
18 17
19 namespace content { 18 namespace content {
20 class BrowserContext; 19 class BrowserContext;
21 } 20 }
22 21
23 struct ShortcutInfo; 22 struct ShortcutInfo;
24 class SkBitmap; 23 class SkBitmap;
25 24
25 // A Java counterpart will be generated for this enum.
26 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.chrome.browser.webapps
27 enum class WebApkInstallResult {
28 SUCCESS = 0,
29 FAILURE = 1,
30 // An install was initiated but it timed out. We did not get a response from
31 // Google Play (or the Android OS in the case of the "unknown sources" flow)
32 // so it is possible that the install will complete some time in the future.
33 PROBABLE_FAILURE = 2
34 };
35
26 // Service which talks to Chrome WebAPK server and Google Play to generate a 36 // Service which talks to Chrome WebAPK server and Google Play to generate a
27 // WebAPK on the server, download it, and install it. 37 // WebAPK on the server, download it, and install it.
28 class WebApkInstallService : public KeyedService { 38 class WebApkInstallService : public KeyedService {
29 public: 39 public:
30 using FinishCallback = WebApkInstaller::FinishCallback; 40 // Called when the creation/updating of a WebAPK is finished or failed.
41 // Parameters:
42 // - the result of the installation.
43 // - true if Chrome received a "request updates less frequently" directive.
44 // from the WebAPK server.
45 // - the package name of the WebAPK.
46 using FinishCallback =
47 base::Callback<void(WebApkInstallResult, bool, const std::string&)>;
31 48
32 static WebApkInstallService* Get(content::BrowserContext* browser_context); 49 static WebApkInstallService* Get(content::BrowserContext* browser_context);
33 50
34 explicit WebApkInstallService(content::BrowserContext* browser_context); 51 explicit WebApkInstallService(content::BrowserContext* browser_context);
35 ~WebApkInstallService() override; 52 ~WebApkInstallService() override;
36 53
37 // Returns whether an install for |web_manifest_url| is in progress. 54 // Returns whether an install for |web_manifest_url| is in progress.
38 bool IsInstallInProgress(const GURL& web_manifest_url); 55 bool IsInstallInProgress(const GURL& web_manifest_url);
39 56
40 // Talks to the Chrome WebAPK server to generate a WebAPK on the server and to 57 // Talks to the Chrome WebAPK server to generate a WebAPK on the server and to
(...skipping 12 matching lines...) Expand all
53 const std::string& webapk_package, 70 const std::string& webapk_package,
54 int webapk_version, 71 int webapk_version,
55 const std::map<std::string, std::string>& icon_url_to_murmur2_hash, 72 const std::map<std::string, std::string>& icon_url_to_murmur2_hash,
56 bool is_manifest_stale, 73 bool is_manifest_stale,
57 const FinishCallback& finish_callback); 74 const FinishCallback& finish_callback);
58 75
59 private: 76 private:
60 // Called once the install/update completed or failed. 77 // Called once the install/update completed or failed.
61 void OnFinishedInstall(const GURL& web_manifest_url, 78 void OnFinishedInstall(const GURL& web_manifest_url,
62 const FinishCallback& finish_callback, 79 const FinishCallback& finish_callback,
63 bool success, 80 WebApkInstallResult result,
64 bool relax_updates, 81 bool relax_updates,
65 const std::string& webapk_package_name); 82 const std::string& webapk_package_name);
66 83
67 content::BrowserContext* browser_context_; 84 content::BrowserContext* browser_context_;
68 85
69 // In progress installs. 86 // In progress installs.
70 std::set<GURL> installs_; 87 std::set<GURL> installs_;
71 88
72 // Used to get |weak_ptr_|. 89 // Used to get |weak_ptr_|.
73 base::WeakPtrFactory<WebApkInstallService> weak_ptr_factory_; 90 base::WeakPtrFactory<WebApkInstallService> weak_ptr_factory_;
74 91
75 DISALLOW_COPY_AND_ASSIGN(WebApkInstallService); 92 DISALLOW_COPY_AND_ASSIGN(WebApkInstallService);
76 }; 93 };
77 94
78 #endif // CHROME_BROWSER_ANDROID_WEBAPK_WEBAPK_INSTALL_SERVICE_H_ 95 #endif // CHROME_BROWSER_ANDROID_WEBAPK_WEBAPK_INSTALL_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698