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

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

Issue 2676863002: Update WebApkInstaller to support badge icon in installation. (Closed)
Patch Set: Rebase Created 3 years, 8 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_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 30 matching lines...) Expand all
41 using FinishCallback = WebApkInstallService::FinishCallback; 41 using FinishCallback = WebApkInstallService::FinishCallback;
42 42
43 ~WebApkInstaller() override; 43 ~WebApkInstaller() override;
44 44
45 // Creates a self-owned WebApkInstaller instance and talks to the Chrome 45 // Creates a self-owned WebApkInstaller instance and talks to the Chrome
46 // WebAPK server to generate a WebAPK on the server and to Google Play to 46 // WebAPK server to generate a WebAPK on the server and to Google Play to
47 // install the downloaded WebAPK. Calls |callback| once the install completed 47 // install the downloaded WebAPK. Calls |callback| once the install completed
48 // or failed. 48 // or failed.
49 static void InstallAsync(content::BrowserContext* context, 49 static void InstallAsync(content::BrowserContext* context,
50 const ShortcutInfo& shortcut_info, 50 const ShortcutInfo& shortcut_info,
51 const SkBitmap& shortcut_icon, 51 const SkBitmap& primary_icon,
52 const SkBitmap& badge_icon,
52 const FinishCallback& finish_callback); 53 const FinishCallback& finish_callback);
53 54
54 // Creates a self-owned WebApkInstaller instance and talks to the Chrome 55 // Creates a self-owned WebApkInstaller instance and talks to the Chrome
55 // WebAPK server to update a WebAPK on the server and to the Google Play 56 // WebAPK server to update a WebAPK on the server and to the Google Play
56 // server to install the downloaded WebAPK. Calls |callback| after the request 57 // server to install the downloaded WebAPK. Calls |callback| after the request
57 // to install the WebAPK is sent to the Google Play server. 58 // to install the WebAPK is sent to the Google Play server.
58 static void UpdateAsync( 59 static void UpdateAsync(
59 content::BrowserContext* context, 60 content::BrowserContext* context,
60 const ShortcutInfo& shortcut_info, 61 const ShortcutInfo& shortcut_info,
61 const SkBitmap& shortcut_icon, 62 const SkBitmap& primary_icon,
62 const std::string& webapk_package, 63 const std::string& webapk_package,
63 int webapk_version, 64 int webapk_version,
64 const std::map<std::string, std::string>& icon_url_to_murmur2_hash, 65 const std::map<std::string, std::string>& icon_url_to_murmur2_hash,
65 bool is_manifest_stale, 66 bool is_manifest_stale,
66 const FinishCallback& callback); 67 const FinishCallback& callback);
67 68
68 // Calls the private function |InstallAsync| for testing. 69 // Calls the private function |InstallAsync| for testing.
69 // Should be used only for testing. 70 // Should be used only for testing.
70 static void InstallAsyncForTesting(WebApkInstaller* installer, 71 static void InstallAsyncForTesting(WebApkInstaller* installer,
71 const FinishCallback& finish_callback); 72 const FinishCallback& finish_callback);
(...skipping 22 matching lines...) Expand all
94 const base::Callback<void(std::unique_ptr<webapk::WebApk>)>& callback, 95 const base::Callback<void(std::unique_ptr<webapk::WebApk>)>& callback,
95 const std::map<std::string, std::string>& icon_url_to_murmur2_hash, 96 const std::map<std::string, std::string>& icon_url_to_murmur2_hash,
96 bool is_manifest_stale); 97 bool is_manifest_stale);
97 98
98 // Registers JNI hooks. 99 // Registers JNI hooks.
99 static bool Register(JNIEnv* env); 100 static bool Register(JNIEnv* env);
100 101
101 protected: 102 protected:
102 WebApkInstaller(content::BrowserContext* browser_context, 103 WebApkInstaller(content::BrowserContext* browser_context,
103 const ShortcutInfo& shortcut_info, 104 const ShortcutInfo& shortcut_info,
104 const SkBitmap& shortcut_icon); 105 const SkBitmap& primary_icon,
106 const SkBitmap& badge_icon);
105 107
106 // Starts installion of the downloaded WebAPK. 108 // Starts installion of the downloaded WebAPK.
107 // |file_path| is the file path that the WebAPK was downloaded to. 109 // |file_path| is the file path that the WebAPK was downloaded to.
108 // |package_name| is the package name of the WebAPK. 110 // |package_name| is the package name of the WebAPK.
109 virtual void InstallDownloadedWebApk( 111 virtual void InstallDownloadedWebApk(
110 JNIEnv* env, 112 JNIEnv* env,
111 const base::android::ScopedJavaLocalRef<jstring>& java_file_path, 113 const base::android::ScopedJavaLocalRef<jstring>& java_file_path,
112 const base::android::ScopedJavaLocalRef<jstring>& java_package_name); 114 const base::android::ScopedJavaLocalRef<jstring>& java_package_name);
113 115
114 // Starts update using the downloaded WebAPK. 116 // Starts update using the downloaded WebAPK.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 void UpdateAsync( 153 void UpdateAsync(
152 const std::string& webapk_package, 154 const std::string& webapk_package,
153 int webapk_version, 155 int webapk_version,
154 const std::map<std::string, std::string>& icon_url_to_murmur2_hash, 156 const std::map<std::string, std::string>& icon_url_to_murmur2_hash,
155 bool is_manifest_stale, 157 bool is_manifest_stale,
156 const FinishCallback& callback); 158 const FinishCallback& callback);
157 159
158 // net::URLFetcherDelegate: 160 // net::URLFetcherDelegate:
159 void OnURLFetchComplete(const net::URLFetcher* source) override; 161 void OnURLFetchComplete(const net::URLFetcher* source) override;
160 162
161 // Called with the computed Murmur2 hash for the app icon. 163 // Called with the computed Murmur2 hash for the primary icon.
162 void OnGotIconMurmur2Hash(const std::string& icon_murmur2_hash); 164 void OnGotPrimaryIconMurmur2Hash(const std::string& primary_icon_hash);
165
166 // Called with the computed Murmur2 hash for the badge icon.
167 void OnGotBadgeIconMurmur2Hash(const std::string& badge_icon_hash);
168
169 // Maps icon URLs to Murmur2 hashes.
170 void MapIconUrlToMurmur2Hash();
163 171
164 // Sends request to WebAPK server to create WebAPK. During a successful 172 // Sends request to WebAPK server to create WebAPK. During a successful
165 // request the WebAPK server responds with the URL of the generated WebAPK. 173 // request the WebAPK server responds with the URL of the generated WebAPK.
166 // |webapk| is the proto to send to the WebAPK server. 174 // |webapk| is the proto to send to the WebAPK server.
167 void SendCreateWebApkRequest(std::unique_ptr<webapk::WebApk> webapk_proto); 175 void SendCreateWebApkRequest(std::unique_ptr<webapk::WebApk> webapk_proto);
168 176
169 // Sends request to WebAPK server to update a WebAPK. During a successful 177 // Sends request to WebAPK server to update a WebAPK. During a successful
170 // request the WebAPK server responds with the URL of the generated WebAPK. 178 // request the WebAPK server responds with the URL of the generated WebAPK.
171 // |webapk| is the proto to send to the WebAPK server. 179 // |webapk| is the proto to send to the WebAPK server.
172 void SendUpdateWebApkRequest(std::unique_ptr<webapk::WebApk> webapk_proto); 180 void SendUpdateWebApkRequest(std::unique_ptr<webapk::WebApk> webapk_proto);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 // Fails WebApkInstaller if WebAPK server takes too long to respond or if the 229 // Fails WebApkInstaller if WebAPK server takes too long to respond or if the
222 // download takes too long. 230 // download takes too long.
223 base::OneShotTimer timer_; 231 base::OneShotTimer timer_;
224 232
225 // Callback to call once WebApkInstaller succeeds or fails. 233 // Callback to call once WebApkInstaller succeeds or fails.
226 FinishCallback finish_callback_; 234 FinishCallback finish_callback_;
227 235
228 // Web Manifest info. 236 // Web Manifest info.
229 const ShortcutInfo shortcut_info_; 237 const ShortcutInfo shortcut_info_;
230 238
231 // WebAPK app icon. 239 // WebAPK primary icon & its Murmur2 hash.
232 const SkBitmap shortcut_icon_; 240 const SkBitmap primary_icon_;
241 std::string primary_icon_hash_;
242
243 // WebAPK badge icon & its Murmur2 hash.
244 const SkBitmap badge_icon_;
245 std::string badge_icon_hash_;
233 246
234 // WebAPK server URL. 247 // WebAPK server URL.
235 GURL server_url_; 248 GURL server_url_;
236 249
237 // The number of milliseconds to wait for the WebAPK download URL from the 250 // The number of milliseconds to wait for the WebAPK download URL from the
238 // WebAPK server. 251 // WebAPK server.
239 int webapk_download_url_timeout_ms_; 252 int webapk_download_url_timeout_ms_;
240 253
241 // The number of milliseconds to wait for the WebAPK download to complete. 254 // The number of milliseconds to wait for the WebAPK download to complete.
242 int download_timeout_ms_; 255 int download_timeout_ms_;
(...skipping 13 matching lines...) Expand all
256 // Points to the Java Object. 269 // Points to the Java Object.
257 base::android::ScopedJavaGlobalRef<jobject> java_ref_; 270 base::android::ScopedJavaGlobalRef<jobject> java_ref_;
258 271
259 // Used to get |weak_ptr_|. 272 // Used to get |weak_ptr_|.
260 base::WeakPtrFactory<WebApkInstaller> weak_ptr_factory_; 273 base::WeakPtrFactory<WebApkInstaller> weak_ptr_factory_;
261 274
262 DISALLOW_COPY_AND_ASSIGN(WebApkInstaller); 275 DISALLOW_COPY_AND_ASSIGN(WebApkInstaller);
263 }; 276 };
264 277
265 #endif // CHROME_BROWSER_ANDROID_WEBAPK_WEBAPK_INSTALLER_H_ 278 #endif // CHROME_BROWSER_ANDROID_WEBAPK_WEBAPK_INSTALLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698