#ifndef CHROME_BROWSER_NOTIFICATIONS_SYNC_NOTIFIER_SYNCED_NOTIFICATION_H_
#define CHROME_BROWSER_NOTIFICATIONS_SYNC_NOTIFIER_SYNCED_NOTIFICATION_H_
#include <string>
#include "base/gtest_prod_util.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/scoped_vector.h"
#include "chrome/browser/bitmap_fetcher.h"
#include "sync/api/sync_data.h"
#include "sync/protocol/sync.pb.h"
#include "ui/gfx/image/image.h"
#include "url/gurl.h"
namespace sync_pb {
class SyncedNotificationSpecifics;
}
class NotificationUIManager;
class Profile;
namespace notifier {
class ChromeNotifierService;
class SyncedNotification : public chrome::BitmapFetcherDelegate {
public:
SyncedNotification(const syncer::SyncData& sync_data,
ChromeNotifierService* notifier,
NotificationUIManager* notification_manager);
virtual ~SyncedNotification();
enum ReadState {
kUnread = 1,
kRead = 2,
kDismissed = 3,
};
static const int kUndefinedPriority = 65535;
void Update(const syncer::SyncData& sync_data);
void Show(Profile* profile);
sync_pb::EntitySpecifics GetEntitySpecifics() const;
void ShowAllForAppId(Profile* profile,
std::string app_id_name);
void HideAllForAppId(std::string app_id_name);
void QueueBitmapFetchJobs(ChromeNotifierService* notifier_service,
Profile* profile);
void StartBitmapFetch();
bool EqualsIgnoringReadState(const SyncedNotification& other) const;
void NotificationHasBeenRead();
void NotificationHasBeenDismissed();
std::string GetTitle() const;
std::string GetHeading() const;
std::string GetDescription() const;
std::string GetAnnotation() const;
std::string GetAppId() const;
std::string GetKey() const;
GURL GetOriginUrl() const;
GURL GetAppIconUrl() const;
GURL GetImageUrl() const;
std::string GetText() const;
ReadState GetReadState() const;
uint64 GetCreationTime() const;
int GetPriority() const;
std::string GetDefaultDestinationTitle() const;
GURL GetDefaultDestinationIconUrl() const;
GURL GetDefaultDestinationUrl() const;
std::string GetButtonTitle(unsigned int which_button) const;
GURL GetButtonIconUrl(unsigned int which_button) const;
GURL GetButtonUrl(unsigned int which_button) const;
GURL GetProfilePictureUrl(unsigned int which_url) const;
size_t GetProfilePictureCount() const;
size_t GetNotificationCount() const;
size_t GetButtonCount() const;
std::string GetContainedNotificationTitle(int index) const;
std::string GetContainedNotificationMessage(int index) const;
const gfx::Image& GetAppIcon() const;
void set_toast_state(bool toast_state);
void LogNotification();
private:
virtual void OnFetchComplete(const GURL url, const SkBitmap* bitmap) OVERRIDE;
void CreateBitmapFetcher(const GURL& gurl);
bool AreAllBitmapsFetched();
void SetReadState(const ReadState& read_state);
void SetNotifierServiceForTest(ChromeNotifierService* notifier) {
notifier_service_ = notifier;
}
sync_pb::SyncedNotificationSpecifics specifics_;
NotificationUIManager* notification_manager_;
ChromeNotifierService* notifier_service_;
Profile* profile_;
bool toast_state_;
ScopedVector<chrome::BitmapFetcher> fetchers_;
gfx::Image app_icon_bitmap_;
gfx::Image sender_bitmap_;
gfx::Image image_bitmap_;
std::vector<gfx::Image> button_bitmaps_;
bool app_icon_bitmap_fetch_pending_;
bool sender_bitmap_fetch_pending_;
bool image_bitmap_fetch_pending_;
std::vector<bool> button_bitmaps_fetch_pending_;
friend class SyncedNotificationTest;
FRIEND_TEST_ALL_PREFIXES(SyncedNotificationTest, CreateBitmapFetcherTest);
FRIEND_TEST_ALL_PREFIXES(SyncedNotificationTest, OnFetchCompleteTest);
FRIEND_TEST_ALL_PREFIXES(SyncedNotificationTest, QueueBitmapFetchJobsTest);
FRIEND_TEST_ALL_PREFIXES(SyncedNotificationTest, EmptyBitmapTest);
FRIEND_TEST_ALL_PREFIXES(SyncedNotificationTest, ShowIfNewlyEnabledTest);
FRIEND_TEST_ALL_PREFIXES(SyncedNotificationTest, HideIfNewlyRemovedTest);
FRIEND_TEST_ALL_PREFIXES(ChromeNotifierServiceTest, SetAddedAppIdsTest);
DISALLOW_COPY_AND_ASSIGN(SyncedNotification);
};
}
#endif