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

Side by Side Diff: chrome/browser/android/webapps/add_to_homescreen_data_fetcher.cc

Issue 2937823002: [Android] Make WebApplicationInfo and Web Manifest mutually exclusive (Closed)
Patch Set: Merge branch 'master' into reenable_tests000 Created 3 years, 6 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
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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 void AddToHomescreenDataFetcher::OnDidPerformInstallableCheck( 200 void AddToHomescreenDataFetcher::OnDidPerformInstallableCheck(
201 const InstallableData& data) { 201 const InstallableData& data) {
202 data_timeout_timer_.Stop(); 202 data_timeout_timer_.Stop();
203 badge_icon_.reset(); 203 badge_icon_.reset();
204 204
205 if (!web_contents() || !weak_observer_ || is_installable_check_complete_) 205 if (!web_contents() || !weak_observer_ || is_installable_check_complete_)
206 return; 206 return;
207 207
208 is_installable_check_complete_ = true; 208 is_installable_check_complete_ = true;
209 209
210 bool webapk_compatible = false; 210 if (!data.manifest.IsEmpty()) {
211 if (check_webapk_compatibility_) { 211 shortcut_info_ = ShortcutInfo(GURL());
212 webapk_compatible = (data.error_code == NO_ERROR_DETECTED &&
213 AreWebManifestUrlsWebApkCompatible(data.manifest));
214 weak_observer_->OnDidDetermineWebApkCompatibility(webapk_compatible);
215 212
216 if (webapk_compatible) {
217 // WebAPKs are wholly defined by the Web Manifest. Ignore the <meta> tag
218 // data received in OnDidGetWebApplicationInfo().
219 shortcut_info_ = ShortcutInfo(GURL());
220 }
221 }
222
223 if (!data.manifest.IsEmpty()) {
224 base::RecordAction(base::UserMetricsAction("webapps.AddShortcut.Manifest")); 213 base::RecordAction(base::UserMetricsAction("webapps.AddShortcut.Manifest"));
225 shortcut_info_.UpdateFromManifest(data.manifest); 214 shortcut_info_.UpdateFromManifest(data.manifest);
dominickn 2017/06/14 05:16:51 This isn't quite what I was suggesting on the othe
226 shortcut_info_.manifest_url = data.manifest_url; 215 shortcut_info_.manifest_url = data.manifest_url;
216 }
227 217
228 if (webapk_compatible) { 218 if (data.badge_icon && !data.badge_icon->drawsNothing()) {
229 shortcut_info_.UpdateSource(ShortcutInfo::SOURCE_ADD_TO_HOMESCREEN_PWA); 219 shortcut_info_.best_badge_icon_url = data.badge_icon_url;
230 220 badge_icon_ = *data.badge_icon;
231 if (data.badge_icon && !data.badge_icon->drawsNothing()) {
232 shortcut_info_.best_badge_icon_url = data.badge_icon_url;
233 badge_icon_ = *data.badge_icon;
234 }
235 }
236 } 221 }
237 222
238 // Save the splash screen URL for the later download. 223 // Save the splash screen URL for the later download.
239 shortcut_info_.splash_image_url = ManifestIconSelector::FindBestMatchingIcon( 224 shortcut_info_.splash_image_url = ManifestIconSelector::FindBestMatchingIcon(
240 data.manifest.icons, ideal_splash_image_size_in_px_, 225 data.manifest.icons, ideal_splash_image_size_in_px_,
241 minimum_splash_image_size_in_px_, 226 minimum_splash_image_size_in_px_,
242 content::Manifest::Icon::IconPurpose::ANY); 227 content::Manifest::Icon::IconPurpose::ANY);
243 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_;
244 shortcut_info_.minimum_splash_image_size_in_px = 229 shortcut_info_.minimum_splash_image_size_in_px =
245 minimum_splash_image_size_in_px_; 230 minimum_splash_image_size_in_px_;
246 231
232 if (check_webapk_compatibility_) {
233 bool webapk_compatible =
234 (data.error_code == NO_ERROR_DETECTED &&
235 AreWebManifestUrlsWebApkCompatible(data.manifest));
236 weak_observer_->OnDidDetermineWebApkCompatibility(webapk_compatible);
237
238 if (webapk_compatible)
239 shortcut_info_.UpdateSource(ShortcutInfo::SOURCE_ADD_TO_HOMESCREEN_PWA);
240 }
241
247 weak_observer_->OnUserTitleAvailable(shortcut_info_.user_title); 242 weak_observer_->OnUserTitleAvailable(shortcut_info_.user_title);
248 243
249 if (data.primary_icon) { 244 if (data.primary_icon) {
250 shortcut_info_.best_primary_icon_url = data.primary_icon_url; 245 shortcut_info_.best_primary_icon_url = data.primary_icon_url;
251 246
252 CreateLauncherIcon(*(data.primary_icon)); 247 CreateLauncherIcon(*(data.primary_icon));
253 return; 248 return;
254 } 249 }
255 250
256 FetchFavicon(); 251 FetchFavicon();
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 void AddToHomescreenDataFetcher::NotifyObserver(const SkBitmap& primary_icon) { 334 void AddToHomescreenDataFetcher::NotifyObserver(const SkBitmap& primary_icon) {
340 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 335 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
341 if (!web_contents() || !weak_observer_ || is_icon_saved_) 336 if (!web_contents() || !weak_observer_ || is_icon_saved_)
342 return; 337 return;
343 338
344 is_icon_saved_ = true; 339 is_icon_saved_ = true;
345 primary_icon_ = primary_icon; 340 primary_icon_ = primary_icon;
346 is_ready_ = true; 341 is_ready_ = true;
347 weak_observer_->OnDataAvailable(shortcut_info_, primary_icon_, badge_icon_); 342 weak_observer_->OnDataAvailable(shortcut_info_, primary_icon_, badge_icon_);
348 } 343 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698