| OLD | NEW |
| 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/engagement/site_engagement_service.h" | 5 #include "chrome/browser/engagement/site_engagement_service.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <cmath> | 9 #include <cmath> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 | 369 |
| 370 const char SiteEngagementService::kEngagementParams[] = "SiteEngagement"; | 370 const char SiteEngagementService::kEngagementParams[] = "SiteEngagement"; |
| 371 | 371 |
| 372 // static | 372 // static |
| 373 SiteEngagementService* SiteEngagementService::Get(Profile* profile) { | 373 SiteEngagementService* SiteEngagementService::Get(Profile* profile) { |
| 374 return SiteEngagementServiceFactory::GetForProfile(profile); | 374 return SiteEngagementServiceFactory::GetForProfile(profile); |
| 375 } | 375 } |
| 376 | 376 |
| 377 // static | 377 // static |
| 378 bool SiteEngagementService::IsEnabled() { | 378 bool SiteEngagementService::IsEnabled() { |
| 379 // If the engagement service or any of its dependencies are force-enabled, | 379 return true; |
| 380 // return true immediately. | |
| 381 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 382 switches::kEnableSiteEngagementService) || | |
| 383 SiteEngagementEvictionPolicy::IsEnabled() || | |
| 384 AppBannerSettingsHelper::ShouldUseSiteEngagementScore()) { | |
| 385 return true; | |
| 386 } | |
| 387 | |
| 388 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 389 switches::kDisableSiteEngagementService)) { | |
| 390 return false; | |
| 391 } | |
| 392 const std::string group_name = | |
| 393 base::FieldTrialList::FindFullName(kEngagementParams); | |
| 394 return base::StartsWith(group_name, "Enabled", base::CompareCase::SENSITIVE); | |
| 395 } | 380 } |
| 396 | 381 |
| 397 SiteEngagementService::SiteEngagementService(Profile* profile) | 382 SiteEngagementService::SiteEngagementService(Profile* profile) |
| 398 : SiteEngagementService(profile, make_scoped_ptr(new base::DefaultClock)) { | 383 : SiteEngagementService(profile, make_scoped_ptr(new base::DefaultClock)) { |
| 399 content::BrowserThread::PostAfterStartupTask( | 384 content::BrowserThread::PostAfterStartupTask( |
| 400 FROM_HERE, content::BrowserThread::GetMessageLoopProxyForThread( | 385 FROM_HERE, content::BrowserThread::GetMessageLoopProxyForThread( |
| 401 content::BrowserThread::UI), | 386 content::BrowserThread::UI), |
| 402 base::Bind(&SiteEngagementService::AfterStartupTask, | 387 base::Bind(&SiteEngagementService::AfterStartupTask, |
| 403 weak_factory_.GetWeakPtr())); | 388 weak_factory_.GetWeakPtr())); |
| 404 | 389 |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 740 HostContentSettingsMapFactory::GetForProfile(profile_); | 725 HostContentSettingsMapFactory::GetForProfile(profile_); |
| 741 for (const auto& origin_to_count : origin_counts) { | 726 for (const auto& origin_to_count : origin_counts) { |
| 742 if (origin_to_count.second != 0) | 727 if (origin_to_count.second != 0) |
| 743 continue; | 728 continue; |
| 744 | 729 |
| 745 settings_map->SetWebsiteSettingDefaultScope( | 730 settings_map->SetWebsiteSettingDefaultScope( |
| 746 origin_to_count.first, GURL(), CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, | 731 origin_to_count.first, GURL(), CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, |
| 747 std::string(), nullptr); | 732 std::string(), nullptr); |
| 748 } | 733 } |
| 749 } | 734 } |
| OLD | NEW |