This source file includes following definitions.
- UpdateMessageCenter
- notifier_id_
- Display
- Error
- Close
- Click
- ButtonClick
- id
- GetRenderViewHost
#include "base/message_loop/message_loop.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/notifications/desktop_notification_service.h"
#include "chrome/browser/notifications/desktop_notification_service_factory.h"
#include "chrome/browser/notifications/message_center_notification_manager.h"
#include "chrome/browser/notifications/notification_ui_manager.h"
#include "chrome/browser/notifications/sync_notifier/chrome_notifier_service.h"
#include "chrome/browser/notifications/sync_notifier/chrome_notifier_service_factory.h"
#include "chrome/browser/notifications/sync_notifier/welcome_delegate.h"
#include "chrome/browser/profiles/profile.h"
#include "ui/message_center/message_center.h"
#include "ui/message_center/message_center_util.h"
namespace notifier {
namespace {
void UpdateMessageCenter() {
NotificationUIManager* notification_ui_manager =
g_browser_process->notification_ui_manager();
if (notification_ui_manager->DelegatesToMessageCenter()) {
MessageCenterNotificationManager* message_center_notification_manager =
static_cast<MessageCenterNotificationManager*>(notification_ui_manager);
message_center_notification_manager->EnsureMessageCenterClosed();
}
}
}
WelcomeDelegate::WelcomeDelegate(const std::string& notification_id,
Profile* profile,
const message_center::NotifierId notifier_id)
: notification_id_(notification_id),
profile_(profile),
notifier_id_(notifier_id) {
DCHECK_EQ(message_center::NotifierId::SYNCED_NOTIFICATION_SERVICE,
notifier_id.type);
}
WelcomeDelegate::~WelcomeDelegate() {}
void WelcomeDelegate::Display() {}
void WelcomeDelegate::Error() {}
void WelcomeDelegate::Close(bool by_user) {}
void WelcomeDelegate::Click() {
g_browser_process->notification_ui_manager()->CancelById(notification_id_);
UpdateMessageCenter();
}
void WelcomeDelegate::ButtonClick(int button_index) {
DCHECK_EQ(0, button_index);
scoped_refptr<WelcomeDelegate> this_ptr(this);
g_browser_process->notification_ui_manager()->CancelById(notification_id_);
DesktopNotificationService* notification_service =
DesktopNotificationServiceFactory::GetForProfile(profile_);
if (notification_service)
notification_service->SetNotifierEnabled(notifier_id_, false);
ChromeNotifierService* notifier_service =
ChromeNotifierServiceFactory::GetForProfile(profile_,
Profile::EXPLICIT_ACCESS);
if (notifier_service) {
notifier_service->OnSyncedNotificationServiceEnabled(notifier_id_.id,
false);
}
UpdateMessageCenter();
}
std::string WelcomeDelegate::id() const { return notification_id_; }
content::RenderViewHost* WelcomeDelegate::GetRenderViewHost() const {
return NULL;
}
}