Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 31 class WebApk; | 31 class WebApk; |
| 32 } | 32 } |
| 33 | 33 |
| 34 class WebApkIconHasher; | 34 class WebApkIconHasher; |
| 35 | 35 |
| 36 // Talks to Chrome WebAPK server and Google Play to generate a WebAPK on the | 36 // Talks to Chrome WebAPK server and Google Play to generate a WebAPK on the |
| 37 // server, download it, and install it. The native WebApkInstaller owns the | 37 // server, download it, and install it. The native WebApkInstaller owns the |
| 38 // Java WebApkInstaller counterpart. | 38 // Java WebApkInstaller counterpart. |
| 39 class WebApkInstaller : public net::URLFetcherDelegate { | 39 class WebApkInstaller : public net::URLFetcherDelegate { |
| 40 public: | 40 public: |
| 41 enum TaskType { | |
| 42 UNDEFINED, | |
| 43 INSTALL, | |
| 44 UPDATE, | |
| 45 }; | |
| 46 | |
| 41 // Called when the creation/updating of a WebAPK is finished or failed. | 47 // Called when the creation/updating of a WebAPK is finished or failed. |
| 42 // Parameters: | 48 // Parameters: |
| 43 // - whether the process succeeds. | 49 // - whether the process succeeds. |
| 44 // - the package name of the WebAPK. | 50 // - the package name of the WebAPK. |
| 45 using FinishCallback = base::Callback<void(bool, const std::string&)>; | 51 using FinishCallback = base::Callback<void(bool, const std::string&)>; |
| 46 | 52 |
| 47 WebApkInstaller(const ShortcutInfo& shortcut_info, | 53 WebApkInstaller(const ShortcutInfo& shortcut_info, |
| 48 const SkBitmap& shorcut_icon); | 54 const SkBitmap& shorcut_icon); |
| 49 | 55 |
| 50 ~WebApkInstaller() override; | 56 ~WebApkInstaller() override; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 102 // could be started. The updating may still fail if true is returned. | 108 // could be started. The updating may still fail if true is returned. |
| 103 // |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. |
| 104 virtual bool StartUpdateUsingDownloadedWebApk( | 110 virtual bool StartUpdateUsingDownloadedWebApk( |
| 105 JNIEnv* env, | 111 JNIEnv* env, |
| 106 const base::android::ScopedJavaLocalRef<jstring>& java_file_path); | 112 const base::android::ScopedJavaLocalRef<jstring>& java_file_path); |
| 107 | 113 |
| 108 // Called when the request to install the WebAPK is sent to Google Play. | 114 // Called when the request to install the WebAPK is sent to Google Play. |
| 109 void OnSuccess(); | 115 void OnSuccess(); |
| 110 | 116 |
| 111 private: | 117 private: |
| 112 enum TaskType { | |
| 113 UNDEFINED, | |
| 114 INSTALL, | |
| 115 UPDATE, | |
| 116 }; | |
| 117 | |
| 118 // Create the Java object. | 118 // Create the Java object. |
| 119 void CreateJavaRef(); | 119 void CreateJavaRef(); |
| 120 | 120 |
| 121 // net::URLFetcherDelegate: | 121 // net::URLFetcherDelegate: |
| 122 void OnURLFetchComplete(const net::URLFetcher* source) override; | 122 void OnURLFetchComplete(const net::URLFetcher* source) override; |
| 123 | 123 |
| 124 // Downloads app icon in order to compute Murmur2 hash. | 124 // Downloads app icon in order to compute Murmur2 hash. |
| 125 void DownloadAppIconAndComputeMurmur2Hash(); | 125 void DownloadAppIconAndComputeMurmur2Hash(); |
| 126 | 126 |
| 127 // Called with the computed Murmur2 hash for the app icon. | 127 // Called with the computed Murmur2 hash for the app icon. |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 142 // WebAPK. | 142 // WebAPK. |
| 143 void SendRequest(std::unique_ptr<webapk::WebApk> request_proto, | 143 void SendRequest(std::unique_ptr<webapk::WebApk> request_proto, |
| 144 net::URLFetcher::RequestType request_type, | 144 net::URLFetcher::RequestType request_type, |
| 145 const GURL& server_url); | 145 const GURL& server_url); |
| 146 | 146 |
| 147 // Called with the URL of generated WebAPK and the package name that the | 147 // Called with the URL of generated WebAPK and the package name that the |
| 148 // WebAPK should be installed at. | 148 // WebAPK should be installed at. |
| 149 void OnGotWebApkDownloadUrl(const GURL& download_url, | 149 void OnGotWebApkDownloadUrl(const GURL& download_url, |
| 150 const std::string& package_name); | 150 const std::string& package_name); |
| 151 | 151 |
| 152 // Called once the sub directory to store the downloaded WebApk was | |
|
pkotwicz
2016/09/26 21:05:49
WebApk -> WebAPK
Xi Han
2016/09/26 22:22:17
Done.
| |
| 153 // created with permissions set properly or failed to create. | |
|
pkotwicz
2016/09/26 21:04:25
Nit: "or failed to create." -> "or if creation fai
Xi Han
2016/09/26 22:22:17
Change to "or if creation failed".
| |
| 154 void OnCreateSubDirAndSetPermissions(const GURL& download_url, | |
| 155 const base::FilePath& file_path); | |
| 156 | |
| 152 // Called once the WebAPK has been downloaded. Makes the downloaded WebAPK | 157 // Called once the WebAPK has been downloaded. Makes the downloaded WebAPK |
| 153 // world readable and installs the WebAPK if the download was successful. | 158 // world readable and installs the WebAPK if the download was successful. |
| 154 // |file_path| is the file path that the WebAPK was downloaded to. | 159 // |file_path| is the file path that the WebAPK was downloaded to. |
| 155 void OnWebApkDownloaded(const base::FilePath& file_path, | 160 void OnWebApkDownloaded(const base::FilePath& file_path, |
| 156 FileDownloader::Result result); | 161 FileDownloader::Result result); |
| 157 | 162 |
| 158 // Called once the downloaded WebAPK has been made world readable. Installs | 163 // Called once the downloaded WebAPK has been made world readable. Installs |
| 159 // the WebAPK. | 164 // the WebAPK. |
| 160 // |file_path| is the file path that the WebAPK was downloaded to. | 165 // |file_path| is the file path that the WebAPK was downloaded to. |
| 161 // |change_permission_success| is whether the WebAPK could be made world | 166 // |change_permission_success| is whether the WebAPK could be made world |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 223 // Points to the Java Object. | 228 // Points to the Java Object. |
| 224 base::android::ScopedJavaGlobalRef<jobject> java_ref_; | 229 base::android::ScopedJavaGlobalRef<jobject> java_ref_; |
| 225 | 230 |
| 226 // Used to get |weak_ptr_|. | 231 // Used to get |weak_ptr_|. |
| 227 base::WeakPtrFactory<WebApkInstaller> weak_ptr_factory_; | 232 base::WeakPtrFactory<WebApkInstaller> weak_ptr_factory_; |
| 228 | 233 |
| 229 DISALLOW_COPY_AND_ASSIGN(WebApkInstaller); | 234 DISALLOW_COPY_AND_ASSIGN(WebApkInstaller); |
| 230 }; | 235 }; |
| 231 | 236 |
| 232 #endif // CHROME_BROWSER_ANDROID_WEBAPK_WEBAPK_INSTALLER_H_ | 237 #endif // CHROME_BROWSER_ANDROID_WEBAPK_WEBAPK_INSTALLER_H_ |
| OLD | NEW |