ChromeNotifierDelegate::~ChromeNotifierDelegate() {}
-std::string ChromeNotifierDelegate::id() const {
- return notification_id_;
-}
+void ChromeNotifierDelegate::Close(bool by_user) {
+ if (by_user)
+ chrome_notifier_->MarkNotificationAsRead(notification_id_);
-content::RenderViewHost* ChromeNotifierDelegate::GetRenderViewHost() const {
- return NULL;
+ CollectAction(by_user ?
+ SYNCED_NOTIFICATION_ACTION_CLOSE_BY_USER :
+ SYNCED_NOTIFICATION_ACTION_CLOSE_BY_SYSTEM);
}
-void ChromeNotifierDelegate::CollectAction(SyncedNotificationActionType type) {
- DCHECK(!notification_id_.empty());
-
- UMA_HISTOGRAM_ENUMERATION("SyncedNotifications.Actions",
- type,
- SYNCED_NOTIFICATION_ACTION_COUNT);
+bool ChromeNotifierDelegate::HasClickedListener() {
+ return GetClickDestination().is_valid();
}
-
-// TODO(petewil) Add the ability to do URL actions also.
void ChromeNotifierDelegate::Click() {
- SyncedNotification* notification =
- chrome_notifier_->FindNotificationById(notification_id_);
- if (notification == NULL)
- return;
-
- GURL destination = notification->GetDefaultDestinationUrl();
+ GURL destination = GetClickDestination();
NavigateToUrl(destination);
chrome_notifier_->MarkNotificationAsRead(notification_id_);
CollectAction(SYNCED_NOTIFICATION_ACTION_CLICK);
}
-// TODO(petewil) Add the ability to do URL actions also.
void ChromeNotifierDelegate::ButtonClick(int button_index) {
SyncedNotification* notification =
chrome_notifier_->FindNotificationById(notification_id_);
CollectAction(SYNCED_NOTIFICATION_ACTION_BUTTON_CLICK);
}
+std::string ChromeNotifierDelegate::id() const {
+ return notification_id_;
+}
+
+content::RenderViewHost* ChromeNotifierDelegate::GetRenderViewHost() const {
+ return NULL;
+}
+
+void ChromeNotifierDelegate::CollectAction(SyncedNotificationActionType type) {
+ DCHECK(!notification_id_.empty());
+
+ UMA_HISTOGRAM_ENUMERATION("SyncedNotifications.Actions",
+ type,
+ SYNCED_NOTIFICATION_ACTION_COUNT);
+}
+
void ChromeNotifierDelegate::NavigateToUrl(const GURL& destination) const {
if (!destination.is_valid())
return;
displayer.browser()->window()->Activate();
}
-void ChromeNotifierDelegate::Close(bool by_user) {
- if (by_user)
- chrome_notifier_->MarkNotificationAsRead(notification_id_);
+const GURL ChromeNotifierDelegate::GetClickDestination() const {
+ SyncedNotification* notification =
+ chrome_notifier_->FindNotificationById(notification_id_);
+ if (notification == NULL)
+ return GURL();
- CollectAction(by_user ?
- SYNCED_NOTIFICATION_ACTION_CLOSE_BY_USER :
- SYNCED_NOTIFICATION_ACTION_CLOSE_BY_SYSTEM);
+ return notification->GetDefaultDestinationUrl();
}
} // namespace notifier