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

Side by Side Diff: chrome/browser/banners/app_banner_settings_helper.cc

Issue 2259553002: Make AppBannerInfoBar install WebAPK. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move logic to WebApkInstaller. Created 4 years, 3 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/banners/app_banner_settings_helper.h" 5 #include "chrome/browser/banners/app_banner_settings_helper.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <string> 10 #include <string>
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 void UpdateMinutesBetweenVisits() { 190 void UpdateMinutesBetweenVisits() {
191 std::string param = variations::GetVariationParamValue( 191 std::string param = variations::GetVariationParamValue(
192 kBannerParamsKey, kBannerParamsMinutesKey); 192 kBannerParamsKey, kBannerParamsMinutesKey);
193 if (!param.empty()) { 193 if (!param.empty()) {
194 int minimum_minutes = 0; 194 int minimum_minutes = 0;
195 if (base::StringToInt(param, &minimum_minutes)) 195 if (base::StringToInt(param, &minimum_minutes))
196 AppBannerSettingsHelper::SetMinimumMinutesBetweenVisits(minimum_minutes); 196 AppBannerSettingsHelper::SetMinimumMinutesBetweenVisits(minimum_minutes);
197 } 197 }
198 } 198 }
199 199
200 std::string getMetric(
dominickn 2016/08/25 04:25:56 This should return const std::string or a base::St
Xi Han 2016/08/26 17:04:18 Done.
201 const AppBannerSettingsHelper::AppBannerRapporMetric& rappor_metric) {
202 if (rappor_metric == AppBannerSettingsHelper::NATIVE)
203 return "AppBanner.NativeApp.Installed";
204 else if (rappor_metric == AppBannerSettingsHelper::WEB)
205 return "AppBanner.WebApp.Installed";
206 else
207 return "AppBanner.WebApk.Installed";
208 }
209
200 } // namespace 210 } // namespace
201 211
202 void AppBannerSettingsHelper::ClearHistoryForURLs( 212 void AppBannerSettingsHelper::ClearHistoryForURLs(
203 Profile* profile, 213 Profile* profile,
204 const std::set<GURL>& origin_urls) { 214 const std::set<GURL>& origin_urls) {
205 HostContentSettingsMap* settings = 215 HostContentSettingsMap* settings =
206 HostContentSettingsMapFactory::GetForProfile(profile); 216 HostContentSettingsMapFactory::GetForProfile(profile);
207 for (const GURL& origin_url : origin_urls) { 217 for (const GURL& origin_url : origin_urls) {
208 settings->SetWebsiteSettingDefaultScope(origin_url, GURL(), 218 settings->SetWebsiteSettingDefaultScope(origin_url, GURL(),
209 CONTENT_SETTINGS_TYPE_APP_BANNER, 219 CONTENT_SETTINGS_TYPE_APP_BANNER,
210 std::string(), nullptr); 220 std::string(), nullptr);
211 settings->FlushLossyWebsiteSettings(); 221 settings->FlushLossyWebsiteSettings();
212 } 222 }
213 } 223 }
214 224
215 void AppBannerSettingsHelper::RecordBannerInstallEvent( 225 void AppBannerSettingsHelper::RecordBannerInstallEvent(
216 content::WebContents* web_contents, 226 content::WebContents* web_contents,
217 const std::string& package_name_or_start_url, 227 const std::string& package_name_or_start_url,
218 AppBannerRapporMetric rappor_metric) { 228 AppBannerRapporMetric rappor_metric) {
219 banners::TrackInstallEvent(banners::INSTALL_EVENT_WEB_APP_INSTALLED); 229 banners::TrackInstallEvent(banners::INSTALL_EVENT_WEB_APP_INSTALLED);
220 230
221 AppBannerSettingsHelper::RecordBannerEvent( 231 AppBannerSettingsHelper::RecordBannerEvent(
222 web_contents, web_contents->GetURL(), package_name_or_start_url, 232 web_contents, web_contents->GetURL(), package_name_or_start_url,
223 AppBannerSettingsHelper::APP_BANNER_EVENT_DID_ADD_TO_HOMESCREEN, 233 AppBannerSettingsHelper::APP_BANNER_EVENT_DID_ADD_TO_HOMESCREEN,
224 banners::AppBannerManager::GetCurrentTime()); 234 banners::AppBannerManager::GetCurrentTime());
225 235
226 rappor::SampleDomainAndRegistryFromGURL( 236 rappor::SampleDomainAndRegistryFromGURL(
227 g_browser_process->rappor_service(), 237 g_browser_process->rappor_service(),
228 (rappor_metric == WEB ? "AppBanner.WebApp.Installed" 238 getMetric(rappor_metric),
229 : "AppBanner.NativeApp.Installed"),
230 web_contents->GetURL()); 239 web_contents->GetURL());
231 } 240 }
232 241
233 void AppBannerSettingsHelper::RecordBannerDismissEvent( 242 void AppBannerSettingsHelper::RecordBannerDismissEvent(
234 content::WebContents* web_contents, 243 content::WebContents* web_contents,
235 const std::string& package_name_or_start_url, 244 const std::string& package_name_or_start_url,
236 AppBannerRapporMetric rappor_metric) { 245 AppBannerRapporMetric rappor_metric) {
237 banners::TrackDismissEvent(banners::DISMISS_EVENT_CLOSE_BUTTON); 246 banners::TrackDismissEvent(banners::DISMISS_EVENT_CLOSE_BUTTON);
238 247
239 AppBannerSettingsHelper::RecordBannerEvent( 248 AppBannerSettingsHelper::RecordBannerEvent(
240 web_contents, web_contents->GetURL(), package_name_or_start_url, 249 web_contents, web_contents->GetURL(), package_name_or_start_url,
241 AppBannerSettingsHelper::APP_BANNER_EVENT_DID_BLOCK, 250 AppBannerSettingsHelper::APP_BANNER_EVENT_DID_BLOCK,
242 banners::AppBannerManager::GetCurrentTime()); 251 banners::AppBannerManager::GetCurrentTime());
243 252
244 rappor::SampleDomainAndRegistryFromGURL( 253 rappor::SampleDomainAndRegistryFromGURL(
245 g_browser_process->rappor_service(), 254 g_browser_process->rappor_service(),
246 (rappor_metric == WEB ? "AppBanner.WebApp.Dismissed" 255 getMetric(rappor_metric),
247 : "AppBanner.NativeApp.Dismissed"),
248 web_contents->GetURL()); 256 web_contents->GetURL());
249 } 257 }
250 258
251 void AppBannerSettingsHelper::RecordBannerEvent( 259 void AppBannerSettingsHelper::RecordBannerEvent(
252 content::WebContents* web_contents, 260 content::WebContents* web_contents,
253 const GURL& origin_url, 261 const GURL& origin_url,
254 const std::string& package_name_or_start_url, 262 const std::string& package_name_or_start_url,
255 AppBannerEvent event, 263 AppBannerEvent event,
256 base::Time time) { 264 base::Time time) {
257 DCHECK(event != APP_BANNER_EVENT_COULD_SHOW); 265 DCHECK(event != APP_BANNER_EVENT_COULD_SHOW);
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 return true; 657 return true;
650 } 658 }
651 659
652 // Assume any value which is not "0" or "false" indicates that we should use 660 // Assume any value which is not "0" or "false" indicates that we should use
653 // site engagement. 661 // site engagement.
654 std::string param = variations::GetVariationParamValue( 662 std::string param = variations::GetVariationParamValue(
655 kBannerParamsKey, kBannerSiteEngagementParamsKey); 663 kBannerParamsKey, kBannerSiteEngagementParamsKey);
656 664
657 return (!param.empty() && param != "0" && param != "false"); 665 return (!param.empty() && param != "0" && param != "false");
658 } 666 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698