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

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

Issue 1011963003: Modify behavior of --bypass-app-banner-engagement-checks flag. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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 | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 settings->SetWebsiteSetting(pattern, ContentSettingsPattern::Wildcard(), 173 settings->SetWebsiteSetting(pattern, ContentSettingsPattern::Wildcard(),
174 CONTENT_SETTINGS_TYPE_APP_BANNER, std::string(), 174 CONTENT_SETTINGS_TYPE_APP_BANNER, std::string(),
175 origin_dict.release()); 175 origin_dict.release());
176 } 176 }
177 177
178 bool AppBannerSettingsHelper::ShouldShowBanner( 178 bool AppBannerSettingsHelper::ShouldShowBanner(
179 content::WebContents* web_contents, 179 content::WebContents* web_contents,
180 const GURL& origin_url, 180 const GURL& origin_url,
181 const std::string& package_name_or_start_url, 181 const std::string& package_name_or_start_url,
182 base::Time time) { 182 base::Time time) {
183 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
184 switches::kBypassAppBannerEngagementChecks)) {
185 return true;
186 }
187
188 // Don't show if it has been added to the homescreen. 183 // Don't show if it has been added to the homescreen.
189 base::Time added_time = 184 base::Time added_time =
190 GetSingleBannerEvent(web_contents, origin_url, package_name_or_start_url, 185 GetSingleBannerEvent(web_contents, origin_url, package_name_or_start_url,
191 APP_BANNER_EVENT_DID_ADD_TO_HOMESCREEN); 186 APP_BANNER_EVENT_DID_ADD_TO_HOMESCREEN);
192 if (!added_time.is_null()) { 187 if (!added_time.is_null()) {
193 banners::TrackDisplayEvent(banners::DISPLAY_EVENT_INSTALLED_PREVIOUSLY); 188 banners::TrackDisplayEvent(banners::DISPLAY_EVENT_INSTALLED_PREVIOUSLY);
194 return false; 189 return false;
195 } 190 }
196 191
192 // Otherwise, ignore all checks if the flag to do so is set.
193 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
194 switches::kBypassAppBannerEngagementChecks)) {
195 return true;
196 }
197
197 base::Time blocked_time = 198 base::Time blocked_time =
198 GetSingleBannerEvent(web_contents, origin_url, package_name_or_start_url, 199 GetSingleBannerEvent(web_contents, origin_url, package_name_or_start_url,
199 APP_BANNER_EVENT_DID_BLOCK); 200 APP_BANNER_EVENT_DID_BLOCK);
200 201
201 // Null times are in the distant past, so the delta between real times and 202 // Null times are in the distant past, so the delta between real times and
202 // null events will always be greater than the limits. 203 // null events will always be greater than the limits.
203 if (time - blocked_time < 204 if (time - blocked_time <
204 base::TimeDelta::FromDays(kMinimumBannerBlockedToBannerShown)) { 205 base::TimeDelta::FromDays(kMinimumBannerBlockedToBannerShown)) {
205 banners::TrackDisplayEvent(banners::DISPLAY_EVENT_BLOCKED_PREVIOUSLY); 206 banners::TrackDisplayEvent(banners::DISPLAY_EVENT_BLOCKED_PREVIOUSLY);
206 return false; 207 return false;
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 GetAppDict(origin_dict.get(), package_name_or_start_url); 354 GetAppDict(origin_dict.get(), package_name_or_start_url);
354 if (!app_dict) 355 if (!app_dict)
355 return; 356 return;
356 357
357 // Update the setting and save it back. 358 // Update the setting and save it back.
358 app_dict->SetBoolean(kHasBlockedKey, true); 359 app_dict->SetBoolean(kHasBlockedKey, true);
359 settings->SetWebsiteSetting(pattern, ContentSettingsPattern::Wildcard(), 360 settings->SetWebsiteSetting(pattern, ContentSettingsPattern::Wildcard(),
360 CONTENT_SETTINGS_TYPE_APP_BANNER, std::string(), 361 CONTENT_SETTINGS_TYPE_APP_BANNER, std::string(),
361 origin_dict.release()); 362 origin_dict.release());
362 } 363 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698