Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/webapps/add_to_homescreen_data_fetcher.h" | 5 #include "chrome/browser/android/webapps/add_to_homescreen_data_fetcher.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 222 | 222 |
| 223 // Save the splash screen URL for the later download. | 223 // Save the splash screen URL for the later download. |
| 224 shortcut_info_.splash_image_url = ManifestIconSelector::FindBestMatchingIcon( | 224 shortcut_info_.splash_image_url = ManifestIconSelector::FindBestMatchingIcon( |
| 225 data.manifest.icons, ideal_splash_image_size_in_px_, | 225 data.manifest.icons, ideal_splash_image_size_in_px_, |
| 226 minimum_splash_image_size_in_px_, | 226 minimum_splash_image_size_in_px_, |
| 227 content::Manifest::Icon::IconPurpose::ANY); | 227 content::Manifest::Icon::IconPurpose::ANY); |
| 228 shortcut_info_.ideal_splash_image_size_in_px = ideal_splash_image_size_in_px_; | 228 shortcut_info_.ideal_splash_image_size_in_px = ideal_splash_image_size_in_px_; |
| 229 shortcut_info_.minimum_splash_image_size_in_px = | 229 shortcut_info_.minimum_splash_image_size_in_px = |
| 230 minimum_splash_image_size_in_px_; | 230 minimum_splash_image_size_in_px_; |
| 231 | 231 |
| 232 bool webapk_compatible = false; | |
| 232 if (check_webapk_compatibility_) { | 233 if (check_webapk_compatibility_) { |
| 233 bool webapk_compatible = | 234 webapk_compatible = (data.error_code == NO_ERROR_DETECTED && |
| 234 (data.error_code == NO_ERROR_DETECTED && | 235 AreWebManifestUrlsWebApkCompatible(data.manifest)); |
| 235 AreWebManifestUrlsWebApkCompatible(data.manifest)); | |
| 236 weak_observer_->OnDidDetermineWebApkCompatibility(webapk_compatible); | 236 weak_observer_->OnDidDetermineWebApkCompatibility(webapk_compatible); |
| 237 | 237 |
| 238 if (webapk_compatible) | 238 if (webapk_compatible) |
| 239 shortcut_info_.UpdateSource(ShortcutInfo::SOURCE_ADD_TO_HOMESCREEN_PWA); | 239 shortcut_info_.UpdateSource(ShortcutInfo::SOURCE_ADD_TO_HOMESCREEN_PWA); |
| 240 } | 240 } |
| 241 | 241 |
| 242 weak_observer_->OnUserTitleAvailable(shortcut_info_.user_title); | 242 weak_observer_->OnUserTitleAvailable(shortcut_info_.user_title); |
| 243 | 243 |
| 244 if (data.primary_icon) { | 244 if (data.primary_icon) { |
| 245 shortcut_info_.best_primary_icon_url = data.primary_icon_url; | 245 shortcut_info_.best_primary_icon_url = data.primary_icon_url; |
| 246 | 246 |
| 247 CreateLauncherIcon(*(data.primary_icon)); | 247 if (webapk_compatible) { |
|
dominickn
2017/06/15 03:01:27
The multiple returns here are a bit strange. Can w
| |
| 248 NotifyObserver(*data.primary_icon); | |
| 249 return; | |
| 250 } | |
| 251 | |
| 252 CreateLauncherIcon(*data.primary_icon); | |
| 248 return; | 253 return; |
| 249 } | 254 } |
| 250 | 255 |
| 251 FetchFavicon(); | 256 FetchFavicon(); |
| 252 } | 257 } |
| 253 | 258 |
| 254 void AddToHomescreenDataFetcher::FetchFavicon() { | 259 void AddToHomescreenDataFetcher::FetchFavicon() { |
| 255 if (!web_contents() || !weak_observer_) | 260 if (!web_contents() || !weak_observer_) |
| 256 return; | 261 return; |
| 257 | 262 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 334 void AddToHomescreenDataFetcher::NotifyObserver(const SkBitmap& primary_icon) { | 339 void AddToHomescreenDataFetcher::NotifyObserver(const SkBitmap& primary_icon) { |
| 335 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 340 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 336 if (!web_contents() || !weak_observer_ || is_icon_saved_) | 341 if (!web_contents() || !weak_observer_ || is_icon_saved_) |
| 337 return; | 342 return; |
| 338 | 343 |
| 339 is_icon_saved_ = true; | 344 is_icon_saved_ = true; |
| 340 primary_icon_ = primary_icon; | 345 primary_icon_ = primary_icon; |
| 341 is_ready_ = true; | 346 is_ready_ = true; |
| 342 weak_observer_->OnDataAvailable(shortcut_info_, primary_icon_, badge_icon_); | 347 weak_observer_->OnDataAvailable(shortcut_info_, primary_icon_, badge_icon_); |
| 343 } | 348 } |
| OLD | NEW |