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

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

Issue 2707773003: Improve the resolution of the menu item homescreen launch source metric. (Closed)
Patch Set: Created 3 years, 10 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 | « chrome/browser/android/shortcut_info.cc ('k') | tools/metrics/histograms/histograms.xml » ('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/callback.h" 10 #include "base/callback.h"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 // Simply set the user-editable title to be the page's title 106 // Simply set the user-editable title to be the page's title
107 shortcut_info_.user_title = web_app_info.title.empty() 107 shortcut_info_.user_title = web_app_info.title.empty()
108 ? web_contents()->GetTitle() 108 ? web_contents()->GetTitle()
109 : web_app_info.title; 109 : web_app_info.title;
110 shortcut_info_.short_name = shortcut_info_.user_title; 110 shortcut_info_.short_name = shortcut_info_.user_title;
111 shortcut_info_.name = shortcut_info_.user_title; 111 shortcut_info_.name = shortcut_info_.user_title;
112 112
113 if (web_app_info.mobile_capable == WebApplicationInfo::MOBILE_CAPABLE || 113 if (web_app_info.mobile_capable == WebApplicationInfo::MOBILE_CAPABLE ||
114 web_app_info.mobile_capable == WebApplicationInfo::MOBILE_CAPABLE_APPLE) { 114 web_app_info.mobile_capable == WebApplicationInfo::MOBILE_CAPABLE_APPLE) {
115 shortcut_info_.display = blink::WebDisplayModeStandalone; 115 shortcut_info_.display = blink::WebDisplayModeStandalone;
116 shortcut_info_.UpdateSource(
117 ShortcutInfo::SOURCE_ADD_TO_HOMESCREEN_STANDALONE);
116 } 118 }
117 119
118 // Record what type of shortcut was added by the user. 120 // Record what type of shortcut was added by the user.
119 switch (web_app_info.mobile_capable) { 121 switch (web_app_info.mobile_capable) {
120 case WebApplicationInfo::MOBILE_CAPABLE: 122 case WebApplicationInfo::MOBILE_CAPABLE:
121 content::RecordAction( 123 content::RecordAction(
122 base::UserMetricsAction("webapps.AddShortcut.AppShortcut")); 124 base::UserMetricsAction("webapps.AddShortcut.AppShortcut"));
123 break; 125 break;
124 case WebApplicationInfo::MOBILE_CAPABLE_APPLE: 126 case WebApplicationInfo::MOBILE_CAPABLE_APPLE:
125 content::RecordAction( 127 content::RecordAction(
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 CreateLauncherIcon(SkBitmap()); 187 CreateLauncherIcon(SkBitmap());
186 } 188 }
187 189
188 void AddToHomescreenDataFetcher::OnDidPerformInstallableCheck( 190 void AddToHomescreenDataFetcher::OnDidPerformInstallableCheck(
189 const InstallableData& data) { 191 const InstallableData& data) {
190 if (!web_contents() || !weak_observer_) 192 if (!web_contents() || !weak_observer_)
191 return; 193 return;
192 194
193 is_installable_check_complete_ = true; 195 is_installable_check_complete_ = true;
194 196
197 bool webapk_compatible = false;
195 if (check_webapk_compatibility_) { 198 if (check_webapk_compatibility_) {
196 bool webapk_compatible = 199 webapk_compatible = (data.error_code == NO_ERROR_DETECTED &&
197 (data.error_code == NO_ERROR_DETECTED && 200 AreWebManifestUrlsWebApkCompatible(data.manifest));
198 AreWebManifestUrlsWebApkCompatible(data.manifest));
199 weak_observer_->OnDidDetermineWebApkCompatibility(webapk_compatible); 201 weak_observer_->OnDidDetermineWebApkCompatibility(webapk_compatible);
200 202
201 // WebAPKs are wholly defined by the Web Manifest. Ignore the <meta> tag 203 // WebAPKs are wholly defined by the Web Manifest. Ignore the <meta> tag
202 // data received in OnDidGetWebApplicationInfo(). 204 // data received in OnDidGetWebApplicationInfo().
203 if (webapk_compatible) 205 if (webapk_compatible)
204 shortcut_info_ = ShortcutInfo(GURL()); 206 shortcut_info_ = ShortcutInfo(GURL());
205 } 207 }
206 208
207 if (!data.manifest.IsEmpty()) { 209 if (!data.manifest.IsEmpty()) {
208 content::RecordAction( 210 content::RecordAction(
209 base::UserMetricsAction("webapps.AddShortcut.Manifest")); 211 base::UserMetricsAction("webapps.AddShortcut.Manifest"));
210 shortcut_info_.UpdateFromManifest(data.manifest); 212 shortcut_info_.UpdateFromManifest(data.manifest);
211 shortcut_info_.manifest_url = data.manifest_url; 213 shortcut_info_.manifest_url = data.manifest_url;
214
215 if (webapk_compatible) {
216 shortcut_info_.UpdateSource(ShortcutInfo::SOURCE_ADD_TO_HOMESCREEN_PWA);
217
218 if (data.badge_icon && !data.badge_icon->drawsNothing()) {
219 shortcut_info_.best_badge_icon_url = data.badge_icon_url;
220 badge_icon_ = *data.badge_icon;
221 }
222 }
212 } 223 }
213 224
214 // Save the splash screen URL for the later download. 225 // Save the splash screen URL for the later download.
215 splash_screen_url_ = ManifestIconSelector::FindBestMatchingIcon( 226 splash_screen_url_ = ManifestIconSelector::FindBestMatchingIcon(
216 data.manifest.icons, ideal_splash_image_size_in_px_, 227 data.manifest.icons, ideal_splash_image_size_in_px_,
217 minimum_splash_image_size_in_px_); 228 minimum_splash_image_size_in_px_);
218 229
219 weak_observer_->OnUserTitleAvailable(shortcut_info_.user_title); 230 weak_observer_->OnUserTitleAvailable(shortcut_info_.user_title);
220 231
221 if (data.primary_icon) { 232 if (data.primary_icon) {
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 void AddToHomescreenDataFetcher::NotifyObserver(const SkBitmap& icon) { 323 void AddToHomescreenDataFetcher::NotifyObserver(const SkBitmap& icon) {
313 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 324 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
314 if (!web_contents() || !weak_observer_ || is_icon_saved_) 325 if (!web_contents() || !weak_observer_ || is_icon_saved_)
315 return; 326 return;
316 327
317 is_icon_saved_ = true; 328 is_icon_saved_ = true;
318 shortcut_icon_ = icon; 329 shortcut_icon_ = icon;
319 is_ready_ = true; 330 is_ready_ = true;
320 weak_observer_->OnDataAvailable(shortcut_info_, shortcut_icon_); 331 weak_observer_->OnDataAvailable(shortcut_info_, shortcut_icon_);
321 } 332 }
OLDNEW
« no previous file with comments | « chrome/browser/android/shortcut_info.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698