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

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

Issue 2138973002: Initial CL for talking to the WebAPK server to generate WebAPK (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge branch 'webapk_builder_impl0' into webapk_builder_impl2 Created 4 years, 5 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_ANDROID_WEBAPK_WEBAPK_BUILDER_H_
6 #define CHROME_BROWSER_ANDROID_WEBAPK_WEBAPK_BUILDER_H_
7
8 #include <jni.h>
9 #include <memory>
10
11 #include "base/callback.h"
12 #include "base/macros.h"
13 #include "base/timer/timer.h"
14 #include "chrome/browser/android/shortcut_info.h"
15 #include "net/url_request/url_fetcher_delegate.h"
16 #include "third_party/skia/include/core/SkBitmap.h"
17
18 namespace content {
19 class BrowserContext;
20 }
21
22 namespace net {
23 class URLFetcher;
24 class URLRequestContextGetter;
25 }
26
27 namespace webapk {
28 class CreateWebApkRequest;
29 }
30
31 // Talks to Chrome WebAPK server and Google Play servers to generate a WebAPK on
32 // the server, download it, and install it.
33 class WebApkBuilder : public net::URLFetcherDelegate {
34 public:
35 typedef base::Callback<void(bool)> FinishCallback;
36
37 WebApkBuilder(content::BrowserContext* browser_context,
38 const ShortcutInfo& shortcut_info,
39 const SkBitmap& shorcut_icon);
40 ~WebApkBuilder() override;
41
42 // Register JNI methods.
43 static bool Register(JNIEnv* env);
44
45 // Converts a blink::WebDisplayMode to a string. Returns one of
46 // https://www.w3.org/TR/appmanifest/#dfn-fallback-display-mode
47 static std::string DisplayToString(blink::WebDisplayMode display);
48
49 // Converts a blink::WebScreenOrientationLockType to a string. Returns one of
50 // https://www.w3.org/TR/screen-orientation/#orientationlocktype-enum
51 static std::string OrientationToString(
52 blink::WebScreenOrientationLockType orientation);
53
54 // Converts a color from the format specified in content::Manifest to a CSS
55 // string.
56 static std::string ColorToString(int64_t color);
57
58 // Talks to Chrome WebAPK server and Google Play servers to generate a WebAPK
59 // on the server, download it, and install it. Calls |callback| after the
60 // request to download the WebAPK is sent tot he Google Play server.
Xi Han 2016/07/14 14:53:16 "sent tot he" -> "send to the". The description is
pkotwicz 2016/07/20 05:13:41 You are right that the comment was a little confus
61 void BuildAsync(const FinishCallback& callback);
62
63 private:
64 // net::URLFetcherDelegate:
65 void OnURLFetchComplete(const net::URLFetcher* source) override;
66
67 // Initializes |request_context_getter_| on UI thread.
68 void InitializeRequestContextGetterOnUIThread();
69
70 // Sends request to WebAPK server to create WebAPK. During a successful
71 // request the WebAPK server responds with a URL to send to Google Play to
72 // download the generated WebAPK.
Xi Han 2016/07/14 14:53:16 to download and install the generated WebAPK.
pkotwicz 2016/07/20 05:13:41 I changed "to download" to "to download and instal
73 void SendCreateWebApkRequest();
74
75 // Called with the URL to send to the Google Play server to download the
Xi Han 2016/07/14 14:53:16 "to download" -> "to install".
76 // WebAPK.
77 void OnGotMarketUrl(const std::string& signed_market_url);
78
79 // Populates webapk::CreateWebApkRequest and returns it.
80 std::unique_ptr<webapk::CreateWebApkRequest> BuildCreateWebApkRequest();
81
82 // Called when the request to the server times out.
83 void OnTimeout();
84
85 // Called when the request to download the WebAPK is sent to the Google Play
Xi Han 2016/07/14 14:53:16 Maybe "download and install"?
86 // server.
87 void OnSuccess();
88
89 // Called if a WebAPK could not be created. WebApkBuilder only tracks the
90 // generation of the WebAPK on the WebAPK server. It does not track the WebAPK
91 // download and installation. OnFailure() is not called if the WebAPK could
92 // not be downloaded or installed.
93 void OnFailure();
94
95 content::BrowserContext* browser_context_;
96 net::URLRequestContextGetter* request_context_getter_;
97
98 // Sends HTTP request to WebAPK server.
99 std::unique_ptr<net::URLFetcher> url_fetcher_;
100
101 // Fails WebApkBuilder if WebAPK server takes too long to respond.
102 base::OneShotTimer timer_;
103
104 // Callback to call once WebApkBuilder succeeds or fails.
105 FinishCallback finish_callback_;
106
107 // Web Manifest info.
108 const ShortcutInfo shortcut_info_;
109
110 // WebAPK app icon.
111 const SkBitmap shortcut_icon_;
112
113 // WebAPK server URL.
114 GURL server_url_;
115
116 DISALLOW_COPY_AND_ASSIGN(WebApkBuilder);
117 };
118
119 #endif // CHROME_BROWSER_ANDROID_WEBAPK_WEBAPK_BUILDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698