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

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
« no previous file with comments | « no previous file | chrome/browser/android/webapps/add_to_homescreen_data_fetcher_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 use_manifest = false;
210 bool webapk_compatible = false; 211 bool webapk_compatible = false;
211 if (check_webapk_compatibility_) { 212 if (!data.manifest.name.string().empty() ||
212 webapk_compatible = (data.error_code == NO_ERROR_DETECTED && 213 !data.manifest.short_name.string().empty()) {
213 AreWebManifestUrlsWebApkCompatible(data.manifest)); 214 use_manifest = true;
214 weak_observer_->OnDidDetermineWebApkCompatibility(webapk_compatible); 215 base::RecordAction(base::UserMetricsAction("webapps.AddShortcut.Manifest"));
215 216
216 if (webapk_compatible) { 217 shortcut_info_ = ShortcutInfo(GURL());
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"));
225 shortcut_info_.UpdateFromManifest(data.manifest); 218 shortcut_info_.UpdateFromManifest(data.manifest);
226 shortcut_info_.manifest_url = data.manifest_url; 219 shortcut_info_.manifest_url = data.manifest_url;
227 220
228 if (webapk_compatible) { 221 if (data.badge_icon && !data.badge_icon->drawsNothing()) {
dominickn 2017/06/15 05:16:23 We only want to grab the badge icon in the case of
222 shortcut_info_.best_badge_icon_url = data.badge_icon_url;
223 badge_icon_ = *data.badge_icon;
224 }
225
226 // Save the splash screen URL for the later download.
227 shortcut_info_.splash_image_url =
228 ManifestIconSelector::FindBestMatchingIcon(
229 data.manifest.icons, ideal_splash_image_size_in_px_,
230 minimum_splash_image_size_in_px_,
231 content::Manifest::Icon::IconPurpose::ANY);
232 shortcut_info_.ideal_splash_image_size_in_px =
233 ideal_splash_image_size_in_px_;
234 shortcut_info_.minimum_splash_image_size_in_px =
235 minimum_splash_image_size_in_px_;
236
237 webapk_compatible = check_webapk_compatibility_ &&
238 data.error_code == NO_ERROR_DETECTED &&
239 AreWebManifestUrlsWebApkCompatible(data.manifest);
240 if (webapk_compatible)
229 shortcut_info_.UpdateSource(ShortcutInfo::SOURCE_ADD_TO_HOMESCREEN_PWA); 241 shortcut_info_.UpdateSource(ShortcutInfo::SOURCE_ADD_TO_HOMESCREEN_PWA);
230
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 } 242 }
237 243
238 // Save the splash screen URL for the later download. 244 if (check_webapk_compatibility_)
239 shortcut_info_.splash_image_url = ManifestIconSelector::FindBestMatchingIcon( 245 weak_observer_->OnDidDetermineWebApkCompatibility(webapk_compatible);
240 data.manifest.icons, ideal_splash_image_size_in_px_,
241 minimum_splash_image_size_in_px_,
242 content::Manifest::Icon::IconPurpose::ANY);
243 shortcut_info_.ideal_splash_image_size_in_px = ideal_splash_image_size_in_px_;
244 shortcut_info_.minimum_splash_image_size_in_px =
245 minimum_splash_image_size_in_px_;
246
247 weak_observer_->OnUserTitleAvailable(shortcut_info_.user_title); 246 weak_observer_->OnUserTitleAvailable(shortcut_info_.user_title);
248 247
249 if (data.primary_icon) { 248 if (use_manifest && data.primary_icon) {
dominickn 2017/06/15 05:16:23 I don't think we want to guard this behind use_man
250 shortcut_info_.best_primary_icon_url = data.primary_icon_url; 249 shortcut_info_.best_primary_icon_url = data.primary_icon_url;
251 250
252 CreateLauncherIcon(*(data.primary_icon)); 251 CreateLauncherIcon(*(data.primary_icon));
253 return; 252 return;
254 } 253 }
255 254
256 FetchFavicon(); 255 FetchFavicon();
257 } 256 }
258 257
259 void AddToHomescreenDataFetcher::FetchFavicon() { 258 void AddToHomescreenDataFetcher::FetchFavicon() {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 void AddToHomescreenDataFetcher::NotifyObserver(const SkBitmap& primary_icon) { 338 void AddToHomescreenDataFetcher::NotifyObserver(const SkBitmap& primary_icon) {
340 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 339 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
341 if (!web_contents() || !weak_observer_ || is_icon_saved_) 340 if (!web_contents() || !weak_observer_ || is_icon_saved_)
342 return; 341 return;
343 342
344 is_icon_saved_ = true; 343 is_icon_saved_ = true;
345 primary_icon_ = primary_icon; 344 primary_icon_ = primary_icon;
346 is_ready_ = true; 345 is_ready_ = true;
347 weak_observer_->OnDataAvailable(shortcut_info_, primary_icon_, badge_icon_); 346 weak_observer_->OnDataAvailable(shortcut_info_, primary_icon_, badge_icon_);
348 } 347 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/android/webapps/add_to_homescreen_data_fetcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698