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 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <utility> | 10 #include <utility> |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "chrome/browser/engagement/site_engagement_helper.h" | 22 #include "chrome/browser/engagement/site_engagement_helper.h" |
23 #include "chrome/browser/engagement/site_engagement_metrics.h" | 23 #include "chrome/browser/engagement/site_engagement_metrics.h" |
24 #include "chrome/browser/engagement/site_engagement_score.h" | 24 #include "chrome/browser/engagement/site_engagement_score.h" |
25 #include "chrome/browser/engagement/site_engagement_service_factory.h" | 25 #include "chrome/browser/engagement/site_engagement_service_factory.h" |
26 #include "chrome/browser/history/history_service_factory.h" | 26 #include "chrome/browser/history/history_service_factory.h" |
27 #include "chrome/browser/profiles/profile.h" | 27 #include "chrome/browser/profiles/profile.h" |
28 #include "chrome/common/chrome_switches.h" | 28 #include "chrome/common/chrome_switches.h" |
29 #include "chrome/common/pref_names.h" | 29 #include "chrome/common/pref_names.h" |
30 #include "components/content_settings/core/browser/host_content_settings_map.h" | 30 #include "components/content_settings/core/browser/host_content_settings_map.h" |
31 #include "components/content_settings/core/common/content_settings_pattern.h" | 31 #include "components/content_settings/core/common/content_settings_pattern.h" |
| 32 #include "components/content_settings/core/common/content_settings_utils.h" |
32 #include "components/history/core/browser/history_service.h" | 33 #include "components/history/core/browser/history_service.h" |
33 #include "components/prefs/pref_service.h" | 34 #include "components/prefs/pref_service.h" |
34 #include "content/public/browser/browser_thread.h" | 35 #include "content/public/browser/browser_thread.h" |
35 #include "content/public/browser/render_frame_host.h" | 36 #include "content/public/browser/render_frame_host.h" |
36 #include "content/public/browser/web_contents.h" | 37 #include "content/public/browser/web_contents.h" |
37 #include "content/public/common/associated_interface_provider.h" | 38 #include "content/public/common/associated_interface_provider.h" |
38 #include "url/gurl.h" | 39 #include "url/gurl.h" |
39 | 40 |
40 #if defined(OS_ANDROID) | 41 #if defined(OS_ANDROID) |
41 #include "chrome/browser/engagement/site_engagement_service_android.h" | 42 #include "chrome/browser/engagement/site_engagement_service_android.h" |
(...skipping 26 matching lines...) Expand all Loading... |
68 | 69 |
69 // Fetch URLs of sites with engagement details stored. | 70 // Fetch URLs of sites with engagement details stored. |
70 for (const auto& site : GetContentSettingsFromProfile( | 71 for (const auto& site : GetContentSettingsFromProfile( |
71 profile, CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT)) { | 72 profile, CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT)) { |
72 urls.insert(GURL(site.primary_pattern.ToString())); | 73 urls.insert(GURL(site.primary_pattern.ToString())); |
73 } | 74 } |
74 | 75 |
75 // Fetch URLs of sites for which notifications are allowed. | 76 // Fetch URLs of sites for which notifications are allowed. |
76 for (const auto& site : GetContentSettingsFromProfile( | 77 for (const auto& site : GetContentSettingsFromProfile( |
77 profile, CONTENT_SETTINGS_TYPE_NOTIFICATIONS)) { | 78 profile, CONTENT_SETTINGS_TYPE_NOTIFICATIONS)) { |
78 if (site.setting != CONTENT_SETTING_ALLOW) | 79 if (content_settings::ValueToContentSetting(site.setting_value.get()) != |
| 80 CONTENT_SETTING_ALLOW) { |
79 continue; | 81 continue; |
| 82 } |
80 urls.insert(GURL(site.primary_pattern.ToString())); | 83 urls.insert(GURL(site.primary_pattern.ToString())); |
81 } | 84 } |
82 | 85 |
83 return urls; | 86 return urls; |
84 } | 87 } |
85 | 88 |
86 // Only accept a navigation event for engagement if it is one of: | 89 // Only accept a navigation event for engagement if it is one of: |
87 // a. direct typed navigation | 90 // a. direct typed navigation |
88 // b. clicking on an omnibox suggestion brought up by typing a keyword | 91 // b. clicking on an omnibox suggestion brought up by typing a keyword |
89 // c. clicking on a bookmark or opening a bookmark app | 92 // c. clicking on a bookmark or opening a bookmark app |
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
701 if (!engagement_score.last_shortcut_launch_time().is_null() && | 704 if (!engagement_score.last_shortcut_launch_time().is_null() && |
702 engagement_score.last_shortcut_launch_time() > last_visit) { | 705 engagement_score.last_shortcut_launch_time() > last_visit) { |
703 engagement_score.set_last_shortcut_launch_time(last_visit); | 706 engagement_score.set_last_shortcut_launch_time(last_visit); |
704 } | 707 } |
705 | 708 |
706 engagement_score.Commit(); | 709 engagement_score.Commit(); |
707 } | 710 } |
708 | 711 |
709 SetLastEngagementTime(now); | 712 SetLastEngagementTime(now); |
710 } | 713 } |
OLD | NEW |