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

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

Issue 919843003: Clear app banner data when history is cleared. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Feedback Created 5 years, 10 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 | chrome/browser/banners/app_banner_settings_helper.cc » ('j') | 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 #ifndef CHROME_BROWSER_BANNERS_APP_BANNER_SETTINGS_HELPER_H_ 5 #ifndef CHROME_BROWSER_BANNERS_APP_BANNER_SETTINGS_HELPER_H_
6 #define CHROME_BROWSER_BANNERS_APP_BANNER_SETTINGS_HELPER_H_ 6 #define CHROME_BROWSER_BANNERS_APP_BANNER_SETTINGS_HELPER_H_
7 7
8 #include <set>
8 #include <string> 9 #include <string>
9 #include <vector> 10 #include <vector>
10 11
11 #include "base/macros.h" 12 #include "base/macros.h"
12 #include "base/time/time.h" 13 #include "base/time/time.h"
13 14
14 namespace content { 15 namespace content {
15 class WebContents; 16 class WebContents;
16 } // namespace content 17 } // namespace content
17 18
18 class GURL; 19 class GURL;
20 class Profile;
19 21
20 // Utility class to record banner events for the given package or start url. 22 // Utility class to record banner events for the given package or start url.
21 // 23 //
22 // These events are used to decide when banners should be shown, using a 24 // These events are used to decide when banners should be shown, using a
23 // heuristic based on how many different days in a recent period of time (for 25 // heuristic based on how many different days in a recent period of time (for
24 // example the past two weeks) the banner could have been shown, when it was 26 // example the past two weeks) the banner could have been shown, when it was
25 // last shown, when it was last blocked, and when it was last installed (for 27 // last shown, when it was last blocked, and when it was last installed (for
26 // ServiceWorker style apps - native apps can query whether the app was 28 // ServiceWorker style apps - native apps can query whether the app was
27 // installed directly). 29 // installed directly).
28 // 30 //
29 // The desired effect is to have banners appear once a user has demonstrated 31 // The desired effect is to have banners appear once a user has demonstrated
30 // an ongoing relationship with the app, and not to pester the user too much. 32 // an ongoing relationship with the app, and not to pester the user too much.
31 // 33 //
32 // For most events only the last event is recorded. The exception are the 34 // For most events only the last event is recorded. The exception are the
33 // could show events. For these a list of the events is maintained. At most 35 // could show events. For these a list of the events is maintained. At most
34 // one event is stored per day, and events outside the window the heuristic 36 // one event is stored per day, and events outside the window the heuristic
35 // uses are discarded. Local times are used to enforce these rules, to ensure 37 // uses are discarded. Local times are used to enforce these rules, to ensure
36 // what we count as a day matches what the user perceives to be days. 38 // what we count as a day matches what the user perceives to be days.
37 class AppBannerSettingsHelper { 39 class AppBannerSettingsHelper {
38 public: 40 public:
39 enum AppBannerEvent { 41 enum AppBannerEvent {
40 APP_BANNER_EVENT_COULD_SHOW, 42 APP_BANNER_EVENT_COULD_SHOW,
41 APP_BANNER_EVENT_DID_SHOW, 43 APP_BANNER_EVENT_DID_SHOW,
42 APP_BANNER_EVENT_DID_BLOCK, 44 APP_BANNER_EVENT_DID_BLOCK,
43 APP_BANNER_EVENT_DID_ADD_TO_HOMESCREEN, 45 APP_BANNER_EVENT_DID_ADD_TO_HOMESCREEN,
44 APP_BANNER_EVENT_NUM_EVENTS, 46 APP_BANNER_EVENT_NUM_EVENTS,
45 }; 47 };
46 48
49 // The content setting basically records a simplified subset of history.
50 // For privacy reasons this needs to be cleared. The ClearHistoryForURLs
51 // function removes any information from the banner content settings for the
52 // given URls.
53 static void ClearHistoryForURLs(Profile* profile,
54 const std::set<GURL>& origin_urls);
55
47 static void RecordBannerEvent(content::WebContents* web_contents, 56 static void RecordBannerEvent(content::WebContents* web_contents,
48 const GURL& origin_url, 57 const GURL& origin_url,
49 const std::string& package_name_or_start_url, 58 const std::string& package_name_or_start_url,
50 AppBannerEvent event, 59 AppBannerEvent event,
51 base::Time time); 60 base::Time time);
52 61
53 // Determine if the banner should be shown, given the recorded events for the 62 // Determine if the banner should be shown, given the recorded events for the
54 // supplied app. 63 // supplied app.
55 static bool ShouldShowBanner(content::WebContents* web_contents, 64 static bool ShouldShowBanner(content::WebContents* web_contents,
56 const GURL& origin_url, 65 const GURL& origin_url,
(...skipping 25 matching lines...) Expand all
82 // Blocks a URL from showing a banner for the given package or start url. 91 // Blocks a URL from showing a banner for the given package or start url.
83 static void Block(content::WebContents* web_contents, 92 static void Block(content::WebContents* web_contents,
84 const GURL& origin_url, 93 const GURL& origin_url,
85 const std::string& package_name_or_start_url); 94 const std::string& package_name_or_start_url);
86 95
87 private: 96 private:
88 DISALLOW_IMPLICIT_CONSTRUCTORS(AppBannerSettingsHelper); 97 DISALLOW_IMPLICIT_CONSTRUCTORS(AppBannerSettingsHelper);
89 }; 98 };
90 99
91 #endif // CHROME_BROWSER_BANNERS_APP_BANNER_SETTINGS_HELPER_H_ 100 #endif // CHROME_BROWSER_BANNERS_APP_BANNER_SETTINGS_HELPER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/banners/app_banner_settings_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698