OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
Lei Zhang
2015/02/02 19:50:13
It's 2015
benwells
2015/02/03 02:33:45
This file has been moved from chrome/browser/andro
Lei Zhang
2015/02/03 02:39:38
Oh, for some reason the file's status is "A" inste
| |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_BANNERS_APP_BANNER_SETTINGS_HELPER_H_ | |
6 #define CHROME_BROWSER_BANNERS_APP_BANNER_SETTINGS_HELPER_H_ | |
7 | |
8 #include <string> | |
9 #include <vector> | |
10 | |
11 #include "base/macros.h" | |
12 #include "base/time/time.h" | |
13 | |
14 namespace content { | |
15 class WebContents; | |
16 } // namespace content | |
17 | |
18 class GURL; | |
19 | |
20 // Utility class for reading and updating ContentSettings for app banners. | |
21 class AppBannerSettingsHelper { | |
22 public: | |
23 // TODO(benwells): Use this method to implement smarter triggering logic. | |
24 // See http://crbug.com/452825. | |
25 // Records that a banner could have been shown for the given package or start | |
26 // url. | |
27 // | |
28 // These events are used to decide when banners should be shown, using a | |
29 // heuristic based on how many different days in a recent period of time (for | |
30 // example the past two weeks) the banner could have been shown. The desired | |
31 // effect is to have banners appear once a user has demonstrated an ongoing | |
32 // relationship with the app. | |
33 // | |
34 // At most one event is stored per day, and events outside the window the | |
35 // heuristic uses are discarded. Local times are used to enforce these rules, | |
36 // to ensure what we count as a day matches what the user perceives to be | |
37 // days. | |
38 static void RecordCouldShowBannerEvent( | |
39 content::WebContents* web_contents, | |
40 const GURL& origin_url, | |
41 const std::string& package_name_or_start_url, | |
42 base::Time time); | |
43 | |
44 // Gets the could have been shown events that are stored for the given package | |
45 // or start url. This is only used for testing. | |
46 static std::vector<base::Time> GetCouldShowBannerEvents( | |
47 content::WebContents* web_contents, | |
48 const GURL& origin_url, | |
49 const std::string& package_name_or_start_url); | |
50 | |
51 // Checks if a URL is allowed to show a banner for the given package or start | |
52 // url. | |
53 static bool IsAllowed(content::WebContents* web_contents, | |
54 const GURL& origin_url, | |
55 const std::string& package_name_or_start_url); | |
56 | |
57 // Blocks a URL from showing a banner for the given package or start url. | |
58 static void Block(content::WebContents* web_contents, | |
59 const GURL& origin_url, | |
60 const std::string& package_name_or_start_url); | |
61 | |
62 private: | |
63 DISALLOW_IMPLICIT_CONSTRUCTORS(AppBannerSettingsHelper); | |
64 }; | |
65 | |
66 #endif // CHROME_BROWSER_BANNERS_APP_BANNER_SETTINGS_HELPER_H_ | |
OLD | NEW |