15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved. 25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file. 45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef CHROME_BROWSER_WEB_RESOURCE_NOTIFICATION_PROMO_MOBILE_NTP_H_ 65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define CHROME_BROWSER_WEB_RESOURCE_NOTIFICATION_PROMO_MOBILE_NTP_H_ 75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <string> 95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/basictypes.h" 115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/web_resource/notification_promo.h" 125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace base { 145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class DictionaryValue; 155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class ListValue; 165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Helper class for NotificationPromo that deals with mobile_ntp promos. 195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class NotificationPromoMobileNtp { 205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public: 212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) NotificationPromoMobileNtp(); 225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ~NotificationPromoMobileNtp(); 235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Initialize from prefs/JSON. 255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Return true if the mobile NTP promotion is valid. 265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool InitFromPrefs(); 275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool InitFromJson(const base::DictionaryValue& json); 285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Return true if the promo is valid and can be shown. 305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool CanShow() const; 315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool valid() const { return valid_; } 335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const std::string& text() const { return text_; } 345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const std::string& text_long() const { return text_long_; } 355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const std::string& action_type() const { return action_type_; } 365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const base::ListValue* action_args() const { return action_args_; } 375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool requires_mobile_only_sync() const { return requires_mobile_only_sync_; } 385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool requires_sync() const { return requires_sync_; } 395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool show_on_most_visited() const { return show_on_most_visited_; } 405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool show_on_open_tabs() const { return show_on_open_tabs_; } 415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool show_as_virtual_computer() const { return show_as_virtual_computer_; } 425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const std::string& virtual_computer_title() const { 435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return virtual_computer_title_; 445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const std::string& virtual_computer_lastsync() const { 465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return virtual_computer_lastsync_; 475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const base::DictionaryValue* payload() const { return payload_; } 495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const NotificationPromo& notification_promo() const { 505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return notification_promo_; 515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) private: 545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Initialize the state and validity from the low-level notification_promo_. 555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool InitFromNotificationPromo(); 565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // True if InitFromPrefs/JSON was called and all mandatory fields were found. 585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool valid_; 595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The short text of the promotion (e.g. for Most Visited and Open Tabs). 605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) std::string text_; 615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The long text of the promotion (e.g. for Open Tabs when no tabs are open). 625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) std::string text_long_; 635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The action that the promotion triggers (e.g. "ACTION_EMAIL"). 645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) std::string action_type_; 655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The title of the virtual computer (e.g. when shown on Open Tabs). 665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) std::string virtual_computer_title_; 675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The detailed info for the virtual computer (e.g. when shown on Open Tabs). 685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) std::string virtual_computer_lastsync_; 695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // True if the promo should be shown only if no desktop sessions were open. 705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool requires_mobile_only_sync_; 715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // True if the promo should be shown only if the user is signed in to Chrome. 725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool requires_sync_; 735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // True if the promo should be shown on Most Visited pane. 745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool show_on_most_visited_; 755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // True if the promo should be shown on Open Tabs pane. 765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool show_on_open_tabs_; 775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // True if the promo should show the virtual computer (e.g. on Open Tabs). 785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool show_as_virtual_computer_; 795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Arguments for the action (e.g. [subject, body] for "ACTION_EMAIL"). 805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const base::ListValue* action_args_; 815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The entire payload for the promo. 825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const base::DictionaryValue* payload_; 835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The lower-level notification promo. 845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) NotificationPromo notification_promo_; 855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(NotificationPromoMobileNtp); 875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}; 885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif // CHROME_BROWSER_WEB_RESOURCE_NOTIFICATION_PROMO_MOBILE_NTP_H_ 90