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

Unified Diff: ios/chrome/browser/ui/ntp/notification_promo_whats_new.h

Issue 2589803002: Upstream Chrome on iOS source code [6/11]. (Closed)
Patch Set: Created 4 years 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
Index: ios/chrome/browser/ui/ntp/notification_promo_whats_new.h
diff --git a/ios/chrome/browser/ui/ntp/notification_promo_whats_new.h b/ios/chrome/browser/ui/ntp/notification_promo_whats_new.h
new file mode 100644
index 0000000000000000000000000000000000000000..31a74f300eab4065ca199200a9c1e0b9fa4b79c1
--- /dev/null
+++ b/ios/chrome/browser/ui/ntp/notification_promo_whats_new.h
@@ -0,0 +1,113 @@
+// Copyright (c) 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef IOS_CHROME_BROWSER_UI_NTP_NOTIFICATION_PROMO_WHATS_NEW_H_
+#define IOS_CHROME_BROWSER_UI_NTP_NOTIFICATION_PROMO_WHATS_NEW_H_
+
+#include <string>
+#include <vector>
+
+#include "base/macros.h"
+#include "ios/chrome/browser/notification_promo.h"
+#include "ios/public/provider/chrome/browser/images/whats_new_icon.h"
+#include "url/gurl.h"
+
+namespace base {
+class DictionaryValue;
+}
+
+// Helper class for NotificationPromo that deals with mobile_ntp promos.
+class NotificationPromoWhatsNew {
+ public:
+ explicit NotificationPromoWhatsNew(PrefService* local_state);
+ ~NotificationPromoWhatsNew();
+
+ // Initialize from variations/prefs/JSON.
+ // Return true if the mobile NTP promotion is valid.
+ bool Init();
+
+ // Used by experimental setting to always show a promo.
+ bool ClearAndInitFromJson(const base::DictionaryValue& json);
+
+ // Return true if the promo is valid and can be shown.
+ bool CanShow() const;
+
+ // Mark the promo as closed when the user dismisses it.
+ void HandleClosed();
+
+ // Mark the promo as having been viewed.
+ void HandleViewed();
+
+ bool valid() const { return valid_; }
+ const std::string& promo_type() { return promo_type_; }
+ const std::string& promo_text() { return promo_text_; }
+ const std::string& promo_name() { return promo_name_; }
+ WhatsNewIcon icon() { return icon_; }
+ bool IsURLPromo() const;
+ const GURL& url() { return url_; }
+ bool IsChromeCommand() const;
+ int command_id() { return command_id_; }
+
+ private:
+ // Initialize the state and validity from the low-level notification_promo_.
+ bool InitFromNotificationPromo();
+
+ // Inject a fake promo. The parameters are equivalent to the equivalent
+ // parameters that can be provided by the variations API. In addition, for
+ // some variations parameters that are not in this list, the following
+ // defaults are used: start: 1 Jan 1999 0:26:06 GMT,
+ // end: 1 Jan 2199 0:26:06 GMT, max_views: 20, max_seconds: 259200.
+ void InjectFakePromo(const std::string& promo_id,
+ const std::string& promo_text,
+ const std::string& promo_type,
+ const std::string& command,
+ const std::string& url,
+ const std::string& metric_name,
+ const std::string& icon);
+
+ // Prefs service for promos.
+ PrefService* local_state_;
+
+ // True if InitFromPrefs/JSON was called and all mandatory fields were found.
+ bool valid_;
+
+ // Text of promo.
+ std::string promo_text_;
+
+ // Type of whats new promo.
+ std::string promo_type_;
+
+ // Name of promo.
+ std::string promo_name_;
+
+ // Icon of promo.
+ WhatsNewIcon icon_;
+
+ // The minimum number of seconds from installation before promo can be valid.
+ // E.g. Don't show the promo if installation was within N days.
+ int seconds_since_install_;
+
+ // The duration after installation that the promo can be valid.
+ // E.g. Don't show the promo if installation was more than N days ago.
+ int max_seconds_since_install_;
+
+ // If promo type is 'url'.
+ GURL url_;
+
+ // If promo type is 'chrome_command'.
+ int command_id_;
+
+ // Metric name to append
+ std::string metric_name_;
+
+ // The lower-level notification promo.
+ ios::NotificationPromo notification_promo_;
+
+ // Convert an icon name string to WhatsNewIcon.
+ WhatsNewIcon ParseIconName(const std::string& icon_name);
+
+ DISALLOW_COPY_AND_ASSIGN(NotificationPromoWhatsNew);
+};
+
+#endif // IOS_CHROME_BROWSER_UI_NTP_NOTIFICATION_PROMO_WHATS_NEW_H_
« no previous file with comments | « ios/chrome/browser/ui/ntp/new_tab_page_view.mm ('k') | ios/chrome/browser/ui/ntp/notification_promo_whats_new.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698