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 #include "chrome/browser/android/webapk/webapk_update_manager.h" | 5 #include "chrome/browser/android/webapk/webapk_update_manager.h" |
6 | 6 |
7 #include <jni.h> | 7 #include <jni.h> |
8 | 8 |
9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "chrome/browser/android/webapk/webapk_installer.h" | 11 #include "chrome/browser/android/webapk/webapk_installer.h" |
12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/browser/profiles/profile_manager.h" | 13 #include "chrome/browser/profiles/profile_manager.h" |
14 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
15 #include "jni/WebApkUpdateManager_jni.h" | 15 #include "jni/WebApkUpdateManager_jni.h" |
16 #include "third_party/skia/include/core/SkBitmap.h" | 16 #include "third_party/skia/include/core/SkBitmap.h" |
17 #include "ui/gfx/android/java_bitmap.h" | 17 #include "ui/gfx/android/java_bitmap.h" |
18 #include "url/gurl.h" | 18 #include "url/gurl.h" |
19 | 19 |
20 using base::android::JavaParamRef; | 20 using base::android::JavaParamRef; |
21 | 21 |
22 // static | 22 // static |
23 bool WebApkUpdateManager::Register(JNIEnv* env) { | 23 bool WebApkUpdateManager::Register(JNIEnv* env) { |
24 return RegisterNativesImpl(env); | 24 return RegisterNativesImpl(env); |
25 } | 25 } |
26 | 26 |
27 // static | 27 // static |
28 void WebApkUpdateManager::OnBuiltWebApk(const std::string& webapk_package, | 28 void WebApkUpdateManager::OnBuiltWebApk(bool success, |
29 bool success) { | 29 const std::string& webapk_package) { |
30 JNIEnv* env = base::android::AttachCurrentThread(); | 30 JNIEnv* env = base::android::AttachCurrentThread(); |
31 | 31 |
32 if (success) { | 32 if (success) { |
33 DVLOG(1) | 33 DVLOG(1) |
34 << "Sent request to update WebAPK to server. Seems to have worked."; | 34 << "Sent request to update WebAPK to server. Seems to have worked."; |
35 } else { | 35 } else { |
36 LOG(WARNING) << "Server request to update WebAPK failed."; | 36 LOG(WARNING) << "Server request to update WebAPK failed."; |
37 } | 37 } |
38 | 38 |
39 base::android::ScopedJavaLocalRef<jstring> java_webapk_package = | 39 base::android::ScopedJavaLocalRef<jstring> java_webapk_package = |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 | 89 |
90 std::string icon_murmur2_hash; | 90 std::string icon_murmur2_hash; |
91 ConvertJavaStringToUTF8(env, java_icon_murmur2_hash, &icon_murmur2_hash); | 91 ConvertJavaStringToUTF8(env, java_icon_murmur2_hash, &icon_murmur2_hash); |
92 | 92 |
93 std::string webapk_package; | 93 std::string webapk_package; |
94 ConvertJavaStringToUTF8(env, java_webapk_package, &webapk_package); | 94 ConvertJavaStringToUTF8(env, java_webapk_package, &webapk_package); |
95 | 95 |
96 WebApkInstaller* installer = new WebApkInstaller(info, icon_bitmap); | 96 WebApkInstaller* installer = new WebApkInstaller(info, icon_bitmap); |
97 installer->UpdateAsync( | 97 installer->UpdateAsync( |
98 profile, | 98 profile, |
99 base::Bind(&WebApkUpdateManager::OnBuiltWebApk, webapk_package), | 99 base::Bind(&WebApkUpdateManager::OnBuiltWebApk), |
100 icon_murmur2_hash, webapk_package, java_webapk_version); | 100 icon_murmur2_hash, webapk_package, java_webapk_version); |
101 } | 101 } |
OLD | NEW |