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

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

Issue 2259553002: Make AppBannerInfoBar install WebAPK. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 <memory> 9 #include <memory>
10 10
11 #include "base/android/scoped_java_ref.h" 11 #include "base/android/scoped_java_ref.h"
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 "base/timer/timer.h" 15 #include "base/timer/timer.h"
16 #include "chrome/browser/android/shortcut_helper.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"
19 #include "net/url_request/url_fetcher_delegate.h" 20 #include "net/url_request/url_fetcher_delegate.h"
20 #include "third_party/skia/include/core/SkBitmap.h" 21 #include "third_party/skia/include/core/SkBitmap.h"
21 22
22 namespace base { 23 namespace base {
23 class FilePath; 24 class FilePath;
24 } 25 }
25 26
(...skipping 18 matching lines...) Expand all
44 using FinishCallback = base::Callback<void(bool)>; 45 using FinishCallback = base::Callback<void(bool)>;
45 46
46 WebApkInstaller(const ShortcutInfo& shortcut_info, 47 WebApkInstaller(const ShortcutInfo& shortcut_info,
47 const SkBitmap& shorcut_icon); 48 const SkBitmap& shorcut_icon);
48 49
49 ~WebApkInstaller() override; 50 ~WebApkInstaller() override;
50 51
51 // Talks to the Chrome WebAPK server to generate a WebAPK on the server and to 52 // Talks to the Chrome WebAPK server to generate a WebAPK on the server and to
52 // Google Play to install the downloaded WebAPK. Calls |callback| after the 53 // Google Play to install the downloaded WebAPK. Calls |callback| after the
53 // request to install the WebAPK is sent to Google Play. 54 // request to install the WebAPK is sent to Google Play.
54 void InstallAsync(content::BrowserContext* browser_context, 55 void InstallAsync(
55 const FinishCallback& callback); 56 content::BrowserContext* browser_context,
57 const ShortcutHelper::WebApkPackageNameAvailableCallback& callback,
58 const FinishCallback& finish_callback);
56 59
57 // Same as InstallAsync() but uses the passed in |request_context_getter|. 60 // Same as InstallAsync() but uses the passed in |request_context_getter|.
58 void InstallAsyncWithURLRequestContextGetter( 61 void InstallAsyncWithURLRequestContextGetter(
59 net::URLRequestContextGetter* request_context_getter, 62 net::URLRequestContextGetter* request_context_getter,
60 const FinishCallback& callback); 63 const ShortcutHelper::WebApkPackageNameAvailableCallback& callback,
64 const FinishCallback& finish_callback);
61 65
62 // Talks to the Chrome WebAPK server to update a WebAPK on the server and to 66 // Talks to the Chrome WebAPK server to update a WebAPK on the server and to
63 // the Google Play server to install the downloaded WebAPK. Calls |callback| 67 // the Google Play server to install the downloaded WebAPK. Calls |callback|
64 // after the request to install the WebAPK is sent to the Google Play server. 68 // after the request to install the WebAPK is sent to the Google Play server.
65 void UpdateAsync(content::BrowserContext* browser_context, 69 void UpdateAsync(content::BrowserContext* browser_context,
66 const FinishCallback& callback, 70 const FinishCallback& callback,
67 const std::string& webapk_package, 71 const std::string& webapk_package,
68 int webapk_version); 72 int webapk_version);
69 73
70 // Same as UpdateAsync() but uses the passed in |request_context_getter|. 74 // Same as UpdateAsync() but uses the passed in |request_context_getter|.
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 // Downloads WebAPK. 180 // Downloads WebAPK.
177 std::unique_ptr<FileDownloader> downloader_; 181 std::unique_ptr<FileDownloader> downloader_;
178 182
179 // Fails WebApkInstaller if WebAPK server takes too long to respond or if the 183 // Fails WebApkInstaller if WebAPK server takes too long to respond or if the
180 // download takes too long. 184 // download takes too long.
181 base::OneShotTimer timer_; 185 base::OneShotTimer timer_;
182 186
183 // Callback to call once WebApkInstaller succeeds or fails. 187 // Callback to call once WebApkInstaller succeeds or fails.
184 FinishCallback finish_callback_; 188 FinishCallback finish_callback_;
185 189
190 // Callback to call once the WebAPK's package name is available (i.e.,
191 // received from the WebAPK Server).
192 ShortcutHelper::WebApkPackageNameAvailableCallback
193 package_available_callback_;
194
186 // Web Manifest info. 195 // Web Manifest info.
187 const ShortcutInfo shortcut_info_; 196 const ShortcutInfo shortcut_info_;
188 197
189 // WebAPK app icon. 198 // WebAPK app icon.
190 const SkBitmap shortcut_icon_; 199 const SkBitmap shortcut_icon_;
191 200
192 // Murmur2 hash of the bitmap at the app icon URL prior to any transformations 201 // Murmur2 hash of the bitmap at the app icon URL prior to any transformations
193 // being applied to the bitmap (such as encoding/decoding the icon bitmap). 202 // being applied to the bitmap (such as encoding/decoding the icon bitmap).
194 std::string shortcut_icon_murmur2_hash_; 203 std::string shortcut_icon_murmur2_hash_;
195 204
(...skipping 16 matching lines...) Expand all
212 // Indicates whether the installer is for installing or updating a WebAPK. 221 // Indicates whether the installer is for installing or updating a WebAPK.
213 TaskType task_type_; 222 TaskType task_type_;
214 223
215 // Used to get |weak_ptr_|. 224 // Used to get |weak_ptr_|.
216 base::WeakPtrFactory<WebApkInstaller> weak_ptr_factory_; 225 base::WeakPtrFactory<WebApkInstaller> weak_ptr_factory_;
217 226
218 DISALLOW_COPY_AND_ASSIGN(WebApkInstaller); 227 DISALLOW_COPY_AND_ASSIGN(WebApkInstaller);
219 }; 228 };
220 229
221 #endif // CHROME_BROWSER_ANDROID_WEBAPK_WEBAPK_INSTALLER_H_ 230 #endif // CHROME_BROWSER_ANDROID_WEBAPK_WEBAPK_INSTALLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698