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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved.
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 IOS_CHROME_BROWSER_UI_NTP_NOTIFICATION_PROMO_WHATS_NEW_H_
6 #define IOS_CHROME_BROWSER_UI_NTP_NOTIFICATION_PROMO_WHATS_NEW_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "base/macros.h"
12 #include "ios/chrome/browser/notification_promo.h"
13 #include "ios/public/provider/chrome/browser/images/whats_new_icon.h"
14 #include "url/gurl.h"
15
16 namespace base {
17 class DictionaryValue;
18 }
19
20 // Helper class for NotificationPromo that deals with mobile_ntp promos.
21 class NotificationPromoWhatsNew {
22 public:
23 explicit NotificationPromoWhatsNew(PrefService* local_state);
24 ~NotificationPromoWhatsNew();
25
26 // Initialize from variations/prefs/JSON.
27 // Return true if the mobile NTP promotion is valid.
28 bool Init();
29
30 // Used by experimental setting to always show a promo.
31 bool ClearAndInitFromJson(const base::DictionaryValue& json);
32
33 // Return true if the promo is valid and can be shown.
34 bool CanShow() const;
35
36 // Mark the promo as closed when the user dismisses it.
37 void HandleClosed();
38
39 // Mark the promo as having been viewed.
40 void HandleViewed();
41
42 bool valid() const { return valid_; }
43 const std::string& promo_type() { return promo_type_; }
44 const std::string& promo_text() { return promo_text_; }
45 const std::string& promo_name() { return promo_name_; }
46 WhatsNewIcon icon() { return icon_; }
47 bool IsURLPromo() const;
48 const GURL& url() { return url_; }
49 bool IsChromeCommand() const;
50 int command_id() { return command_id_; }
51
52 private:
53 // Initialize the state and validity from the low-level notification_promo_.
54 bool InitFromNotificationPromo();
55
56 // Inject a fake promo. The parameters are equivalent to the equivalent
57 // parameters that can be provided by the variations API. In addition, for
58 // some variations parameters that are not in this list, the following
59 // defaults are used: start: 1 Jan 1999 0:26:06 GMT,
60 // end: 1 Jan 2199 0:26:06 GMT, max_views: 20, max_seconds: 259200.
61 void InjectFakePromo(const std::string& promo_id,
62 const std::string& promo_text,
63 const std::string& promo_type,
64 const std::string& command,
65 const std::string& url,
66 const std::string& metric_name,
67 const std::string& icon);
68
69 // Prefs service for promos.
70 PrefService* local_state_;
71
72 // True if InitFromPrefs/JSON was called and all mandatory fields were found.
73 bool valid_;
74
75 // Text of promo.
76 std::string promo_text_;
77
78 // Type of whats new promo.
79 std::string promo_type_;
80
81 // Name of promo.
82 std::string promo_name_;
83
84 // Icon of promo.
85 WhatsNewIcon icon_;
86
87 // The minimum number of seconds from installation before promo can be valid.
88 // E.g. Don't show the promo if installation was within N days.
89 int seconds_since_install_;
90
91 // The duration after installation that the promo can be valid.
92 // E.g. Don't show the promo if installation was more than N days ago.
93 int max_seconds_since_install_;
94
95 // If promo type is 'url'.
96 GURL url_;
97
98 // If promo type is 'chrome_command'.
99 int command_id_;
100
101 // Metric name to append
102 std::string metric_name_;
103
104 // The lower-level notification promo.
105 ios::NotificationPromo notification_promo_;
106
107 // Convert an icon name string to WhatsNewIcon.
108 WhatsNewIcon ParseIconName(const std::string& icon_name);
109
110 DISALLOW_COPY_AND_ASSIGN(NotificationPromoWhatsNew);
111 };
112
113 #endif // IOS_CHROME_BROWSER_UI_NTP_NOTIFICATION_PROMO_WHATS_NEW_H_
OLDNEW
« 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