1 // Copyright (c) 2012 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.
5 #ifndef COMPONENTS_WEB_RESOURCE_NOTIFICATION_PROMO_MOBILE_NTP_H_
6 #define COMPONENTS_WEB_RESOURCE_NOTIFICATION_PROMO_MOBILE_NTP_H_
10 #include "base/basictypes.h"
11 #include "components/web_resource/notification_promo.h"
14 class DictionaryValue
;
20 namespace web_resource
{
22 // Helper class for NotificationPromo that deals with mobile_ntp promos.
23 class NotificationPromoMobileNtp
{
25 explicit NotificationPromoMobileNtp(PrefService
* local_state
);
26 ~NotificationPromoMobileNtp();
28 // Initialize from prefs/JSON.
29 // Return true if the mobile NTP promotion is valid.
31 bool InitFromJson(const base::DictionaryValue
& json
);
33 // Return true if the promo is valid and can be shown.
36 bool valid() const { return valid_
; }
37 const std::string
& text() const { return text_
; }
38 const std::string
& text_long() const { return text_long_
; }
39 const std::string
& action_type() const { return action_type_
; }
40 const base::ListValue
* action_args() const { return action_args_
; }
41 bool requires_mobile_only_sync() const { return requires_mobile_only_sync_
; }
42 bool requires_sync() const { return requires_sync_
; }
43 bool show_on_most_visited() const { return show_on_most_visited_
; }
44 bool show_on_open_tabs() const { return show_on_open_tabs_
; }
45 bool show_as_virtual_computer() const { return show_as_virtual_computer_
; }
46 const std::string
& virtual_computer_title() const {
47 return virtual_computer_title_
;
49 const std::string
& virtual_computer_lastsync() const {
50 return virtual_computer_lastsync_
;
52 const base::DictionaryValue
* payload() const { return payload_
; }
53 const NotificationPromo
& notification_promo() const {
54 return notification_promo_
;
58 // Initialize the state and validity from the low-level notification_promo_.
59 bool InitFromNotificationPromo();
61 // True if InitFromPrefs/JSON was called and all mandatory fields were found.
63 // The short text of the promotion (e.g. for Most Visited and Open Tabs).
65 // The long text of the promotion (e.g. for Open Tabs when no tabs are open).
66 std::string text_long_
;
67 // The action that the promotion triggers (e.g. "ACTION_EMAIL").
68 std::string action_type_
;
69 // The title of the virtual computer (e.g. when shown on Open Tabs).
70 std::string virtual_computer_title_
;
71 // The detailed info for the virtual computer (e.g. when shown on Open Tabs).
72 std::string virtual_computer_lastsync_
;
73 // True if the promo should be shown only if no desktop sessions were open.
74 bool requires_mobile_only_sync_
;
75 // True if the promo should be shown only if the user is signed in to Chrome.
77 // True if the promo should be shown on Most Visited pane.
78 bool show_on_most_visited_
;
79 // True if the promo should be shown on Open Tabs pane.
80 bool show_on_open_tabs_
;
81 // True if the promo should show the virtual computer (e.g. on Open Tabs).
82 bool show_as_virtual_computer_
;
83 // Arguments for the action (e.g. [subject, body] for "ACTION_EMAIL").
84 const base::ListValue
* action_args_
;
85 // The entire payload for the promo.
86 const base::DictionaryValue
* payload_
;
87 // The lower-level notification promo.
88 NotificationPromo notification_promo_
;
90 DISALLOW_COPY_AND_ASSIGN(NotificationPromoMobileNtp
);
93 } // namespace web_resource
95 #endif // COMPONENTS_WEB_RESOURCE_NOTIFICATION_PROMO_MOBILE_NTP_H_