| 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_data_fetcher.h" | 5 #include "chrome/browser/android/webapk/webapk_update_data_fetcher.h" |
| 6 | 6 |
| 7 #include <jni.h> | 7 #include <jni.h> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/android/jni_array.h" | 10 #include "base/android/jni_array.h" |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 } | 148 } |
| 149 | 149 |
| 150 info_.UpdateFromManifest(data.manifest); | 150 info_.UpdateFromManifest(data.manifest); |
| 151 info_.manifest_url = data.manifest_url; | 151 info_.manifest_url = data.manifest_url; |
| 152 info_.best_primary_icon_url = data.primary_icon_url; | 152 info_.best_primary_icon_url = data.primary_icon_url; |
| 153 best_primary_icon_ = *data.primary_icon; | 153 best_primary_icon_ = *data.primary_icon; |
| 154 | 154 |
| 155 Profile* profile = | 155 Profile* profile = |
| 156 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); | 156 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
| 157 | 157 |
| 158 icon_hasher_.reset(new WebApkIconHasher( | 158 WebApkIconHasher::DownloadAndComputeMurmur2Hash( |
| 159 profile->GetRequestContext(), data.primary_icon_url, | 159 profile->GetRequestContext(), data.primary_icon_url, |
| 160 base::Bind(&WebApkUpdateDataFetcher::OnGotIconMurmur2Hash, | 160 base::Bind(&WebApkUpdateDataFetcher::OnGotIconMurmur2Hash, |
| 161 weak_ptr_factory_.GetWeakPtr()))); | 161 weak_ptr_factory_.GetWeakPtr())); |
| 162 icon_hasher_->DownloadAndComputeMurmur2Hash(); | |
| 163 } | 162 } |
| 164 | 163 |
| 165 void WebApkUpdateDataFetcher::OnGotIconMurmur2Hash( | 164 void WebApkUpdateDataFetcher::OnGotIconMurmur2Hash( |
| 166 const std::string& best_primary_icon_murmur2_hash) { | 165 const std::string& best_primary_icon_murmur2_hash) { |
| 167 icon_hasher_.reset(); | |
| 168 | |
| 169 if (best_primary_icon_murmur2_hash.empty()) { | 166 if (best_primary_icon_murmur2_hash.empty()) { |
| 170 OnWebManifestNotWebApkCompatible(); | 167 OnWebManifestNotWebApkCompatible(); |
| 171 return; | 168 return; |
| 172 } | 169 } |
| 173 | 170 |
| 174 OnDataAvailable(info_, best_primary_icon_murmur2_hash, best_primary_icon_); | 171 OnDataAvailable(info_, best_primary_icon_murmur2_hash, best_primary_icon_); |
| 175 } | 172 } |
| 176 | 173 |
| 177 void WebApkUpdateDataFetcher::OnDataAvailable( | 174 void WebApkUpdateDataFetcher::OnDataAvailable( |
| 178 const ShortcutInfo& info, | 175 const ShortcutInfo& info, |
| (...skipping 28 matching lines...) Expand all Loading... |
| 207 info.theme_color, info.background_color); | 204 info.theme_color, info.background_color); |
| 208 } | 205 } |
| 209 | 206 |
| 210 void WebApkUpdateDataFetcher::OnWebManifestNotWebApkCompatible() { | 207 void WebApkUpdateDataFetcher::OnWebManifestNotWebApkCompatible() { |
| 211 if (!is_initial_fetch_) | 208 if (!is_initial_fetch_) |
| 212 return; | 209 return; |
| 213 | 210 |
| 214 Java_WebApkUpdateDataFetcher_onWebManifestForInitialUrlNotWebApkCompatible( | 211 Java_WebApkUpdateDataFetcher_onWebManifestForInitialUrlNotWebApkCompatible( |
| 215 base::android::AttachCurrentThread(), java_ref_); | 212 base::android::AttachCurrentThread(), java_ref_); |
| 216 } | 213 } |
| OLD | NEW |