OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/important_sites_util.h" | 5 #include "chrome/browser/engagement/important_sites_util.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <map> | 8 #include <map> |
9 #include <memory> | 9 #include <memory> |
10 #include <set> | 10 #include <set> |
(...skipping 18 matching lines...) Expand all Loading... |
29 #include "components/pref_registry/pref_registry_syncable.h" | 29 #include "components/pref_registry/pref_registry_syncable.h" |
30 #include "components/prefs/pref_service.h" | 30 #include "components/prefs/pref_service.h" |
31 #include "components/prefs/scoped_user_pref_update.h" | 31 #include "components/prefs/scoped_user_pref_update.h" |
32 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 32 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
33 #include "third_party/WebKit/public/platform/site_engagement.mojom.h" | 33 #include "third_party/WebKit/public/platform/site_engagement.mojom.h" |
34 #include "url/gurl.h" | 34 #include "url/gurl.h" |
35 | 35 |
36 namespace { | 36 namespace { |
37 using bookmarks::BookmarkModel; | 37 using bookmarks::BookmarkModel; |
38 using ImportantDomainInfo = ImportantSitesUtil::ImportantDomainInfo; | 38 using ImportantDomainInfo = ImportantSitesUtil::ImportantDomainInfo; |
| 39 using ImportantReason = ImportantSitesUtil::ImportantReason; |
39 | 40 |
40 // Note: These values are stored on both the per-site content settings | 41 // Note: These values are stored on both the per-site content settings |
41 // dictionary and the dialog preference dictionary. | 42 // dictionary and the dialog preference dictionary. |
42 | 43 |
43 static const char kTimeLastIgnored[] = "TimeLastIgnored"; | 44 static const char kTimeLastIgnored[] = "TimeLastIgnored"; |
44 static const int kBlacklistExpirationTimeDays = 30 * 5; | 45 static const int kBlacklistExpirationTimeDays = 30 * 5; |
45 | 46 |
46 static const char kNumTimesIgnoredName[] = "NumTimesIgnored"; | 47 static const char kNumTimesIgnoredName[] = "NumTimesIgnored"; |
47 static const int kTimesIgnoredForBlacklist = 3; | 48 static const int kTimesIgnoredForBlacklist = 3; |
48 | 49 |
49 // These are the maximum # of bookmarks we can use as signals. If the user has | 50 // These are the maximum # of bookmarks we can use as signals. If the user has |
50 // <= kMaxBookmarks, then we just use those bookmarks. Otherwise we filter all | 51 // <= kMaxBookmarks, then we just use those bookmarks. Otherwise we filter all |
51 // bookmarks on site engagement > 0, sort, and trim to kMaxBookmarks. | 52 // bookmarks on site engagement > 0, sort, and trim to kMaxBookmarks. |
52 static const int kMaxBookmarks = 5; | 53 static const int kMaxBookmarks = 5; |
53 | 54 |
54 // Do not change the values here, as they are used for UMA histograms. | |
55 enum ImportantReason { | |
56 ENGAGEMENT = 0, | |
57 DURABLE = 1, | |
58 BOOKMARKS = 2, | |
59 HOME_SCREEN = 3, | |
60 NOTIFICATIONS = 4, | |
61 REASON_BOUNDARY | |
62 }; | |
63 | |
64 // We need this to be a macro, as the histogram macros cache their pointers | 55 // We need this to be a macro, as the histogram macros cache their pointers |
65 // after the first call, so when we change the uma name we check fail if we're | 56 // after the first call, so when we change the uma name we check fail if we're |
66 // just a method. | 57 // just a method. |
67 #define RECORD_UMA_FOR_IMPORTANT_REASON(uma_name, uma_count_name, \ | 58 #define RECORD_UMA_FOR_IMPORTANT_REASON(uma_name, uma_count_name, \ |
68 reason_bitfield) \ | 59 reason_bitfield) \ |
69 do { \ | 60 do { \ |
70 int count = 0; \ | 61 int count = 0; \ |
71 int32_t bitfield = (reason_bitfield); \ | 62 int32_t bitfield = (reason_bitfield); \ |
72 for (int i = 0; i < ImportantReason::REASON_BOUNDARY; i++) { \ | 63 for (int i = 0; i < ImportantReason::REASON_BOUNDARY; i++) { \ |
73 if ((bitfield >> i) & 1) { \ | 64 if ((bitfield >> i) & 1) { \ |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 const GURL& origin) { | 478 const GURL& origin) { |
488 SiteEngagementScore::SetParamValuesForTesting(); | 479 SiteEngagementScore::SetParamValuesForTesting(); |
489 // First get data from site engagement. | 480 // First get data from site engagement. |
490 SiteEngagementService* site_engagement_service = | 481 SiteEngagementService* site_engagement_service = |
491 SiteEngagementService::Get(profile); | 482 SiteEngagementService::Get(profile); |
492 site_engagement_service->ResetBaseScoreForURL( | 483 site_engagement_service->ResetBaseScoreForURL( |
493 origin, SiteEngagementScore::GetMediumEngagementBoundary()); | 484 origin, SiteEngagementScore::GetMediumEngagementBoundary()); |
494 DCHECK(site_engagement_service->IsEngagementAtLeast( | 485 DCHECK(site_engagement_service->IsEngagementAtLeast( |
495 origin, blink::mojom::EngagementLevel::MEDIUM)); | 486 origin, blink::mojom::EngagementLevel::MEDIUM)); |
496 } | 487 } |
OLD | NEW |