Commit 5d654b92 authored by juyik@chromium.org's avatar juyik@chromium.org

Rename notification_id() to disambiguate its meaning.

As an intermediate step to disambiguate notifications
at notification UI manager level, we rename notification_id()
to delegate_id() to clarify that it is not an id for
notification in message center.

Also change assignment operator of message center's
notification to protected. Other members are still used by
notification list so they need to be public.

BUG=297867

Review URL: https://codereview.chromium.org/344763002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@278593 0039d316-1c4b-4281-b951-d872f2087c98
parent 995127b8
...@@ -383,7 +383,7 @@ std::string DesktopNotificationService::AddIconNotification( ...@@ -383,7 +383,7 @@ std::string DesktopNotificationService::AddIconNotification(
blink::WebTextDirectionDefault, blink::WebTextDirectionDefault,
base::string16(), replace_id, delegate); base::string16(), replace_id, delegate);
g_browser_process->notification_ui_manager()->Add(notification, profile); g_browser_process->notification_ui_manager()->Add(notification, profile);
return notification.notification_id(); return notification.delegate_id();
} }
DesktopNotificationService::DesktopNotificationService( DesktopNotificationService::DesktopNotificationService(
......
...@@ -137,7 +137,7 @@ bool MessageCenterNotificationManager::Update(const Notification& notification, ...@@ -137,7 +137,7 @@ bool MessageCenterNotificationManager::Update(const Notification& notification,
// Changing the type from non-progress to progress does not count towards // Changing the type from non-progress to progress does not count towards
// the immediate update allowed in the message center. // the immediate update allowed in the message center.
std::string old_id = std::string old_id =
old_notification->notification().notification_id(); old_notification->notification().delegate_id();
DCHECK(message_center_->FindVisibleNotificationById(old_id)); DCHECK(message_center_->FindVisibleNotificationById(old_id));
// Add/remove notification in the local list but just update the same // Add/remove notification in the local list but just update the same
...@@ -146,7 +146,7 @@ bool MessageCenterNotificationManager::Update(const Notification& notification, ...@@ -146,7 +146,7 @@ bool MessageCenterNotificationManager::Update(const Notification& notification,
profile_notifications_.erase(old_id); profile_notifications_.erase(old_id);
ProfileNotification* new_notification = ProfileNotification* new_notification =
new ProfileNotification(profile, notification, message_center_); new ProfileNotification(profile, notification, message_center_);
profile_notifications_[notification.notification_id()] = new_notification; profile_notifications_[notification.delegate_id()] = new_notification;
// Now pass a copy to message center. // Now pass a copy to message center.
scoped_ptr<message_center::Notification> message_center_notification( scoped_ptr<message_center::Notification> message_center_notification(
...@@ -323,7 +323,7 @@ void MessageCenterNotificationManager::ImageDownloads::StartDownloads( ...@@ -323,7 +323,7 @@ void MessageCenterNotificationManager::ImageDownloads::StartDownloads(
notification.icon_url(), notification.icon_url(),
base::Bind(&message_center::MessageCenter::SetNotificationIcon, base::Bind(&message_center::MessageCenter::SetNotificationIcon,
base::Unretained(message_center_), base::Unretained(message_center_),
notification.notification_id())); notification.delegate_id()));
// Notification image. // Notification image.
StartDownloadWithImage( StartDownloadWithImage(
...@@ -332,7 +332,7 @@ void MessageCenterNotificationManager::ImageDownloads::StartDownloads( ...@@ -332,7 +332,7 @@ void MessageCenterNotificationManager::ImageDownloads::StartDownloads(
notification.image_url(), notification.image_url(),
base::Bind(&message_center::MessageCenter::SetNotificationImage, base::Bind(&message_center::MessageCenter::SetNotificationImage,
base::Unretained(message_center_), base::Unretained(message_center_),
notification.notification_id())); notification.delegate_id()));
// Notification button icons. // Notification button icons.
StartDownloadWithImage( StartDownloadWithImage(
...@@ -341,7 +341,7 @@ void MessageCenterNotificationManager::ImageDownloads::StartDownloads( ...@@ -341,7 +341,7 @@ void MessageCenterNotificationManager::ImageDownloads::StartDownloads(
notification.button_one_icon_url(), notification.button_one_icon_url(),
base::Bind(&message_center::MessageCenter::SetNotificationButtonIcon, base::Bind(&message_center::MessageCenter::SetNotificationButtonIcon,
base::Unretained(message_center_), base::Unretained(message_center_),
notification.notification_id(), notification.delegate_id(),
0)); 0));
StartDownloadWithImage( StartDownloadWithImage(
notification, notification,
...@@ -349,7 +349,7 @@ void MessageCenterNotificationManager::ImageDownloads::StartDownloads( ...@@ -349,7 +349,7 @@ void MessageCenterNotificationManager::ImageDownloads::StartDownloads(
notification.button_two_icon_url(), notification.button_two_icon_url(),
base::Bind(&message_center::MessageCenter::SetNotificationButtonIcon, base::Bind(&message_center::MessageCenter::SetNotificationButtonIcon,
base::Unretained(message_center_), base::Unretained(message_center_),
notification.notification_id(), notification.delegate_id(),
1)); 1));
// This should tell the observer we're done if everything was synchronous. // This should tell the observer we're done if everything was synchronous.
...@@ -472,7 +472,7 @@ std::string ...@@ -472,7 +472,7 @@ std::string
void MessageCenterNotificationManager::AddProfileNotification( void MessageCenterNotificationManager::AddProfileNotification(
ProfileNotification* profile_notification) { ProfileNotification* profile_notification) {
const Notification& notification = profile_notification->notification(); const Notification& notification = profile_notification->notification();
std::string id = notification.notification_id(); std::string id = notification.delegate_id();
// Notification ids should be unique. // Notification ids should be unique.
DCHECK(profile_notifications_.find(id) == profile_notifications_.end()); DCHECK(profile_notifications_.find(id) == profile_notifications_.end());
profile_notifications_[id] = profile_notification; profile_notifications_[id] = profile_notification;
...@@ -487,7 +487,7 @@ void MessageCenterNotificationManager::AddProfileNotification( ...@@ -487,7 +487,7 @@ void MessageCenterNotificationManager::AddProfileNotification(
void MessageCenterNotificationManager::RemoveProfileNotification( void MessageCenterNotificationManager::RemoveProfileNotification(
ProfileNotification* profile_notification) { ProfileNotification* profile_notification) {
std::string id = profile_notification->notification().notification_id(); std::string id = profile_notification->notification().delegate_id();
profile_notifications_.erase(id); profile_notifications_.erase(id);
delete profile_notification; delete profile_notification;
} }
......
...@@ -82,7 +82,8 @@ class Notification : public message_center::Notification { ...@@ -82,7 +82,8 @@ class Notification : public message_center::Notification {
// A url for the image to be shown (optional). // A url for the image to be shown (optional).
const GURL& image_url() const { return image_url_; } const GURL& image_url() const { return image_url_; }
std::string notification_id() const { return delegate()->id(); } // Id of the delegate embedded inside this instance.
std::string delegate_id() const { return delegate()->id(); }
int process_id() const { return delegate()->process_id(); } int process_id() const { return delegate()->process_id(); }
content::WebContents* GetWebContents() const { content::WebContents* GetWebContents() const {
......
...@@ -65,7 +65,7 @@ StubNotificationUIManager::GetAllIdsByProfileAndSourceOrigin( ...@@ -65,7 +65,7 @@ StubNotificationUIManager::GetAllIdsByProfileAndSourceOrigin(
const GURL& source) { const GURL& source) {
std::set<std::string> notification_ids; std::set<std::string> notification_ids;
if (source == notification_.origin_url() && profile->IsSameProfile(profile_)) if (source == notification_.origin_url() && profile->IsSameProfile(profile_))
notification_ids.insert(notification_.notification_id()); notification_ids.insert(notification_.delegate_id());
return notification_ids; return notification_ids;
} }
......
...@@ -66,8 +66,6 @@ class MESSAGE_CENTER_EXPORT Notification { ...@@ -66,8 +66,6 @@ class MESSAGE_CENTER_EXPORT Notification {
Notification(const Notification& other); Notification(const Notification& other);
Notification& operator=(const Notification& other);
virtual ~Notification(); virtual ~Notification();
// Copies the internal on-memory state from |base|, i.e. shown_as_popup, // Copies the internal on-memory state from |base|, i.e. shown_as_popup,
...@@ -202,6 +200,8 @@ class MESSAGE_CENTER_EXPORT Notification { ...@@ -202,6 +200,8 @@ class MESSAGE_CENTER_EXPORT Notification {
const base::Closure& click_callback); const base::Closure& click_callback);
protected: protected:
Notification& operator=(const Notification& other);
// The type of notification we'd like displayed. // The type of notification we'd like displayed.
NotificationType type_; NotificationType type_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment