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

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

Issue 2528073002: Add a flag in WebAPK's proto when the Web App Manifest is no longer available. (Closed)
Patch Set: Nits. Created 4 years 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 <memory> 10 #include <memory>
10 11
11 #include "base/android/scoped_java_ref.h" 12 #include "base/android/scoped_java_ref.h"
12 #include "base/callback.h" 13 #include "base/callback.h"
13 #include "base/macros.h" 14 #include "base/macros.h"
14 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
15 #include "base/timer/timer.h" 16 #include "base/timer/timer.h"
16 #include "chrome/browser/android/shortcut_info.h" 17 #include "chrome/browser/android/shortcut_info.h"
17 #include "chrome/browser/net/file_downloader.h" 18 #include "chrome/browser/net/file_downloader.h"
18 #include "net/url_request/url_fetcher.h" 19 #include "net/url_request/url_fetcher.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 const FinishCallback& finish_callback); 57 const FinishCallback& finish_callback);
57 58
58 // Same as InstallAsync() but uses the passed in |request_context_getter|. 59 // Same as InstallAsync() but uses the passed in |request_context_getter|.
59 void InstallAsyncWithURLRequestContextGetter( 60 void InstallAsyncWithURLRequestContextGetter(
60 net::URLRequestContextGetter* request_context_getter, 61 net::URLRequestContextGetter* request_context_getter,
61 const FinishCallback& finish_callback); 62 const FinishCallback& finish_callback);
62 63
63 // Talks to the Chrome WebAPK server to update a WebAPK on the server and to 64 // Talks to the Chrome WebAPK server to update a WebAPK on the server and to
64 // the Google Play server to install the downloaded WebAPK. Calls |callback| 65 // the Google Play server to install the downloaded WebAPK. Calls |callback|
65 // after the request to install the WebAPK is sent to the Google Play server. 66 // after the request to install the WebAPK is sent to the Google Play server.
66 void UpdateAsync(content::BrowserContext* browser_context, 67 void UpdateAsync(
67 const FinishCallback& callback, 68 content::BrowserContext* browser_context,
68 const std::string& icon_murmur2_hash, 69 const FinishCallback& callback,
69 const std::string& webapk_package, 70 const std::string& webapk_package,
70 int webapk_version); 71 int webapk_version,
72 bool stale_manifest,
73 const std::map<std::string, std::string>& icon_url_to_murmur2_hash_map);
71 74
72 // Same as UpdateAsync() but uses the passed in |request_context_getter|. 75 // Same as UpdateAsync() but uses the passed in |request_context_getter|.
73 void UpdateAsyncWithURLRequestContextGetter( 76 void UpdateAsyncWithURLRequestContextGetter(
74 net::URLRequestContextGetter* request_context_getter, 77 net::URLRequestContextGetter* request_context_getter,
75 const FinishCallback& callback, 78 const FinishCallback& callback,
76 const std::string& icon_murmur2_hash,
77 const std::string& webapk_package, 79 const std::string& webapk_package,
78 int webapk_version); 80 int webapk_version,
81 bool stale_manifest,
82 const std::map<std::string, std::string>& icon_url_to_murmur2_hash_map);
79 83
80 // Sets the timeout for the server requests. 84 // Sets the timeout for the server requests.
81 void SetTimeoutMs(int timeout_ms); 85 void SetTimeoutMs(int timeout_ms);
82 86
83 // Called once the installation is complete or failed. 87 // Called once the installation is complete or failed.
84 void OnInstallFinished(JNIEnv* env, 88 void OnInstallFinished(JNIEnv* env,
85 const base::android::JavaParamRef<jobject>& obj, 89 const base::android::JavaParamRef<jobject>& obj,
86 jboolean success); 90 jboolean success);
87 91
92 // Creates a WebApk install or update request.
93 // Should be used only for testing.
pkotwicz 2016/12/09 22:18:55 This is kind of weird. You could move BuildWebApkP
94 void BuildWebApkProtoInBackgroundForTesting(
95 const base::Callback<void(std::unique_ptr<webapk::WebApk>)>& callback,
96 bool stale_manifest,
97 const std::map<std::string, std::string>& icon_url_to_murmur2_hash_map);
98
88 // Registers JNI hooks. 99 // Registers JNI hooks.
89 static bool Register(JNIEnv* env); 100 static bool Register(JNIEnv* env);
90 101
91 protected: 102 protected:
92 // Starts installation of the downloaded WebAPK. Returns whether the install 103 // Starts installation of the downloaded WebAPK. Returns whether the install
93 // could be started. The installation may still fail if true is returned. 104 // could be started. The installation may still fail if true is returned.
94 // |file_path| is the file path that the WebAPK was downloaded to. 105 // |file_path| is the file path that the WebAPK was downloaded to.
95 // |package_name| is the package name that the WebAPK should be installed at. 106 // |package_name| is the package name that the WebAPK should be installed at.
96 virtual bool StartInstallingDownloadedWebApk( 107 virtual bool StartInstallingDownloadedWebApk(
97 JNIEnv* env, 108 JNIEnv* env,
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 214
204 // Callback to call once WebApkInstaller succeeds or fails. 215 // Callback to call once WebApkInstaller succeeds or fails.
205 FinishCallback finish_callback_; 216 FinishCallback finish_callback_;
206 217
207 // Web Manifest info. 218 // Web Manifest info.
208 const ShortcutInfo shortcut_info_; 219 const ShortcutInfo shortcut_info_;
209 220
210 // WebAPK app icon. 221 // WebAPK app icon.
211 const SkBitmap shortcut_icon_; 222 const SkBitmap shortcut_icon_;
212 223
213 // Murmur2 hash of the bitmap at the app icon URL prior to any transformations
214 // being applied to the bitmap (such as encoding/decoding the icon bitmap).
215 std::string shortcut_icon_murmur2_hash_;
216
217 // WebAPK server URL. 224 // WebAPK server URL.
218 GURL server_url_; 225 GURL server_url_;
219 226
220 // The number of milliseconds to wait for the WebAPK download URL from the 227 // The number of milliseconds to wait for the WebAPK download URL from the
221 // WebAPK server. 228 // WebAPK server.
222 int webapk_download_url_timeout_ms_; 229 int webapk_download_url_timeout_ms_;
223 230
224 // The number of milliseconds to wait for the WebAPK download to complete. 231 // The number of milliseconds to wait for the WebAPK download to complete.
225 int download_timeout_ms_; 232 int download_timeout_ms_;
226 233
227 // WebAPK package name. 234 // WebAPK package name.
228 std::string webapk_package_; 235 std::string webapk_package_;
229 236
230 // WebAPK version code. 237 // WebAPK version code.
231 int webapk_version_; 238 int webapk_version_;
232 239
233 // Indicates whether the installer is for installing or updating a WebAPK. 240 // Indicates whether the installer is for installing or updating a WebAPK.
234 TaskType task_type_; 241 TaskType task_type_;
235 242
236 // Points to the Java Object. 243 // Points to the Java Object.
237 base::android::ScopedJavaGlobalRef<jobject> java_ref_; 244 base::android::ScopedJavaGlobalRef<jobject> java_ref_;
238 245
239 // Used to get |weak_ptr_|. 246 // Used to get |weak_ptr_|.
240 base::WeakPtrFactory<WebApkInstaller> weak_ptr_factory_; 247 base::WeakPtrFactory<WebApkInstaller> weak_ptr_factory_;
241 248
242 DISALLOW_COPY_AND_ASSIGN(WebApkInstaller); 249 DISALLOW_COPY_AND_ASSIGN(WebApkInstaller);
243 }; 250 };
244 251
245 #endif // CHROME_BROWSER_ANDROID_WEBAPK_WEBAPK_INSTALLER_H_ 252 #endif // CHROME_BROWSER_ANDROID_WEBAPK_WEBAPK_INSTALLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698