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

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

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

Powered by Google App Engine
This is Rietveld 408576698