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

Unified Diff: chrome/browser/banners/app_banner_settings_helper.h

Issue 884373002: Update content setting for app banners to store more information. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Mac test failure Created 5 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/banners/OWNERS ('k') | chrome/browser/banners/app_banner_settings_helper.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/banners/app_banner_settings_helper.h
diff --git a/chrome/browser/banners/app_banner_settings_helper.h b/chrome/browser/banners/app_banner_settings_helper.h
new file mode 100644
index 0000000000000000000000000000000000000000..241e592c12f86aa4807d918e7c486ee2b6f47e34
--- /dev/null
+++ b/chrome/browser/banners/app_banner_settings_helper.h
@@ -0,0 +1,66 @@
+// 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
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_BANNERS_APP_BANNER_SETTINGS_HELPER_H_
+#define CHROME_BROWSER_BANNERS_APP_BANNER_SETTINGS_HELPER_H_
+
+#include <string>
+#include <vector>
+
+#include "base/macros.h"
+#include "base/time/time.h"
+
+namespace content {
+class WebContents;
+} // namespace content
+
+class GURL;
+
+// Utility class for reading and updating ContentSettings for app banners.
+class AppBannerSettingsHelper {
+ public:
+ // TODO(benwells): Use this method to implement smarter triggering logic.
+ // See http://crbug.com/452825.
+ // Records that a banner could have been shown for the given package or start
+ // url.
+ //
+ // These events are used to decide when banners should be shown, using a
+ // heuristic based on how many different days in a recent period of time (for
+ // example the past two weeks) the banner could have been shown. The desired
+ // effect is to have banners appear once a user has demonstrated an ongoing
+ // relationship with the app.
+ //
+ // At most one event is stored per day, and events outside the window the
+ // heuristic uses are discarded. Local times are used to enforce these rules,
+ // to ensure what we count as a day matches what the user perceives to be
+ // days.
+ static void RecordCouldShowBannerEvent(
+ content::WebContents* web_contents,
+ const GURL& origin_url,
+ const std::string& package_name_or_start_url,
+ base::Time time);
+
+ // Gets the could have been shown events that are stored for the given package
+ // or start url. This is only used for testing.
+ static std::vector<base::Time> GetCouldShowBannerEvents(
+ content::WebContents* web_contents,
+ const GURL& origin_url,
+ const std::string& package_name_or_start_url);
+
+ // Checks if a URL is allowed to show a banner for the given package or start
+ // url.
+ static bool IsAllowed(content::WebContents* web_contents,
+ const GURL& origin_url,
+ const std::string& package_name_or_start_url);
+
+ // Blocks a URL from showing a banner for the given package or start url.
+ static void Block(content::WebContents* web_contents,
+ const GURL& origin_url,
+ const std::string& package_name_or_start_url);
+
+ private:
+ DISALLOW_IMPLICIT_CONSTRUCTORS(AppBannerSettingsHelper);
+};
+
+#endif // CHROME_BROWSER_BANNERS_APP_BANNER_SETTINGS_HELPER_H_
« no previous file with comments | « chrome/browser/banners/OWNERS ('k') | chrome/browser/banners/app_banner_settings_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698