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